From 9d72c0527c5b3dbfdf4a8cad3f306b2891dc3ea9 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 18 Apr 2012 20:48:36 +0100 Subject: nutdec: add malloc check and fix const to non-const conversion warnings Signed-off-by: Mans Rullgard --- libavformat/nutdec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 004a2ea255..f3cb4d8838 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -305,14 +305,18 @@ static int decode_main_header(NUTContext *nut) GET_V(nut->header_count, tmp < 128U) nut->header_count++; for (i = 1; i < nut->header_count; i++) { + uint8_t *hdr; GET_V(nut->header_len[i], tmp > 0 && tmp < 256); rem -= nut->header_len[i]; if (rem < 0) { av_log(s, AV_LOG_ERROR, "invalid elision header\n"); return AVERROR_INVALIDDATA; } - nut->header[i] = av_malloc(nut->header_len[i]); - avio_read(bc, nut->header[i], nut->header_len[i]); + hdr = av_malloc(nut->header_len[i]); + if (!hdr) + return AVERROR(ENOMEM); + avio_read(bc, hdr, nut->header_len[i]); + nut->header[i] = hdr; } assert(nut->header_len[0] == 0); } -- cgit v1.2.3 From 6208313aebb29b2fef263b705d82b27c8844e3f3 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 18 Apr 2012 21:01:15 +0100 Subject: avio: make AVIOContext.av_class pointer to const Fix this warning: libavformat/aviobuf.c:663:20: warning: assignment discards qualifiers from pointer target type Although this is a public header, it should remain source and binary compatible. Signed-off-by: Mans Rullgard --- libavformat/avio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 0ab92c32e5..10c0a12ccb 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -78,7 +78,7 @@ typedef struct { * warning -- this field can be NULL, be sure to not pass this AVIOContext * to any av_opt_* functions in that case. */ - AVClass *av_class; + const AVClass *av_class; unsigned char *buffer; /**< Start of the buffer. */ int buffer_size; /**< Maximum buffer size */ unsigned char *buf_ptr; /**< Current position in the buffer */ -- cgit v1.2.3 From d8b06521a94550c8352b0e2fe5e55873718fc0c0 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 17 Apr 2012 13:30:00 -0400 Subject: avconv: check for an incompatible changing channel layout The decoder can change the layout and channel count during decoding, but currently we only validate that the two are compatible when opening the codec. This checks for incompatibilities after each decoded frame. --- avconv.c | 99 +++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 54 insertions(+), 45 deletions(-) diff --git a/avconv.c b/avconv.c index 48b4c6b70b..3da123cd22 100644 --- a/avconv.c +++ b/avconv.c @@ -1191,6 +1191,58 @@ static int check_recording_time(OutputStream *ost) return 1; } +static void get_default_channel_layouts(OutputStream *ost, InputStream *ist) +{ + char layout_name[256]; + AVCodecContext *enc = ost->st->codec; + AVCodecContext *dec = ist->st->codec; + + if (dec->channel_layout && + av_get_channel_layout_nb_channels(dec->channel_layout) != dec->channels) { + av_get_channel_layout_string(layout_name, sizeof(layout_name), + dec->channels, dec->channel_layout); + av_log(NULL, AV_LOG_ERROR, "New channel layout (%s) is invalid\n", + layout_name); + dec->channel_layout = 0; + } + if (!dec->channel_layout) { + if (enc->channel_layout && dec->channels == enc->channels) { + dec->channel_layout = enc->channel_layout; + } else { + dec->channel_layout = av_get_default_channel_layout(dec->channels); + + if (!dec->channel_layout) { + av_log(NULL, AV_LOG_FATAL, "Unable to find default channel " + "layout for Input Stream #%d.%d\n", ist->file_index, + ist->st->index); + exit_program(1); + } + } + av_get_channel_layout_string(layout_name, sizeof(layout_name), + dec->channels, dec->channel_layout); + av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream " + "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name); + } + if (!enc->channel_layout) { + if (dec->channels == enc->channels) { + enc->channel_layout = dec->channel_layout; + return; + } else { + enc->channel_layout = av_get_default_channel_layout(enc->channels); + } + if (!enc->channel_layout) { + av_log(NULL, AV_LOG_FATAL, "Unable to find default channel layout " + "for Output Stream #%d.%d\n", ost->file_index, + ost->st->index); + exit_program(1); + } + av_get_channel_layout_string(layout_name, sizeof(layout_name), + enc->channels, enc->channel_layout); + av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Output Stream " + "#%d.%d : %s\n", ost->file_index, ost->st->index, layout_name); + } +} + static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size) { int fill_char = 0x00; @@ -1301,6 +1353,8 @@ static void do_audio_out(AVFormatContext *s, OutputStream *ost, uint8_t *buf = decoded_frame->data[0]; int size = decoded_frame->nb_samples * dec->channels * isize; + get_default_channel_layouts(ost, ist); + if (alloc_audio_output_buf(dec, enc, decoded_frame->nb_samples) < 0) { av_log(NULL, AV_LOG_FATAL, "Error allocating audio buffer\n"); exit_program(1); @@ -2430,51 +2484,6 @@ static void print_sdp(void) av_freep(&avc); } -static void get_default_channel_layouts(OutputStream *ost, InputStream *ist) -{ - char layout_name[256]; - AVCodecContext *enc = ost->st->codec; - AVCodecContext *dec = ist->st->codec; - - if (!dec->channel_layout) { - if (enc->channel_layout && dec->channels == enc->channels) { - dec->channel_layout = enc->channel_layout; - } else { - dec->channel_layout = av_get_default_channel_layout(dec->channels); - - if (!dec->channel_layout) { - av_log(NULL, AV_LOG_FATAL, "Unable to find default channel " - "layout for Input Stream #%d.%d\n", ist->file_index, - ist->st->index); - exit_program(1); - } - } - av_get_channel_layout_string(layout_name, sizeof(layout_name), - dec->channels, dec->channel_layout); - av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream " - "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name); - } - if (!enc->channel_layout) { - if (dec->channels == enc->channels) { - enc->channel_layout = dec->channel_layout; - return; - } else { - enc->channel_layout = av_get_default_channel_layout(enc->channels); - } - if (!enc->channel_layout) { - av_log(NULL, AV_LOG_FATAL, "Unable to find default channel layout " - "for Output Stream #%d.%d\n", ost->file_index, - ost->st->index); - exit_program(1); - } - av_get_channel_layout_string(layout_name, sizeof(layout_name), - enc->channels, enc->channel_layout); - av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Output Stream " - "#%d.%d : %s\n", ost->file_index, ost->st->index, layout_name); - } -} - - static int init_input_stream(int ist_index, char *error, int error_len) { int i; -- cgit v1.2.3 From e73ec9216bbd4d63fa30a51e90eff9169ad4dd17 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 19 Apr 2012 00:42:56 +0100 Subject: configure: detect PGI compiler and set suitable flags Signed-off-by: Mans Rullgard --- configure | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/configure b/configure index 2eb885b5af..172e1d6ea9 100755 --- a/configure +++ b/configure @@ -2140,6 +2140,24 @@ elif $cc -v 2>&1 | grep -q Open64; then speed_cflags='-O2' size_cflags='-Os' filter_cflags='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros' +elif $cc -V 2>&1 | grep -q Portland; then + cc_type=pgi + cc_version='AV_STRINGIFY(__PGIC__.__PGIC_MINOR__.__PGIC_PATCHLEVEL__)' + cc_ident="PGI $($cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')" + opt_common='-alias=ansi -Mlre -Mpre' + speed_cflags="-O3 -Mautoinline -Munroll=c:4 $opt_common" + size_cflags="-O2 -Munroll=c:1 $opt_common" + noopt_cflags="-O1" + filter_cflags=pgi_flags + pgi_flags(){ + for flag; do + case $flag in + -fomit-frame-pointer) echo -Mnoframe ;; + -g) echo -gopt ;; + *) echo $flag ;; + esac + done + } fi test -n "$cc_type" && enable $cc_type || -- cgit v1.2.3 From 705f3d4759e80044c2a33020aef05b1ed0150558 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Tue, 10 Apr 2012 10:40:38 -0400 Subject: x86inc: support AVX abstraction for 2-operand instructions Add cvtdq2ps and cvtps2dq to the AVX instruction list. Signed-off-by: Justin Ruggles --- libavutil/x86/x86inc.asm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm index ea9f9a1550..c167057921 100644 --- a/libavutil/x86/x86inc.asm +++ b/libavutil/x86/x86inc.asm @@ -822,7 +822,7 @@ INIT_XMM ;%1 == instruction ;%2 == 1 if float, 0 if int -;%3 == 1 if 4-operand (xmm, xmm, xmm, imm), 0 if 3-operand (xmm, xmm, xmm) +;%3 == 1 if 4-operand (xmm, xmm, xmm, imm), 0 if 2- or 3-operand (xmm, xmm, xmm) ;%4 == number of operands given ;%5+: operands %macro RUN_AVX_INSTR 6-7+ @@ -832,7 +832,11 @@ INIT_XMM %define %%size mmsize %endif %if %%size==32 - v%1 %5, %6, %7 + %if %0 >= 7 + v%1 %5, %6, %7 + %else + v%1 %5, %6 + %endif %else %if %%size==8 %define %%regmov movq @@ -918,6 +922,8 @@ AVX_INSTR cmppd, 1, 0, 0 AVX_INSTR cmpps, 1, 0, 0 AVX_INSTR cmpsd, 1, 0, 0 AVX_INSTR cmpss, 1, 0, 0 +AVX_INSTR cvtdq2ps, 1, 0, 0 +AVX_INSTR cvtps2dq, 1, 0, 0 AVX_INSTR divpd, 1, 0, 0 AVX_INSTR divps, 1, 0, 0 AVX_INSTR divsd, 1, 0, 0 -- cgit v1.2.3 From c755b1fbbc54694f1ac657be7517de28981cf326 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 16 Apr 2012 21:06:00 -0400 Subject: FATE: specify the input format when decoding in enc_dec_pcm() The output format is not always the same as the file extension, which is sometimes required for correct probing. We can avoid probing by specifying the format since it is already known. --- tests/fate-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index b19f0aeba4..39db0e89e0 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -91,7 +91,7 @@ enc_dec_pcm(){ encfile="${outdir}/${test}.${out_fmt}" cleanfiles=$encfile avconv -i $ref "$@" -f $out_fmt -y ${target_path}/${encfile} || return - avconv -i ${target_path}/${encfile} -c:a pcm_${pcm_fmt} -f wav - + avconv -f $out_fmt -i ${target_path}/${encfile} -c:a pcm_${pcm_fmt} -f wav - } regtest(){ -- cgit v1.2.3 From 9cc338b1de78c1b82d0867ea96e07367038d226e Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 17 Apr 2012 16:47:57 +0100 Subject: FATE: pass the decoded output format and audio source file to enc_dec_pcm This will allow decoding to md5 and doing a diff comparison to a reference checksum instead of a fuzzy stddev or oneoff comparison. Signed-off-by: Mans Rullgard --- tests/fate-run.sh | 16 ++++++++++++---- tests/fate/ac3.mak | 4 ++-- tests/fate/wma.mak | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 39db0e89e0..f7a7abaa76 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -28,6 +28,11 @@ errfile="${outdir}/${test}.err" cmpfile="${outdir}/${test}.diff" repfile="${outdir}/${test}.rep" +target_path(){ + test ${1} = ${1#/} && p=${target_path}/ + echo ${p}${1} +} + # $1=value1, $2=value2, $3=threshold # prints 0 if absolute difference between value1 and value2 is <= threshold compare(){ @@ -86,12 +91,15 @@ pcm(){ enc_dec_pcm(){ out_fmt=$1 - pcm_fmt=$2 - shift 2 + dec_fmt=$2 + pcm_fmt=$3 + src_file=$(target_path $4) + shift 4 encfile="${outdir}/${test}.${out_fmt}" cleanfiles=$encfile - avconv -i $ref "$@" -f $out_fmt -y ${target_path}/${encfile} || return - avconv -f $out_fmt -i ${target_path}/${encfile} -c:a pcm_${pcm_fmt} -f wav - + encfile=$(target_path ${encfile}) + avconv -i $src_file "$@" -f $out_fmt -y ${encfile} || return + avconv -f $out_fmt -i ${encfile} -c:a pcm_${pcm_fmt} -f ${dec_fmt} - } regtest(){ diff --git a/tests/fate/ac3.mak b/tests/fate/ac3.mak index 2e851864c3..ca0704d08d 100644 --- a/tests/fate/ac3.mak +++ b/tests/fate/ac3.mak @@ -29,7 +29,7 @@ fate-eac3-4: CMP = oneoff fate-eac3-4: REF = $(SAMPLES)/eac3/serenity_english_5.1_1536_small.pcm FATE_AC3 += fate-ac3-encode -fate-ac3-encode: CMD = enc_dec_pcm ac3 s16le -c:a ac3 -b:a 128k +fate-ac3-encode: CMD = enc_dec_pcm ac3 wav s16le $(REF) -c:a ac3 -b:a 128k fate-ac3-encode: CMP = stddev fate-ac3-encode: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav fate-ac3-encode: CMP_SHIFT = -1024 @@ -37,7 +37,7 @@ fate-ac3-encode: CMP_TARGET = 399.62 fate-ac3-encode: SIZE_TOLERANCE = 488 FATE_AC3 += fate-eac3-encode -fate-eac3-encode: CMD = enc_dec_pcm eac3 s16le -c:a eac3 -b:a 128k +fate-eac3-encode: CMD = enc_dec_pcm eac3 wav s16le $(REF) -c:a eac3 -b:a 128k fate-eac3-encode: CMP = stddev fate-eac3-encode: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav fate-eac3-encode: CMP_SHIFT = -1024 diff --git a/tests/fate/wma.mak b/tests/fate/wma.mak index 9143f8c0f3..6fd4b38ca7 100644 --- a/tests/fate/wma.mak +++ b/tests/fate/wma.mak @@ -38,7 +38,7 @@ FATE_TESTS += $(FATE_WMAVOICE) fate-wmavoice: $(FATE_WMAVOICE) FATE_WMA_ENCODE += fate-wmav1-encode -fate-wmav1-encode: CMD = enc_dec_pcm asf s16le -c:a wmav1 -b:a 128k +fate-wmav1-encode: CMD = enc_dec_pcm asf wav s16le $(REF) -c:a wmav1 -b:a 128k fate-wmav1-encode: CMP = stddev fate-wmav1-encode: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav fate-wmav1-encode: CMP_SHIFT = -8192 @@ -46,7 +46,7 @@ fate-wmav1-encode: CMP_TARGET = 291.06 fate-wmav1-encode: SIZE_TOLERANCE = 4632 FATE_WMA_ENCODE += fate-wmav2-encode -fate-wmav2-encode: CMD = enc_dec_pcm asf s16le -c:a wmav2 -b:a 128k +fate-wmav2-encode: CMD = enc_dec_pcm asf wav s16le $(REF) -c:a wmav2 -b:a 128k fate-wmav2-encode: CMP = stddev fate-wmav2-encode: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav fate-wmav2-encode: CMP_SHIFT = -8192 -- cgit v1.2.3 From f2e44655221d5af8cf88043cc84626dda5591c5c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 18 Apr 2012 16:05:17 +0200 Subject: dv: Replace some magic numbers by the appropriate #define. --- libavcodec/dv_vlc_data.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/dv_vlc_data.h b/libavcodec/dv_vlc_data.h index b5c1ddecb4..d62fd6bf22 100644 --- a/libavcodec/dv_vlc_data.h +++ b/libavcodec/dv_vlc_data.h @@ -36,7 +36,7 @@ * between (run, level) and vlc is not 1-1. So you have to watch out for that * when building misc. tables. E.g. (1, 0) can be either 0x7cf or 0x1f82. */ -static const uint16_t dv_vlc_bits[409] = { +static const uint16_t dv_vlc_bits[NB_DV_VLC] = { 0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016, 0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2, @@ -91,7 +91,7 @@ static const uint16_t dv_vlc_bits[409] = { 0x0006, }; -static const uint8_t dv_vlc_len[409] = { +static const uint8_t dv_vlc_len[NB_DV_VLC] = { 2, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, @@ -146,7 +146,7 @@ static const uint8_t dv_vlc_len[409] = { 4, }; -static const uint8_t dv_vlc_run[409] = { +static const uint8_t dv_vlc_run[NB_DV_VLC] = { 0, 0, 1, 0, 0, 2, 1, 0, 0, 3, 4, 0, 0, 5, 6, 2, 1, 1, 0, 0, 0, 7, 8, 9, @@ -201,7 +201,7 @@ static const uint8_t dv_vlc_run[409] = { 127, }; -static const uint8_t dv_vlc_level[409] = { +static const uint8_t dv_vlc_level[NB_DV_VLC] = { 1, 2, 1, 3, 4, 1, 2, 5, 6, 1, 1, 7, 8, 1, 1, 2, 3, 4, 9, 10, 11, 1, 1, 1, -- cgit v1.2.3 From 2b98377935384ecd22c2cd26106b9e03a6c9f598 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 18 Apr 2012 18:47:16 +0200 Subject: dv: Initialize encoder tables during encoder init. --- libavcodec/dv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 034daac2d7..9c0893a47a 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -294,8 +294,6 @@ av_cold int ff_dvvideo_init(AVCodecContext *avctx) ff_dv_rl_vlc[i].run = run; } ff_free_vlc(&dv_vlc); - - dv_vlc_map_tableinit(); } /* Generic DSP setup */ @@ -338,6 +336,8 @@ static av_cold int dvvideo_init_encoder(AVCodecContext *avctx) return AVERROR(EINVAL); } + dv_vlc_map_tableinit(); + return ff_dvvideo_init(avctx); } -- cgit v1.2.3