Remove majority of warnings

There were a *lot* of warnings, managed to remove most of them.

Also, put warning flags before C_FLAGS and CXX_FLAGS, rather than after,
as -Wall -Wextra was overwriting flags that came before it.
This commit is contained in:
jp9000
2014-02-14 15:13:36 -07:00
parent 4bc282f5e9
commit 966b943d5b
46 changed files with 625 additions and 344 deletions

View File

@@ -39,9 +39,9 @@ struct audio_line {
char *name;
struct audio_output *audio;
struct circlebuf buffers[MAX_AUDIO_PLANES];
struct circlebuf buffers[MAX_AV_PLANES];
pthread_mutex_t mutex;
DARRAY(uint8_t) volume_buffers[MAX_AUDIO_PLANES];
DARRAY(uint8_t) volume_buffers[MAX_AV_PLANES];
uint64_t base_timestamp;
uint64_t last_timestamp;
@@ -55,7 +55,7 @@ struct audio_line {
static inline void audio_line_destroy_data(struct audio_line *line)
{
for (size_t i = 0; i < MAX_AUDIO_PLANES; i++) {
for (size_t i = 0; i < MAX_AV_PLANES; i++) {
circlebuf_free(&line->buffers[i]);
da_free(line->volume_buffers[i]);
}
@@ -74,7 +74,7 @@ struct audio_output {
pthread_t thread;
event_t stop_event;
DARRAY(uint8_t) mix_buffers[MAX_AUDIO_PLANES];
DARRAY(uint8_t) mix_buffers[MAX_AV_PLANES];
bool initialized;
@@ -196,7 +196,7 @@ static inline void do_audio_output(struct audio_output *audio,
uint64_t timestamp, uint32_t frames)
{
struct audio_data data;
for (size_t i = 0; i < MAX_AUDIO_PLANES; i++)
for (size_t i = 0; i < MAX_AV_PLANES; i++)
data.data[i] = audio->mix_buffers[i].array;
data.frames = frames;
data.timestamp = timestamp;
@@ -415,7 +415,7 @@ void audio_output_close(audio_t audio)
line = next;
}
for (size_t i = 0; i < MAX_AUDIO_PLANES; i++)
for (size_t i = 0; i < MAX_AV_PLANES; i++)
da_free(audio->mix_buffers[i]);
event_destroy(&audio->stop_event);

View File

@@ -17,6 +17,7 @@
#pragma once
#include "media-io-defs.h"
#include "../util/c99defs.h"
#ifdef __cplusplus
@@ -28,8 +29,6 @@ extern "C" {
* for the media.
*/
#define MAX_AUDIO_PLANES 8
struct audio_output;
struct audio_line;
typedef struct audio_output *audio_t;
@@ -64,7 +63,7 @@ enum speaker_layout {
};
struct audio_data {
const uint8_t *data[MAX_AUDIO_PLANES];
const uint8_t *data[MAX_AV_PLANES];
uint32_t frames;
uint64_t timestamp;
float volume;

View File

@@ -30,7 +30,7 @@ struct audio_resampler {
uint64_t input_layout;
enum AVSampleFormat input_format;
uint8_t *output_buffer[MAX_AUDIO_PLANES];
uint8_t *output_buffer[MAX_AV_PLANES];
uint64_t output_layout;
enum AVSampleFormat output_format;
int output_size;

View File

@@ -19,74 +19,74 @@
#include <xmmintrin.h>
#include <emmintrin.h>
/* ...surprisingly, if I don't use a macro to force inlining, it causes the
* CPU usage to boost by a tremendous amount in debug builds. */
#define get_m128_32_0(val) (*((uint32_t*)&val))
#define get_m128_32_1(val) (*(((uint32_t*)&val)+1))
static FORCE_INLINE void pack_lum(uint8_t *lum_plane,
uint32_t lum_pos0, uint32_t lum_pos1,
const __m128i line1, const __m128i line2,
const __m128i lum_mask)
#define pack_lum(lum_plane, lum_pos0, lum_pos1, line1, line2, lum_mask) \
do { \
__m128i pack_val = _mm_packs_epi32( \
_mm_srli_si128(_mm_and_si128(line1, lum_mask), 1), \
_mm_srli_si128(_mm_and_si128(line2, lum_mask), 1)); \
pack_val = _mm_packus_epi16(pack_val, pack_val); \
\
*(uint32_t*)(lum_plane+lum_pos0) = get_m128_32_0(pack_val); \
*(uint32_t*)(lum_plane+lum_pos1) = get_m128_32_1(pack_val); \
} while (false)
#define pack_ch_1plane(uv_plane, chroma_pos, line1, line2, uv_mask) \
do { \
__m128i add_val = _mm_add_epi64( \
_mm_and_si128(line1, uv_mask), \
_mm_and_si128(line2, uv_mask)); \
__m128i avg_val = _mm_add_epi64( \
add_val, \
_mm_shuffle_epi32(add_val, _MM_SHUFFLE(2, 3, 0, 1))); \
avg_val = _mm_srai_epi16(avg_val, 2); \
avg_val = _mm_shuffle_epi32(avg_val, _MM_SHUFFLE(3, 1, 2, 0)); \
avg_val = _mm_packus_epi16(avg_val, avg_val); \
\
*(uint32_t*)(uv_plane+chroma_pos) = get_m128_32_0(avg_val); \
} while (false)
#define pack_ch_2plane(u_plane, v_plane, chroma_pos, line1, line2, uv_mask) \
do { \
uint32_t packed_vals; \
\
__m128i add_val = _mm_add_epi64( \
_mm_and_si128(line1, uv_mask), \
_mm_and_si128(line2, uv_mask)); \
__m128i avg_val = _mm_add_epi64( \
add_val, \
_mm_shuffle_epi32(add_val, _MM_SHUFFLE(2, 3, 0, 1))); \
avg_val = _mm_srai_epi16(avg_val, 2); \
avg_val = _mm_shuffle_epi32(avg_val, _MM_SHUFFLE(3, 1, 2, 0)); \
avg_val = _mm_shufflelo_epi16(avg_val, _MM_SHUFFLE(3, 1, 2, 0)); \
avg_val = _mm_packus_epi16(avg_val, avg_val); \
\
packed_vals = get_m128_32_0(avg_val); \
\
*(uint16_t*)(u_plane+chroma_pos) = (uint16_t)(packed_vals); \
*(uint16_t*)(v_plane+chroma_pos) = (uint16_t)(packed_vals>>16); \
} while (false)
static FORCE_INLINE uint32_t min_uint32(uint32_t a, uint32_t b)
{
__m128i pack_val = _mm_packs_epi32(
_mm_srli_si128(_mm_and_si128(line1, lum_mask), 1),
_mm_srli_si128(_mm_and_si128(line2, lum_mask), 1));
pack_val = _mm_packus_epi16(pack_val, pack_val);
*(uint32_t*)(lum_plane+lum_pos0) = get_m128_32_0(pack_val);
*(uint32_t*)(lum_plane+lum_pos1) = get_m128_32_1(pack_val);
}
static FORCE_INLINE void pack_chroma_1plane(uint8_t *uv_plane,
uint32_t chroma_pos,
const __m128i line1, const __m128i line2,
const __m128i uv_mask)
{
__m128i add_val = _mm_add_epi64(
_mm_and_si128(line1, uv_mask),
_mm_and_si128(line2, uv_mask));
__m128i avg_val = _mm_add_epi64(
add_val,
_mm_shuffle_epi32(add_val, _MM_SHUFFLE(2, 3, 0, 1)));
avg_val = _mm_srai_epi16(avg_val, 2);
avg_val = _mm_shuffle_epi32(avg_val, _MM_SHUFFLE(3, 1, 2, 0));
avg_val = _mm_packus_epi16(avg_val, avg_val);
*(uint32_t*)(uv_plane+chroma_pos) = get_m128_32_0(avg_val);
}
static FORCE_INLINE void pack_chroma_2plane(uint8_t *u_plane, uint8_t *v_plane,
uint32_t chroma_pos,
const __m128i line1, const __m128i line2,
const __m128i uv_mask)
{
uint32_t packed_vals;
__m128i add_val = _mm_add_epi64(
_mm_and_si128(line1, uv_mask),
_mm_and_si128(line2, uv_mask));
__m128i avg_val = _mm_add_epi64(
add_val,
_mm_shuffle_epi32(add_val, _MM_SHUFFLE(2, 3, 0, 1)));
avg_val = _mm_srai_epi16(avg_val, 2);
avg_val = _mm_shuffle_epi32(avg_val, _MM_SHUFFLE(3, 1, 2, 0));
avg_val = _mm_shufflelo_epi16(avg_val, _MM_SHUFFLE(3, 1, 2, 0));
avg_val = _mm_packus_epi16(avg_val, avg_val);
packed_vals = get_m128_32_0(avg_val);
*(uint16_t*)(u_plane+chroma_pos) = (uint16_t)(packed_vals);
*(uint16_t*)(v_plane+chroma_pos) = (uint16_t)(packed_vals>>16);
return a < b ? a : b;
}
void compress_uyvx_to_i420(
const uint8_t *input, uint32_t in_linesize,
uint32_t width, uint32_t height,
uint32_t start_y, uint32_t end_y,
uint8_t *output[], const uint32_t out_linesize[])
{
uint8_t *lum_plane = output[0];
uint8_t *u_plane = output[1];
uint8_t *v_plane = output[2];
uint32_t width = min_uint32(in_linesize, out_linesize[0]);
uint32_t y;
__m128i lum_mask = _mm_set1_epi32(0x0000FF00);
@@ -109,7 +109,7 @@ void compress_uyvx_to_i420(
pack_lum(lum_plane, lum_pos0, lum_pos1,
line1, line2, lum_mask);
pack_chroma_2plane(u_plane, v_plane,
pack_ch_2plane(u_plane, v_plane,
chroma_y_pos + (x>>1),
line1, line2, uv_mask);
}
@@ -118,12 +118,12 @@ void compress_uyvx_to_i420(
void compress_uyvx_to_nv12(
const uint8_t *input, uint32_t in_linesize,
uint32_t width, uint32_t height,
uint32_t start_y, uint32_t end_y,
uint8_t *output[], const uint32_t out_linesize[])
{
uint8_t *lum_plane = output[0];
uint8_t *chroma_plane = output[1];
uint32_t width = min_uint32(in_linesize, out_linesize[0]);
uint32_t y;
__m128i lum_mask = _mm_set1_epi32(0x0000FF00);
@@ -146,7 +146,7 @@ void compress_uyvx_to_nv12(
pack_lum(lum_plane, lum_pos0, lum_pos1,
line1, line2, lum_mask);
pack_chroma_1plane(chroma_plane, chroma_y_pos + x,
pack_ch_1plane(chroma_plane, chroma_y_pos + x,
line1, line2, uv_mask);
}
}
@@ -154,12 +154,11 @@ void compress_uyvx_to_nv12(
void decompress_420(
const uint8_t *const input[], const uint32_t in_linesize[],
uint32_t width, uint32_t height,
uint32_t start_y, uint32_t end_y,
uint8_t *output, uint32_t out_linesize)
{
uint32_t start_y_d2 = start_y/2;
uint32_t width_d2 = width/2;
uint32_t width_d2 = min_uint32(in_linesize[0], out_linesize)/2;
uint32_t height_d2 = end_y/2;
uint32_t y;
@@ -170,8 +169,8 @@ void decompress_420(
register uint32_t *output0, *output1;
uint32_t x;
lum0 = input[0] + y * 2*width;
lum1 = lum0 + width;
lum0 = input[0] + y * 2 * in_linesize[0];
lum1 = lum0 + in_linesize[0];
output0 = (uint32_t*)(output + y * 2 * in_linesize[0]);
output1 = (uint32_t*)((uint8_t*)output0 + in_linesize[0]);
@@ -190,12 +189,11 @@ void decompress_420(
void decompress_nv12(
const uint8_t *const input[], const uint32_t in_linesize[],
uint32_t width, uint32_t height,
uint32_t start_y, uint32_t end_y,
uint8_t *output, uint32_t out_linesize)
{
uint32_t start_y_d2 = start_y/2;
uint32_t width_d2 = width/2;
uint32_t width_d2 = min_uint32(in_linesize[0], out_linesize)/2;
uint32_t height_d2 = end_y/2;
uint32_t y;
@@ -206,9 +204,9 @@ void decompress_nv12(
uint32_t x;
chroma = (const uint16_t*)(input[1] + y * in_linesize[1]);
lum0 = input[0] + y*2 * in_linesize[0];
lum0 = input[0] + y * 2 * in_linesize[0];
lum1 = lum0 + in_linesize[0];
output0 = (uint32_t*)(output + y*2 * out_linesize);
output0 = (uint32_t*)(output + y * 2 * out_linesize);
output1 = (uint32_t*)((uint8_t*)output0 + out_linesize);
for (x = 0; x < width_d2; x++) {
@@ -225,12 +223,11 @@ void decompress_nv12(
void decompress_422(
const uint8_t *input, uint32_t in_linesize,
uint32_t width, uint32_t height,
uint32_t start_y, uint32_t end_y,
uint8_t *output, uint32_t out_linesize,
bool leading_lum)
{
uint32_t width_d2 = width >> 1;
uint32_t width_d2 = min_uint32(in_linesize, out_linesize)/2;
uint32_t y;
register const uint32_t *input32;

View File

@@ -29,31 +29,26 @@ extern "C" {
EXPORT void compress_uyvx_to_i420(
const uint8_t *input, uint32_t in_linesize,
uint32_t width, uint32_t height,
uint32_t start_y, uint32_t end_y,
uint8_t *output[], const uint32_t out_linesize[]);
EXPORT void compress_uyvx_to_nv12(
const uint8_t *input, uint32_t in_linesize,
uint32_t width, uint32_t height,
uint32_t start_y, uint32_t end_y,
uint8_t *output[], const uint32_t out_linesize[]);
EXPORT void decompress_nv12(
const uint8_t *const input[], const uint32_t in_linesize[],
uint32_t width, uint32_t height,
uint32_t start_y, uint32_t end_y,
uint8_t *output, uint32_t out_linesize);
EXPORT void decompress_420(
const uint8_t *const input[], const uint32_t in_linesize[],
uint32_t width, uint32_t height,
uint32_t start_y, uint32_t end_y,
uint8_t *output, uint32_t out_linesize);
EXPORT void decompress_422(
const uint8_t *input, uint32_t in_linesize,
uint32_t width, uint32_t height,
uint32_t start_y, uint32_t end_y,
uint8_t *output, uint32_t out_linesize,
bool leading_lum);

View File

@@ -0,0 +1,20 @@
/******************************************************************************
Copyright (C) 2014 by Hugh Bailey <obs.jim@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#pragma once
#define MAX_AV_PLANES 8

View File

@@ -63,9 +63,6 @@ static inline void video_swapframes(struct video_output *video)
static inline void video_output_cur_frame(struct video_output *video)
{
size_t width = video->info.width;
size_t height = video->info.height;
if (!video->cur_frame.data[0])
return;

View File

@@ -17,6 +17,7 @@
#pragma once
#include "media-io-defs.h"
#include "../util/c99defs.h"
#ifdef __cplusplus
@@ -25,8 +26,6 @@ extern "C" {
/* Base video output component. Use this to create an video output track. */
#define MAX_VIDEO_PLANES 8
struct video_output;
typedef struct video_output *video_t;
@@ -49,8 +48,8 @@ enum video_format {
};
struct video_frame {
const uint8_t *data[MAX_VIDEO_PLANES];
uint32_t linesize[MAX_VIDEO_PLANES];
const uint8_t *data[MAX_AV_PLANES];
uint32_t linesize[MAX_AV_PLANES];
uint64_t timestamp;
};