From ea57502c82a91362daeafec392375706fa266d8b Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 19 Jun 2011 16:19:06 +0100 Subject: [PATCH 001/780] fate: remove output redirections from old regtest scripts All tests are run through the fate-run.sh script which already sets up redirections. Using the outputs set there simplifies things somewhat. Signed-off-by: Mans Rullgard --- tests/codec-regression.sh | 10 ++++------ tests/fate-run.sh | 3 --- tests/lavf-regression.sh | 6 ++---- tests/lavfi-regression.sh | 6 ++---- tests/regression-funcs.sh | 23 ++++++++--------------- 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh index a858250e2f..ccedbdbfef 100755 --- a/tests/codec-regression.sh +++ b/tests/codec-regression.sh @@ -11,8 +11,6 @@ set -e eval do_$test=y -rm -f "$logfile" - # generate reference for quality check if [ -n "$do_vref" ]; then do_ffmpeg $raw_ref -f image2 -vcodec pgmyuv -i $raw_src -an -f rawvideo @@ -265,14 +263,14 @@ fi if [ -n "$do_mp2" ] ; then do_audio_encoding mp2.mp2 do_audio_decoding -$tiny_psnr $pcm_dst $pcm_ref 2 1924 >> $logfile +$tiny_psnr $pcm_dst $pcm_ref 2 1924 fi if [ -n "$do_ac3_fixed" ] ; then do_audio_encoding ac3.rm "-vn -acodec ac3_fixed" # binaries configured with --disable-sse decode ac3 differently #do_audio_decoding -#$tiny_psnr $pcm_dst $pcm_ref 2 1024 >> $logfile +#$tiny_psnr $pcm_dst $pcm_ref 2 1024 fi if [ -n "$do_g726" ] ; then @@ -318,12 +316,12 @@ fi if [ -n "$do_wmav1" ] ; then do_audio_encoding wmav1.asf "-acodec wmav1" do_ffmpeg_nomd5 $pcm_dst $DEC_OPTS -i $target_path/$file -f wav -$tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile +$tiny_psnr $pcm_dst $pcm_ref 2 8192 fi if [ -n "$do_wmav2" ] ; then do_audio_encoding wmav2.asf "-acodec wmav2" do_ffmpeg_nomd5 $pcm_dst $DEC_OPTS -i $target_path/$file -f wav -$tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile +$tiny_psnr $pcm_dst $pcm_ref 2 8192 fi #if [ -n "$do_vorbis" ] ; then diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 366145d22f..2c744b880f 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -76,9 +76,6 @@ pcm(){ regtest(){ t="${test#$2-}" ref=${base}/ref/$2/$t - cleanfiles="$cleanfiles $outfile $errfile" - outfile=tests/data/regression/$2/$t - errfile=tests/data/$t.$2.err ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" "$thread_type" } diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh index 39e752b3c6..d7e684032c 100755 --- a/tests/lavf-regression.sh +++ b/tests/lavf-regression.sh @@ -31,9 +31,9 @@ do_image_formats() mkdir -p "$outfile" file=${outfile}%02d.$1 run_ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $2 $ENC_OPTS $3 -t 0.5 -y -qscale 10 $target_path/$file - do_md5sum ${outfile}02.$1 >> $logfile + do_md5sum ${outfile}02.$1 do_ffmpeg_crc $file $DEC_OPTS $3 -i $target_path/$file - wc -c ${outfile}02.$1 >> $logfile + wc -c ${outfile}02.$1 } do_audio_only() @@ -43,8 +43,6 @@ do_audio_only() do_ffmpeg_crc $file $DEC_OPTS $4 -i $target_path/$file } -rm -f "$logfile" - if [ -n "$do_avi" ] ; then do_lavf avi fi diff --git a/tests/lavfi-regression.sh b/tests/lavfi-regression.sh index b2a195a90e..4a483e68a5 100755 --- a/tests/lavfi-regression.sh +++ b/tests/lavfi-regression.sh @@ -11,15 +11,13 @@ set -e eval do_$test=y -rm -f "$logfile" - do_video_filter() { label=$1 filters=$2 shift 2 - printf '%-20s' $label >>$logfile + printf '%-20s' $label run_ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \ - $ENC_OPTS -vf "$filters" -vcodec rawvideo $* -f nut md5: >>$logfile + $ENC_OPTS -vf "$filters" -vcodec rawvideo $* -f nut md5: } do_lavfi() { diff --git a/tests/regression-funcs.sh b/tests/regression-funcs.sh index e57cdf111e..979157bcf9 100755 --- a/tests/regression-funcs.sh +++ b/tests/regression-funcs.sh @@ -15,10 +15,7 @@ datadir="./tests/data" target_datadir="${target_path}/${datadir}" this="$test.$test_ref" -logdir="$datadir/regression/$test_ref" -logfile="$logdir/$test" outfile="$datadir/$test_ref/" -errfile="$datadir/$this.err" # various files ffmpeg="$target_exec ${target_path}/ffmpeg" @@ -37,12 +34,8 @@ trap 'rm -f -- $cleanfiles' EXIT mkdir -p "$datadir" mkdir -p "$outfile" -mkdir -p "$logdir" - -(exec >&3) 2>/dev/null || exec 3>&2 [ "${V-0}" -gt 0 ] && echov=echov || echov=: -[ "${V-0}" -gt 1 ] || exec 2>$errfile echov(){ echo "$@" >&3 @@ -67,13 +60,13 @@ do_ffmpeg() shift set -- $* ${target_path}/$f run_ffmpeg $* - do_md5sum $f >> $logfile + do_md5sum $f if [ $f = $raw_dst ] ; then - $tiny_psnr $f $raw_ref >> $logfile + $tiny_psnr $f $raw_ref elif [ $f = $pcm_dst ] ; then - $tiny_psnr $f $pcm_ref 2 >> $logfile + $tiny_psnr $f $pcm_ref 2 else - wc -c $f >> $logfile + wc -c $f fi } @@ -84,11 +77,11 @@ do_ffmpeg_nomd5() set -- $* ${target_path}/$f run_ffmpeg $* if [ $f = $raw_dst ] ; then - $tiny_psnr $f $raw_ref >> $logfile + $tiny_psnr $f $raw_ref elif [ $f = $pcm_dst ] ; then - $tiny_psnr $f $pcm_ref 2 >> $logfile + $tiny_psnr $f $pcm_ref 2 else - wc -c $f >> $logfile + wc -c $f fi } @@ -97,7 +90,7 @@ do_ffmpeg_crc() f="$1" shift run_ffmpeg $* -f crc "$target_crcfile" - echo "$f $(cat $crcfile)" >> $logfile + echo "$f $(cat $crcfile)" } do_video_decoding() From 84e70ef004d763262ea4e795341ff240b8b10da3 Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Tue, 21 Jun 2011 00:30:23 -0400 Subject: [PATCH 002/780] h264: Add x86 assembly for 10-bit weight/biweight H.264 functions. Mainly ported from 8-bit H.264 weight/biweight. Signed-off-by: Diego Biurrun --- libavcodec/x86/Makefile | 1 + libavcodec/x86/h264_weight_10bit.asm | 321 +++++++++++++++++++++++++++ libavcodec/x86/h264dsp_mmx.c | 61 +++++ 3 files changed, 383 insertions(+) create mode 100644 libavcodec/x86/h264_weight_10bit.asm diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index ea57bd1db6..022ab27766 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -15,6 +15,7 @@ YASM-OBJS-$(CONFIG_H264DSP) += x86/h264_deblock.o \ x86/h264_idct.o \ x86/h264_idct_10bit.o \ x86/h264_weight.o \ + x86/h264_weight_10bit.o \ YASM-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred.o \ x86/h264_intrapred_10bit.o diff --git a/libavcodec/x86/h264_weight_10bit.asm b/libavcodec/x86/h264_weight_10bit.asm new file mode 100644 index 0000000000..1c58d72d94 --- /dev/null +++ b/libavcodec/x86/h264_weight_10bit.asm @@ -0,0 +1,321 @@ +;***************************************************************************** +;* MMX/SSE2/AVX-optimized 10-bit H.264 weighted prediction code +;***************************************************************************** +;* Copyright (C) 2005-2011 x264 project +;* +;* Authors: Daniel Kang +;* +;* This file is part of Libav. +;* +;* Libav is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* Libav 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 +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with Libav; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" +%include "x86util.asm" + +SECTION_RODATA 32 + +pw_pixel_max: times 8 dw ((1 << 10)-1) +sq_1: dq 1 + dq 0 + +cextern pw_1 + +SECTION .text + +;----------------------------------------------------------------------------- +; void h264_weight(uint8_t *dst, int stride, int log2_denom, +; int weight, int offset); +;----------------------------------------------------------------------------- +%ifdef ARCH_X86_32 +DECLARE_REG_TMP 2 +%else +DECLARE_REG_TMP 10 +%endif + +%macro WEIGHT_PROLOGUE 1 + mov t0, %1 +.prologue + PROLOGUE 0,5,8 + movifnidn r0, r0mp + movifnidn r1d, r1m + movifnidn r3d, r3m + movifnidn r4d, r4m +%endmacro + +%macro WEIGHT_SETUP 1 + mova m0, [pw_1] + movd m2, r2m + pslld m0, m2 ; 1<h264_idct8_add4 = ff_h264_idct8_add4_10_sse2; #endif + c->weight_h264_pixels_tab[0] = ff_h264_weight_16x16_10_sse2; + c->weight_h264_pixels_tab[1] = ff_h264_weight_16x8_10_sse2; + c->weight_h264_pixels_tab[2] = ff_h264_weight_8x16_10_sse2; + c->weight_h264_pixels_tab[3] = ff_h264_weight_8x8_10_sse2; + c->weight_h264_pixels_tab[4] = ff_h264_weight_8x4_10_sse2; + c->weight_h264_pixels_tab[5] = ff_h264_weight_4x8_10_sse2; + c->weight_h264_pixels_tab[6] = ff_h264_weight_4x4_10_sse2; + c->weight_h264_pixels_tab[7] = ff_h264_weight_4x2_10_sse2; + + c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16x16_10_sse2; + c->biweight_h264_pixels_tab[1] = ff_h264_biweight_16x8_10_sse2; + c->biweight_h264_pixels_tab[2] = ff_h264_biweight_8x16_10_sse2; + c->biweight_h264_pixels_tab[3] = ff_h264_biweight_8x8_10_sse2; + c->biweight_h264_pixels_tab[4] = ff_h264_biweight_8x4_10_sse2; + c->biweight_h264_pixels_tab[5] = ff_h264_biweight_4x8_10_sse2; + c->biweight_h264_pixels_tab[6] = ff_h264_biweight_4x4_10_sse2; + c->biweight_h264_pixels_tab[7] = ff_h264_biweight_4x2_10_sse2; + c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_sse2; c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_sse2; #if HAVE_ALIGNED_STACK @@ -463,6 +505,25 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_sse2; #endif } + if (mm_flags&AV_CPU_FLAG_SSE4) { + c->weight_h264_pixels_tab[0] = ff_h264_weight_16x16_10_sse4; + c->weight_h264_pixels_tab[1] = ff_h264_weight_16x8_10_sse4; + c->weight_h264_pixels_tab[2] = ff_h264_weight_8x16_10_sse4; + c->weight_h264_pixels_tab[3] = ff_h264_weight_8x8_10_sse4; + c->weight_h264_pixels_tab[4] = ff_h264_weight_8x4_10_sse4; + c->weight_h264_pixels_tab[5] = ff_h264_weight_4x8_10_sse4; + c->weight_h264_pixels_tab[6] = ff_h264_weight_4x4_10_sse4; + c->weight_h264_pixels_tab[7] = ff_h264_weight_4x2_10_sse4; + + c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16x16_10_sse4; + c->biweight_h264_pixels_tab[1] = ff_h264_biweight_16x8_10_sse4; + c->biweight_h264_pixels_tab[2] = ff_h264_biweight_8x16_10_sse4; + c->biweight_h264_pixels_tab[3] = ff_h264_biweight_8x8_10_sse4; + c->biweight_h264_pixels_tab[4] = ff_h264_biweight_8x4_10_sse4; + c->biweight_h264_pixels_tab[5] = ff_h264_biweight_4x8_10_sse4; + c->biweight_h264_pixels_tab[6] = ff_h264_biweight_4x4_10_sse4; + c->biweight_h264_pixels_tab[7] = ff_h264_biweight_4x2_10_sse4; + } #if HAVE_AVX if (mm_flags&AV_CPU_FLAG_AVX) { c->h264_idct_dc_add = From 6371ce4b0f0535a7f576b8f109d35345e3d11d7d Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 21 Jun 2011 01:11:28 +0200 Subject: [PATCH 003/780] h264: Fix assert that failed to compile with -DDEBUG. The assert referenced a variable that no longer exists since 4:4:4 support. --- libavcodec/h264.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index dc4acb8379..13a63809a0 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1682,7 +1682,7 @@ static av_always_inline void hl_decode_mb_predict_luma(H264Context *h, int mb_ty uint64_t tr_high; if(dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED){ const int topright_avail= (h->topright_samples_available<mb_y || linesize <= block_offset[i]); if(!topright_avail){ if (pixel_shift) { tr_high= ((uint16_t*)ptr)[3 - linesize/2]*0x0001000100010001ULL; From 087d93f568962463e3db7bc2895a3d98ce30bfc0 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 15 Jun 2011 13:45:24 +0200 Subject: [PATCH 004/780] swscale: Remove unused variable from ff_bfin_get_unscaled_swscale(). --- libswscale/bfin/swscale_bfin.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libswscale/bfin/swscale_bfin.c b/libswscale/bfin/swscale_bfin.c index c8030ba29f..0c5f004930 100644 --- a/libswscale/bfin/swscale_bfin.c +++ b/libswscale/bfin/swscale_bfin.c @@ -78,8 +78,6 @@ static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], i void ff_bfin_get_unscaled_swscale(SwsContext *c) { - SwsFunc swScale = c->swScale; - if (c->dstFormat == PIX_FMT_YUV420P && c->srcFormat == PIX_FMT_UYVY422) { av_log (NULL, AV_LOG_VERBOSE, "selecting Blackfin optimized uyvytoyv12_unscaled\n"); c->swScale = uyvytoyv12_unscaled; From d352df093169f39631f1ec0017a3f186ef85f83c Mon Sep 17 00:00:00 2001 From: ami_stuff Date: Mon, 25 Apr 2011 00:20:27 +0200 Subject: [PATCH 005/780] rawvideo: Support auv2 fourcc. --- libavcodec/raw.c | 1 + libavformat/riff.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index 7d92aba4a7..bc7c1561e7 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -61,6 +61,7 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_UYVY422, MKTAG('A', 'V', '1', 'x') }, /* Avid 1:1x */ { PIX_FMT_UYVY422, MKTAG('A', 'V', 'u', 'p') }, { PIX_FMT_UYVY422, MKTAG('V', 'D', 'T', 'Z') }, /* SoftLab-NSK VideoTizer */ + { PIX_FMT_UYVY422, MKTAG('a', 'u', 'v', '2') }, { PIX_FMT_UYYVYY411, MKTAG('Y', '4', '1', '1') }, { PIX_FMT_GRAY8, MKTAG('G', 'R', 'E', 'Y') }, { PIX_FMT_NV12, MKTAG('N', 'V', '1', '2') }, diff --git a/libavformat/riff.c b/libavformat/riff.c index fe6cc55055..756fc57f01 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -180,6 +180,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', 'B') }, { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'V', '9') }, { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') }, + { CODEC_ID_RAWVIDEO, MKTAG('a', 'u', 'v', '2') }, { CODEC_ID_FRWU, MKTAG('F', 'R', 'W', 'U') }, { CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') }, { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, From 682a20114e9ee0272be764c68dc1cf251ff083da Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 25 Apr 2011 00:27:03 +0200 Subject: [PATCH 006/780] riff: Add M263, XVIX, MMJP, CDV5 fourccs. --- libavformat/riff.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 756fc57f01..95e08b28a8 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -40,6 +40,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_H263, MKTAG('L', '2', '6', '3') }, { CODEC_ID_H263, MKTAG('V', 'X', '1', 'K') }, { CODEC_ID_H263, MKTAG('Z', 'y', 'G', 'o') }, + { CODEC_ID_H263, MKTAG('M', '2', '6', '3') }, { CODEC_ID_H263P, MKTAG('H', '2', '6', '3') }, { CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */ { CODEC_ID_H261, MKTAG('H', '2', '6', '1') }, @@ -83,6 +84,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_MPEG4, MKTAG('U', 'L', 'D', 'X') }, { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') }, { CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') }, /* Samsung SHR-6040 */ + { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'X') }, { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') }, @@ -107,6 +109,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', '0') }, { CODEC_ID_DVVIDEO, MKTAG('c', 'd', 'v', 'c') }, /* Canopus DV */ { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', 'H') }, /* Canopus DV */ + { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', '5') }, /* Canopus DV */ { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 's') }, { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') }, @@ -148,6 +151,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '2') }, { CODEC_ID_MJPEG, MKTAG('M', 'T', 'S', 'J') }, { CODEC_ID_MJPEG, MKTAG('Z', 'J', 'P', 'G') }, /* Paradigm Matrix M-JPEG Codec */ + { CODEC_ID_MJPEG, MKTAG('M', 'M', 'J', 'P') }, { CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') }, { CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') }, { CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') }, From 2ea1ca1714f655a463b941b115e45a1a2f031f7b Mon Sep 17 00:00:00 2001 From: ami_stuff Date: Wed, 11 May 2011 22:18:15 +0200 Subject: [PATCH 007/780] riff: Add DAVC fourcc. This fourcc is used by the "mpegable AVC" codec and files encoded with this codec decode correctly with our H.264 decoder. --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 95e08b28a8..b2e8414b5d 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -33,6 +33,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_H264, MKTAG('X', '2', '6', '4') }, { CODEC_ID_H264, MKTAG('x', '2', '6', '4') }, { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, + { CODEC_ID_H264, MKTAG('D', 'A', 'V', 'C') }, { CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') }, { CODEC_ID_H263, MKTAG('H', '2', '6', '3') }, { CODEC_ID_H263, MKTAG('X', '2', '6', '3') }, From a304a833621a793bbf49b796fe1fd11ea1cd54c8 Mon Sep 17 00:00:00 2001 From: Kamil Nowosad Date: Mon, 23 May 2011 23:13:34 +0200 Subject: [PATCH 008/780] riff/img2: Add JPEG 2000 codec IDs. --- libavformat/img2.c | 1 + libavformat/riff.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libavformat/img2.c b/libavformat/img2.c index ec37a38845..4eef62371d 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -82,6 +82,7 @@ static const IdStrMap img_tags[] = { { CODEC_ID_SUNRAST , "im24"}, { CODEC_ID_SUNRAST , "sunras"}, { CODEC_ID_JPEG2000 , "jp2"}, + { CODEC_ID_JPEG2000 , "jpc"}, { CODEC_ID_DPX , "dpx"}, { CODEC_ID_PICTOR , "pic"}, { CODEC_ID_NONE , NULL} diff --git a/libavformat/riff.c b/libavformat/riff.c index b2e8414b5d..817349cb82 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -250,6 +250,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_ZMBV, MKTAG('Z', 'M', 'B', 'V') }, { CODEC_ID_KMVC, MKTAG('K', 'M', 'V', 'C') }, { CODEC_ID_CAVS, MKTAG('C', 'A', 'V', 'S') }, + { CODEC_ID_JPEG2000, MKTAG('m', 'j', 'p', '2') }, { CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') }, { CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') }, { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') }, From 7ac639654f21aa78e0afa14f6c049ffa2c9078bd Mon Sep 17 00:00:00 2001 From: ami_stuff Date: Fri, 13 May 2011 00:49:29 +0200 Subject: [PATCH 009/780] mov: Support R10g codec identifier. --- libavformat/isom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/isom.c b/libavformat/isom.c index c65f9317e7..dd4008b69b 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -83,6 +83,7 @@ const AVCodecTag codec_movvideo_tags[] = { { CODEC_ID_RAWVIDEO, MKTAG('b', '4', '8', 'r') }, { CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') }, /* UNCOMPRESSED 10BIT RGB */ + { CODEC_ID_R10K, MKTAG('R', '1', '0', 'g') }, /* UNCOMPRESSED 10BIT RGB */ { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, /* UNCOMPRESSED 10BIT RGB */ { CODEC_ID_V210, MKTAG('v', '2', '1', '0') }, /* UNCOMPRESSED 10BIT 4:2:2 */ From 53d5cd2c8225e251826c77f8f69a30250038fbd0 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 13 May 2011 01:08:01 +0200 Subject: [PATCH 010/780] mov: Support Digital Voodoo SD 8 Bit and DTS codec identifiers. --- libavcodec/raw.c | 1 + libavformat/isom.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index bc7c1561e7..4bc07b869a 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -122,6 +122,7 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_UYVY422, MKTAG('A', 'V', 'U', 'I') }, /* FIXME merge both fields */ { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', '2') }, { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', 's') }, + { PIX_FMT_YUYV422, MKTAG('D', 'V', 'O', 'O') }, /* Digital Voodoo SD 8 Bit */ { PIX_FMT_PAL8, MKTAG('W', 'R', 'A', 'W') }, { PIX_FMT_RGB555LE,MKTAG('L', '5', '5', '5') }, { PIX_FMT_RGB565LE,MKTAG('L', '5', '6', '5') }, diff --git a/libavformat/isom.c b/libavformat/isom.c index dd4008b69b..eb17e25474 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -57,6 +57,7 @@ const AVCodecTag ff_mp4_obj_type[] = { { CODEC_ID_VC1 , 0xA3 }, { CODEC_ID_DIRAC , 0xA4 }, { CODEC_ID_AC3 , 0xA5 }, + { CODEC_ID_DTS , 0xA9 }, /* mp4ra.org */ { CODEC_ID_VORBIS , 0xDD }, /* non standard, gpac uses it */ { CODEC_ID_DVD_SUBTITLE, 0xE0 }, /* non standard, see unsupported-embedded-subs-2.mp4 */ { CODEC_ID_QCELP , 0xE1 }, @@ -81,6 +82,7 @@ const AVCodecTag codec_movvideo_tags[] = { { CODEC_ID_RAWVIDEO, MKTAG('A', 'B', 'G', 'R') }, { CODEC_ID_RAWVIDEO, MKTAG('b', '1', '6', 'g') }, { CODEC_ID_RAWVIDEO, MKTAG('b', '4', '8', 'r') }, + { CODEC_ID_RAWVIDEO, MKTAG('D', 'V', 'O', 'O') }, /* Digital Voodoo SD 8 Bit */ { CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') }, /* UNCOMPRESSED 10BIT RGB */ { CODEC_ID_R10K, MKTAG('R', '1', '0', 'g') }, /* UNCOMPRESSED 10BIT RGB */ @@ -243,6 +245,8 @@ const AVCodecTag codec_movaudio_tags[] = { { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') }, /* MPEG-4 AAC */ { CODEC_ID_AC3, MKTAG('a', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F */ { CODEC_ID_AC3, MKTAG('s', 'a', 'c', '3') }, /* Nero Recode */ + { CODEC_ID_DTS, MKTAG('d', 't', 's', 'c') }, /* mp4ra.org */ + { CODEC_ID_DTS, MKTAG('D', 'T', 'S', ' ') }, /* non-standard */ { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') }, /* AMR-NB 3gp */ { CODEC_ID_AMR_WB, MKTAG('s', 'a', 'w', 'b') }, /* AMR-WB 3gp */ From f082a0fb420f0367bdd00219fd0fe8fe3caf7bc7 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 19 Jun 2011 18:41:14 +0100 Subject: [PATCH 011/780] configure: report optimization for size separately This removes an unsightly override of the 'optimizations' setting only to make the configure report print 'small' when --enable-small is used. Signed-off-by: Mans Rullgard --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 31e82fc6db..b26394ec29 100755 --- a/configure +++ b/configure @@ -3006,7 +3006,6 @@ fi if enabled small; then add_cflags $size_cflags - optimizations="small" elif enabled optimizations; then add_cflags $speed_cflags else @@ -3140,6 +3139,7 @@ if enabled sparc; then echo "VIS enabled ${vis-no}" fi echo "debug symbols ${debug-no}" +echo "optimize for size ${small-no}" echo "optimizations ${optimizations-no}" echo "static ${static-no}" echo "shared ${shared-no}" From 67e7dc54049d9b51a0c2168c8265145a9aef7780 Mon Sep 17 00:00:00 2001 From: ami_stuff Date: Tue, 24 May 2011 23:38:01 +0200 Subject: [PATCH 012/780] rawdec: Fix decoding of QT WRAW files. From some tests it results that: 1. All of the AVI/MOV WRAW files need to be flipped. 2. MOV WRAW files need to use AVI color modes. 3. Assigning PAL8 mode by default to WRAW codec is not correct. --- libavcodec/raw.c | 1 - libavcodec/rawdec.c | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index 4bc07b869a..aa1ea308b0 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -123,7 +123,6 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', '2') }, { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', 's') }, { PIX_FMT_YUYV422, MKTAG('D', 'V', 'O', 'O') }, /* Digital Voodoo SD 8 Bit */ - { PIX_FMT_PAL8, MKTAG('W', 'R', 'A', 'W') }, { PIX_FMT_RGB555LE,MKTAG('L', '5', '5', '5') }, { PIX_FMT_RGB565LE,MKTAG('L', '5', '6', '5') }, { PIX_FMT_RGB565BE,MKTAG('B', '5', '6', '5') }, diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 6b3387f636..5e8e6c4c43 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -78,6 +78,8 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx) if (avctx->codec_tag == MKTAG('r','a','w',' ')) avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_mov, avctx->bits_per_coded_sample); + else if (avctx->codec_tag == MKTAG('W','R','A','W')) + avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_avi, avctx->bits_per_coded_sample); else if (avctx->codec_tag) avctx->pix_fmt = find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag); else if (avctx->pix_fmt == PIX_FMT_NONE && avctx->bits_per_coded_sample) @@ -98,7 +100,7 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx) avctx->coded_frame= &context->pic; if((avctx->extradata_size >= 9 && !memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9)) || - avctx->codec_tag == MKTAG( 3 , 0 , 0 , 0 )) + avctx->codec_tag == MKTAG(3, 0, 0, 0) || avctx->codec_tag == MKTAG('W','R','A','W')) context->flip=1; return 0; From edf5fbd5b2e78f59d864332d0db1320b429e9dc0 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sun, 12 Jun 2011 20:13:18 -0700 Subject: [PATCH 013/780] CrystalHD: Simplfy extradata handling for non-Annex B content. Originally, we needed to restore the original extradata after initialising the mp4toannexb filter because mplayer would end up taking two passes through the init sequence for the same stream and end up miscategorising the stream. This doesn't seem to happen anymore, making the backup/restore process unnecessary. Signed-off-by: Philip Langdale --- libavcodec/crystalhd.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index ce1cd55228..4fd2cdf0c0 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -402,34 +402,19 @@ static av_cold int init(AVCodecContext *avctx) uint8_t *dummy_p; int dummy_int; - uint32_t orig_data_size = avctx->extradata_size; - uint8_t *orig_data = av_malloc(orig_data_size); - if (!orig_data) { - av_log(avctx, AV_LOG_ERROR, - "Failed to allocate copy of extradata\n"); - return AVERROR(ENOMEM); - } - memcpy(orig_data, avctx->extradata, orig_data_size); - + format.startCodeSz = (avctx->extradata[4] & 0x03) + 1; priv->bsfc = av_bitstream_filter_init("h264_mp4toannexb"); if (!priv->bsfc) { av_log(avctx, AV_LOG_ERROR, "Cannot open the h264_mp4toannexb BSF!\n"); - av_free(orig_data); return AVERROR_BSF_NOT_FOUND; } av_bitstream_filter_filter(priv->bsfc, avctx, NULL, &dummy_p, &dummy_int, NULL, 0, 0); - priv->sps_pps_buf = avctx->extradata; - priv->sps_pps_size = avctx->extradata_size; - avctx->extradata = orig_data; - avctx->extradata_size = orig_data_size; - - format.pMetaData = priv->sps_pps_buf; - format.metaDataSz = priv->sps_pps_size; - format.startCodeSz = (avctx->extradata[4] & 0x03) + 1; + format.pMetaData = avctx->extradata; + format.metaDataSz = avctx->extradata_size; } break; case BC_MSUBTYPE_H264: From 63e0697294ce0040fba58daa0a1de4e45dc4c677 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sat, 18 Jun 2011 11:00:37 -0700 Subject: [PATCH 014/780] CrystalHD: Always send filtered H.264 stream to hardware. As we're now always running mp4 format streams through the annex b filter, it makes sense to pass the filtered stream down, as libcrystalhd would be doing the conversion internally anyway. Signed-off-by: Philip Langdale --- libavcodec/crystalhd.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index 4fd2cdf0c0..632d774dfa 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -794,7 +794,9 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *a CopyRet rec_ret; CHDContext *priv = avctx->priv_data; HANDLE dev = priv->dev; + uint8_t *in_data = avpkt->data; int len = avpkt->size; + int free_data = 0; uint8_t pic_type = 0; av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: decode_frame\n"); @@ -819,15 +821,14 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *a int32_t tx_free = (int32_t)DtsTxFreeSize(dev); if (priv->parser) { - uint8_t *in_data = avpkt->data; - int in_len = len; int ret = 0; if (priv->bsfc) { ret = av_bitstream_filter_filter(priv->bsfc, avctx, NULL, - &in_data, &in_len, + &in_data, &len, avpkt->data, len, 0); } + free_data = ret > 0; if (ret >= 0) { uint8_t *pout; @@ -836,13 +837,13 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *a H264Context *h = priv->parser->priv_data; index = av_parser_parse2(priv->parser, avctx, &pout, &psize, - in_data, in_len, avctx->pkt->pts, + in_data, len, avctx->pkt->pts, avctx->pkt->dts, 0); if (index < 0) { av_log(avctx, AV_LOG_WARNING, "CrystalHD: Failed to parse h.264 packet to " "detect interlacing.\n"); - } else if (index != in_len) { + } else if (index != len) { av_log(avctx, AV_LOG_WARNING, "CrystalHD: Failed to parse h.264 packet " "completely. Interlaced frames may be " @@ -859,9 +860,6 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *a "packet. Interlaced frames may be incorrectly " "detected.\n"); } - if (ret > 0) { - av_freep(&in_data); - } } if (len < tx_free - 1024) { @@ -876,11 +874,17 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *a */ uint64_t pts = opaque_list_push(priv, avctx->pkt->pts, pic_type); if (!pts) { + if (free_data) { + av_freep(&in_data); + } return AVERROR(ENOMEM); } av_log(priv->avctx, AV_LOG_VERBOSE, "input \"pts\": %"PRIu64"\n", pts); - ret = DtsProcInput(dev, avpkt->data, len, pts, 0); + ret = DtsProcInput(dev, in_data, len, pts, 0); + if (free_data) { + av_freep(&in_data); + } if (ret == BC_STS_BUSY) { av_log(avctx, AV_LOG_WARNING, "CrystalHD: ProcInput returned busy\n"); From b2ad33dead8e97b8eee4e707e54dcd64b4854b8d Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sat, 18 Jun 2011 10:58:42 -0700 Subject: [PATCH 015/780] CrystalHD: Always identify H.264 streams as Annex B. Now that we're converting all streams to Annex B format, we can identify them as such to the hardware. Signed-off-by: Philip Langdale --- libavcodec/crystalhd.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index 632d774dfa..173f35607d 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -402,8 +402,6 @@ static av_cold int init(AVCodecContext *avctx) uint8_t *dummy_p; int dummy_int; - format.startCodeSz = (avctx->extradata[4] & 0x03) + 1; - priv->bsfc = av_bitstream_filter_init("h264_mp4toannexb"); if (!priv->bsfc) { av_log(avctx, AV_LOG_ERROR, @@ -412,11 +410,9 @@ static av_cold int init(AVCodecContext *avctx) } av_bitstream_filter_filter(priv->bsfc, avctx, NULL, &dummy_p, &dummy_int, NULL, 0, 0); - - format.pMetaData = avctx->extradata; - format.metaDataSz = avctx->extradata_size; } - break; + subtype = BC_MSUBTYPE_H264; + // Fall-through case BC_MSUBTYPE_H264: format.startCodeSz = 4; // Fall-through From 3b79f2e2e928eb346dbea85cc89393dcdf010ca9 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Mon, 20 Jun 2011 15:56:35 -0700 Subject: [PATCH 016/780] H.264: fix bug in lossless 4:4:4 decoding Coefficient test for i16x16 add_pixels4 assumed luma plane. --- libavcodec/h264.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 13a63809a0..124f9a88cd 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1744,7 +1744,7 @@ static av_always_inline void hl_decode_mb_idct_luma(H264Context *h, int mb_type, h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset, h->mb + (p*256 << pixel_shift), linesize); }else{ for(i=0; i<16; i++){ - if(h->non_zero_count_cache[ scan8[i+p*16] ] || dctcoef_get(h->mb, pixel_shift, i*16)) + if(h->non_zero_count_cache[ scan8[i+p*16] ] || dctcoef_get(h->mb, pixel_shift, i*16+p*256)) s->dsp.add_pixels4(dest_y + block_offset[i], h->mb + (i*16+p*256 << pixel_shift), linesize); } } From 85a88f9c0c0fcc2fc48121db1beb5ada68d24bdc Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Tue, 21 Jun 2011 01:10:37 -0700 Subject: [PATCH 017/780] H.264: reference the correct SPS in decode_scaling_matrices --- libavcodec/h264_ps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 9c41e4ca73..5ca2361a6d 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -281,12 +281,12 @@ static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_s decode_scaling_list(h,scaling_matrix4[5],16,default_scaling4[1],scaling_matrix4[4]); // Inter, Cb if(is_sps || pps->transform_8x8_mode){ decode_scaling_list(h,scaling_matrix8[0],64,default_scaling8[0],fallback[2]); // Intra, Y - if(h->sps.chroma_format_idc == 3){ + if(sps->chroma_format_idc == 3){ decode_scaling_list(h,scaling_matrix8[1],64,default_scaling8[0],scaling_matrix8[0]); // Intra, Cr decode_scaling_list(h,scaling_matrix8[2],64,default_scaling8[0],scaling_matrix8[1]); // Intra, Cb } decode_scaling_list(h,scaling_matrix8[3],64,default_scaling8[1],fallback[3]); // Inter, Y - if(h->sps.chroma_format_idc == 3){ + if(sps->chroma_format_idc == 3){ decode_scaling_list(h,scaling_matrix8[4],64,default_scaling8[1],scaling_matrix8[3]); // Inter, Cr decode_scaling_list(h,scaling_matrix8[5],64,default_scaling8[1],scaling_matrix8[4]); // Inter, Cb } From 932db250243812380640112fd27a59bc0642bc8a Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Tue, 21 Jun 2011 04:16:33 -0700 Subject: [PATCH 018/780] H.264: fix 4:4:4 cropping warning --- libavcodec/h264_ps.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 5ca2361a6d..7491807460 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -396,6 +396,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ #endif sps->crop= get_bits1(&s->gb); if(sps->crop){ + int crop_limit = sps->chroma_format_idc == 3 ? 16 : 8; sps->crop_left = get_ue_golomb(&s->gb); sps->crop_right = get_ue_golomb(&s->gb); sps->crop_top = get_ue_golomb(&s->gb); @@ -403,7 +404,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ if(sps->crop_left || sps->crop_top){ av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n"); } - if(sps->crop_right >= (8<crop_bottom >= (8<crop_right >= crop_limit || sps->crop_bottom >= crop_limit){ av_log(h->s.avctx, AV_LOG_ERROR, "brainfart cropping not supported, this could look slightly wrong ...\n"); } }else{ From 7c9079ab4cf0bcf34103fc9c5e49ec1fd7dd390c Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 22 Jun 2011 02:05:14 -0700 Subject: [PATCH 019/780] H.264: fix 4:4:4 + deblocking + MBAFF --- libavcodec/h264.c | 4 ++-- libavcodec/h264_loopfilter.c | 30 ++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 124f9a88cd..6bee7c39b0 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3300,8 +3300,8 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2; if(mb_y&1){ //FIXME move out of this function? dest_y -= s->linesize*15; - dest_cb-= s->uvlinesize*7; - dest_cr-= s->uvlinesize*7; + dest_cb-= s->uvlinesize*((8 << CHROMA444)-1); + dest_cr-= s->uvlinesize*((8 << CHROMA444)-1); } } else { linesize = h->mb_linesize = s->linesize; diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 1ae534ec96..b88c338804 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -663,19 +663,33 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0] ); filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1] ); if (chroma){ - filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0] ); - filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1] ); - filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0] ); - filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1] ); + if (CHROMA444) { + filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0] ); + filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1] ); + filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0] ); + filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1] ); + }else{ + filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0] ); + filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1] ); + filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0] ); + filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1] ); + } } }else{ filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0] ); filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1] ); if (chroma){ - filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0] ); - filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1] ); - filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0] ); - filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1] ); + if (CHROMA444) { + filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0] ); + filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1] ); + filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0] ); + filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1] ); + }else{ + filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0] ); + filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1] ); + filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0] ); + filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1] ); + } } } } From 2702a6f114f996ddfb334f1d8ddfae50e2c7eef7 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 22 Jun 2011 02:34:02 -0700 Subject: [PATCH 020/780] H.264: fix 4:4:4 + deblocking + 8x8dct + cavlc + MBAFF --- libavcodec/h264_loopfilter.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index b88c338804..86ecb2737f 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -393,10 +393,10 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u AV_WN64A(bS, 0x0003000300030003ULL); } else { if(!CABAC && IS_8x8DCT(s->current_picture.mb_type[mbn_xy])){ - bS[0]= 1+((h->cbp_table[mbn_xy] & 4)||h->non_zero_count_cache[scan8[0]+0]); - bS[1]= 1+((h->cbp_table[mbn_xy] & 4)||h->non_zero_count_cache[scan8[0]+1]); - bS[2]= 1+((h->cbp_table[mbn_xy] & 8)||h->non_zero_count_cache[scan8[0]+2]); - bS[3]= 1+((h->cbp_table[mbn_xy] & 8)||h->non_zero_count_cache[scan8[0]+3]); + bS[0]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+0]); + bS[1]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+1]); + bS[2]= 1+((h->cbp_table[mbn_xy] & 0x8000)||h->non_zero_count_cache[scan8[0]+2]); + bS[3]= 1+((h->cbp_table[mbn_xy] & 0x8000)||h->non_zero_count_cache[scan8[0]+3]); }else{ const uint8_t *mbn_nnz = h->non_zero_count[mbn_xy] + 3*4; int i; @@ -635,7 +635,7 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint else{ bS[i] = 1 + !!(h->non_zero_count_cache[12+8*(i>>1)] | ((!h->pps.cabac && IS_8x8DCT(mbn_type)) ? - (h->cbp_table[mbn_xy] & ((MB_FIELD ? (i&2) : (mb_y&1)) ? 8 : 2)) + (h->cbp_table[mbn_xy] & (((MB_FIELD ? (i&2) : (mb_y&1)) ? 8 : 2) << 12)) : h->non_zero_count[mbn_xy][ off[i] ])); } From 0e4dbe2996cad6d5e0b1c1d702306f3bd8499df9 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 21 Jun 2011 13:39:02 -0400 Subject: [PATCH 021/780] ac3enc: avoid masking output in asym_quant() by using signed values for quantized mantissas. --- libavcodec/ac3enc.c | 22 +++++++++++----------- libavcodec/ac3enc.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 3426bd252a..1db69414a5 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -46,7 +46,7 @@ #include "eac3enc.h" typedef struct AC3Mant { - uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; ///< mantissa pointers for bap=1,2,4 + int16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; ///< mantissa pointers for bap=1,2,4 int mant1_cnt, mant2_cnt, mant4_cnt; ///< mantissa counts for bap=1,2,4 } AC3Mant; @@ -1136,7 +1136,7 @@ static inline int asym_quant(int c, int e, int qbits) if (v >= m) v = m - 1; av_assert2(v >= -m); - return v & ((1 << qbits)-1); + return v; } @@ -1145,7 +1145,7 @@ static inline int asym_quant(int c, int e, int qbits) */ static void quantize_mantissas_blk_ch(AC3Mant *s, int32_t *fixed_coef, uint8_t *exp, uint8_t *bap, - uint16_t *qmant, int start_freq, + int16_t *qmant, int start_freq, int end_freq) { int i; @@ -1497,14 +1497,14 @@ static void output_audio_block(AC3EncodeContext *s, int blk) q = block->qmant[ch][i]; b = s->ref_bap[ch][blk][i]; switch (b) { - case 0: break; - case 1: if (q != 128) put_bits(&s->pb, 5, q); break; - case 2: if (q != 128) put_bits(&s->pb, 7, q); break; - case 3: put_bits(&s->pb, 3, q); break; - case 4: if (q != 128) put_bits(&s->pb, 7, q); break; - case 14: put_bits(&s->pb, 14, q); break; - case 15: put_bits(&s->pb, 16, q); break; - default: put_bits(&s->pb, b-1, q); break; + case 0: break; + case 1: if (q != 128) put_bits (&s->pb, 5, q); break; + case 2: if (q != 128) put_bits (&s->pb, 7, q); break; + case 3: put_sbits(&s->pb, 3, q); break; + case 4: if (q != 128) put_bits (&s->pb, 7, q); break; + case 14: put_sbits(&s->pb, 14, q); break; + case 15: put_sbits(&s->pb, 16, q); break; + default: put_sbits(&s->pb, b-1, q); break; } } if (ch == CPL_CH) diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index bf25298940..01abe94e0d 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -212,7 +212,7 @@ typedef struct AC3EncodeContext { int16_t *psd_buffer; int16_t *band_psd_buffer; int16_t *mask_buffer; - uint16_t *qmant_buffer; + int16_t *qmant_buffer; uint8_t *cpl_coord_exp_buffer; uint8_t *cpl_coord_mant_buffer; From f21fb76b1be18036c93c3e29fe1889a9fabf30b3 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 21 Jun 2011 16:14:19 -0400 Subject: [PATCH 022/780] ac3enc: remove a branch in asym_quant() by doing 2 shifts --- libavcodec/ac3enc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 1db69414a5..db45c8360e 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1123,15 +1123,9 @@ static inline int sym_quant(int c, int e, int levels) */ static inline int asym_quant(int c, int e, int qbits) { - int lshift, m, v; + int m, v; - lshift = e + qbits - 24; - if (lshift >= 0) - v = c << lshift; - else - v = c >> (-lshift); - /* rounding */ - v = (v + 1) >> 1; + v = (((c << e) >> (24 - qbits)) + 1) >> 1; m = (1 << (qbits-1)); if (v >= m) v = m - 1; From 684f4abfac6e007d3481e06e1c0777b826e3ba42 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 21 Jun 2011 16:49:16 -0400 Subject: [PATCH 023/780] ac3enc: remove unneeded local variable in asym_quant() --- libavcodec/ac3enc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index db45c8360e..1f7d05e87c 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1123,14 +1123,14 @@ static inline int sym_quant(int c, int e, int levels) */ static inline int asym_quant(int c, int e, int qbits) { - int m, v; + int m; - v = (((c << e) >> (24 - qbits)) + 1) >> 1; + c = (((c << e) >> (24 - qbits)) + 1) >> 1; m = (1 << (qbits-1)); - if (v >= m) - v = m - 1; - av_assert2(v >= -m); - return v; + if (c >= m) + c = m - 1; + av_assert2(c >= -m); + return c; } From f4228097e41575dbbef56d65b01eb585892ce66b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 21 Jun 2011 10:30:41 +0200 Subject: [PATCH 024/780] lavfi: minor style fixes in formats.c --- libavfilter/formats.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 49977c51fd..eccb52304b 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -30,7 +30,7 @@ static void merge_ref(AVFilterFormats *ret, AVFilterFormats *a) { int i; - for(i = 0; i < a->refcount; i ++) { + for (i = 0; i < a->refcount; i++) { ret->refs[ret->refcount] = a->refs[i]; *ret->refs[ret->refcount++] = ret; } @@ -52,14 +52,14 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) /* merge list of formats */ ret->formats = av_malloc(sizeof(*ret->formats) * FFMIN(a->format_count, b->format_count)); - for(i = 0; i < a->format_count; i ++) - for(j = 0; j < b->format_count; j ++) - if(a->formats[i] == b->formats[j]) + for (i = 0; i < a->format_count; i++) + for (j = 0; j < b->format_count; j++) + if (a->formats[i] == b->formats[j]) ret->formats[k++] = a->formats[i]; ret->format_count = k; /* check that there was at least one common format */ - if(!ret->format_count) { + if (!ret->format_count) { av_free(ret->formats); av_free(ret); return NULL; @@ -83,7 +83,7 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) if (!formats) return NULL; \ formats->format_count = count; \ if (count) { \ - formats->formats = av_malloc(sizeof(*formats->formats)*count); \ + formats->formats = av_malloc(sizeof(*formats->formats)*count); \ if (!formats->formats) { \ av_free(formats); \ return NULL; \ @@ -171,8 +171,8 @@ void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) static int find_ref_index(AVFilterFormats **ref) { int i; - for(i = 0; i < (*ref)->refcount; i ++) - if((*ref)->refs[i] == ref) + for (i = 0; i < (*ref)->refcount; i++) + if ((*ref)->refs[i] == ref) return i; return -1; } @@ -186,11 +186,11 @@ void avfilter_formats_unref(AVFilterFormats **ref) idx = find_ref_index(ref); - if(idx >= 0) + if (idx >= 0) memmove((*ref)->refs + idx, (*ref)->refs + idx+1, sizeof(AVFilterFormats**) * ((*ref)->refcount-idx-1)); - if(!--(*ref)->refcount) { + if (!--(*ref)->refcount) { av_free((*ref)->formats); av_free((*ref)->refs); av_free(*ref); @@ -203,7 +203,7 @@ void avfilter_formats_changeref(AVFilterFormats **oldref, { int idx = find_ref_index(oldref); - if(idx >= 0) { + if (idx >= 0) { (*oldref)->refs[idx] = newref; *newref = *oldref; *oldref = NULL; From c9584f0c9c5f3b84c3b2e9b2b9d3a7fdc2e0fd0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 22 Jun 2011 10:33:01 +0200 Subject: [PATCH 025/780] vf_mp: do not add duplicated pixel formats. This avoid a crash with in avfilter_merge_formats() in case one of the filter formats list has multiple time the same entry. Thanks to Mina Nagy Zaki for helping figuring out the issue. --- libavfilter/vf_mp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c index 36616b9c94..9e413b4776 100644 --- a/libavfilter/vf_mp.c +++ b/libavfilter/vf_mp.c @@ -41,6 +41,7 @@ //FIXME maybe link the orig in +//XXX: identical pix_fmt must be following with each others static const struct { int fmt; enum PixelFormat pix_fmt; @@ -785,13 +786,17 @@ static int query_formats(AVFilterContext *ctx) { AVFilterFormats *avfmts=NULL; MPContext *m = ctx->priv; + enum PixelFormat lastpixfmt = PIX_FMT_NONE; int i; for(i=0; conversion_map[i].fmt; i++){ av_log(ctx, AV_LOG_DEBUG, "query: %X\n", conversion_map[i].fmt); if(m->vf.query_format(&m->vf, conversion_map[i].fmt)){ av_log(ctx, AV_LOG_DEBUG, "supported,adding\n"); - avfilter_add_format(&avfmts, conversion_map[i].pix_fmt); + if (conversion_map[i].pix_fmt != lastpixfmt) { + avfilter_add_format(&avfmts, conversion_map[i].pix_fmt); + lastpixfmt = conversion_map[i].pix_fmt; + } } } From b6bde8c7702f6e6a485594fb5831e5bc04b2e763 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 9 Jun 2011 10:58:23 +0200 Subject: [PATCH 026/780] ffplay: use new avformat_open_* API. --- ffplay.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/ffplay.c b/ffplay.c index 96a8517b98..8788771491 100644 --- a/ffplay.c +++ b/ffplay.c @@ -27,6 +27,7 @@ #include "libavutil/colorspace.h" #include "libavutil/pixdesc.h" #include "libavutil/imgutils.h" +#include "libavutil/dict.h" #include "libavutil/parseutils.h" #include "libavutil/samplefmt.h" #include "libavutil/avassert.h" @@ -2295,15 +2296,13 @@ static int decode_interrupt_cb(void) static int read_thread(void *arg) { VideoState *is = arg; - AVFormatContext *ic; + AVFormatContext *ic = NULL; int err, i, ret; int st_index[AVMEDIA_TYPE_NB]; AVPacket pkt1, *pkt = &pkt1; - AVFormatParameters params, *ap = ¶ms; int eof=0; int pkt_in_play_range = 0; - - ic = avformat_alloc_context(); + AVDictionaryEntry *t; memset(st_index, -1, sizeof(st_index)); is->video_stream = -1; @@ -2313,30 +2312,17 @@ static int read_thread(void *arg) global_video_state = is; avio_set_interrupt_cb(decode_interrupt_cb); - memset(ap, 0, sizeof(*ap)); - - ap->prealloced_context = 1; - ap->width = frame_width; - ap->height= frame_height; - ap->time_base= (AVRational){1, 25}; - ap->pix_fmt = frame_pix_fmt; - ic->flags |= AVFMT_FLAG_PRIV_OPT; - - - err = av_open_input_file(&ic, is->filename, is->iformat, 0, ap); - if (err >= 0) { - set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM, NULL); - err = av_demuxer_open(ic, ap); - if(err < 0){ - avformat_free_context(ic); - ic= NULL; - } - } + err = avformat_open_input(&ic, is->filename, is->iformat, &format_opts); if (err < 0) { print_error(is->filename, err); ret = -1; goto fail; } + if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); + ret = AVERROR_OPTION_NOT_FOUND; + goto fail; + } is->ic = ic; if(genpts) From c956907eca740f609a4e19d32b43a01fbaedff75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Wed, 22 Jun 2011 18:25:49 +0200 Subject: [PATCH 027/780] Revert needless API change in 05e84c95. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When providing a custom AVIOContex for a AVFMT_NOFILE format only print a warning instead of erroring out. This allows the code to work with older MPlayer versions that just always set pb out of laziness. Signed-off-by: Reimar Döffinger --- libavformat/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index cd90480be6..e0a5455d75 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -591,7 +591,8 @@ static int init_input(AVFormatContext *s, const char *filename) if (!s->iformat) return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0); else if (s->iformat->flags & AVFMT_NOFILE) - return AVERROR(EINVAL); + av_log(s, AV_LOG_WARNING, "Custom AVIOContext makes no sense and " + "will be ignored with AVFMT_NOFILE format.\n"); return 0; } From 81ef892ca8a85f0ab6058a3ed40c05a82a151ba5 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 22 Jun 2011 21:42:09 +0200 Subject: [PATCH 028/780] Use HAVE_TEN_OPERANDS for new decode_significance* functions. --- libavcodec/h264_cabac.c | 2 +- libavcodec/x86/h264_i386.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 3975a61699..a373edbb4e 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1647,7 +1647,7 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT index[coeff_count++] = last;\ } const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD]; -#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) +#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) && HAVE_TEN_OPERANDS coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, last_coeff_ctx_base-significant_coeff_ctx_base, sig_off); } else { diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index c2477ac96b..982e8aa4fb 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -36,7 +36,7 @@ //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet //as that would make optimization work hard) -#if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) +#if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) && HAVE_TEN_OPERANDS static int decode_significance_x86(CABACContext *c, int max_coeff, uint8_t *significant_coeff_ctx_base, int *index, x86_reg last_off){ From 8ae1a9524ebeecc2287731c47aad517904c4f942 Mon Sep 17 00:00:00 2001 From: Alexis Ballier Date: Wed, 22 Jun 2011 22:25:14 +0200 Subject: [PATCH 029/780] This is to match gcc's {athlon64,k8,opteron}-sse3 -march flags. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 865851d9c1..486ef92633 100755 --- a/configure +++ b/configure @@ -2261,7 +2261,7 @@ elif enabled x86; then disable cmov ;; # targets that do support conditional mov (cmov) - i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10|barcelona|atom) + i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|amdfam10|barcelona|atom) cpuflags="-march=$cpu" enable cmov enable fast_cmov From 698a183e30a5803537ded99e4b7aee640373575c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 6 Jun 2011 19:44:29 +0100 Subject: [PATCH 030/780] build: move test rules to tests/Makefile Signed-off-by: Mans Rullgard --- Makefile | 123 ++----------------------------------------------- configure | 1 + tests/Makefile | 121 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 120 deletions(-) create mode 100644 tests/Makefile diff --git a/Makefile b/Makefile index 084e175b90..47d0429c0d 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,6 @@ tools/%.o: tools/%.c $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $< -include $(wildcard tools/*.d) --include $(wildcard tests/*.d) VERSION_SH = $(SRC_PATH_BARE)/version.sh GIT_LOG = $(SRC_PATH_BARE)/.git/logs/HEAD @@ -163,13 +162,7 @@ uninstall-data: uninstall-man: $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES)) -testclean: - $(RM) -r tests/vsynth1 tests/vsynth2 tests/data - $(RM) $(addprefix tests/,$(CLEANSUFFIXES)) - $(RM) tests/seek_test$(EXESUF) tests/seek_test.o - $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF)) - -clean:: testclean +clean:: $(RM) $(ALLPROGS) $(RM) $(CLEANSUFFIXES) $(RM) doc/*.html doc/*.pod doc/*.1 @@ -183,119 +176,9 @@ distclean:: config: $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION) -# regression tests - check: test checkheaders -fulltest test: codectest lavftest lavfitest seektest - -FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref - -codectest: fate-codec -lavftest: fate-lavf -lavfitest: fate-lavfi -seektest: fate-seek - -AREF = fate-acodec-aref -VREF = fate-vsynth1-vref fate-vsynth2-vref -REFS = $(AREF) $(VREF) - -$(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm -$(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw - -ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw - @echo - @echo "Unfortunately ffserver is broken and therefore its regression" - @echo "test fails randomly. Treat the results accordingly." - @echo - $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf - -tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF) - @mkdir -p tests/vsynth1 - $(M)./$< 'tests/vsynth1/' - -tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF) - @mkdir -p tests/vsynth2 - $(M)./$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm - -tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF) - @mkdir -p tests/data - $(M)./$< $@ - -tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN - -tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS) - $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) - -tools/lavfi-showfiltfmts$(EXESUF): tools/lavfi-showfiltfmts.o $(FF_DEP_LIBS) - $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) - -include $(SRC_PATH_BARE)/tests/fate.mak -include $(SRC_PATH_BARE)/tests/fate2.mak - -include $(SRC_PATH_BARE)/tests/fate/aac.mak -include $(SRC_PATH_BARE)/tests/fate/als.mak -include $(SRC_PATH_BARE)/tests/fate/fft.mak -include $(SRC_PATH_BARE)/tests/fate/h264.mak -include $(SRC_PATH_BARE)/tests/fate/mp3.mak -include $(SRC_PATH_BARE)/tests/fate/vorbis.mak -include $(SRC_PATH_BARE)/tests/fate/vp8.mak - -FATE_ACODEC = $(ACODEC_TESTS:%=fate-acodec-%) -FATE_VSYNTH1 = $(VCODEC_TESTS:%=fate-vsynth1-%) -FATE_VSYNTH2 = $(VCODEC_TESTS:%=fate-vsynth2-%) -FATE_VCODEC = $(FATE_VSYNTH1) $(FATE_VSYNTH2) -FATE_LAVF = $(LAVF_TESTS:%=fate-lavf-%) -FATE_LAVFI = $(LAVFI_TESTS:%=fate-lavfi-%) -FATE_SEEK = $(SEEK_TESTS:seek_%=fate-seek-%) - -FATE = $(FATE_ACODEC) \ - $(FATE_VCODEC) \ - $(FATE_LAVF) \ - $(FATE_LAVFI) \ - $(FATE_SEEK) \ - -$(filter-out %-aref,$(FATE_ACODEC)): $(AREF) -$(filter-out %-vref,$(FATE_VCODEC)): $(VREF) -$(FATE_LAVF): $(REFS) -$(FATE_LAVFI): $(REFS) tools/lavfi-showfiltfmts$(EXESUF) -$(FATE_SEEK): fate-codec fate-lavf tests/seek_test$(EXESUF) - -$(FATE_ACODEC): CMD = codectest acodec -$(FATE_VSYNTH1): CMD = codectest vsynth1 -$(FATE_VSYNTH2): CMD = codectest vsynth2 -$(FATE_LAVF): CMD = lavftest -$(FATE_LAVFI): CMD = lavfitest -$(FATE_SEEK): CMD = seektest - -fate-codec: fate-acodec fate-vcodec -fate-acodec: $(FATE_ACODEC) -fate-vcodec: $(FATE_VCODEC) -fate-lavf: $(FATE_LAVF) -fate-lavfi: $(FATE_LAVFI) -fate-seek: $(FATE_SEEK) - -ifdef SAMPLES -FATE += $(FATE_TESTS) -fate-rsync: - rsync -vaLW rsync://fate-suite.libav.org/fate-suite/ $(SAMPLES) -else -fate-rsync: - @echo "use 'make fate-rsync SAMPLES=/path/to/samples' to sync the fate suite" -$(FATE_TESTS): - @echo "SAMPLES not specified, cannot run FATE" -endif - -FATE_UTILS = base64 tiny_psnr - -fate: $(FATE) - -$(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF)) - @echo "TEST $(@:fate-%=%)" - $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' '$(THREAD_TYPE)' - -fate-list: - @printf '%s\n' $(sort $(FATE)) +include tests/Makefile .PHONY: all alltools *clean check config documentation examples install* -.PHONY: *test testprogs uninstall* +.PHONY: testprogs uninstall* diff --git a/configure b/configure index b26394ec29..d9a768e4d8 100755 --- a/configure +++ b/configure @@ -3231,6 +3231,7 @@ if enabled source_path_used; then libavutil/Makefile libpostproc/Makefile libswscale/Makefile + tests/Makefile " map 'mkdir -p $v' $DIRS; map 'test -f "$source_path/$v" && $ln_s "$source_path/$v" $v' $FILES diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000000..1f7ba26aff --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,121 @@ +fulltest test: codectest lavftest lavfitest seektest + +FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref + +codectest: fate-codec +lavftest: fate-lavf +lavfitest: fate-lavfi +seektest: fate-seek + +AREF = fate-acodec-aref +VREF = fate-vsynth1-vref fate-vsynth2-vref +REFS = $(AREF) $(VREF) + +$(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm +$(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw + +ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw + @echo + @echo "Unfortunately ffserver is broken and therefore its regression" + @echo "test fails randomly. Treat the results accordingly." + @echo + $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf + +tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF) + @mkdir -p tests/vsynth1 + $(M)./$< 'tests/vsynth1/' + +tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF) + @mkdir -p tests/vsynth2 + $(M)./$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm + +tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF) + @mkdir -p tests/data + $(M)./$< $@ + +tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN + +tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS) + $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) + +tools/lavfi-showfiltfmts$(EXESUF): tools/lavfi-showfiltfmts.o $(FF_DEP_LIBS) + $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) + +include $(SRC_PATH_BARE)/tests/fate.mak +include $(SRC_PATH_BARE)/tests/fate2.mak + +include $(SRC_PATH_BARE)/tests/fate/aac.mak +include $(SRC_PATH_BARE)/tests/fate/als.mak +include $(SRC_PATH_BARE)/tests/fate/fft.mak +include $(SRC_PATH_BARE)/tests/fate/h264.mak +include $(SRC_PATH_BARE)/tests/fate/mp3.mak +include $(SRC_PATH_BARE)/tests/fate/vorbis.mak +include $(SRC_PATH_BARE)/tests/fate/vp8.mak + +FATE_ACODEC = $(ACODEC_TESTS:%=fate-acodec-%) +FATE_VSYNTH1 = $(VCODEC_TESTS:%=fate-vsynth1-%) +FATE_VSYNTH2 = $(VCODEC_TESTS:%=fate-vsynth2-%) +FATE_VCODEC = $(FATE_VSYNTH1) $(FATE_VSYNTH2) +FATE_LAVF = $(LAVF_TESTS:%=fate-lavf-%) +FATE_LAVFI = $(LAVFI_TESTS:%=fate-lavfi-%) +FATE_SEEK = $(SEEK_TESTS:seek_%=fate-seek-%) + +FATE = $(FATE_ACODEC) \ + $(FATE_VCODEC) \ + $(FATE_LAVF) \ + $(FATE_LAVFI) \ + $(FATE_SEEK) \ + +$(filter-out %-aref,$(FATE_ACODEC)): $(AREF) +$(filter-out %-vref,$(FATE_VCODEC)): $(VREF) +$(FATE_LAVF): $(REFS) +$(FATE_LAVFI): $(REFS) tools/lavfi-showfiltfmts$(EXESUF) +$(FATE_SEEK): fate-codec fate-lavf tests/seek_test$(EXESUF) + +$(FATE_ACODEC): CMD = codectest acodec +$(FATE_VSYNTH1): CMD = codectest vsynth1 +$(FATE_VSYNTH2): CMD = codectest vsynth2 +$(FATE_LAVF): CMD = lavftest +$(FATE_LAVFI): CMD = lavfitest +$(FATE_SEEK): CMD = seektest + +fate-codec: fate-acodec fate-vcodec +fate-acodec: $(FATE_ACODEC) +fate-vcodec: $(FATE_VCODEC) +fate-lavf: $(FATE_LAVF) +fate-lavfi: $(FATE_LAVFI) +fate-seek: $(FATE_SEEK) + +ifdef SAMPLES +FATE += $(FATE_TESTS) +fate-rsync: + rsync -vaLW rsync://fate-suite.libav.org/fate-suite/ $(SAMPLES) +else +fate-rsync: + @echo "use 'make fate-rsync SAMPLES=/path/to/samples' to sync the fate suite" +$(FATE_TESTS): + @echo "SAMPLES not specified, cannot run FATE" +endif + +FATE_UTILS = base64 tiny_psnr + +fate: $(FATE) + +$(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF)) + @echo "TEST $(@:fate-%=%)" + $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' '$(THREAD_TYPE)' + +fate-list: + @printf '%s\n' $(sort $(FATE)) + +clean:: testclean + +testclean: + $(RM) -r tests/vsynth1 tests/vsynth2 tests/data + $(RM) $(addprefix tests/,$(CLEANSUFFIXES)) + $(RM) tests/seek_test$(EXESUF) tests/seek_test.o + $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF)) + +-include $(wildcard tests/*.d) + +.PHONY: fate* *test From f87b03b50d0b4632f95da5b5d6772ec8f2a7f16f Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 6 Jun 2011 18:03:22 +0100 Subject: [PATCH 031/780] build: move documentation rules to doc/Makefile Signed-off-by: Mans Rullgard --- Makefile | 41 +++-------------------------------------- configure | 1 + doc/Makefile | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 38 deletions(-) create mode 100644 doc/Makefile diff --git a/Makefile b/Makefile index 47d0429c0d..f4d03d42f8 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,6 @@ PROGS-$(CONFIG_FFSERVER) += ffserver PROGS := $(PROGS-yes:%=%$(EXESUF)) OBJS = $(PROGS-yes:%=%.o) cmdutils.o -MANPAGES = $(PROGS-yes:%=doc/%.1) -PODPAGES = $(PROGS-yes:%=doc/%.pod) -HTMLPAGES = $(PROGS-yes:%=doc/%.html) TOOLS = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher)) TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64 HOSTPROGS := $(TESTTOOLS:%=tests/%) @@ -48,8 +45,6 @@ FF_LDFLAGS := $(FFLDFLAGS) FF_EXTRALIBS := $(FFEXTRALIBS) FF_DEP_LIBS := $(DEP_LIBS) -all-$(CONFIG_DOC): documentation - all: $(FF_DEP_LIBS) $(PROGS) config.h: .config @@ -105,28 +100,6 @@ version.h .version: # force version.sh to run whenever version might have changed -include .version -DOCS = $(addprefix doc/, developer.html faq.html general.html libavfilter.html) $(HTMLPAGES) $(MANPAGES) $(PODPAGES) - -documentation: $(DOCS) - --include $(wildcard $(DOCS:%=%.d)) - -TEXIDEP = awk '/^@include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d) - -doc/%.html: TAG = HTML -doc/%.html: doc/%.texi $(SRC_PATH_BARE)/doc/t2h.init - $(Q)$(TEXIDEP) - $(M)texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init --output $@ $< - -doc/%.pod: TAG = POD -doc/%.pod: doc/%.texi - $(Q)$(TEXIDEP) - $(M)doc/texi2pod.pl $< $@ - -doc/%.1: TAG = MAN -doc/%.1: doc/%.pod - $(M)pod2man --section=1 --center=" " --release=" " $< > $@ - ifdef PROGS install: install-progs install-data endif @@ -136,7 +109,6 @@ install: install-libs install-headers install-libs: install-libs-yes install-progs-yes: -install-progs-$(CONFIG_DOC): install-man install-progs-$(CONFIG_SHARED): install-libs install-progs: install-progs-yes $(PROGS) @@ -147,11 +119,7 @@ install-data: $(DATA_FILES) $(Q)mkdir -p "$(DATADIR)" $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)" -install-man: $(MANPAGES) - $(Q)mkdir -p "$(MANDIR)/man1" - $(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1" - -uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data uninstall-man +uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data uninstall-progs: $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS)) @@ -159,13 +127,9 @@ uninstall-progs: uninstall-data: $(RM) -r "$(DATADIR)" -uninstall-man: - $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES)) - clean:: $(RM) $(ALLPROGS) $(RM) $(CLEANSUFFIXES) - $(RM) doc/*.html doc/*.pod doc/*.1 $(RM) $(TOOLS) $(RM) $(CLEANSUFFIXES:%=tools/%) @@ -178,7 +142,8 @@ config: check: test checkheaders +include doc/Makefile include tests/Makefile -.PHONY: all alltools *clean check config documentation examples install* +.PHONY: all alltools *clean check config examples install* .PHONY: testprogs uninstall* diff --git a/configure b/configure index d9a768e4d8..6f1560574f 100755 --- a/configure +++ b/configure @@ -3221,6 +3221,7 @@ if enabled source_path_used; then Makefile common.mak subdir.mak + doc/Makefile doc/texi2pod.pl libavcodec/Makefile libavcodec/${arch}/Makefile diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000000..a5e090b0cc --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,43 @@ +MANPAGES = $(PROGS-yes:%=doc/%.1) +PODPAGES = $(PROGS-yes:%=doc/%.pod) +HTMLPAGES = $(PROGS-yes:%=doc/%.html) + +DOCS = $(addprefix doc/, developer.html faq.html general.html libavfilter.html) $(HTMLPAGES) $(MANPAGES) $(PODPAGES) + +all-$(CONFIG_DOC): documentation + +documentation: $(DOCS) + +TEXIDEP = awk '/^@include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d) + +doc/%.html: TAG = HTML +doc/%.html: doc/%.texi $(SRC_PATH_BARE)/doc/t2h.init + $(Q)$(TEXIDEP) + $(M)texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init --output $@ $< + +doc/%.pod: TAG = POD +doc/%.pod: doc/%.texi + $(Q)$(TEXIDEP) + $(M)doc/texi2pod.pl $< $@ + +doc/%.1: TAG = MAN +doc/%.1: doc/%.pod + $(M)pod2man --section=1 --center=" " --release=" " $< > $@ + +install-progs-$(CONFIG_DOC): install-man + +install-man: $(MANPAGES) + $(Q)mkdir -p "$(MANDIR)/man1" + $(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1" + +uninstall: uninstall-man + +uninstall-man: + $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES)) + +clean:: + $(RM) doc/*.html doc/*.pod doc/*.1 $(CLEANSUFFIXES:%=doc/%) + +-include $(wildcard $(DOCS:%=%.d)) + +.PHONY: documentation From 9cd7b8549b71bcfced2062596fd9eecba092aeb1 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 19 Jun 2011 18:47:06 +0100 Subject: [PATCH 032/780] configure: add --optflags option This allows overriding the default optimisation flags selected by configure. Signed-off-by: Mans Rullgard --- configure | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 6f1560574f..4032e687ad 100755 --- a/configure +++ b/configure @@ -237,6 +237,7 @@ Advanced options (experts only): --malloc-prefix=PFX prefix malloc and related names with PFX --enable-sram allow use of on-chip SRAM --disable-symver disable symbol versioning + --optflags override optimization-related compiler flags Developer options (useful when working on Libav itself): --disable-debug disable debugging symbols @@ -1181,6 +1182,7 @@ CMDLINE_SET=" logfile malloc_prefix nm + optflags pkg_config samples sysinclude @@ -3004,7 +3006,9 @@ void ff_foo(void) {} EOF fi -if enabled small; then +if [ -n "$optflags" ]; then + add_cflags $optflags +elif enabled small; then add_cflags $size_cflags elif enabled optimizations; then add_cflags $speed_cflags From 72365be496f845a419dccda09f94b3e11ee26a4d Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 22 Jun 2011 21:17:31 +0200 Subject: [PATCH 033/780] general.texi: apply minor formatting fix in the MinGW section --- doc/general.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index e5e76db056..c50e3c8ef9 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -819,8 +819,8 @@ the FFmpeg Windows Help Forum at FFmpeg can be built to run natively on Windows using the MinGW tools. Install the latest versions of MSYS and MinGW from @url{http://www.mingw.org/}. -You can find detailed installation -instructions in the download section and the FAQ. +You can find detailed installation instructions in the download +section and the FAQ. FFmpeg does not build out-of-the-box with the packages the automated MinGW installer provides. It also requires coreutils to be installed and many other From 1af1b527727ccdfcfec8c02fa4e1ff291e9dd932 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 22 Jun 2011 21:16:40 +0200 Subject: [PATCH 034/780] general.texi: use "the FFmpeg libraries" in place of enumerating them Avoid an incomplete listing of the libav* libraries, and the need to update them again. --- doc/general.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/general.texi b/doc/general.texi index c50e3c8ef9..b6392d76e3 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -854,7 +854,7 @@ where SDL was installed. Verify that @file{sdl-config} can be launched from the MSYS command line. @item By using @code{./configure --enable-shared} when configuring FFmpeg, -you can build libavutil, libavcodec and libavformat as DLLs. +you can build the FFmpeg libraries as DLLs. @end itemize From 8986fddc2bab92bd7d77a123ac70c4fb70c96c7c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 14 Jun 2011 11:29:48 +0100 Subject: [PATCH 035/780] ARM: allow building in Thumb2 mode Signed-off-by: Mans Rullgard --- configure | 3 +- libavcodec/arm/aac.h | 3 + libavcodec/arm/ac3dsp_arm.S | 1 + libavcodec/arm/ac3dsp_armv6.S | 2 + libavcodec/arm/ac3dsp_neon.S | 1 + libavcodec/arm/asm.S | 93 +++++++++++++++++++++ libavcodec/arm/dcadsp_neon.S | 1 + libavcodec/arm/dsputil_arm.S | 10 +++ libavcodec/arm/dsputil_armv6.S | 76 +++++++++--------- libavcodec/arm/dsputil_neon.S | 3 + libavcodec/arm/dsputil_vfp.S | 21 +++++ libavcodec/arm/fmtconvert_neon.S | 4 + libavcodec/arm/fmtconvert_vfp.S | 3 + libavcodec/arm/h264dsp_neon.S | 98 +++++++++++++---------- libavcodec/arm/h264idct_neon.S | 23 ++++-- libavcodec/arm/mathops.h | 3 + libavcodec/arm/mdct_neon.S | 4 +- libavcodec/arm/mpegaudiodsp_fixed_armv6.S | 6 +- libavcodec/arm/mpegvideo_armv5te_s.S | 12 +++ libavcodec/arm/mpegvideo_neon.S | 4 + libavcodec/arm/rdft_neon.S | 1 + libavcodec/arm/simple_idct_arm.S | 32 ++++++-- libavcodec/arm/simple_idct_armv5te.S | 39 ++++++--- libavcodec/arm/simple_idct_armv6.S | 33 ++++---- libavcodec/arm/simple_idct_neon.S | 6 +- libavcodec/arm/synth_filter_neon.S | 2 + libavcodec/arm/vp56_arith.h | 27 ++++++- libavcodec/arm/vp8_armv6.S | 36 ++++++++- libavcodec/arm/vp8dsp_neon.S | 16 ++-- libavutil/arm/intmath.h | 2 + 30 files changed, 419 insertions(+), 146 deletions(-) diff --git a/configure b/configure index 4032e687ad..672d452849 100755 --- a/configure +++ b/configure @@ -967,6 +967,7 @@ CONFIG_LIST=" static swscale swscale_alpha + thumb vaapi vdpau version3 @@ -2607,7 +2608,7 @@ if enabled alpha; then elif enabled arm; then - check_cflags -marm + enabled thumb && check_cflags -mthumb || check_cflags -marm nogas=die if check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then diff --git a/libavcodec/arm/aac.h b/libavcodec/arm/aac.h index 6d5df4933a..83b5aef1b6 100644 --- a/libavcodec/arm/aac.h +++ b/libavcodec/arm/aac.h @@ -114,12 +114,15 @@ static inline float *VMUL4S(float *dst, const float *v, unsigned idx, "vmov d1, %2, %3 \n\t" "lsls %6, %6, #1 \n\t" "and %0, %5, #1<<31 \n\t" + "it cs \n\t" "lslcs %5, %5, #1 \n\t" "lsls %6, %6, #1 \n\t" "and %1, %5, #1<<31 \n\t" + "it cs \n\t" "lslcs %5, %5, #1 \n\t" "lsls %6, %6, #1 \n\t" "and %2, %5, #1<<31 \n\t" + "it cs \n\t" "lslcs %5, %5, #1 \n\t" "vmov d4, %0, %1 \n\t" "and %3, %5, #1<<31 \n\t" diff --git a/libavcodec/arm/ac3dsp_arm.S b/libavcodec/arm/ac3dsp_arm.S index 545714cff1..9a7d20eb7b 100644 --- a/libavcodec/arm/ac3dsp_arm.S +++ b/libavcodec/arm/ac3dsp_arm.S @@ -27,6 +27,7 @@ function ff_ac3_update_bap_counts_arm, export=1 lsl r3, lr, #1 ldrh r12, [r0, r3] subs r2, r2, #1 + it gt ldrbgt lr, [r1], #1 add r12, r12, #1 strh r12, [r0, r3] diff --git a/libavcodec/arm/ac3dsp_armv6.S b/libavcodec/arm/ac3dsp_armv6.S index 8026cb72e6..d3058ffcec 100644 --- a/libavcodec/arm/ac3dsp_armv6.S +++ b/libavcodec/arm/ac3dsp_armv6.S @@ -42,9 +42,11 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1 mov r11, r10 ldrb r10, [r4], #1 @ band_start_tab[band++] subs r9, r9, r5 @ - floor + it lt movlt r9, #0 cmp r10, r3 @ - end and r9, r9, r8 @ & 0x1fe0 + ite gt subgt r8, r3, r11 suble r8, r10, r11 add r9, r9, r5 @ + floor => m diff --git a/libavcodec/arm/ac3dsp_neon.S b/libavcodec/arm/ac3dsp_neon.S index 946b39f25b..fdf1deabc9 100644 --- a/libavcodec/arm/ac3dsp_neon.S +++ b/libavcodec/arm/ac3dsp_neon.S @@ -41,6 +41,7 @@ endfunc function ff_ac3_exponent_min_neon, export=1 cmp r1, #0 + it eq bxeq lr push {lr} mov r12, #256 diff --git a/libavcodec/arm/asm.S b/libavcodec/arm/asm.S index 8d7fe98614..a7d3ace208 100644 --- a/libavcodec/arm/asm.S +++ b/libavcodec/arm/asm.S @@ -24,9 +24,18 @@ # define ELF #else # define ELF @ +#endif + +#if CONFIG_THUMB +# define A @ +# define T +#else +# define A +# define T @ #endif .syntax unified +T .thumb .macro require8 val=1 ELF .eabi_attribute 24, \val @@ -82,6 +91,90 @@ ELF .size \name, . - \name #endif .endm +.macro ldr_pre rt, rn, rm:vararg +A ldr \rt, [\rn, \rm]! +T add \rn, \rn, \rm +T ldr \rt, [\rn] +.endm + +.macro ldr_post rt, rn, rm:vararg +A ldr \rt, [\rn], \rm +T ldr \rt, [\rn] +T add \rn, \rn, \rm +.endm + +.macro ldrd_reg rt, rt2, rn, rm +A ldrd \rt, \rt2, [\rn, \rm] +T add \rt, \rn, \rm +T ldrd \rt, \rt2, [\rt] +.endm + +.macro ldrd_post rt, rt2, rn, rm +A ldrd \rt, \rt2, [\rn], \rm +T ldrd \rt, \rt2, [\rn] +T add \rn, \rn, \rm +.endm + +.macro ldrh_pre rt, rn, rm +A ldrh \rt, [\rn, \rm]! +T add \rn, \rn, \rm +T ldrh \rt, [\rn] +.endm + +.macro ldrh_dpre rt, rn, rm +A ldrh \rt, [\rn, -\rm]! +T sub \rn, \rn, \rm +T ldrh \rt, [\rn] +.endm + +.macro ldrh_post rt, rn, rm +A ldrh \rt, [\rn], \rm +T ldrh \rt, [\rn] +T add \rn, \rn, \rm +.endm + +.macro str_post rt, rn, rm:vararg +A str \rt, [\rn], \rm +T str \rt, [\rn] +T add \rn, \rn, \rm +.endm + +.macro strb_post rt, rn, rm:vararg +A strb \rt, [\rn], \rm +T strb \rt, [\rn] +T add \rn, \rn, \rm +.endm + +.macro strd_post rt, rt2, rn, rm +A strd \rt, \rt2, [\rn], \rm +T strd \rt, \rt2, [\rn] +T add \rn, \rn, \rm +.endm + +.macro strh_pre rt, rn, rm +A strh \rt, [\rn, \rm]! +T add \rn, \rn, \rm +T strh \rt, [\rn] +.endm + +.macro strh_dpre rt, rn, rm +A strh \rt, [\rn, -\rm]! +T sub \rn, \rn, \rm +T strh \rt, [\rn] +.endm + +.macro strh_post rt, rn, rm +A strh \rt, [\rn], \rm +T strh \rt, [\rn] +T add \rn, \rn, \rm +.endm + +.macro strh_dpost rt, rn, rm +A strh \rt, [\rn], -\rm +T strh \rt, [\rn] +T sub \rn, \rn, \rm +.endm + #if HAVE_VFP_ARGS .eabi_attribute 28, 1 # define VFP diff --git a/libavcodec/arm/dcadsp_neon.S b/libavcodec/arm/dcadsp_neon.S index 61208361df..71f5dd843b 100644 --- a/libavcodec/arm/dcadsp_neon.S +++ b/libavcodec/arm/dcadsp_neon.S @@ -27,6 +27,7 @@ function ff_dca_lfe_fir_neon, export=1 add r5, r2, #256*4-16 @ cf1 sub r1, r1, #12 cmp r3, #32 + ite eq moveq r6, #256/32 movne r6, #256/64 NOVFP vldr s0, [sp, #16] @ scale diff --git a/libavcodec/arm/dsputil_arm.S b/libavcodec/arm/dsputil_arm.S index 21176283c4..eb20ad6d9e 100644 --- a/libavcodec/arm/dsputil_arm.S +++ b/libavcodec/arm/dsputil_arm.S @@ -554,10 +554,12 @@ endfunc and r9, r5, r14 and r10, r6, r14 and r11, r7, r14 + it eq andeq r14, r14, r14, \rnd #1 add r8, r8, r10 add r9, r9, r11 ldr r12, =0xfcfcfcfc >> 2 + itt eq addeq r8, r8, r14 addeq r9, r9, r14 and r4, r12, r4, lsr #2 @@ -638,8 +640,10 @@ function ff_add_pixels_clamped_arm, export=1 mvn r5, r5 mvn r7, r7 tst r6, #0x100 + it ne movne r6, r5, lsr #24 tst r8, #0x100 + it ne movne r8, r7, lsr #24 mov r9, r6 ldrsh r5, [r0, #4] /* moved form [A] */ @@ -654,8 +658,10 @@ function ff_add_pixels_clamped_arm, export=1 mvn r5, r5 mvn r7, r7 tst r6, #0x100 + it ne movne r6, r5, lsr #24 tst r8, #0x100 + it ne movne r8, r7, lsr #24 orr r9, r9, r6, lsl #16 ldr r4, [r1, #4] /* moved form [B] */ @@ -676,8 +682,10 @@ function ff_add_pixels_clamped_arm, export=1 mvn r5, r5 mvn r7, r7 tst r6, #0x100 + it ne movne r6, r5, lsr #24 tst r8, #0x100 + it ne movne r8, r7, lsr #24 mov r9, r6 ldrsh r5, [r0, #12] /* moved from [D] */ @@ -692,8 +700,10 @@ function ff_add_pixels_clamped_arm, export=1 mvn r5, r5 mvn r7, r7 tst r6, #0x100 + it ne movne r6, r5, lsr #24 tst r8, #0x100 + it ne movne r8, r7, lsr #24 orr r9, r9, r6, lsl #16 add r0, r0, #16 /* moved from [E] */ diff --git a/libavcodec/arm/dsputil_armv6.S b/libavcodec/arm/dsputil_armv6.S index 8acb96de2f..b8461059d9 100644 --- a/libavcodec/arm/dsputil_armv6.S +++ b/libavcodec/arm/dsputil_armv6.S @@ -47,16 +47,16 @@ function ff_put_pixels16_armv6, export=1 ldr r5, [r1, #4] ldr r6, [r1, #8] ldr r7, [r1, #12] - ldr r4, [r1], r2 + ldr_post r4, r1, r2 strd r6, r7, [r0, #8] ldr r9, [r1, #4] - strd r4, r5, [r0], r2 + strd_post r4, r5, r0, r2 ldr r10, [r1, #8] ldr r11, [r1, #12] - ldr r8, [r1], r2 + ldr_post r8, r1, r2 strd r10, r11, [r0, #8] subs r3, r3, #2 - strd r8, r9, [r0], r2 + strd_post r8, r9, r0, r2 bne 1b pop {r4-r11} @@ -67,12 +67,12 @@ function ff_put_pixels8_armv6, export=1 push {r4-r7} 1: ldr r5, [r1, #4] - ldr r4, [r1], r2 + ldr_post r4, r1, r2 ldr r7, [r1, #4] - strd r4, r5, [r0], r2 - ldr r6, [r1], r2 + strd_post r4, r5, r0, r2 + ldr_post r6, r1, r2 subs r3, r3, #2 - strd r6, r7, [r0], r2 + strd_post r6, r7, r0, r2 bne 1b pop {r4-r7} @@ -90,7 +90,7 @@ function ff_put_pixels8_x2_armv6, export=1 ldr r5, [r1, #4] ldr r7, [r1, #5] lsr r6, r4, #8 - ldr r8, [r1, r2]! + ldr_pre r8, r1, r2 orr r6, r6, r5, lsl #24 ldr r9, [r1, #4] ldr r11, [r1, #5] @@ -112,9 +112,9 @@ function ff_put_pixels8_x2_armv6, export=1 uhadd8 r9, r9, r11 and r6, r6, r12 uadd8 r8, r8, r14 - strd r4, r5, [r0], r2 + strd_post r4, r5, r0, r2 uadd8 r9, r9, r6 - strd r8, r9, [r0], r2 + strd_post r8, r9, r0, r2 bne 1b pop {r4-r11, pc} @@ -127,7 +127,7 @@ function ff_put_pixels8_y2_armv6, export=1 orr r12, r12, r12, lsl #16 ldr r4, [r1] ldr r5, [r1, #4] - ldr r6, [r1, r2]! + ldr_pre r6, r1, r2 ldr r7, [r1, #4] 1: subs r3, r3, #2 @@ -136,7 +136,7 @@ function ff_put_pixels8_y2_armv6, export=1 uhadd8 r9, r5, r7 eor r11, r5, r7 and r10, r10, r12 - ldr r4, [r1, r2]! + ldr_pre r4, r1, r2 uadd8 r8, r8, r10 and r11, r11, r12 uadd8 r9, r9, r11 @@ -148,11 +148,11 @@ function ff_put_pixels8_y2_armv6, export=1 eor r7, r5, r7 uadd8 r10, r10, r6 and r7, r7, r12 - ldr r6, [r1, r2]! + ldr_pre r6, r1, r2 uadd8 r11, r11, r7 - strd r8, r9, [r0], r2 + strd_post r8, r9, r0, r2 ldr r7, [r1, #4] - strd r10, r11, [r0], r2 + strd_post r10, r11, r0, r2 bne 1b pop {r4-r11} @@ -166,7 +166,7 @@ function ff_put_pixels8_x2_no_rnd_armv6, export=1 ldr r4, [r1] ldr r5, [r1, #4] ldr r7, [r1, #5] - ldr r8, [r1, r2]! + ldr_pre r8, r1, r2 ldr r9, [r1, #4] ldr r14, [r1, #5] add r1, r1, r2 @@ -191,16 +191,16 @@ function ff_put_pixels8_y2_no_rnd_armv6, export=1 push {r4-r9, lr} ldr r4, [r1] ldr r5, [r1, #4] - ldr r6, [r1, r2]! + ldr_pre r6, r1, r2 ldr r7, [r1, #4] 1: subs r3, r3, #2 uhadd8 r8, r4, r6 - ldr r4, [r1, r2]! + ldr_pre r4, r1, r2 uhadd8 r9, r5, r7 ldr r5, [r1, #4] uhadd8 r12, r4, r6 - ldr r6, [r1, r2]! + ldr_pre r6, r1, r2 uhadd8 r14, r5, r7 ldr r7, [r1, #4] stm r0, {r8,r9} @@ -220,44 +220,44 @@ function ff_avg_pixels8_armv6, export=1 orr lr, lr, lr, lsl #16 ldrd r4, r5, [r0] ldr r10, [r1, #4] - ldr r9, [r1], r2 + ldr_post r9, r1, r2 subs r3, r3, #2 1: pld [r1, r2] eor r8, r4, r9 uhadd8 r4, r4, r9 eor r12, r5, r10 - ldrd r6, r7, [r0, r2] + ldrd_reg r6, r7, r0, r2 uhadd8 r5, r5, r10 and r8, r8, lr ldr r10, [r1, #4] and r12, r12, lr uadd8 r4, r4, r8 - ldr r9, [r1], r2 + ldr_post r9, r1, r2 eor r8, r6, r9 uadd8 r5, r5, r12 pld [r1, r2, lsl #1] eor r12, r7, r10 uhadd8 r6, r6, r9 - strd r4, r5, [r0], r2 + strd_post r4, r5, r0, r2 uhadd8 r7, r7, r10 beq 2f and r8, r8, lr - ldrd r4, r5, [r0, r2] + ldrd_reg r4, r5, r0, r2 uadd8 r6, r6, r8 ldr r10, [r1, #4] and r12, r12, lr subs r3, r3, #2 uadd8 r7, r7, r12 - ldr r9, [r1], r2 - strd r6, r7, [r0], r2 + ldr_post r9, r1, r2 + strd_post r6, r7, r0, r2 b 1b 2: and r8, r8, lr and r12, r12, lr uadd8 r6, r6, r8 uadd8 r7, r7, r12 - strd r6, r7, [r0], r2 + strd_post r6, r7, r0, r2 pop {r4-r10, pc} endfunc @@ -284,7 +284,7 @@ function ff_add_pixels_clamped_armv6, export=1 orr r6, r8, r5, lsl #8 orr r7, r4, lr, lsl #8 subs r3, r3, #1 - strd r6, r7, [r1], r2 + strd_post r6, r7, r1, r2 bgt 1b pop {r4-r8,pc} endfunc @@ -294,7 +294,7 @@ function ff_get_pixels_armv6, export=1 push {r4-r8, lr} mov lr, #8 1: - ldrd r4, r5, [r1], r2 + ldrd_post r4, r5, r1, r2 subs lr, lr, #1 uxtb16 r6, r4 uxtb16 r4, r4, ror #8 @@ -317,8 +317,8 @@ function ff_diff_pixels_armv6, export=1 push {r4-r9, lr} mov lr, #8 1: - ldrd r4, r5, [r1], r3 - ldrd r6, r7, [r2], r3 + ldrd_post r4, r5, r1, r3 + ldrd_post r6, r7, r2, r3 uxtb16 r8, r4 uxtb16 r4, r4, ror #8 uxtb16 r9, r6 @@ -492,19 +492,19 @@ function ff_pix_abs8_armv6, export=1 push {r4-r9, lr} mov r0, #0 mov lr, #0 - ldrd r4, r5, [r1], r3 + ldrd_post r4, r5, r1, r3 1: subs r12, r12, #2 ldr r7, [r2, #4] - ldr r6, [r2], r3 - ldrd r8, r9, [r1], r3 + ldr_post r6, r2, r3 + ldrd_post r8, r9, r1, r3 usada8 r0, r4, r6, r0 pld [r2, r3] usada8 lr, r5, r7, lr ldr r7, [r2, #4] - ldr r6, [r2], r3 + ldr_post r6, r2, r3 beq 2f - ldrd r4, r5, [r1], r3 + ldrd_post r4, r5, r1, r3 usada8 r0, r8, r6, r0 pld [r2, r3] usada8 lr, r9, r7, lr @@ -613,7 +613,7 @@ function ff_pix_sum_armv6, export=1 ldr r7, [r0, #12] usada8 r2, r6, lr, r2 beq 2f - ldr r4, [r0, r1]! + ldr_pre r4, r0, r1 usada8 r3, r7, lr, r3 bgt 1b 2: diff --git a/libavcodec/arm/dsputil_neon.S b/libavcodec/arm/dsputil_neon.S index 5b80e40d6f..5e3bf27f67 100644 --- a/libavcodec/arm/dsputil_neon.S +++ b/libavcodec/arm/dsputil_neon.S @@ -531,6 +531,7 @@ function ff_vorbis_inverse_coupling_neon, export=1 2: vst1.32 {d2-d3}, [r3, :128]! vst1.32 {d0-d1}, [r12,:128]! + it lt bxlt lr 3: vld1.32 {d2-d3}, [r1,:128] @@ -575,6 +576,7 @@ NOVFP vdup.32 q8, r2 2: vst1.32 {q2},[r0,:128]! vst1.32 {q3},[r0,:128]! ands len, len, #15 + it eq bxeq lr 3: vld1.32 {q0},[r1,:128]! vmul.f32 q0, q0, q8 @@ -638,6 +640,7 @@ NOVFP ldr r3, [sp] 2: vst1.32 {q8},[r0,:128]! vst1.32 {q9},[r0,:128]! ands r3, r3, #7 + it eq popeq {pc} 3: vld1.32 {q0},[r1,:128]! ldr r12, [r2], #4 diff --git a/libavcodec/arm/dsputil_vfp.S b/libavcodec/arm/dsputil_vfp.S index 16ea25afe6..cbc4bd6c70 100644 --- a/libavcodec/arm/dsputil_vfp.S +++ b/libavcodec/arm/dsputil_vfp.S @@ -55,18 +55,23 @@ function ff_vector_fmul_vfp, export=1 1: subs r3, r3, #16 vmul.f32 s12, s4, s12 + itttt ge vldmiage r1!, {s16-s19} vldmiage r2!, {s24-s27} vldmiage r1!, {s20-s23} vldmiage r2!, {s28-s31} + it ge vmulge.f32 s24, s16, s24 vstmia r0!, {s8-s11} vstmia r0!, {s12-s15} + it ge vmulge.f32 s28, s20, s28 + itttt gt vldmiagt r1!, {s0-s3} vldmiagt r2!, {s8-s11} vldmiagt r1!, {s4-s7} vldmiagt r2!, {s12-s15} + ittt ge vmulge.f32 s8, s0, s8 vstmiage r0!, {s24-s27} vstmiage r0!, {s28-s31} @@ -97,33 +102,49 @@ function ff_vector_fmul_reverse_vfp, export=1 vmul.f32 s11, s0, s11 1: subs r3, r3, #16 + it ge vldmdbge r2!, {s16-s19} vmul.f32 s12, s7, s12 + it ge vldmiage r1!, {s24-s27} vmul.f32 s13, s6, s13 + it ge vldmdbge r2!, {s20-s23} vmul.f32 s14, s5, s14 + it ge vldmiage r1!, {s28-s31} vmul.f32 s15, s4, s15 + it ge vmulge.f32 s24, s19, s24 + it gt vldmdbgt r2!, {s0-s3} + it ge vmulge.f32 s25, s18, s25 vstmia r0!, {s8-s13} + it ge vmulge.f32 s26, s17, s26 + it gt vldmiagt r1!, {s8-s11} + itt ge vmulge.f32 s27, s16, s27 vmulge.f32 s28, s23, s28 + it gt vldmdbgt r2!, {s4-s7} + it ge vmulge.f32 s29, s22, s29 vstmia r0!, {s14-s15} + ittt ge vmulge.f32 s30, s21, s30 vmulge.f32 s31, s20, s31 vmulge.f32 s8, s3, s8 + it gt vldmiagt r1!, {s12-s15} + itttt ge vmulge.f32 s9, s2, s9 vmulge.f32 s10, s1, s10 vstmiage r0!, {s24-s27} vmulge.f32 s11, s0, s11 + it ge vstmiage r0!, {s28-s31} bgt 1b diff --git a/libavcodec/arm/fmtconvert_neon.S b/libavcodec/arm/fmtconvert_neon.S index 4b0e9a2d6a..45cc84b7ec 100644 --- a/libavcodec/arm/fmtconvert_neon.S +++ b/libavcodec/arm/fmtconvert_neon.S @@ -71,6 +71,7 @@ endfunc function ff_float_to_int16_interleave_neon, export=1 cmp r3, #2 + itt lt ldrlt r1, [r1] blt ff_float_to_int16_neon bne 4f @@ -196,6 +197,7 @@ function ff_float_to_int16_interleave_neon, export=1 vst1.64 {d3}, [r8], ip vst1.64 {d7}, [r8], ip subs r3, r3, #4 + it eq popeq {r4-r8,pc} cmp r3, #4 add r0, r0, #8 @@ -305,6 +307,7 @@ function ff_float_to_int16_interleave_neon, export=1 vst1.32 {d23[1]}, [r8], ip 8: subs r3, r3, #2 add r0, r0, #4 + it eq popeq {r4-r8,pc} @ 1 channel @@ -354,6 +357,7 @@ function ff_float_to_int16_interleave_neon, export=1 vst1.16 {d2[3]}, [r5,:16], ip vst1.16 {d3[1]}, [r5,:16], ip vst1.16 {d3[3]}, [r5,:16], ip + it eq popeq {r4-r8,pc} vld1.64 {d0-d1}, [r4,:128]! vcvt.s32.f32 q0, q0, #16 diff --git a/libavcodec/arm/fmtconvert_vfp.S b/libavcodec/arm/fmtconvert_vfp.S index 1bb7f49801..f7b0e3dcb5 100644 --- a/libavcodec/arm/fmtconvert_vfp.S +++ b/libavcodec/arm/fmtconvert_vfp.S @@ -46,6 +46,7 @@ function ff_float_to_int16_vfp, export=1 vmov r5, r6, s2, s3 vmov r7, r8, s4, s5 vmov ip, lr, s6, s7 + it gt vldmiagt r1!, {s16-s23} ssat r4, #16, r4 ssat r3, #16, r3 @@ -53,10 +54,12 @@ function ff_float_to_int16_vfp, export=1 ssat r5, #16, r5 pkhbt r3, r3, r4, lsl #16 pkhbt r4, r5, r6, lsl #16 + itttt gt vcvtgt.s32.f32 s0, s16 vcvtgt.s32.f32 s1, s17 vcvtgt.s32.f32 s2, s18 vcvtgt.s32.f32 s3, s19 + itttt gt vcvtgt.s32.f32 s4, s20 vcvtgt.s32.f32 s5, s21 vcvtgt.s32.f32 s6, s22 diff --git a/libavcodec/arm/h264dsp_neon.S b/libavcodec/arm/h264dsp_neon.S index b76e4479b5..0fa4a6b0a5 100644 --- a/libavcodec/arm/h264dsp_neon.S +++ b/libavcodec/arm/h264dsp_neon.S @@ -71,7 +71,9 @@ function ff_\type\()_h264_chroma_mc8_neon, export=1 pld [r1] pld [r1, r2] - muls r7, r4, r5 +A muls r7, r4, r5 +T mul r7, r4, r5 +T cmp r7, #0 rsb r6, r7, r5, lsl #3 rsb ip, r7, r4, lsl #3 sub r4, r7, r4, lsl #3 @@ -197,7 +199,9 @@ function ff_\type\()_h264_chroma_mc4_neon, export=1 pld [r1] pld [r1, r2] - muls r7, r4, r5 +A muls r7, r4, r5 +T mul r7, r4, r5 +T cmp r7, #0 rsb r6, r7, r5, lsl #3 rsb ip, r7, r4, lsl #3 sub r4, r7, r4, lsl #3 @@ -368,10 +372,10 @@ function ff_\type\()_h264_chroma_mc2_neon, export=1 pop {r4-r6, pc} 2: .ifc \type,put - ldrh r5, [r1], r2 - strh r5, [r0], r2 - ldrh r6, [r1], r2 - strh r6, [r0], r2 + ldrh_post r5, r1, r2 + strh_post r5, r0, r2 + ldrh_post r6, r1, r2 + strh_post r6, r0, r2 .else vld1.16 {d16[0]}, [r1], r2 vld1.16 {d16[1]}, [r1], r2 @@ -404,28 +408,17 @@ endfunc ldr ip, [sp] tst r2, r2 ldr ip, [ip] + it ne tstne r3, r3 vmov.32 d24[0], ip and ip, ip, ip, lsl #16 + it eq bxeq lr ands ip, ip, ip, lsl #8 + it lt bxlt lr .endm - .macro align_push_regs - and ip, sp, #15 - add ip, ip, #32 - sub sp, sp, ip - vst1.64 {d12-d15}, [sp,:128] - sub sp, sp, #32 - vst1.64 {d8-d11}, [sp,:128] - .endm - - .macro align_pop_regs - vld1.64 {d8-d11}, [sp,:128]! - vld1.64 {d12-d15}, [sp,:128], ip - .endm - .macro h264_loop_filter_luma vdup.8 q11, r2 @ alpha vmovl.u8 q12, d24 @@ -506,7 +499,7 @@ function ff_h264_v_loop_filter_luma_neon, export=1 vld1.64 {d18,d19}, [r0,:128], r1 vld1.64 {d16,d17}, [r0,:128], r1 - align_push_regs + vpush {d8-d15} h264_loop_filter_luma @@ -516,7 +509,7 @@ function ff_h264_v_loop_filter_luma_neon, export=1 vst1.64 {d0, d1}, [r0,:128], r1 vst1.64 {d10,d11}, [r0,:128] - align_pop_regs + vpop {d8-d15} bx lr endfunc @@ -543,7 +536,7 @@ function ff_h264_h_loop_filter_luma_neon, export=1 transpose_8x8 q3, q10, q9, q8, q0, q1, q2, q13 - align_push_regs + vpush {d8-d15} h264_loop_filter_luma @@ -568,7 +561,7 @@ function ff_h264_h_loop_filter_luma_neon, export=1 vst1.32 {d1[1]}, [r0], r1 vst1.32 {d11[1]}, [r0], r1 - align_pop_regs + vpop {d8-d15} bx lr endfunc @@ -1116,6 +1109,7 @@ function \type\()_h264_qpel8_hv_lowpass_neon vrhadd.u8 d11, d11, d7 sub r0, r0, r2, lsl #3 .endif + vst1.64 {d12}, [r0,:64], r2 vst1.64 {d13}, [r0,:64], r2 vst1.64 {d14}, [r0,:64], r2 @@ -1263,7 +1257,9 @@ function ff_\type\()_h264_qpel8_mc11_neon, export=1 \type\()_h264_qpel8_mc11: lowpass_const r3 mov r11, sp - bic sp, sp, #15 +A bic sp, sp, #15 +T bic r0, r11, #15 +T mov sp, r0 sub sp, sp, #64 mov r0, sp sub r1, r1, #2 @@ -1271,14 +1267,14 @@ function ff_\type\()_h264_qpel8_mc11_neon, export=1 mov ip, #8 vpush {d8-d15} bl put_h264_qpel8_h_lowpass_neon - ldrd r0, [r11] + ldrd r0, [r11], #8 mov r3, r2 add ip, sp, #64 sub r1, r1, r2, lsl #1 mov r2, #8 bl \type\()_h264_qpel8_v_lowpass_l2_neon vpop {d8-d15} - add sp, r11, #8 + mov sp, r11 pop {r11, pc} endfunc @@ -1287,7 +1283,9 @@ function ff_\type\()_h264_qpel8_mc21_neon, export=1 \type\()_h264_qpel8_mc21: lowpass_const r3 mov r11, sp - bic sp, sp, #15 +A bic sp, sp, #15 +T bic r0, r11, #15 +T mov sp, r0 sub sp, sp, #(8*8+16*12) sub r1, r1, #2 mov r3, #8 @@ -1296,14 +1294,14 @@ function ff_\type\()_h264_qpel8_mc21_neon, export=1 vpush {d8-d15} bl put_h264_qpel8_h_lowpass_neon mov r4, r0 - ldrd r0, [r11] + ldrd r0, [r11], #8 sub r1, r1, r2, lsl #1 sub r1, r1, #2 mov r3, r2 sub r2, r4, #64 bl \type\()_h264_qpel8_hv_lowpass_l2_neon vpop {d8-d15} - add sp, r11, #8 + mov sp, r11 pop {r4, r10, r11, pc} endfunc @@ -1330,7 +1328,9 @@ function ff_\type\()_h264_qpel8_mc12_neon, export=1 \type\()_h264_qpel8_mc12: lowpass_const r3 mov r11, sp - bic sp, sp, #15 +A bic sp, sp, #15 +T bic r0, r11, #15 +T mov sp, r0 sub sp, sp, #(8*8+16*12) sub r1, r1, r2, lsl #1 mov r3, r2 @@ -1339,20 +1339,22 @@ function ff_\type\()_h264_qpel8_mc12_neon, export=1 vpush {d8-d15} bl put_h264_qpel8_v_lowpass_neon mov r4, r0 - ldrd r0, [r11] + ldrd r0, [r11], #8 sub r1, r1, r3, lsl #1 sub r1, r1, #2 sub r2, r4, #64 bl \type\()_h264_qpel8_hv_lowpass_l2_neon vpop {d8-d15} - add sp, r11, #8 + mov sp, r11 pop {r4, r10, r11, pc} endfunc function ff_\type\()_h264_qpel8_mc22_neon, export=1 push {r4, r10, r11, lr} mov r11, sp - bic sp, sp, #15 +A bic sp, sp, #15 +T bic r4, r11, #15 +T mov sp, r4 sub r1, r1, r2, lsl #1 sub r1, r1, #2 mov r3, r2 @@ -1441,21 +1443,23 @@ function ff_\type\()_h264_qpel16_mc11_neon, export=1 \type\()_h264_qpel16_mc11: lowpass_const r3 mov r11, sp - bic sp, sp, #15 +A bic sp, sp, #15 +T bic r0, r11, #15 +T mov sp, r0 sub sp, sp, #256 mov r0, sp sub r1, r1, #2 mov r3, #16 vpush {d8-d15} bl put_h264_qpel16_h_lowpass_neon - ldrd r0, [r11] + ldrd r0, [r11], #8 mov r3, r2 add ip, sp, #64 sub r1, r1, r2, lsl #1 mov r2, #16 bl \type\()_h264_qpel16_v_lowpass_l2_neon vpop {d8-d15} - add sp, r11, #8 + mov sp, r11 pop {r4, r11, pc} endfunc @@ -1464,20 +1468,22 @@ function ff_\type\()_h264_qpel16_mc21_neon, export=1 \type\()_h264_qpel16_mc21: lowpass_const r3 mov r11, sp - bic sp, sp, #15 +A bic sp, sp, #15 +T bic r0, r11, #15 +T mov sp, r0 sub sp, sp, #(16*16+16*12) sub r1, r1, #2 mov r0, sp vpush {d8-d15} bl put_h264_qpel16_h_lowpass_neon_packed mov r4, r0 - ldrd r0, [r11] + ldrd r0, [r11], #8 sub r1, r1, r2, lsl #1 sub r1, r1, #2 mov r3, r2 bl \type\()_h264_qpel16_hv_lowpass_l2_neon vpop {d8-d15} - add sp, r11, #8 + mov sp, r11 pop {r4-r5, r9-r11, pc} endfunc @@ -1504,7 +1510,9 @@ function ff_\type\()_h264_qpel16_mc12_neon, export=1 \type\()_h264_qpel16_mc12: lowpass_const r3 mov r11, sp - bic sp, sp, #15 +A bic sp, sp, #15 +T bic r0, r11, #15 +T mov sp, r0 sub sp, sp, #(16*16+16*12) sub r1, r1, r2, lsl #1 mov r0, sp @@ -1512,13 +1520,13 @@ function ff_\type\()_h264_qpel16_mc12_neon, export=1 vpush {d8-d15} bl put_h264_qpel16_v_lowpass_neon_packed mov r4, r0 - ldrd r0, [r11] + ldrd r0, [r11], #8 sub r1, r1, r3, lsl #1 sub r1, r1, #2 mov r2, r3 bl \type\()_h264_qpel16_hv_lowpass_l2_neon vpop {d8-d15} - add sp, r11, #8 + mov sp, r11 pop {r4-r5, r9-r11, pc} endfunc @@ -1526,7 +1534,9 @@ function ff_\type\()_h264_qpel16_mc22_neon, export=1 push {r4, r9-r11, lr} lowpass_const r3 mov r11, sp - bic sp, sp, #15 +A bic sp, sp, #15 +T bic r4, r11, #15 +T mov sp, r4 sub r1, r1, r2, lsl #1 sub r1, r1, #2 mov r3, r2 diff --git a/libavcodec/arm/h264idct_neon.S b/libavcodec/arm/h264idct_neon.S index 3c743e1607..eadf2e711d 100644 --- a/libavcodec/arm/h264idct_neon.S +++ b/libavcodec/arm/h264idct_neon.S @@ -106,10 +106,12 @@ function ff_h264_idct_add16_neon, export=1 blt 2f ldrsh lr, [r1] add r0, r0, r4 + it ne movne lr, #0 cmp lr, #0 - adrne lr, ff_h264_idct_dc_add_neon - adreq lr, ff_h264_idct_add_neon + ite ne + adrne lr, ff_h264_idct_dc_add_neon + CONFIG_THUMB + adreq lr, ff_h264_idct_add_neon + CONFIG_THUMB blx lr 2: subs ip, ip, #1 add r1, r1, #32 @@ -132,8 +134,9 @@ function ff_h264_idct_add16intra_neon, export=1 add r0, r0, r4 cmp r8, #0 ldrsh r8, [r1] - adrne lr, ff_h264_idct_add_neon - adreq lr, ff_h264_idct_dc_add_neon + iteet ne + adrne lr, ff_h264_idct_add_neon + CONFIG_THUMB + adreq lr, ff_h264_idct_dc_add_neon + CONFIG_THUMB cmpeq r8, #0 blxne lr subs ip, ip, #1 @@ -159,12 +162,14 @@ function ff_h264_idct_add8_neon, export=1 add r1, r3, r12, lsl #5 cmp r8, #0 ldrsh r8, [r1] - adrne lr, ff_h264_idct_add_neon - adreq lr, ff_h264_idct_dc_add_neon + iteet ne + adrne lr, ff_h264_idct_add_neon + CONFIG_THUMB + adreq lr, ff_h264_idct_dc_add_neon + CONFIG_THUMB cmpeq r8, #0 blxne lr add r12, r12, #1 cmp r12, #4 + itt eq moveq r12, #16 moveq r4, r9 cmp r12, #20 @@ -365,10 +370,12 @@ function ff_h264_idct8_add4_neon, export=1 blt 2f ldrsh lr, [r1] add r0, r0, r4 + it ne movne lr, #0 cmp lr, #0 - adrne lr, ff_h264_idct8_dc_add_neon - adreq lr, ff_h264_idct8_add_neon + ite ne + adrne lr, ff_h264_idct8_dc_add_neon + CONFIG_THUMB + adreq lr, ff_h264_idct8_add_neon + CONFIG_THUMB blx lr 2: subs r12, r12, #4 add r1, r1, #128 diff --git a/libavcodec/arm/mathops.h b/libavcodec/arm/mathops.h index b27b18f871..3803fcde8c 100644 --- a/libavcodec/arm/mathops.h +++ b/libavcodec/arm/mathops.h @@ -64,11 +64,14 @@ static inline av_const int mid_pred(int a, int b, int c) __asm__ ( "mov %0, %2 \n\t" "cmp %1, %2 \n\t" + "itt gt \n\t" "movgt %0, %1 \n\t" "movgt %1, %2 \n\t" "cmp %1, %3 \n\t" + "it le \n\t" "movle %1, %3 \n\t" "cmp %0, %1 \n\t" + "it gt \n\t" "movgt %0, %1 \n\t" : "=&r"(m), "+r"(a) : "r"(b), "r"(c) diff --git a/libavcodec/arm/mdct_neon.S b/libavcodec/arm/mdct_neon.S index c375f4c121..1ba3067c4e 100644 --- a/libavcodec/arm/mdct_neon.S +++ b/libavcodec/arm/mdct_neon.S @@ -191,7 +191,9 @@ function ff_mdct_calc_neon, export=1 vadd.f32 d17, d17, d3 @ in2u+in1d -I 1: vmul.f32 d7, d0, d21 @ I*s - ldr r10, [r3, lr, lsr #1] +A ldr r10, [r3, lr, lsr #1] +T lsr r10, lr, #1 +T ldr r10, [r3, r10] vmul.f32 d6, d1, d20 @ -R*c ldr r6, [r3, #4]! vmul.f32 d4, d1, d21 @ -R*s diff --git a/libavcodec/arm/mpegaudiodsp_fixed_armv6.S b/libavcodec/arm/mpegaudiodsp_fixed_armv6.S index 9ec731480b..b517b973e7 100644 --- a/libavcodec/arm/mpegaudiodsp_fixed_armv6.S +++ b/libavcodec/arm/mpegaudiodsp_fixed_armv6.S @@ -75,7 +75,7 @@ function ff_mpadsp_apply_window_fixed_armv6, export=1 sum8 r8, r9, r1, r0, r10, r11, r12, lr sum8 r8, r9, r1, r2, r10, r11, r12, lr, rsb, 32 round r10, r8, r9 - strh r10, [r3], r4 + strh_post r10, r3, r4 mov lr, #15 1: @@ -127,10 +127,10 @@ function ff_mpadsp_apply_window_fixed_armv6, export=1 round r10, r8, r9 adds r8, r8, r4 adc r9, r9, r7 - strh r10, [r3], r12 + strh_post r10, r3, r12 round r11, r8, r9 subs lr, lr, #1 - strh r11, [r5], -r12 + strh_dpost r11, r5, r12 bgt 1b sum8 r8, r9, r1, r0, r10, r11, r12, lr, rsb, 33 diff --git a/libavcodec/arm/mpegvideo_armv5te_s.S b/libavcodec/arm/mpegvideo_armv5te_s.S index e3461601d5..952c8d74cb 100644 --- a/libavcodec/arm/mpegvideo_armv5te_s.S +++ b/libavcodec/arm/mpegvideo_armv5te_s.S @@ -38,15 +38,21 @@ .macro dequant_t dst, src, mul, add, tmp rsbs \tmp, ip, \src, asr #16 + it gt addgt \tmp, \add, #0 + it lt rsblt \tmp, \add, #0 + it ne smlatbne \dst, \src, \mul, \tmp .endm .macro dequant_b dst, src, mul, add, tmp rsbs \tmp, ip, \src, lsl #16 + it gt addgt \tmp, \add, #0 + it lt rsblt \tmp, \add, #0 + it ne smlabbne \dst, \src, \mul, \tmp .endm @@ -80,21 +86,27 @@ function ff_dct_unquantize_h263_armv5te, export=1 strh lr, [r0], #2 subs r3, r3, #8 + it gt ldrdgt r4, [r0, #0] /* load data early to avoid load/use pipeline stall */ bgt 1b adds r3, r3, #2 + it le pople {r4-r9,pc} 2: ldrsh r9, [r0, #0] ldrsh lr, [r0, #2] mov r8, r2 cmp r9, #0 + it lt rsblt r8, r2, #0 + it ne smlabbne r9, r9, r1, r8 mov r8, r2 cmp lr, #0 + it lt rsblt r8, r2, #0 + it ne smlabbne lr, lr, r1, r8 strh r9, [r0], #2 strh lr, [r0], #2 diff --git a/libavcodec/arm/mpegvideo_neon.S b/libavcodec/arm/mpegvideo_neon.S index 365dcf65cf..206a71a14d 100644 --- a/libavcodec/arm/mpegvideo_neon.S +++ b/libavcodec/arm/mpegvideo_neon.S @@ -57,6 +57,7 @@ function ff_dct_unquantize_h263_neon, export=1 subs r3, r3, #16 vst1.16 {q0}, [r1,:128]! vst1.16 {q8}, [r1,:128]! + it le bxle lr cmp r3, #8 bgt 1b @@ -78,6 +79,7 @@ function ff_dct_unquantize_h263_intra_neon, export=1 ldr r6, [r0, #AC_PRED] add lr, r0, #INTER_SCANTAB_RASTER_END cmp r6, #0 + it ne movne r12, #63 bne 1f ldr r12, [r12, r2, lsl #2] @@ -86,9 +88,11 @@ function ff_dct_unquantize_h263_intra_neon, export=1 ldrsh r4, [r1] cmp r5, #0 mov r5, r1 + it ne movne r2, #0 bne 2f cmp r2, #4 + it ge addge r0, r0, #4 sub r2, r3, #1 ldr r6, [r0, #Y_DC_SCALE] diff --git a/libavcodec/arm/rdft_neon.S b/libavcodec/arm/rdft_neon.S index 8aafdc9cf4..fba275eb8c 100644 --- a/libavcodec/arm/rdft_neon.S +++ b/libavcodec/arm/rdft_neon.S @@ -137,6 +137,7 @@ function ff_rdft_calc_neon, export=1 vst1.32 {d22}, [r5,:64] cmp r6, #0 + it eq popeq {r4-r8,pc} vmul.f32 d22, d22, d18 diff --git a/libavcodec/arm/simple_idct_arm.S b/libavcodec/arm/simple_idct_arm.S index 4e6dfa4391..717b12c64b 100644 --- a/libavcodec/arm/simple_idct_arm.S +++ b/libavcodec/arm/simple_idct_arm.S @@ -121,11 +121,13 @@ __b_evaluation: ldr r11, [r12, #offW7] @ R11=W7 mul r5, r10, r7 @ R5=W5*ROWr16[1]=b2 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle) mul r7, r11, r7 @ R7=W7*ROWr16[1]=b3 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle) - teq r2, #0 @ if null avoid muls - mlane r0, r9, r2, r0 @ R0+=W3*ROWr16[3]=b0 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle) + teq r2, #0 @ if null avoid muls + itttt ne + mlane r0, r9, r2, r0 @ R0+=W3*ROWr16[3]=b0 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle) rsbne r2, r2, #0 @ R2=-ROWr16[3] mlane r1, r11, r2, r1 @ R1-=W7*ROWr16[3]=b1 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle) mlane r5, r8, r2, r5 @ R5-=W1*ROWr16[3]=b2 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle) + it ne mlane r7, r10, r2, r7 @ R7-=W5*ROWr16[3]=b3 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle) @@ at this point, R0=b0, R1=b1, R2 (free), R3=ROWr32[2], R4=ROWr32[3], @@ -148,19 +150,23 @@ __b_evaluation: @@ MAC16(b3, -W1, row[7]); @@ MAC16(b1, -W5, row[7]); mov r3, r3, asr #16 @ R3=ROWr16[5] - teq r3, #0 @ if null avoid muls + teq r3, #0 @ if null avoid muls + it ne mlane r0, r10, r3, r0 @ R0+=W5*ROWr16[5]=b0 mov r4, r4, asr #16 @ R4=ROWr16[7] + itttt ne mlane r5, r11, r3, r5 @ R5+=W7*ROWr16[5]=b2 mlane r7, r9, r3, r7 @ R7+=W3*ROWr16[5]=b3 rsbne r3, r3, #0 @ R3=-ROWr16[5] mlane r1, r8, r3, r1 @ R7-=W1*ROWr16[5]=b1 @@ R3 is free now - teq r4, #0 @ if null avoid muls + teq r4, #0 @ if null avoid muls + itttt ne mlane r0, r11, r4, r0 @ R0+=W7*ROWr16[7]=b0 mlane r5, r9, r4, r5 @ R5+=W3*ROWr16[7]=b2 rsbne r4, r4, #0 @ R4=-ROWr16[7] mlane r7, r8, r4, r7 @ R7-=W1*ROWr16[7]=b3 + it ne mlane r1, r10, r4, r1 @ R1-=W5*ROWr16[7]=b1 @@ R4 is free now __end_b_evaluation: @@ -204,16 +210,19 @@ __a_evaluation: @@ a2 -= W4*row[4] @@ a3 += W4*row[4] ldrsh r11, [r14, #8] @ R11=ROWr16[4] - teq r11, #0 @ if null avoid muls + teq r11, #0 @ if null avoid muls + it ne mulne r11, r9, r11 @ R11=W4*ROWr16[4] @@ R9 is free now ldrsh r9, [r14, #12] @ R9=ROWr16[6] + itttt ne addne r6, r6, r11 @ R6+=W4*ROWr16[4] (a0) subne r2, r2, r11 @ R2-=W4*ROWr16[4] (a1) subne r3, r3, r11 @ R3-=W4*ROWr16[4] (a2) addne r4, r4, r11 @ R4+=W4*ROWr16[4] (a3) @@ W6 alone is no more useful, save W2*ROWr16[6] in it instead - teq r9, #0 @ if null avoid muls + teq r9, #0 @ if null avoid muls + itttt ne mulne r11, r10, r9 @ R11=W6*ROWr16[6] addne r6, r6, r11 @ R6+=W6*ROWr16[6] (a0) mulne r10, r8, r9 @ R10=W2*ROWr16[6] @@ -222,6 +231,7 @@ __a_evaluation: @@ a1 -= W2*row[6]; @@ a2 += W2*row[6]; subne r4, r4, r11 @ R4-=W6*ROWr16[6] (a3) + itt ne subne r2, r2, r10 @ R2-=W2*ROWr16[6] (a1) addne r3, r3, r10 @ R3+=W2*ROWr16[6] (a2) @@ -323,10 +333,12 @@ __b_evaluation2: ldrsh r2, [r14, #48] mul r7, r11, r7 @ R7=W7*ROWr16[1]=b3 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle) teq r2, #0 @ if 0, then avoid muls + itttt ne mlane r0, r9, r2, r0 @ R0+=W3*ROWr16[3]=b0 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle) rsbne r2, r2, #0 @ R2=-ROWr16[3] mlane r1, r11, r2, r1 @ R1-=W7*ROWr16[3]=b1 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle) mlane r5, r8, r2, r5 @ R5-=W1*ROWr16[3]=b2 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle) + it ne mlane r7, r10, r2, r7 @ R7-=W5*ROWr16[3]=b3 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle) @@ at this point, R0=b0, R1=b1, R2 (free), R3 (free), R4 (free), @@ -342,18 +354,22 @@ __b_evaluation2: @@ MAC16(b1, -W5, col[7x8]); ldrsh r3, [r14, #80] @ R3=COLr16[5x8] teq r3, #0 @ if 0 then avoid muls + itttt ne mlane r0, r10, r3, r0 @ R0+=W5*ROWr16[5x8]=b0 mlane r5, r11, r3, r5 @ R5+=W7*ROWr16[5x8]=b2 mlane r7, r9, r3, r7 @ R7+=W3*ROWr16[5x8]=b3 rsbne r3, r3, #0 @ R3=-ROWr16[5x8] ldrsh r4, [r14, #112] @ R4=COLr16[7x8] + it ne mlane r1, r8, r3, r1 @ R7-=W1*ROWr16[5x8]=b1 @@ R3 is free now teq r4, #0 @ if 0 then avoid muls + itttt ne mlane r0, r11, r4, r0 @ R0+=W7*ROWr16[7x8]=b0 mlane r5, r9, r4, r5 @ R5+=W3*ROWr16[7x8]=b2 rsbne r4, r4, #0 @ R4=-ROWr16[7x8] mlane r7, r8, r4, r7 @ R7-=W1*ROWr16[7x8]=b3 + it ne mlane r1, r10, r4, r1 @ R1-=W5*ROWr16[7x8]=b1 @@ R4 is free now __end_b_evaluation2: @@ -390,15 +406,18 @@ __a_evaluation2: @@ a3 += W4*row[4] ldrsh r11, [r14, #64] @ R11=ROWr16[4] teq r11, #0 @ if null avoid muls + itttt ne mulne r11, r9, r11 @ R11=W4*ROWr16[4] @@ R9 is free now addne r6, r6, r11 @ R6+=W4*ROWr16[4] (a0) subne r2, r2, r11 @ R2-=W4*ROWr16[4] (a1) subne r3, r3, r11 @ R3-=W4*ROWr16[4] (a2) ldrsh r9, [r14, #96] @ R9=ROWr16[6] + it ne addne r4, r4, r11 @ R4+=W4*ROWr16[4] (a3) @@ W6 alone is no more useful, save W2*ROWr16[6] in it instead teq r9, #0 @ if null avoid muls + itttt ne mulne r11, r10, r9 @ R11=W6*ROWr16[6] addne r6, r6, r11 @ R6+=W6*ROWr16[6] (a0) mulne r10, r8, r9 @ R10=W2*ROWr16[6] @@ -407,6 +426,7 @@ __a_evaluation2: @@ a1 -= W2*row[6]; @@ a2 += W2*row[6]; subne r4, r4, r11 @ R4-=W6*ROWr16[6] (a3) + itt ne subne r2, r2, r10 @ R2-=W2*ROWr16[6] (a1) addne r3, r3, r10 @ R3+=W2*ROWr16[6] (a2) __end_a_evaluation2: diff --git a/libavcodec/arm/simple_idct_armv5te.S b/libavcodec/arm/simple_idct_armv5te.S index 29ebf5c03c..24641e47b6 100644 --- a/libavcodec/arm/simple_idct_armv5te.S +++ b/libavcodec/arm/simple_idct_armv5te.S @@ -49,6 +49,7 @@ function idct_row_armv5te ldrd v1, [a1, #8] ldrd a3, [a1] /* a3 = row[1:0], a4 = row[3:2] */ orrs v1, v1, v2 + itt eq cmpeq v1, a4 cmpeq v1, a3, lsr #16 beq row_dc_only @@ -269,6 +270,7 @@ function idct_col_armv5te ldmfd sp!, {a3, a4} adds a2, a3, v1 mov a2, a2, lsr #20 + it mi orrmi a2, a2, #0xf000 add ip, a4, v2 mov ip, ip, asr #20 @@ -276,6 +278,7 @@ function idct_col_armv5te str a2, [a1] subs a3, a3, v1 mov a2, a3, lsr #20 + it mi orrmi a2, a2, #0xf000 sub a4, a4, v2 mov a4, a4, asr #20 @@ -285,6 +288,7 @@ function idct_col_armv5te subs a2, a3, v3 mov a2, a2, lsr #20 + it mi orrmi a2, a2, #0xf000 sub ip, a4, v4 mov ip, ip, asr #20 @@ -292,6 +296,7 @@ function idct_col_armv5te str a2, [a1, #(16*1)] adds a3, a3, v3 mov a2, a3, lsr #20 + it mi orrmi a2, a2, #0xf000 add a4, a4, v4 mov a4, a4, asr #20 @@ -301,6 +306,7 @@ function idct_col_armv5te adds a2, a3, v5 mov a2, a2, lsr #20 + it mi orrmi a2, a2, #0xf000 add ip, a4, v6 mov ip, ip, asr #20 @@ -308,6 +314,7 @@ function idct_col_armv5te str a2, [a1, #(16*2)] subs a3, a3, v5 mov a2, a3, lsr #20 + it mi orrmi a2, a2, #0xf000 sub a4, a4, v6 mov a4, a4, asr #20 @@ -317,6 +324,7 @@ function idct_col_armv5te adds a2, a3, v7 mov a2, a2, lsr #20 + it mi orrmi a2, a2, #0xf000 add ip, a4, fp mov ip, ip, asr #20 @@ -324,6 +332,7 @@ function idct_col_armv5te str a2, [a1, #(16*3)] subs a3, a3, v7 mov a2, a3, lsr #20 + it mi orrmi a2, a2, #0xf000 sub a4, a4, fp mov a4, a4, asr #20 @@ -335,15 +344,19 @@ endfunc .macro clip dst, src:vararg movs \dst, \src + it mi movmi \dst, #0 cmp \dst, #255 + it gt movgt \dst, #255 .endm .macro aclip dst, src:vararg adds \dst, \src + it mi movmi \dst, #0 cmp \dst, #255 + it gt movgt \dst, #255 .endm @@ -370,35 +383,35 @@ function idct_col_put_armv5te orr a2, a3, a4, lsl #8 rsb v2, lr, lr, lsl #3 ldmfd sp!, {a3, a4} - strh a2, [v2, v1]! + strh_pre a2, v2, v1 sub a2, a3, v3 clip a2, a2, asr #20 sub ip, a4, v4 clip ip, ip, asr #20 orr a2, a2, ip, lsl #8 - strh a2, [v1, lr]! + strh_pre a2, v1, lr add a3, a3, v3 clip a2, a3, asr #20 add a4, a4, v4 clip a4, a4, asr #20 orr a2, a2, a4, lsl #8 ldmfd sp!, {a3, a4} - strh a2, [v2, -lr]! + strh_dpre a2, v2, lr add a2, a3, v5 clip a2, a2, asr #20 add ip, a4, v6 clip ip, ip, asr #20 orr a2, a2, ip, lsl #8 - strh a2, [v1, lr]! + strh_pre a2, v1, lr sub a3, a3, v5 clip a2, a3, asr #20 sub a4, a4, v6 clip a4, a4, asr #20 orr a2, a2, a4, lsl #8 ldmfd sp!, {a3, a4} - strh a2, [v2, -lr]! + strh_dpre a2, v2, lr add a2, a3, v7 clip a2, a2, asr #20 @@ -411,7 +424,7 @@ function idct_col_put_armv5te sub a4, a4, fp clip a4, a4, asr #20 orr a2, a2, a4, lsl #8 - strh a2, [v2, -lr] + strh_dpre a2, v2, lr ldr pc, [sp], #4 endfunc @@ -436,7 +449,7 @@ function idct_col_add_armv5te ldr v1, [sp, #32] sub a4, a4, v2 rsb v2, v1, v1, lsl #3 - ldrh ip, [v2, lr]! + ldrh_pre ip, v2, lr strh a2, [lr] and a2, ip, #255 aclip a3, a2, a3, asr #20 @@ -448,7 +461,7 @@ function idct_col_add_armv5te strh a2, [v2] ldmfd sp!, {a3, a4} - ldrh ip, [lr, v1]! + ldrh_pre ip, lr, v1 sub a2, a3, v3 add a3, a3, v3 and v3, ip, #255 @@ -458,7 +471,7 @@ function idct_col_add_armv5te aclip v3, v3, ip, lsr #8 orr a2, a2, v3, lsl #8 add a4, a4, v4 - ldrh ip, [v2, -v1]! + ldrh_dpre ip, v2, v1 strh a2, [lr] and a2, ip, #255 aclip a3, a2, a3, asr #20 @@ -468,7 +481,7 @@ function idct_col_add_armv5te strh a2, [v2] ldmfd sp!, {a3, a4} - ldrh ip, [lr, v1]! + ldrh_pre ip, lr, v1 add a2, a3, v5 sub a3, a3, v5 and v3, ip, #255 @@ -478,7 +491,7 @@ function idct_col_add_armv5te aclip v3, v3, ip, lsr #8 orr a2, a2, v3, lsl #8 sub a4, a4, v6 - ldrh ip, [v2, -v1]! + ldrh_dpre ip, v2, v1 strh a2, [lr] and a2, ip, #255 aclip a3, a2, a3, asr #20 @@ -488,7 +501,7 @@ function idct_col_add_armv5te strh a2, [v2] ldmfd sp!, {a3, a4} - ldrh ip, [lr, v1]! + ldrh_pre ip, lr, v1 add a2, a3, v7 sub a3, a3, v7 and v3, ip, #255 @@ -498,7 +511,7 @@ function idct_col_add_armv5te aclip v3, v3, ip, lsr #8 orr a2, a2, v3, lsl #8 sub a4, a4, fp - ldrh ip, [v2, -v1]! + ldrh_dpre ip, v2, v1 strh a2, [lr] and a2, ip, #255 aclip a3, a2, a3, asr #20 diff --git a/libavcodec/arm/simple_idct_armv6.S b/libavcodec/arm/simple_idct_armv6.S index b2eb525de5..284eb1f941 100644 --- a/libavcodec/arm/simple_idct_armv6.S +++ b/libavcodec/arm/simple_idct_armv6.S @@ -200,6 +200,7 @@ function idct_row_armv6 ldr r3, [r0, #8] /* r3 = row[3,1] */ ldr r2, [r0] /* r2 = row[2,0] */ orrs lr, lr, ip + itt eq cmpeq lr, r3 cmpeq lr, r2, lsr #16 beq 1f @@ -282,14 +283,14 @@ function idct_col_put_armv6 pop {r1, r2} idct_finish_shift_sat COL_SHIFT - strb r4, [r1], r2 - strb r5, [r1], r2 - strb r6, [r1], r2 - strb r7, [r1], r2 - strb r11,[r1], r2 - strb r10,[r1], r2 - strb r9, [r1], r2 - strb r8, [r1], r2 + strb_post r4, r1, r2 + strb_post r5, r1, r2 + strb_post r6, r1, r2 + strb_post r7, r1, r2 + strb_post r11,r1, r2 + strb_post r10,r1, r2 + strb_post r9, r1, r2 + strb_post r8, r1, r2 sub r1, r1, r2, lsl #3 @@ -318,16 +319,16 @@ function idct_col_add_armv6 add ip, r3, ip, asr #COL_SHIFT usat ip, #8, ip add r4, r7, r4, asr #COL_SHIFT - strb ip, [r1], r2 + strb_post ip, r1, r2 ldrb ip, [r1, r2] usat r4, #8, r4 ldrb r11,[r1, r2, lsl #2] add r5, ip, r5, asr #COL_SHIFT usat r5, #8, r5 - strb r4, [r1], r2 + strb_post r4, r1, r2 ldrb r3, [r1, r2] ldrb ip, [r1, r2, lsl #2] - strb r5, [r1], r2 + strb_post r5, r1, r2 ldrb r7, [r1, r2] ldrb r4, [r1, r2, lsl #2] add r6, r3, r6, asr #COL_SHIFT @@ -340,11 +341,11 @@ function idct_col_add_armv6 usat r8, #8, r8 add lr, r4, lr, asr #COL_SHIFT usat lr, #8, lr - strb r6, [r1], r2 - strb r10,[r1], r2 - strb r9, [r1], r2 - strb r8, [r1], r2 - strb lr, [r1], r2 + strb_post r6, r1, r2 + strb_post r10,r1, r2 + strb_post r9, r1, r2 + strb_post r8, r1, r2 + strb_post lr, r1, r2 sub r1, r1, r2, lsl #3 diff --git a/libavcodec/arm/simple_idct_neon.S b/libavcodec/arm/simple_idct_neon.S index 0628b9676a..cbed9eefe4 100644 --- a/libavcodec/arm/simple_idct_neon.S +++ b/libavcodec/arm/simple_idct_neon.S @@ -71,7 +71,7 @@ function idct_row4_pld_neon add r3, r0, r1, lsl #2 pld [r0, r1] pld [r0, r1, lsl #1] - pld [r3, -r1] +A pld [r3, -r1] pld [r3] pld [r3, r1] add r3, r3, r1, lsl #1 @@ -164,6 +164,7 @@ function idct_col4_neon orrs r4, r4, r5 idct_col4_top + it eq addeq r2, r2, #16 beq 1f @@ -176,6 +177,7 @@ function idct_col4_neon 1: orrs r6, r6, r7 ldrd r4, [r2, #16] + it eq addeq r2, r2, #16 beq 2f @@ -187,6 +189,7 @@ function idct_col4_neon 2: orrs r4, r4, r5 ldrd r4, [r2, #16] + it eq addeq r2, r2, #16 beq 3f @@ -199,6 +202,7 @@ function idct_col4_neon vadd.i32 q13, q13, q8 3: orrs r4, r4, r5 + it eq addeq r2, r2, #16 beq 4f diff --git a/libavcodec/arm/synth_filter_neon.S b/libavcodec/arm/synth_filter_neon.S index d4f67b785c..1d6e5b2b86 100644 --- a/libavcodec/arm/synth_filter_neon.S +++ b/libavcodec/arm/synth_filter_neon.S @@ -100,9 +100,11 @@ NOVFP vldr s0, [sp, #12*4] @ scale vst1.32 {q9}, [r2,:128] subs r1, r1, #1 + it eq popeq {r4-r11,pc} cmp r4, #0 + itt eq subeq r8, r8, #512*4 subeq r9, r9, #512*4 sub r5, r5, #512*4 diff --git a/libavcodec/arm/vp56_arith.h b/libavcodec/arm/vp56_arith.h index 9ce3fd0d91..ef30ffe897 100644 --- a/libavcodec/arm/vp56_arith.h +++ b/libavcodec/arm/vp56_arith.h @@ -21,6 +21,14 @@ #ifndef AVCODEC_ARM_VP56_ARITH_H #define AVCODEC_ARM_VP56_ARITH_H +#if CONFIG_THUMB +# define A(x) +# define T(x) x +#else +# define A(x) x +# define T(x) +#endif + #if HAVE_ARMV6 && HAVE_INLINE_ASM #define vp56_rac_get_prob vp56_rac_get_prob_armv6 @@ -32,15 +40,21 @@ static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr) unsigned bit; __asm__ ("adds %3, %3, %0 \n" + "itt cs \n" "cmpcs %7, %4 \n" - "ldrcsh %2, [%4], #2 \n" + A("ldrcsh %2, [%4], #2 \n") + T("ldrhcs %2, [%4], #2 \n") "rsb %0, %6, #256 \n" "smlabb %0, %5, %6, %0 \n" + T("itttt cs \n") "rev16cs %2, %2 \n" - "orrcs %1, %1, %2, lsl %3 \n" + T("lslcs %2, %2, %3 \n") + T("orrcs %1, %1, %2 \n") + A("orrcs %1, %1, %2, lsl %3 \n") "subcs %3, %3, #16 \n" "lsr %0, %0, #8 \n" "cmp %1, %0, lsl #16 \n" + "ittte ge \n" "subge %1, %1, %0, lsl #16 \n" "subge %0, %5, %0 \n" "movge %2, #1 \n" @@ -64,12 +78,17 @@ static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr) unsigned tmp; __asm__ ("adds %3, %3, %0 \n" + "itt cs \n" "cmpcs %7, %4 \n" - "ldrcsh %2, [%4], #2 \n" + A("ldrcsh %2, [%4], #2 \n") + T("ldrhcs %2, [%4], #2 \n") "rsb %0, %6, #256 \n" "smlabb %0, %5, %6, %0 \n" + T("itttt cs \n") "rev16cs %2, %2 \n" - "orrcs %1, %1, %2, lsl %3 \n" + T("lslcs %2, %2, %3 \n") + T("orrcs %1, %1, %2 \n") + A("orrcs %1, %1, %2, lsl %3 \n") "subcs %3, %3, #16 \n" "lsr %0, %0, #8 \n" "lsl %2, %0, #16 \n" diff --git a/libavcodec/arm/vp8_armv6.S b/libavcodec/arm/vp8_armv6.S index 602c8a58be..1d89c68909 100644 --- a/libavcodec/arm/vp8_armv6.S +++ b/libavcodec/arm/vp8_armv6.S @@ -25,13 +25,18 @@ lsl \cw, \cw, \t0 lsl \t0, \h, \t0 rsb \h, \pr, #256 + it cs ldrhcs \t1, [\buf], #2 smlabb \h, \t0, \pr, \h +T itttt cs rev16cs \t1, \t1 - orrcs \cw, \cw, \t1, lsl \bs +A orrcs \cw, \cw, \t1, lsl \bs +T lslcs \t1, \t1, \bs +T orrcs \cw, \cw, \t1 subcs \bs, \bs, #16 lsr \h, \h, #8 cmp \cw, \h, lsl #16 + itt ge subge \cw, \cw, \h, lsl #16 subge \h, \t0, \h .endm @@ -40,14 +45,20 @@ adds \bs, \bs, \t0 lsl \cw, \cw, \t0 lsl \t0, \h, \t0 + it cs ldrhcs \t1, [\buf], #2 mov \h, #128 + it cs rev16cs \t1, \t1 add \h, \h, \t0, lsl #7 - orrcs \cw, \cw, \t1, lsl \bs +A orrcs \cw, \cw, \t1, lsl \bs +T ittt cs +T lslcs \t1, \t1, \bs +T orrcs \cw, \cw, \t1 subcs \bs, \bs, #16 lsr \h, \h, #8 cmp \cw, \h, lsl #16 + itt ge subge \cw, \cw, \h, lsl #16 subge \h, \t0, \h .endm @@ -59,6 +70,7 @@ function ff_decode_block_coeffs_armv6, export=1 cmp r3, #0 ldr r11, [r5] ldm r0, {r5-r7} @ high, bits, buf + it ne pkhtbne r11, r11, r11, asr #16 ldr r8, [r0, #16] @ code_word 0: @@ -80,19 +92,26 @@ function ff_decode_block_coeffs_armv6, export=1 adds r6, r6, r9 add r4, r4, #11 lsl r8, r8, r9 + it cs ldrhcs r10, [r7], #2 lsl r9, r5, r9 mov r5, #128 + it cs rev16cs r10, r10 add r5, r5, r9, lsl #7 - orrcs r8, r8, r10, lsl r6 +T ittt cs +T lslcs r10, r10, r6 +T orrcs r8, r8, r10 +A orrcs r8, r8, r10, lsl r6 subcs r6, r6, #16 lsr r5, r5, #8 cmp r8, r5, lsl #16 movrel r10, zigzag_scan-1 + itt ge subge r8, r8, r5, lsl #16 subge r5, r9, r5 ldrb r10, [r10, r3] + it ge rsbge r12, r12, #0 cmp r3, #16 strh r12, [r1, r10] @@ -108,6 +127,7 @@ function ff_decode_block_coeffs_armv6, export=1 ldr r0, [sp] ldr r9, [r0, #12] cmp r7, r9 + it hi movhi r7, r9 stm r0, {r5-r7} @ high, bits, buf str r8, [r0, #16] @ code_word @@ -131,11 +151,13 @@ function ff_decode_block_coeffs_armv6, export=1 mov r12, #2 ldrb r0, [r4, #4] rac_get_prob r5, r6, r7, r8, r0, r9, r10 + it ge addge r12, #1 ldrb r9, [lr, r5] blt 4f ldrb r0, [r4, #5] rac_get_prob r5, r6, r7, r8, r0, r9, r10 + it ge addge r12, #1 ldrb r9, [lr, r5] b 4f @@ -153,6 +175,7 @@ function ff_decode_block_coeffs_armv6, export=1 mov r12, #5 mov r0, #159 rac_get_prob r5, r6, r7, r8, r0, r9, r10 + it ge addge r12, r12, #1 ldrb r9, [lr, r5] b 4f @@ -160,23 +183,28 @@ function ff_decode_block_coeffs_armv6, export=1 mov r12, #7 mov r0, #165 rac_get_prob r5, r6, r7, r8, r0, r9, r10 + it ge addge r12, r12, #2 ldrb r9, [lr, r5] mov r0, #145 rac_get_prob r5, r6, r7, r8, r0, r9, r10 + it ge addge r12, r12, #1 ldrb r9, [lr, r5] b 4f 3: ldrb r0, [r4, #8] rac_get_prob r5, r6, r7, r8, r0, r9, r10 + it ge addge r4, r4, #1 ldrb r9, [lr, r5] + ite ge movge r12, #2 movlt r12, #0 ldrb r0, [r4, #9] rac_get_prob r5, r6, r7, r8, r0, r9, r10 mov r9, #8 + it ge addge r12, r12, #1 movrel r4, X(ff_vp8_dct_cat_prob) lsl r9, r9, r12 @@ -189,6 +217,7 @@ function ff_decode_block_coeffs_armv6, export=1 lsl r1, r1, #1 rac_get_prob r5, r6, r7, r8, r0, r9, r10 ldrb r0, [r4], #1 + it ge addge r1, r1, #1 cmp r0, #0 bne 1b @@ -200,6 +229,7 @@ function ff_decode_block_coeffs_armv6, export=1 add r4, r2, r4 add r4, r4, #22 rac_get_128 r5, r6, r7, r8, r9, r10 + it ge rsbge r12, r12, #0 smulbb r12, r12, r11 movrel r9, zigzag_scan-1 diff --git a/libavcodec/arm/vp8dsp_neon.S b/libavcodec/arm/vp8dsp_neon.S index 92b1ef4eb7..1b9f24eef2 100644 --- a/libavcodec/arm/vp8dsp_neon.S +++ b/libavcodec/arm/vp8dsp_neon.S @@ -746,14 +746,14 @@ function ff_put_vp8_pixels4_neon, export=1 push {r4-r6,lr} 1: subs r12, r12, #4 - ldr r4, [r2], r3 - ldr r5, [r2], r3 - ldr r6, [r2], r3 - ldr lr, [r2], r3 - str r4, [r0], r1 - str r5, [r0], r1 - str r6, [r0], r1 - str lr, [r0], r1 + ldr_post r4, r2, r3 + ldr_post r5, r2, r3 + ldr_post r6, r2, r3 + ldr_post lr, r2, r3 + str_post r4, r0, r1 + str_post r5, r0, r1 + str_post r6, r0, r1 + str_post lr, r0, r1 bgt 1b pop {r4-r6,pc} endfunc diff --git a/libavutil/arm/intmath.h b/libavutil/arm/intmath.h index 4340b59075..b6a45c1395 100644 --- a/libavutil/arm/intmath.h +++ b/libavutil/arm/intmath.h @@ -36,6 +36,7 @@ static av_always_inline av_const int FASTDIV(int a, int b) int r; __asm__ ("cmp %2, #2 \n\t" "ldr %0, [%3, %2, lsl #2] \n\t" + "ite le \n\t" "lsrle %0, %1, #1 \n\t" "smmulgt %0, %0, %1 \n\t" : "=&r"(r) : "r"(a), "r"(b), "r"(ff_inverse) : "cc"); @@ -101,6 +102,7 @@ static av_always_inline av_const int32_t av_clipl_int32_arm(int64_t a) { int x, y; __asm__ ("adds %1, %R2, %Q2, lsr #31 \n\t" + "itet ne \n\t" "mvnne %1, #1<<31 \n\t" "moveq %0, %Q2 \n\t" "eorne %0, %1, %R2, asr #31 \n\t" From 921715edffbba5db8deb26b7ad3cb583ba963d03 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 13 Jun 2011 21:16:30 +0200 Subject: [PATCH 036/780] alsa: add support for more formats. Specifically, f32, f64, s32, s24, a-law and mu-law. Signed-off-by: Anton Khirnov --- libavdevice/alsa-audio-common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index ff6c9f875d..4279790ddc 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -36,9 +36,19 @@ static av_cold snd_pcm_format_t codec_id_to_pcm_format(int codec_id) { switch(codec_id) { + case CODEC_ID_PCM_F64LE: return SND_PCM_FORMAT_FLOAT64_LE; + case CODEC_ID_PCM_F64BE: return SND_PCM_FORMAT_FLOAT64_BE; + case CODEC_ID_PCM_F32LE: return SND_PCM_FORMAT_FLOAT_LE; + case CODEC_ID_PCM_F32BE: return SND_PCM_FORMAT_FLOAT_BE; + case CODEC_ID_PCM_S32LE: return SND_PCM_FORMAT_S32_LE; + case CODEC_ID_PCM_S32BE: return SND_PCM_FORMAT_S32_BE; + case CODEC_ID_PCM_S24LE: return SND_PCM_FORMAT_S24_3LE; + case CODEC_ID_PCM_S24BE: return SND_PCM_FORMAT_S24_3BE; case CODEC_ID_PCM_S16LE: return SND_PCM_FORMAT_S16_LE; case CODEC_ID_PCM_S16BE: return SND_PCM_FORMAT_S16_BE; case CODEC_ID_PCM_S8: return SND_PCM_FORMAT_S8; + case CODEC_ID_PCM_MULAW: return SND_PCM_FORMAT_MU_LAW; + case CODEC_ID_PCM_ALAW: return SND_PCM_FORMAT_A_LAW; default: return SND_PCM_FORMAT_UNKNOWN; } } From 2359aeb52d2325ed6c28d4f7579e0999963bcec1 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Thu, 14 Apr 2011 01:04:18 +0200 Subject: [PATCH 037/780] alsa: support unsigned variants of already supported signed formats. --- libavdevice/alsa-audio-common.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index 4279790ddc..baa6ac79ca 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -42,11 +42,18 @@ static av_cold snd_pcm_format_t codec_id_to_pcm_format(int codec_id) case CODEC_ID_PCM_F32BE: return SND_PCM_FORMAT_FLOAT_BE; case CODEC_ID_PCM_S32LE: return SND_PCM_FORMAT_S32_LE; case CODEC_ID_PCM_S32BE: return SND_PCM_FORMAT_S32_BE; + case CODEC_ID_PCM_U32LE: return SND_PCM_FORMAT_U32_LE; + case CODEC_ID_PCM_U32BE: return SND_PCM_FORMAT_U32_BE; case CODEC_ID_PCM_S24LE: return SND_PCM_FORMAT_S24_3LE; case CODEC_ID_PCM_S24BE: return SND_PCM_FORMAT_S24_3BE; + case CODEC_ID_PCM_U24LE: return SND_PCM_FORMAT_U24_3LE; + case CODEC_ID_PCM_U24BE: return SND_PCM_FORMAT_U24_3BE; case CODEC_ID_PCM_S16LE: return SND_PCM_FORMAT_S16_LE; case CODEC_ID_PCM_S16BE: return SND_PCM_FORMAT_S16_BE; + case CODEC_ID_PCM_U16LE: return SND_PCM_FORMAT_U16_LE; + case CODEC_ID_PCM_U16BE: return SND_PCM_FORMAT_U16_BE; case CODEC_ID_PCM_S8: return SND_PCM_FORMAT_S8; + case CODEC_ID_PCM_U8: return SND_PCM_FORMAT_U8; case CODEC_ID_PCM_MULAW: return SND_PCM_FORMAT_MU_LAW; case CODEC_ID_PCM_ALAW: return SND_PCM_FORMAT_A_LAW; default: return SND_PCM_FORMAT_UNKNOWN; From 147bcf27c4f8b22a386ea626f9455cf3f7cf0410 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 10 Mar 2011 12:10:34 +0100 Subject: [PATCH 038/780] ALSA: implement channel layout for playback. Currently quad, 5.0, 5.1 and 7.1 are implemented. Implementing support for other formats/layouts and capture should be straightforward. 5.0 and 7.1 support by Carl Eugen Hoyos. Signed-off-by: Anton Khirnov --- libavdevice/alsa-audio-common.c | 155 ++++++++++++++++++++++++++++++++ libavdevice/alsa-audio-enc.c | 10 ++- libavdevice/alsa-audio.h | 5 ++ 3 files changed, 169 insertions(+), 1 deletion(-) diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index baa6ac79ca..4cfc6e9864 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -30,6 +30,7 @@ #include #include "libavformat/avformat.h" +#include "libavutil/avassert.h" #include "alsa-audio.h" @@ -60,6 +61,127 @@ static av_cold snd_pcm_format_t codec_id_to_pcm_format(int codec_id) } } +#define REORDER_OUT_50(NAME, TYPE) \ +static void alsa_reorder_ ## NAME ## _out_50(const void *in_v, void *out_v, int n) \ +{ \ + const TYPE *in = in_v; \ + TYPE *out = out_v; \ +\ + while (n-- > 0) { \ + out[0] = in[0]; \ + out[1] = in[1]; \ + out[2] = in[3]; \ + out[3] = in[4]; \ + out[4] = in[2]; \ + in += 5; \ + out += 5; \ + } \ +} + +#define REORDER_OUT_51(NAME, TYPE) \ +static void alsa_reorder_ ## NAME ## _out_51(const void *in_v, void *out_v, int n) \ +{ \ + const TYPE *in = in_v; \ + TYPE *out = out_v; \ +\ + while (n-- > 0) { \ + out[0] = in[0]; \ + out[1] = in[1]; \ + out[2] = in[4]; \ + out[3] = in[5]; \ + out[4] = in[2]; \ + out[5] = in[3]; \ + in += 6; \ + out += 6; \ + } \ +} + +#define REORDER_OUT_71(NAME, TYPE) \ +static void alsa_reorder_ ## NAME ## _out_71(const void *in_v, void *out_v, int n) \ +{ \ + const TYPE *in = in_v; \ + TYPE *out = out_v; \ +\ + while (n-- > 0) { \ + out[0] = in[0]; \ + out[1] = in[1]; \ + out[2] = in[4]; \ + out[3] = in[5]; \ + out[4] = in[2]; \ + out[5] = in[3]; \ + out[6] = in[6]; \ + out[7] = in[7]; \ + in += 8; \ + out += 8; \ + } \ +} + +REORDER_OUT_50(int8, int8_t) +REORDER_OUT_51(int8, int8_t) +REORDER_OUT_71(int8, int8_t) +REORDER_OUT_50(int16, int16_t) +REORDER_OUT_51(int16, int16_t) +REORDER_OUT_71(int16, int16_t) +REORDER_OUT_50(int32, int32_t) +REORDER_OUT_51(int32, int32_t) +REORDER_OUT_71(int32, int32_t) +REORDER_OUT_50(f32, float) +REORDER_OUT_51(f32, float) +REORDER_OUT_71(f32, float) + +#define FORMAT_I8 0 +#define FORMAT_I16 1 +#define FORMAT_I32 2 +#define FORMAT_F32 3 + +#define PICK_REORDER(layout)\ +switch(format) {\ + case FORMAT_I8: s->reorder_func = alsa_reorder_int8_out_ ##layout; break;\ + case FORMAT_I16: s->reorder_func = alsa_reorder_int16_out_ ##layout; break;\ + case FORMAT_I32: s->reorder_func = alsa_reorder_int32_out_ ##layout; break;\ + case FORMAT_F32: s->reorder_func = alsa_reorder_f32_out_ ##layout; break;\ +} + +static av_cold int find_reorder_func(AlsaData *s, int codec_id, int64_t layout, int out) +{ + int format; + + /* reordering input is not currently supported */ + if (!out) + return AVERROR(ENOSYS); + + /* reordering is not needed for QUAD or 2_2 layout */ + if (layout == AV_CH_LAYOUT_QUAD || layout == AV_CH_LAYOUT_2_2) + return 0; + + switch (codec_id) { + case CODEC_ID_PCM_S8: + case CODEC_ID_PCM_U8: + case CODEC_ID_PCM_ALAW: + case CODEC_ID_PCM_MULAW: format = FORMAT_I8; break; + case CODEC_ID_PCM_S16LE: + case CODEC_ID_PCM_S16BE: + case CODEC_ID_PCM_U16LE: + case CODEC_ID_PCM_U16BE: format = FORMAT_I16; break; + case CODEC_ID_PCM_S32LE: + case CODEC_ID_PCM_S32BE: + case CODEC_ID_PCM_U32LE: + case CODEC_ID_PCM_U32BE: format = FORMAT_I32; break; + case CODEC_ID_PCM_F32LE: + case CODEC_ID_PCM_F32BE: format = FORMAT_F32; break; + default: return AVERROR(ENOSYS); + } + + if (layout == AV_CH_LAYOUT_5POINT0_BACK || layout == AV_CH_LAYOUT_5POINT0) + PICK_REORDER(50) + else if (layout == AV_CH_LAYOUT_5POINT1_BACK || layout == AV_CH_LAYOUT_5POINT1) + PICK_REORDER(51) + else if (layout == AV_CH_LAYOUT_7POINT1) + PICK_REORDER(71) + + return s->reorder_func ? 0 : AVERROR(ENOSYS); +} + av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, unsigned int *sample_rate, int channels, enum CodecID *codec_id) @@ -71,6 +193,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, snd_pcm_t *h; snd_pcm_hw_params_t *hw_params; snd_pcm_uframes_t buffer_size, period_size; + int64_t layout = ctx->streams[0]->codec->channel_layout; if (ctx->filename[0] == 0) audio_device = "default"; else audio_device = ctx->filename; @@ -163,6 +286,21 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, snd_pcm_hw_params_free(hw_params); + if (channels > 2 && layout) { + if (find_reorder_func(s, *codec_id, layout, mode == SND_PCM_STREAM_PLAYBACK) < 0) { + char name[128]; + av_get_channel_layout_string(name, sizeof(name), channels, layout); + av_log(ctx, AV_LOG_WARNING, "ALSA channel layout unknown or unimplemented for %s %s.\n", + name, mode == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture"); + } + if (s->reorder_func) { + s->reorder_buf_size = buffer_size; + s->reorder_buf = av_malloc(s->reorder_buf_size * s->frame_size); + if (!s->reorder_buf) + goto fail1; + } + } + s->h = h; return 0; @@ -177,6 +315,7 @@ av_cold int ff_alsa_close(AVFormatContext *s1) { AlsaData *s = s1->priv_data; + av_freep(&s->reorder_buf); snd_pcm_close(s->h); return 0; } @@ -201,3 +340,19 @@ int ff_alsa_xrun_recover(AVFormatContext *s1, int err) } return err; } + +int ff_alsa_extend_reorder_buf(AlsaData *s, int min_size) +{ + int size = s->reorder_buf_size; + void *r; + + av_assert0(size != 0); + while (size < min_size) + size *= 2; + r = av_realloc(s->reorder_buf, size * s->frame_size); + if (!r) + return AVERROR(ENOMEM); + s->reorder_buf = r; + s->reorder_buf_size = size; + return 0; +} diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c index ebe598c86f..f3782c5ab6 100644 --- a/libavdevice/alsa-audio-enc.c +++ b/libavdevice/alsa-audio-enc.c @@ -76,7 +76,15 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) int size = pkt->size; uint8_t *buf = pkt->data; - while((res = snd_pcm_writei(s->h, buf, size / s->frame_size)) < 0) { + size /= s->frame_size; + if (s->reorder_func) { + if (size > s->reorder_buf_size) + if (ff_alsa_extend_reorder_buf(s, size)) + return AVERROR(ENOMEM); + s->reorder_func(buf, s->reorder_buf, size); + buf = s->reorder_buf; + } + while ((res = snd_pcm_writei(s->h, buf, size)) < 0) { if (res == -EAGAIN) { return AVERROR(EAGAIN); diff --git a/libavdevice/alsa-audio.h b/libavdevice/alsa-audio.h index 32c07426ef..1e0be1cac7 100644 --- a/libavdevice/alsa-audio.h +++ b/libavdevice/alsa-audio.h @@ -47,6 +47,9 @@ typedef struct { int period_size; ///< bytes per sample * channels int sample_rate; ///< sample rate set by user int channels; ///< number of channels set by user + void (*reorder_func)(const void *, void *, int); + void *reorder_buf; + int reorder_buf_size; ///< in frames } AlsaData; /** @@ -86,4 +89,6 @@ int ff_alsa_close(AVFormatContext *s1); */ int ff_alsa_xrun_recover(AVFormatContext *s1, int err); +int ff_alsa_extend_reorder_buf(AlsaData *s, int size); + #endif /* AVDEVICE_ALSA_AUDIO_H */ From da51a7c69cd105498d28a23f1137eef2915a8e6b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 3 Jun 2011 10:54:10 +0200 Subject: [PATCH 039/780] bktr: prefer "framerate" over "fps" for grab_read_header() The variable is used for containing the parsed value of s1->framerate, using a lexically consistent name ease readability/understanding. Signed-off-by: Anton Khirnov --- libavdevice/bktr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index 4d3933f4e9..aa3055d946 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -248,7 +248,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) VideoData *s = s1->priv_data; AVStream *st; int width, height; - AVRational fps; + AVRational framerate; int ret = 0; #if FF_API_FORMAT_PARAMETERS @@ -277,7 +277,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) ret = AVERROR(EINVAL); goto out; } - if ((ret = av_parse_video_rate(&fps, s->framerate)) < 0) { + if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) { av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n"); goto out; } @@ -287,7 +287,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) if (ap->height > 0) height = ap->height; if (ap->time_base.num) - fps = (AVRational){ap->time_base.den, ap->time_base.num}; + framerate = (AVRational){ap->time_base.den, ap->time_base.num}; #endif st = av_new_stream(s1, 0); @@ -299,15 +299,15 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) s->width = width; s->height = height; - s->per_frame = ((uint64_t)1000000 * fps.den) / fps.num; + s->per_frame = ((uint64_t)1000000 * framerate.den) / framerate.num; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->pix_fmt = PIX_FMT_YUV420P; st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->width = width; st->codec->height = height; - st->codec->time_base.den = fps.num; - st->codec->time_base.num = fps.den; + st->codec->time_base.den = framerate.num; + st->codec->time_base.num = framerate.den; if (bktr_init(s1->filename, width, height, s->standard, From a5351720cc2439219bb348efc81ff3df828df2a3 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 3 Jun 2011 10:31:42 +0200 Subject: [PATCH 040/780] fbdev: prefer "framerate_q" over "fps" in device context The variable is used for containing the parsed value of framerate, using a lexically consistent name eases readability/understanding. Signed-off-by: Anton Khirnov --- libavdevice/fbdev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index afd6b94ed0..68a52693fd 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -79,7 +79,7 @@ static enum PixelFormat get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *var typedef struct { AVClass *class; ///< class for private options int frame_size; ///< size in bytes of a grabbed frame - AVRational fps; ///< framerate + AVRational framerate_q; ///< framerate char *framerate; ///< framerate string set by a private option int64_t time_frame; ///< time for the next frame to output (in 1/1000000 units) @@ -102,14 +102,14 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, enum PixelFormat pix_fmt; int ret, flags = O_RDONLY; - ret = av_parse_video_rate(&fbdev->fps, fbdev->framerate); + ret = av_parse_video_rate(&fbdev->framerate_q, fbdev->framerate); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Couldn't parse framerate.\n"); return ret; } #if FF_API_FORMAT_PARAMETERS if (ap->time_base.num) - fbdev->fps = (AVRational){ap->time_base.den, ap->time_base.num}; + fbdev->framerate_q = (AVRational){ap->time_base.den, ap->time_base.num}; #endif if (!(st = av_new_stream(avctx, 0))) @@ -168,15 +168,15 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, st->codec->width = fbdev->width; st->codec->height = fbdev->heigth; st->codec->pix_fmt = pix_fmt; - st->codec->time_base = (AVRational){fbdev->fps.den, fbdev->fps.num}; + st->codec->time_base = (AVRational){fbdev->framerate_q.den, fbdev->framerate_q.num}; st->codec->bit_rate = - fbdev->width * fbdev->heigth * fbdev->bytes_per_pixel * av_q2d(fbdev->fps) * 8; + fbdev->width * fbdev->heigth * fbdev->bytes_per_pixel * av_q2d(fbdev->framerate_q) * 8; av_log(avctx, AV_LOG_INFO, "w:%d h:%d bpp:%d pixfmt:%s fps:%d/%d bit_rate:%d\n", fbdev->width, fbdev->heigth, fbdev->varinfo.bits_per_pixel, av_pix_fmt_descriptors[pix_fmt].name, - fbdev->fps.num, fbdev->fps.den, + fbdev->framerate_q.num, fbdev->framerate_q.den, st->codec->bit_rate); return 0; @@ -210,7 +210,7 @@ static int fbdev_read_packet(AVFormatContext *avctx, AVPacket *pkt) while (nanosleep(&ts, &ts) < 0 && errno == EINTR); } /* compute the time of the next frame */ - fbdev->time_frame += INT64_C(1000000) / av_q2d(fbdev->fps); + fbdev->time_frame += INT64_C(1000000) / av_q2d(fbdev->framerate_q); if ((ret = av_new_packet(pkt, fbdev->frame_size)) < 0) return ret; From e60068baeb576f34a542c8cad75d5604e9c5a2a9 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 3 Jun 2011 10:39:54 +0200 Subject: [PATCH 041/780] v4l2: prefer "framerate_q" over "fps" in v4l2_set_parameters() The variable is used for containing the parsed value of framerate, using a lexically consistent name eases readability/understanding. Signed-off-by: Anton Khirnov --- libavdevice/v4l2.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 2553bca48a..b024c48d2e 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -455,11 +455,11 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) struct v4l2_streamparm streamparm = { 0 }; struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; int i, ret; - AVRational fps; + AVRational framerate_q; streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (s->framerate && (ret = av_parse_video_rate(&fps, s->framerate)) < 0) { + if (s->framerate && (ret = av_parse_video_rate(&framerate_q, s->framerate)) < 0) { av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n"); return ret; } @@ -467,7 +467,7 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) if (ap->channel > 0) s->channel = ap->channel; if (ap->time_base.num) - fps = (AVRational){ap->time_base.den, ap->time_base.num}; + framerate_q = (AVRational){ap->time_base.den, ap->time_base.num}; #endif /* set tv video input */ @@ -520,23 +520,23 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) } } - if (fps.num && fps.den) { + if (framerate_q.num && framerate_q.den) { av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", - fps.den, fps.num); - tpf->numerator = fps.den; - tpf->denominator = fps.num; + framerate_q.den, framerate_q.num); + tpf->numerator = framerate_q.den; + tpf->denominator = framerate_q.num; if (ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl set time per frame(%d/%d) failed\n", - fps.den, fps.num); + framerate_q.den, framerate_q.num); return AVERROR(EIO); } - if (fps.num != tpf->denominator || - fps.den != tpf->numerator) { + if (framerate_q.num != tpf->denominator || + framerate_q.den != tpf->numerator) { av_log(s1, AV_LOG_INFO, "The driver changed the time per frame from %d/%d to %d/%d\n", - fps.den, fps.num, + framerate_q.den, framerate_q.num, tpf->numerator, tpf->denominator); } } else { From a4bda405447b13e84b4004ab281ae01abd230e22 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 3 Jun 2011 10:41:47 +0200 Subject: [PATCH 042/780] vfwcap: prefer "framerate_q" over "fps" in vfw_read_header() The variable is used for containing the parsed value of framerate, using a lexically consistent name eases readability/understanding. Signed-off-by: Anton Khirnov --- libavdevice/vfwcap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c index 95dd4c34b8..80f9d00e9c 100644 --- a/libavdevice/vfwcap.c +++ b/libavdevice/vfwcap.c @@ -249,7 +249,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) DWORD biCompression; WORD biBitCount; int ret; - AVRational fps; + AVRational framerate_q; if (!strcmp(s->filename, "list")) { for (devnum = 0; devnum <= 9; devnum++) { @@ -269,7 +269,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) #if FF_API_FORMAT_PARAMETERS if (ap->time_base.num) - fps = (AVRational){ap->time_base.den, ap->time_base.num}; + framerate_q = (AVRational){ap->time_base.den, ap->time_base.num}; #endif ctx->hwnd = capCreateCaptureWindow(NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0); @@ -369,7 +369,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) cparms.fYield = 1; // Spawn a background thread cparms.dwRequestMicroSecPerFrame = - (fps.den*1000000) / fps.num; + (framerate_q.den*1000000) / framerate_q.num; cparms.fAbortLeftMouse = 0; cparms.fAbortRightMouse = 0; cparms.fCaptureAudio = 0; @@ -381,7 +381,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail_io; codec = st->codec; - codec->time_base = (AVRational){fps.den, fps.num}; + codec->time_base = (AVRational){framerate_q.den, framerate_q.num}; codec->codec_type = AVMEDIA_TYPE_VIDEO; codec->width = bi->bmiHeader.biWidth; codec->height = bi->bmiHeader.biHeight; From 41b68dce4d148b6a227d001b32deb275c01aa550 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 3 Jun 2011 10:50:28 +0200 Subject: [PATCH 043/780] lavdev: improve feedback in case of invalid frame rate/size Show the invalid string in the error message. While at it also prefer "Could not" over "Couldn't", plain forms are preferred over contractions (simplify readability, especially for non English-savvy people). Signed-off-by: Anton Khirnov --- libavdevice/bktr.c | 4 ++-- libavdevice/fbdev.c | 2 +- libavdevice/libdc1394.c | 4 ++-- libavdevice/v4l2.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index aa3055d946..f1ae9ea685 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -263,7 +263,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) #endif if ((ret = av_parse_video_size(&width, &height, s->video_size)) < 0) { - av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n"); + av_log(s1, AV_LOG_ERROR, "Could not parse video size '%s'.\n", s->video_size); goto out; } @@ -278,7 +278,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) goto out; } if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) { - av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", s->framerate); goto out; } #if FF_API_FORMAT_PARAMETERS diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index 68a52693fd..2f3e0ff937 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -104,7 +104,7 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, ret = av_parse_video_rate(&fbdev->framerate_q, fbdev->framerate); if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + av_log(avctx, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", fbdev->framerate); return ret; } #if FF_API_FORMAT_PARAMETERS diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c index 622579bc92..bf4e27e51b 100644 --- a/libavdevice/libdc1394.c +++ b/libavdevice/libdc1394.c @@ -134,11 +134,11 @@ static inline int dc1394_read_common(AVFormatContext *c, AVFormatParameters *ap, } if ((ret = av_parse_video_size(&width, &height, dc1394->video_size)) < 0) { - av_log(c, AV_LOG_ERROR, "Couldn't parse video size.\n"); + av_log(c, AV_LOG_ERROR, "Could not parse video size '%s'.\n", dc1394->video_size); goto out; } if ((ret = av_parse_video_rate(&framerate, dc1394->framerate)) < 0) { - av_log(c, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + av_log(c, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", dc1394->framerate); goto out; } #if FF_API_FORMAT_PARAMETERS diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index b024c48d2e..072be48d40 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -460,7 +460,7 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (s->framerate && (ret = av_parse_video_rate(&framerate_q, s->framerate)) < 0) { - av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", s->framerate); return ret; } #if FF_API_FORMAT_PARAMETERS @@ -601,7 +601,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap) av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ if (s->video_size && (res = av_parse_video_size(&s->width, &s->height, s->video_size)) < 0) { - av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n"); + av_log(s1, AV_LOG_ERROR, "Could not parse video size '%s'.\n", s->video_size); goto out; } if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) { From 8d853efe53f13ef85ef8937df33017b33869bd52 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 6 Jun 2011 15:21:12 +0100 Subject: [PATCH 044/780] build: move special targets to end of main Makefile Signed-off-by: Mans Rullgard --- Makefile | 8 ++++++++ common.mak | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f4d03d42f8..75fe364029 100644 --- a/Makefile +++ b/Makefile @@ -145,5 +145,13 @@ check: test checkheaders include doc/Makefile include tests/Makefile +# Dummy rule to stop make trying to rebuild removed or renamed headers +%.h: + @: + +# Disable suffix rules. Most of the builtin rules are suffix rules, +# so this saves some time on slow systems. +.SUFFIXES: + .PHONY: all alltools *clean check config examples install* .PHONY: testprogs uninstall* diff --git a/common.mak b/common.mak index e9e69f263b..8d21d154d5 100644 --- a/common.mak +++ b/common.mak @@ -43,14 +43,6 @@ HOSTCFLAGS += $(IFLAGS) %.c %.h: TAG = GEN -# Dummy rule to stop make trying to rebuild removed or renamed headers -%.h: - @: - -# Disable suffix rules. Most of the builtin rules are suffix rules, -# so this saves some time on slow systems. -.SUFFIXES: - endif OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes) From bb5249244ddb22df1cfb8dee1c369e6cd653d00d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 5 Jun 2011 22:29:37 +0100 Subject: [PATCH 045/780] build: move basic rules and variables to main Makefile Signed-off-by: Mans Rullgard --- Makefile | 35 +++++++++++++++++++++++++++++++++++ common.mak | 40 ---------------------------------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index 75fe364029..d3396a1794 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,41 @@ vpath %.asm $(SRC_DIR) vpath %.v $(SRC_DIR) vpath %.texi $(SRC_PATH_BARE) +ifndef V +Q = @ +ECHO = printf "$(1)\t%s\n" $(2) +BRIEF = CC AS YASM AR LD HOSTCC +SILENT = DEPCC YASMDEP RM RANLIB +MSG = $@ +M = @$(call ECHO,$(TAG),$@); +$(foreach VAR,$(BRIEF), \ + $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR)))) +$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) +$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL)) +endif + +IFLAGS := -I. -I$(SRC_PATH) +CPPFLAGS := $(IFLAGS) $(CPPFLAGS) +CFLAGS += $(ECFLAGS) +YASMFLAGS += $(IFLAGS) -Pconfig.asm +HOSTCFLAGS += $(IFLAGS) + +%.o: %.c + $(CCDEP) + $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $< + +%.o: %.S + $(ASDEP) + $(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $< + +%.ho: %.h + $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $< + +%.ver: %.v + $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@ + +%.c %.h: TAG = GEN + PROGS-$(CONFIG_FFMPEG) += ffmpeg PROGS-$(CONFIG_FFPLAY) += ffplay PROGS-$(CONFIG_FFPROBE) += ffprobe diff --git a/common.mak b/common.mak index 8d21d154d5..e2eaa399da 100644 --- a/common.mak +++ b/common.mak @@ -5,46 +5,6 @@ # first so "all" becomes default target all: all-yes -ifndef SUBDIR - -ifndef V -Q = @ -ECHO = printf "$(1)\t%s\n" $(2) -BRIEF = CC AS YASM AR LD HOSTCC -SILENT = DEPCC YASMDEP RM RANLIB -MSG = $@ -M = @$(call ECHO,$(TAG),$@); -$(foreach VAR,$(BRIEF), \ - $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR)))) -$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) -$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL)) -endif - -IFLAGS := -I. -I$(SRC_PATH) -CPPFLAGS := $(IFLAGS) $(CPPFLAGS) -CFLAGS += $(ECFLAGS) -YASMFLAGS += $(IFLAGS) -Pconfig.asm - -HOSTCFLAGS += $(IFLAGS) - -%.o: %.c - $(CCDEP) - $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $< - -%.o: %.S - $(ASDEP) - $(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $< - -%.ho: %.h - $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $< - -%.ver: %.v - $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@ - -%.c %.h: TAG = GEN - -endif - OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes) OBJS += $(OBJS-yes) From f038cf3c745099151cdc8aa311fa83f5907598a6 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 6 Jun 2011 22:38:38 +0100 Subject: [PATCH 046/780] build: remove SRC_PATH_BARE variable Setting SRC_PATH to "." when building in-tree removes the need for a quoted version of the source path since out-of-tree builds are not possible if the pathname contains spaces. Signed-off-by: Mans Rullgard --- Makefile | 24 +++++++++++------------- configure | 5 ++--- doc/Makefile | 4 ++-- subdir.mak | 2 +- tests/Makefile | 18 +++++++++--------- tests/fate/vp8.mak | 4 ++-- 6 files changed, 27 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index d3396a1794..f1bede83db 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,11 @@ include config.mak -SRC_DIR = $(SRC_PATH_BARE) - -vpath %.c $(SRC_DIR) -vpath %.h $(SRC_DIR) -vpath %.S $(SRC_DIR) -vpath %.asm $(SRC_DIR) -vpath %.v $(SRC_DIR) -vpath %.texi $(SRC_PATH_BARE) +vpath %.c $(SRC_PATH) +vpath %.h $(SRC_PATH) +vpath %.S $(SRC_PATH) +vpath %.asm $(SRC_PATH) +vpath %.v $(SRC_PATH) +vpath %.texi $(SRC_PATH) ifndef V Q = @ @@ -19,7 +17,7 @@ M = @$(call ECHO,$(TAG),$@); $(foreach VAR,$(BRIEF), \ $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR)))) $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) -$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL)) +$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_PATH)/%=%)); $(INSTALL)) endif IFLAGS := -I. -I$(SRC_PATH) @@ -70,7 +68,7 @@ FFLIBS-$(CONFIG_SWSCALE) += swscale FFLIBS := avutil -DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset) +DATA_FILES := $(wildcard $(SRC_PATH)/ffpresets/*.ffpreset) SKIPHEADERS = cmdutils_common_opts.h @@ -83,7 +81,7 @@ FF_DEP_LIBS := $(DEP_LIBS) all: $(FF_DEP_LIBS) $(PROGS) config.h: .config -.config: $(wildcard $(FFLIBS:%=$(SRC_DIR)/lib%/all*.c)) +.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) @-tput bold 2>/dev/null @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n' @-tput sgr0 2>/dev/null @@ -122,8 +120,8 @@ tools/%.o: tools/%.c -include $(wildcard tools/*.d) -VERSION_SH = $(SRC_PATH_BARE)/version.sh -GIT_LOG = $(SRC_PATH_BARE)/.git/logs/HEAD +VERSION_SH = $(SRC_PATH)/version.sh +GIT_LOG = $(SRC_PATH)/.git/logs/HEAD .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak .version: M=@ diff --git a/configure b/configure index 672d452849..0f2bd063b8 100755 --- a/configure +++ b/configure @@ -1688,7 +1688,7 @@ DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM' # find source path if test -f configure; then - source_path="$(pwd)" + source_path=. disable source_path_used else source_path=$(cd $(dirname "$0"); pwd) @@ -3257,8 +3257,7 @@ INCDIR=\$(DESTDIR)$incdir BINDIR=\$(DESTDIR)$bindir DATADIR=\$(DESTDIR)$datadir MANDIR=\$(DESTDIR)$mandir -SRC_PATH="$source_path" -SRC_PATH_BARE=$source_path +SRC_PATH=$source_path CC_IDENT=$cc_ident ARCH=$arch CC=$cc diff --git a/doc/Makefile b/doc/Makefile index a5e090b0cc..558277ad0c 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -11,9 +11,9 @@ documentation: $(DOCS) TEXIDEP = awk '/^@include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d) doc/%.html: TAG = HTML -doc/%.html: doc/%.texi $(SRC_PATH_BARE)/doc/t2h.init +doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(Q)$(TEXIDEP) - $(M)texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init --output $@ $< + $(M)texi2html -monolithic --init-file $(SRC_PATH)/doc/t2h.init --output $@ $< doc/%.pod: TAG = POD doc/%.pod: doc/%.texi diff --git a/subdir.mak b/subdir.mak index 1d5824b022..63398608d7 100644 --- a/subdir.mak +++ b/subdir.mak @@ -1,4 +1,4 @@ -SRC_DIR := $(SRC_PATH_BARE)/lib$(NAME) +SRC_DIR := $(SRC_PATH)/lib$(NAME) include $(SUBDIR)../common.mak diff --git a/tests/Makefile b/tests/Makefile index 1f7ba26aff..fb9b56e6b3 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -41,16 +41,16 @@ tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS) tools/lavfi-showfiltfmts$(EXESUF): tools/lavfi-showfiltfmts.o $(FF_DEP_LIBS) $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) -include $(SRC_PATH_BARE)/tests/fate.mak -include $(SRC_PATH_BARE)/tests/fate2.mak +include $(SRC_PATH)/tests/fate.mak +include $(SRC_PATH)/tests/fate2.mak -include $(SRC_PATH_BARE)/tests/fate/aac.mak -include $(SRC_PATH_BARE)/tests/fate/als.mak -include $(SRC_PATH_BARE)/tests/fate/fft.mak -include $(SRC_PATH_BARE)/tests/fate/h264.mak -include $(SRC_PATH_BARE)/tests/fate/mp3.mak -include $(SRC_PATH_BARE)/tests/fate/vorbis.mak -include $(SRC_PATH_BARE)/tests/fate/vp8.mak +include $(SRC_PATH)/tests/fate/aac.mak +include $(SRC_PATH)/tests/fate/als.mak +include $(SRC_PATH)/tests/fate/fft.mak +include $(SRC_PATH)/tests/fate/h264.mak +include $(SRC_PATH)/tests/fate/mp3.mak +include $(SRC_PATH)/tests/fate/vorbis.mak +include $(SRC_PATH)/tests/fate/vp8.mak FATE_ACODEC = $(ACODEC_TESTS:%=fate-acodec-%) FATE_VSYNTH1 = $(VCODEC_TESTS:%=fate-vsynth1-%) diff --git a/tests/fate/vp8.mak b/tests/fate/vp8.mak index 2b171305cc..1f442af4ac 100644 --- a/tests/fate/vp8.mak +++ b/tests/fate/vp8.mak @@ -3,7 +3,7 @@ VP8_SUITE = 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 define FATE_VP8_SUITE FATE_VP8 += fate-vp8-test-vector$(2)-$(1) fate-vp8-test-vector$(2)-$(1): CMD = framemd5 $(3) -i $(SAMPLES)/vp8-test-vectors-r1/vp80-00-comprehensive-$(1).ivf -fate-vp8-test-vector$(2)-$(1): REF = $(SRC_PATH_BARE)/tests/ref/fate/vp8-test-vector-$(1) +fate-vp8-test-vector$(2)-$(1): REF = $(SRC_PATH)/tests/ref/fate/vp8-test-vector-$(1) endef define FATE_VP8_FULL @@ -11,7 +11,7 @@ $(foreach N,$(VP8_SUITE),$(eval $(call FATE_VP8_SUITE,$(N),$(1),$(2)))) FATE_VP8 += fate-vp8-sign-bias$(1) fate-vp8-sign-bias$(1): CMD = framemd5 $(2) -i $(SAMPLES)/vp8/sintel-signbias.ivf -fate-vp8-sign-bias$(1): REF = $(SRC_PATH_BARE)/tests/ref/fate/vp8-sign-bias +fate-vp8-sign-bias$(1): REF = $(SRC_PATH)/tests/ref/fate/vp8-sign-bias endef $(eval $(call FATE_VP8_FULL)) From 35fa0d47585cef28cd8191dccf0607d90c7667a6 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 23 Jun 2011 13:27:21 +0200 Subject: [PATCH 047/780] nsvdec: Propagate error values instead of returning 0 in nsv_read_header(). This eliminates a warning about a set-but-unused variable. --- libavformat/nsvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index 9adb2f4729..6e9cfe3a84 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -531,7 +531,7 @@ static int nsv_read_header(AVFormatContext *s, AVFormatParameters *ap) err = nsv_read_chunk(s, 1); av_dlog(s, "parsed header\n"); - return 0; + return err; } static int nsv_read_chunk(AVFormatContext *s, int fill_header) From ffc6c8a4305d25db8a5af72389a2453b17f43646 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 23 Jun 2011 16:49:51 +0200 Subject: [PATCH 048/780] Support u8, s8, alaw and mulaw channel reordering in alsa. --- libavdevice/alsa-audio-common.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index 38466a06ce..668ca02201 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -115,6 +115,9 @@ static void alsa_reorder_ ## NAME ## _out_71(const void *in_v, void *out_v, int } \ } +REORDER_OUT_50(int8, int8_t) +REORDER_OUT_51(int8, int8_t) +REORDER_OUT_71(int8, int8_t) REORDER_OUT_50(int16, int16_t) REORDER_OUT_51(int16, int16_t) REORDER_OUT_71(int16, int16_t) @@ -132,6 +135,17 @@ static av_cold ff_reorder_func find_reorder_func(int codec_id, int out) { return + codec_id == CODEC_ID_PCM_U8 || codec_id == CODEC_ID_PCM_S8 || + codec_id == CODEC_ID_PCM_ALAW || codec_id == CODEC_ID_PCM_MULAW ? + layout == AV_CH_LAYOUT_QUAD || layout == AV_CH_LAYOUT_2_2 ? + REORDER_DUMMY : + layout == AV_CH_LAYOUT_5POINT0_BACK || layout == AV_CH_LAYOUT_5POINT0 ? + out ? alsa_reorder_int8_out_50 : NULL : + layout == AV_CH_LAYOUT_5POINT1_BACK || layout == AV_CH_LAYOUT_5POINT1 ? + out ? alsa_reorder_int8_out_51 : NULL : + layout == AV_CH_LAYOUT_7POINT1 ? + out ? alsa_reorder_int8_out_71 : NULL : + NULL : codec_id == CODEC_ID_PCM_U16LE || codec_id == CODEC_ID_PCM_U16BE || codec_id == CODEC_ID_PCM_S16LE || codec_id == CODEC_ID_PCM_S16BE ? layout == AV_CH_LAYOUT_QUAD || layout == AV_CH_LAYOUT_2_2 ? From 9e19704a6a04786f65478b9e9aeb470c6d1e277c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 23 Jun 2011 15:42:19 +0100 Subject: [PATCH 049/780] ARM: enable thumb for Cortex-M* CPUs These CPUs are thumb-only and thus require this option. Signed-off-by: Mans Rullgard --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 0f2bd063b8..f557482c18 100755 --- a/configure +++ b/configure @@ -2270,7 +2270,7 @@ elif enabled arm; then case $cpu in cortex-a*) subarch=armv7a ;; cortex-r*) subarch=armv7r ;; - cortex-m*) subarch=armv7m ;; + cortex-m*) enable thumb; subarch=armv7m ;; arm11*) subarch=armv6 ;; arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;; armv4*|arm7*|arm9[24]*) subarch=armv4 ;; From 67e9ae14d93aeee019bf65d38192ca5c75dc99dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 17 Jun 2011 10:30:15 +0300 Subject: [PATCH 050/780] Add av_printf_format, for marking printf style format strings and their parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- doc/APIchanges | 3 +++ libavutil/attributes.h | 2 ++ libavutil/avutil.h | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 79d9749373..65e1da7a62 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-06-xx - xxxxxxx - lavu 51.8.0 - attributes.h + Add av_printf_format(). + 2011-06-xx - xxxxxxx - lavf 53.2.0 - avformat.h Add avformat_open_input and avformat_write_header(). Deprecate av_open_input_stream, av_open_input_file, diff --git a/libavutil/attributes.h b/libavutil/attributes.h index 4abe78f3bf..ef990a1d4f 100644 --- a/libavutil/attributes.h +++ b/libavutil/attributes.h @@ -127,8 +127,10 @@ #ifdef __GNUC__ # define av_builtin_constant_p __builtin_constant_p +# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos))) #else # define av_builtin_constant_p(x) 0 +# define av_printf_format(fmtpos, attrpos) #endif #endif /* AVUTIL_ATTRIBUTES_H */ diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 18461467b4..d6e4668b88 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -40,7 +40,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 7 +#define LIBAVUTIL_VERSION_MINOR 8 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From 9abbe8cc136e7fbc69004df3f1de9d54c40d969d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 17 Jun 2011 10:31:11 +0300 Subject: [PATCH 051/780] Use av_printf_format to check the usage of printf style functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This helps catching cases where the format string doesn't match what is passed in, or injection bugs where user data is passed in as format string. Signed-off-by: Martin Storsjö --- libavcodec/avcodec.h | 2 +- libavformat/avio.h | 12 ++---------- libavformat/internal.h | 2 +- libavformat/rtpproto.c | 2 +- libavutil/avstring.h | 3 ++- libavutil/log.h | 7 ++----- 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index a70d8adb90..e251db4c9a 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -4143,7 +4143,7 @@ void av_log_missing_feature(void *avc, const char *feature, int want_sample); * a pointer to an AVClass struct * @param[in] msg string containing an optional message, or NULL if no message */ -void av_log_ask_for_sample(void *avc, const char *msg, ...); +void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3); /** * Register the hardware accelerator hwaccel. diff --git a/libavformat/avio.h b/libavformat/avio.h index e07e3c3c92..bb2d9f85a6 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -284,11 +284,7 @@ attribute_deprecated int64_t url_fsize(AVIOContext *s); #define URL_EOF (-1) attribute_deprecated int url_fgetc(AVIOContext *s); attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size); -#ifdef __GNUC__ -attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); -#else -attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); -#endif +attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); attribute_deprecated void put_flush_packet(AVIOContext *s); attribute_deprecated int url_open_dyn_buf(AVIOContext **s); attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); @@ -463,11 +459,7 @@ static av_always_inline int64_t avio_tell(AVIOContext *s) int64_t avio_size(AVIOContext *s); /** @warning currently size is limited */ -#ifdef __GNUC__ -int avio_printf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); -#else -int avio_printf(AVIOContext *s, const char *fmt, ...); -#endif +int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); void avio_flush(AVIOContext *s); diff --git a/libavformat/internal.h b/libavformat/internal.h index 7413b0906a..30faa00e95 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -108,7 +108,7 @@ uint64_t ff_ntp_time(void); */ int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, - int port, const char *fmt, ...); + int port, const char *fmt, ...) av_printf_format(7, 8); /** * Append the media-specific SDP fragment for the media stream c diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 1340665c74..dba1d35b03 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -86,7 +86,7 @@ int rtp_set_remote_url(URLContext *h, const char *uri) * "http://host:port/path?option1=val1&option2=val2... */ -static void url_add_option(char *buf, int buf_size, const char *fmt, ...) +static av_printf_format(3, 4) void url_add_option(char *buf, int buf_size, const char *fmt, ...) { char buf1[1024]; va_list ap; diff --git a/libavutil/avstring.h b/libavutil/avstring.h index b40acf6ebb..44ed89d654 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -22,6 +22,7 @@ #define AVUTIL_AVSTRING_H #include +#include "attributes.h" /** * Return non-zero if pfx is a prefix of str. If it is, *ptr is set to @@ -107,7 +108,7 @@ size_t av_strlcat(char *dst, const char *src, size_t size); * @return the length of the string that would have been generated * if enough space had been available */ -size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...); +size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4); /** * Convert a number to a av_malloced string. diff --git a/libavutil/log.h b/libavutil/log.h index c823a763ee..c1d9a6c393 100644 --- a/libavutil/log.h +++ b/libavutil/log.h @@ -23,6 +23,7 @@ #include #include "avutil.h" +#include "attributes.h" /** * Describe the class of an AVClass context structure. That is an @@ -129,11 +130,7 @@ typedef struct { * subsequent arguments are converted to output. * @see av_vlog */ -#ifdef __GNUC__ -void av_log(void *avcl, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); -#else -void av_log(void *avcl, int level, const char *fmt, ...); -#endif +void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); void av_vlog(void *avcl, int level, const char *fmt, va_list); int av_log_get_level(void); From adbfc605f6bbe87b292c82cd1f5d4d974fa6b73c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 23 Jun 2011 22:41:54 +0200 Subject: [PATCH 052/780] doxygen: Consistently use '@' instead of '\' for Doxygen markup. Signed-off-by: Diego Biurrun --- libavcodec/acelp_pitch_delay.h | 74 ++++++++++++++++---------------- libavcodec/avcodec.h | 6 +-- libavcodec/celp_filters.h | 2 +- libavcodec/fft.h | 2 +- libavcodec/g729dec.c | 2 +- libavcodec/h264_parser.c | 2 +- libavcodec/lagarith.c | 26 +++++------ libavcodec/lagarithrac.h | 14 +++--- libavcodec/lcldec.c | 14 +++--- libavcodec/lsp.c | 6 +-- libavcodec/lsp.h | 42 +++++++++--------- libavcodec/motion_est.c | 2 +- libavcodec/motion_est_template.c | 8 ++-- libavcodec/mpegvideo.h | 2 +- libavcodec/nuv.c | 14 +++--- libavcodec/qcelpdata.h | 6 +-- libavcodec/qcelpdec.c | 8 ++-- libavcodec/rtjpeg.c | 38 ++++++++-------- libavcodec/tableprint.h | 2 +- libavcodec/twinvq.c | 8 ++-- libavcodec/vaapi.c | 2 +- libavcodec/vaapi.h | 4 +- libavcodec/vaapi_internal.h | 2 +- libavcodec/vdpau.c | 2 +- libavcodec/vdpau.h | 12 +++--- libavcodec/x86/idct_sse2_xvid.c | 2 +- libavcodec/x86/idct_xvid.h | 2 +- libavcodec/xsubenc.c | 4 +- libavformat/asfcrypt.c | 36 ++++++++-------- libavformat/gxf.c | 54 +++++++++++------------ libavformat/mpegts.c | 8 ++-- libavformat/nuv.c | 10 ++--- libavutil/common.h | 20 ++++----- libavutil/des.c | 2 +- libavutil/des.h | 18 ++++---- libavutil/lzo.c | 22 +++++----- libavutil/lzo.h | 22 +++++----- libavutil/rc4.h | 18 ++++---- 38 files changed, 259 insertions(+), 259 deletions(-) diff --git a/libavcodec/acelp_pitch_delay.h b/libavcodec/acelp_pitch_delay.h index 6d182bb7ad..e5410bba7f 100644 --- a/libavcodec/acelp_pitch_delay.h +++ b/libavcodec/acelp_pitch_delay.h @@ -30,11 +30,11 @@ #define PITCH_DELAY_MAX 143 /** - * \brief Decode pitch delay of the first subframe encoded by 8 bits with 1/3 + * @brief Decode pitch delay of the first subframe encoded by 8 bits with 1/3 * resolution. - * \param ac_index adaptive codebook index (8 bits) + * @param ac_index adaptive codebook index (8 bits) * - * \return pitch delay in 1/3 units + * @return pitch delay in 1/3 units * * Pitch delay is coded: * with 1/3 resolution, 19 < pitch_delay < 85 @@ -43,18 +43,18 @@ int ff_acelp_decode_8bit_to_1st_delay3(int ac_index); /** - * \brief Decode pitch delay of the second subframe encoded by 5 or 6 bits + * @brief Decode pitch delay of the second subframe encoded by 5 or 6 bits * with 1/3 precision. - * \param ac_index adaptive codebook index (5 or 6 bits) - * \param pitch_delay_min lower bound (integer) of pitch delay interval + * @param ac_index adaptive codebook index (5 or 6 bits) + * @param pitch_delay_min lower bound (integer) of pitch delay interval * for second subframe * - * \return pitch delay in 1/3 units + * @return pitch delay in 1/3 units * * Pitch delay is coded: * with 1/3 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5 * - * \remark The routine is used in G.729 @@8k, AMR @@10.2k, AMR @@7.95k, + * @remark The routine is used in G.729 @@8k, AMR @@10.2k, AMR @@7.95k, * AMR @@7.4k for the second subframe. */ int ff_acelp_decode_5_6_bit_to_2nd_delay3( @@ -62,19 +62,19 @@ int ff_acelp_decode_5_6_bit_to_2nd_delay3( int pitch_delay_min); /** - * \brief Decode pitch delay with 1/3 precision. - * \param ac_index adaptive codebook index (4 bits) - * \param pitch_delay_min lower bound (integer) of pitch delay interval for + * @brief Decode pitch delay with 1/3 precision. + * @param ac_index adaptive codebook index (4 bits) + * @param pitch_delay_min lower bound (integer) of pitch delay interval for * second subframe * - * \return pitch delay in 1/3 units + * @return pitch delay in 1/3 units * * Pitch delay is coded: * integers only, -6 < pitch_delay - int(prev_pitch_delay) <= -2 * with 1/3 resolution, -2 < pitch_delay - int(prev_pitch_delay) < 1 * integers only, 1 <= pitch_delay - int(prev_pitch_delay) < 5 * - * \remark The routine is used in G.729 @@6.4k, AMR @@6.7k, AMR @@5.9k, + * @remark The routine is used in G.729 @@6.4k, AMR @@6.7k, AMR @@5.9k, * AMR @@5.15k, AMR @@4.75k for the second subframe. */ int ff_acelp_decode_4bit_to_2nd_delay3( @@ -82,44 +82,44 @@ int ff_acelp_decode_4bit_to_2nd_delay3( int pitch_delay_min); /** - * \brief Decode pitch delay of the first subframe encoded by 9 bits + * @brief Decode pitch delay of the first subframe encoded by 9 bits * with 1/6 precision. - * \param ac_index adaptive codebook index (9 bits) + * @param ac_index adaptive codebook index (9 bits) * - * \return pitch delay in 1/6 units + * @return pitch delay in 1/6 units * * Pitch delay is coded: * with 1/6 resolution, 17 < pitch_delay < 95 * integers only, 95 <= pitch_delay <= 143 * - * \remark The routine is used in AMR @@12.2k for the first and third subframes. + * @remark The routine is used in AMR @@12.2k for the first and third subframes. */ int ff_acelp_decode_9bit_to_1st_delay6(int ac_index); /** - * \brief Decode pitch delay of the second subframe encoded by 6 bits + * @brief Decode pitch delay of the second subframe encoded by 6 bits * with 1/6 precision. - * \param ac_index adaptive codebook index (6 bits) - * \param pitch_delay_min lower bound (integer) of pitch delay interval for + * @param ac_index adaptive codebook index (6 bits) + * @param pitch_delay_min lower bound (integer) of pitch delay interval for * second subframe * - * \return pitch delay in 1/6 units + * @return pitch delay in 1/6 units * * Pitch delay is coded: * with 1/6 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5 * - * \remark The routine is used in AMR @@12.2k for the second and fourth subframes. + * @remark The routine is used in AMR @@12.2k for the second and fourth subframes. */ int ff_acelp_decode_6bit_to_2nd_delay6( int ac_index, int pitch_delay_min); /** - * \brief Update past quantized energies - * \param[in,out] quant_energy past quantized energies (5.10) - * \param gain_corr_factor gain correction factor - * \param log2_ma_pred_order log2() of MA prediction order - * \param erasure frame erasure flag + * @brief Update past quantized energies + * @param[in,out] quant_energy past quantized energies (5.10) + * @param gain_corr_factor gain correction factor + * @param log2_ma_pred_order log2() of MA prediction order + * @param erasure frame erasure flag * * If frame erasure flag is not equal to zero, memory is updated with * averaged energy, attenuated by 4dB: @@ -128,7 +128,7 @@ int ff_acelp_decode_6bit_to_2nd_delay6( * In normal mode memory is updated with * Er - Ep = 20 * log10(gain_corr_factor) * - * \remark The routine is used in G.729 and AMR (all modes). + * @remark The routine is used in G.729 and AMR (all modes). */ void ff_acelp_update_past_gain( int16_t* quant_energy, @@ -137,16 +137,16 @@ void ff_acelp_update_past_gain( int erasure); /** - * \brief Decode the adaptive codebook gain and add + * @brief Decode the adaptive codebook gain and add * correction (4.1.5 and 3.9.1 of G.729). - * \param dsp initialized dsputil context - * \param gain_corr_factor gain correction factor (2.13) - * \param fc_v fixed-codebook vector (2.13) - * \param mr_energy mean innovation energy and fixed-point correction (7.13) - * \param[in,out] quant_energy past quantized energies (5.10) - * \param subframe_size length of subframe + * @param dsp initialized dsputil context + * @param gain_corr_factor gain correction factor (2.13) + * @param fc_v fixed-codebook vector (2.13) + * @param mr_energy mean innovation energy and fixed-point correction (7.13) + * @param[in,out] quant_energy past quantized energies (5.10) + * @param subframe_size length of subframe * - * \return quantized fixed-codebook gain (14.1) + * @return quantized fixed-codebook gain (14.1) * * The routine implements equations 69, 66 and 71 of the G.729 specification (3.9.1) * @@ -205,7 +205,7 @@ void ff_acelp_update_past_gain( * * mr_energy = Em + 10log(N) + 10log(2^26) * - * \remark The routine is used in G.729 and AMR (all modes). + * @remark The routine is used in G.729 and AMR (all modes). */ int16_t ff_acelp_decode_gain_code( DSPContext *dsp, diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index e251db4c9a..40c30fc8e4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3255,7 +3255,7 @@ void av_resample_close(struct AVResampleContext *c); /** * Allocate memory for a picture. Call avpicture_free() to free it. * - * \see avpicture_fill() + * @see avpicture_fill() * * @param picture the picture to be filled in * @param pix_fmt the format of the picture @@ -3302,7 +3302,7 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr, * The data is stored compactly, without any gaps for alignment or padding * which may be applied by avpicture_fill(). * - * \see avpicture_get_size() + * @see avpicture_get_size() * * @param[in] src AVPicture containing image data * @param[in] pix_fmt The format in which the picture data is stored. @@ -3896,7 +3896,7 @@ typedef struct AVCodecParserContext { int64_t offset; ///< byte offset from starting packet start int64_t cur_frame_end[AV_PARSER_PTS_NB]; - /*! + /** * Set by parser to 1 for key frames and 0 for non-key frames. * It is initialized to -1, so if the parser doesn't set this flag, * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames diff --git a/libavcodec/celp_filters.h b/libavcodec/celp_filters.h index 03d481d859..cfd08fd440 100644 --- a/libavcodec/celp_filters.h +++ b/libavcodec/celp_filters.h @@ -34,7 +34,7 @@ * * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] } * - * \note fc_in and fc_out should not overlap! + * @note fc_in and fc_out should not overlap! */ void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in, const int16_t *filter, int len); diff --git a/libavcodec/fft.h b/libavcodec/fft.h index dc3c1909b0..706f94b574 100644 --- a/libavcodec/fft.h +++ b/libavcodec/fft.h @@ -119,7 +119,7 @@ extern COSTABLE_CONST FFTSample* const FFT_NAME(ff_cos_tabs)[17]; /** * Initialize the cosine table in ff_cos_tabs[index] - * \param index index in ff_cos_tabs array of the table to initialize + * @param index index in ff_cos_tabs array of the table to initialize */ void ff_init_ff_cos_tabs(int index); diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c index 979b87fd27..71e7c5d4c8 100644 --- a/libavcodec/g729dec.c +++ b/libavcodec/g729dec.c @@ -116,7 +116,7 @@ static const G729FormatDescription format_g729d_6k4 = { }; /** - * \brief pseudo random number generator + * @brief pseudo random number generator */ static inline uint16_t g729_prng(uint16_t value) { diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index c39baeb739..56102691a8 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -97,7 +97,7 @@ found: return i-(state&5); } -/*! +/** * Parse NAL units of found picture and decode some basic information. * * @param s parser context. diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c index 3d53536d13..1c18b967e4 100644 --- a/libavcodec/lagarith.c +++ b/libavcodec/lagarith.c @@ -32,25 +32,25 @@ #include "lagarithrac.h" enum LagarithFrameType { - FRAME_RAW = 1, /*!< uncompressed */ - FRAME_U_RGB24 = 2, /*!< unaligned RGB24 */ - FRAME_ARITH_YUY2 = 3, /*!< arithmetic coded YUY2 */ - FRAME_ARITH_RGB24 = 4, /*!< arithmetic coded RGB24 */ - FRAME_SOLID_GRAY = 5, /*!< solid grayscale color frame */ - FRAME_SOLID_COLOR = 6, /*!< solid non-grayscale color frame */ - FRAME_OLD_ARITH_RGB = 7, /*!< obsolete arithmetic coded RGB (no longer encoded by upstream since version 1.1.0) */ - FRAME_ARITH_RGBA = 8, /*!< arithmetic coded RGBA */ - FRAME_SOLID_RGBA = 9, /*!< solid RGBA color frame */ - FRAME_ARITH_YV12 = 10, /*!< arithmetic coded YV12 */ - FRAME_REDUCED_RES = 11, /*!< reduced resolution YV12 frame */ + FRAME_RAW = 1, /**< uncompressed */ + FRAME_U_RGB24 = 2, /**< unaligned RGB24 */ + FRAME_ARITH_YUY2 = 3, /**< arithmetic coded YUY2 */ + FRAME_ARITH_RGB24 = 4, /**< arithmetic coded RGB24 */ + FRAME_SOLID_GRAY = 5, /**< solid grayscale color frame */ + FRAME_SOLID_COLOR = 6, /**< solid non-grayscale color frame */ + FRAME_OLD_ARITH_RGB = 7, /**< obsolete arithmetic coded RGB (no longer encoded by upstream since version 1.1.0) */ + FRAME_ARITH_RGBA = 8, /**< arithmetic coded RGBA */ + FRAME_SOLID_RGBA = 9, /**< solid RGBA color frame */ + FRAME_ARITH_YV12 = 10, /**< arithmetic coded YV12 */ + FRAME_REDUCED_RES = 11, /**< reduced resolution YV12 frame */ }; typedef struct LagarithContext { AVCodecContext *avctx; AVFrame picture; DSPContext dsp; - int zeros; /*!< number of consecutive zero bytes encountered */ - int zeros_rem; /*!< number of zero bytes remaining to output */ + int zeros; /**< number of consecutive zero bytes encountered */ + int zeros_rem; /**< number of zero bytes remaining to output */ } LagarithContext; /** diff --git a/libavcodec/lagarithrac.h b/libavcodec/lagarithrac.h index 6a8fa95a8e..b9421993a4 100644 --- a/libavcodec/lagarithrac.h +++ b/libavcodec/lagarithrac.h @@ -40,15 +40,15 @@ typedef struct lag_rac { AVCodecContext *avctx; unsigned low; unsigned range; - unsigned scale; /*!< Number of bits of precision in range. */ - unsigned hash_shift; /*!< Number of bits to shift to calculate hash for radix search. */ + unsigned scale; /**< Number of bits of precision in range. */ + unsigned hash_shift; /**< Number of bits to shift to calculate hash for radix search. */ - const uint8_t *bytestream_start; /*!< Start of input bytestream. */ - const uint8_t *bytestream; /*!< Current position in input bytestream. */ - const uint8_t *bytestream_end; /*!< End position of input bytestream. */ + const uint8_t *bytestream_start; /**< Start of input bytestream. */ + const uint8_t *bytestream; /**< Current position in input bytestream. */ + const uint8_t *bytestream_end; /**< End position of input bytestream. */ - uint32_t prob[258]; /*!< Table of cumulative probability for each symbol. */ - uint8_t range_hash[256]; /*!< Hash table mapping upper byte to approximate symbol. */ + uint32_t prob[258]; /**< Table of cumulative probability for each symbol. */ + uint8_t range_hash[256]; /**< Hash table mapping upper byte to approximate symbol. */ } lag_rac; void lag_rac_init(lag_rac *l, GetBitContext *gb, int length); diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index 70414d4d55..f41a88934b 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -73,8 +73,8 @@ typedef struct LclDecContext { /** - * \param srcptr compressed source buffer, must be padded with at least 5 extra bytes - * \param destptr must be padded sufficiently for av_memcpy_backptr + * @param srcptr compressed source buffer, must be padded with at least 5 extra bytes + * @param destptr must be padded sufficiently for av_memcpy_backptr */ static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize) { @@ -119,11 +119,11 @@ static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsign #if CONFIG_ZLIB_DECODER /** - * \brief decompress a zlib-compressed data block into decomp_buf - * \param src compressed input buffer - * \param src_len data length in input buffer - * \param offset offset in decomp_buf - * \param expected expected decompressed length + * @brief decompress a zlib-compressed data block into decomp_buf + * @param src compressed input buffer + * @param src_len data length in input buffer + * @param offset offset in decomp_buf + * @param expected expected decompressed length */ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, int offset, int expected) { diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c index d9ddd7d081..26b35843b6 100644 --- a/libavcodec/lsp.c +++ b/libavcodec/lsp.c @@ -74,9 +74,9 @@ void ff_acelp_lsf2lspd(double *lsp, const float *lsf, int lp_order) } /** - * \brief decodes polynomial coefficients from LSP - * \param f [out] decoded polynomial coefficients (-0x20000000 <= (3.22) <= 0x1fffffff) - * \param lsp LSP coefficients (-0x8000 <= (0.15) <= 0x7fff) + * @brief decodes polynomial coefficients from LSP + * @param f [out] decoded polynomial coefficients (-0x20000000 <= (3.22) <= 0x1fffffff) + * @param lsp LSP coefficients (-0x8000 <= (0.15) <= 0x7fff) */ static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order) { diff --git a/libavcodec/lsp.h b/libavcodec/lsp.h index 388de514c6..3648ec74e5 100644 --- a/libavcodec/lsp.h +++ b/libavcodec/lsp.h @@ -30,12 +30,12 @@ */ /** - * \brief ensure a minimum distance between LSFs - * \param[in,out] lsfq LSF to check and adjust - * \param lsfq_min_distance minimum distance between LSFs - * \param lsfq_min minimum allowed LSF value - * \param lsfq_max maximum allowed LSF value - * \param lp_order LP filter order + * @brief ensure a minimum distance between LSFs + * @param[in,out] lsfq LSF to check and adjust + * @param lsfq_min_distance minimum distance between LSFs + * @param lsfq_min minimum allowed LSF value + * @param lsfq_max maximum allowed LSF value + * @param lp_order LP filter order */ void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order); @@ -53,12 +53,12 @@ void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, in void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size); /** - * \brief Convert LSF to LSP - * \param[out] lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000) - * \param lsf normalized LSF coefficients (0 <= (2.13) < 0x2000 * PI) - * \param lp_order LP filter order + * @brief Convert LSF to LSP + * @param[out] lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000) + * @param lsf normalized LSF coefficients (0 <= (2.13) < 0x2000 * PI) + * @param lp_order LP filter order * - * \remark It is safe to pass the same array into the lsf and lsp parameters. + * @remark It is safe to pass the same array into the lsf and lsp parameters. */ void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order); @@ -68,10 +68,10 @@ void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order); void ff_acelp_lsf2lspd(double *lsp, const float *lsf, int lp_order); /** - * \brief LSP to LP conversion (3.2.6 of G.729) - * \param[out] lp decoded LP coefficients (-0x8000 <= (3.12) < 0x8000) - * \param lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000) - * \param lp_half_order LP filter order, divided by 2 + * @brief LSP to LP conversion (3.2.6 of G.729) + * @param[out] lp decoded LP coefficients (-0x8000 <= (3.12) < 0x8000) + * @param lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000) + * @param lp_half_order LP filter order, divided by 2 */ void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order); @@ -81,12 +81,12 @@ void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order); void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order); /** - * \brief Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729) - * \param[out] lp_1st decoded LP coefficients for first subframe (-0x8000 <= (3.12) < 0x8000) - * \param[out] lp_2nd decoded LP coefficients for second subframe (-0x8000 <= (3.12) < 0x8000) - * \param lsp_2nd LSP coefficients of the second subframe (-0x8000 <= (0.15) < 0x8000) - * \param lsp_prev LSP coefficients from the second subframe of the previous frame (-0x8000 <= (0.15) < 0x8000) - * \param lp_order LP filter order + * @brief Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729) + * @param[out] lp_1st decoded LP coefficients for first subframe (-0x8000 <= (3.12) < 0x8000) + * @param[out] lp_2nd decoded LP coefficients for second subframe (-0x8000 <= (3.12) < 0x8000) + * @param lsp_2nd LSP coefficients of the second subframe (-0x8000 <= (0.15) < 0x8000) + * @param lsp_prev LSP coefficients from the second subframe of the previous frame (-0x8000 <= (0.15) < 0x8000) + * @param lp_order LP filter order */ void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order); diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 5f10456d3b..48e8ea9ffa 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -248,7 +248,7 @@ static int cmp_internal(MpegEncContext *s, const int x, const int y, const int s } } -/*! \brief compares a block (either a full macroblock or a partition thereof) +/** @brief compares a block (either a full macroblock or a partition thereof) against a proposed motion-compensated prediction of that block */ static av_always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby, diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index 6b807dc6f6..b451c76bb4 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -990,8 +990,8 @@ static av_always_inline int diamond_search(MpegEncContext * s, int *best, int dm return var_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags); } -/*! - \param P[10][2] a list of candidate mvs to check before starting the +/** + @param P[10][2] a list of candidate mvs to check before starting the iterative search. If one of the candidates is close to the optimal mv, then it takes fewer iterations. And it increases the chance that we find the optimal mv. @@ -1001,12 +1001,12 @@ static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int int ref_mv_scale, int flags, int size, int h) { MotionEstContext * const c= &s->me; - int best[2]={0, 0}; /*!< x and y coordinates of the best motion vector. + int best[2]={0, 0}; /**< x and y coordinates of the best motion vector. i.e. the difference between the position of the block currently being encoded and the position of the block chosen to predict it from. */ int d; ///< the score (cmp + penalty) of any given mv - int dmin; /*!< the best value of d, i.e. the score + int dmin; /**< the best value of d, i.e. the score corresponding to the mv stored in best[]. */ int map_generation; int penalty_factor; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 6ce7faa235..e072aa7c33 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -154,7 +154,7 @@ typedef struct MotionEstContext{ uint32_t *score_map; ///< map to store the scores int map_generation; int pre_penalty_factor; - int penalty_factor; /*!< an estimate of the bits required to + int penalty_factor; /**< an estimate of the bits required to code a given mv value, e.g. (1,0) takes more bits than (0,0). We have to estimate whether any reduction in diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 0c5e42fe78..3bc6328a04 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -63,11 +63,11 @@ static const uint8_t fallback_cquant[] = { }; /** - * \brief copy frame data from buffer to AVFrame, handling stride. - * \param f destination AVFrame - * \param src source buffer, does not use any line-stride - * \param width width of the video frame - * \param height height of the video frame + * @brief copy frame data from buffer to AVFrame, handling stride. + * @param f destination AVFrame + * @param src source buffer, does not use any line-stride + * @param width width of the video frame + * @param height height of the video frame */ static void copy_frame(AVFrame *f, const uint8_t *src, int width, int height) { @@ -77,7 +77,7 @@ static void copy_frame(AVFrame *f, const uint8_t *src, } /** - * \brief extract quantization tables from codec data into our context + * @brief extract quantization tables from codec data into our context */ static int get_quant(AVCodecContext *avctx, NuvContext *c, const uint8_t *buf, int size) { @@ -94,7 +94,7 @@ static int get_quant(AVCodecContext *avctx, NuvContext *c, } /** - * \brief set quantization tables from a quality value + * @brief set quantization tables from a quality value */ static void get_quant_quality(NuvContext *c, int quality) { int i; diff --git a/libavcodec/qcelpdata.h b/libavcodec/qcelpdata.h index df33e9158c..457e856fa3 100644 --- a/libavcodec/qcelpdata.h +++ b/libavcodec/qcelpdata.h @@ -74,9 +74,9 @@ typedef struct { static const float qcelp_hammsinc_table[4] = { -0.006822, 0.041249, -0.143459, 0.588863}; typedef struct { - uint8_t index; /*!< index into the QCELPContext structure */ - uint8_t bitpos; /*!< position of the lowest bit in the value's byte */ - uint8_t bitlen; /*!< number of bits to read */ + uint8_t index; /**< index into the QCELPContext structure */ + uint8_t bitpos; /**< position of the lowest bit in the value's byte */ + uint8_t bitlen; /**< number of bits to read */ } QCELPBitmap; #define QCELP_OF(variable, bit, len) {offsetof(QCELPFrame, variable), bit, len} diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c index 3095a2464d..5942a03072 100644 --- a/libavcodec/qcelpdec.c +++ b/libavcodec/qcelpdec.c @@ -46,7 +46,7 @@ typedef enum { - I_F_Q = -1, /*!< insufficient frame quality */ + I_F_Q = -1, /**< insufficient frame quality */ SILENCE, RATE_OCTAVE, RATE_QUARTER, @@ -58,12 +58,12 @@ typedef struct { GetBitContext gb; qcelp_packet_rate bitrate; - QCELPFrame frame; /*!< unpacked data frame */ + QCELPFrame frame; /**< unpacked data frame */ uint8_t erasure_count; - uint8_t octave_count; /*!< count the consecutive RATE_OCTAVE frames */ + uint8_t octave_count; /**< count the consecutive RATE_OCTAVE frames */ float prev_lspf[10]; - float predictor_lspf[10];/*!< LSP predictor for RATE_OCTAVE and I_F_Q */ + float predictor_lspf[10];/**< LSP predictor for RATE_OCTAVE and I_F_Q */ float pitch_synthesis_filter_mem[303]; float pitch_pre_filter_mem[303]; float rnd_fir_filter_mem[180]; diff --git a/libavcodec/rtjpeg.c b/libavcodec/rtjpeg.c index 616c40258a..8d1f28a436 100644 --- a/libavcodec/rtjpeg.c +++ b/libavcodec/rtjpeg.c @@ -33,12 +33,12 @@ if (n) {skip_bits(gb, n);} /** - * \brief read one block from stream - * \param gb contains stream data - * \param block where data is written to - * \param scan array containing the mapping stream address -> block position - * \param quant quantization factors - * \return 0 means the block is not coded, < 0 means an error occurred. + * @brief read one block from stream + * @param gb contains stream data + * @param block where data is written to + * @param scan array containing the mapping stream address -> block position + * @param quant quantization factors + * @return 0 means the block is not coded, < 0 means an error occurred. * * Note: GetBitContext is used to make the code simpler, since all data is * aligned this could be done faster in a different way, e.g. as it is done @@ -96,13 +96,13 @@ static inline int get_block(GetBitContext *gb, DCTELEM *block, const uint8_t *sc } /** - * \brief decode one rtjpeg YUV420 frame - * \param c context, must be initialized via rtjpeg_decode_init - * \param f AVFrame to place decoded frame into. If parts of the frame + * @brief decode one rtjpeg YUV420 frame + * @param c context, must be initialized via rtjpeg_decode_init + * @param f AVFrame to place decoded frame into. If parts of the frame * are not coded they are left unchanged, so consider initializing it - * \param buf buffer containing input data - * \param buf_size length of input data in bytes - * \return number of bytes consumed from the input buffer + * @param buf buffer containing input data + * @param buf_size length of input data in bytes + * @return number of bytes consumed from the input buffer */ int rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f, const uint8_t *buf, int buf_size) { @@ -143,15 +143,15 @@ int rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f, } /** - * \brief initialize an RTJpegContext, may be called multiple times - * \param c context to initialize - * \param dsp specifies the idct to use for decoding - * \param width width of image, will be rounded down to the nearest multiple + * @brief initialize an RTJpegContext, may be called multiple times + * @param c context to initialize + * @param dsp specifies the idct to use for decoding + * @param width width of image, will be rounded down to the nearest multiple * of 16 for decoding - * \param height height of image, will be rounded down to the nearest multiple + * @param height height of image, will be rounded down to the nearest multiple * of 16 for decoding - * \param lquant luma quantization table to use - * \param cquant chroma quantization table to use + * @param lquant luma quantization table to use + * @param cquant chroma quantization table to use */ void rtjpeg_decode_init(RTJpegContext *c, DSPContext *dsp, int width, int height, diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index ddf2635da0..f6c72fe716 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -56,7 +56,7 @@ void write_##type##_2d_array(const void *arg, int len, int len2)\ } /** - * \defgroup printfuncs Predefined functions for printing tables + * @defgroup printfuncs Predefined functions for printing tables * * \{ */ diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index 985f71c8ca..86c81a1b0f 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -411,7 +411,7 @@ static inline float mulawinv(float y, float clip, float mu) * a*b == 200 and the nearest integer is ill-defined, use a table to emulate * the following broken float-based implementation used by the binary decoder: * - * \code + * @code * static int very_broken_op(int a, int b) * { * static float test; // Ugh, force gcc to do the division first... @@ -419,7 +419,7 @@ static inline float mulawinv(float y, float clip, float mu) * test = a/400.; * return b * test + 0.5; * } - * \endcode + * @endcode * * @note if this function is replaced by just ROUNDED_DIV(a*b,400.), the stddev * between the original file (before encoding with Yamaha encoder) and the @@ -938,14 +938,14 @@ static void permutate_in_line(int16_t *tab, int num_vect, int num_blocks, /** * Interpret the input data as in the following table: * - * \verbatim + * @verbatim * * abcdefgh * ijklmnop * qrstuvw * x123456 * - * \endverbatim + * @endverbatim * * and transpose it, giving the output * aiqxbjr1cks2dlt3emu4fvn5gow6hp diff --git a/libavcodec/vaapi.c b/libavcodec/vaapi.c index cc2fec365c..d6b0298ee0 100644 --- a/libavcodec/vaapi.c +++ b/libavcodec/vaapi.c @@ -24,7 +24,7 @@ #include "vaapi_internal.h" /** - * \addtogroup VAAPI_Decoding + * @addtogroup VAAPI_Decoding * * @{ */ diff --git a/libavcodec/vaapi.h b/libavcodec/vaapi.h index 306e164b88..36fb386acf 100644 --- a/libavcodec/vaapi.h +++ b/libavcodec/vaapi.h @@ -27,8 +27,8 @@ #include /** - * \defgroup VAAPI_Decoding VA API Decoding - * \ingroup Decoder + * @defgroup VAAPI_Decoding VA API Decoding + * @ingroup Decoder * @{ */ diff --git a/libavcodec/vaapi_internal.h b/libavcodec/vaapi_internal.h index 3a14a2b969..38432e1bc0 100644 --- a/libavcodec/vaapi_internal.h +++ b/libavcodec/vaapi_internal.h @@ -30,7 +30,7 @@ #include "mpegvideo.h" /** - * \addtogroup VAAPI_Decoding + * @addtogroup VAAPI_Decoding * * @{ */ diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 5f8f09186e..98616e8da6 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -33,7 +33,7 @@ #include "vdpau_internal.h" /** - * \addtogroup VDPAU_Decoding + * @addtogroup VDPAU_Decoding * * @{ */ diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h index d06ba634fb..6f1386067b 100644 --- a/libavcodec/vdpau.h +++ b/libavcodec/vdpau.h @@ -25,7 +25,7 @@ #define AVCODEC_VDPAU_H /** - * \defgroup Decoder VDPAU Decoder and Renderer + * @defgroup Decoder VDPAU Decoder and Renderer * * VDPAU hardware acceleration has two modules * - VDPAU decoding @@ -38,25 +38,25 @@ * and rendering (API calls) are done as part of the VDPAU * presentation (vo_vdpau.c) module. * - * \defgroup VDPAU_Decoding VDPAU Decoding - * \ingroup Decoder + * @defgroup VDPAU_Decoding VDPAU Decoding + * @ingroup Decoder * @{ */ #include #include -/** \brief The videoSurface is used for rendering. */ +/** @brief The videoSurface is used for rendering. */ #define FF_VDPAU_STATE_USED_FOR_RENDER 1 /** - * \brief The videoSurface is needed for reference/prediction. + * @brief The videoSurface is needed for reference/prediction. * The codec manipulates this. */ #define FF_VDPAU_STATE_USED_FOR_REFERENCE 2 /** - * \brief This structure is used as a callback between the Libav + * @brief This structure is used as a callback between the Libav * decoder (vd_) and presentation (vo_) module. * This is used for defining a video frame containing surface, * picture parameter, bitstream information etc which are passed diff --git a/libavcodec/x86/idct_sse2_xvid.c b/libavcodec/x86/idct_sse2_xvid.c index 4b6885f4a2..968b400c6d 100644 --- a/libavcodec/x86/idct_sse2_xvid.c +++ b/libavcodec/x86/idct_sse2_xvid.c @@ -43,7 +43,7 @@ #include "idct_xvid.h" #include "dsputil_mmx.h" -/*! +/** * @file * @brief SSE2 idct compatible with xvidmmx */ diff --git a/libavcodec/x86/idct_xvid.h b/libavcodec/x86/idct_xvid.h index 1ff039d928..495d2caaf9 100644 --- a/libavcodec/x86/idct_xvid.h +++ b/libavcodec/x86/idct_xvid.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/*! +/** * @file * header for Xvid IDCT functions */ diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c index 87dc75c22d..0c7d07f09d 100644 --- a/libavcodec/xsubenc.c +++ b/libavcodec/xsubenc.c @@ -36,8 +36,8 @@ /** * Encode a single color run. At most 16 bits will be used. - * \param len length of the run, values > 255 mean "until end of line", may not be < 0. - * \param color color to encode, only the lowest two bits are used and all others must be 0. + * @param len length of the run, values > 255 mean "until end of line", may not be < 0. + * @param color color to encode, only the lowest two bits are used and all others must be 0. */ static void put_xsub_rle(PutBitContext *pb, int len, int color) { diff --git a/libavformat/asfcrypt.c b/libavformat/asfcrypt.c index 52cfc17d6c..aea3d4f345 100644 --- a/libavformat/asfcrypt.c +++ b/libavformat/asfcrypt.c @@ -28,9 +28,9 @@ #include "asfcrypt.h" /** - * \brief find multiplicative inverse modulo 2 ^ 32 - * \param v number to invert, must be odd! - * \return number so that result * v = 1 (mod 2^32) + * @brief find multiplicative inverse modulo 2 ^ 32 + * @param v number to invert, must be odd! + * @return number so that result * v = 1 (mod 2^32) */ static uint32_t inverse(uint32_t v) { // v ^ 3 gives the inverse (mod 16), could also be implemented @@ -45,9 +45,9 @@ static uint32_t inverse(uint32_t v) { } /** - * \brief read keys from keybuf into keys - * \param keybuf buffer containing the keys - * \param keys output key array containing the keys for encryption in + * @brief read keys from keybuf into keys + * @param keybuf buffer containing the keys + * @param keys output key array containing the keys for encryption in * native endianness */ static void multiswap_init(const uint8_t keybuf[48], uint32_t keys[12]) { @@ -57,9 +57,9 @@ static void multiswap_init(const uint8_t keybuf[48], uint32_t keys[12]) { } /** - * \brief invert the keys so that encryption become decryption keys and + * @brief invert the keys so that encryption become decryption keys and * the other way round. - * \param keys key array of ints to invert + * @param keys key array of ints to invert */ static void multiswap_invert_keys(uint32_t keys[12]) { int i; @@ -92,12 +92,12 @@ static uint32_t multiswap_inv_step(const uint32_t keys[12], uint32_t v) { } /** - * \brief "MultiSwap" encryption - * \param keys 32 bit numbers in machine endianness, + * @brief "MultiSwap" encryption + * @param keys 32 bit numbers in machine endianness, * 0-4 and 6-10 must be inverted from decryption - * \param key another key, this one must be the same for the decryption - * \param data data to encrypt - * \return encrypted data + * @param key another key, this one must be the same for the decryption + * @param data data to encrypt + * @return encrypted data */ static uint64_t multiswap_enc(const uint32_t keys[12], uint64_t key, uint64_t data) { uint32_t a = data; @@ -114,12 +114,12 @@ static uint64_t multiswap_enc(const uint32_t keys[12], uint64_t key, uint64_t da } /** - * \brief "MultiSwap" decryption - * \param keys 32 bit numbers in machine endianness, + * @brief "MultiSwap" decryption + * @param keys 32 bit numbers in machine endianness, * 0-4 and 6-10 must be inverted from encryption - * \param key another key, this one must be the same as for the encryption - * \param data data to decrypt - * \return decrypted data + * @param key another key, this one must be the same as for the encryption + * @param data data to decrypt + * @return decrypted data */ static uint64_t multiswap_dec(const uint32_t keys[12], uint64_t key, uint64_t data) { uint32_t a; diff --git a/libavformat/gxf.c b/libavformat/gxf.c index 74d925fe60..54fdadfc32 100644 --- a/libavformat/gxf.c +++ b/libavformat/gxf.c @@ -32,11 +32,11 @@ struct gxf_stream_info { }; /** - * \brief parses a packet header, extracting type and length - * \param pb AVIOContext to read header from - * \param type detected packet type is stored here - * \param length detected packet length, excluding header is stored here - * \return 0 if header not found or contains invalid data, 1 otherwise + * @brief parses a packet header, extracting type and length + * @param pb AVIOContext to read header from + * @param type detected packet type is stored here + * @param length detected packet length, excluding header is stored here + * @return 0 if header not found or contains invalid data, 1 otherwise */ static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length) { if (avio_rb32(pb)) @@ -58,7 +58,7 @@ static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length) { } /** - * \brief check if file starts with a PKT_MAP header + * @brief check if file starts with a PKT_MAP header */ static int gxf_probe(AVProbeData *p) { static const uint8_t startcode[] = {0, 0, 0, 0, 1, 0xbc}; // start with map packet @@ -70,10 +70,10 @@ static int gxf_probe(AVProbeData *p) { } /** - * \brief gets the stream index for the track with the specified id, creates new + * @brief gets the stream index for the track with the specified id, creates new * stream if not found - * \param id id of stream to find / add - * \param format stream format identifier + * @param id id of stream to find / add + * @param format stream format identifier */ static int get_sindex(AVFormatContext *s, int id, int format) { int i; @@ -153,9 +153,9 @@ static int get_sindex(AVFormatContext *s, int id, int format) { } /** - * \brief filters out interesting tags from material information. - * \param len length of tag section, will be adjusted to contain remaining bytes - * \param si struct to store collected information into + * @brief filters out interesting tags from material information. + * @param len length of tag section, will be adjusted to contain remaining bytes + * @param si struct to store collected information into */ static void gxf_material_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si) { si->first_field = AV_NOPTS_VALUE; @@ -179,9 +179,9 @@ static void gxf_material_tags(AVIOContext *pb, int *len, struct gxf_stream_info } /** - * \brief convert fps tag value to AVRational fps - * \param fps fps value from tag - * \return fps as AVRational, or 0 / 0 if unknown + * @brief convert fps tag value to AVRational fps + * @param fps fps value from tag + * @return fps as AVRational, or 0 / 0 if unknown */ static AVRational fps_tag2avr(int32_t fps) { extern const AVRational ff_frame_rate_tab[]; @@ -190,9 +190,9 @@ static AVRational fps_tag2avr(int32_t fps) { } /** - * \brief convert UMF attributes flags to AVRational fps - * \param flags UMF flags to convert - * \return fps as AVRational, or 0 / 0 if unknown + * @brief convert UMF attributes flags to AVRational fps + * @param flags UMF flags to convert + * @return fps as AVRational, or 0 / 0 if unknown */ static AVRational fps_umf2avr(uint32_t flags) { static const AVRational map[] = {{50, 1}, {60000, 1001}, {24, 1}, @@ -202,9 +202,9 @@ static AVRational fps_umf2avr(uint32_t flags) { } /** - * \brief filters out interesting tags from track information. - * \param len length of tag section, will be adjusted to contain remaining bytes - * \param si struct to store collected information into + * @brief filters out interesting tags from track information. + * @param len length of tag section, will be adjusted to contain remaining bytes + * @param si struct to store collected information into */ static void gxf_track_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si) { si->frames_per_second = (AVRational){0, 0}; @@ -228,7 +228,7 @@ static void gxf_track_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si } /** - * \brief read index from FLT packet into stream 0 av_index + * @brief read index from FLT packet into stream 0 av_index */ static void gxf_read_index(AVFormatContext *s, int pkt_len) { AVIOContext *pb = s->pb; @@ -374,11 +374,11 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { } /** - * \brief resync the stream on the next media packet with specified properties - * \param max_interval how many bytes to search for matching packet at most - * \param track track id the media packet must belong to, -1 for any - * \param timestamp minimum timestamp (== field number) the packet must have, -1 for any - * \return timestamp of packet found + * @brief resync the stream on the next media packet with specified properties + * @param max_interval how many bytes to search for matching packet at most + * @param track track id the media packet must belong to, -1 for any + * @param timestamp minimum timestamp (== field number) the packet must have, -1 for any + * @return timestamp of packet found */ static int64_t gxf_resync_media(AVFormatContext *s, uint64_t max_interval, int track, int timestamp) { uint32_t tmp; diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index e9b8b3513a..f2ae567789 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -221,11 +221,11 @@ static void add_pid_to_pmt(MpegTSContext *ts, unsigned int programid, unsigned i } /** - * \brief discard_pid() decides if the pid is to be discarded according + * @brief discard_pid() decides if the pid is to be discarded according * to caller's programs selection - * \param ts : - TS context - * \param pid : - pid - * \return 1 if the pid is only comprised in programs that have .discard=AVDISCARD_ALL + * @param ts : - TS context + * @param pid : - pid + * @return 1 if the pid is only comprised in programs that have .discard=AVDISCARD_ALL * 0 otherwise */ static int discard_pid(MpegTSContext *ts, unsigned int pid) diff --git a/libavformat/nuv.c b/libavformat/nuv.c index bf596109e8..4e1ee5702b 100644 --- a/libavformat/nuv.c +++ b/libavformat/nuv.c @@ -49,11 +49,11 @@ static int nuv_probe(AVProbeData *p) { #define PKTSIZE(s) (s & 0xffffff) /** - * \brief read until we found all data needed for decoding - * \param vst video stream of which to change parameters - * \param ast video stream of which to change parameters - * \param myth set if this is a MythTVVideo format file - * \return 1 if all required codec data was found + * @brief read until we found all data needed for decoding + * @param vst video stream of which to change parameters + * @param ast video stream of which to change parameters + * @param myth set if this is a MythTVVideo format file + * @return 1 if all required codec data was found */ static int get_codec_data(AVIOContext *pb, AVStream *vst, AVStream *ast, int myth) { diff --git a/libavutil/common.h b/libavutil/common.h index a985fa4804..9691f5bcf8 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -268,16 +268,16 @@ static av_always_inline av_const int av_popcount_c(uint32_t x) }\ }\ -/*! - * \def PUT_UTF8(val, tmp, PUT_BYTE) +/** + * @def PUT_UTF8(val, tmp, PUT_BYTE) * Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). - * \param val is an input-only argument and should be of type uint32_t. It holds + * @param val is an input-only argument and should be of type uint32_t. It holds * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If * val is given as a function it is executed only once. - * \param tmp is a temporary variable and should be of type uint8_t. It + * @param tmp is a temporary variable and should be of type uint8_t. It * represents an intermediate value during conversion that is to be * output by PUT_BYTE. - * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. + * @param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. * It could be a function or a statement, and uses tmp as the input byte. * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be * executed up to 4 times for values in the valid UTF-8 range and up to @@ -304,16 +304,16 @@ static av_always_inline av_const int av_popcount_c(uint32_t x) }\ } -/*! - * \def PUT_UTF16(val, tmp, PUT_16BIT) +/** + * @def PUT_UTF16(val, tmp, PUT_16BIT) * Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). - * \param val is an input-only argument and should be of type uint32_t. It holds + * @param val is an input-only argument and should be of type uint32_t. It holds * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If * val is given as a function it is executed only once. - * \param tmp is a temporary variable and should be of type uint16_t. It + * @param tmp is a temporary variable and should be of type uint16_t. It * represents an intermediate value during conversion that is to be * output by PUT_16BIT. - * \param PUT_16BIT writes the converted UTF-16 data to any proper destination + * @param PUT_16BIT writes the converted UTF-16 data to any proper destination * in desired endianness. It could be a function or a statement, and uses tmp * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" * PUT_BYTE will be executed 1 or 2 times depending on input character. diff --git a/libavutil/des.c b/libavutil/des.c index e8009a2ab9..a30ef3ba7c 100644 --- a/libavutil/des.c +++ b/libavutil/des.c @@ -240,7 +240,7 @@ static uint32_t f_func(uint32_t r, uint64_t k) { } /** - * \brief rotate the two halves of the expanded 56 bit key each 1 bit left + * @brief rotate the two halves of the expanded 56 bit key each 1 bit left * * Note: the specification calls this "shift", so I kept it although * it is confusing. diff --git a/libavutil/des.h b/libavutil/des.h index 5a6d4a12fb..935d7c5d71 100644 --- a/libavutil/des.h +++ b/libavutil/des.h @@ -30,22 +30,22 @@ struct AVDES { }; /** - * \brief Initializes an AVDES context. + * @brief Initializes an AVDES context. * - * \param key_bits must be 64 or 192 - * \param decrypt 0 for encryption, 1 for decryption + * @param key_bits must be 64 or 192 + * @param decrypt 0 for encryption, 1 for decryption */ int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt); /** - * \brief Encrypts / decrypts using the DES algorithm. + * @brief Encrypts / decrypts using the DES algorithm. * - * \param count number of 8 byte blocks - * \param dst destination array, can be equal to src, must be 8-byte aligned - * \param src source array, can be equal to dst, must be 8-byte aligned, may be NULL - * \param iv initialization vector for CBC mode, if NULL then ECB will be used, + * @param count number of 8 byte blocks + * @param dst destination array, can be equal to src, must be 8-byte aligned + * @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL + * @param iv initialization vector for CBC mode, if NULL then ECB will be used, * must be 8-byte aligned - * \param decrypt 0 for encryption, 1 for decryption + * @param decrypt 0 for encryption, 1 for decryption */ void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt); diff --git a/libavutil/lzo.c b/libavutil/lzo.c index ef01653aa8..743d596656 100644 --- a/libavutil/lzo.c +++ b/libavutil/lzo.c @@ -37,8 +37,8 @@ typedef struct LZOContext { } LZOContext; /** - * \brief Reads one byte from the input buffer, avoiding an overrun. - * \return byte read + * @brief Reads one byte from the input buffer, avoiding an overrun. + * @return byte read */ static inline int get_byte(LZOContext *c) { if (c->in < c->in_end) @@ -54,10 +54,10 @@ static inline int get_byte(LZOContext *c) { #endif /** - * \brief Decodes a length value in the coding used by lzo. - * \param x previous byte value - * \param mask bits used from x - * \return decoded length value + * @brief Decodes a length value in the coding used by lzo. + * @param x previous byte value + * @param mask bits used from x + * @return decoded length value */ static inline int get_len(LZOContext *c, int x, int mask) { int cnt = x & mask; @@ -82,8 +82,8 @@ static inline int get_len(LZOContext *c, int x, int mask) { #endif /** - * \brief Copies bytes from input to output buffer with checking. - * \param cnt number of bytes to copy, must be >= 0 + * @brief Copies bytes from input to output buffer with checking. + * @param cnt number of bytes to copy, must be >= 0 */ static inline void copy(LZOContext *c, int cnt) { register const uint8_t *src = c->in; @@ -111,9 +111,9 @@ static inline void copy(LZOContext *c, int cnt) { static inline void memcpy_backptr(uint8_t *dst, int back, int cnt); /** - * \brief Copies previously decoded bytes to current position. - * \param back how many bytes back we start - * \param cnt number of bytes to copy, must be >= 0 + * @brief Copies previously decoded bytes to current position. + * @param back how many bytes back we start + * @param cnt number of bytes to copy, must be >= 0 * * cnt > back is valid, this will copy the bytes we just copied, * thus creating a repeating pattern with a period length of back. diff --git a/libavutil/lzo.h b/libavutil/lzo.h index 01c9280a43..41ee6b1d67 100644 --- a/libavutil/lzo.h +++ b/libavutil/lzo.h @@ -24,7 +24,7 @@ #include -/** \defgroup errflags Error flags returned by av_lzo1x_decode +/** @defgroup errflags Error flags returned by av_lzo1x_decode * \{ */ //! end of the input buffer reached before decoding finished #define AV_LZO_INPUT_DEPLETED 1 @@ -40,12 +40,12 @@ #define AV_LZO_OUTPUT_PADDING 12 /** - * \brief Decodes LZO 1x compressed data. - * \param out output buffer - * \param outlen size of output buffer, number of bytes left are returned here - * \param in input buffer - * \param inlen size of input buffer, number of bytes left are returned here - * \return 0 on success, otherwise a combination of the error flags above + * @brief Decodes LZO 1x compressed data. + * @param out output buffer + * @param outlen size of output buffer, number of bytes left are returned here + * @param in input buffer + * @param inlen size of input buffer, number of bytes left are returned here + * @return 0 on success, otherwise a combination of the error flags above * * Make sure all buffers are appropriately padded, in must provide * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes. @@ -53,10 +53,10 @@ int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); /** - * \brief deliberately overlapping memcpy implementation - * \param dst destination buffer; must be padded with 12 additional bytes - * \param back how many bytes back we start (the initial size of the overlapping window) - * \param cnt number of bytes to copy, must be >= 0 + * @brief deliberately overlapping memcpy implementation + * @param dst destination buffer; must be padded with 12 additional bytes + * @param back how many bytes back we start (the initial size of the overlapping window) + * @param cnt number of bytes to copy, must be >= 0 * * cnt > back is valid, this will copy the bytes we just copied, * thus creating a repeating pattern with a period length of back. diff --git a/libavutil/rc4.h b/libavutil/rc4.h index dc5066d3fc..ec3b47cc8a 100644 --- a/libavutil/rc4.h +++ b/libavutil/rc4.h @@ -29,21 +29,21 @@ struct AVRC4 { }; /** - * \brief Initializes an AVRC4 context. + * @brief Initializes an AVRC4 context. * - * \param key_bits must be a multiple of 8 - * \param decrypt 0 for encryption, 1 for decryption, currently has no effect + * @param key_bits must be a multiple of 8 + * @param decrypt 0 for encryption, 1 for decryption, currently has no effect */ int av_rc4_init(struct AVRC4 *d, const uint8_t *key, int key_bits, int decrypt); /** - * \brief Encrypts / decrypts using the RC4 algorithm. + * @brief Encrypts / decrypts using the RC4 algorithm. * - * \param count number of bytes - * \param dst destination array, can be equal to src - * \param src source array, can be equal to dst, may be NULL - * \param iv not (yet) used for RC4, should be NULL - * \param decrypt 0 for encryption, 1 for decryption, not (yet) used + * @param count number of bytes + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst, may be NULL + * @param iv not (yet) used for RC4, should be NULL + * @param decrypt 0 for encryption, 1 for decryption, not (yet) used */ void av_rc4_crypt(struct AVRC4 *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt); From 2ec899222b3c90b3496a502175baac74cac1f564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Fri, 24 Jun 2011 09:02:57 +0200 Subject: [PATCH 053/780] Revert "build: move basic rules and variables to main Makefile" This reverts commit bb5249244ddb22df1cfb8dee1c369e6cd653d00d. This is necessary to allow running "make" in subdirs again. Conflicts: Makefile --- Makefile | 35 ----------------------------------- common.mak | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index 9eff02dbed..d3a56de712 100644 --- a/Makefile +++ b/Makefile @@ -7,41 +7,6 @@ vpath %.asm $(SRC_PATH) vpath %.v $(SRC_PATH) vpath %.texi $(SRC_PATH) -ifndef V -Q = @ -ECHO = printf "$(1)\t%s\n" $(2) -BRIEF = CC AS YASM AR LD HOSTCC STRIP CP -SILENT = DEPCC YASMDEP RM RANLIB -MSG = $@ -M = @$(call ECHO,$(TAG),$@); -$(foreach VAR,$(BRIEF), \ - $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR)))) -$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) -$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_PATH)/%=%)); $(INSTALL)) -endif - -IFLAGS := -I. -I$(SRC_PATH) -CPPFLAGS := $(IFLAGS) $(CPPFLAGS) -CFLAGS += $(ECFLAGS) -YASMFLAGS += $(IFLAGS) -Pconfig.asm -HOSTCFLAGS += $(IFLAGS) - -%.o: %.c - $(CCDEP) - $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $< - -%.o: %.S - $(ASDEP) - $(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $< - -%.ho: %.h - $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $< - -%.ver: %.v - $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@ - -%.c %.h: TAG = GEN - # Do not delete intermediate files from chains of implicit rules $(OBJS): diff --git a/common.mak b/common.mak index e2eaa399da..8d21d154d5 100644 --- a/common.mak +++ b/common.mak @@ -5,6 +5,46 @@ # first so "all" becomes default target all: all-yes +ifndef SUBDIR + +ifndef V +Q = @ +ECHO = printf "$(1)\t%s\n" $(2) +BRIEF = CC AS YASM AR LD HOSTCC +SILENT = DEPCC YASMDEP RM RANLIB +MSG = $@ +M = @$(call ECHO,$(TAG),$@); +$(foreach VAR,$(BRIEF), \ + $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR)))) +$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) +$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL)) +endif + +IFLAGS := -I. -I$(SRC_PATH) +CPPFLAGS := $(IFLAGS) $(CPPFLAGS) +CFLAGS += $(ECFLAGS) +YASMFLAGS += $(IFLAGS) -Pconfig.asm + +HOSTCFLAGS += $(IFLAGS) + +%.o: %.c + $(CCDEP) + $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $< + +%.o: %.S + $(ASDEP) + $(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $< + +%.ho: %.h + $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $< + +%.ver: %.v + $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@ + +%.c %.h: TAG = GEN + +endif + OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes) OBJS += $(OBJS-yes) From 95dd1741af2c0416b74135f6ccf40f4bab5583b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Fri, 24 Jun 2011 09:10:25 +0200 Subject: [PATCH 054/780] Allow running make in subdirs again. --- Makefile | 1 + common.mak | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Makefile b/Makefile index d3a56de712..966afc636b 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,7 @@ DATA_FILES := $(wildcard $(SRC_PATH)/ffpresets/*.ffpreset) SKIPHEADERS = cmdutils_common_opts.h +MAIN_MAKEFILE=1 include common.mak FF_LDFLAGS := $(FFLDFLAGS) diff --git a/common.mak b/common.mak index 8d21d154d5..7c03e48091 100644 --- a/common.mak +++ b/common.mak @@ -7,6 +7,12 @@ all: all-yes ifndef SUBDIR +ifndef MAIN_MAKEFILE +ifeq ($(SRC_PATH),.) +SRC_PATH = .. +endif +endif + ifndef V Q = @ ECHO = printf "$(1)\t%s\n" $(2) From 9fff623d0a95f44ef9ec8b5e752146b77869e5d3 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 23 Jun 2011 23:52:33 +0200 Subject: [PATCH 055/780] Changelog: merge various 0.7* sections into a single 0.8 section FFmpeg never had distinct alfa/beta 0.7 releases, so having a single 0.8 section with all the changes should be less confusing for the users, and it is also consistent with what we did with 0.5 and 0.6 releases. Also add a dedicated 0.7 section, explaining how it differs from 0.8. --- Changelog | 70 ++++++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/Changelog b/Changelog index 4362371aeb..4c2f2e3d1b 100644 --- a/Changelog +++ b/Changelog @@ -2,44 +2,9 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. -version 0.7: +version 0.8: - many many things we forgot because we rather write code than changelogs -- libmpcodecs video filter support (3 times as many filters than before) -- mpeg2 aspect ratio dection fixed -- libxvid aspect pickiness fixed -- Frame multithreaded decoding -- E-AC-3 audio encoder -- ac3enc: add channel coupling support -- floating-point sample format support to the ac3, eac3, dca, aac, and vorbis decoders. -- H264/MPEG frame-level multi-threading -- All av_metadata_* functions renamed to av_dict_* and moved to libavutil -- 4:4:4 H.264 decoding support -- 10-bit H.264 optimizations for x86 -- lut, lutrgb, and lutyuv filters added -- buffersink libavfilter sink added -- Bump libswscale for recently reported ABI break - - -version 0.7_beta2: - -- VP8 frame-multithreading -- NEON optimizations for VP8 -- Lots of deprecated API cruft removed -- fft and imdct optimizations for AVX (Sandy Bridge) processors -- showinfo filter added -- DPX image encoder -- SMPTE 302M AES3 audio decoder -- Apple Core Audio Format muxer -- 9bit and 10bit per sample support in the H.264 decoder -- 9bit and 10bit FFV1 encoding / decoding -- split filter added -- select filter added -- sdl output device added - - -version 0.7_beta1: - - WebM support in Matroska de/muxer - low overhead Ogg muxing - MMS-TCP support @@ -58,7 +23,7 @@ version 0.7_beta1: - RTP depacketization of QDM2 - ANSI/ASCII art playback system - Lego Mindstorms RSO de/muxer -- libavcore added +- libavcore added (and subsequently removed) - SubRip subtitle file muxer and demuxer - Chinese AVS encoding via libxavs - ffprobe -show_packets option added @@ -126,6 +91,37 @@ version 0.7_beta1: - AMR-WB encoding via libvo-amrwbenc - xWMA demuxer - Mobotix MxPEG decoder +- VP8 frame-multithreading +- NEON optimizations for VP8 +- Lots of deprecated API cruft removed +- fft and imdct optimizations for AVX (Sandy Bridge) processors +- showinfo filter added +- SMPTE 302M AES3 audio decoder +- Apple Core Audio Format muxer +- 9bit and 10bit per sample support in the H.264 decoder +- 9bit and 10bit FFV1 encoding / decoding +- split filter added +- select filter added +- sdl output device added +- libmpcodecs video filter support (3 times as many filters than before) +- mpeg2 aspect ratio dection fixed +- libxvid aspect pickiness fixed +- Frame multithreaded decoding +- E-AC-3 audio encoder +- ac3enc: add channel coupling support +- floating-point sample format support to the ac3, eac3, dca, aac, and vorbis decoders. +- H264/MPEG frame-level multi-threading +- All av_metadata_* functions renamed to av_dict_* and moved to libavutil +- 4:4:4 H.264 decoding support +- 10-bit H.264 optimizations for x86 +- lut, lutrgb, and lutyuv filters added +- buffersink libavfilter sink added +- Bump libswscale for recently reported ABI break + + +version 0.7: + +- all the changes for 0.8, but keeping API/ABI compatibility with the 0.6 release version 0.6: From 470ac1437d8efbb619b72b75be0e71fe98915be4 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 24 Jun 2011 00:06:56 +0200 Subject: [PATCH 056/780] MAINTAINERS: add a "Releases" section The new section documents the maintainership status for the various FFmpeg releases, on a best effort basis. --- MAINTAINERS | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 8588ba73ad..e5ba8d2fac 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -362,6 +362,16 @@ Sparc Roman Shaposhnik x86 Michael Niedermayer +Releases +======== + +0.5 *Deprecated/Unmaintained* +0.6 Stefano Sabatini +0.7 Michael Niedermayer +0.8 Michael Niedermayer + + + GnuPG Fingerprints of maintainers and others who have svn write access ====================================================================== From 978e711b2cacf6d9515f7c5e32e76a4013aec0d2 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 23 Jun 2011 01:36:29 +0200 Subject: [PATCH 057/780] general.texi: remove reference to --enable-memalign-hack, no longer required --- doc/general.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index b6392d76e3..8104fb7477 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -961,7 +961,7 @@ MSVC++-compatible import libraries. @item Build FFmpeg with @example -./configure --enable-shared --enable-memalign-hack +./configure --enable-shared make make install @end example @@ -1083,12 +1083,12 @@ and add some special flags to your configure invocation. For a static build run @example -./configure --target-os=mingw32 --enable-memalign-hack --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin +./configure --target-os=mingw32 --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin @end example and for a build with shared libraries @example -./configure --target-os=mingw32 --enable-memalign-hack --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin +./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin @end example @bye From f925b243818fa320b3c19e4e0554a07b49e8a2be Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 24 Jun 2011 11:56:19 +0200 Subject: [PATCH 058/780] general.texi: clarify with examples what "the FFmpeg libraries" means --- doc/general.texi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/general.texi b/doc/general.texi index 8104fb7477..8e3d4af706 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -854,7 +854,8 @@ where SDL was installed. Verify that @file{sdl-config} can be launched from the MSYS command line. @item By using @code{./configure --enable-shared} when configuring FFmpeg, -you can build the FFmpeg libraries as DLLs. +you can build the FFmpeg libraries (e.g. libavutil, libavcodec, +libavformat) as DLLs. @end itemize From fc66e231541b91b22f6e0d8257991cc5343db8d5 Mon Sep 17 00:00:00 2001 From: Can Wu Date: Fri, 17 Jun 2011 13:58:01 +0800 Subject: [PATCH 059/780] udp: Receive on the remote port number, if no local port is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For a unicast udp stream to localhost:1234, currently ffplay udp://:1234?localport=1234 works, but ffplay udp://:1234 doesn't work. Signed-off-by: Martin Storsjö --- libavformat/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index d6522bf0be..724ff0197d 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -365,7 +365,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) goto fail; } - if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) + if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ)) s->local_port = port; udp_fd = udp_socket_create(s, &my_addr, &len); if (udp_fd < 0) From f6d28cf02965e74ff2f772d8632b018375a6c346 Mon Sep 17 00:00:00 2001 From: Jeff Downs Date: Thu, 23 Jun 2011 14:12:37 -0400 Subject: [PATCH 060/780] parse_options(): Avoid passing NULL as a string arg to fprintf --- cmdutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmdutils.c b/cmdutils.c index cd6d13346d..f538d98f14 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -281,7 +281,7 @@ unknown_opt: *po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); } else if (po->u.func_arg) { if (po->u.func_arg(opt, arg) < 0) { - fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt); + fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg ? arg : "[null]", opt); exit(1); } } From 5aa8b270db2b88f136ef518b4bdf2b5dfff4a77b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Fri, 24 Jun 2011 19:51:16 +0200 Subject: [PATCH 061/780] Restore accidentally removed parts of "BRIEF" list. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Reimar Döffinger --- common.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mak b/common.mak index 7c03e48091..98ec53e611 100644 --- a/common.mak +++ b/common.mak @@ -16,7 +16,7 @@ endif ifndef V Q = @ ECHO = printf "$(1)\t%s\n" $(2) -BRIEF = CC AS YASM AR LD HOSTCC +BRIEF = CC AS YASM AR LD HOSTCC STRIP CP SILENT = DEPCC YASMDEP RM RANLIB MSG = $@ M = @$(call ECHO,$(TAG),$@); From b36518dcf457f5655c75c978bffed08dcd9535d6 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 24 Jun 2011 21:16:10 +0200 Subject: [PATCH 062/780] configure: Add -Wno-format-zero-length to CFLAGS. The C standard specifies that zero-length format strings are allowed. --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index f557482c18..e20bb064a4 100755 --- a/configure +++ b/configure @@ -2978,6 +2978,7 @@ check_cflags -Wdeclaration-after-statement check_cflags -Wall check_cflags -Wno-parentheses check_cflags -Wno-switch +check_cflags -Wno-format-zero-length check_cflags -Wdisabled-optimization check_cflags -Wpointer-arith check_cflags -Wredundant-decls From e65d6e22e300e286bcc27443df8449aaf9d062dd Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 24 Jun 2011 23:45:15 +0200 Subject: [PATCH 063/780] configure: select buffersink_filter when ffmpeg is enabled buffersink_filter is a strong requirement for compiling ffmpeg. Fixes ffmpeg compilation with --disable-everything. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 7d4cd1417a..e285e16545 100755 --- a/configure +++ b/configure @@ -1515,7 +1515,7 @@ postproc_deps="gpl" # programs ffmpeg_deps="avcodec avformat swscale" -ffmpeg_select="buffer_filter" +ffmpeg_select="buffer_filter buffersink_filter" ffplay_deps="avcodec avformat swscale sdl" ffplay_select="rdft" ffprobe_deps="avcodec avformat" From 392aa6e444f13aaddcf3d215b1058640a2ada846 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Fri, 24 Jun 2011 12:02:41 +0200 Subject: [PATCH 064/780] ogg_read_packet: forward error code. --- libavformat/oggdec.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 655da35dd4..08de280c0e 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -550,15 +550,16 @@ static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt) { struct ogg *ogg; struct ogg_stream *os; - int idx = -1; + int idx = -1, ret; int pstart, psize; int64_t fpos, pts, dts; //Get an ogg packet retry: do{ - if (ogg_packet (s, &idx, &pstart, &psize, &fpos) < 0) - return AVERROR(EIO); + ret = ogg_packet (s, &idx, &pstart, &psize, &fpos); + if (ret < 0) + return ret; }while (idx < 0 || !s->streams[idx]); ogg = s->priv_data; @@ -572,8 +573,9 @@ retry: os->keyframe_seek = 0; //Alloc a pkt - if (av_new_packet (pkt, psize) < 0) - return AVERROR(EIO); + ret = av_new_packet (pkt, psize); + if (ret < 0) + return ret; pkt->stream_index = idx; memcpy (pkt->data, os->buf + pstart, psize); From 3a0d0ff5e60a8245f672fedd2aa49fa937aa875a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 24 Jun 2011 10:49:59 +0200 Subject: [PATCH 065/780] aacenc: Mark psy_3gpp_window() as av_unused. It is intentionally left in to allow adding 3GPP-style windowing in the future. Marking it av_unused silences an annoying unused function warning. --- libavcodec/aacpsy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index 5aea1faa40..cf8f7eb914 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -377,9 +377,10 @@ static const uint8_t window_grouping[9] = { * Tell encoder which window types to use. * @see 3GPP TS26.403 5.4.1 "Blockswitching" */ -static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, - const int16_t *audio, const int16_t *la, - int channel, int prev_type) +static av_unused FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, + const int16_t *audio, + const int16_t *la, + int channel, int prev_type) { int i, j; int br = ctx->avctx->bit_rate / ctx->avctx->channels; From a6213f3dce4006e0d47bd938e15832987d95efef Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 25 Jun 2011 00:19:39 +0200 Subject: [PATCH 066/780] build: Remove redundant config.mak includes from subdirectory Makefiles. Calling Make from subdirectories is not supported and config.mak has multiple inclusion guards anyway, so the top-level include is enough. --- libavcodec/Makefile | 2 -- libavdevice/Makefile | 2 -- libavfilter/Makefile | 2 -- libavformat/Makefile | 2 -- libavutil/Makefile | 2 -- libpostproc/Makefile | 2 -- libswscale/Makefile | 2 -- 7 files changed, 14 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 0cfa08c1c3..64a286289d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1,5 +1,3 @@ -include $(SUBDIR)../config.mak - NAME = avcodec FFLIBS = avutil diff --git a/libavdevice/Makefile b/libavdevice/Makefile index 5cfc5e8ecc..cbe20d6d57 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -1,5 +1,3 @@ -include $(SUBDIR)../config.mak - NAME = avdevice FFLIBS = avformat avcodec avutil diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 2ed1f937a3..e22527ae49 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -1,5 +1,3 @@ -include $(SUBDIR)../config.mak - NAME = avfilter FFLIBS = avutil FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec diff --git a/libavformat/Makefile b/libavformat/Makefile index c2fa8af466..5041fe0dc9 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -1,5 +1,3 @@ -include $(SUBDIR)../config.mak - NAME = avformat FFLIBS = avcodec avutil diff --git a/libavutil/Makefile b/libavutil/Makefile index 0d8f01dd8d..304b288851 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -1,5 +1,3 @@ -include $(SUBDIR)../config.mak - NAME = avutil HEADERS = adler32.h \ diff --git a/libpostproc/Makefile b/libpostproc/Makefile index bd0b71e3d4..7b359709dc 100644 --- a/libpostproc/Makefile +++ b/libpostproc/Makefile @@ -1,5 +1,3 @@ -include $(SUBDIR)../config.mak - NAME = postproc FFLIBS = avutil diff --git a/libswscale/Makefile b/libswscale/Makefile index 8bb06baae2..b2914113c0 100644 --- a/libswscale/Makefile +++ b/libswscale/Makefile @@ -1,5 +1,3 @@ -include $(SUBDIR)../config.mak - NAME = swscale FFLIBS = avutil From 89b5829d0a4d9510efeff65dbeeaed50e0980120 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 25 Jun 2011 00:32:12 +0200 Subject: [PATCH 067/780] build: Remove multiple inclusion guards from config.mak. config.mak is no longer included multiple times; the guards are pointless. --- configure | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure b/configure index e20bb064a4..41e1a4d2a5 100755 --- a/configure +++ b/configure @@ -3248,8 +3248,6 @@ config_files="$TMPH config.mak" cat > config.mak <> $TMPH -echo "endif # LIBAV_CONFIG_MAK" >> config.mak # Do not overwrite an unchanged config.h to avoid superfluous rebuilds. cp_if_changed $TMPH config.h From 729f953fb5079ca09bbac391b824be454df029d6 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 25 Jun 2011 02:01:12 +0200 Subject: [PATCH 068/780] build: Add DEP_LIBS dependency directly to the shared library build rule. The dependency was added conditional to a variable that is always defined, so it is safe to add it directly. --- subdir.mak | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/subdir.mak b/subdir.mak index 63398608d7..e4d7377fcb 100644 --- a/subdir.mak +++ b/subdir.mak @@ -39,15 +39,11 @@ $(SUBDIR)%$(EXESUF): $(SUBDIR)%.o $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR) $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME) -$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver +$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(DEP_LIBS) $(SLIB_CREATE_DEF_CMD) $$(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS) $(SLIB_EXTRA_CMD) -ifdef SUBDIR -$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS) -endif - clean:: $(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \ $(foreach dir,$(DIRS),$(CLEANSUFFIXES:%=$(SUBDIR)$(dir)/%)) \ From c713620b4c261e35522fc49394bc9ab5cc4ca27a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 25 Jun 2011 14:09:40 +0200 Subject: [PATCH 069/780] ffplay: Remove unused-but-set channels variable from update_sample_display(). --- ffplay.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ffplay.c b/ffplay.c index ffd4c230b8..43cd50c5eb 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1895,9 +1895,7 @@ static int subtitle_thread(void *arg) /* copy samples for viewing in editor window */ static void update_sample_display(VideoState *is, short *samples, int samples_size) { - int size, len, channels; - - channels = is->audio_st->codec->channels; + int size, len; size = samples_size / sizeof(short); while (size > 0) { From fe343286ec5564606f29aa94848bc5dc3b2b3709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Fri, 24 Jun 2011 19:53:28 +0200 Subject: [PATCH 070/780] Restore some more rules to common.mak to improve building in subdirs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Reimar Döffinger --- Makefile | 11 ----------- common.mak | 10 ++++++++++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 966afc636b..8b3a51fb6f 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,6 @@ vpath %.asm $(SRC_PATH) vpath %.v $(SRC_PATH) vpath %.texi $(SRC_PATH) -# Do not delete intermediate files from chains of implicit rules -$(OBJS): - PROGS-$(CONFIG_FFMPEG) += ffmpeg PROGS-$(CONFIG_FFPLAY) += ffplay PROGS-$(CONFIG_FFPROBE) += ffprobe @@ -153,13 +150,5 @@ check: test include doc/Makefile include tests/Makefile -# Dummy rule to stop make trying to rebuild removed or renamed headers -%.h: - @: - -# Disable suffix rules. Most of the builtin rules are suffix rules, -# so this saves some time on slow systems. -.SUFFIXES: - .PHONY: all alltools *clean check config examples install* .PHONY: testprogs uninstall* diff --git a/common.mak b/common.mak index 98ec53e611..9a59f77fdd 100644 --- a/common.mak +++ b/common.mak @@ -49,6 +49,16 @@ HOSTCFLAGS += $(IFLAGS) %.c %.h: TAG = GEN +# Dummy rule to stop make trying to rebuild removed or renamed headers +%.h: + @: + +# Disable suffix rules. Most of the builtin rules are suffix rules, +# so this saves some time on slow systems. +.SUFFIXES: + +# Do not delete intermediate files from chains of implicit rules +$(OBJS): endif OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes) From c5cf0f7a76e80996bd6d2786408cd24bbef605de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Fri, 24 Jun 2011 10:04:22 +0200 Subject: [PATCH 071/780] Fix compilation in subdir with NASM. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Reimar Döffinger --- common.mak | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common.mak b/common.mak index 9a59f77fdd..66bbed4a40 100644 --- a/common.mak +++ b/common.mak @@ -26,7 +26,8 @@ $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL)) endif -IFLAGS := -I. -I$(SRC_PATH) +# NASM requires -I path terminated with / +IFLAGS := -I. -I$(SRC_PATH)/ CPPFLAGS := $(IFLAGS) $(CPPFLAGS) CFLAGS += $(ECFLAGS) YASMFLAGS += $(IFLAGS) -Pconfig.asm From d0ce090ec553c88eb8e9c303156017417d4599cc Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 25 Jun 2011 18:51:00 +0100 Subject: [PATCH 072/780] ARM: silence some annoying armcc warnings This silences warnings about pointer target sign mismatches as already done for gcc with -Wno-pointer-sign. Signed-off-by: Mans Rullgard --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index 41e1a4d2a5..70317178ad 100755 --- a/configure +++ b/configure @@ -3065,6 +3065,8 @@ elif enabled armcc; then add_cflags -W${armcc_opt},--diag_suppress=1207 add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat + add_cflags -W${armcc_opt},--diag_suppress=167 # pointer sign + add_cflags -W${armcc_opt},--diag_suppress=513 # pointer sign elif enabled tms470; then add_cflags -pds=824 -pds=837 elif enabled pathscale; then From d7686b3e0f590e793cd0b2986015019023dc22c2 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 25 Jun 2011 21:49:45 +0200 Subject: [PATCH 073/780] configure: select buffersink_filter when ffplay is enabled buffersink_filter is a strong requirement for compiling ffplay. Fixes ffplay compilation with --disable-everything --disable-ffmpeg. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 81f056f695..384da2b83b 100755 --- a/configure +++ b/configure @@ -1517,7 +1517,7 @@ postproc_deps="gpl" ffmpeg_deps="avcodec avformat swscale" ffmpeg_select="buffer_filter buffersink_filter" ffplay_deps="avcodec avformat swscale sdl" -ffplay_select="rdft" +ffplay_select="buffersink_filter rdft" ffprobe_deps="avcodec avformat" ffserver_deps="avformat ffm_muxer fork rtp_protocol rtsp_demuxer" ffserver_extralibs='$ldl' From 5aca97e2471f0a64c93789a912d4284726bea47b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 25 Jun 2011 21:53:21 +0200 Subject: [PATCH 074/780] vsink_buffer: add missing description --- libavfilter/vsink_buffer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/vsink_buffer.c b/libavfilter/vsink_buffer.c index b5627b4f82..f8140b5e5a 100644 --- a/libavfilter/vsink_buffer.c +++ b/libavfilter/vsink_buffer.c @@ -96,6 +96,7 @@ int av_vsink_buffer_get_video_buffer_ref(AVFilterContext *ctx, AVFilter avfilter_vsink_buffersink = { .name = "buffersink", + .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."), .priv_size = sizeof(BufferSinkContext), .init = init, .uninit = uninit, From 5fba761f6e3ff1e3d27fdefe257a9bb31d2cc7ea Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 25 Jun 2011 21:54:58 +0200 Subject: [PATCH 075/780] samplefmt: remove deprecated use of av_get_bits_per_sample_fmt() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use av_get_bytes_per_sample() instead. Fix deprecation warning: samplefmt.c: In function ‘av_samples_fill_arrays’: samplefmt.c:88: warning: ‘av_get_bits_per_sample_fmt’ is deprecated (declared at samplefmt.c:76) --- libavutil/samplefmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c index 2df06a619e..6f7070e43c 100644 --- a/libavutil/samplefmt.c +++ b/libavutil/samplefmt.c @@ -85,7 +85,7 @@ int av_samples_fill_arrays(uint8_t *pointers[8], int linesizes[8], enum AVSampleFormat sample_fmt, int planar, int align) { int i, linesize; - int sample_size = av_get_bits_per_sample_fmt(sample_fmt) >> 3; + int sample_size = av_get_bytes_per_sample(sample_fmt); if (nb_channels * (uint64_t)nb_samples * sample_size >= INT_MAX - align*(uint64_t)nb_channels) return AVERROR(EINVAL); From b3ca11f07feb08738128f6b7127ccf8eb3f72ede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 26 Jun 2011 09:42:42 +0200 Subject: [PATCH 076/780] Revert "build: Add DEP_LIBS dependency directly to the shared library build rule." This reverts commit 729f953fb5079ca09bbac391b824be454df029d6. --- subdir.mak | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/subdir.mak b/subdir.mak index f8473da596..8b3807378f 100644 --- a/subdir.mak +++ b/subdir.mak @@ -39,11 +39,15 @@ $(SUBDIR)%$(EXESUF): $(SUBDIR)%.o $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR) $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME) -$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(DEP_LIBS) +$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(SLIB_CREATE_DEF_CMD) $$(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS) $(SLIB_EXTRA_CMD) +ifdef SUBDIR +$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS) +endif + clean:: $(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \ $(foreach dir,$(DIRS),$(CLEANSUFFIXES:%=$(SUBDIR)$(dir)/%)) \ From 11096804340ac2cec37ef1bce828105bd0a7dfbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 26 Jun 2011 09:46:05 +0200 Subject: [PATCH 077/780] Revert "build: Remove redundant config.mak includes from subdirectory Makefiles." This reverts commit a6213f3dce4006e0d47bd938e15832987d95efef. --- libavcodec/Makefile | 2 ++ libavdevice/Makefile | 2 ++ libavfilter/Makefile | 2 ++ libavformat/Makefile | 2 ++ libavutil/Makefile | 2 ++ libpostproc/Makefile | 2 ++ libswscale/Makefile | 2 ++ 7 files changed, 14 insertions(+) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index deff279627..b6103af3c0 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1,3 +1,5 @@ +include $(SUBDIR)../config.mak + NAME = avcodec FFLIBS = avutil diff --git a/libavdevice/Makefile b/libavdevice/Makefile index 63153bb18b..60103a4864 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -1,3 +1,5 @@ +include $(SUBDIR)../config.mak + NAME = avdevice FFLIBS = avformat avcodec avutil diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 93f852d9d8..461df37a10 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -1,3 +1,5 @@ +include $(SUBDIR)../config.mak + NAME = avfilter FFLIBS = avutil FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec diff --git a/libavformat/Makefile b/libavformat/Makefile index d11cd7eca7..e5ec44bfb6 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -1,3 +1,5 @@ +include $(SUBDIR)../config.mak + NAME = avformat FFLIBS = avcodec avutil diff --git a/libavutil/Makefile b/libavutil/Makefile index 304b288851..0d8f01dd8d 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -1,3 +1,5 @@ +include $(SUBDIR)../config.mak + NAME = avutil HEADERS = adler32.h \ diff --git a/libpostproc/Makefile b/libpostproc/Makefile index 7b359709dc..bd0b71e3d4 100644 --- a/libpostproc/Makefile +++ b/libpostproc/Makefile @@ -1,3 +1,5 @@ +include $(SUBDIR)../config.mak + NAME = postproc FFLIBS = avutil diff --git a/libswscale/Makefile b/libswscale/Makefile index b2914113c0..8bb06baae2 100644 --- a/libswscale/Makefile +++ b/libswscale/Makefile @@ -1,3 +1,5 @@ +include $(SUBDIR)../config.mak + NAME = swscale FFLIBS = avutil From ebc64dc81881bd514144b9ddf6ee08c1bc116574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 26 Jun 2011 09:44:31 +0200 Subject: [PATCH 078/780] Revert "build: Remove multiple inclusion guards from config.mak." This reverts commit 89b5829d0a4d9510efeff65dbeeaed50e0980120. Conflicts: configure --- configure | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure b/configure index 65a8884d11..af3c09f7c5 100755 --- a/configure +++ b/configure @@ -3319,6 +3319,8 @@ config_files="$TMPH config.mak" cat > config.mak <> $TMPH +echo "endif # FFMPEG_CONFIG_MAK" >> config.mak # Do not overwrite an unchanged config.h to avoid superfluous rebuilds. cp_if_changed $TMPH config.h From 5c13b5bb398c12361732b7b47c71954484f5af1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 26 Jun 2011 13:29:17 +0200 Subject: [PATCH 079/780] Add operand size to add instructions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In these cases it can't be guessed from the operands (at least not necessarily), and it seems some clang versions refuse to compiler it. Fixes ticket #303. Signed-off-by: Reimar Döffinger --- libavcodec/x86/snowdsp_mmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/x86/snowdsp_mmx.c b/libavcodec/x86/snowdsp_mmx.c index 9c1fa429a8..f107d55e87 100644 --- a/libavcodec/x86/snowdsp_mmx.c +++ b/libavcodec/x86/snowdsp_mmx.c @@ -675,14 +675,14 @@ static void ff_snow_vertical_compose97i_mmx(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM #define snow_inner_add_yblock_sse2_end_8\ "sal $1, %%"REG_c" \n\t"\ - "add $"PTR_SIZE"*2, %1 \n\t"\ + "add"OPSIZE" $"PTR_SIZE"*2, %1 \n\t"\ snow_inner_add_yblock_sse2_end_common1\ "sar $1, %%"REG_c" \n\t"\ "sub $2, %2 \n\t"\ snow_inner_add_yblock_sse2_end_common2 #define snow_inner_add_yblock_sse2_end_16\ - "add $"PTR_SIZE"*1, %1 \n\t"\ + "add"OPSIZE" $"PTR_SIZE"*1, %1 \n\t"\ snow_inner_add_yblock_sse2_end_common1\ "dec %2 \n\t"\ snow_inner_add_yblock_sse2_end_common2 From f3876ea4850dcb52c200cf7b8955dc6790626829 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 15 Jun 2011 00:30:03 +0200 Subject: [PATCH 080/780] Move some variable declarations below the proper #ifdefs. This avoids warnings about set-but-unused variables. --- ffplay.c | 4 ++-- libavcodec/fft-test.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ffplay.c b/ffplay.c index 43cd50c5eb..73b30c400b 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1313,9 +1313,10 @@ static void alloc_picture(void *opaque) static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t pos) { VideoPicture *vp; - int dst_pix_fmt; #if CONFIG_AVFILTER AVPicture pict_src; +#else + int dst_pix_fmt = PIX_FMT_YUV420P; #endif /* wait until we have space to put a new picture */ SDL_LockMutex(is->pictq_mutex); @@ -1376,7 +1377,6 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t /* get a pointer on the bitmap */ SDL_LockYUVOverlay (vp->bmp); - dst_pix_fmt = PIX_FMT_YUV420P; memset(&pict,0,sizeof(AVPicture)); pict.data[0] = vp->bmp->pixels[0]; pict.data[1] = vp->bmp->pixels[2]; diff --git a/libavcodec/fft-test.c b/libavcodec/fft-test.c index 0112c6fcbb..59a53ddeb6 100644 --- a/libavcodec/fft-test.c +++ b/libavcodec/fft-test.c @@ -252,8 +252,9 @@ int main(int argc, char **argv) #if CONFIG_FFT_FLOAT RDFTContext r1, *r = &r1; DCTContext d1, *d = &d1; + int fft_size_2; #endif - int fft_nbits, fft_size, fft_size_2; + int fft_nbits, fft_size; double scale = 1.0; AVLFG prng; av_lfg_init(&prng, 1); @@ -292,7 +293,6 @@ int main(int argc, char **argv) } fft_size = 1 << fft_nbits; - fft_size_2 = fft_size >> 1; tab = av_malloc(fft_size * sizeof(FFTComplex)); tab1 = av_malloc(fft_size * sizeof(FFTComplex)); tab_ref = av_malloc(fft_size * sizeof(FFTComplex)); @@ -372,6 +372,7 @@ int main(int argc, char **argv) break; #if CONFIG_FFT_FLOAT case TRANSFORM_RDFT: + fft_size_2 = fft_size >> 1; if (do_inverse) { tab1[ 0].im = 0; tab1[fft_size_2].im = 0; From 9ddf1b1ae4d654008501726f98a244627b8765a0 Mon Sep 17 00:00:00 2001 From: Alexis Ballier Date: Wed, 22 Jun 2011 22:25:14 +0200 Subject: [PATCH 081/780] configure: allow post-fixed cpu strings for athlon64, k8, and opteron when setting the -march flag. This is to match gcc's {athlon64,k8,opteron}-sse3 -march flags. Signed-off-by: Justin Ruggles --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 70317178ad..db3277f262 100755 --- a/configure +++ b/configure @@ -2233,7 +2233,7 @@ elif enabled x86; then disable cmov ;; # targets that do support conditional mov (cmov) - i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10|barcelona|atom) + i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|amdfam10|barcelona|atom) cpuflags="-march=$cpu" enable cmov enable fast_cmov From 2f222b95506349f78c0124eb72489dc61d2c6218 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 18 Jun 2011 03:11:16 +0200 Subject: [PATCH 082/780] lavfi: add testsrc source --- doc/filters.texi | 43 +++++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/avfilter.h | 2 +- libavfilter/vsrc_testsrc.c | 338 +++++++++++++++++++++++++++++++++++++ 5 files changed, 384 insertions(+), 1 deletion(-) create mode 100644 libavfilter/vsrc_testsrc.c diff --git a/doc/filters.texi b/doc/filters.texi index eb31714486..b4ffcd9a04 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1970,6 +1970,49 @@ Some examples follow: frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay @end example +@section testsrc + +Generate a test video pattern, showing a color pattern, a scrolling +gradient and a timestamp. This is mainly intended for testing +purposes. + +It accepts an optional sequence of @var{key}=@var{value} pairs, +separated by ":". The description of the accepted options follows. + +@table @option + +@item size, s +Specify the size of the sourced video, it may be a string of the form +@var{width}x@var{heigth}, or the name of a size abbreviation. The +default value is "320x240". + +@item rate, r +Specify the frame rate of the sourced video, as the number of frames +generated per second. It has to be a string in the format +@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float +number or a valid video frame rate abbreviation. The default value is +"25". + +@item duration +Set the video duration of the sourced video. The accepted syntax is: +@example +[-]HH[:MM[:SS[.m...]]] +[-]S+[.m...] +@end example +See also the function @code{av_parse_time()}. + +If not specified, or the expressed duration is negative, the video is +supposed to be generated forever. +@end table + +For example the following: +@example +testsrc=duration=5.3:size=qcif:rate=10 +@end example + +will generate a video with a duration of 5.3 seconds, with size +176x144 and a framerate of 10 frames per second. + @c man end VIDEO SOURCES @chapter Video Sinks diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 461df37a10..d2e59f9049 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -68,6 +68,7 @@ OBJS-$(CONFIG_COLOR_FILTER) += vsrc_color.o OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o OBJS-$(CONFIG_MOVIE_FILTER) += vsrc_movie.o OBJS-$(CONFIG_NULLSRC_FILTER) += vsrc_nullsrc.o +OBJS-$(CONFIG_TESTSRC_FILTER) += vsrc_testsrc.o OBJS-$(CONFIG_BUFFERSINK_FILTER) += vsink_buffer.o OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 42047ecbe8..feae239626 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -84,6 +84,7 @@ void avfilter_register_all(void) REGISTER_FILTER (FREI0R, frei0r_src, vsrc); REGISTER_FILTER (MOVIE, movie, vsrc); REGISTER_FILTER (NULLSRC, nullsrc, vsrc); + REGISTER_FILTER (TESTSRC, testsrc, vsrc); REGISTER_FILTER (BUFFER, buffersink, vsink); REGISTER_FILTER (NULLSINK, nullsink, vsink); diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index c276f3037e..5d25c72289 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -26,7 +26,7 @@ #include "libavutil/samplefmt.h" #define LIBAVFILTER_VERSION_MAJOR 2 -#define LIBAVFILTER_VERSION_MINOR 23 +#define LIBAVFILTER_VERSION_MINOR 24 #define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c new file mode 100644 index 0000000000..6f2c3cf166 --- /dev/null +++ b/libavfilter/vsrc_testsrc.c @@ -0,0 +1,338 @@ +/* + * Copyright (c) 2007 Nicolas George + * Copyright (c) 2011 Stefano Sabatini + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Based on the test pattern generator demuxer by Nicolas George: + * http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2007-October/037845.html + */ + +#include + +#include "libavutil/opt.h" +#include "libavutil/parseutils.h" +#include "avfilter.h" + +typedef struct { + const AVClass *class; + int h, w; + unsigned int nb_frame; + AVRational time_base; + int64_t pts, max_pts; + char *size; ///< video frame size + char *rate; ///< video frame rate + char *duration; ///< total duration of the generated video +} TestSourceContext; + +#define OFFSET(x) offsetof(TestSourceContext, x) + +static const AVOption testsrc_options[]= { + { "size", "set video size", OFFSET(size), FF_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 }, + { "s", "set video size", OFFSET(size), FF_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 }, + { "rate", "set video rate", OFFSET(rate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, + { "r", "set video rate", OFFSET(rate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, + { "duration", "set video duration", OFFSET(duration), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, + { NULL }, +}; + +static const char *testsrc_get_name(void *ctx) +{ + return "testsrc"; +} + +static const AVClass testsrc_class = { + "TestSourceContext", + testsrc_get_name, + testsrc_options +}; + +static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) +{ + TestSourceContext *test = ctx->priv; + AVRational frame_rate_q; + int64_t duration = -1; + int ret = 0; + + test->class = &testsrc_class; + av_opt_set_defaults2(test, 0, 0); + + if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0) { + av_log(ctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args); + return ret; + } + + if ((ret = av_parse_video_size(&test->w, &test->h, test->size)) < 0) { + av_log(ctx, AV_LOG_ERROR, "Invalid frame size: '%s'\n", test->size); + return ret; + } + + if ((ret = av_parse_video_rate(&frame_rate_q, test->rate)) < 0 || + frame_rate_q.den <= 0 || frame_rate_q.num <= 0) { + av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", test->rate); + return ret; + } + + if ((test->duration) && (ret = av_parse_time(&duration, test->duration, 1)) < 0) { + av_log(ctx, AV_LOG_ERROR, "Invalid duration: '%s'\n", test->duration); + return ret; + } + + test->time_base.num = frame_rate_q.den; + test->time_base.den = frame_rate_q.num; + test->max_pts = duration >= 0 ? + av_rescale_q(duration, AV_TIME_BASE_Q, test->time_base) : -1; + test->nb_frame = 0; + test->pts = 0; + + av_log(ctx, AV_LOG_INFO, "size:%dx%d rate:%d/%d duration:%f\n", + test->w, test->h, frame_rate_q.num, frame_rate_q.den, + duration < 0 ? -1 : test->max_pts * av_q2d(test->time_base)); + return 0; +} + +static int config_props(AVFilterLink *outlink) +{ + TestSourceContext *test = outlink->src->priv; + + outlink->w = test->w; + outlink->h = test->h; + outlink->time_base = test->time_base; + + return 0; +} + +/** + * Fill a rectangle with value val. + * + * @param val the RGB value to set + * @param dst pointer to the destination buffer to fill + * @param dst_linesize linesize of destination + * @param segment_width width of the segment + * @param x horizontal coordinate where to draw the rectangle in the destination buffer + * @param y horizontal coordinate where to draw the rectangle in the destination buffer + * @param w width of the rectangle to draw, expressed as a number of segment_width units + * @param h height of the rectangle to draw, expressed as a number of segment_width units + */ +static void draw_rectangle(unsigned val, uint8_t *dst, int dst_linesize, unsigned segment_width, + unsigned x, unsigned y, unsigned w, unsigned h) +{ + int i; + int step = 3; + + dst += segment_width * (step * x + y * dst_linesize); + w *= segment_width * step; + h *= segment_width; + for (i = 0; i < h; i++) { + memset(dst, val, w); + dst += dst_linesize; + } +} + +static void draw_digit(int digit, uint8_t *dst, unsigned dst_linesize, + unsigned segment_width) +{ +#define TOP_HBAR 1 +#define MID_HBAR 2 +#define BOT_HBAR 4 +#define LEFT_TOP_VBAR 8 +#define LEFT_BOT_VBAR 16 +#define RIGHT_TOP_VBAR 32 +#define RIGHT_BOT_VBAR 64 + struct { + int x, y, w, h; + } segments[] = { + { 1, 0, 5, 1 }, /* TOP_HBAR */ + { 1, 6, 5, 1 }, /* MID_HBAR */ + { 1, 12, 5, 1 }, /* BOT_HBAR */ + { 0, 1, 1, 5 }, /* LEFT_TOP_VBAR */ + { 0, 7, 1, 5 }, /* LEFT_BOT_VBAR */ + { 6, 1, 1, 5 }, /* RIGHT_TOP_VBAR */ + { 6, 7, 1, 5 } /* RIGHT_BOT_VBAR */ + }; + static const unsigned char masks[10] = { + /* 0 */ TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR, + /* 1 */ RIGHT_TOP_VBAR|RIGHT_BOT_VBAR, + /* 2 */ TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR, + /* 3 */ TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR, + /* 4 */ MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR, + /* 5 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR, + /* 6 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR, + /* 7 */ TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR, + /* 8 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR, + /* 9 */ TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR, + }; + unsigned mask = masks[digit]; + int i; + + draw_rectangle(0, dst, dst_linesize, segment_width, 0, 0, 8, 13); + for (i = 0; i < FF_ARRAY_ELEMS(segments); i++) + if (mask & (1<data[0]; + int width = picref->video->w; + int height = picref->video->h; + + /* draw colored bars and circle */ + radius = (width + height) / 4; + quad0 = width * width / 4 + height * height / 4 - radius * radius; + dquad_y = 1 - height; + p0 = data; + for (y = 0; y < height; y++) { + p = p0; + color = 0; + color_rest = 0; + quad = quad0; + dquad_x = 1 - width; + for (x = 0; x < width; x++) { + icolor = color; + if (quad < 0) + icolor ^= 7; + quad += dquad_x; + dquad_x += 2; + *(p++) = icolor & 1 ? 255 : 0; + *(p++) = icolor & 2 ? 255 : 0; + *(p++) = icolor & 4 ? 255 : 0; + color_rest += 8; + if (color_rest >= width) { + color_rest -= width; + color++; + } + } + quad0 += dquad_y; + dquad_y += 2; + p0 += picref->linesize[0]; + } + + /* draw sliding color line */ + p = data + picref->linesize[0] * height * 3/4; + grad = (256 * test->nb_frame * test->time_base.num / test->time_base.den) % + GRADIENT_SIZE; + rgrad = 0; + dgrad = GRADIENT_SIZE / width; + drgrad = GRADIENT_SIZE % width; + for (x = 0; x < width; x++) { + *(p++) = + grad < 256 || grad >= 5 * 256 ? 255 : + grad >= 2 * 256 && grad < 4 * 256 ? 0 : + grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256; + *(p++) = + grad >= 4 * 256 ? 0 : + grad >= 1 * 256 && grad < 3 * 256 ? 255 : + grad < 1 * 256 ? grad : 4 * 256 - 1 - grad; + *(p++) = + grad < 2 * 256 ? 0 : + grad >= 3 * 256 && grad < 5 * 256 ? 255 : + grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad; + grad += dgrad; + rgrad += drgrad; + if (rgrad >= GRADIENT_SIZE) { + grad++; + rgrad -= GRADIENT_SIZE; + } + if (grad >= GRADIENT_SIZE) + grad -= GRADIENT_SIZE; + } + for (y = height / 8; y > 0; y--) { + memcpy(p, p - picref->linesize[0], 3 * width); + p += picref->linesize[0]; + } + + /* draw digits */ + seg_size = width / 80; + if (seg_size >= 1 && height >= 13 * seg_size) { + second = test->nb_frame * test->time_base.num / test->time_base.den; + x = width - (width - seg_size * 64) / 2; + y = (height - seg_size * 13) / 2; + p = data + (x*3 + y * picref->linesize[0]); + for (i = 0; i < 8; i++) { + p -= 3 * 8 * seg_size; + draw_digit(second % 10, p, picref->linesize[0], seg_size); + second /= 10; + if (second == 0) + break; + } + } +} + +static int request_frame(AVFilterLink *outlink) +{ + TestSourceContext *test = outlink->src->priv; + AVFilterBufferRef *picref; + + if (test->max_pts >= 0 && test->pts > test->max_pts) + return AVERROR_EOF; + picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, + test->w, test->h); + picref->pts = test->pts++; + test->nb_frame++; + fill_picture(test, picref); + + avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); + avfilter_draw_slice(outlink, 0, picref->video->h, 1); + avfilter_end_frame(outlink); + avfilter_unref_buffer(picref); + + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + static const enum PixelFormat pix_fmts[] = { + PIX_FMT_RGB24, PIX_FMT_NONE + }; + avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); + return 0; +} + +AVFilter avfilter_vsrc_testsrc = { + .name = "testsrc", + .description = NULL_IF_CONFIG_SMALL("Generate test pattern."), + .priv_size = sizeof(TestSourceContext), + .init = init, + + .query_formats = query_formats, + + .inputs = (AVFilterPad[]) {{ .name = NULL}}, + + .outputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .request_frame = request_frame, + .config_props = config_props, }, + { .name = NULL }}, +}; From 3fbc9bbb884da6a1fb331b1cb03945008ee36312 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 26 Jun 2011 16:37:07 +0200 Subject: [PATCH 083/780] mpeg4videoenc: Remove disabled variant of mpeg4_encode_block(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As a nice sideeffect this fixes the following warning: libavcodec/mpeg4videoenc.c:302:20: warning: variable ‘rl’ set but not used [-Wunused-but-set-variable] --- libavcodec/mpeg4videoenc.c | 65 -------------------------------------- 1 file changed, 65 deletions(-) diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 8a9bd198df..8a044d6d23 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -296,10 +296,6 @@ static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n uint8_t *scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb) { int i, last_non_zero; -#if 0 //variables for the outcommented version - int code, sign, last; -#endif - const RLTable *rl; uint32_t *bits_tab; uint8_t *len_tab; const int last_index = s->block_last_index[n]; @@ -309,20 +305,17 @@ static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n mpeg4_encode_dc(dc_pb, intra_dc, n); if(last_index<1) return; i = 1; - rl = &ff_mpeg4_rl_intra; bits_tab= uni_mpeg4_intra_rl_bits; len_tab = uni_mpeg4_intra_rl_len; } else { if(last_index<0) return; i = 0; - rl = &ff_h263_rl_inter; bits_tab= uni_mpeg4_inter_rl_bits; len_tab = uni_mpeg4_inter_rl_len; } /* AC coefs */ last_non_zero = i - 1; -#if 1 for (; i < last_index; i++) { int level = block[ scan_table[i] ]; if (level) { @@ -348,64 +341,6 @@ static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n put_bits(ac_pb, 7+2+1+6+1+12+1, (3<<23)+(3<<21)+(1<<20)+(run<<14)+(1<<13)+(((level-64)&0xfff)<<1)+1); } } -#else - for (; i <= last_index; i++) { - const int slevel = block[ scan_table[i] ]; - if (slevel) { - int level; - int run = i - last_non_zero - 1; - last = (i == last_index); - sign = 0; - level = slevel; - if (level < 0) { - sign = 1; - level = -level; - } - code = get_rl_index(rl, last, run, level); - put_bits(ac_pb, rl->table_vlc[code][1], rl->table_vlc[code][0]); - if (code == rl->n) { - int level1, run1; - level1 = level - rl->max_level[last][run]; - if (level1 < 1) - goto esc2; - code = get_rl_index(rl, last, run, level1); - if (code == rl->n) { - esc2: - put_bits(ac_pb, 1, 1); - if (level > MAX_LEVEL) - goto esc3; - run1 = run - rl->max_run[last][level] - 1; - if (run1 < 0) - goto esc3; - code = get_rl_index(rl, last, run1, level); - if (code == rl->n) { - esc3: - /* third escape */ - put_bits(ac_pb, 1, 1); - put_bits(ac_pb, 1, last); - put_bits(ac_pb, 6, run); - put_bits(ac_pb, 1, 1); - put_sbits(ac_pb, 12, slevel); - put_bits(ac_pb, 1, 1); - } else { - /* second escape */ - put_bits(ac_pb, 1, 0); - put_bits(ac_pb, rl->table_vlc[code][1], rl->table_vlc[code][0]); - put_bits(ac_pb, 1, sign); - } - } else { - /* first escape */ - put_bits(ac_pb, 1, 0); - put_bits(ac_pb, rl->table_vlc[code][1], rl->table_vlc[code][0]); - put_bits(ac_pb, 1, sign); - } - } else { - put_bits(ac_pb, 1, sign); - } - last_non_zero = i; - } - } -#endif } static int mpeg4_get_block_length(MpegEncContext * s, DCTELEM * block, int n, int intra_dc, From 90a40b226a5c90e48da8041294c3782de6ee61fc Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Sun, 26 Jun 2011 14:01:00 -0700 Subject: [PATCH 084/780] ffmpeg: fix prototypes of functions after the removal of OPT_FUNC2. --- ffmpeg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 80a67c180e..f2716a35aa 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -4071,13 +4071,13 @@ static void parse_matrix_coeffs(uint16_t *dest, const char *str) } } -static void opt_inter_matrix(const char *arg) +static void opt_inter_matrix(const char *opt, const char *arg) { inter_matrix = av_mallocz(sizeof(uint16_t) * 64); parse_matrix_coeffs(inter_matrix, arg); } -static void opt_intra_matrix(const char *arg) +static void opt_intra_matrix(const char *opt, const char *arg) { intra_matrix = av_mallocz(sizeof(uint16_t) * 64); parse_matrix_coeffs(intra_matrix, arg); @@ -4375,7 +4375,7 @@ static void log_callback_null(void* ptr, int level, const char* fmt, va_list vl) { } -static void opt_passlogfile(const char *arg) +static void opt_passlogfile(const char *opt, const char *arg) { pass_logfilename_prefix = arg; opt_default("passlogfile", arg); From 721719dd0c0321b47500fa49b649c78422e910aa Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Sun, 26 Jun 2011 14:08:22 -0700 Subject: [PATCH 085/780] dnxhddec: handle cid change in bitstream. --- libavcodec/dnxhddec.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 8cbe1a8111..43c4679f69 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -63,7 +63,7 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx) static int dnxhd_init_vlc(DNXHDContext *ctx, int cid) { - if (!ctx->cid_table) { + if (cid != ctx->cid) { int index; if ((index = ff_dnxhd_get_cid_table(cid)) < 0) { @@ -71,6 +71,11 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid) return -1; } ctx->cid_table = &ff_dnxhd_cid_table[index]; + + free_vlc(&ctx->ac_vlc); + free_vlc(&ctx->dc_vlc); + free_vlc(&ctx->run_vlc); + init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257, ctx->cid_table->ac_bits, 1, 1, ctx->cid_table->ac_codes, 2, 2, 0); @@ -82,6 +87,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid) ctx->cid_table->run_codes, 2, 2, 0); ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, ff_zigzag_direct); + ctx->cid = cid; } return 0; } @@ -89,7 +95,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid) static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_size, int first_field) { static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 }; - int i; + int i, cid; if (buf_size < 0x280) return -1; @@ -115,10 +121,10 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si return -1; } - ctx->cid = AV_RB32(buf + 0x28); - av_dlog(ctx->avctx, "compression id %d\n", ctx->cid); + cid = AV_RB32(buf + 0x28); + av_dlog(ctx->avctx, "compression id %d\n", cid); - if (dnxhd_init_vlc(ctx, ctx->cid) < 0) + if (dnxhd_init_vlc(ctx, cid) < 0) return -1; if (buf_size < ctx->cid_table->coding_unit_size) { From 84153d188347b3dee684fab40bf28ddd3eba64cf Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Sat, 25 Jun 2011 19:40:05 -0700 Subject: [PATCH 086/780] H.264: make filter_mb_fast support 4:4:4 --- libavcodec/h264_loopfilter.c | 62 ++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 86ecb2737f..bdfbce79f0 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -218,10 +218,11 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, int mb_type, left_type; int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh; int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)); + int chroma444 = CHROMA444; mb_xy = h->mb_xy; - if(!h->top_type || !h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff || CHROMA444) { + if(!h->top_type || !h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) { ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize); return; } @@ -264,16 +265,46 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, h); } if(chroma){ - if(left_type){ - filter_mb_edgecv( &img_cb[2*0], uvlinesize, bS4, qpc0, h); - filter_mb_edgecv( &img_cr[2*0], uvlinesize, bS4, qpc0, h); + if(chroma444){ + if(left_type){ + filter_mb_edgev( &img_cb[4*0], linesize, bS4, qpc0, h); + filter_mb_edgev( &img_cr[4*0], linesize, bS4, qpc0, h); + } + if( IS_8x8DCT(mb_type) ) { + filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h); + filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h); + filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h); + filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h); + filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h); + filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h); + } else { + filter_mb_edgev( &img_cb[4*1], linesize, bS3, qpc, h); + filter_mb_edgev( &img_cr[4*1], linesize, bS3, qpc, h); + filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h); + filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h); + filter_mb_edgev( &img_cb[4*3], linesize, bS3, qpc, h); + filter_mb_edgev( &img_cr[4*3], linesize, bS3, qpc, h); + filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h); + filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h); + filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, h); + filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, h); + filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h); + filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h); + filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, h); + filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, h); + } + }else{ + if(left_type){ + filter_mb_edgecv( &img_cb[2*0], uvlinesize, bS4, qpc0, h); + filter_mb_edgecv( &img_cr[2*0], uvlinesize, bS4, qpc0, h); + } + filter_mb_edgecv( &img_cb[2*2], uvlinesize, bS3, qpc, h); + filter_mb_edgecv( &img_cr[2*2], uvlinesize, bS3, qpc, h); + filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h); + filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, h); + filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h); + filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, h); } - filter_mb_edgecv( &img_cb[2*2], uvlinesize, bS3, qpc, h); - filter_mb_edgecv( &img_cr[2*2], uvlinesize, bS3, qpc, h); - filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h); - filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, h); - filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h); - filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, h); } return; } else { @@ -301,9 +332,14 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, #define FILTER(hv,dir,edge)\ if(AV_RN64A(bS[dir][edge])) { \ filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qp : qp##dir, h );\ - if(chroma && !(edge&1)) {\ - filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\ - filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\ + if(chroma){\ + if(chroma444){\ + filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\ + filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\ + } else if(!(edge&1)) {\ + filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\ + filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\ + }\ }\ } if(left_type) From 9a0dda8b3ab07fa7be60335715a6c350c907a7b8 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Sun, 26 Jun 2011 00:21:54 -0700 Subject: [PATCH 087/780] H.264: disable 2tap qpel with CODEC_FLAG2_FAST and >8-bit 2tap qpel isn't implemented yet for high bit depth, so it just breaks decoding. --- libavcodec/h264.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 6bee7c39b0..2c000a3420 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2485,7 +2485,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ s->dropable= h->nal_ref_idc == 0; - if((s->avctx->flags2 & CODEC_FLAG2_FAST) && !h->nal_ref_idc){ + /* FIXME: 2tap qpel isn't implemented for high bit depth. */ + if((s->avctx->flags2 & CODEC_FLAG2_FAST) && !h->nal_ref_idc && !h->pixel_shift){ s->me.qpel_put= s->dsp.put_2tap_qpel_pixels_tab; s->me.qpel_avg= s->dsp.avg_2tap_qpel_pixels_tab; }else{ From 97535ffb9795f59c4fbfacfe1541d752ed47218e Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 26 Jun 2011 14:41:44 -0700 Subject: [PATCH 088/780] swscale: remove unused xInc/srcW arguments from hScale(). --- libswscale/ppc/swscale_altivec.c | 3 +-- libswscale/swscale.c | 8 +++----- libswscale/swscale_internal.h | 4 ++-- libswscale/x86/swscale_template.c | 3 +-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 42e965de95..47fe54c088 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -222,8 +222,7 @@ yuv2yuvX_altivec_real(SwsContext *c, } static void hScale_altivec_real(int16_t *dst, int dstW, - const uint8_t *src, int srcW, - int xInc, const int16_t *filter, + const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize) { register int i; diff --git a/libswscale/swscale.c b/libswscale/swscale.c index f729c117a7..731f1320b3 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1804,10 +1804,8 @@ static void rgb24ToUV_half_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, } } - // bilinear / bicubic scaling static void hScale_c(int16_t *dst, int dstW, const uint8_t *src, - int srcW, int xInc, const int16_t *filter, const int16_t *filterPos, int filterSize) { @@ -1886,7 +1884,7 @@ static av_always_inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, } if (!c->hyscale_fast) { - c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); + c->hScale(dst, dstWidth, src, hLumFilter, hLumFilterPos, hLumFilterSize); } else { // fast bilinear upscale / crap downscale c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc); } @@ -1924,8 +1922,8 @@ static av_always_inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *ds } if (!c->hcscale_fast) { - c->hScale(dst1, dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); - c->hScale(dst2, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); + c->hScale(dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize); + c->hScale(dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize); } else { // fast bilinear upscale / crap downscale c->hcscale_fast(c, dst1, dst2, dstWidth, src1, src2, srcW, xInc); } diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index ea34d8ce0e..9967c99eda 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -306,8 +306,8 @@ typedef struct SwsContext { const uint8_t *src1, const uint8_t *src2, int srcW, int xInc); - void (*hScale)(int16_t *dst, int dstW, const uint8_t *src, int srcW, - int xInc, const int16_t *filter, const int16_t *filterPos, + void (*hScale)(int16_t *dst, int dstW, const uint8_t *src, + const int16_t *filter, const int16_t *filterPos, int filterSize); void (*lumConvertRange)(int16_t *dst, int width); ///< Color range conversion function for luma plane if needed. diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 8fad257ddf..79bf2a4c8c 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -1906,8 +1906,7 @@ static void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, #if !COMPILE_TEMPLATE_MMX2 // bilinear / bicubic scaling static void RENAME(hScale)(int16_t *dst, int dstW, - const uint8_t *src, int srcW, - int xInc, const int16_t *filter, + const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize) { assert(filterSize % 4 == 0 && filterSize>0); From bc877faf7f92deef9c619d81bec85202b9f10f0e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 25 Jun 2011 11:57:32 +0100 Subject: [PATCH 089/780] build: factor out the .c and .S compile commands as a macro These commands have the same form, and using a common macro allows it to be used elsewhere without further duplication. Signed-off-by: Mans Rullgard --- Makefile | 15 +++++++++++---- configure | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f1bede83db..f16da3acca 100644 --- a/Makefile +++ b/Makefile @@ -23,16 +23,23 @@ endif IFLAGS := -I. -I$(SRC_PATH) CPPFLAGS := $(IFLAGS) $(CPPFLAGS) CFLAGS += $(ECFLAGS) +CCFLAGS = $(CFLAGS) YASMFLAGS += $(IFLAGS) -Pconfig.asm HOSTCFLAGS += $(IFLAGS) +define COMPILE + $($(1)DEP) + $($(1)) $(CPPFLAGS) $($(1)FLAGS) $($(1)_DEPFLAGS) -c $($(1)_O) $< +endef + +COMPILE_C = $(call COMPILE,CC) +COMPILE_S = $(call COMPILE,AS) + %.o: %.c - $(CCDEP) - $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $< + $(COMPILE_C) %.o: %.S - $(ASDEP) - $(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $< + $(COMPILE_S) %.ho: %.h $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $< diff --git a/configure b/configure index db3277f262..d8454e0d23 100755 --- a/configure +++ b/configure @@ -1674,6 +1674,7 @@ SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)' SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)' LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' +AS_O='-o $@' CC_O='-o $@' host_cflags='-D_ISOC99_SOURCE -O3 -g' @@ -3273,6 +3274,7 @@ LN_S=$ln_s CPPFLAGS=$CPPFLAGS CFLAGS=$CFLAGS ASFLAGS=$ASFLAGS +AS_O=$CC_O CC_O=$CC_O DLLTOOL=$dlltool LDFLAGS=$LDFLAGS From 659aa20e56de03b461afdaa6ae7e5d4be6e0d5fc Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 25 Jun 2011 11:51:09 +0100 Subject: [PATCH 090/780] build: improve rules for test programs This generates dependencies for the *-test.o files ensuring rebuilds when necessary. Signed-off-by: Mans Rullgard --- subdir.mak | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/subdir.mak b/subdir.mak index e4d7377fcb..f544796022 100644 --- a/subdir.mak +++ b/subdir.mak @@ -11,16 +11,17 @@ all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)%-test.o: $(SUBDIR)%-test.c - $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $(CC_O) $^ + $(COMPILE_C) $(SUBDIR)%-test.o: $(SUBDIR)%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $(CC_O) $^ + $(COMPILE_C) $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm $(YASMDEP) $(YASMFLAGS) -I $( $(@:.o=.d) $(YASM) $(YASMFLAGS) -I $( Date: Mon, 27 Jun 2011 09:26:48 +0200 Subject: [PATCH 091/780] Fix VDPAU decoding for some H264 samples. --- libavcodec/vdpau.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 9fbcbf9a3f..7263099591 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -183,7 +183,8 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s) render->info.h264.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; render->info.h264.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present; memcpy(render->info.h264.scaling_lists_4x4, h->pps.scaling_matrix4, sizeof(render->info.h264.scaling_lists_4x4)); - memcpy(render->info.h264.scaling_lists_8x8, h->pps.scaling_matrix8, sizeof(render->info.h264.scaling_lists_8x8)); + memcpy(render->info.h264.scaling_lists_8x8[0], h->pps.scaling_matrix8[0], sizeof(render->info.h264.scaling_lists_8x8[0])); + memcpy(render->info.h264.scaling_lists_8x8[1], h->pps.scaling_matrix8[3], sizeof(render->info.h264.scaling_lists_8x8[0])); ff_draw_horiz_band(s, 0, s->avctx->height); render->bitstream_buffers_used = 0; From 90d475a9e7ecc03f9b3067a90225a9438ac84b9f Mon Sep 17 00:00:00 2001 From: ami_stuff Date: Mon, 27 Jun 2011 09:40:53 +0200 Subject: [PATCH 092/780] Support fourcc YV16 (ticket 307). --- libavcodec/raw.c | 1 + libavcodec/rawdec.c | 1 + libavformat/riff.c | 1 + 3 files changed, 3 insertions(+) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index 0bc04df071..c44220ee4d 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -36,6 +36,7 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_YUV411P, MKTAG('Y', '4', '1', 'B') }, { PIX_FMT_YUV422P, MKTAG('Y', '4', '2', 'B') }, { PIX_FMT_YUV422P, MKTAG('P', '4', '2', '2') }, + { PIX_FMT_YUV422P, MKTAG('Y', 'V', '1', '6') }, /* yuvjXXX formats are deprecated hacks specific to libav*, they are identical to yuvXXX */ { PIX_FMT_YUVJ420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */ diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 503351e68a..04aa51edc2 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -199,6 +199,7 @@ static int raw_decode(AVCodecContext *avctx, flip(avctx, picture); if ( avctx->codec_tag == MKTAG('Y', 'V', '1', '2') + || avctx->codec_tag == MKTAG('Y', 'V', '1', '6') || avctx->codec_tag == MKTAG('Y', 'V', 'U', '9')) FFSWAP(uint8_t *, picture->data[1], picture->data[2]); diff --git a/libavformat/riff.c b/libavformat/riff.c index 544c29f116..1213edd0ca 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -171,6 +171,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', 's') }, { CODEC_ID_RAWVIDEO, MKTAG('P', '4', '2', '2') }, { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') }, + { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '6') }, { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') }, { CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') }, { CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') }, From 9df1d329a5ac718dd9459ed37acdbbc88adc31e3 Mon Sep 17 00:00:00 2001 From: ami_stuff Date: Mon, 27 Jun 2011 10:03:21 +0200 Subject: [PATCH 093/780] Support fourcc Y8 (ticket 308). --- libavcodec/raw.c | 1 + libavformat/riff.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index c44220ee4d..d6867186ad 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -46,6 +46,7 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_YUVJ422P, MKTAG('P', '4', '2', '2') }, { PIX_FMT_GRAY8, MKTAG('Y', '8', '0', '0') }, { PIX_FMT_GRAY8, MKTAG(' ', ' ', 'Y', '8') }, + { PIX_FMT_GRAY8, MKTAG('Y', '8', ' ', ' ') }, { PIX_FMT_YUYV422, MKTAG('Y', 'U', 'Y', '2') }, /* Packed formats */ { PIX_FMT_YUYV422, MKTAG('Y', '4', '2', '2') }, diff --git a/libavformat/riff.c b/libavformat/riff.c index 1213edd0ca..acac938187 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -175,6 +175,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') }, { CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') }, { CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') }, + { CODEC_ID_RAWVIDEO, MKTAG('Y', '8', ' ', ' ') }, { CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') }, { CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') }, { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') }, From cdeb803e2fe1239e0217186c7441c94adb0d9895 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 26 Jun 2011 18:49:00 +0200 Subject: [PATCH 094/780] vf_lut: fix draw_slice() in case of non packed image data for packed RGB The previous code was erroneously assuming that the linesize was equivalent to width*pixel_step, which is not always true. --- libavfilter/vf_lut.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index c457972474..fdab6941a4 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -306,21 +306,25 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) AVFilterLink *outlink = ctx->outputs[0]; AVFilterBufferRef *inpic = inlink ->cur_buf; AVFilterBufferRef *outpic = outlink->out_buf; - uint8_t *inrow, *outrow; + uint8_t *inrow, *outrow, *inrow0, *outrow0; int i, j, k, plane; if (lut->is_rgb) { /* packed */ - inrow = inpic ->data[0] + y * inpic ->linesize[0]; - outrow = outpic->data[0] + y * outpic->linesize[0]; + inrow0 = inpic ->data[0] + y * inpic ->linesize[0]; + outrow0 = outpic->data[0] + y * outpic->linesize[0]; for (i = 0; i < h; i ++) { + inrow = inrow0; + outrow = outrow0; for (j = 0; j < inlink->w; j++) { for (k = 0; k < lut->step; k++) outrow[k] = lut->lut[lut->rgba_map[k]][inrow[k]]; outrow += lut->step; inrow += lut->step; } + inrow0 += inpic ->linesize[0]; + outrow0 += outpic->linesize[0]; } } else { /* planar */ From 65eae2a7a2a14926c9f9683544e99982ba565f93 Mon Sep 17 00:00:00 2001 From: Jonathan Baldwin Date: Sat, 25 Jun 2011 08:06:00 +0200 Subject: [PATCH 095/780] lavdev: add openal input device --- Changelog | 4 + configure | 9 ++ doc/indevs.texi | 89 ++++++++++++++ libavdevice/Makefile | 1 + libavdevice/alldevices.c | 1 + libavdevice/avdevice.h | 4 +- libavdevice/openal-dec.c | 256 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 362 insertions(+), 2 deletions(-) create mode 100644 libavdevice/openal-dec.c diff --git a/Changelog b/Changelog index 4c2f2e3d1b..70a912fb49 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,10 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version next: + +- openal input device added + version 0.8: diff --git a/configure b/configure index fb197aae55..afa25d9d06 100755 --- a/configure +++ b/configure @@ -188,6 +188,7 @@ External library support: --enable-libxavs enable AVS encoding via xavs [no] --enable-libxvid enable Xvid encoding via xvidcore, native MPEG-4/Xvid encoder exists [no] + --enable-openal enable OpenAL 1.1 capture support [no] --enable-mlib enable Sun medialib [no] --enable-zlib enable zlib [autodetect] @@ -959,6 +960,7 @@ CONFIG_LIST=" mpegaudiodsp network nonfree + openal pic postproc rdft @@ -1471,6 +1473,7 @@ dv1394_indev_deps="dv1394 dv_demuxer" fbdev_indev_deps="linux_fb_h" jack_indev_deps="jack_jack_h sem_timedwait" libdc1394_indev_deps="libdc1394" +openal_indev_deps="openal" oss_indev_deps_any="soundcard_h sys_soundcard_h" oss_outdev_deps_any="soundcard_h sys_soundcard_h" sdl_outdev_deps="sdl" @@ -2948,6 +2951,11 @@ enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 && die "ERROR: libx264 version must be >= 0.115."; } enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore +enabled openal && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do + check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } || + die "ERROR: openal not found"; } && + { check_cpp_condition "AL/al.h" "defined(AL_VERSION_1_1)" || + die "ERROR: openal version must be 1.1 or compatible"; } enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib SDL_CONFIG="${cross_prefix}sdl-config" @@ -3247,6 +3255,7 @@ echo "libvpx enabled ${libvpx-no}" echo "libx264 enabled ${libx264-no}" echo "libxavs enabled ${libxavs-no}" echo "libxvid enabled ${libxvid-no}" +echo "openal enabled ${openal-no}" echo "zlib enabled ${zlib-no}" echo "bzlib enabled ${bzlib-no}" echo diff --git a/doc/indevs.texi b/doc/indevs.texi index 04871081dd..6d837ed412 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -137,6 +137,95 @@ For more information read: IIDC1394 input device, based on libdc1394 and libraw1394. +@section openal + +The OpenAL input device provides audio capture on all systems with a +working OpenAL 1.1 implementation. + +To enable this input device during configuration, you need OpenAL +headers and libraries installed on your system, and need to configure +FFmpeg with @code{--enable-openal}. + +OpenAL headers and libraries should be provided as part of your OpenAL +implementation, or as an additional download (an SDK). Depending on your +installation you may need to specify additional flags via the +@code{--extra-cflags} and @code{--extra-ldflags} for allowing the build +system to locate the OpenAL headers and libraries. + +An incomplete list of OpenAL implementations follows: + +@table @strong +@item Creative +The official Windows implementation, providing hardware acceleration +with supported devices and software fallback. +See @url{http://openal.org/}. +@item OpenAL Soft +Portable, open source (LGPL) software implementation. Includes +backends for the most common sound APIs on the Windows, Linux, +Solaris, and BSD operating systems. +See @url{http://kcat.strangesoft.net/openal.html}. +@item Apple +OpenAL is part of Core Audio, the official Mac OS X Audio interface. +See @url{http://developer.apple.com/technologies/mac/audio-and-video.html} +@end table + +This device allows to capture from an audio input device handled +through OpenAL. + +You need to specify the name of the device to capture in the provided +filename. If the empty string is provided, the device will +automatically select the default device. You can get the list of the +supported devices by using the option @var{list_devices}. + +@subsection Options + +@table @option + +@item channels +Set the number of channels in the captured audio. Only the values +@option{1} (monaural) and @option{2} (stereo) are currently supported. +Defaults to @option{2}. + +@item sample_size +Set the sample size (in bits) of the captured audio. Only the values +@option{8} and @option{16} are currently supported. Defaults to +@option{16}. + +@item sample_rate +Set the sample rate (in Hz) of the captured audio. +Defaults to @option{44.1k}. + +@item list_devices +If set to @option{true}, print a list of devices and exit. +Defaults to @option{false}. + +@end table + +@subsection Examples + +Print the list of OpenAL supported devices and exit: +@example +$ ffmpeg -list_devices true -f openal -i dummy out.ogg +@end example + +Capture from the OpenAL device @file{DR-BT101 via PulseAudio}: +@example +$ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out.ogg +@end example + +Capture from the default device (note the empty string '' as filename): +@example +$ ffmpeg -f openal -i '' out.ogg +@end example + +Capture from two devices simultaneously, writing to two different files, +within the same @file{ffmpeg} command: +@example +$ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out1.ogg -f openal -i 'ALSA Default' out2.ogg +@end example +Note: not all OpenAL implementations support multiple simultaneous capture - +try the latest OpenAL Soft if the above does not work. + @section oss Open Sound System input device. diff --git a/libavdevice/Makefile b/libavdevice/Makefile index 60103a4864..4d3c1aec6c 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -19,6 +19,7 @@ OBJS-$(CONFIG_DSHOW_INDEV) += dshow.o dshow_enummediatypes.o \ OBJS-$(CONFIG_DV1394_INDEV) += dv1394.o OBJS-$(CONFIG_FBDEV_INDEV) += fbdev.o OBJS-$(CONFIG_JACK_INDEV) += jack_audio.o +OBJS-$(CONFIG_OPENAL_INDEV) += openal-dec.o OBJS-$(CONFIG_OSS_INDEV) += oss_audio.o OBJS-$(CONFIG_OSS_OUTDEV) += oss_audio.o OBJS-$(CONFIG_SDL_OUTDEV) += sdl.o diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c index 7846704861..ef302d700d 100644 --- a/libavdevice/alldevices.c +++ b/libavdevice/alldevices.c @@ -44,6 +44,7 @@ void avdevice_register_all(void) REGISTER_INDEV (DV1394, dv1394); REGISTER_INDEV (FBDEV, fbdev); REGISTER_INDEV (JACK, jack); + REGISTER_INDEV (OPENAL, openal); REGISTER_INOUTDEV (OSS, oss); REGISTER_OUTDEV (SDL, sdl); REGISTER_INOUTDEV (SNDIO, sndio); diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h index e49e5b71f7..7cb8f5497f 100644 --- a/libavdevice/avdevice.h +++ b/libavdevice/avdevice.h @@ -23,8 +23,8 @@ #include "libavformat/avformat.h" #define LIBAVDEVICE_VERSION_MAJOR 53 -#define LIBAVDEVICE_VERSION_MINOR 1 -#define LIBAVDEVICE_VERSION_MICRO 1 +#define LIBAVDEVICE_VERSION_MINOR 2 +#define LIBAVDEVICE_VERSION_MICRO 0 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ LIBAVDEVICE_VERSION_MINOR, \ diff --git a/libavdevice/openal-dec.c b/libavdevice/openal-dec.c new file mode 100644 index 0000000000..f01dff7d87 --- /dev/null +++ b/libavdevice/openal-dec.c @@ -0,0 +1,256 @@ +/* + * Copyright (c) 2011 Jonathan Baldwin + * + * This file is part of FFmpeg. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * @file + * OpenAL 1.1 capture device for libavdevice + **/ + +#include +#include + +#include "libavutil/opt.h" +#include "avdevice.h" + +typedef struct { + AVClass *class; + /** OpenAL capture device context. **/ + ALCdevice *device; + /** The number of channels in the captured audio. **/ + int channels; + /** The sample rate (in Hz) of the captured audio. **/ + int sample_rate; + /** The sample size (in bits) of the captured audio. **/ + int sample_size; + /** The OpenAL sample format of the captured audio. **/ + ALCenum sample_format; + /** The number of bytes between two consecutive samples of the same channel/component. **/ + ALCint sample_step; + /** If true, print a list of capture devices on this system and exit. **/ + int list_devices; +} al_data; + +typedef struct { + ALCenum al_fmt; + enum CodecID codec_id; + int channels; +} al_format_info; + +#define LOWEST_AL_FORMAT FFMIN(FFMIN(AL_FORMAT_MONO8,AL_FORMAT_MONO16),FFMIN(AL_FORMAT_STEREO8,AL_FORMAT_STEREO16)) + +/** + * Get information about an AL_FORMAT value. + * @param al_fmt the AL_FORMAT value to find information about. + * @return A pointer to a structure containing information about the AL_FORMAT value. + */ +static inline al_format_info* get_al_format_info(ALCenum al_fmt) +{ + static al_format_info info_table[] = { + [AL_FORMAT_MONO8-LOWEST_AL_FORMAT] = {AL_FORMAT_MONO8, CODEC_ID_PCM_U8, 1}, + [AL_FORMAT_MONO16-LOWEST_AL_FORMAT] = {AL_FORMAT_MONO16, AV_NE (CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE), 1}, + [AL_FORMAT_STEREO8-LOWEST_AL_FORMAT] = {AL_FORMAT_STEREO8, CODEC_ID_PCM_U8, 2}, + [AL_FORMAT_STEREO16-LOWEST_AL_FORMAT] = {AL_FORMAT_STEREO16, AV_NE (CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE), 2}, + }; + + return &info_table[al_fmt-LOWEST_AL_FORMAT]; +} + +/** + * Get the OpenAL error code, translated into an av/errno error code. + * @param device The ALC device to check for errors. + * @param error_msg_ret A pointer to a char* in which to return the error message, or NULL if desired. + * @return The error code, or 0 if there is no error. + */ +static inline int al_get_error(ALCdevice *device, const char** error_msg_ret) +{ + ALCenum error = alcGetError(device); + if (error_msg_ret) + *error_msg_ret = (const char*) alcGetString(device, error); + switch (error) { + case ALC_NO_ERROR: + return 0; + case ALC_INVALID_DEVICE: + return AVERROR(ENODEV); + break; + case ALC_INVALID_CONTEXT: + case ALC_INVALID_ENUM: + case ALC_INVALID_VALUE: + return AVERROR(EINVAL); + break; + case ALC_OUT_OF_MEMORY: + return AVERROR(ENOMEM); + break; + default: + return AVERROR(EIO); + } +} + +/** + * Print out a list of OpenAL capture devices on this system. + */ +static inline void print_al_capture_devices(void *log_ctx) +{ + const char *devices; + + if (!(devices = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER))) + return; + + av_log(log_ctx, AV_LOG_INFO, "List of OpenAL capture devices on this system:\n"); + + for (; *devices != '\0'; devices += strlen(devices) + 1) + av_log(log_ctx, AV_LOG_INFO, " %s\n", devices); +} + +static int read_header(AVFormatContext *ctx, AVFormatParameters *ap) +{ + al_data *ad = ctx->priv_data; + static const ALCenum sample_formats[2][2] = { + { AL_FORMAT_MONO8, AL_FORMAT_STEREO8 }, + { AL_FORMAT_MONO16, AL_FORMAT_STEREO16 } + }; + int error = 0; + const char *error_msg; + AVStream *st = NULL; + AVCodecContext *codec = NULL; + + if (ad->list_devices) { + print_al_capture_devices(ctx); + return AVERROR_EXIT; + } + + ad->sample_format = sample_formats[ad->sample_size/8-1][ad->channels-1]; + + /* Open device for capture */ + ad->device = + alcCaptureOpenDevice(ctx->filename[0] ? ctx->filename : NULL, + ad->sample_rate, + ad->sample_format, + ad->sample_rate); /* Maximum 1 second of sample data to be read at once */ + + if (error = al_get_error(ad->device, &error_msg)) goto fail; + + /* Create stream */ + if (!(st = av_new_stream(ctx, 0))) { + error = AVERROR(ENOMEM); + goto fail; + } + + /* We work in microseconds */ + av_set_pts_info(st, 64, 1, 1000000); + + /* Set codec parameters */ + codec = st->codec; + codec->codec_type = AVMEDIA_TYPE_AUDIO; + codec->sample_rate = ad->sample_rate; + codec->channels = get_al_format_info(ad->sample_format)->channels; + codec->codec_id = get_al_format_info(ad->sample_format)->codec_id; + + /* This is needed to read the audio data */ + ad->sample_step = (av_get_bits_per_sample(get_al_format_info(ad->sample_format)->codec_id) * + get_al_format_info(ad->sample_format)->channels) / 8; + + /* Finally, start the capture process */ + alcCaptureStart(ad->device); + + return 0; + +fail: + /* Handle failure */ + if (ad->device) + alcCaptureCloseDevice(ad->device); + if (error_msg) + av_log(ctx, AV_LOG_ERROR, "Cannot open device: %s\n", error_msg); + return error; +} + +static int read_packet(AVFormatContext* ctx, AVPacket *pkt) +{ + al_data *ad = ctx->priv_data; + int error=0; + const char *error_msg; + ALCint nb_samples; + + /* Get number of samples available */ + alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples); + if (error = al_get_error(ad->device, &error_msg)) goto fail; + + /* Create a packet of appropriate size */ + av_new_packet(pkt, nb_samples*ad->sample_step); + pkt->pts = av_gettime(); + + /* Fill the packet with the available samples */ + alcCaptureSamples(ad->device, pkt->data, nb_samples); + if (error = al_get_error(ad->device, &error_msg)) goto fail; + + return pkt->size; +fail: + /* Handle failure */ + if (pkt->data) + av_destruct_packet(pkt); + if (error_msg) + av_log(ctx, AV_LOG_ERROR, "Error: %s\n", error_msg); + return error; +} + +static int read_close(AVFormatContext* ctx) +{ + al_data *ad = ctx->priv_data; + + if (ad->device) { + alcCaptureStop(ad->device); + alcCaptureCloseDevice(ad->device); + } + return 0; +} + +#define OFFSET(x) offsetof(al_data, x) + +static const AVOption options[] = { + {"channels", "set number of channels", OFFSET(channels), FF_OPT_TYPE_INT, {.dbl=2}, 1, 2, AV_OPT_FLAG_DECODING_PARAM }, + {"sample_rate", "set sample rate", OFFSET(sample_rate), FF_OPT_TYPE_INT, {.dbl=44100}, 1, 192000, AV_OPT_FLAG_DECODING_PARAM }, + {"sample_size", "set sample size", OFFSET(sample_size), FF_OPT_TYPE_INT, {.dbl=16}, 8, 16, AV_OPT_FLAG_DECODING_PARAM }, + {"list_devices", "list available devices", OFFSET(list_devices), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, + {"true", "", 0, FF_OPT_TYPE_CONST, {.dbl=1}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "list_devices" }, + {"false", "", 0, FF_OPT_TYPE_CONST, {.dbl=0}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "list_devices" }, + {NULL}, +}; + +static const AVClass class = { + .class_name = "openal", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT +}; + +AVInputFormat ff_openal_demuxer = { + .name = "openal", + .long_name = NULL_IF_CONFIG_SMALL("OpenAL audio capture device"), + .priv_data_size = sizeof(al_data), + .read_probe = NULL, + .read_header = read_header, + .read_packet = read_packet, + .read_close = read_close, + .flags = AVFMT_NOFILE, + .priv_class = &class +}; From 7dcdf974d02caee206b38d0946b2fc1fab082aa3 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 21 Jun 2011 12:59:11 -0400 Subject: [PATCH 096/780] ac3enc: Remove bit allocation fallbacks. They introduce too much complexity for very little benefit. The result is that encoding will be more likely to fail at extremely low bitrates where quality would be awful anyway. --- libavcodec/ac3enc.c | 71 +-------------------------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 1f7d05e87c..3fbbbd0991 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1022,47 +1022,6 @@ static int cbr_bit_allocation(AC3EncodeContext *s) } -/** - * Downgrade exponent strategies to reduce the bits used by the exponents. - * This is a fallback for when bit allocation fails with the normal exponent - * strategies. Each time this function is run it only downgrades the - * strategy in 1 channel of 1 block. - * @return non-zero if downgrade was unsuccessful - */ -static int downgrade_exponents(AC3EncodeContext *s) -{ - int ch, blk; - - for (blk = AC3_MAX_BLOCKS-1; blk >= 0; blk--) { - for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) { - if (s->exp_strategy[ch][blk] == EXP_D15) { - s->exp_strategy[ch][blk] = EXP_D25; - return 0; - } - } - } - for (blk = AC3_MAX_BLOCKS-1; blk >= 0; blk--) { - for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) { - if (s->exp_strategy[ch][blk] == EXP_D25) { - s->exp_strategy[ch][blk] = EXP_D45; - return 0; - } - } - } - /* block 0 cannot reuse exponents, so only downgrade D45 to REUSE if - the block number > 0 */ - for (blk = AC3_MAX_BLOCKS-1; blk > 0; blk--) { - for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) { - if (s->exp_strategy[ch][blk] > EXP_REUSE) { - s->exp_strategy[ch][blk] = EXP_REUSE; - return 0; - } - } - } - return -1; -} - - /** * Perform bit allocation search. * Finds the SNR offset value that maximizes quality and fits in the specified @@ -1071,39 +1030,11 @@ static int downgrade_exponents(AC3EncodeContext *s) */ static int compute_bit_allocation(AC3EncodeContext *s) { - int ret; - count_frame_bits(s); bit_alloc_masking(s); - ret = cbr_bit_allocation(s); - while (ret) { - /* fallback 1: disable channel coupling */ - if (s->cpl_on) { - s->cpl_on = 0; - compute_coupling_strategy(s); - s->compute_rematrixing_strategy(s); - apply_rematrixing(s); - process_exponents(s); - ret = compute_bit_allocation(s); - continue; - } - - /* fallback 2: downgrade exponents */ - if (!downgrade_exponents(s)) { - extract_exponents(s); - encode_exponents(s); - group_exponents(s); - ret = compute_bit_allocation(s); - continue; - } - - /* fallbacks were not enough... */ - break; - } - - return ret; + return cbr_bit_allocation(s); } From 668afae438ec8502517abb1c001b984c649e5e95 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 27 Jun 2011 07:46:27 -0400 Subject: [PATCH 097/780] ac3enc: merge log2_tab() into normalize_samples() --- libavcodec/ac3enc_fixed.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index 0620a6ac1a..32ff405247 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -71,19 +71,6 @@ void AC3_NAME(apply_window)(DSPContext *dsp, int16_t *output, } -/** - * Calculate the log2() of the maximum absolute value in an array. - * @param tab input array - * @param n number of values in the array - * @return log2(max(abs(tab[]))) - */ -static int log2_tab(AC3EncodeContext *s, int16_t *src, int len) -{ - int v = s->ac3dsp.ac3_max_msb_abs_int16(src, len); - return av_log2(v); -} - - /** * Normalize the input samples to use the maximum available precision. * This assumes signed 16-bit input samples. @@ -92,7 +79,8 @@ static int log2_tab(AC3EncodeContext *s, int16_t *src, int len) */ int AC3_NAME(normalize_samples)(AC3EncodeContext *s) { - int v = 14 - log2_tab(s, s->windowed_samples, AC3_WINDOW_SIZE); + int v = s->ac3dsp.ac3_max_msb_abs_int16(s->windowed_samples, AC3_WINDOW_SIZE); + v = 14 - av_log2(v); if (v > 0) s->ac3dsp.ac3_lshift_int16(s->windowed_samples, AC3_WINDOW_SIZE, v); /* +6 to right-shift from 31-bit to 25-bit */ From 8683c6a638f2e323d11b520c5e130b46b1eb1eda Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 26 Jun 2011 23:58:19 -0400 Subject: [PATCH 098/780] ac3enc: move ff_ac3_encode_frame() to ac3enc_template.c This avoids using function pointers for quite a few small functions, most of which just call DSP functions. --- libavcodec/ac3enc.c | 82 ++++-------------------------------- libavcodec/ac3enc.h | 58 +++++++++---------------- libavcodec/ac3enc_fixed.c | 11 +++-- libavcodec/ac3enc_float.c | 19 ++++++--- libavcodec/ac3enc_template.c | 78 ++++++++++++++++++++++++++++++---- libavcodec/eac3enc.c | 2 +- 6 files changed, 119 insertions(+), 131 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 3fbbbd0991..44dfce80e2 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -177,7 +177,7 @@ static const int8_t ac3_coupling_start_tab[6][3][19] = { * Adjust the frame size to make the average bit rate match the target bit rate. * This is only needed for 11025, 22050, and 44100 sample rates or any E-AC-3. */ -static void adjust_frame_size(AC3EncodeContext *s) +void ff_ac3_adjust_frame_size(AC3EncodeContext *s) { while (s->bits_written >= s->bit_rate && s->samples_written >= s->sample_rate) { s->bits_written -= s->bit_rate; @@ -190,7 +190,7 @@ static void adjust_frame_size(AC3EncodeContext *s) } -static void compute_coupling_strategy(AC3EncodeContext *s) +void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) { int blk, ch; int got_cpl_snr; @@ -254,7 +254,7 @@ static void compute_coupling_strategy(AC3EncodeContext *s) /** * Apply stereo rematrixing to coefficients based on rematrixing flags. */ -static void apply_rematrixing(AC3EncodeContext *s) +void ff_ac3_apply_rematrixing(AC3EncodeContext *s) { int nb_coefs; int blk, bnd, i; @@ -570,7 +570,7 @@ static void group_exponents(AC3EncodeContext *s) * Extract exponents from MDCT coefficients, calculate exponent strategies, * and encode final exponents. */ -static void process_exponents(AC3EncodeContext *s) +void ff_ac3_process_exponents(AC3EncodeContext *s) { extract_exponents(s); @@ -1028,7 +1028,7 @@ static int cbr_bit_allocation(AC3EncodeContext *s) * frame size. Output is the SNR offset and a set of bit allocation pointers * used to quantize the mantissas. */ -static int compute_bit_allocation(AC3EncodeContext *s) +int ff_ac3_compute_bit_allocation(AC3EncodeContext *s) { count_frame_bits(s); @@ -1163,7 +1163,7 @@ static void quantize_mantissas_blk_ch(AC3Mant *s, int32_t *fixed_coef, /** * Quantize mantissas using coefficients, exponents, and bit allocation pointers. */ -static void quantize_mantissas(AC3EncodeContext *s) +void ff_ac3_quantize_mantissas(AC3EncodeContext *s) { int blk, ch, ch0=0, got_cpl; @@ -1522,7 +1522,7 @@ static void output_frame_end(AC3EncodeContext *s) /** * Write the frame to the output bitstream. */ -static void output_frame(AC3EncodeContext *s, unsigned char *frame) +void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame) { int blk; @@ -1691,7 +1691,7 @@ static void validate_mix_level(void *log_ctx, const char *opt_name, * Validate metadata options as set by AVOption system. * These values can optionally be changed per-frame. */ -static int validate_metadata(AVCodecContext *avctx) +int ff_ac3_validate_metadata(AVCodecContext *avctx) { AC3EncodeContext *s = avctx->priv_data; AC3EncOptions *opt = &s->options; @@ -1800,57 +1800,6 @@ static int validate_metadata(AVCodecContext *avctx) } -/** - * Encode a single AC-3 frame. - */ -int ff_ac3_encode_frame(AVCodecContext *avctx, unsigned char *frame, - int buf_size, void *data) -{ - AC3EncodeContext *s = avctx->priv_data; - const SampleType *samples = data; - int ret; - - if (!s->eac3 && s->options.allow_per_frame_metadata) { - ret = validate_metadata(avctx); - if (ret) - return ret; - } - - if (s->bit_alloc.sr_code == 1 || s->eac3) - adjust_frame_size(s); - - s->deinterleave_input_samples(s, samples); - - s->apply_mdct(s); - - s->scale_coefficients(s); - - s->cpl_on = s->cpl_enabled; - compute_coupling_strategy(s); - - if (s->cpl_on) - s->apply_channel_coupling(s); - - s->compute_rematrixing_strategy(s); - - apply_rematrixing(s); - - process_exponents(s); - - ret = compute_bit_allocation(s); - if (ret) { - av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n"); - return ret; - } - - quantize_mantissas(s); - - output_frame(s, frame); - - return s->frame_size; -} - - /** * Finalize encoding and free any memory allocated by the encoder. */ @@ -2047,7 +1996,7 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s) } if (!s->eac3) { - ret = validate_metadata(avctx); + ret = ff_ac3_validate_metadata(avctx); if (ret) return ret; } @@ -2273,24 +2222,11 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) if (CONFIG_AC3_FIXED_ENCODER && s->fixed_point) { s->mdct_end = ff_ac3_fixed_mdct_end; s->mdct_init = ff_ac3_fixed_mdct_init; - s->apply_window = ff_ac3_fixed_apply_window; - s->normalize_samples = ff_ac3_fixed_normalize_samples; - s->scale_coefficients = ff_ac3_fixed_scale_coefficients; s->allocate_sample_buffers = ff_ac3_fixed_allocate_sample_buffers; - s->deinterleave_input_samples = ff_ac3_fixed_deinterleave_input_samples; - s->apply_mdct = ff_ac3_fixed_apply_mdct; - s->apply_channel_coupling = ff_ac3_fixed_apply_channel_coupling; - s->compute_rematrixing_strategy = ff_ac3_fixed_compute_rematrixing_strategy; } else if (CONFIG_AC3_ENCODER || CONFIG_EAC3_ENCODER) { s->mdct_end = ff_ac3_float_mdct_end; s->mdct_init = ff_ac3_float_mdct_init; - s->apply_window = ff_ac3_float_apply_window; - s->scale_coefficients = ff_ac3_float_scale_coefficients; s->allocate_sample_buffers = ff_ac3_float_allocate_sample_buffers; - s->deinterleave_input_samples = ff_ac3_float_deinterleave_input_samples; - s->apply_mdct = ff_ac3_float_apply_mdct; - s->apply_channel_coupling = ff_ac3_float_apply_channel_coupling; - s->compute_rematrixing_strategy = ff_ac3_float_compute_rematrixing_strategy; } if (CONFIG_EAC3_ENCODER && s->eac3) s->output_frame_header = ff_eac3_output_frame_header; diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 01abe94e0d..be62656650 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -224,19 +224,9 @@ typedef struct AC3EncodeContext { /* fixed vs. float function pointers */ void (*mdct_end)(AC3MDCTContext *mdct); int (*mdct_init)(AVCodecContext *avctx, AC3MDCTContext *mdct, int nbits); - void (*apply_window)(DSPContext *dsp, SampleType *output, - const SampleType *input, const SampleType *window, - unsigned int len); - int (*normalize_samples)(struct AC3EncodeContext *s); - void (*scale_coefficients)(struct AC3EncodeContext *s); /* fixed vs. float templated function pointers */ int (*allocate_sample_buffers)(struct AC3EncodeContext *s); - void (*deinterleave_input_samples)(struct AC3EncodeContext *s, - const SampleType *samples); - void (*apply_mdct)(struct AC3EncodeContext *s); - void (*apply_channel_coupling)(struct AC3EncodeContext *s); - void (*compute_rematrixing_strategy)(struct AC3EncodeContext *s); /* AC-3 vs. E-AC-3 function pointers */ void (*output_frame_header)(struct AC3EncodeContext *s); @@ -247,11 +237,24 @@ extern const int64_t ff_ac3_channel_layouts[19]; int ff_ac3_encode_init(AVCodecContext *avctx); -int ff_ac3_encode_frame(AVCodecContext *avctx, unsigned char *frame, - int buf_size, void *data); - int ff_ac3_encode_close(AVCodecContext *avctx); +int ff_ac3_validate_metadata(AVCodecContext *avctx); + +void ff_ac3_adjust_frame_size(AC3EncodeContext *s); + +void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s); + +void ff_ac3_apply_rematrixing(AC3EncodeContext *s); + +void ff_ac3_process_exponents(AC3EncodeContext *s); + +int ff_ac3_compute_bit_allocation(AC3EncodeContext *s); + +void ff_ac3_quantize_mantissas(AC3EncodeContext *s); + +void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame); + /* prototypes for functions in ac3enc_fixed.c and ac3enc_float.c */ @@ -263,36 +266,15 @@ int ff_ac3_fixed_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, int ff_ac3_float_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, int nbits); -void ff_ac3_fixed_apply_window(DSPContext *dsp, SampleType *output, - const SampleType *input, - const SampleType *window, unsigned int len); -void ff_ac3_float_apply_window(DSPContext *dsp, SampleType *output, - const SampleType *input, - const SampleType *window, unsigned int len); - -int ff_ac3_fixed_normalize_samples(AC3EncodeContext *s); - -void ff_ac3_fixed_scale_coefficients(AC3EncodeContext *s); -void ff_ac3_float_scale_coefficients(AC3EncodeContext *s); - /* prototypes for functions in ac3enc_template.c */ int ff_ac3_fixed_allocate_sample_buffers(AC3EncodeContext *s); int ff_ac3_float_allocate_sample_buffers(AC3EncodeContext *s); -void ff_ac3_fixed_deinterleave_input_samples(AC3EncodeContext *s, - const SampleType *samples); -void ff_ac3_float_deinterleave_input_samples(AC3EncodeContext *s, - const SampleType *samples); - -void ff_ac3_fixed_apply_mdct(AC3EncodeContext *s); -void ff_ac3_float_apply_mdct(AC3EncodeContext *s); - -void ff_ac3_fixed_apply_channel_coupling(AC3EncodeContext *s); -void ff_ac3_float_apply_channel_coupling(AC3EncodeContext *s); - -void ff_ac3_fixed_compute_rematrixing_strategy(AC3EncodeContext *s); -void ff_ac3_float_compute_rematrixing_strategy(AC3EncodeContext *s); +int ff_ac3_fixed_encode_frame(AVCodecContext *avctx, unsigned char *frame, + int buf_size, void *data); +int ff_ac3_float_encode_frame(AVCodecContext *avctx, unsigned char *frame, + int buf_size, void *data); #endif /* AVCODEC_AC3ENC_H */ diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index 32ff405247..d55720eb80 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -63,9 +63,8 @@ av_cold int AC3_NAME(mdct_init)(AVCodecContext *avctx, AC3MDCTContext *mdct, /** * Apply KBD window to input samples prior to MDCT. */ -void AC3_NAME(apply_window)(DSPContext *dsp, int16_t *output, - const int16_t *input, const int16_t *window, - unsigned int len) +static void apply_window(DSPContext *dsp, int16_t *output, const int16_t *input, + const int16_t *window, unsigned int len) { dsp->apply_window_int16(output, input, window, len); } @@ -77,7 +76,7 @@ void AC3_NAME(apply_window)(DSPContext *dsp, int16_t *output, * * @return exponent shift */ -int AC3_NAME(normalize_samples)(AC3EncodeContext *s) +static int normalize_samples(AC3EncodeContext *s) { int v = s->ac3dsp.ac3_max_msb_abs_int16(s->windowed_samples, AC3_WINDOW_SIZE); v = 14 - av_log2(v); @@ -91,7 +90,7 @@ int AC3_NAME(normalize_samples)(AC3EncodeContext *s) /** * Scale MDCT coefficients to 25-bit signed fixed-point. */ -void AC3_NAME(scale_coefficients)(AC3EncodeContext *s) +static void scale_coefficients(AC3EncodeContext *s) { int blk, ch; @@ -119,7 +118,7 @@ AVCodec ff_ac3_fixed_encoder = { CODEC_ID_AC3, sizeof(AC3EncodeContext), ac3_fixed_encode_init, - ff_ac3_encode_frame, + ff_ac3_fixed_encode_frame, ff_ac3_encode_close, NULL, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 43fbb954d6..12d6b19241 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -82,18 +82,27 @@ av_cold int ff_ac3_float_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, /** * Apply KBD window to input samples prior to MDCT. */ -void ff_ac3_float_apply_window(DSPContext *dsp, float *output, - const float *input, const float *window, - unsigned int len) +static void apply_window(DSPContext *dsp, float *output, const float *input, + const float *window, unsigned int len) { dsp->vector_fmul(output, input, window, len); } +/** + * Normalize the input samples. + * Not needed for the floating-point encoder. + */ +static int normalize_samples(AC3EncodeContext *s) +{ + return 0; +} + + /** * Scale MDCT coefficients from float to 24-bit fixed-point. */ -void ff_ac3_float_scale_coefficients(AC3EncodeContext *s) +static void scale_coefficients(AC3EncodeContext *s) { int chan_size = AC3_MAX_COEFS * AC3_MAX_BLOCKS; s->ac3dsp.float_to_fixed24(s->fixed_coef_buffer + chan_size, @@ -109,7 +118,7 @@ AVCodec ff_ac3_encoder = { CODEC_ID_AC3, sizeof(AC3EncodeContext), ff_ac3_encode_init, - ff_ac3_encode_frame, + ff_ac3_float_encode_frame, ff_ac3_encode_close, NULL, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index f6248a82c9..85eea54a4a 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -31,6 +31,17 @@ #include "ac3enc.h" +/* prototypes for static functions in ac3enc_fixed.c and ac3enc_float.c */ + +static void scale_coefficients(AC3EncodeContext *s); + +static void apply_window(DSPContext *dsp, SampleType *output, + const SampleType *input, const SampleType *window, + unsigned int len); + +static int normalize_samples(AC3EncodeContext *s); + + int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s) { int ch; @@ -55,8 +66,8 @@ alloc_fail: * Deinterleave input samples. * Channels are reordered from Libav's default order to AC-3 order. */ -void AC3_NAME(deinterleave_input_samples)(AC3EncodeContext *s, - const SampleType *samples) +static void deinterleave_input_samples(AC3EncodeContext *s, + const SampleType *samples) { int ch, i; @@ -85,7 +96,7 @@ void AC3_NAME(deinterleave_input_samples)(AC3EncodeContext *s, * This applies the KBD window and normalizes the input to reduce precision * loss due to fixed-point calculations. */ -void AC3_NAME(apply_mdct)(AC3EncodeContext *s) +static void apply_mdct(AC3EncodeContext *s) { int blk, ch; @@ -94,11 +105,11 @@ void AC3_NAME(apply_mdct)(AC3EncodeContext *s) AC3Block *block = &s->blocks[blk]; const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE]; - s->apply_window(&s->dsp, s->windowed_samples, input_samples, - s->mdct->window, AC3_WINDOW_SIZE); + apply_window(&s->dsp, s->windowed_samples, input_samples, + s->mdct->window, AC3_WINDOW_SIZE); if (s->fixed_point) - block->coeff_shift[ch+1] = s->normalize_samples(s); + block->coeff_shift[ch+1] = normalize_samples(s); s->mdct->fft.mdct_calcw(&s->mdct->fft, block->mdct_coef[ch+1], s->windowed_samples); @@ -127,7 +138,7 @@ static inline float calc_cpl_coord(float energy_ch, float energy_cpl) * adaptive coupling strategy were to be implemented it might be useful * at that time to use coupling for the fixed-point encoder as well. */ -void AC3_NAME(apply_channel_coupling)(AC3EncodeContext *s) +static void apply_channel_coupling(AC3EncodeContext *s) { #if CONFIG_AC3ENC_FLOAT LOCAL_ALIGNED_16(float, cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]); @@ -339,7 +350,7 @@ void AC3_NAME(apply_channel_coupling)(AC3EncodeContext *s) /** * Determine rematrixing flags for each block and band. */ -void AC3_NAME(compute_rematrixing_strategy)(AC3EncodeContext *s) +static void compute_rematrixing_strategy(AC3EncodeContext *s) { int nb_coefs; int blk, bnd, i; @@ -397,3 +408,54 @@ void AC3_NAME(compute_rematrixing_strategy)(AC3EncodeContext *s) block0 = block; } } + + +/** + * Encode a single AC-3 frame. + */ +int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame, + int buf_size, void *data) +{ + AC3EncodeContext *s = avctx->priv_data; + const SampleType *samples = data; + int ret; + + if (!s->eac3 && s->options.allow_per_frame_metadata) { + ret = ff_ac3_validate_metadata(avctx); + if (ret) + return ret; + } + + if (s->bit_alloc.sr_code == 1 || s->eac3) + ff_ac3_adjust_frame_size(s); + + deinterleave_input_samples(s, samples); + + apply_mdct(s); + + scale_coefficients(s); + + s->cpl_on = s->cpl_enabled; + ff_ac3_compute_coupling_strategy(s); + + if (s->cpl_on) + apply_channel_coupling(s); + + compute_rematrixing_strategy(s); + + ff_ac3_apply_rematrixing(s); + + ff_ac3_process_exponents(s); + + ret = ff_ac3_compute_bit_allocation(s); + if (ret) { + av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n"); + return ret; + } + + ff_ac3_quantize_mantissas(s); + + ff_ac3_output_frame(s, frame); + + return s->frame_size; +} diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index d37acaf20b..f39b9f1925 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -145,7 +145,7 @@ AVCodec ff_eac3_encoder = { .id = CODEC_ID_EAC3, .priv_data_size = sizeof(AC3EncodeContext), .init = ff_ac3_encode_init, - .encode = ff_ac3_encode_frame, + .encode = ff_ac3_float_encode_frame, .close = ff_ac3_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52 E-AC-3"), From 0d994b2f45c08794899057ee7ca54f48218c0a53 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 26 Jun 2011 15:52:00 -0700 Subject: [PATCH 099/780] swscale: don't use planar output functions to write to NV12/21. This prevents a crash when converting to NV12/21 without the bitexact flags enabled. --- libswscale/x86/swscale_template.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 79bf2a4c8c..f6e970832d 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -2202,7 +2202,8 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) enum PixelFormat srcFormat = c->srcFormat, dstFormat = c->dstFormat; - if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat)) { + if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && + dstFormat != PIX_FMT_NV12 && dstFormat != PIX_FMT_NV21) { if (!(c->flags & SWS_BITEXACT)) { if (c->flags & SWS_ACCURATE_RND) { c->yuv2yuv1 = RENAME(yuv2yuv1_ar ); From dc179ec81902e3c9d327f9e818454f2849308000 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 16 Jun 2011 12:04:24 -0400 Subject: [PATCH 100/780] swscale: split yuv2packedX_altivec in smaller functions. This will likely lead to a considerable performance boost, since it removes a branch from the inner loop. Part of the Great Evil Plan to simplify swscale. --- libswscale/ppc/swscale_altivec.c | 14 +++++++++----- libswscale/ppc/yuv2rgb_altivec.c | 28 ++++++++++++++++++++++++---- libswscale/ppc/yuv2rgb_altivec.h | 18 +++++++++++++----- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 47fe54c088..7161fe7963 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -414,10 +414,14 @@ void ff_sws_init_swScale_altivec(SwsContext *c) /* The following list of supported dstFormat values should * match what's found in the body of ff_yuv2packedX_altivec() */ - if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->alpPixBuf && - (c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA || - c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 || - c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)) { - c->yuv2packedX = ff_yuv2packedX_altivec; + if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->alpPixBuf) { + switch (c->dstFormat) { + case PIX_FMT_ABGR: c->yuv2packedX = ff_yuv2abgr_X_altivec; break; + case PIX_FMT_BGRA: c->yuv2packedX = ff_yuv2bgra_X_altivec; break; + case PIX_FMT_ARGB: c->yuv2packedX = ff_yuv2argb_X_altivec; break; + case PIX_FMT_RGBA: c->yuv2packedX = ff_yuv2rgba_X_altivec; break; + case PIX_FMT_BGR24: c->yuv2packedX = ff_yuv2bgr24_X_altivec; break; + case PIX_FMT_RGB24: c->yuv2packedX = ff_yuv2rgb24_X_altivec; break; } + } } diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c index 476db22489..73c02e9494 100644 --- a/libswscale/ppc/yuv2rgb_altivec.c +++ b/libswscale/ppc/yuv2rgb_altivec.c @@ -626,13 +626,13 @@ void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4], int b } -void +static av_always_inline void ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, - int dstW, int dstY) + int dstW, int dstY, enum PixelFormat target) { int i,j; vector signed short X,X0,X1,Y0,U0,V0,Y1,U1,V1,U,V; @@ -706,7 +706,7 @@ ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter, G = vec_packclp (G0,G1); B = vec_packclp (B0,B1); - switch(c->dstFormat) { + switch(target) { case PIX_FMT_ABGR: out_abgr (R,G,B,out); break; case PIX_FMT_BGRA: out_bgra (R,G,B,out); break; case PIX_FMT_RGBA: out_rgba (R,G,B,out); break; @@ -785,7 +785,7 @@ ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter, B = vec_packclp (B0,B1); nout = (vector unsigned char *)scratch; - switch(c->dstFormat) { + switch(target) { case PIX_FMT_ABGR: out_abgr (R,G,B,nout); break; case PIX_FMT_BGRA: out_bgra (R,G,B,nout); break; case PIX_FMT_RGBA: out_rgba (R,G,B,nout); break; @@ -803,3 +803,23 @@ ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter, } } + +#define YUV2PACKEDX_WRAPPER(suffix, pixfmt) \ +void ff_yuv2 ## suffix ## _X_altivec(SwsContext *c, const int16_t *lumFilter, \ + const int16_t **lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, const int16_t **chrUSrc, \ + const int16_t **chrVSrc, int chrFilterSize, \ + const int16_t **alpSrc, uint8_t *dest, \ + int dstW, int dstY) \ +{ \ + ff_yuv2packedX_altivec(c, lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ + alpSrc, dest, dstW, dstY, pixfmt); \ +} + +YUV2PACKEDX_WRAPPER(abgr, PIX_FMT_ABGR); +YUV2PACKEDX_WRAPPER(bgra, PIX_FMT_BGRA); +YUV2PACKEDX_WRAPPER(argb, PIX_FMT_ARGB); +YUV2PACKEDX_WRAPPER(rgba, PIX_FMT_RGBA); +YUV2PACKEDX_WRAPPER(rgb24, PIX_FMT_RGB24); +YUV2PACKEDX_WRAPPER(bgr24, PIX_FMT_BGR24); diff --git a/libswscale/ppc/yuv2rgb_altivec.h b/libswscale/ppc/yuv2rgb_altivec.h index b54a856905..b809fe13fe 100644 --- a/libswscale/ppc/yuv2rgb_altivec.h +++ b/libswscale/ppc/yuv2rgb_altivec.h @@ -24,11 +24,19 @@ #ifndef PPC_YUV2RGB_ALTIVEC_H #define PPC_YUV2RGB_ALTIVEC_H 1 -void ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, +#define YUV2PACKEDX_HEADER(suffix) \ +void ff_yuv2 ## suffix ## _X_altivec(SwsContext *c, const int16_t *lumFilter, \ + const int16_t **lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, const int16_t **chrUSrc, \ + const int16_t **chrVSrc, int chrFilterSize, \ + const int16_t **alpSrc, uint8_t *dest, \ int dstW, int dstY); +YUV2PACKEDX_HEADER(abgr); +YUV2PACKEDX_HEADER(bgra); +YUV2PACKEDX_HEADER(argb); +YUV2PACKEDX_HEADER(rgba); +YUV2PACKEDX_HEADER(rgb24); +YUV2PACKEDX_HEADER(bgr24); + #endif /* PPC_YUV2RGB_ALTIVEC_H */ From 6fba14eecbc7849efc9951866103e21d99713d88 Mon Sep 17 00:00:00 2001 From: Ronald Bultje Date: Mon, 27 Jun 2011 18:10:03 -0700 Subject: [PATCH 101/780] swscale: split yuv2packed[12X]_c() remainders into small functions. This is part of the Great Evil Plan to simplify swscale. --- libswscale/swscale.c | 698 +++++++++++++++++++++++++------------------ 1 file changed, 402 insertions(+), 296 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 731f1320b3..bbcb1974c5 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -885,53 +885,321 @@ YUV2PACKEDWRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE); YUV2PACKEDWRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE); //YUV2PACKEDWRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE); -#define YSCALE_YUV_2_RGBX_C(type,alpha) \ - for (i=0; i<(dstW>>1); i++) {\ - int j;\ - int Y1 = 1<<18;\ - int Y2 = 1<<18;\ - int U = 1<<18;\ - int V = 1<<18;\ - int av_unused A1, A2;\ - type av_unused *r, *b, *g;\ - const int i2= 2*i;\ - \ - for (j=0; j>=19;\ - Y2>>=19;\ - U >>=19;\ - V >>=19;\ - if ((Y1|Y2|U|V)&0x100) {\ - Y1 = av_clip_uint8(Y1); \ - Y2 = av_clip_uint8(Y2); \ - U = av_clip_uint8(U); \ - V = av_clip_uint8(V); \ - }\ - if (alpha) {\ - A1 = 1<<18;\ - A2 = 1<<18;\ - for (j=0; j>=19;\ - A2>>=19;\ - if ((A1|A2)&0x100) {\ - A1 = av_clip_uint8(A1); \ - A2 = av_clip_uint8(A2); \ - }\ - }\ - /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/\ - r = (type *)c->table_rV[V]; \ - g = (type *)(c->table_gU[U] + c->table_gV[V]); \ - b = (type *)c->table_bU[U]; +static av_always_inline void +yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2, + int U, int V, int A1, int A2, + const void *_r, const void *_g, const void *_b, int y, + enum PixelFormat target, int hasAlpha) +{ + if (target == PIX_FMT_ARGB || target == PIX_FMT_RGBA || + target == PIX_FMT_ABGR || target == PIX_FMT_BGRA) { + uint32_t *dest = (uint32_t *) _dest; + const uint32_t *r = (const uint32_t *) _r; + const uint32_t *g = (const uint32_t *) _g; + const uint32_t *b = (const uint32_t *) _b; + +#if CONFIG_SMALL + int sh = hasAlpha ? ((fmt == PIX_FMT_RGB32_1 || fmt == PIX_FMT_BGR32_1) ? 0 : 24) : 0; + + dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0); + dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0); +#else + if (hasAlpha) { + int sh = (target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24; + + dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh); + dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh); + } else { + dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1]; + dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2]; + } +#endif + } else if (target == PIX_FMT_RGB24 || target == PIX_FMT_BGR24) { + uint8_t *dest = (uint8_t *) _dest; + const uint8_t *r = (const uint8_t *) _r; + const uint8_t *g = (const uint8_t *) _g; + const uint8_t *b = (const uint8_t *) _b; + +#define r_b ((target == PIX_FMT_RGB24) ? r : b) +#define b_r ((target == PIX_FMT_RGB24) ? b : r) + dest[i * 6 + 0] = r_b[Y1]; + dest[i * 6 + 1] = g[Y1]; + dest[i * 6 + 2] = b_r[Y1]; + dest[i * 6 + 3] = r_b[Y2]; + dest[i * 6 + 4] = g[Y2]; + dest[i * 6 + 5] = b_r[Y2]; +#undef r_b +#undef b_r + } else if (target == PIX_FMT_RGB565 || target == PIX_FMT_BGR565 || + target == PIX_FMT_RGB555 || target == PIX_FMT_BGR555 || + target == PIX_FMT_RGB444 || target == PIX_FMT_BGR444) { + uint16_t *dest = (uint16_t *) _dest; + const uint16_t *r = (const uint16_t *) _r; + const uint16_t *g = (const uint16_t *) _g; + const uint16_t *b = (const uint16_t *) _b; + int dr1, dg1, db1, dr2, dg2, db2; + + if (target == PIX_FMT_RGB565 || target == PIX_FMT_BGR565) { + dr1 = dither_2x2_8[ y & 1 ][0]; + dg1 = dither_2x2_4[ y & 1 ][0]; + db1 = dither_2x2_8[(y & 1) ^ 1][0]; + dr2 = dither_2x2_8[ y & 1 ][1]; + dg2 = dither_2x2_4[ y & 1 ][1]; + db2 = dither_2x2_8[(y & 1) ^ 1][1]; + } else if (target == PIX_FMT_RGB555 || target == PIX_FMT_BGR555) { + dr1 = dither_2x2_8[ y & 1 ][0]; + dg1 = dither_2x2_8[ y & 1 ][1]; + db1 = dither_2x2_8[(y & 1) ^ 1][0]; + dr2 = dither_2x2_8[ y & 1 ][1]; + dg2 = dither_2x2_8[ y & 1 ][0]; + db2 = dither_2x2_8[(y & 1) ^ 1][1]; + } else { + dr1 = dither_4x4_16[ y & 3 ][0]; + dg1 = dither_4x4_16[ y & 3 ][1]; + db1 = dither_4x4_16[(y & 3) ^ 3][0]; + dr2 = dither_4x4_16[ y & 3 ][1]; + dg2 = dither_4x4_16[ y & 3 ][0]; + db2 = dither_4x4_16[(y & 3) ^ 3][1]; + } + + dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1]; + dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]; + } else /* 8/4-bit */ { + uint8_t *dest = (uint8_t *) _dest; + const uint8_t *r = (const uint8_t *) _r; + const uint8_t *g = (const uint8_t *) _g; + const uint8_t *b = (const uint8_t *) _b; + int dr1, dg1, db1, dr2, dg2, db2; + + if (target == PIX_FMT_RGB8 || target == PIX_FMT_BGR8) { + const uint8_t * const d64 = dither_8x8_73[y & 7]; + const uint8_t * const d32 = dither_8x8_32[y & 7]; + dr1 = dg1 = d32[(i * 2 + 0) & 7]; + db1 = d64[(i * 2 + 0) & 7]; + dr2 = dg2 = d32[(i * 2 + 1) & 7]; + db2 = d64[(i * 2 + 1) & 7]; + } else { + const uint8_t * const d64 = dither_8x8_73 [y & 7]; + const uint8_t * const d128 = dither_8x8_220[y & 7]; + dr1 = db1 = d128[(i * 2 + 0) & 7]; + dg1 = d64[(i * 2 + 0) & 7]; + dr2 = db2 = d128[(i * 2 + 1) & 7]; + dg2 = d64[(i * 2 + 1) & 7]; + } + + if (target == PIX_FMT_RGB4 || target == PIX_FMT_BGR4) { + dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] + + ((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4); + } else { + dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1]; + dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]; + } + } +} + +static av_always_inline void +yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, int dstW, + int y, enum PixelFormat target, int hasAlpha) +{ + int i; + + for (i = 0; i < (dstW >> 1); i++) { + int j; + int Y1 = 1 << 18; + int Y2 = 1 << 18; + int U = 1 << 18; + int V = 1 << 18; + int av_unused A1, A2; + const void *r, *g, *b; + + for (j = 0; j < lumFilterSize; j++) { + Y1 += lumSrc[j][i * 2] * lumFilter[j]; + Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j]; + } + for (j = 0; j < chrFilterSize; j++) { + U += chrUSrc[j][i] * chrFilter[j]; + V += chrVSrc[j][i] * chrFilter[j]; + } + Y1 >>= 19; + Y2 >>= 19; + U >>= 19; + V >>= 19; + if ((Y1 | Y2 | U | V) & 0x100) { + Y1 = av_clip_uint8(Y1); + Y2 = av_clip_uint8(Y2); + U = av_clip_uint8(U); + V = av_clip_uint8(V); + } + if (hasAlpha) {\ + A1 = 1 << 18; + A2 = 1 << 18; + for (j = 0; j < lumFilterSize; j++) { + A1 += alpSrc[j][i * 2 ] * lumFilter[j]; + A2 += alpSrc[j][i * 2 + 1] * lumFilter[j]; + } + A1 >>= 19; + A2 >>= 19; + if ((A1 | A2) & 0x100) { + A1 = av_clip_uint8(A1); + A2 = av_clip_uint8(A2); + } + } + + /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/ + r = c->table_rV[V]; + g = (c->table_gU[U] + c->table_gV[V]); + b = c->table_bU[U]; + + yuv2rgb_write(dest, i, Y1, Y2, U, V, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0, + r, g, b, y, target, hasAlpha); + } +} + +static av_always_inline void +yuv2rgb_2_c_template(SwsContext *c, const uint16_t *buf0, + const uint16_t *buf1, const uint16_t *ubuf0, + const uint16_t *ubuf1, const uint16_t *vbuf0, + const uint16_t *vbuf1, const uint16_t *abuf0, + const uint16_t *abuf1, uint8_t *dest, int dstW, + int yalpha, int uvalpha, int y, + enum PixelFormat target, int hasAlpha) +{ + int yalpha1 = 4095 - yalpha; + int uvalpha1 = 4095 - uvalpha; + int i; + + for (i = 0; i < (dstW >> 1); i++) { + int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19; + int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19; + int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19; + int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19; + int A1, A2; + const void *r = c->table_rV[V], + *g = (c->table_gU[U] + c->table_gV[V]), + *b = c->table_bU[U]; + + if (hasAlpha) { + A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 19; + A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 19; + } + + yuv2rgb_write(dest, i, Y1, Y2, U, V, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0, + r, g, b, y, target, hasAlpha); + } +} + +static av_always_inline void +yuv2rgb_1_c_template(SwsContext *c, const uint16_t *buf0, + const uint16_t *ubuf0, const uint16_t *ubuf1, + const uint16_t *vbuf0, const uint16_t *vbuf1, + const uint16_t *abuf0, uint8_t *dest, int dstW, + int uvalpha, enum PixelFormat dstFormat, + int flags, int y, enum PixelFormat target, + int hasAlpha) +{ + int i; + + if (uvalpha < 2048) { + for (i = 0; i < (dstW >> 1); i++) { + int Y1 = buf0[i * 2] >> 7; + int Y2 = buf0[i * 2 + 1] >> 7; + int U = ubuf1[i] >> 7; + int V = vbuf1[i] >> 7; + int A1, A2; + const void *r = c->table_rV[V], + *g = (c->table_gU[U] + c->table_gV[V]), + *b = c->table_bU[U]; + + if (hasAlpha) { + A1 = abuf0[i * 2 ] >> 7; + A2 = abuf0[i * 2 + 1] >> 7; + } + + yuv2rgb_write(dest, i, Y1, Y2, U, V, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0, + r, g, b, y, target, hasAlpha); + } + } else { + for (i = 0; i < (dstW >> 1); i++) { + int Y1 = buf0[i * 2] >> 7; + int Y2 = buf0[i * 2 + 1] >> 7; + int U = (ubuf0[i] + ubuf1[i]) >> 8; + int V = (vbuf0[i] + vbuf1[i]) >> 8; + int A1, A2; + const void *r = c->table_rV[V], + *g = (c->table_gU[U] + c->table_gV[V]), + *b = c->table_bU[U]; + + if (hasAlpha) { + A1 = abuf0[i * 2 ] >> 7; + A2 = abuf0[i * 2 + 1] >> 7; + } + + yuv2rgb_write(dest, i, Y1, Y2, U, V, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0, + r, g, b, y, target, hasAlpha); + } + } +} + +#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \ +static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ + const int16_t **lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, const int16_t **chrUSrc, \ + const int16_t **chrVSrc, int chrFilterSize, \ + const int16_t **alpSrc, uint8_t *dest, int dstW, \ + int y) \ +{ \ + name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ + alpSrc, dest, dstW, y, fmt, hasAlpha); \ +} \ + \ +static void name ## ext ## _2_c(SwsContext *c, const uint16_t *buf0, \ + const uint16_t *buf1, const uint16_t *ubuf0, \ + const uint16_t *ubuf1, const uint16_t *vbuf0, \ + const uint16_t *vbuf1, const uint16_t *abuf0, \ + const uint16_t *abuf1, uint8_t *dest, int dstW, \ + int yalpha, int uvalpha, int y) \ +{ \ + name ## base ## _2_c_template(c, buf0, buf1, ubuf0, ubuf1, \ + vbuf0, vbuf1, abuf0, abuf1, \ + dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \ +} \ + \ +static void name ## ext ## _1_c(SwsContext *c, const uint16_t *buf0, \ + const uint16_t *ubuf0, const uint16_t *ubuf1, \ + const uint16_t *vbuf0, const uint16_t *vbuf1, \ + const uint16_t *abuf0, uint8_t *dest, int dstW, \ + int uvalpha, enum PixelFormat dstFormat, \ + int flags, int y) \ +{ \ + name ## base ## _1_c_template(c, buf0, ubuf0, ubuf1, vbuf0, \ + vbuf1, abuf0, dest, dstW, uvalpha, \ + dstFormat, flags, y, fmt, hasAlpha); \ +} + +#if CONFIG_SMALL +YUV2RGBWRAPPER(yuv2rgb,, 32_1, PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); +YUV2RGBWRAPPER(yuv2rgb,, 32, PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); +#else +#if CONFIG_SWSCALE_ALPHA +YUV2RGBWRAPPER(yuv2rgb,, a32_1, PIX_FMT_RGB32_1, 1); +YUV2RGBWRAPPER(yuv2rgb,, a32, PIX_FMT_RGB32, 1); +#endif +YUV2RGBWRAPPER(yuv2rgb,, x32_1, PIX_FMT_RGB32_1, 0); +YUV2RGBWRAPPER(yuv2rgb,, x32, PIX_FMT_RGB32, 0); +#endif +YUV2RGBWRAPPER(yuv2, rgb, rgb24, PIX_FMT_RGB24, 0); +YUV2RGBWRAPPER(yuv2, rgb, bgr24, PIX_FMT_BGR24, 0); +YUV2RGBWRAPPER(yuv2rgb,, 16, PIX_FMT_RGB565, 0); +YUV2RGBWRAPPER(yuv2rgb,, 15, PIX_FMT_RGB555, 0); +YUV2RGBWRAPPER(yuv2rgb,, 12, PIX_FMT_RGB444, 0); +YUV2RGBWRAPPER(yuv2rgb,, 8, PIX_FMT_RGB8, 0); +YUV2RGBWRAPPER(yuv2rgb,, 4, PIX_FMT_RGB4, 0); +YUV2RGBWRAPPER(yuv2rgb,, 4b, PIX_FMT_RGB4_BYTE, 0); #define YSCALE_YUV_2_RGBX_FULL_C(rnd,alpha) \ for (i=0; i>1); i++) { \ - const int i2= 2*i; \ - int Y1= (buf0[i2 ]*yalpha1+buf1[i2 ]*yalpha)>>19; \ - int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>19; \ - int U= (ubuf0[i]*uvalpha1+ubuf1[i]*uvalpha)>>19; \ - int V= (vbuf0[i]*uvalpha1+vbuf1[i]*uvalpha)>>19; \ - type av_unused *r, *b, *g; \ - int av_unused A1, A2; \ - if (alpha) {\ - A1= (abuf0[i2 ]*yalpha1+abuf1[i2 ]*yalpha)>>19; \ - A2= (abuf0[i2+1]*yalpha1+abuf1[i2+1]*yalpha)>>19; \ - }\ - r = (type *)c->table_rV[V];\ - g = (type *)(c->table_gU[U] + c->table_gV[V]);\ - b = (type *)c->table_bU[U]; - -#define YSCALE_YUV_2_RGB1_C(type,alpha) \ - for (i=0; i<(dstW>>1); i++) {\ - const int i2= 2*i;\ - int Y1= buf0[i2 ]>>7;\ - int Y2= buf0[i2+1]>>7;\ - int U= (ubuf1[i])>>7;\ - int V= (vbuf1[i])>>7;\ - type av_unused *r, *b, *g;\ - int av_unused A1, A2;\ - if (alpha) {\ - A1= abuf0[i2 ]>>7;\ - A2= abuf0[i2+1]>>7;\ - }\ - r = (type *)c->table_rV[V];\ - g = (type *)(c->table_gU[U] + c->table_gV[V]);\ - b = (type *)c->table_bU[U]; - -#define YSCALE_YUV_2_RGB1B_C(type,alpha) \ - for (i=0; i<(dstW>>1); i++) {\ - const int i2= 2*i;\ - int Y1= buf0[i2 ]>>7;\ - int Y2= buf0[i2+1]>>7;\ - int U= (ubuf0[i] + ubuf1[i])>>8;\ - int V= (vbuf0[i] + vbuf1[i])>>8;\ - type av_unused *r, *b, *g;\ - int av_unused A1, A2;\ - if (alpha) {\ - A1= abuf0[i2 ]>>7;\ - A2= abuf0[i2+1]>>7;\ - }\ - r = (type *)c->table_rV[V];\ - g = (type *)(c->table_gU[U] + c->table_gV[V]);\ - b = (type *)c->table_bU[U]; - -#define YSCALE_YUV_2_ANYRGB_C(func)\ - switch(c->dstFormat) {\ - case PIX_FMT_RGBA:\ - case PIX_FMT_BGRA:\ - if (CONFIG_SMALL) {\ - int needAlpha = CONFIG_SWSCALE_ALPHA && c->alpPixBuf;\ - func(uint32_t,needAlpha)\ - ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] + (needAlpha ? (A1<<24) : 0);\ - ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] + (needAlpha ? (A2<<24) : 0);\ - }\ - } else {\ - if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {\ - func(uint32_t,1)\ - ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] + (A1<<24);\ - ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] + (A2<<24);\ - }\ - } else {\ - func(uint32_t,0)\ - ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\ - ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\ - }\ - }\ - }\ - break;\ - case PIX_FMT_ARGB:\ - case PIX_FMT_ABGR:\ - if (CONFIG_SMALL) {\ - int needAlpha = CONFIG_SWSCALE_ALPHA && c->alpPixBuf;\ - func(uint32_t,needAlpha)\ - ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] + (needAlpha ? A1 : 0);\ - ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] + (needAlpha ? A2 : 0);\ - }\ - } else {\ - if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {\ - func(uint32_t,1)\ - ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] + A1;\ - ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] + A2;\ - }\ - } else {\ - func(uint32_t,0)\ - ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\ - ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\ - }\ - }\ - } \ - break;\ - case PIX_FMT_RGB24:\ - func(uint8_t,0)\ - ((uint8_t*)dest)[0]= r[Y1];\ - ((uint8_t*)dest)[1]= g[Y1];\ - ((uint8_t*)dest)[2]= b[Y1];\ - ((uint8_t*)dest)[3]= r[Y2];\ - ((uint8_t*)dest)[4]= g[Y2];\ - ((uint8_t*)dest)[5]= b[Y2];\ - dest+=6;\ - }\ - break;\ - case PIX_FMT_BGR24:\ - func(uint8_t,0)\ - ((uint8_t*)dest)[0]= b[Y1];\ - ((uint8_t*)dest)[1]= g[Y1];\ - ((uint8_t*)dest)[2]= r[Y1];\ - ((uint8_t*)dest)[3]= b[Y2];\ - ((uint8_t*)dest)[4]= g[Y2];\ - ((uint8_t*)dest)[5]= r[Y2];\ - dest+=6;\ - }\ - break;\ - case PIX_FMT_RGB565:\ - case PIX_FMT_BGR565:\ - {\ - const int dr1= dither_2x2_8[y&1 ][0];\ - const int dg1= dither_2x2_4[y&1 ][0];\ - const int db1= dither_2x2_8[(y&1)^1][0];\ - const int dr2= dither_2x2_8[y&1 ][1];\ - const int dg2= dither_2x2_4[y&1 ][1];\ - const int db2= dither_2x2_8[(y&1)^1][1];\ - func(uint16_t,0)\ - ((uint16_t*)dest)[i2+0]= r[Y1+dr1] + g[Y1+dg1] + b[Y1+db1];\ - ((uint16_t*)dest)[i2+1]= r[Y2+dr2] + g[Y2+dg2] + b[Y2+db2];\ - }\ - }\ - break;\ - case PIX_FMT_RGB555:\ - case PIX_FMT_BGR555:\ - {\ - const int dr1= dither_2x2_8[y&1 ][0];\ - const int dg1= dither_2x2_8[y&1 ][1];\ - const int db1= dither_2x2_8[(y&1)^1][0];\ - const int dr2= dither_2x2_8[y&1 ][1];\ - const int dg2= dither_2x2_8[y&1 ][0];\ - const int db2= dither_2x2_8[(y&1)^1][1];\ - func(uint16_t,0)\ - ((uint16_t*)dest)[i2+0]= r[Y1+dr1] + g[Y1+dg1] + b[Y1+db1];\ - ((uint16_t*)dest)[i2+1]= r[Y2+dr2] + g[Y2+dg2] + b[Y2+db2];\ - }\ - }\ - break;\ - case PIX_FMT_RGB444:\ - case PIX_FMT_BGR444:\ - {\ - const int dr1= dither_4x4_16[y&3 ][0];\ - const int dg1= dither_4x4_16[y&3 ][1];\ - const int db1= dither_4x4_16[(y&3)^3][0];\ - const int dr2= dither_4x4_16[y&3 ][1];\ - const int dg2= dither_4x4_16[y&3 ][0];\ - const int db2= dither_4x4_16[(y&3)^3][1];\ - func(uint16_t,0)\ - ((uint16_t*)dest)[i2+0]= r[Y1+dr1] + g[Y1+dg1] + b[Y1+db1];\ - ((uint16_t*)dest)[i2+1]= r[Y2+dr2] + g[Y2+dg2] + b[Y2+db2];\ - }\ - }\ - break;\ - case PIX_FMT_RGB8:\ - case PIX_FMT_BGR8:\ - {\ - const uint8_t * const d64= dither_8x8_73[y&7];\ - const uint8_t * const d32= dither_8x8_32[y&7];\ - func(uint8_t,0)\ - ((uint8_t*)dest)[i2+0]= r[Y1+d32[(i2+0)&7]] + g[Y1+d32[(i2+0)&7]] + b[Y1+d64[(i2+0)&7]];\ - ((uint8_t*)dest)[i2+1]= r[Y2+d32[(i2+1)&7]] + g[Y2+d32[(i2+1)&7]] + b[Y2+d64[(i2+1)&7]];\ - }\ - }\ - break;\ - case PIX_FMT_RGB4:\ - case PIX_FMT_BGR4:\ - {\ - const uint8_t * const d64= dither_8x8_73 [y&7];\ - const uint8_t * const d128=dither_8x8_220[y&7];\ - func(uint8_t,0)\ - ((uint8_t*)dest)[i]= r[Y1+d128[(i2+0)&7]] + g[Y1+d64[(i2+0)&7]] + b[Y1+d128[(i2+0)&7]]\ - + ((r[Y2+d128[(i2+1)&7]] + g[Y2+d64[(i2+1)&7]] + b[Y2+d128[(i2+1)&7]])<<4);\ - }\ - }\ - break;\ - case PIX_FMT_RGB4_BYTE:\ - case PIX_FMT_BGR4_BYTE:\ - {\ - const uint8_t * const d64= dither_8x8_73 [y&7];\ - const uint8_t * const d128=dither_8x8_220[y&7];\ - func(uint8_t,0)\ - ((uint8_t*)dest)[i2+0]= r[Y1+d128[(i2+0)&7]] + g[Y1+d64[(i2+0)&7]] + b[Y1+d128[(i2+0)&7]];\ - ((uint8_t*)dest)[i2+1]= r[Y2+d128[(i2+1)&7]] + g[Y2+d64[(i2+1)&7]] + b[Y2+d128[(i2+1)&7]];\ - }\ - }\ - break;\ - } - -static void yuv2packedX_c(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, int dstW, int y) -{ - int i; - YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGBX_C) -} - static void yuv2rgbX_c_full(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, @@ -1267,42 +1326,6 @@ static void yuv2rgbX_c_full(SwsContext *c, const int16_t *lumFilter, } } -/** - * vertical bilinear scale YV12 to RGB - */ -static void yuv2packed2_c(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, int dstW, - int yalpha, int uvalpha, int y) -{ - int yalpha1=4095- yalpha; - int uvalpha1=4095-uvalpha; - int i; - - YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C) -} - -/** - * YV12 to RGB without scaling or interpolating - */ -static void yuv2packed1_c(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, int dstW, - int uvalpha, enum PixelFormat dstFormat, - int flags, int y) -{ - int i; - - if (uvalpha < 2048) { - YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C) - } else { - YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C) - } -} - static av_always_inline void fillPlane(uint8_t* plane, int stride, int width, int height, int y, uint8_t val) @@ -2008,10 +2031,93 @@ find_c_packed_planar_out_funcs(SwsContext *c, *yuv2packed2 = yuv2bgr48be_2_c; *yuv2packedX = yuv2bgr48be_X_c; break; - default: - *yuv2packed1 = yuv2packed1_c; - *yuv2packed2 = yuv2packed2_c; - *yuv2packedX = yuv2packedX_c; + case PIX_FMT_RGB32: + case PIX_FMT_BGR32: +#if CONFIG_SMALL + *yuv2packed1 = yuv2rgb32_1_c; + *yuv2packed2 = yuv2rgb32_2_c; + *yuv2packedX = yuv2rgb32_X_c; +#else +#if CONFIG_SWSCALE_ALPHA + if (c->alpPixBuf) { + *yuv2packed1 = yuv2rgba32_1_c; + *yuv2packed2 = yuv2rgba32_2_c; + *yuv2packedX = yuv2rgba32_X_c; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + *yuv2packed1 = yuv2rgbx32_1_c; + *yuv2packed2 = yuv2rgbx32_2_c; + *yuv2packedX = yuv2rgbx32_X_c; + } +#endif /* !CONFIG_SMALL */ + break; + case PIX_FMT_RGB32_1: + case PIX_FMT_BGR32_1: +#if CONFIG_SMALL + *yuv2packed1 = yuv2rgb32_1_1_c; + *yuv2packed2 = yuv2rgb32_1_2_c; + *yuv2packedX = yuv2rgb32_1_X_c; +#else +#if CONFIG_SWSCALE_ALPHA + if (c->alpPixBuf) { + *yuv2packed1 = yuv2rgba32_1_1_c; + *yuv2packed2 = yuv2rgba32_1_2_c; + *yuv2packedX = yuv2rgba32_1_X_c; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + *yuv2packed1 = yuv2rgbx32_1_1_c; + *yuv2packed2 = yuv2rgbx32_1_2_c; + *yuv2packedX = yuv2rgbx32_1_X_c; + } +#endif /* !CONFIG_SMALL */ + break; + case PIX_FMT_RGB24: + *yuv2packed1 = yuv2rgb24_1_c; + *yuv2packed2 = yuv2rgb24_2_c; + *yuv2packedX = yuv2rgb24_X_c; + break; + case PIX_FMT_BGR24: + *yuv2packed1 = yuv2bgr24_1_c; + *yuv2packed2 = yuv2bgr24_2_c; + *yuv2packedX = yuv2bgr24_X_c; + break; + case PIX_FMT_RGB565: + case PIX_FMT_BGR565: + *yuv2packed1 = yuv2rgb16_1_c; + *yuv2packed2 = yuv2rgb16_2_c; + *yuv2packedX = yuv2rgb16_X_c; + break; + case PIX_FMT_RGB555: + case PIX_FMT_BGR555: + *yuv2packed1 = yuv2rgb15_1_c; + *yuv2packed2 = yuv2rgb15_2_c; + *yuv2packedX = yuv2rgb15_X_c; + break; + case PIX_FMT_RGB444: + case PIX_FMT_BGR444: + *yuv2packed1 = yuv2rgb12_1_c; + *yuv2packed2 = yuv2rgb12_2_c; + *yuv2packedX = yuv2rgb12_X_c; + break; + case PIX_FMT_RGB8: + case PIX_FMT_BGR8: + *yuv2packed1 = yuv2rgb8_1_c; + *yuv2packed2 = yuv2rgb8_2_c; + *yuv2packedX = yuv2rgb8_X_c; + break; + case PIX_FMT_RGB4: + case PIX_FMT_BGR4: + *yuv2packed1 = yuv2rgb4_1_c; + *yuv2packed2 = yuv2rgb4_2_c; + *yuv2packedX = yuv2rgb4_X_c; + break; + case PIX_FMT_RGB4_BYTE: + case PIX_FMT_BGR4_BYTE: + *yuv2packed1 = yuv2rgb4b_1_c; + *yuv2packed2 = yuv2rgb4b_2_c; + *yuv2packedX = yuv2rgb4b_X_c; break; } } From 3d3c8149370da133c2059bc2370268b4ffbc18d5 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 16 Jun 2011 12:04:25 -0400 Subject: [PATCH 102/780] swscale: disentangle yuv2rgbX_c_full() into small functions. This is part of the Great Evil Plan to simplify swscale. --- libswscale/swscale.c | 292 +++++++++++++++++++++++++------------------ 1 file changed, 171 insertions(+), 121 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index bbcb1974c5..1fd7efdd6f 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1144,7 +1144,7 @@ yuv2rgb_1_c_template(SwsContext *c, const uint16_t *buf0, } } -#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \ +#define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \ static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ const int16_t **lumSrc, int lumFilterSize, \ const int16_t *chrFilter, const int16_t **chrUSrc, \ @@ -1155,8 +1155,9 @@ static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \ chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ alpSrc, dest, dstW, y, fmt, hasAlpha); \ -} \ - \ +} +#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \ +YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \ static void name ## ext ## _2_c(SwsContext *c, const uint16_t *buf0, \ const uint16_t *buf1, const uint16_t *ubuf0, \ const uint16_t *ubuf1, const uint16_t *vbuf0, \ @@ -1201,131 +1202,117 @@ YUV2RGBWRAPPER(yuv2rgb,, 8, PIX_FMT_RGB8, 0); YUV2RGBWRAPPER(yuv2rgb,, 4, PIX_FMT_RGB4, 0); YUV2RGBWRAPPER(yuv2rgb,, 4b, PIX_FMT_RGB4_BYTE, 0); -#define YSCALE_YUV_2_RGBX_FULL_C(rnd,alpha) \ - for (i=0; i>=10;\ - U >>=10;\ - V >>=10;\ - if (alpha) {\ - A = rnd;\ - for (j=0; j>=19;\ - if (A&0x100)\ - A = av_clip_uint8(A);\ - }\ - Y-= c->yuv2rgb_y_offset;\ - Y*= c->yuv2rgb_y_coeff;\ - Y+= rnd;\ - R= Y + V*c->yuv2rgb_v2r_coeff;\ - G= Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff;\ - B= Y + U*c->yuv2rgb_u2b_coeff;\ - if ((R|G|B)&(0xC0000000)) {\ - R = av_clip_uintp2(R, 30); \ - G = av_clip_uintp2(G, 30); \ - B = av_clip_uintp2(B, 30); \ - } - -static void yuv2rgbX_c_full(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, int dstW, int y) +static av_always_inline void +yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, + int dstW, int y, enum PixelFormat target, int hasAlpha) { int i; - int step= c->dstFormatBpp/8; - int aidx= 3; + int step = (target == PIX_FMT_RGB24 || target == PIX_FMT_BGR24) ? 3 : 4; - switch(c->dstFormat) { - case PIX_FMT_ARGB: - dest++; - aidx= 0; - case PIX_FMT_RGB24: - aidx--; - case PIX_FMT_RGBA: - if (CONFIG_SMALL) { - int needAlpha = CONFIG_SWSCALE_ALPHA && c->alpPixBuf; - YSCALE_YUV_2_RGBX_FULL_C(1<<21, needAlpha) - dest[aidx]= needAlpha ? A : 255; - dest[0]= R>>22; - dest[1]= G>>22; - dest[2]= B>>22; - dest+= step; - } - } else { - if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { - YSCALE_YUV_2_RGBX_FULL_C(1<<21, 1) - dest[aidx]= A; - dest[0]= R>>22; - dest[1]= G>>22; - dest[2]= B>>22; - dest+= step; - } - } else { - YSCALE_YUV_2_RGBX_FULL_C(1<<21, 0) - dest[aidx]= 255; - dest[0]= R>>22; - dest[1]= G>>22; - dest[2]= B>>22; - dest+= step; - } - } + for (i = 0; i < dstW; i++) { + int j; + int Y = 0; + int U = -128 << 19; + int V = -128 << 19; + int av_unused A; + int R, G, B; + + for (j = 0; j < lumFilterSize; j++) { + Y += lumSrc[j][i] * lumFilter[j]; } - break; - case PIX_FMT_ABGR: - dest++; - aidx= 0; - case PIX_FMT_BGR24: - aidx--; - case PIX_FMT_BGRA: - if (CONFIG_SMALL) { - int needAlpha = CONFIG_SWSCALE_ALPHA && c->alpPixBuf; - YSCALE_YUV_2_RGBX_FULL_C(1<<21, needAlpha) - dest[aidx]= needAlpha ? A : 255; - dest[0]= B>>22; - dest[1]= G>>22; - dest[2]= R>>22; - dest+= step; - } - } else { - if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { - YSCALE_YUV_2_RGBX_FULL_C(1<<21, 1) - dest[aidx]= A; - dest[0]= B>>22; - dest[1]= G>>22; - dest[2]= R>>22; - dest+= step; - } - } else { - YSCALE_YUV_2_RGBX_FULL_C(1<<21, 0) - dest[aidx]= 255; - dest[0]= B>>22; - dest[1]= G>>22; - dest[2]= R>>22; - dest+= step; - } - } + for (j = 0; j < chrFilterSize; j++) { + U += chrUSrc[j][i] * chrFilter[j]; + V += chrVSrc[j][i] * chrFilter[j]; } - break; - default: - assert(0); + Y >>= 10; + U >>= 10; + V >>= 10; + if (hasAlpha) { + A = 1 << 21; + for (j = 0; j < lumFilterSize; j++) { + A += alpSrc[j][i] * lumFilter[j]; + } + A >>= 19; + if (A & 0x100) + A = av_clip_uint8(A); + } + Y -= c->yuv2rgb_y_offset; + Y *= c->yuv2rgb_y_coeff; + Y += 1 << 21; + R = Y + V*c->yuv2rgb_v2r_coeff; + G = Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff; + B = Y + U*c->yuv2rgb_u2b_coeff; + if ((R | G | B) & 0xC0000000) { + R = av_clip_uintp2(R, 30); + G = av_clip_uintp2(G, 30); + B = av_clip_uintp2(B, 30); + } + + switch(target) { + case PIX_FMT_ARGB: + dest[0] = hasAlpha ? A : 255; + dest[1] = R >> 22; + dest[2] = G >> 22; + dest[3] = B >> 22; + break; + case PIX_FMT_RGB24: + dest[0] = R >> 22; + dest[1] = G >> 22; + dest[2] = B >> 22; + break; + case PIX_FMT_RGBA: + dest[0] = R >> 22; + dest[1] = G >> 22; + dest[2] = B >> 22; + dest[3] = hasAlpha ? A : 255; + break; + case PIX_FMT_ABGR: + dest[0] = hasAlpha ? A : 255; + dest[1] = B >> 22; + dest[2] = G >> 22; + dest[3] = R >> 22; + dest += 4; + break; + case PIX_FMT_BGR24: + dest[0] = B >> 22; + dest[1] = G >> 22; + dest[2] = R >> 22; + break; + case PIX_FMT_BGRA: + dest[0] = B >> 22; + dest[1] = G >> 22; + dest[2] = R >> 22; + dest[3] = hasAlpha ? A : 255; + break; + } + dest += step; } } +#if CONFIG_SMALL +YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); +YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); +YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); +YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->alpPixBuf); +#else +#if CONFIG_SWSCALE_ALPHA +YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, PIX_FMT_BGRA, 1); +YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, PIX_FMT_ABGR, 1); +YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, PIX_FMT_RGBA, 1); +YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, PIX_FMT_ARGB, 1); +#endif +YUV2RGBWRAPPERX(yuv2, rgb_full, bgrx32_full, PIX_FMT_BGRA, 0); +YUV2RGBWRAPPERX(yuv2, rgb_full, xbgr32_full, PIX_FMT_ABGR, 0); +YUV2RGBWRAPPERX(yuv2, rgb_full, rgbx32_full, PIX_FMT_RGBA, 0); +YUV2RGBWRAPPERX(yuv2, rgb_full, xrgb32_full, PIX_FMT_ARGB, 0); +#endif +YUV2RGBWRAPPERX(yuv2, rgb_full, bgr24_full, PIX_FMT_BGR24, 0); +YUV2RGBWRAPPERX(yuv2, rgb_full, rgb24_full, PIX_FMT_RGB24, 0); + static av_always_inline void fillPlane(uint8_t* plane, int stride, int width, int height, int y, uint8_t val) @@ -1978,7 +1965,70 @@ find_c_packed_planar_out_funcs(SwsContext *c, *yuv2yuvX = yuv2yuvX_c; } if(c->flags & SWS_FULL_CHR_H_INT) { - *yuv2packedX = yuv2rgbX_c_full; + switch (dstFormat) { + case PIX_FMT_RGBA: +#if CONFIG_SMALL + *yuv2packedX = yuv2rgba32_full_X_c; +#else +#if CONFIG_SWSCALE_ALPHA + if (c->alpPixBuf) { + *yuv2packedX = yuv2rgba32_full_X_c; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + *yuv2packedX = yuv2rgbx32_full_X_c; + } +#endif /* !CONFIG_SMALL */ + break; + case PIX_FMT_ARGB: +#if CONFIG_SMALL + *yuv2packedX = yuv2argb32_full_X_c; +#else +#if CONFIG_SWSCALE_ALPHA + if (c->alpPixBuf) { + *yuv2packedX = yuv2argb32_full_X_c; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + *yuv2packedX = yuv2xrgb32_full_X_c; + } +#endif /* !CONFIG_SMALL */ + break; + case PIX_FMT_BGRA: +#if CONFIG_SMALL + *yuv2packedX = yuv2bgra32_full_X_c; +#else +#if CONFIG_SWSCALE_ALPHA + if (c->alpPixBuf) { + *yuv2packedX = yuv2bgra32_full_X_c; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + *yuv2packedX = yuv2bgrx32_full_X_c; + } +#endif /* !CONFIG_SMALL */ + break; + case PIX_FMT_ABGR: +#if CONFIG_SMALL + *yuv2packedX = yuv2abgr32_full_X_c; +#else +#if CONFIG_SWSCALE_ALPHA + if (c->alpPixBuf) { + *yuv2packedX = yuv2abgr32_full_X_c; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + *yuv2packedX = yuv2xbgr32_full_X_c; + } +#endif /* !CONFIG_SMALL */ + break; + case PIX_FMT_RGB24: + *yuv2packedX = yuv2rgb24_full_X_c; + break; + case PIX_FMT_BGR24: + *yuv2packedX = yuv2bgr24_full_X_c; + break; + } } else { switch (dstFormat) { case PIX_FMT_GRAY16BE: From dff5a8353266641311827a4bbdd940f7ad08c8b6 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 24 Jun 2011 07:43:19 -0700 Subject: [PATCH 103/780] swscale: re-add support for non-native endianness. This works through some non-obvious hacks in utils.c. --- libswscale/swscale.c | 18 ++++++++++++------ libswscale/utils.c | 18 ++++++++++++------ tests/ref/lavfi/pixdesc_le | 4 ++++ tests/ref/lavfi/pixfmts_copy_le | 4 ++++ tests/ref/lavfi/pixfmts_crop_le | 4 ++++ tests/ref/lavfi/pixfmts_hflip_le | 4 ++++ tests/ref/lavfi/pixfmts_null_le | 4 ++++ tests/ref/lavfi/pixfmts_scale_le | 4 ++++ tests/ref/lavfi/pixfmts_vflip_le | 4 ++++ 9 files changed, 52 insertions(+), 12 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 1fd7efdd6f..e0dce96036 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2133,20 +2133,26 @@ find_c_packed_planar_out_funcs(SwsContext *c, *yuv2packed2 = yuv2bgr24_2_c; *yuv2packedX = yuv2bgr24_X_c; break; - case PIX_FMT_RGB565: - case PIX_FMT_BGR565: + case PIX_FMT_RGB565LE: + case PIX_FMT_RGB565BE: + case PIX_FMT_BGR565LE: + case PIX_FMT_BGR565BE: *yuv2packed1 = yuv2rgb16_1_c; *yuv2packed2 = yuv2rgb16_2_c; *yuv2packedX = yuv2rgb16_X_c; break; - case PIX_FMT_RGB555: - case PIX_FMT_BGR555: + case PIX_FMT_RGB555LE: + case PIX_FMT_RGB555BE: + case PIX_FMT_BGR555LE: + case PIX_FMT_BGR555BE: *yuv2packed1 = yuv2rgb15_1_c; *yuv2packed2 = yuv2rgb15_2_c; *yuv2packedX = yuv2rgb15_X_c; break; - case PIX_FMT_RGB444: - case PIX_FMT_BGR444: + case PIX_FMT_RGB444LE: + case PIX_FMT_RGB444BE: + case PIX_FMT_BGR444LE: + case PIX_FMT_BGR444BE: *yuv2packed1 = yuv2rgb12_1_c; *yuv2packed2 = yuv2rgb12_2_c; *yuv2packedX = yuv2rgb12_X_c; diff --git a/libswscale/utils.c b/libswscale/utils.c index d048b22e24..69714183d0 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -146,12 +146,18 @@ int sws_isSupportedInput(enum PixelFormat pix_fmt) || (x)==PIX_FMT_YUVJ444P \ || isRGBinBytes(x) \ || isBGRinBytes(x) \ - || (x)==PIX_FMT_RGB565 \ - || (x)==PIX_FMT_RGB555 \ - || (x)==PIX_FMT_RGB444 \ - || (x)==PIX_FMT_BGR565 \ - || (x)==PIX_FMT_BGR555 \ - || (x)==PIX_FMT_BGR444 \ + || (x)==PIX_FMT_RGB565LE \ + || (x)==PIX_FMT_RGB565BE \ + || (x)==PIX_FMT_RGB555LE \ + || (x)==PIX_FMT_RGB555BE \ + || (x)==PIX_FMT_RGB444LE \ + || (x)==PIX_FMT_RGB444BE \ + || (x)==PIX_FMT_BGR565LE \ + || (x)==PIX_FMT_BGR565BE \ + || (x)==PIX_FMT_BGR555LE \ + || (x)==PIX_FMT_BGR555BE \ + || (x)==PIX_FMT_BGR444LE \ + || (x)==PIX_FMT_BGR444BE \ || (x)==PIX_FMT_RGB8 \ || (x)==PIX_FMT_BGR8 \ || (x)==PIX_FMT_RGB4_BYTE \ diff --git a/tests/ref/lavfi/pixdesc_le b/tests/ref/lavfi/pixdesc_le index b5afb92ffd..de13e94cff 100644 --- a/tests/ref/lavfi/pixdesc_le +++ b/tests/ref/lavfi/pixdesc_le @@ -4,7 +4,9 @@ bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f bgr48le d022bfdd6a07d5dcc693799322a386b4 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 +bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b +bgr565be 257cf78afa35dc31e9696f139c916715 bgr565le 1dfdd03995c287e3c754b164bf26a355 bgr8 24bd566170343d06fec6fccfff5abc54 bgra 76a18a5151242fa137133f604cd624d2 @@ -19,7 +21,9 @@ rgb24 b41eba9651e1b5fe386289b506188105 rgb48be 460b6de89b156290a12d3941db8bd731 rgb48le cd93cb34d15996987367dabda3a10128 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 +rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c +rgb565be 9cadf742e05ddc23a3b5b270f89aad3c rgb565le d39aa298bb525e9be8860351c6f62dab rgb8 4a9d8e4f2f154e83a7e1735be6300700 rgba 93a5b3712e6eb8c5b9a09ffc7b9fbc12 diff --git a/tests/ref/lavfi/pixfmts_copy_le b/tests/ref/lavfi/pixfmts_copy_le index b5afb92ffd..de13e94cff 100644 --- a/tests/ref/lavfi/pixfmts_copy_le +++ b/tests/ref/lavfi/pixfmts_copy_le @@ -4,7 +4,9 @@ bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f bgr48le d022bfdd6a07d5dcc693799322a386b4 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 +bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b +bgr565be 257cf78afa35dc31e9696f139c916715 bgr565le 1dfdd03995c287e3c754b164bf26a355 bgr8 24bd566170343d06fec6fccfff5abc54 bgra 76a18a5151242fa137133f604cd624d2 @@ -19,7 +21,9 @@ rgb24 b41eba9651e1b5fe386289b506188105 rgb48be 460b6de89b156290a12d3941db8bd731 rgb48le cd93cb34d15996987367dabda3a10128 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 +rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c +rgb565be 9cadf742e05ddc23a3b5b270f89aad3c rgb565le d39aa298bb525e9be8860351c6f62dab rgb8 4a9d8e4f2f154e83a7e1735be6300700 rgba 93a5b3712e6eb8c5b9a09ffc7b9fbc12 diff --git a/tests/ref/lavfi/pixfmts_crop_le b/tests/ref/lavfi/pixfmts_crop_le index 01da415947..af42cd3c4a 100644 --- a/tests/ref/lavfi/pixfmts_crop_le +++ b/tests/ref/lavfi/pixfmts_crop_le @@ -4,7 +4,9 @@ bgr24 3450fd00cf1493d1ded75544d82ba3ec bgr48be 90cb5d373a1123432d63c6a10c101afa bgr48le 9371f54ceda9010f1199e86f4930ac3f bgr4_byte 2f6ac3cdd4676ab4e2982bdf0664945b +bgr555be d3a7c273604723adeb7e5f5dd1c4272b bgr555le d22442fc13b464f9ba455b08df4e981f +bgr565be fadceef4a64ad6873fcb43ddee0deb3c bgr565le 891664e5a54ae5968901347da92bc5e9 bgr8 4b7159e05765bd4703180072d86423c8 bgra 395c9f706fccda721471acaa5c96c16c @@ -15,7 +17,9 @@ rgb24 3b90ed64b687d3dc186c6ef521dc71a8 rgb48be a808128041a1962deaa8620c7448feba rgb48le ce92d02cc322608d5be377cb1940677b rgb4_byte 6958029f73c6cdfed4f71020d816f027 +rgb555be 41a7d1836837bc90f2cae19a9c9df3b3 rgb555le eeb78f8ce6186fba55c941469e60ba67 +rgb565be b2d1cb525f3a0cfe27753c0d479b2fa9 rgb565le 6a49700680be9a0d434411825a769556 rgb8 88b0398c265d1ed7a837dc084fa0917c rgba fd00b24c7597268c32759a84a1de2de4 diff --git a/tests/ref/lavfi/pixfmts_hflip_le b/tests/ref/lavfi/pixfmts_hflip_le index 514eed7b3b..3a3dbf0014 100644 --- a/tests/ref/lavfi/pixfmts_hflip_le +++ b/tests/ref/lavfi/pixfmts_hflip_le @@ -4,7 +4,9 @@ bgr24 cc53d2011d097972db0d22756c3699e3 bgr48be 11641cf0f4516a9aed98f7872720f801 bgr48le b5440734eed128554dd9f83b34ba582f bgr4_byte aac987e7d1a6a96477cfc0b48a4285de +bgr555be bc07265898440116772200390d70c092 bgr555le ccee08679bac84a1f960c6c9070c5538 +bgr565be e088789ce46224b87c6e46610ef19add bgr565le 3703466e19e1b52e03a34fd244a8e8e4 bgr8 50b505a889f0428242305acb642da107 bgra 01ca21e7e6a8d1281b4553bde8e8a404 @@ -15,7 +17,9 @@ rgb24 754f1722fc738590cc407ac65749bfe8 rgb48be 10743e1577dc3198dbbc7c0b3b8f429e rgb48le dd945a44f39119221407bf7a04f1bc49 rgb4_byte c8a3f995fcf3e0919239ea2c413ddc29 +rgb555be 045ce8607d3910586f4d97481dda8632 rgb555le 8778ee0cf58ce9ad1d99a1eca9f95e87 +rgb565be c8022a1b2470e72f124e4389fad4c372 rgb565le 2cb690eb3fcb72da3771ad6a48931158 rgb8 9e462b811b9b6173397b9cfc1f6b2f17 rgba d3d0dc1ecef3ed72f26a2986d0efc204 diff --git a/tests/ref/lavfi/pixfmts_null_le b/tests/ref/lavfi/pixfmts_null_le index b5afb92ffd..de13e94cff 100644 --- a/tests/ref/lavfi/pixfmts_null_le +++ b/tests/ref/lavfi/pixfmts_null_le @@ -4,7 +4,9 @@ bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f bgr48le d022bfdd6a07d5dcc693799322a386b4 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 +bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b +bgr565be 257cf78afa35dc31e9696f139c916715 bgr565le 1dfdd03995c287e3c754b164bf26a355 bgr8 24bd566170343d06fec6fccfff5abc54 bgra 76a18a5151242fa137133f604cd624d2 @@ -19,7 +21,9 @@ rgb24 b41eba9651e1b5fe386289b506188105 rgb48be 460b6de89b156290a12d3941db8bd731 rgb48le cd93cb34d15996987367dabda3a10128 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 +rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c +rgb565be 9cadf742e05ddc23a3b5b270f89aad3c rgb565le d39aa298bb525e9be8860351c6f62dab rgb8 4a9d8e4f2f154e83a7e1735be6300700 rgba 93a5b3712e6eb8c5b9a09ffc7b9fbc12 diff --git a/tests/ref/lavfi/pixfmts_scale_le b/tests/ref/lavfi/pixfmts_scale_le index 275dce8516..670efe15bb 100644 --- a/tests/ref/lavfi/pixfmts_scale_le +++ b/tests/ref/lavfi/pixfmts_scale_le @@ -4,7 +4,9 @@ bgr24 570f8d6b51a838aed022ef67535f6bdc bgr48be fcc0f2dbf45d325f84f816c74cbeeebe bgr48le 3f9c2b23eed3b8d196d1c14b38ce50f5 bgr4_byte ee1d35a7baf8e9016891929a2f565c0b +bgr555be de8901c1358834fddea060fcb3a67beb bgr555le 36b745067197f9ca8c1731cac51329c9 +bgr565be 922a2503767036ae9536f4f7823c04ee bgr565le 3a514a298c6161a071ddf9963c06509d bgr8 7f007fa6c153a16e808a9c51605a4016 bgra a5e7040f9a80cccd65e5acf2ca09ace5 @@ -19,7 +21,9 @@ rgb24 514692e28e8ff6860e415ce4fcf6eb8c rgb48be 1894cd30dabcd3180518e4d5f09f25e7 rgb48le 1354e6e27ce3c1d4d4989ee56030c94b rgb4_byte d81ffd3add95842a618eec81024f0b5c +rgb555be 4607309f9f217d51cbb53d13b84b4537 rgb555le a350ef1dc2c9688ed49e7ba018843795 +rgb565be 678ce231c4ea13629c1353b1df4ffbef rgb565le 6f4bb711238baa762d73305213f8d035 rgb8 091d0170b354ef0e97312b95feb5483f rgba a3d362f222098a00e63867f612018659 diff --git a/tests/ref/lavfi/pixfmts_vflip_le b/tests/ref/lavfi/pixfmts_vflip_le index 5100c42412..0383ad9c08 100644 --- a/tests/ref/lavfi/pixfmts_vflip_le +++ b/tests/ref/lavfi/pixfmts_vflip_le @@ -4,7 +4,9 @@ bgr24 89108a4ba00201f79b75b9305c42352d bgr48be ed82382da09b64a8e04728fcf76e6814 bgr48le 0f1f135608c2ff24d26d03e939fc2112 bgr4_byte 407fcf564ed764c38e1d748f700ab921 +bgr555be f739d2519f7e9d494359bf67a3821537 bgr555le bd7b3ec4d684dfad075d89a606cb8b74 +bgr565be f19e9a4786395e1ddcd51399c98c9f6c bgr565le fdb617533e1e7ff512ea5b6b6233e738 bgr8 c60f93fd152c6903391d1fe9decd3547 bgra 7f9b799fb48544e49ce93e91d7f9fca8 @@ -19,7 +21,9 @@ rgb24 eaefabc168d0b14576bab45bc1e56e1e rgb48be 4e0c384163ebab06a08e74637beb02bc rgb48le a77bfeefcd96750cf0e1917a2e2bf1e7 rgb4_byte 8c6ff02df0b06dd2d574836c3741b2a2 +rgb555be 40dc33cfb5cf56aac1c5a290ac486c36 rgb555le 4f8eaad29a17e0f8e9d8ab743e76b999 +rgb565be b57623ad9df74648339311a0edcebc7b rgb565le 73f247a3315dceaea3022ac7c197c5ef rgb8 13a8d89ef78d8127297d899005456ff0 rgba 1fc6e920a42ec812aaa3b2aa02f37987 From c029ea39bd58905d7a15ad7e1eb7991447606974 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 28 Jun 2011 04:10:40 +0200 Subject: [PATCH 104/780] AVDictionary: warn about its shortcommings and mention available replacements. Signed-off-by: Michael Niedermayer --- libavutil/dict.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavutil/dict.h b/libavutil/dict.h index 421be32244..dc575eb76c 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -19,6 +19,13 @@ /** * @file Public dictionary API. + * @deprecated + * AVDictionary is provided for compatibility with libav. It is both in + * implementation as well as API inefficient. It doesnt scale and is + * be extreemly slow with large dictionaries. + * It is recommanded that new code uses our tree container from tree.c/h + * where applicable. + * Which uses AVL trees to achive O(log n) performance */ #ifndef AVUTIL_DICT_H From 94e59cb84b0fbc016333c22685cdc4afeabbdf08 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 28 Jun 2011 04:23:20 +0200 Subject: [PATCH 105/780] random_seed: more elaborate doxy. Signed-off-by: Michael Niedermayer --- libavutil/random_seed.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavutil/random_seed.h b/libavutil/random_seed.h index 7f75063233..bb957879be 100644 --- a/libavutil/random_seed.h +++ b/libavutil/random_seed.h @@ -25,6 +25,10 @@ /** * Get a seed to use in conjunction with random functions. + * This function tries to provide a good seed at a best effort bases. + * Its possible to call this function multiple times if more bits are needed. + * It can be quite slow, which is why it should only be used as seed for a faster + * PRNG. The quality of the seed depends on the platform. */ uint32_t av_get_random_seed(void); From 13a099799e89a76eb921ca452e1b04a7a28a9855 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 16 Jun 2011 12:04:26 -0400 Subject: [PATCH 106/780] swscale: change prototypes of scaled YUV output functions. Remove unused variables "flags" and "dstFormat" in yuv2packed1, merge source rows per plane for yuv2packed[12], and make every source argument int16_t (some where invalidly set to uint16_t). This prevents stack pollution and is part of the Great Evil Plan to simplify swscale. --- libswscale/ppc/swscale_altivec.c | 7 +- libswscale/swscale.c | 268 ++++++++++++++---------------- libswscale/swscale_internal.h | 40 ++--- libswscale/x86/swscale_template.c | 159 +++++++++--------- 4 files changed, 228 insertions(+), 246 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 7161fe7963..14f35b64cb 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -98,10 +98,9 @@ yuv2yuvX_altivec_real(SwsContext *c, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest, uint8_t *uDest, - uint8_t *vDest, uint8_t *aDest, - int dstW, int chrDstW) + uint8_t *dest[4], int dstW, int chrDstW) { + uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2]; const vector signed int vini = {(1 << 18), (1 << 18), (1 << 18), (1 << 18)}; register int i, j; { @@ -150,7 +149,7 @@ yuv2yuvX_altivec_real(SwsContext *c, val[i] += lumSrc[j][i] * lumFilter[j]; } } - altivec_packIntArrayToCharArray(val, dest, dstW); + altivec_packIntArrayToCharArray(val, yDest, dstW); } if (uDest != 0) { DECLARE_ALIGNED(16, int, u)[chrDstW]; diff --git a/libswscale/swscale.c b/libswscale/swscale.c index e0dce96036..64ba97e7d4 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -199,13 +199,14 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, - uint16_t *dest, uint16_t *uDest, uint16_t *vDest, - uint16_t *aDest, int dstW, int chrDstW, + uint16_t *dest[4], int dstW, int chrDstW, int big_endian, int output_bits) { //FIXME Optimize (just quickly written not optimized..) int i; int shift = 11 + 16 - output_bits; + uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], + *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; #define output_pixel(pos, val) \ if (big_endian) { \ @@ -228,7 +229,7 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, for (j = 0; j < lumFilterSize; j++) val += lumSrc[j][i] * lumFilter[j]; - output_pixel(&dest[i], val); + output_pixel(&yDest[i], val); } if (uDest) { @@ -267,15 +268,11 @@ static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFil const int16_t *chrFilter, const int16_t **chrUSrc, \ const int16_t **chrVSrc, \ int chrFilterSize, const int16_t **alpSrc, \ - uint8_t *_dest, uint8_t *_uDest, uint8_t *_vDest, \ - uint8_t *_aDest, int dstW, int chrDstW) \ + uint8_t *_dest[4], int dstW, int chrDstW) \ { \ - uint16_t *dest = (uint16_t *) _dest, *uDest = (uint16_t *) _uDest, \ - *vDest = (uint16_t *) _vDest, *aDest = (uint16_t *) _aDest; \ yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \ chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ - alpSrc, \ - dest, uDest, vDest, aDest, \ + alpSrc, (uint16_t **) _dest, \ dstW, chrDstW, is_be, bits); \ } yuv2NBPS( 9, BE, 1); @@ -290,18 +287,20 @@ static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest, uint8_t *uDest, uint8_t *vDest, - uint8_t *aDest, int dstW, int chrDstW) + uint8_t *dest[4], int dstW, int chrDstW) { - //FIXME Optimize (just quickly written not optimized..) + uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], + *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; int i; + + //FIXME Optimize (just quickly written not optimized..) for (i=0; i>19); + yDest[i]= av_clip_uint8(val>>19); } if (uDest) @@ -332,13 +331,15 @@ static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, static void yuv2yuv1_c(SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, - uint8_t *dest, uint8_t *uDest, uint8_t *vDest, - uint8_t *aDest, int dstW, int chrDstW) + uint8_t *dest[4], int dstW, int chrDstW) { + uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], + *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; int i; + for (i=0; i>7; - dest[i]= av_clip_uint8(val); + yDest[i]= av_clip_uint8(val); } if (uDest) @@ -360,10 +361,10 @@ static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, - uint8_t *vDest, uint8_t *aDest, + const int16_t **alpSrc, uint8_t *dest[4], int dstW, int chrDstW) { + uint8_t *yDest = dest[0], *uDest = dest[1]; enum PixelFormat dstFormat = c->dstFormat; //FIXME Optimize (just quickly written not optimized..) @@ -374,7 +375,7 @@ static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, for (j=0; j>19); + yDest[i]= av_clip_uint8(val>>19); } if (!uDest) @@ -447,16 +448,15 @@ yuv2gray16_X_c_template(SwsContext *c, const int16_t *lumFilter, } static av_always_inline void -yuv2gray16_2_c_template(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, int dstW, +yuv2gray16_2_c_template(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { - int yalpha1 = 4095 - yalpha; \ + int yalpha1 = 4095 - yalpha; int i; + const int16_t *buf0 = buf[0], *buf1 = buf[1]; for (i = 0; i < (dstW >> 1); i++) { const int i2 = 2 * i; @@ -469,12 +469,10 @@ yuv2gray16_2_c_template(SwsContext *c, const uint16_t *buf0, } static av_always_inline void -yuv2gray16_1_c_template(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, int dstW, - int uvalpha, enum PixelFormat dstFormat, - int flags, int y, enum PixelFormat target) +yuv2gray16_1_c_template(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf0, uint8_t *dest, int dstW, + int uvalpha, int y, enum PixelFormat target) { int i; @@ -503,28 +501,22 @@ static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ alpSrc, dest, dstW, y, fmt); \ } \ \ -static void name ## ext ## _2_c(SwsContext *c, const uint16_t *buf0, \ - const uint16_t *buf1, const uint16_t *ubuf0, \ - const uint16_t *ubuf1, const uint16_t *vbuf0, \ - const uint16_t *vbuf1, const uint16_t *abuf0, \ - const uint16_t *abuf1, uint8_t *dest, int dstW, \ +static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \ + const int16_t *ubuf[2], const int16_t *vbuf[2], \ + const int16_t *abuf[2], uint8_t *dest, int dstW, \ int yalpha, int uvalpha, int y) \ { \ - name ## base ## _2_c_template(c, buf0, buf1, ubuf0, ubuf1, \ - vbuf0, vbuf1, abuf0, abuf1, \ + name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \ dest, dstW, yalpha, uvalpha, y, fmt); \ } \ \ -static void name ## ext ## _1_c(SwsContext *c, const uint16_t *buf0, \ - const uint16_t *ubuf0, const uint16_t *ubuf1, \ - const uint16_t *vbuf0, const uint16_t *vbuf1, \ - const uint16_t *abuf0, uint8_t *dest, int dstW, \ - int uvalpha, enum PixelFormat dstFormat, \ - int flags, int y) \ +static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ + const int16_t *ubuf[2], const int16_t *vbuf[2], \ + const int16_t *abuf0, uint8_t *dest, int dstW, \ + int uvalpha, int y) \ { \ - name ## base ## _1_c_template(c, buf0, ubuf0, ubuf1, vbuf0, \ - vbuf1, abuf0, dest, dstW, uvalpha, \ - dstFormat, flags, y, fmt); \ + name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \ + dstW, uvalpha, y, fmt); \ } YUV2PACKEDWRAPPER(yuv2gray16,, LE, PIX_FMT_GRAY16LE); @@ -574,14 +566,13 @@ yuv2mono_X_c_template(SwsContext *c, const int16_t *lumFilter, } static av_always_inline void -yuv2mono_2_c_template(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, int dstW, +yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { + const int16_t *buf0 = buf[0], *buf1 = buf[1]; const uint8_t * const d128 = dither_8x8_220[y & 7]; uint8_t *g = c->table_gU[128] + c->table_gV[128]; int yalpha1 = 4095 - yalpha; @@ -601,12 +592,10 @@ yuv2mono_2_c_template(SwsContext *c, const uint16_t *buf0, } static av_always_inline void -yuv2mono_1_c_template(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, int dstW, - int uvalpha, enum PixelFormat dstFormat, - int flags, int y, enum PixelFormat target) +yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf0, uint8_t *dest, int dstW, + int uvalpha, int y, enum PixelFormat target) { const uint8_t * const d128 = dither_8x8_220[y & 7]; uint8_t *g = c->table_gU[128] + c->table_gV[128]; @@ -683,14 +672,15 @@ yuv2422_X_c_template(SwsContext *c, const int16_t *lumFilter, } static av_always_inline void -yuv2422_2_c_template(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, int dstW, +yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; int yalpha1 = 4095 - yalpha; int uvalpha1 = 4095 - uvalpha; int i; @@ -706,13 +696,13 @@ yuv2422_2_c_template(SwsContext *c, const uint16_t *buf0, } static av_always_inline void -yuv2422_1_c_template(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, int dstW, - int uvalpha, enum PixelFormat dstFormat, - int flags, int y, enum PixelFormat target) +yuv2422_1_c_template(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf0, uint8_t *dest, int dstW, + int uvalpha, int y, enum PixelFormat target) { + const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; int i; if (uvalpha < 2048) { @@ -797,14 +787,15 @@ yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter, } static av_always_inline void -yuv2rgb48_2_c_template(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, int dstW, +yuv2rgb48_2_c_template(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; int yalpha1 = 4095 - yalpha; int uvalpha1 = 4095 - uvalpha; int i; @@ -829,13 +820,13 @@ yuv2rgb48_2_c_template(SwsContext *c, const uint16_t *buf0, } static av_always_inline void -yuv2rgb48_1_c_template(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, int dstW, - int uvalpha, enum PixelFormat dstFormat, - int flags, int y, enum PixelFormat target) +yuv2rgb48_1_c_template(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf0, uint8_t *dest, int dstW, + int uvalpha, int y, enum PixelFormat target) { + const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; int i; if (uvalpha < 2048) { @@ -1060,14 +1051,16 @@ yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter, } static av_always_inline void -yuv2rgb_2_c_template(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, int dstW, +yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target, int hasAlpha) { + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + *vbuf0 = vbuf[0], *vbuf1 = vbuf[1], + *abuf0 = abuf[0], *abuf1 = abuf[1]; int yalpha1 = 4095 - yalpha; int uvalpha1 = 4095 - uvalpha; int i; @@ -1093,14 +1086,14 @@ yuv2rgb_2_c_template(SwsContext *c, const uint16_t *buf0, } static av_always_inline void -yuv2rgb_1_c_template(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, int dstW, - int uvalpha, enum PixelFormat dstFormat, - int flags, int y, enum PixelFormat target, +yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf0, uint8_t *dest, int dstW, + int uvalpha, int y, enum PixelFormat target, int hasAlpha) { + const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; int i; if (uvalpha < 2048) { @@ -1158,28 +1151,22 @@ static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ } #define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \ YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \ -static void name ## ext ## _2_c(SwsContext *c, const uint16_t *buf0, \ - const uint16_t *buf1, const uint16_t *ubuf0, \ - const uint16_t *ubuf1, const uint16_t *vbuf0, \ - const uint16_t *vbuf1, const uint16_t *abuf0, \ - const uint16_t *abuf1, uint8_t *dest, int dstW, \ +static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \ + const int16_t *ubuf[2], const int16_t *vbuf[2], \ + const int16_t *abuf[2], uint8_t *dest, int dstW, \ int yalpha, int uvalpha, int y) \ { \ - name ## base ## _2_c_template(c, buf0, buf1, ubuf0, ubuf1, \ - vbuf0, vbuf1, abuf0, abuf1, \ + name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \ dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \ } \ \ -static void name ## ext ## _1_c(SwsContext *c, const uint16_t *buf0, \ - const uint16_t *ubuf0, const uint16_t *ubuf1, \ - const uint16_t *vbuf0, const uint16_t *vbuf1, \ - const uint16_t *abuf0, uint8_t *dest, int dstW, \ - int uvalpha, enum PixelFormat dstFormat, \ - int flags, int y) \ +static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ + const int16_t *ubuf[2], const int16_t *vbuf[2], \ + const int16_t *abuf0, uint8_t *dest, int dstW, \ + int uvalpha, int y) \ { \ - name ## base ## _1_c_template(c, buf0, ubuf0, ubuf1, vbuf0, \ - vbuf1, abuf0, dest, dstW, uvalpha, \ - dstFormat, flags, y, fmt, hasAlpha); \ + name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \ + dstW, uvalpha, y, fmt, hasAlpha); \ } #if CONFIG_SMALL @@ -2279,11 +2266,13 @@ static int swScale(SwsContext *c, const uint8_t* src[], lastDstY= dstY; for (;dstY < dstH; dstY++) { - unsigned char *dest =dst[0]+dstStride[0]*dstY; const int chrDstY= dstY>>c->chrDstVSubSample; - unsigned char *uDest=dst[1]+dstStride[1]*chrDstY; - unsigned char *vDest=dst[2]+dstStride[2]*chrDstY; - unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL; + uint8_t *dest[4] = { + dst[0] + dstStride[0] * dstY, + dst[1] + dstStride[1] * chrDstY, + dst[2] + dstStride[2] * chrDstY, + (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL, + }; const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<chrDstVSubSample) - 1), dstH-1)]; @@ -2377,46 +2366,43 @@ static int swScale(SwsContext *c, const uint8_t* src[], const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like const int chrSkipMask= (1<chrDstVSubSample)-1; - if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi + if ((dstY&chrSkipMask) || isGray(dstFormat)) + dest[1] = dest[2] = NULL; //FIXME split functions in lumi / chromi if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12 - const int16_t *lumBuf = lumSrcPtr[0]; - const int16_t *chrUBuf= chrUSrcPtr[0]; - const int16_t *chrVBuf= chrVSrcPtr[0]; const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL; - yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest, - uDest, vDest, aDest, dstW, chrDstW); + yuv2yuv1(c, lumSrcPtr[0], chrUSrcPtr[0], chrVSrcPtr[0], alpBuf, + dest, dstW, chrDstW); } else { //General YV12 - yuv2yuvX(c, - vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, - vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, - chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW); + yuv2yuvX(c, vLumFilter + dstY * vLumFilterSize, + lumSrcPtr, vLumFilterSize, + vChrFilter + chrDstY * vChrFilterSize, + chrUSrcPtr, chrVSrcPtr, vChrFilterSize, + alpSrcPtr, dest, dstW, chrDstW); } } else { assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB - int chrAlpha= vChrFilter[2*dstY+1]; - yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1), - *chrVSrcPtr, *(chrVSrcPtr+1), - alpPixBuf ? *alpSrcPtr : NULL, - dest, dstW, chrAlpha, dstFormat, flags, dstY); + int chrAlpha = vChrFilter[2 * dstY + 1]; + yuv2packed1(c, *lumSrcPtr, chrUSrcPtr, chrVSrcPtr, + alpPixBuf ? *alpSrcPtr : NULL, + dest[0], dstW, chrAlpha, dstY); } else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB - int lumAlpha= vLumFilter[2*dstY+1]; - int chrAlpha= vChrFilter[2*dstY+1]; - lumMmxFilter[2]= - lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001; - chrMmxFilter[2]= - chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001; - yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1), - *chrVSrcPtr, *(chrVSrcPtr+1), - alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL, - dest, dstW, lumAlpha, chrAlpha, dstY); + int lumAlpha = vLumFilter[2 * dstY + 1]; + int chrAlpha = vChrFilter[2 * dstY + 1]; + lumMmxFilter[2] = + lumMmxFilter[3] = vLumFilter[2 * dstY ] * 0x10001; + chrMmxFilter[2] = + chrMmxFilter[3] = vChrFilter[2 * chrDstY] * 0x10001; + yuv2packed2(c, lumSrcPtr, chrUSrcPtr, chrVSrcPtr, + alpPixBuf ? alpSrcPtr : NULL, + dest[0], dstW, lumAlpha, chrAlpha, dstY); } else { //general RGB - yuv2packedX(c, - vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, - vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, dstW, dstY); + yuv2packedX(c, vLumFilter + dstY * vLumFilterSize, + lumSrcPtr, vLumFilterSize, + vChrFilter + dstY * vChrFilterSize, + chrUSrcPtr, chrVSrcPtr, vChrFilterSize, + alpSrcPtr, dest[0], dstW, dstY); } } } diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 9967c99eda..453cc9ee5e 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -60,37 +60,27 @@ typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[], typedef void (*yuv2planar1_fn) (struct SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, - uint8_t *dest, - uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, - int dstW, int chrDstW); -typedef void (*yuv2planarX_fn) (struct SwsContext *c, - const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, + uint8_t *dest[4], int dstW, int chrDstW); +typedef void (*yuv2planarX_fn) (struct SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, - uint8_t *dest, - uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest[4], int dstW, int chrDstW); -typedef void (*yuv2packed1_fn) (struct SwsContext *c, - const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, - uint8_t *dest, - int dstW, int uvalpha, int dstFormat, int flags, int y); -typedef void (*yuv2packed2_fn) (struct SwsContext *c, - const uint16_t *buf0, const uint16_t *buf1, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, const uint16_t *abuf1, - uint8_t *dest, +typedef void (*yuv2packed1_fn) (struct SwsContext *c, const int16_t *lumSrc, + const int16_t *chrUSrc[2], const int16_t *chrVSrc[2], + const int16_t *alpSrc, uint8_t *dest, + int dstW, int uvalpha, int y); +typedef void (*yuv2packed2_fn) (struct SwsContext *c, const int16_t *lumSrc[2], + const int16_t *chrUSrc[2], const int16_t *chrVSrc[2], + const int16_t *alpSrc[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y); -typedef void (*yuv2packedX_fn) (struct SwsContext *c, - const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, +typedef void (*yuv2packedX_fn) (struct SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, - int dstW, int dstY); + int dstW, int y); /* This struct should be aligned on at least a 32-byte boundary. */ typedef struct SwsContext { diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index f6e970832d..de0e4abfe0 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -75,9 +75,11 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest, uint8_t *uDest, uint8_t *vDest, - uint8_t *aDest, int dstW, int chrDstW) + uint8_t *dest[4], int dstW, int chrDstW) { + uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], + *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; + if (uDest) { x86_reg uv_off = c->uv_off; YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) @@ -87,7 +89,7 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, YSCALEYUV2YV12X(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0) } - YSCALEYUV2YV12X(LUM_MMX_FILTER_OFFSET, dest, dstW, 0) + YSCALEYUV2YV12X(LUM_MMX_FILTER_OFFSET, yDest, dstW, 0) } #define YSCALEYUV2YV12X_ACCURATE(offset, dest, end, pos) \ @@ -156,9 +158,11 @@ static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest, uint8_t *uDest, uint8_t *vDest, - uint8_t *aDest, int dstW, int chrDstW) + uint8_t *dest[4], int dstW, int chrDstW) { + uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], + *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; + if (uDest) { x86_reg uv_off = c->uv_off; YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) @@ -168,19 +172,20 @@ static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, YSCALEYUV2YV12X_ACCURATE(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0) } - YSCALEYUV2YV12X_ACCURATE(LUM_MMX_FILTER_OFFSET, dest, dstW, 0) + YSCALEYUV2YV12X_ACCURATE(LUM_MMX_FILTER_OFFSET, yDest, dstW, 0) } static void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, - uint8_t *dest, uint8_t *uDest, uint8_t *vDest, - uint8_t *aDest, int dstW, int chrDstW) + uint8_t *dst[4], int dstW, int chrDstW) { int p= 4; - const int16_t *src[4]= { alpSrc + dstW, lumSrc + dstW, chrUSrc + chrDstW, chrVSrc + chrDstW }; - uint8_t *dst[4]= { aDest, dest, uDest, vDest }; - x86_reg counter[4]= { dstW, dstW, chrDstW, chrDstW }; + const int16_t *src[4]= { + lumSrc + dstW, chrUSrc + chrDstW, + chrVSrc + chrDstW, alpSrc + dstW + }; + x86_reg counter[4]= { dstW, chrDstW, chrDstW, dstW }; while (p--) { if (dst[p]) { @@ -207,13 +212,14 @@ static void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc, static void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, - uint8_t *dest, uint8_t *uDest, uint8_t *vDest, - uint8_t *aDest, int dstW, int chrDstW) + uint8_t *dst[4], int dstW, int chrDstW) { int p= 4; - const int16_t *src[4]= { alpSrc + dstW, lumSrc + dstW, chrUSrc + chrDstW, chrVSrc + chrDstW }; - uint8_t *dst[4]= { aDest, dest, uDest, vDest }; - x86_reg counter[4]= { dstW, dstW, chrDstW, chrDstW }; + const int16_t *src[4]= { + lumSrc + dstW, chrUSrc + chrDstW, + chrVSrc + chrDstW, alpSrc + dstW + }; + x86_reg counter[4]= { dstW, chrDstW, chrDstW, dstW }; while (p--) { if (dst[p]) { @@ -969,14 +975,16 @@ static void RENAME(yuv2yuyv422_X)(SwsContext *c, const int16_t *lumFilter, /** * vertical bilinear scale YV12 to RGB */ -static void RENAME(yuv2rgb32_2)(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, +static void RENAME(yuv2rgb32_2)(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; + if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { + const int16_t *abuf0 = abuf[0], *abuf1 = abuf[1]; #if ARCH_X86_64 __asm__ volatile( YSCALEYUV2RGB(%%r8, %5) @@ -1031,13 +1039,14 @@ static void RENAME(yuv2rgb32_2)(SwsContext *c, const uint16_t *buf0, } } -static void RENAME(yuv2bgr24_2)(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, +static void RENAME(yuv2bgr24_2)(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; + //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" @@ -1053,13 +1062,14 @@ static void RENAME(yuv2bgr24_2)(SwsContext *c, const uint16_t *buf0, ); } -static void RENAME(yuv2rgb555_2)(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, +static void RENAME(yuv2rgb555_2)(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; + //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" @@ -1081,13 +1091,14 @@ static void RENAME(yuv2rgb555_2)(SwsContext *c, const uint16_t *buf0, ); } -static void RENAME(yuv2rgb565_2)(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, +static void RENAME(yuv2rgb565_2)(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; + //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" @@ -1149,13 +1160,14 @@ static void RENAME(yuv2rgb565_2)(SwsContext *c, const uint16_t *buf0, #define YSCALEYUV2PACKED(index, c) REAL_YSCALEYUV2PACKED(index, c) -static void RENAME(yuv2yuyv422_2)(SwsContext *c, const uint16_t *buf0, - const uint16_t *buf1, const uint16_t *ubuf0, - const uint16_t *ubuf1, const uint16_t *vbuf0, - const uint16_t *vbuf1, const uint16_t *abuf0, - const uint16_t *abuf1, uint8_t *dest, +static void RENAME(yuv2yuyv422_2)(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; + //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" @@ -1288,14 +1300,13 @@ static void RENAME(yuv2yuyv422_2)(SwsContext *c, const uint16_t *buf0, /** * YV12 to RGB without scaling or interpolating */ -static void RENAME(yuv2rgb32_1)(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, - int dstW, int uvalpha, enum PixelFormat dstFormat, - int flags, int y) +static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *bguf[2], + const int16_t *abuf0, uint8_t *dest, + int dstW, int uvalpha, int y) { - const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 + const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; + const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { @@ -1356,14 +1367,13 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const uint16_t *buf0, } } -static void RENAME(yuv2bgr24_1)(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, - int dstW, int uvalpha, enum PixelFormat dstFormat, - int flags, int y) +static void RENAME(yuv2bgr24_1)(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *bguf[2], + const int16_t *abuf0, uint8_t *dest, + int dstW, int uvalpha, int y) { - const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 + const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; + const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster __asm__ volatile( @@ -1394,14 +1404,13 @@ static void RENAME(yuv2bgr24_1)(SwsContext *c, const uint16_t *buf0, } } -static void RENAME(yuv2rgb555_1)(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, - int dstW, int uvalpha, enum PixelFormat dstFormat, - int flags, int y) +static void RENAME(yuv2rgb555_1)(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *bguf[2], + const int16_t *abuf0, uint8_t *dest, + int dstW, int uvalpha, int y) { - const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 + const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; + const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster __asm__ volatile( @@ -1444,14 +1453,13 @@ static void RENAME(yuv2rgb555_1)(SwsContext *c, const uint16_t *buf0, } } -static void RENAME(yuv2rgb565_1)(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, - int dstW, int uvalpha, enum PixelFormat dstFormat, - int flags, int y) +static void RENAME(yuv2rgb565_1)(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *bguf[2], + const int16_t *abuf0, uint8_t *dest, + int dstW, int uvalpha, int y) { - const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 + const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; + const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster __asm__ volatile( @@ -1531,14 +1539,13 @@ static void RENAME(yuv2rgb565_1)(SwsContext *c, const uint16_t *buf0, "psraw $7, %%mm7 \n\t" #define YSCALEYUV2PACKED1b(index, c) REAL_YSCALEYUV2PACKED1b(index, c) -static void RENAME(yuv2yuyv422_1)(SwsContext *c, const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, uint8_t *dest, - int dstW, int uvalpha, enum PixelFormat dstFormat, - int flags, int y) +static void RENAME(yuv2yuyv422_1)(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *bguf[2], + const int16_t *abuf0, uint8_t *dest, + int dstW, int uvalpha, int y) { - const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 + const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; + const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster __asm__ volatile( From 8dbaa5bd695e9f0fc3f7bbf52a76fd0d7caa2b80 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Tue, 21 Jun 2011 23:12:42 -0700 Subject: [PATCH 107/780] aacenc: Fix codebook trellising for zeroed bands. Choose band type (codebook) zero, count its bits, and mark the other states as unnavigable. --- libavcodec/aaccoder.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 4d5b98fa63..e752b63c7f 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -432,10 +432,26 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, for (swb = 0; swb < max_sfb; swb++) { size = sce->ics.swb_sizes[swb]; if (sce->zeroes[win*16 + swb]) { - for (cb = 0; cb < 12; cb++) { - path[swb+1][cb].prev_idx = cb; - path[swb+1][cb].cost = path[swb][cb].cost; - path[swb+1][cb].run = path[swb][cb].run + 1; + float cost_stay_here = path[swb][0].cost; + float cost_get_here = next_minrd + run_bits + 4; + if ( run_value_bits[sce->ics.num_windows == 8][path[swb][0].run] + != run_value_bits[sce->ics.num_windows == 8][path[swb][0].run+1]) + cost_stay_here += run_bits; + if (cost_get_here < cost_stay_here) { + path[swb+1][0].prev_idx = next_mincb; + path[swb+1][0].cost = cost_get_here; + path[swb+1][0].run = 1; + } else { + path[swb+1][0].prev_idx = 0; + path[swb+1][0].cost = cost_stay_here; + path[swb+1][0].run = path[swb][0].run + 1; + } + next_minrd = path[swb+1][0].cost; + next_mincb = 0; + for (cb = 1; cb < 12; cb++) { + path[swb+1][cb].cost = 61450; + path[swb+1][cb].prev_idx = -1; + path[swb+1][cb].run = 0; } } else { float minrd = next_minrd; From 1bb52045d3a6eb3fa35dbe8c9775ae07329e4cd6 Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Sun, 19 Jun 2011 22:29:37 -0600 Subject: [PATCH 108/780] aacenc: Save channel configuration for later use. --- libavcodec/aacenc.c | 16 ++++++++-------- libavcodec/aacenc.h | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index e8942a13f9..8c7ed87b4a 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -199,8 +199,9 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) ff_init_ff_sine_windows(10); ff_init_ff_sine_windows(7); + s->chan_map = aac_chan_configs[avctx->channels-1]; s->samples = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0])); - s->cpe = av_mallocz(sizeof(ChannelElement) * aac_chan_configs[avctx->channels-1][0]); + s->cpe = av_mallocz(sizeof(ChannelElement) * s->chan_map[0]); avctx->extradata = av_mallocz(5 + FF_INPUT_BUFFER_PADDING_SIZE); avctx->extradata_size = 5; put_audio_specific_config(avctx); @@ -491,7 +492,6 @@ static int aac_encode_frame(AVCodecContext *avctx, int16_t *samples = s->samples, *samples2, *la; ChannelElement *cpe; int i, ch, w, g, chans, tag, start_ch; - const uint8_t *chan_map = aac_chan_configs[avctx->channels-1]; int chan_el_counter[4]; FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; @@ -504,8 +504,8 @@ static int aac_encode_frame(AVCodecContext *avctx, } else { start_ch = 0; samples2 = s->samples + 1024 * avctx->channels; - for (i = 0; i < chan_map[0]; i++) { - tag = chan_map[i+1]; + for (i = 0; i < s->chan_map[0]; i++) { + tag = s->chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; ff_psy_preprocess(s->psypp, (uint16_t*)data + start_ch, samples2 + start_ch, start_ch, chans); @@ -520,9 +520,9 @@ static int aac_encode_frame(AVCodecContext *avctx, } start_ch = 0; - for (i = 0; i < chan_map[0]; i++) { + for (i = 0; i < s->chan_map[0]; i++) { FFPsyWindowInfo* wi = windows + start_ch; - tag = chan_map[i+1]; + tag = s->chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; for (ch = 0; ch < chans; ch++) { @@ -562,9 +562,9 @@ static int aac_encode_frame(AVCodecContext *avctx, put_bitstream_info(avctx, s, LIBAVCODEC_IDENT); start_ch = 0; memset(chan_el_counter, 0, sizeof(chan_el_counter)); - for (i = 0; i < chan_map[0]; i++) { + for (i = 0; i < s->chan_map[0]; i++) { FFPsyWindowInfo* wi = windows + start_ch; - tag = chan_map[i+1]; + tag = s->chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; put_bits(&s->pb, 3, tag); diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h index 067a9b04f3..3f590fefea 100644 --- a/libavcodec/aacenc.h +++ b/libavcodec/aacenc.h @@ -61,6 +61,7 @@ typedef struct AACEncContext { int16_t *samples; ///< saved preprocessed input int samplerate_index; ///< MPEG-4 samplerate index + uint8_t *chan_map; ///< channel configuration map ChannelElement *cpe; ///< channel elements FFPsyContext psy; From ca699ac24e85c2f4ef8effa5d57d1c3082160d30 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 28 Jun 2011 10:35:30 +0200 Subject: [PATCH 109/780] dict: fix various typos --- libavutil/dict.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavutil/dict.h b/libavutil/dict.h index dc575eb76c..b960923f17 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -21,11 +21,10 @@ * @file Public dictionary API. * @deprecated * AVDictionary is provided for compatibility with libav. It is both in - * implementation as well as API inefficient. It doesnt scale and is - * be extreemly slow with large dictionaries. - * It is recommanded that new code uses our tree container from tree.c/h - * where applicable. - * Which uses AVL trees to achive O(log n) performance + * implementation as well as API inefficient. It does not scale and is + * extremely slow with large dictionaries. + * It is recommended that new code uses our tree container from tree.c/h + * where applicable, which uses AVL trees to achive O(log n) performance. */ #ifndef AVUTIL_DICT_H From d2ee495fb241fa4ef5b8b56161328c4379d1c79a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 22 Jun 2011 23:30:15 +0200 Subject: [PATCH 110/780] configure: Drop check for availability of ten assembler operands. This was done to support gcc 2.95, which is an old legacy compiler that fails to compile the current codebase anyway. --- configure | 14 -------------- libavcodec/x86/dsputil_mmx.c | 4 ++-- libavcodec/x86/mlpdsp.c | 6 +++--- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/configure b/configure index d8454e0d23..c2975d3f61 100755 --- a/configure +++ b/configure @@ -1120,7 +1120,6 @@ HAVE_LIST=" sys_select_h sys_soundcard_h sys_videoio_h - ten_operands threads trunc truncf @@ -2704,18 +2703,6 @@ EOF # check whether xmm clobbers are supported check_asm xmm_clobbers '"":::"%xmm0"' - # check whether more than 10 operands are supported - check_cc <add_hfyu_median_prediction = ff_add_hfyu_median_prediction_mmx2; #endif -#if HAVE_7REGS && HAVE_TEN_OPERANDS +#if HAVE_7REGS if( mm_flags&AV_CPU_FLAG_3DNOW ) c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov; #endif diff --git a/libavcodec/x86/mlpdsp.c b/libavcodec/x86/mlpdsp.c index 333dc561f1..400855d7c4 100644 --- a/libavcodec/x86/mlpdsp.c +++ b/libavcodec/x86/mlpdsp.c @@ -23,7 +23,7 @@ #include "libavcodec/dsputil.h" #include "libavcodec/mlp.h" -#if HAVE_7REGS && HAVE_TEN_OPERANDS +#if HAVE_7REGS extern void ff_mlp_firorder_8; extern void ff_mlp_firorder_7; @@ -171,11 +171,11 @@ static void mlp_filter_channel_x86(int32_t *state, const int32_t *coeff, ); } -#endif /* HAVE_7REGS && HAVE_TEN_OPERANDS */ +#endif /* HAVE_7REGS */ void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx) { -#if HAVE_7REGS && HAVE_TEN_OPERANDS +#if HAVE_7REGS c->mlp_filter_channel = mlp_filter_channel_x86; #endif } From bb00b15f9e4e3c56abf628ed2cb9bfa8965e2bf8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 27 Jun 2011 00:42:55 +0200 Subject: [PATCH 111/780] avutil: Remove unused arbitrary precision integer code. --- libavcodec/utils.c | 1 - libavutil/integer.c | 197 ---------------------------------------- libavutil/integer.h | 86 ------------------ libavutil/mathematics.c | 29 ------ 4 files changed, 313 deletions(-) delete mode 100644 libavutil/integer.c delete mode 100644 libavutil/integer.h diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 146dd306c3..4e15f6fb42 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -26,7 +26,6 @@ */ #include "libavutil/avstring.h" -#include "libavutil/integer.h" #include "libavutil/crc.h" #include "libavutil/pixdesc.h" #include "libavutil/audioconvert.h" diff --git a/libavutil/integer.c b/libavutil/integer.c deleted file mode 100644 index 0114bb0671..0000000000 --- a/libavutil/integer.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - * arbitrary precision integers - * Copyright (c) 2004 Michael Niedermayer - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * arbitrary precision integers - * @author Michael Niedermayer - */ - -#include "common.h" -#include "integer.h" - -AVInteger av_add_i(AVInteger a, AVInteger b){ - int i, carry=0; - - for(i=0; i>16) + a.v[i] + b.v[i]; - a.v[i]= carry; - } - return a; -} - -AVInteger av_sub_i(AVInteger a, AVInteger b){ - int i, carry=0; - - for(i=0; i>16) + a.v[i] - b.v[i]; - a.v[i]= carry; - } - return a; -} - -int av_log2_i(AVInteger a){ - int i; - - for(i=AV_INTEGER_SIZE-1; i>=0; i--){ - if(a.v[i]) - return av_log2_16bit(a.v[i]) + 16*i; - } - return -1; -} - -AVInteger av_mul_i(AVInteger a, AVInteger b){ - AVInteger out; - int i, j; - int na= (av_log2_i(a)+16) >> 4; - int nb= (av_log2_i(b)+16) >> 4; - - memset(&out, 0, sizeof(out)); - - for(i=0; i>16) + out.v[j] + a.v[i]*b.v[j-i]; - out.v[j]= carry; - } - } - - return out; -} - -int av_cmp_i(AVInteger a, AVInteger b){ - int i; - int v= (int16_t)a.v[AV_INTEGER_SIZE-1] - (int16_t)b.v[AV_INTEGER_SIZE-1]; - if(v) return (v>>16)|1; - - for(i=AV_INTEGER_SIZE-2; i>=0; i--){ - int v= a.v[i] - b.v[i]; - if(v) return (v>>16)|1; - } - return 0; -} - -AVInteger av_shr_i(AVInteger a, int s){ - AVInteger out; - int i; - - for(i=0; i>4); - unsigned int v=0; - if(index+1> (s&15); - } - return out; -} - -AVInteger av_mod_i(AVInteger *quot, AVInteger a, AVInteger b){ - int i= av_log2_i(a) - av_log2_i(b); - AVInteger quot_temp; - if(!quot) quot = "_temp; - - assert((int16_t)a[AV_INTEGER_SIZE-1] >= 0 && (int16_t)b[AV_INTEGER_SIZE-1] >= 0); - assert(av_log2(b)>=0); - - if(i > 0) - b= av_shr_i(b, -i); - - memset(quot, 0, sizeof(AVInteger)); - - while(i-- >= 0){ - *quot= av_shr_i(*quot, -1); - if(av_cmp_i(a, b) >= 0){ - a= av_sub_i(a, b); - quot->v[0] += 1; - } - b= av_shr_i(b, 1); - } - return a; -} - -AVInteger av_div_i(AVInteger a, AVInteger b){ - AVInteger quot; - av_mod_i(", a, b); - return quot; -} - -AVInteger av_int2i(int64_t a){ - AVInteger out; - int i; - - for(i=0; i>=16; - } - return out; -} - -int64_t av_i2int(AVInteger a){ - int i; - int64_t out=(int8_t)a.v[AV_INTEGER_SIZE-1]; - - for(i= AV_INTEGER_SIZE-2; i>=0; i--){ - out = (out<<16) + a.v[i]; - } - return out; -} - -#ifdef TEST -#undef NDEBUG -#include - -const uint8_t ff_log2_tab[256]={ - 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -}; - -int main(void){ - int64_t a,b; - - for(a=7; a<256*256*256; a+=13215){ - for(b=3; b<256*256*256; b+=27118){ - AVInteger ai= av_int2i(a); - AVInteger bi= av_int2i(b); - - assert(av_i2int(ai) == a); - assert(av_i2int(bi) == b); - assert(av_i2int(av_add_i(ai,bi)) == a+b); - assert(av_i2int(av_sub_i(ai,bi)) == a-b); - assert(av_i2int(av_mul_i(ai,bi)) == a*b); - assert(av_i2int(av_shr_i(ai, 9)) == a>>9); - assert(av_i2int(av_shr_i(ai,-9)) == a<<9); - assert(av_i2int(av_shr_i(ai, 17)) == a>>17); - assert(av_i2int(av_shr_i(ai,-17)) == a<<17); - assert(av_log2_i(ai) == av_log2(a)); - assert(av_i2int(av_div_i(ai,bi)) == a/b); - } - } - return 0; -} -#endif diff --git a/libavutil/integer.h b/libavutil/integer.h deleted file mode 100644 index f434cfadab..0000000000 --- a/libavutil/integer.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * arbitrary precision integers - * Copyright (c) 2004 Michael Niedermayer - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * arbitrary precision integers - * @author Michael Niedermayer - */ - -#ifndef AVUTIL_INTEGER_H -#define AVUTIL_INTEGER_H - -#include -#include "common.h" - -#define AV_INTEGER_SIZE 8 - -typedef struct AVInteger{ - uint16_t v[AV_INTEGER_SIZE]; -} AVInteger; - -AVInteger av_add_i(AVInteger a, AVInteger b) av_const; -AVInteger av_sub_i(AVInteger a, AVInteger b) av_const; - -/** - * Return the rounded-down value of the base 2 logarithm of the given - * AVInteger. This is simply the index of the most significant bit - * which is 1, or 0 if all bits are 0. - */ -int av_log2_i(AVInteger a) av_const; -AVInteger av_mul_i(AVInteger a, AVInteger b) av_const; - -/** - * Return 0 if a==b, 1 if a>b and -1 if a (1LL<<63)) - continue; - - if(d!=e) printf("%"PRId64"*%"PRId64"/%"PRId64"= %"PRId64"=%"PRId64"\n", a, b, c, d, e); - } - } - } - return 0; -} -#endif From 512933671409f9f88cc9fdfc8f29525d32240bab Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Tue, 28 Jun 2011 13:26:56 +0200 Subject: [PATCH 112/780] pict_type: add a value for unknown/none. In commit bebe72f4a05d338e04ae9ca1e9c6b72749b488aa, the enum AV_PICTURE_TYPE_* was introduced. There are still places in the code where pict_type is used as an integer and there is a case where "pict_type = 0" with the explanation "let ffmpeg decide what to do". The new enum does not know a value of 0 and C++ will fail if compiling such programs anyway as it is refered as an int (and you cannot patch them properly). --- libavutil/avutil.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 33eacc7fae..1b196a916d 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -104,7 +104,8 @@ enum AVMediaType { #define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} enum AVPictureType { - AV_PICTURE_TYPE_I = 1, ///< Intra + AV_PICTURE_TYPE_NONE = 0, ///< Undefined + AV_PICTURE_TYPE_I, ///< Intra AV_PICTURE_TYPE_P, ///< Predicted AV_PICTURE_TYPE_B, ///< Bi-dir predicted AV_PICTURE_TYPE_S, ///< S(GMC)-VOP MPEG4 From deb3ed01b50f5706a610bf7f3e82ef97e910a65e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 28 Jun 2011 14:45:57 +0100 Subject: [PATCH 113/780] build: replace some addprefix/addsuffix with substitution refs Signed-off-by: Mans Rullgard --- common.mak | 20 ++++++++++---------- tests/Makefile | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/common.mak b/common.mak index e2eaa399da..19be4a6949 100644 --- a/common.mak +++ b/common.mak @@ -11,21 +11,21 @@ OBJS += $(OBJS-yes) FFLIBS := $(FFLIBS-yes) $(FFLIBS) TESTPROGS += $(TESTPROGS-yes) -FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS) -FFLDFLAGS := $(addprefix -Llib,$(ALLFFLIBS)) $(LDFLAGS) +FFEXTRALIBS := $(FFLIBS:%=-l%$(BUILDSUF)) $(EXTRALIBS) +FFLDFLAGS := $(ALLFFLIBS:%=-Llib%) $(LDFLAGS) -EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES))) -OBJS := $(addprefix $(SUBDIR),$(sort $(OBJS))) -TESTOBJS := $(addprefix $(SUBDIR),$(TESTOBJS) $(TESTPROGS:%=%-test.o)) -TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS))) -HOSTOBJS := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS))) -HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS))) +EXAMPLES := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF)) +OBJS := $(sort $(OBJS:%=$(SUBDIR)%)) +TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o) +TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF)) +HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o) +HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF)) DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME)) ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h)) -SKIPHEADERS += $(addprefix $(ARCH)/,$(ARCH_HEADERS)) -SKIPHEADERS := $(addprefix $(SUBDIR),$(SKIPHEADERS-) $(SKIPHEADERS)) +SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-) +SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%) checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho)) $(HOSTOBJS): %.o: %.c diff --git a/tests/Makefile b/tests/Makefile index fb9b56e6b3..87ec0256de 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -112,7 +112,7 @@ clean:: testclean testclean: $(RM) -r tests/vsynth1 tests/vsynth2 tests/data - $(RM) $(addprefix tests/,$(CLEANSUFFIXES)) + $(RM) $(CLEANSUFFIXES:%=tests/%) $(RM) tests/seek_test$(EXESUF) tests/seek_test.o $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF)) From bd2deab706bba303e15fb43e91f46a9f7840aba6 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Thu, 23 Jun 2011 14:26:34 -0400 Subject: [PATCH 114/780] cosmetics: remove outdated comment that is no longer true --- libavcodec/ac3enc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 44dfce80e2..809a3f5a4f 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -306,8 +306,6 @@ static av_cold void exponent_init(AC3EncodeContext *s) /** * Extract exponents from the MDCT coefficients. - * This takes into account the normalization that was done to the input samples - * by adjusting the exponents by the exponent shift values. */ static void extract_exponents(AC3EncodeContext *s) { From cb7b55b0962f5503f601d6b557f8945444b73395 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 28 Jun 2011 11:49:32 +0200 Subject: [PATCH 115/780] wavpack: skip blocks with no samples These blocks don't report audio stream parameters and they are not needed for decoding. Signed-off-by: Mans Rullgard --- libavformat/wv.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/wv.c b/libavformat/wv.c index 8f9d0fdb1b..d6d7099ba7 100644 --- a/libavformat/wv.c +++ b/libavformat/wv.c @@ -110,6 +110,9 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb, int appen size = wc->blksize; } wc->flags = AV_RL32(wc->extra + 4); + // blocks with zero samples don't contain actual audio information and should be ignored + if (!AV_RN32(wc->extra)) + return 0; //parse flags bpp = ((wc->flags & 3) + 1) << 3; chan = 1 + !(wc->flags & WV_MONO); @@ -207,8 +210,14 @@ static int wv_read_header(AVFormatContext *s, AVStream *st; wc->block_parsed = 0; - if(wv_read_block_header(s, pb, 0) < 0) - return -1; + for(;;){ + if(wv_read_block_header(s, pb, 0) < 0) + return -1; + if(!AV_RN32(wc->extra)) + avio_skip(pb, wc->blksize - 24); + else + break; + } /* now we are ready: build format streams */ st = av_new_stream(s, 0); From 618230c7f44adf2c6acc68028e4117376c9f68db Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Mon, 27 Jun 2011 20:49:12 -0700 Subject: [PATCH 116/780] swscale: update big endian reference values after dff5a835. --- tests/ref/lavfi/pixdesc_be | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/ref/lavfi/pixdesc_be b/tests/ref/lavfi/pixdesc_be index 830fd2a793..de13e94cff 100644 --- a/tests/ref/lavfi/pixdesc_be +++ b/tests/ref/lavfi/pixdesc_be @@ -5,7 +5,9 @@ bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f bgr48le d022bfdd6a07d5dcc693799322a386b4 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 +bgr555le 378d6ac4223651a1adcbf94a3d0d807b bgr565be 257cf78afa35dc31e9696f139c916715 +bgr565le 1dfdd03995c287e3c754b164bf26a355 bgr8 24bd566170343d06fec6fccfff5abc54 bgra 76a18a5151242fa137133f604cd624d2 gray db08f7f0751900347e6b8649e4164d21 @@ -20,7 +22,9 @@ rgb48be 460b6de89b156290a12d3941db8bd731 rgb48le cd93cb34d15996987367dabda3a10128 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 rgb555be 912a62c5e53bfcbac2a0340e10973cf2 +rgb555le a937a0fc764fb57dc1b3af87cba0273c rgb565be 9cadf742e05ddc23a3b5b270f89aad3c +rgb565le d39aa298bb525e9be8860351c6f62dab rgb8 4a9d8e4f2f154e83a7e1735be6300700 rgba 93a5b3712e6eb8c5b9a09ffc7b9fbc12 uyvy422 adcf64516a19fce44df77082bdb16291 From efdb198e00bf4cf21023db6f47f16aab6ee31393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Mon, 27 Jun 2011 19:05:49 +0200 Subject: [PATCH 117/780] targa: Simplify using bytestream_get functions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Reimar Döffinger --- libavcodec/targa.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libavcodec/targa.c b/libavcodec/targa.c index 41741ff9c5..7418f92d1b 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/imgutils.h" #include "avcodec.h" +#include "bytestream.h" #include "targa.h" typedef struct TargaContext { @@ -116,13 +117,13 @@ static int decode_frame(AVCodecContext *avctx, idlen = *buf++; buf++; /* pal */ compr = *buf++; - first_clr = AV_RL16(buf); buf += 2; - colors = AV_RL16(buf); buf += 2; + first_clr = bytestream_get_le16(&buf); + colors = bytestream_get_le16(&buf); csize = *buf++; buf += 2; /* x */ - y = AV_RL16(buf); buf += 2; - w = AV_RL16(buf); buf += 2; - h = AV_RL16(buf); buf += 2; + y = bytestream_get_le16(&buf); + w = bytestream_get_le16(&buf); + h = bytestream_get_le16(&buf); bpp = *buf++; flags = *buf++; //skip identifier if any @@ -186,13 +187,10 @@ static int decode_frame(AVCodecContext *avctx, if(avctx->pix_fmt != PIX_FMT_PAL8)//should not occur but skip palette anyway buf += pal_size; else{ - int r, g, b, t; + int t; int32_t *pal = ((int32_t*)p->data[1]) + first_clr; for(t = 0; t < colors; t++){ - b = *buf++; - g = *buf++; - r = *buf++; - *pal++ = (0xff<<24) | (r << 16) | (g << 8) | b; + *pal++ = (0xff<<24) | bytestream_get_le24(&buf); } p->palette_has_changed = 1; } From 90cbbbc1e2fbe0ea35da450f82d2b6e53691b9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Mon, 27 Jun 2011 19:15:46 +0200 Subject: [PATCH 118/780] targa: Do not read colormap from files without one. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is necessary because some programs writing TGA files forget to initialize parts of the header they don't care about, resulting in "random" data there. The new behaviour is consistent with other programs, e.g. tgatoppm. Signed-off-by: Reimar Döffinger --- libavcodec/targa.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/targa.c b/libavcodec/targa.c index 7418f92d1b..88b34f3bf4 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -109,17 +109,22 @@ static int decode_frame(AVCodecContext *avctx, AVFrame * const p= (AVFrame*)&s->picture; uint8_t *dst; int stride; - int idlen, compr, y, w, h, bpp, flags; + int idlen, pal, compr, y, w, h, bpp, flags; int first_clr, colors, csize; /* parse image header */ CHECK_BUFFER_SIZE(buf, buf_end, 18, "header"); idlen = *buf++; - buf++; /* pal */ + pal = *buf++; compr = *buf++; first_clr = bytestream_get_le16(&buf); colors = bytestream_get_le16(&buf); csize = *buf++; + if (!pal && (first_clr || colors || csize)) { + av_log(avctx, AV_LOG_WARNING, "File without colormap has colormap information set.\n"); + // specification says we should ignore those value in this case + first_clr = colors = csize = 0; + } buf += 2; /* x */ y = bytestream_get_le16(&buf); w = bytestream_get_le16(&buf); From 57b4a3dd2b358b2122736af861c1538acd1eed1a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 28 Jun 2011 17:08:00 +0100 Subject: [PATCH 119/780] build: include sub-makefiles using full path instead of symlinks Signed-off-by: Mans Rullgard --- Makefile | 8 ++++---- configure | 15 +-------------- libavcodec/Makefile | 4 ++-- libavdevice/Makefile | 2 +- libavfilter/Makefile | 4 ++-- libavformat/Makefile | 2 +- libavutil/Makefile | 2 +- libpostproc/Makefile | 2 +- libswscale/Makefile | 2 +- subdir.mak | 2 +- 10 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index f16da3acca..24a5951ec1 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ DATA_FILES := $(wildcard $(SRC_PATH)/ffpresets/*.ffpreset) SKIPHEADERS = cmdutils_common_opts.h -include common.mak +include $(SRC_PATH)/common.mak FF_LDFLAGS := $(FFLDFLAGS) FF_EXTRALIBS := $(FFEXTRALIBS) @@ -105,7 +105,7 @@ endef define DOSUBDIR $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V)))) SUBDIR := $(1)/ -include $(1)/Makefile +include $(SRC_PATH)/$(1)/Makefile endef $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D)))) @@ -182,8 +182,8 @@ config: check: test checkheaders -include doc/Makefile -include tests/Makefile +include $(SRC_PATH)/doc/Makefile +include $(SRC_PATH)/tests/Makefile # Dummy rule to stop make trying to rebuild removed or renamed headers %.h: diff --git a/configure b/configure index c2975d3f61..0857d6f3b2 100755 --- a/configure +++ b/configure @@ -3214,23 +3214,10 @@ if enabled source_path_used; then " FILES=" Makefile - common.mak - subdir.mak - doc/Makefile doc/texi2pod.pl - libavcodec/Makefile - libavcodec/${arch}/Makefile - libavdevice/Makefile - libavfilter/Makefile - libavfilter/${arch}/Makefile - libavformat/Makefile - libavutil/Makefile - libpostproc/Makefile - libswscale/Makefile - tests/Makefile " map 'mkdir -p $v' $DIRS; - map 'test -f "$source_path/$v" && $ln_s "$source_path/$v" $v' $FILES + map '$ln_s "$source_path/$v" $v' $FILES fi config_files="$TMPH config.mak" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 64a286289d..b781ed7ef3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -649,7 +649,7 @@ OBJS-$(CONFIG_MLIB) += mlib/dsputil_mlib.o \ # well. OBJS-$(!CONFIG_SMALL) += inverse.o --include $(SUBDIR)$(ARCH)/Makefile +-include $(SRC_PATH)/$(SUBDIR)$(ARCH)/Makefile SKIPHEADERS += %_tablegen.h \ %_tables.h \ @@ -678,7 +678,7 @@ DIRS = alpha arm bfin mlib ppc ps2 sh4 sparc x86 CLEANFILES = *_tables.c *_tables.h *_tablegen$(HOSTEXESUF) -include $(SUBDIR)../subdir.mak +include $(SRC_PATH)/subdir.mak $(SUBDIR)dct-test$(EXESUF): $(SUBDIR)dctref.o diff --git a/libavdevice/Makefile b/libavdevice/Makefile index cbe20d6d57..eaf27ddc42 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -29,4 +29,4 @@ OBJS-$(CONFIG_LIBDC1394_INDEV) += libdc1394.o SKIPHEADERS-$(HAVE_ALSA_ASOUNDLIB_H) += alsa-audio.h SKIPHEADERS-$(HAVE_SNDIO_H) += sndio_common.h -include $(SUBDIR)../subdir.mak +include $(SRC_PATH)/subdir.mak diff --git a/libavfilter/Makefile b/libavfilter/Makefile index e22527ae49..02016076bf 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -58,8 +58,8 @@ OBJS-$(CONFIG_NULLSRC_FILTER) += vsrc_nullsrc.o OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o --include $(SUBDIR)$(ARCH)/Makefile +-include $(SRC_PATH)/$(SUBDIR)$(ARCH)/Makefile DIRS = x86 -include $(SUBDIR)../subdir.mak +include $(SRC_PATH)/subdir.mak diff --git a/libavformat/Makefile b/libavformat/Makefile index 5041fe0dc9..3d22c6f265 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -336,6 +336,6 @@ OBJS-$(CONFIG_JACK_INDEV) += timefilter.o EXAMPLES = output TESTPROGS = timefilter -include $(SUBDIR)../subdir.mak +include $(SRC_PATH)/subdir.mak $(SUBDIR)output-example$(EXESUF): ELIBS = -lswscale diff --git a/libavutil/Makefile b/libavutil/Makefile index 304b288851..01344df2a3 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -82,6 +82,6 @@ DIRS = arm bfin sh4 x86 ARCH_HEADERS = bswap.h intmath.h intreadwrite.h timer.h -include $(SUBDIR)../subdir.mak +include $(SRC_PATH)/subdir.mak $(SUBDIR)lzo-test$(EXESUF): ELIBS = -llzo2 diff --git a/libpostproc/Makefile b/libpostproc/Makefile index 7b359709dc..11de3d3235 100644 --- a/libpostproc/Makefile +++ b/libpostproc/Makefile @@ -5,4 +5,4 @@ HEADERS = postprocess.h OBJS = postprocess.o -include $(SUBDIR)../subdir.mak +include $(SRC_PATH)/subdir.mak diff --git a/libswscale/Makefile b/libswscale/Makefile index b2914113c0..57e867a1b2 100644 --- a/libswscale/Makefile +++ b/libswscale/Makefile @@ -22,4 +22,4 @@ TESTPROGS = colorspace swscale DIRS = bfin mlib ppc sparc x86 -include $(SUBDIR)../subdir.mak +include $(SRC_PATH)/subdir.mak diff --git a/subdir.mak b/subdir.mak index f544796022..e7c9eaafca 100644 --- a/subdir.mak +++ b/subdir.mak @@ -1,6 +1,6 @@ SRC_DIR := $(SRC_PATH)/lib$(NAME) -include $(SUBDIR)../common.mak +include $(SRC_PATH)/common.mak LIBVERSION := $(lib$(NAME)_VERSION) LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR) From 7ac6910dd83be28331edccf5ad7511cb006afd05 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 28 Jun 2011 17:12:36 +0100 Subject: [PATCH 120/780] build: call texi2pod.pl with full path instead of symlink Signed-off-by: Mans Rullgard --- configure | 6 +----- doc/Makefile | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 0857d6f3b2..16ef011be7 100755 --- a/configure +++ b/configure @@ -3212,12 +3212,8 @@ if enabled source_path_used; then tests tools " - FILES=" - Makefile - doc/texi2pod.pl - " map 'mkdir -p $v' $DIRS; - map '$ln_s "$source_path/$v" $v' $FILES + $ln_s "$source_path/Makefile" . fi config_files="$TMPH config.mak" diff --git a/doc/Makefile b/doc/Makefile index 558277ad0c..da46cce647 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -18,7 +18,7 @@ doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init doc/%.pod: TAG = POD doc/%.pod: doc/%.texi $(Q)$(TEXIDEP) - $(M)doc/texi2pod.pl $< $@ + $(M)$(SRC_PATH)/doc/texi2pod.pl $< $@ doc/%.1: TAG = MAN doc/%.1: doc/%.pod From d6cc6ac6b844ce0ea8c8e6383b940ca2a94c2993 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 28 Jun 2011 19:42:17 +0200 Subject: [PATCH 121/780] swscale: Add Doxygen for yuv2planar*/yuv2packed* functions. --- libswscale/swscale_internal.h | 98 +++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 453cc9ee5e..decf101e56 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -57,24 +57,122 @@ typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]); +/** + * Write one line of horizontally scaled Y/U/V/A to planar output + * without any additional vertical scaling (or point-scaling). + * + * @param c SWS scaling context + * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output + * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output + * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output + * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output + * @param dest pointer to the 4 output planes (Y/U/V/A) + * @param dstW width of dest[0], dest[3], lumSrc and alpSrc in pixels + * @param chrDstW width of dest[1], dest[2], chrUSrc and chrVSrc + */ typedef void (*yuv2planar1_fn) (struct SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, uint8_t *dest[4], int dstW, int chrDstW); +/** + * Write one line of horizontally scaled Y/U/V/A to planar output + * with multi-point vertical scaling between input pixels. + * + * @param c SWS scaling context + * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096] + * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output + * @param lumFilterSize number of vertical luma/alpha input lines to scale + * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096] + * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output + * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output + * @param chrFilterSize number of vertical chroma input lines to scale + * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output + * @param dest pointer to the 4 output planes (Y/U/V/A) + * @param dstW width of dest[0], dest[3], lumSrc and alpSrc in pixels + * @param chrDstW width of dest[1], dest[2], chrUSrc and chrVSrc + */ typedef void (*yuv2planarX_fn) (struct SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest[4], int dstW, int chrDstW); +/** + * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB + * output without any additional vertical scaling (or point-scaling). Note + * that this function may do chroma scaling, see the "uvalpha" argument. + * + * @param c SWS scaling context + * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output + * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output + * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output + * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output + * @param dest pointer to the output plane + * @param dstW width of lumSrc and alpSrc in pixels, number of pixels + * to write into dest[] + * @param uvalpha chroma scaling coefficient for the second line of chroma + * pixels, either 2048 or 0. If 0, one chroma input is used + * for 2 output pixels (or if the SWS_FLAG_FULL_CHR_INT flag + * is set, it generates 1 output pixel). If 2048, two chroma + * input pixels should be averaged for 2 output pixels (this + * only happens if SWS_FLAG_FULL_CHR_INT is not set) + * @param y vertical line number for this output. This does not need + * to be used to calculate the offset in the destination, + * but can be used to generate comfort noise using dithering + * for some output formats. + */ typedef void (*yuv2packed1_fn) (struct SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc[2], const int16_t *chrVSrc[2], const int16_t *alpSrc, uint8_t *dest, int dstW, int uvalpha, int y); +/** + * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB + * output by doing bilinear scaling between two input lines. + * + * @param c SWS scaling context + * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output + * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output + * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output + * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output + * @param dest pointer to the output plane + * @param dstW width of lumSrc and alpSrc in pixels, number of pixels + * to write into dest[] + * @param yalpha luma/alpha scaling coefficients for the second input line. + * The first line's coefficients can be calculated by using + * 4096 - yalpha + * @param uvalpha chroma scaling coefficient for the second input line. The + * first line's coefficients can be calculated by using + * 4096 - uvalpha + * @param y vertical line number for this output. This does not need + * to be used to calculate the offset in the destination, + * but can be used to generate comfort noise using dithering + * for some output formats. + */ typedef void (*yuv2packed2_fn) (struct SwsContext *c, const int16_t *lumSrc[2], const int16_t *chrUSrc[2], const int16_t *chrVSrc[2], const int16_t *alpSrc[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y); +/** + * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB + * output by doing multi-point vertical scaling between input pixels. + * + * @param c SWS scaling context + * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096] + * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output + * @param lumFilterSize number of vertical luma/alpha input lines to scale + * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096] + * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output + * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output + * @param chrFilterSize number of vertical chroma input lines to scale + * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output + * @param dest pointer to the output plane + * @param dstW width of lumSrc and alpSrc in pixels, number of pixels + * to write into dest[] + * @param y vertical line number for this output. This does not need + * to be used to calculate the offset in the destination, + * but can be used to generate comfort noise using dithering + * or some output formats. + */ typedef void (*yuv2packedX_fn) (struct SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, From e78f96811247571fe111c38672cfae6074bdb1d4 Mon Sep 17 00:00:00 2001 From: Paul Sterne Date: Sun, 26 Jun 2011 12:55:53 -0700 Subject: [PATCH 122/780] Fix configure problem with out-of-source-tree build for fate-related .mak files in the tests and tests/fate subdirectories This patch will add to the list of files for which configure creates symbolic links when building outside of the ffmpeg source tree. This fixes a problem for fate-related .mak files in the tests and tests/fate subdirectories. --- configure | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configure b/configure index afa25d9d06..4c9b7318df 100755 --- a/configure +++ b/configure @@ -3300,6 +3300,7 @@ if enabled source_path_used; then libswscale libswscale/$arch tests + tests/fate tools " FILES=" @@ -3318,6 +3319,15 @@ if enabled source_path_used; then libpostproc/Makefile libswscale/Makefile tests/Makefile + tests/fate.mak + tests/fate2.mak + tests/fate/aac.mak + tests/fate/als.mak + tests/fate/fft.mak + tests/fate/h264.mak + tests/fate/mp3.mak + tests/fate/vorbis.mak + tests/fate/vp8.mak " map 'mkdir -p $v' $DIRS; map 'test -f "$source_path/$v" && $ln_s "$source_path/$v" $v' $FILES From 842f463c7706671546a637a23ad9639aaac7b969 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 28 Jun 2011 21:24:35 +0100 Subject: [PATCH 123/780] fate: merge identical pixdesc_be/le tests Signed-off-by: Mans Rullgard --- configure | 1 - tests/lavfi-regression.sh | 2 +- tests/ref/lavfi/{pixdesc_be => pixdesc} | 0 tests/ref/lavfi/pixdesc_le | 52 ------------------------- 4 files changed, 1 insertion(+), 54 deletions(-) rename tests/ref/lavfi/{pixdesc_be => pixdesc} (100%) delete mode 100644 tests/ref/lavfi/pixdesc_le diff --git a/configure b/configure index 16ef011be7..0e978ba5ff 100755 --- a/configure +++ b/configure @@ -1592,7 +1592,6 @@ test_deps _muxer _demuxer \ ac3_fixed_test_deps="ac3_fixed_encoder ac3_decoder rm_muxer rm_demuxer" mpg_test_deps="mpeg1system_muxer mpegps_demuxer" -set_ne_test_deps pixdesc set_ne_test_deps pixfmts_copy set_ne_test_deps pixfmts_crop set_ne_test_deps pixfmts_hflip diff --git a/tests/lavfi-regression.sh b/tests/lavfi-regression.sh index 4a483e68a5..8942756697 100755 --- a/tests/lavfi-regression.sh +++ b/tests/lavfi-regression.sh @@ -69,7 +69,7 @@ do_lavfi_pixfmts "pad" "500:400:20:20" do_lavfi_pixfmts "scale" "200:100" do_lavfi_pixfmts "vflip" "" -if [ -n "$do_pixdesc_be" ] || [ -n "$do_pixdesc_le" ]; then +if [ -n "$do_pixdesc" ]; then pix_fmts="$($ffmpeg -pix_fmts list 2>/dev/null | sed -ne '9,$p' | grep '^IO' | cut -d' ' -f2 | sort)" for pix_fmt in $pix_fmts; do do_video_filter $pix_fmt "slicify=random,format=$pix_fmt,pixdesctest" -pix_fmt $pix_fmt diff --git a/tests/ref/lavfi/pixdesc_be b/tests/ref/lavfi/pixdesc similarity index 100% rename from tests/ref/lavfi/pixdesc_be rename to tests/ref/lavfi/pixdesc diff --git a/tests/ref/lavfi/pixdesc_le b/tests/ref/lavfi/pixdesc_le deleted file mode 100644 index de13e94cff..0000000000 --- a/tests/ref/lavfi/pixdesc_le +++ /dev/null @@ -1,52 +0,0 @@ -abgr 037bf9df6a765520ad6d490066bf4b89 -argb c442a8261c2265a07212ef0f72e35f5a -bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b -bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f -bgr48le d022bfdd6a07d5dcc693799322a386b4 -bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 -bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 -bgr555le 378d6ac4223651a1adcbf94a3d0d807b -bgr565be 257cf78afa35dc31e9696f139c916715 -bgr565le 1dfdd03995c287e3c754b164bf26a355 -bgr8 24bd566170343d06fec6fccfff5abc54 -bgra 76a18a5151242fa137133f604cd624d2 -gray db08f7f0751900347e6b8649e4164d21 -gray16be 7becf34ae825a3df3969bf4c6bfeb5e2 -gray16le 10bd87059b5c189f3caef2837f4f2b5c -monob 668ebe8b8103b9046b251b2fa8a1d88f -monow 9251497f3b0634f1165d12d5a289d943 -nv12 e0af357888584d36eec5aa0f673793ef -nv21 9a3297f3b34baa038b1f37cb202b512f -rgb24 b41eba9651e1b5fe386289b506188105 -rgb48be 460b6de89b156290a12d3941db8bd731 -rgb48le cd93cb34d15996987367dabda3a10128 -rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 -rgb555be 912a62c5e53bfcbac2a0340e10973cf2 -rgb555le a937a0fc764fb57dc1b3af87cba0273c -rgb565be 9cadf742e05ddc23a3b5b270f89aad3c -rgb565le d39aa298bb525e9be8860351c6f62dab -rgb8 4a9d8e4f2f154e83a7e1735be6300700 -rgba 93a5b3712e6eb8c5b9a09ffc7b9fbc12 -uyvy422 adcf64516a19fce44df77082bdb16291 -yuv410p 2d9225153c83ee1132397d619d94d1b3 -yuv411p 8b298af3e43348ca1b11eb8a3252ac6c -yuv420p eba2f135a08829387e2f698ff72a2939 -yuv420p10be 7605e266c088d0fcf68c7b27c3ceff5f -yuv420p10le 4228ee628c6deec123a13b9784516cc7 -yuv420p16be 16c009a235cd52b74791a895423152a3 -yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc -yuv420p9be ce880fa07830e5297c22acf6e20555ce -yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a -yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p16be 5499502e1c29534a158a1fe60e889f60 -yuv422p16le e3d61fde6978591596bc36b914386623 -yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf -yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be ea602a24b8e6969679265078bd8607b6 -yuv444p16le 1262a0dc57ee147967fc896d04206313 -yuva420p a29884f3f3dfe1e00b961bc17bef3d47 -yuvj420p 32eec78ba51857b16ce9b813a49b7189 -yuvj422p 0dfa0ed434f73be51428758c69e082cb -yuvj440p 657501a28004e27a592757a7509f5189 -yuvj444p 98d3d054f2ec09a75eeed5d328dc75b7 -yuyv422 f2569f2b5069a0ee0cecae33de0455e3 From dbe5f0172b4f123b15bc8ada82dd17b13c4bbbd7 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 28 Jun 2011 22:23:52 +0200 Subject: [PATCH 124/780] amrnbdec: we dont want dtx samples anymore and give the user a hint towards how to play such files. Signed-off-by: Michael Niedermayer --- libavcodec/amrnbdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index 55dc8b05f5..e0b6332065 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -936,7 +936,8 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, p->cur_frame_mode = unpack_bitstream(p, buf, buf_size); if (p->cur_frame_mode == MODE_DTX) { - av_log_missing_feature(avctx, "dtx mode", 1); + av_log_missing_feature(avctx, "dtx mode", 0); + av_log(avctx, AV_LOG_INFO, "Note: libopencore_amrnb supports dtx\n"); return -1; } From 635930d466dd146686e4b6736aab3cab38527df4 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 28 Jun 2011 23:19:36 +0100 Subject: [PATCH 125/780] PPC: swscale: disable altivec functions for unsupported formats Signed-off-by: Mans Rullgard --- libswscale/ppc/swscale_altivec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 14f35b64cb..396b00ccc6 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -407,7 +407,9 @@ void ff_sws_init_swScale_altivec(SwsContext *c) return; c->hScale = hScale_altivec_real; - if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat)) { + if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && + dstFormat != PIX_FMT_NV12 && dstFormat != PIX_FMT_NV21 && + !c->alpPixBuf) { c->yuv2yuvX = yuv2yuvX_altivec_real; } From b0da4903dd5092f4b646880ae88b639991132a59 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 28 Jun 2011 22:37:42 +0100 Subject: [PATCH 126/780] fate: enable lavfi-pixmt tests on big endian systems Signed-off-by: Mans Rullgard --- configure | 13 ------------- tests/ref/lavfi/{pixfmts_copy_le => pixfmts_copy} | 0 tests/ref/lavfi/{pixfmts_crop_le => pixfmts_crop} | 0 tests/ref/lavfi/{pixfmts_hflip_le => pixfmts_hflip} | 0 tests/ref/lavfi/{pixfmts_null_le => pixfmts_null} | 0 tests/ref/lavfi/{pixfmts_pad_le => pixfmts_pad} | 0 tests/ref/lavfi/{pixfmts_scale_le => pixfmts_scale} | 0 tests/ref/lavfi/{pixfmts_vflip_le => pixfmts_vflip} | 0 8 files changed, 13 deletions(-) rename tests/ref/lavfi/{pixfmts_copy_le => pixfmts_copy} (100%) rename tests/ref/lavfi/{pixfmts_crop_le => pixfmts_crop} (100%) rename tests/ref/lavfi/{pixfmts_hflip_le => pixfmts_hflip} (100%) rename tests/ref/lavfi/{pixfmts_null_le => pixfmts_null} (100%) rename tests/ref/lavfi/{pixfmts_pad_le => pixfmts_pad} (100%) rename tests/ref/lavfi/{pixfmts_scale_le => pixfmts_scale} (100%) rename tests/ref/lavfi/{pixfmts_vflip_le => pixfmts_vflip} (100%) diff --git a/configure b/configure index 0e978ba5ff..f7112ea22c 100755 --- a/configure +++ b/configure @@ -1511,11 +1511,6 @@ test_deps(){ done } -set_ne_test_deps(){ - eval ${1}_be_test_deps="bigendian" - eval ${1}_le_test_deps="!bigendian" -} - test_deps _encoder _decoder \ adpcm_g726=g726 \ adpcm_ima_qt \ @@ -1592,14 +1587,6 @@ test_deps _muxer _demuxer \ ac3_fixed_test_deps="ac3_fixed_encoder ac3_decoder rm_muxer rm_demuxer" mpg_test_deps="mpeg1system_muxer mpegps_demuxer" -set_ne_test_deps pixfmts_copy -set_ne_test_deps pixfmts_crop -set_ne_test_deps pixfmts_hflip -set_ne_test_deps pixfmts_null -set_ne_test_deps pixfmts_pad -set_ne_test_deps pixfmts_scale -set_ne_test_deps pixfmts_vflip - # default parameters logfile="config.log" diff --git a/tests/ref/lavfi/pixfmts_copy_le b/tests/ref/lavfi/pixfmts_copy similarity index 100% rename from tests/ref/lavfi/pixfmts_copy_le rename to tests/ref/lavfi/pixfmts_copy diff --git a/tests/ref/lavfi/pixfmts_crop_le b/tests/ref/lavfi/pixfmts_crop similarity index 100% rename from tests/ref/lavfi/pixfmts_crop_le rename to tests/ref/lavfi/pixfmts_crop diff --git a/tests/ref/lavfi/pixfmts_hflip_le b/tests/ref/lavfi/pixfmts_hflip similarity index 100% rename from tests/ref/lavfi/pixfmts_hflip_le rename to tests/ref/lavfi/pixfmts_hflip diff --git a/tests/ref/lavfi/pixfmts_null_le b/tests/ref/lavfi/pixfmts_null similarity index 100% rename from tests/ref/lavfi/pixfmts_null_le rename to tests/ref/lavfi/pixfmts_null diff --git a/tests/ref/lavfi/pixfmts_pad_le b/tests/ref/lavfi/pixfmts_pad similarity index 100% rename from tests/ref/lavfi/pixfmts_pad_le rename to tests/ref/lavfi/pixfmts_pad diff --git a/tests/ref/lavfi/pixfmts_scale_le b/tests/ref/lavfi/pixfmts_scale similarity index 100% rename from tests/ref/lavfi/pixfmts_scale_le rename to tests/ref/lavfi/pixfmts_scale diff --git a/tests/ref/lavfi/pixfmts_vflip_le b/tests/ref/lavfi/pixfmts_vflip similarity index 100% rename from tests/ref/lavfi/pixfmts_vflip_le rename to tests/ref/lavfi/pixfmts_vflip From 4578435f35888c95b12a53a12cdab612ac3fef04 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 28 Jun 2011 21:32:40 +0200 Subject: [PATCH 127/780] swscale: Add Doxygen for hyscale_fast/hScale. --- libswscale/swscale_internal.h | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index decf101e56..c1eed8ac96 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -386,6 +386,25 @@ typedef struct SwsContext { void (*chrToYV12)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *pal); ///< Unscaled conversion of chroma planes to YV12 for horizontal scaler. + /** + * Scale one horizontal line of input data using a bilinear filter + * to produce one line of output data. Compared to SwsContext->hScale(), + * please take note of the following caveats when using these: + * - Scaling is done using only 7bit instead of 14bit coefficients. + * - You can use no more than 5 input pixels to produce 4 output + * pixels. Therefore, this filter should not be used for downscaling + * by more than ~20% in width (because that equals more than 5/4th + * downscaling and thus more than 5 pixels input per 4 pixels output). + * - In general, bilinear filters create artifacts during downscaling + * (even when <20%), because one output pixel will span more than one + * input pixel, and thus some pixels will need edges of both neighbor + * pixels to interpolate the output pixel. Since you can use at most + * two input pixels per output pixel in bilinear scaling, this is + * impossible and thus downscaling by any size will create artifacts. + * To enable this type of scaling, set SWS_FLAG_FAST_BILINEAR + * in SwsContext->flags. + */ + /** @{ */ void (*hyscale_fast)(struct SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc); @@ -393,7 +412,33 @@ typedef struct SwsContext { int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc); + /** @} */ + /** + * Scale one horizontal line of input data using a filter over the input + * lines, to produce one (differently sized) line of output data. + * + * @param dst pointer to destination buffer for horizontally scaled + * data. If the scaling depth (SwsContext->scalingBpp) is + * 8, data will be 15bpp in 16bits (int16_t) width. If + * scaling depth is 16, data will be 19bpp in 32bpp + * (int32_t) width. + * @param dstW width of destination image + * @param src pointer to source data to be scaled. If scaling depth + * is 8, this is 8bpp in 8bpp (uint8_t) width. If scaling + * depth is 16, this is 16bpp in 16bpp (uint16_t) depth. + * @param filter filter coefficients to be used per output pixel for + * scaling. This contains 14bpp filtering coefficients. + * Guaranteed to contain dstW * filterSize entries. + * @param filterPos position of the first input pixel to be used for + * each output pixel during scaling. Guaranteed to + * contain dstW entries. + * @param filterSize the number of input coefficients to be used (and + * thus the number of input pixels to be used) for + * creating a single output pixel. Is aligned to 4 + * (and input coefficients thus padded with zeroes) + * to simplify creating SIMD code. + */ void (*hScale)(int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize); From 9e17d051ac9b113b70980373b8489ca469505f3f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 29 Jun 2011 05:56:46 +0200 Subject: [PATCH 128/780] swscale: Fix yuv422p10 Signed-off-by: Michael Niedermayer --- libswscale/utils.c | 6 ++++-- tests/ref/lavfi/pixdesc | 1 + tests/ref/lavfi/pixfmts_copy | 1 + tests/ref/lavfi/pixfmts_null | 1 + tests/ref/lavfi/pixfmts_scale | 1 + tests/ref/lavfi/pixfmts_vflip | 1 + 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 0679b020ea..bff9f4d3c6 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -119,6 +119,7 @@ const char *swscale_license(void) || (x)==PIX_FMT_YUV420P16LE \ || (x)==PIX_FMT_YUV422P16LE \ || (x)==PIX_FMT_YUV444P16LE \ + || (x)==PIX_FMT_YUV422P10LE \ || (x)==PIX_FMT_YUV420P9BE \ || (x)==PIX_FMT_YUV444P9BE \ || (x)==PIX_FMT_YUV420P10BE \ @@ -127,7 +128,7 @@ const char *swscale_license(void) || (x)==PIX_FMT_YUV420P16BE \ || (x)==PIX_FMT_YUV422P16BE \ || (x)==PIX_FMT_YUV444P16BE \ - || (x)==PIX_FMT_YUV422P10 \ + || (x)==PIX_FMT_YUV422P10BE \ ) int sws_isSupportedInput(enum PixelFormat pix_fmt) @@ -176,12 +177,13 @@ int sws_isSupportedInput(enum PixelFormat pix_fmt) || (x)==PIX_FMT_GRAY8 \ || (x)==PIX_FMT_YUV410P \ || (x)==PIX_FMT_YUV440P \ - || (x)==PIX_FMT_YUV422P10 \ + || (x)==PIX_FMT_YUV422P10LE \ || (x)==PIX_FMT_YUV420P9LE \ || (x)==PIX_FMT_YUV420P10LE \ || (x)==PIX_FMT_YUV420P16LE \ || (x)==PIX_FMT_YUV422P16LE \ || (x)==PIX_FMT_YUV444P16LE \ + || (x)==PIX_FMT_YUV422P10BE \ || (x)==PIX_FMT_YUV420P9BE \ || (x)==PIX_FMT_YUV420P10BE \ || (x)==PIX_FMT_YUV420P16BE \ diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc index 81a75062da..3efc45bf4b 100644 --- a/tests/ref/lavfi/pixdesc +++ b/tests/ref/lavfi/pixdesc @@ -38,6 +38,7 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a +yuv422p10be bdc13b630fd668b34c6fe1aae28dfc71 yuv422p10le d0607c260a45c973e6639f4e449730ad yuv422p16be 5499502e1c29534a158a1fe60e889f60 yuv422p16le e3d61fde6978591596bc36b914386623 diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index 81a75062da..3efc45bf4b 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -38,6 +38,7 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a +yuv422p10be bdc13b630fd668b34c6fe1aae28dfc71 yuv422p10le d0607c260a45c973e6639f4e449730ad yuv422p16be 5499502e1c29534a158a1fe60e889f60 yuv422p16le e3d61fde6978591596bc36b914386623 diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index 81a75062da..3efc45bf4b 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -38,6 +38,7 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a +yuv422p10be bdc13b630fd668b34c6fe1aae28dfc71 yuv422p10le d0607c260a45c973e6639f4e449730ad yuv422p16be 5499502e1c29534a158a1fe60e889f60 yuv422p16le e3d61fde6978591596bc36b914386623 diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index 206ade8b42..b3351c8631 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -38,6 +38,7 @@ yuv420p16le 165f9aaf5332e5d088f44534d8ed2bc9 yuv420p9be bb87fddca65d1742412c8d2b1caf96c6 yuv420p9le 828eec50014a41258a5423c1fe56ac97 yuv422p 918e37701ee7377d16a8a6c119c56a40 +yuv422p10be cea7ca6b0e66d6f29539885896c88603 yuv422p10le a10c4a5837547716f13cd61918b145f9 yuv422p16be 961860aa4f229e09f1249910c687081c yuv422p16le 7695ee42c0581279bbe68de81deb7aee diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index 10161ac718..16471417ab 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -38,6 +38,7 @@ yuv420p16le 0f609e588e5a258644ef85170d70e030 yuv420p9be be40ec975fb2873891643cbbbddbc3b0 yuv420p9le 7e606310d3f5ff12badf911e8f333471 yuv422p d7f5cb44d9b0210d66d6a8762640ab34 +yuv422p10be 588fe319b96513c32e21d3e32b45447f yuv422p10le 11b57f2bd9661024153f3973b9090cdb yuv422p16be 9bd8f8c961822b586fa4cf992be54acc yuv422p16le 9c4a1239605c7952b736ac3130163f14 From da55ee6ccc05efdd9006bb8c31db9012a3326857 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Tue, 28 Jun 2011 18:22:23 -0700 Subject: [PATCH 129/780] Add new yuv444 pixfmts to avcodec_align_dimensions2 Fixes draw_edges crashes with high-bit-depth 4:4:4 decoding. --- libavcodec/utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 4e15f6fb42..44a6f8c232 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -141,6 +141,10 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l case PIX_FMT_YUV420P10BE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV422P10BE: + case PIX_FMT_YUV444P9LE: + case PIX_FMT_YUV444P9BE: + case PIX_FMT_YUV444P10LE: + case PIX_FMT_YUV444P10BE: w_align= 16; //FIXME check for non mpeg style codecs and use less alignment h_align= 16; if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP || s->codec_id == CODEC_ID_H264) From 4d08dfefa9911055fc89e94936bdbed7a6c4da36 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 29 Jun 2011 10:07:39 +0200 Subject: [PATCH 130/780] Remove gcc 2.95.3 remnants. --- doc/developer.texi | 2 +- libavcodec/h264_cabac.c | 2 +- libavcodec/x86/h264_i386.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index 69c2951620..c1ca096ddf 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -54,7 +54,7 @@ These features are supported by all compilers we care about, so we will not accept patches to remove their use unless they absolutely do not impair clarity and performance. -All code must compile with GCC 2.95 and GCC 3.3. Currently, FFmpeg also +All code must compile with GCC 3.3. Currently, FFmpeg also compiles with several other compilers, such as the Compaq ccc compiler or Sun Studio 9, and we would like to keep it that way unless it would be exceedingly involved. To ensure compatibility, please do not use any diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index a373edbb4e..3975a61699 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1647,7 +1647,7 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT index[coeff_count++] = last;\ } const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD]; -#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) && HAVE_TEN_OPERANDS +#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, last_coeff_ctx_base-significant_coeff_ctx_base, sig_off); } else { diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index 982e8aa4fb..c2477ac96b 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -36,7 +36,7 @@ //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet //as that would make optimization work hard) -#if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) && HAVE_TEN_OPERANDS +#if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) static int decode_significance_x86(CABACContext *c, int max_coeff, uint8_t *significant_coeff_ctx_base, int *index, x86_reg last_off){ From 5e27ec28f0aa263fc6af60ea88677e2c40631920 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 28 Jun 2011 18:45:13 +0100 Subject: [PATCH 131/780] build: create output directories as needed Signed-off-by: Mans Rullgard --- Makefile | 7 ++++++- common.mak | 6 ++++++ configure | 31 +++++-------------------------- doc/Makefile | 3 +++ 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 24a5951ec1..3510a1ed59 100644 --- a/Makefile +++ b/Makefile @@ -122,9 +122,11 @@ alltools: $(TOOLS) tools/%$(EXESUF): tools/%.o $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) -tools/%.o: tools/%.c +tools/%.o: tools/%.c | tools $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $< +OBJDIRS += tools + -include $(wildcard tools/*.d) VERSION_SH = $(SRC_PATH)/version.sh @@ -185,6 +187,9 @@ check: test checkheaders include $(SRC_PATH)/doc/Makefile include $(SRC_PATH)/tests/Makefile +$(sort $(OBJDIRS)): + $(Q)mkdir -p $@ + # Dummy rule to stop make trying to rebuild removed or renamed headers %.h: @: diff --git a/common.mak b/common.mak index 19be4a6949..bd210462b9 100644 --- a/common.mak +++ b/common.mak @@ -34,6 +34,12 @@ $(HOSTOBJS): %.o: %.c $(HOSTPROGS): %$(HOSTEXESUF): %.o $(HOSTCC) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS) +$(OBJS): | $(dir $(OBJS)) +$(HOSTOBJS): | $(dir $(HOSTOBJS)) +$(TESTOBJS): | $(dir $(TESTOBJS)) + +OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS)) + CLEANSUFFIXES = *.d *.o *~ *.ho *.map *.ver DISTCLEANSUFFIXES = *.pc LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp diff --git a/configure b/configure index f7112ea22c..a1cc59ae5b 100755 --- a/configure +++ b/configure @@ -875,9 +875,9 @@ apply(){ } cp_if_changed(){ - cmp -s "$1" "$2" && - echo "$2 is unchanged" || - cp -f "$1" "$2" + cmp -s "$1" "$2" && echo "$2 is unchanged" && return + mkdir -p "$(dirname $2)" + cp -f "$1" "$2" } # CONFIG_LIST contains configurable options, while HAVE_LIST is for @@ -1675,10 +1675,8 @@ DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM' # find source path if test -f configure; then source_path=. - disable source_path_used else source_path=$(cd $(dirname "$0"); pwd) - enable source_path_used echo "$source_path" | grep -q '[[:blank:]]' && die "Out of tree builds are impossible with whitespace in source path." test -e "$source_path/config.h" && @@ -3180,27 +3178,7 @@ echo "License: $license" echo "Creating config.mak and config.h..." -# build tree in object directory if source path is different from current one -if enabled source_path_used; then - DIRS=" - doc - libavcodec - libavcodec/$arch - libavdevice - libavfilter - libavfilter/$arch - libavformat - libavutil - libavutil/$arch - libpostproc - libswscale - libswscale/$arch - tests - tools - " - map 'mkdir -p $v' $DIRS; - $ln_s "$source_path/Makefile" . -fi +test -e Makefile || $ln_s "$source_path/Makefile" . config_files="$TMPH config.mak" @@ -3379,6 +3357,7 @@ version=$3 libs=$4 requires=$5 enabled ${name#lib} || return 0 +mkdir -p $name cat < $name/$name.pc prefix=$prefix exec_prefix=\${prefix} diff --git a/doc/Makefile b/doc/Makefile index da46cce647..01960b74b0 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -24,6 +24,9 @@ doc/%.1: TAG = MAN doc/%.1: doc/%.pod $(M)pod2man --section=1 --center=" " --release=" " $< > $@ +$(DOCS): | doc +OBJDIRS += doc + install-progs-$(CONFIG_DOC): install-man install-man: $(MANPAGES) From 86c3c1abf0126e8aad58aaf9d2bfa124d112a372 Mon Sep 17 00:00:00 2001 From: Can Wu Date: Wed, 29 Jun 2011 09:37:57 +0800 Subject: [PATCH 132/780] pixfmt: fix YUV422/444 wrong endian comment Signed-off-by: Diego Biurrun --- libavutil/pixfmt.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index e852d85519..9bf793866a 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -139,12 +139,12 @@ enum PixelFormat { PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian - PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian - PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian - PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian - PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian - PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian - PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; From e2542dcc6e94d86b8b844f6ab0ce32ed329d39ee Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 7 Jun 2011 13:16:48 +0200 Subject: [PATCH 133/780] build: Mark all-yes Makefile target as phony. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3510a1ed59..59a1692018 100644 --- a/Makefile +++ b/Makefile @@ -198,5 +198,5 @@ $(sort $(OBJDIRS)): # so this saves some time on slow systems. .SUFFIXES: -.PHONY: all alltools *clean check config examples install* +.PHONY: all all-yes alltools *clean check config examples install* .PHONY: testprogs uninstall* From f68069868bd17a46f2dd80f87b712845f2fcfa56 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 29 Jun 2011 11:46:08 +0100 Subject: [PATCH 134/780] build: fix creation of tools dir with make 3.81 GNU make 3.81 apparently does not support order-only prerequisites with pattern rules, and thus fails to create the tools directory if it is missing. Naming the objects explicitly in the rule makes it work properly. Signed-off-by: Mans Rullgard --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 59a1692018..da12fba8a4 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,6 @@ PROGS-$(CONFIG_FFSERVER) += ffserver PROGS := $(PROGS-yes:%=%$(EXESUF)) OBJS = $(PROGS-yes:%=%.o) cmdutils.o -TOOLS = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher)) TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64 HOSTPROGS := $(TESTTOOLS:%=tests/%) @@ -117,12 +116,16 @@ ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS) $(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS) $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS) +TOOLS = cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher +TOOLOBJS := $(TOOLS:%=tools/%.o) +TOOLS := $(TOOLS:%=tools/%$(EXESUF)) + alltools: $(TOOLS) tools/%$(EXESUF): tools/%.o $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) -tools/%.o: tools/%.c | tools +$(TOOLOBJS): %.o: %.c | tools $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $< OBJDIRS += tools From ef1ee362b36893cd1cc1e9c7de378e9cb239b0e8 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 29 Jun 2011 09:39:43 -0700 Subject: [PATCH 135/780] swscale: implement >8bit scaling support. This means that precision is retained when scaling between sample formats with >8 bits per component (48bit RGB, 16bit grayscale, 9/10/16bit YUV). --- libswscale/ppc/swscale_altivec.c | 4 +- libswscale/swscale.c | 690 ++++++++++++++++++++---------- libswscale/swscale_internal.h | 10 + libswscale/utils.c | 9 +- libswscale/x86/swscale_template.c | 73 +--- tests/ref/lavfi/pixdesc | 16 +- tests/ref/lavfi/pixfmts_copy | 16 +- tests/ref/lavfi/pixfmts_crop | 16 +- tests/ref/lavfi/pixfmts_hflip | 16 +- tests/ref/lavfi/pixfmts_null | 16 +- tests/ref/lavfi/pixfmts_scale | 32 +- tests/ref/lavfi/pixfmts_vflip | 16 +- 12 files changed, 543 insertions(+), 371 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 396b00ccc6..6fb3de0ee7 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -406,7 +406,9 @@ void ff_sws_init_swScale_altivec(SwsContext *c) if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; - c->hScale = hScale_altivec_real; + if (c->scalingBpp == 8) { + c->hScale = hScale_altivec_real; + } if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && dstFormat != PIX_FMT_NV12 && dstFormat != PIX_FMT_NV21 && !c->alpPixBuf) { diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 64ba97e7d4..987afff2d2 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -195,18 +195,18 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={ #endif static av_always_inline void -yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, +yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, - const int16_t **chrUSrc, const int16_t **chrVSrc, - int chrFilterSize, const int16_t **alpSrc, + const int32_t **chrUSrc, const int32_t **chrVSrc, + int chrFilterSize, const int32_t **alpSrc, uint16_t *dest[4], int dstW, int chrDstW, int big_endian, int output_bits) { //FIXME Optimize (just quickly written not optimized..) int i; - int shift = 11 + 16 - output_bits; uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; + int shift = 15 + 16 - output_bits; #define output_pixel(pos, val) \ if (big_endian) { \ @@ -223,7 +223,7 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, } \ } for (i = 0; i < dstW; i++) { - int val = 1 << (26-output_bits); + int val = 1 << (30-output_bits); int j; for (j = 0; j < lumFilterSize; j++) @@ -234,8 +234,8 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, if (uDest) { for (i = 0; i < chrDstW; i++) { - int u = 1 << (26-output_bits); - int v = 1 << (26-output_bits); + int u = 1 << (30-output_bits); + int v = 1 << (30-output_bits); int j; for (j = 0; j < chrFilterSize; j++) { @@ -250,7 +250,7 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, if (CONFIG_SWSCALE_ALPHA && aDest) { for (i = 0; i < dstW; i++) { - int val = 1 << (26-output_bits); + int val = 1 << (30-output_bits); int j; for (j = 0; j < lumFilterSize; j++) @@ -264,12 +264,16 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, #define yuv2NBPS(bits, BE_LE, is_be) \ static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFilter, \ - const int16_t **lumSrc, int lumFilterSize, \ - const int16_t *chrFilter, const int16_t **chrUSrc, \ - const int16_t **chrVSrc, \ - int chrFilterSize, const int16_t **alpSrc, \ + const int16_t **_lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, const int16_t **_chrUSrc, \ + const int16_t **_chrVSrc, \ + int chrFilterSize, const int16_t **_alpSrc, \ uint8_t *_dest[4], int dstW, int chrDstW) \ { \ + const int32_t **lumSrc = (const int32_t **) _lumSrc, \ + **chrUSrc = (const int32_t **) _chrUSrc, \ + **chrVSrc = (const int32_t **) _chrVSrc, \ + **alpSrc = (const int32_t **) _alpSrc; \ yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \ chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ alpSrc, (uint16_t **) _dest, \ @@ -418,109 +422,121 @@ static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, static av_always_inline void yuv2gray16_X_c_template(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, int dstW, + const int32_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int32_t **chrUSrc, + const int32_t **chrVSrc, int chrFilterSize, + const int32_t **alpSrc, uint16_t *dest, int dstW, int y, enum PixelFormat target) { int i; for (i = 0; i < (dstW >> 1); i++) { int j; - int Y1 = 1 << 18; - int Y2 = 1 << 18; - const int i2 = 2 * i; + int Y1 = 1 << 14; + int Y2 = 1 << 14; for (j = 0; j < lumFilterSize; j++) { - Y1 += lumSrc[j][i2] * lumFilter[j]; - Y2 += lumSrc[j][i2+1] * lumFilter[j]; + Y1 += lumSrc[j][i * 2] * lumFilter[j]; + Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j]; } - Y1 >>= 11; - Y2 >>= 11; + Y1 >>= 15; + Y2 >>= 15; if ((Y1 | Y2) & 0x10000) { Y1 = av_clip_uint16(Y1); Y2 = av_clip_uint16(Y2); } - output_pixel(&dest[2 * i2 + 0], Y1); - output_pixel(&dest[2 * i2 + 2], Y2); + output_pixel(&dest[i * 2 + 0], Y1); + output_pixel(&dest[i * 2 + 1], Y2); } } static av_always_inline void -yuv2gray16_2_c_template(SwsContext *c, const int16_t *buf[2], - const int16_t *ubuf[2], const int16_t *vbuf[2], - const int16_t *abuf[2], uint8_t *dest, int dstW, +yuv2gray16_2_c_template(SwsContext *c, const int32_t *buf[2], + const int32_t *ubuf[2], const int32_t *vbuf[2], + const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { int yalpha1 = 4095 - yalpha; int i; - const int16_t *buf0 = buf[0], *buf1 = buf[1]; + const int32_t *buf0 = buf[0], *buf1 = buf[1]; for (i = 0; i < (dstW >> 1); i++) { - const int i2 = 2 * i; - int Y1 = (buf0[i2 ] * yalpha1 + buf1[i2 ] * yalpha) >> 11; - int Y2 = (buf0[i2+1] * yalpha1 + buf1[i2+1] * yalpha) >> 11; + int Y1 = (buf0[i * 2 ] * yalpha1 + buf1[i * 2 ] * yalpha) >> 15; + int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 15; - output_pixel(&dest[2 * i2 + 0], Y1); - output_pixel(&dest[2 * i2 + 2], Y2); + output_pixel(&dest[i * 2 + 0], Y1); + output_pixel(&dest[i * 2 + 1], Y2); } } static av_always_inline void -yuv2gray16_1_c_template(SwsContext *c, const int16_t *buf0, - const int16_t *ubuf[2], const int16_t *vbuf[2], - const int16_t *abuf0, uint8_t *dest, int dstW, +yuv2gray16_1_c_template(SwsContext *c, const int32_t *buf0, + const int32_t *ubuf[2], const int32_t *vbuf[2], + const int32_t *abuf0, uint16_t *dest, int dstW, int uvalpha, int y, enum PixelFormat target) { int i; for (i = 0; i < (dstW >> 1); i++) { - const int i2 = 2 * i; - int Y1 = buf0[i2 ] << 1; - int Y2 = buf0[i2+1] << 1; + int Y1 = buf0[i * 2 ] << 1; + int Y2 = buf0[i * 2 + 1] << 1; - output_pixel(&dest[2 * i2 + 0], Y1); - output_pixel(&dest[2 * i2 + 2], Y2); + output_pixel(&dest[i * 2 + 0], Y1); + output_pixel(&dest[i * 2 + 1], Y2); } } #undef output_pixel -#define YUV2PACKEDWRAPPER(name, base, ext, fmt) \ +#define YUV2PACKED16WRAPPER(name, base, ext, fmt) \ static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ - const int16_t **lumSrc, int lumFilterSize, \ - const int16_t *chrFilter, const int16_t **chrUSrc, \ - const int16_t **chrVSrc, int chrFilterSize, \ - const int16_t **alpSrc, uint8_t *dest, int dstW, \ + const int16_t **_lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, const int16_t **_chrUSrc, \ + const int16_t **_chrVSrc, int chrFilterSize, \ + const int16_t **_alpSrc, uint8_t *_dest, int dstW, \ int y) \ { \ + const int32_t **lumSrc = (const int32_t **) _lumSrc, \ + **chrUSrc = (const int32_t **) _chrUSrc, \ + **chrVSrc = (const int32_t **) _chrVSrc, \ + **alpSrc = (const int32_t **) _alpSrc; \ + uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \ chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ alpSrc, dest, dstW, y, fmt); \ } \ \ -static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \ - const int16_t *ubuf[2], const int16_t *vbuf[2], \ - const int16_t *abuf[2], uint8_t *dest, int dstW, \ +static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \ + const int16_t *_ubuf[2], const int16_t *_vbuf[2], \ + const int16_t *_abuf[2], uint8_t *_dest, int dstW, \ int yalpha, int uvalpha, int y) \ { \ + const int32_t **buf = (const int32_t **) _buf, \ + **ubuf = (const int32_t **) _ubuf, \ + **vbuf = (const int32_t **) _vbuf, \ + **abuf = (const int32_t **) _abuf; \ + uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \ dest, dstW, yalpha, uvalpha, y, fmt); \ } \ \ -static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ - const int16_t *ubuf[2], const int16_t *vbuf[2], \ - const int16_t *abuf0, uint8_t *dest, int dstW, \ +static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \ + const int16_t *_ubuf[2], const int16_t *_vbuf[2], \ + const int16_t *_abuf0, uint8_t *_dest, int dstW, \ int uvalpha, int y) \ { \ + const int32_t *buf0 = (const int32_t *) _buf0, \ + **ubuf = (const int32_t **) _ubuf, \ + **vbuf = (const int32_t **) _vbuf, \ + *abuf0 = (const int32_t *) _abuf0; \ + uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \ dstW, uvalpha, y, fmt); \ } -YUV2PACKEDWRAPPER(yuv2gray16,, LE, PIX_FMT_GRAY16LE); -YUV2PACKEDWRAPPER(yuv2gray16,, BE, PIX_FMT_GRAY16BE); +YUV2PACKED16WRAPPER(yuv2gray16,, LE, PIX_FMT_GRAY16LE); +YUV2PACKED16WRAPPER(yuv2gray16,, BE, PIX_FMT_GRAY16BE); #define output_pixel(pos, acc) \ if (target == PIX_FMT_MONOBLACK) { \ @@ -616,6 +632,38 @@ yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0, #undef output_pixel +#define YUV2PACKEDWRAPPER(name, base, ext, fmt) \ +static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ + const int16_t **lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, const int16_t **chrUSrc, \ + const int16_t **chrVSrc, int chrFilterSize, \ + const int16_t **alpSrc, uint8_t *dest, int dstW, \ + int y) \ +{ \ + name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ + alpSrc, dest, dstW, y, fmt); \ +} \ + \ +static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \ + const int16_t *ubuf[2], const int16_t *vbuf[2], \ + const int16_t *abuf[2], uint8_t *dest, int dstW, \ + int yalpha, int uvalpha, int y) \ +{ \ + name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \ + dest, dstW, yalpha, uvalpha, y, fmt); \ +} \ + \ +static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ + const int16_t *ubuf[2], const int16_t *vbuf[2], \ + const int16_t *abuf0, uint8_t *dest, int dstW, \ + int uvalpha, int y) \ +{ \ + name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \ + abuf0, dest, dstW, uvalpha, \ + y, fmt); \ +} + YUV2PACKEDWRAPPER(yuv2mono,, white, PIX_FMT_MONOWHITE); YUV2PACKEDWRAPPER(yuv2mono,, black, PIX_FMT_MONOBLACK); @@ -731,26 +779,32 @@ yuv2422_1_c_template(SwsContext *c, const int16_t *buf0, YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, PIX_FMT_YUYV422); YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, PIX_FMT_UYVY422); -#define r_b ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? r : b) -#define b_r ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? b : r) +#define R_B ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? R : B) +#define B_R ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? B : R) +#define output_pixel(pos, val) \ + if (isBE(target)) { \ + AV_WB16(pos, val); \ + } else { \ + AV_WL16(pos, val); \ + } static av_always_inline void yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, int dstW, + const int32_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int32_t **chrUSrc, + const int32_t **chrVSrc, int chrFilterSize, + const int32_t **alpSrc, uint16_t *dest, int dstW, int y, enum PixelFormat target) { int i; for (i = 0; i < (dstW >> 1); i++) { int j; - int Y1 = 1 << 18; - int Y2 = 1 << 18; - int U = 1 << 18; - int V = 1 << 18; - const uint8_t *r, *g, *b; + int Y1 = 0; + int Y2 = 0; + int U = -128 << 23; // 19 + int V = -128 << 23; + int R, G, B; for (j = 0; j < lumFilterSize; j++) { Y1 += lumSrc[j][i * 2] * lumFilter[j]; @@ -760,40 +814,45 @@ yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter, U += chrUSrc[j][i] * chrFilter[j]; V += chrVSrc[j][i] * chrFilter[j]; } - Y1 >>= 19; - Y2 >>= 19; - U >>= 19; - V >>= 19; - if ((Y1 | Y2 | U | V) & 0x100) { - Y1 = av_clip_uint8(Y1); - Y2 = av_clip_uint8(Y2); - U = av_clip_uint8(U); - V = av_clip_uint8(V); - } - /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/ - r = (const uint8_t *) c->table_rV[V]; - g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]); - b = (const uint8_t *) c->table_bU[U]; + // 8bit: 12+15=27; 16-bit: 12+19=31 + Y1 >>= 14; // 10 + Y2 >>= 14; + U >>= 14; + V >>= 14; - dest[ 0] = dest[ 1] = r_b[Y1]; - dest[ 2] = dest[ 3] = g[Y1]; - dest[ 4] = dest[ 5] = b_r[Y1]; - dest[ 6] = dest[ 7] = r_b[Y2]; - dest[ 8] = dest[ 9] = g[Y2]; - dest[10] = dest[11] = b_r[Y2]; - dest += 12; + // 8bit: 27 -> 17bit, 16bit: 31 - 14 = 17bit + Y1 -= c->yuv2rgb_y_offset; + Y2 -= c->yuv2rgb_y_offset; + Y1 *= c->yuv2rgb_y_coeff; + Y2 *= c->yuv2rgb_y_coeff; + Y1 += 1 << 13; // 21 + Y2 += 1 << 13; + // 8bit: 17 + 13bit = 30bit, 16bit: 17 + 13bit = 30bit + + R = V * c->yuv2rgb_v2r_coeff; + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; + B = U * c->yuv2rgb_u2b_coeff; + + // 8bit: 30 - 22 = 8bit, 16bit: 30bit - 14 = 16bit + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; } } static av_always_inline void -yuv2rgb48_2_c_template(SwsContext *c, const int16_t *buf[2], - const int16_t *ubuf[2], const int16_t *vbuf[2], - const int16_t *abuf[2], uint8_t *dest, int dstW, +yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2], + const int32_t *ubuf[2], const int32_t *vbuf[2], + const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { - const int16_t *buf0 = buf[0], *buf1 = buf[1], + const int32_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; int yalpha1 = 4095 - yalpha; @@ -801,80 +860,108 @@ yuv2rgb48_2_c_template(SwsContext *c, const int16_t *buf[2], int i; for (i = 0; i < (dstW >> 1); i++) { - int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19; - int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19; - int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19; - int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19; - const uint8_t *r = (const uint8_t *) c->table_rV[V], - *g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]), - *b = (const uint8_t *) c->table_bU[U]; + int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14; + int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14; + int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14; + int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14; + int R, G, B; - dest[ 0] = dest[ 1] = r_b[Y1]; - dest[ 2] = dest[ 3] = g[Y1]; - dest[ 4] = dest[ 5] = b_r[Y1]; - dest[ 6] = dest[ 7] = r_b[Y2]; - dest[ 8] = dest[ 9] = g[Y2]; - dest[10] = dest[11] = b_r[Y2]; - dest += 12; + Y1 -= c->yuv2rgb_y_offset; + Y2 -= c->yuv2rgb_y_offset; + Y1 *= c->yuv2rgb_y_coeff; + Y2 *= c->yuv2rgb_y_coeff; + Y1 += 1 << 13; + Y2 += 1 << 13; + + R = V * c->yuv2rgb_v2r_coeff; + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; + B = U * c->yuv2rgb_u2b_coeff; + + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; } } static av_always_inline void -yuv2rgb48_1_c_template(SwsContext *c, const int16_t *buf0, - const int16_t *ubuf[2], const int16_t *vbuf[2], - const int16_t *abuf0, uint8_t *dest, int dstW, +yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0, + const int32_t *ubuf[2], const int32_t *vbuf[2], + const int32_t *abuf0, uint16_t *dest, int dstW, int uvalpha, int y, enum PixelFormat target) { - const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + const int32_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; int i; if (uvalpha < 2048) { for (i = 0; i < (dstW >> 1); i++) { - int Y1 = buf0[i * 2] >> 7; - int Y2 = buf0[i * 2 + 1] >> 7; - int U = ubuf1[i] >> 7; - int V = vbuf1[i] >> 7; - const uint8_t *r = (const uint8_t *) c->table_rV[V], - *g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]), - *b = (const uint8_t *) c->table_bU[U]; + int Y1 = (buf0[i * 2] ) >> 2; + int Y2 = (buf0[i * 2 + 1]) >> 2; + int U = (ubuf0[i] + (-128 << 11)) >> 2; + int V = (vbuf0[i] + (-128 << 11)) >> 2; + int R, G, B; - dest[ 0] = dest[ 1] = r_b[Y1]; - dest[ 2] = dest[ 3] = g[Y1]; - dest[ 4] = dest[ 5] = b_r[Y1]; - dest[ 6] = dest[ 7] = r_b[Y2]; - dest[ 8] = dest[ 9] = g[Y2]; - dest[10] = dest[11] = b_r[Y2]; - dest += 12; + Y1 -= c->yuv2rgb_y_offset; + Y2 -= c->yuv2rgb_y_offset; + Y1 *= c->yuv2rgb_y_coeff; + Y2 *= c->yuv2rgb_y_coeff; + Y1 += 1 << 13; + Y2 += 1 << 13; + + R = V * c->yuv2rgb_v2r_coeff; + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; + B = U * c->yuv2rgb_u2b_coeff; + + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; } } else { for (i = 0; i < (dstW >> 1); i++) { - int Y1 = buf0[i * 2] >> 7; - int Y2 = buf0[i * 2 + 1] >> 7; - int U = (ubuf0[i] + ubuf1[i]) >> 8; - int V = (vbuf0[i] + vbuf1[i]) >> 8; - const uint8_t *r = (const uint8_t *) c->table_rV[V], - *g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]), - *b = (const uint8_t *) c->table_bU[U]; + int Y1 = (buf0[i * 2] ) >> 2; + int Y2 = (buf0[i * 2 + 1]) >> 2; + int U = (ubuf0[i] + ubuf1[i] + (-128 << 11)) >> 3; + int V = (vbuf0[i] + vbuf1[i] + (-128 << 11)) >> 3; + int R, G, B; - dest[ 0] = dest[ 1] = r_b[Y1]; - dest[ 2] = dest[ 3] = g[Y1]; - dest[ 4] = dest[ 5] = b_r[Y1]; - dest[ 6] = dest[ 7] = r_b[Y2]; - dest[ 8] = dest[ 9] = g[Y2]; - dest[10] = dest[11] = b_r[Y2]; - dest += 12; + Y1 -= c->yuv2rgb_y_offset; + Y2 -= c->yuv2rgb_y_offset; + Y1 *= c->yuv2rgb_y_coeff; + Y2 *= c->yuv2rgb_y_coeff; + Y1 += 1 << 13; + Y2 += 1 << 13; + + R = V * c->yuv2rgb_v2r_coeff; + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; + B = U * c->yuv2rgb_u2b_coeff; + + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; } } } +#undef output_pixel #undef r_b #undef b_r -YUV2PACKEDWRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE); -//YUV2PACKEDWRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE); -YUV2PACKEDWRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE); -//YUV2PACKEDWRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE); +YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE); +YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE); +YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE); +YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE); static av_always_inline void yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2, @@ -1025,7 +1112,7 @@ yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter, U = av_clip_uint8(U); V = av_clip_uint8(V); } - if (hasAlpha) {\ + if (hasAlpha) { A1 = 1 << 18; A2 = 1 << 18; for (j = 0; j < lumFilterSize; j++) { @@ -1318,50 +1405,50 @@ static av_always_inline void fillPlane(uint8_t* plane, int stride, #define b ((origin == PIX_FMT_BGR48BE || origin == PIX_FMT_BGR48LE) ? r_b : b_r) static av_always_inline void -rgb48ToY_c_template(uint8_t *dst, const uint8_t *src, int width, +rgb48ToY_c_template(uint16_t *dst, const uint16_t *src, int width, enum PixelFormat origin) { int i; for (i = 0; i < width; i++) { - int r_b = input_pixel(&src[i*6+0]) >> 8; - int g = input_pixel(&src[i*6+2]) >> 8; - int b_r = input_pixel(&src[i*6+4]) >> 8; + unsigned int r_b = input_pixel(&src[i*3+0]); + unsigned int g = input_pixel(&src[i*3+1]); + unsigned int b_r = input_pixel(&src[i*3+2]); - dst[i] = (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + dst[i] = (RY*r + GY*g + BY*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; } } static av_always_inline void -rgb48ToUV_c_template(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, +rgb48ToUV_c_template(uint16_t *dstU, uint16_t *dstV, + const uint16_t *src1, const uint16_t *src2, int width, enum PixelFormat origin) { int i; assert(src1==src2); for (i = 0; i < width; i++) { - int r_b = input_pixel(&src1[i*6+0]) >> 8; - int g = input_pixel(&src1[i*6+2]) >> 8; - int b_r = input_pixel(&src1[i*6+4]) >> 8; + int r_b = input_pixel(&src1[i*3+0]); + int g = input_pixel(&src1[i*3+1]); + int b_r = input_pixel(&src1[i*3+2]); - dstU[i] = (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; - dstV[i] = (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + dstU[i] = (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + dstV[i] = (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; } } static av_always_inline void -rgb48ToUV_half_c_template(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, +rgb48ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV, + const uint16_t *src1, const uint16_t *src2, int width, enum PixelFormat origin) { int i; assert(src1==src2); for (i = 0; i < width; i++) { - int r_b = (input_pixel(&src1[12*i + 0]) >> 8) + (input_pixel(&src1[12*i + 6]) >> 8); - int g = (input_pixel(&src1[12*i + 2]) >> 8) + (input_pixel(&src1[12*i + 8]) >> 8); - int b_r = (input_pixel(&src1[12*i + 4]) >> 8) + (input_pixel(&src1[12*i + 10]) >> 8); + int r_b = (input_pixel(&src1[6 * i + 0]) + input_pixel(&src1[6 * i + 3]) + 1) >> 1; + int g = (input_pixel(&src1[6 * i + 1]) + input_pixel(&src1[6 * i + 4]) + 1) >> 1; + int b_r = (input_pixel(&src1[6 * i + 2]) + input_pixel(&src1[6 * i + 5]) + 1) >> 1; - dstU[i]= (RU*r + GU*g + BU*b + (257<> (RGB2YUV_SHIFT+1); - dstV[i]= (RV*r + GV*g + BV*b + (257<> (RGB2YUV_SHIFT+1); + dstU[i]= (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + dstV[i]= (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; } } @@ -1370,23 +1457,31 @@ rgb48ToUV_half_c_template(uint8_t *dstU, uint8_t *dstV, #undef input_pixel #define rgb48funcs(pattern, BE_LE, origin) \ -static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *dst, const uint8_t *src, \ +static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, \ int width, uint32_t *unused) \ { \ + const uint16_t *src = (const uint16_t *) _src; \ + uint16_t *dst = (uint16_t *) _dst; \ rgb48ToY_c_template(dst, src, width, origin); \ } \ \ -static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \ - const uint8_t *src1, const uint8_t *src2, \ +static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ + const uint8_t *_src1, const uint8_t *_src2, \ int width, uint32_t *unused) \ { \ + const uint16_t *src1 = (const uint16_t *) _src1, \ + *src2 = (const uint16_t *) _src2; \ + uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin); \ } \ \ -static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \ - const uint8_t *src1, const uint8_t *src2, \ +static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \ + const uint8_t *_src1, const uint8_t *_src2, \ int width, uint32_t *unused) \ { \ + const uint16_t *src1 = (const uint16_t *) _src1, \ + *src2 = (const uint16_t *) _src2; \ + uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \ } @@ -1601,13 +1696,26 @@ static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, assert(src1 == src2); } -static void LEToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, - const uint8_t *src2, int width, uint32_t *unused) +static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, int width, uint32_t *unused) { int i; + const uint16_t *src = (const uint16_t *) _src; + uint16_t *dst = (uint16_t *) _dst; for (i=0; i> (depth - 8); - dstV[i] = input_pixel(&srcV[i]) >> (depth - 8); + int upx = input_pixel(&srcU[i]); + int vpx = input_pixel(&srcV[i]); + dstU[i] = (upx << (16 - depth)) | (upx >> (2 * depth - 16)); + dstV[i] = (vpx << (16 - depth)) | (vpx >> (2 * depth - 16)); } } static av_always_inline void -yuv9_or_10ToY_c_template(uint8_t *dstY, const uint8_t *_srcY, +yuv9_or_10ToY_c_template(uint16_t *dstY, const uint16_t *srcY, int width, enum PixelFormat origin, int depth) { int i; - const uint16_t *srcY = (const uint16_t*)_srcY; - for (i = 0; i < width; i++) - dstY[i] = input_pixel(&srcY[i]) >> (depth - 8); + for (i = 0; i < width; i++) { + int px = input_pixel(&srcY[i]); + dstY[i] = (px << (16 - depth)) | (px >> (2 * depth - 16)); + } } #undef input_pixel #define YUV_NBPS(depth, BE_LE, origin) \ -static void BE_LE ## depth ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \ - const uint8_t *srcU, const uint8_t *srcV, \ +static void BE_LE ## depth ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ + const uint8_t *_srcU, const uint8_t *_srcV, \ int width, uint32_t *unused) \ { \ + uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ + const uint16_t *srcU = (const uint16_t *) _srcU, \ + *srcV = (const uint16_t *) _srcV; \ yuv9_OR_10ToUV_c_template(dstU, dstV, srcU, srcV, width, origin, depth); \ } \ -static void BE_LE ## depth ## ToY_c(uint8_t *dstY, const uint8_t *srcY, \ +static void BE_LE ## depth ## ToY_c(uint8_t *_dstY, const uint8_t *_srcY, \ int width, uint32_t *unused) \ { \ + uint16_t *dstY = (uint16_t *) _dstY; \ + const uint16_t *srcY = (const uint16_t *) _srcY; \ yuv9_or_10ToY_c_template(dstY, srcY, width, origin, depth); \ } @@ -1801,6 +1905,27 @@ static void rgb24ToUV_half_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, } } +static void hScale16_c(int16_t *_dst, int dstW, const uint8_t *_src, + const int16_t *filter, + const int16_t *filterPos, int filterSize) +{ + int i; + int32_t *dst = (int32_t *) _dst; + const uint16_t *src = (const uint16_t *) _src; + + for (i = 0; i < dstW; i++) { + int j; + int srcPos = filterPos[i]; + unsigned int val = 0; + + for (j = 0; j < filterSize; j++) { + val += src[srcPos + j] * filter[filterSize * i + j]; + } + // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit + dst[i] = FFMIN(val >> 11, (1 << 19) - 1); + } +} + // bilinear / bicubic scaling static void hScale_c(int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, @@ -1851,6 +1976,41 @@ static void lumRangeFromJpeg_c(int16_t *dst, int width) dst[i] = (dst[i]*14071 + 33561947)>>14; } +static void chrRangeToJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) +{ + int i; + int32_t *dstU = (int32_t *) _dstU; + int32_t *dstV = (int32_t *) _dstV; + for (i = 0; i < width; i++) { + dstU[i] = (FFMIN(dstU[i],30775)*4663 - 9289992)>>12; //-264 + dstV[i] = (FFMIN(dstV[i],30775)*4663 - 9289992)>>12; //-264 + } +} +static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) +{ + int i; + int32_t *dstU = (int32_t *) _dstU; + int32_t *dstV = (int32_t *) _dstV; + for (i = 0; i < width; i++) { + dstU[i] = (dstU[i]*1799 + 4081085)>>11; //1469 + dstV[i] = (dstV[i]*1799 + 4081085)>>11; //1469 + } +} +static void lumRangeToJpeg16_c(int16_t *_dst, int width) +{ + int i; + int32_t *dst = (int32_t *) _dst; + for (i = 0; i < width; i++) + dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14; +} +static void lumRangeFromJpeg16_c(int16_t *_dst, int width) +{ + int i; + int32_t *dst = (int32_t *) _dst; + for (i = 0; i < width; i++) + dst[i] = (dst[i]*14071 + 33561947)>>14; +} + static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc) { @@ -1864,8 +2024,25 @@ static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, } } +static void scale8To16Rv_c(uint16_t *_dst, const uint8_t *src, int len) +{ + int i; + uint8_t *dst = (uint8_t *) _dst; + for (i = len - 1; i >= 0; i--) { + dst[i * 2] = dst[i * 2 + 1] = src[i]; + } +} + +static void scale19To15Fw_c(int16_t *dst, const int32_t *src, int len) +{ + int i; + for (i = 0; i < len; i++) { + dst[i] = src[i] >> 4; + } +} + // *** horizontal scale Y line to temp buffer -static av_always_inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, +static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc, const int16_t *hLumFilter, const int16_t *hLumFilterPos, int hLumFilterSize, @@ -1880,6 +2057,11 @@ static av_always_inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, src= formatConvBuffer; } + if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + c->scale8To16Rv((uint16_t *) formatConvBuffer, src, srcW); + src = formatConvBuffer; + } + if (!c->hyscale_fast) { c->hScale(dst, dstWidth, src, hLumFilter, hLumFilterPos, hLumFilterSize); } else { // fast bilinear upscale / crap downscale @@ -1888,6 +2070,10 @@ static av_always_inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, if (convertRange) convertRange(dst, dstWidth); + + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + c->scale19To15Fw(dst, (int32_t *) dst, dstWidth); + } } static void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2, @@ -1905,19 +2091,27 @@ static void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2, } } -static av_always_inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *dst2, int dstWidth, +static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc, const int16_t *hChrFilter, const int16_t *hChrFilterPos, int hChrFilterSize, uint8_t *formatConvBuffer, uint32_t *pal) { if (c->chrToYV12) { - uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW, 16); + uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * c->scalingBpp >> 3, 16); c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); src1= formatConvBuffer; src2= buf2; } + if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + uint8_t *buf2 = (formatConvBuffer + FFALIGN(srcW * 2, 16)); + c->scale8To16Rv((uint16_t *) formatConvBuffer, src1, srcW); + c->scale8To16Rv((uint16_t *) buf2, src2, srcW); + src1 = formatConvBuffer; + src2 = buf2; + } + if (!c->hcscale_fast) { c->hScale(dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize); c->hScale(dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize); @@ -1927,6 +2121,11 @@ static av_always_inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *ds if (c->chrConvertRange) c->chrConvertRange(dst1, dst2, dstWidth); + + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + c->scale19To15Fw(dst1, (int32_t *) dst1, dstWidth); + c->scale19To15Fw(dst2, (int32_t *) dst2, dstWidth); + } } static av_always_inline void @@ -2049,20 +2248,20 @@ find_c_packed_planar_out_funcs(SwsContext *c, *yuv2packedX = yuv2uyvy422_X_c; break; case PIX_FMT_RGB48LE: - //*yuv2packed1 = yuv2rgb48le_1_c; - //*yuv2packed2 = yuv2rgb48le_2_c; - //*yuv2packedX = yuv2rgb48le_X_c; - //break; + *yuv2packed1 = yuv2rgb48le_1_c; + *yuv2packed2 = yuv2rgb48le_2_c; + *yuv2packedX = yuv2rgb48le_X_c; + break; case PIX_FMT_RGB48BE: *yuv2packed1 = yuv2rgb48be_1_c; *yuv2packed2 = yuv2rgb48be_2_c; *yuv2packedX = yuv2rgb48be_X_c; break; case PIX_FMT_BGR48LE: - //*yuv2packed1 = yuv2bgr48le_1_c; - //*yuv2packed2 = yuv2bgr48le_2_c; - //*yuv2packedX = yuv2bgr48le_X_c; - //break; + *yuv2packed1 = yuv2bgr48le_1_c; + *yuv2packed2 = yuv2bgr48le_2_c; + *yuv2packedX = yuv2bgr48le_X_c; + break; case PIX_FMT_BGR48BE: *yuv2packed1 = yuv2bgr48be_1_c; *yuv2packed2 = yuv2bgr48be_2_c; @@ -2435,13 +2634,6 @@ static av_cold void sws_init_swScale_c(SwsContext *c) &c->yuv2packed1, &c->yuv2packed2, &c->yuv2packedX); - c->hScale = hScale_c; - - if (c->flags & SWS_FAST_BILINEAR) { - c->hyscale_fast = hyscale_fast_c; - c->hcscale_fast = hcscale_fast_c; - } - c->chrToYV12 = NULL; switch(srcFormat) { case PIX_FMT_YUYV422 : c->chrToYV12 = yuy2ToUV_c; break; @@ -2453,22 +2645,25 @@ static av_cold void sws_init_swScale_c(SwsContext *c) case PIX_FMT_PAL8 : case PIX_FMT_BGR4_BYTE: case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break; - case PIX_FMT_YUV444P9BE: - case PIX_FMT_YUV420P9BE: c->chrToYV12 = BE9ToUV_c; break; case PIX_FMT_YUV444P9LE: - case PIX_FMT_YUV420P9LE: c->chrToYV12 = LE9ToUV_c; break; - case PIX_FMT_YUV444P10BE: - case PIX_FMT_YUV422P10BE: - case PIX_FMT_YUV420P10BE: c->chrToYV12 = BE10ToUV_c; break; + case PIX_FMT_YUV420P9LE: c->chrToYV12 = LE9ToUV_c; break; case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV444P10LE: case PIX_FMT_YUV420P10LE: c->chrToYV12 = LE10ToUV_c; break; - case PIX_FMT_YUV420P16BE: - case PIX_FMT_YUV422P16BE: - case PIX_FMT_YUV444P16BE: c->chrToYV12 = BEToUV_c; break; + case PIX_FMT_YUV444P9BE: + case PIX_FMT_YUV420P9BE: c->chrToYV12 = BE9ToUV_c; break; + case PIX_FMT_YUV444P10BE: + case PIX_FMT_YUV422P10BE: + case PIX_FMT_YUV420P10BE: c->chrToYV12 = BE10ToUV_c; break; +#if HAVE_BIGENDIAN case PIX_FMT_YUV420P16LE: case PIX_FMT_YUV422P16LE: - case PIX_FMT_YUV444P16LE: c->chrToYV12 = LEToUV_c; break; + case PIX_FMT_YUV444P16LE: c->chrToYV12 = bswap16UV_c; break; +#else + case PIX_FMT_YUV420P16BE: + case PIX_FMT_YUV422P16BE: + case PIX_FMT_YUV444P16BE: c->chrToYV12 = bswap16UV_c; break; +#endif } if (c->chrSrcHSubSample) { switch(srcFormat) { @@ -2517,27 +2712,30 @@ static av_cold void sws_init_swScale_c(SwsContext *c) c->lumToYV12 = NULL; c->alpToYV12 = NULL; switch (srcFormat) { - case PIX_FMT_YUV444P9BE: - case PIX_FMT_YUV420P9BE: c->lumToYV12 = BE9ToY_c; break; case PIX_FMT_YUV444P9LE: - case PIX_FMT_YUV420P9LE: c->lumToYV12 = LE9ToY_c; break; - case PIX_FMT_YUV444P10BE: - case PIX_FMT_YUV422P10BE: - case PIX_FMT_YUV420P10BE: c->lumToYV12 = BE10ToY_c; break; + case PIX_FMT_YUV420P9LE: c->lumToYV12 = LE9ToY_c; break; case PIX_FMT_YUV444P10LE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV420P10LE: c->lumToYV12 = LE10ToY_c; break; - case PIX_FMT_YUYV422 : - case PIX_FMT_YUV420P16BE: - case PIX_FMT_YUV422P16BE: - case PIX_FMT_YUV444P16BE: - case PIX_FMT_Y400A : - case PIX_FMT_GRAY16BE : c->lumToYV12 = yuy2ToY_c; break; - case PIX_FMT_UYVY422 : + case PIX_FMT_YUV444P9BE: + case PIX_FMT_YUV420P9BE: c->lumToYV12 = BE9ToY_c; break; + case PIX_FMT_YUV444P10BE: + case PIX_FMT_YUV422P10BE: + case PIX_FMT_YUV420P10BE: c->lumToYV12 = BE10ToY_c; break; +#if HAVE_BIGENDIAN case PIX_FMT_YUV420P16LE: case PIX_FMT_YUV422P16LE: case PIX_FMT_YUV444P16LE: - case PIX_FMT_GRAY16LE : c->lumToYV12 = uyvyToY_c; break; + case PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break; +#else + case PIX_FMT_YUV420P16BE: + case PIX_FMT_YUV422P16BE: + case PIX_FMT_YUV444P16BE: + case PIX_FMT_GRAY16BE: c->lumToYV12 = bswap16Y_c; break; +#endif + case PIX_FMT_YUYV422 : + case PIX_FMT_Y400A : c->lumToYV12 = yuy2ToY_c; break; + case PIX_FMT_UYVY422 : c->lumToYV12 = uyvyToY_c; break; case PIX_FMT_BGR24 : c->lumToYV12 = bgr24ToY_c; break; case PIX_FMT_BGR565LE : c->lumToYV12 = bgr16leToY_c; break; case PIX_FMT_BGR565BE : c->lumToYV12 = bgr16beToY_c; break; @@ -2574,6 +2772,13 @@ static av_cold void sws_init_swScale_c(SwsContext *c) } } + if (c->scalingBpp == 8) { + c->hScale = hScale_c; + if (c->flags & SWS_FAST_BILINEAR) { + c->hyscale_fast = hyscale_fast_c; + c->hcscale_fast = hcscale_fast_c; + } + if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { if (c->srcRange) { c->lumConvertRange = lumRangeFromJpeg_c; @@ -2583,6 +2788,21 @@ static av_cold void sws_init_swScale_c(SwsContext *c) c->chrConvertRange = chrRangeToJpeg_c; } } + } else { + c->hScale = hScale16_c; + c->scale19To15Fw = scale19To15Fw_c; + c->scale8To16Rv = scale8To16Rv_c; + + if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { + if (c->srcRange) { + c->lumConvertRange = lumRangeFromJpeg16_c; + c->chrConvertRange = chrRangeFromJpeg16_c; + } else { + c->lumConvertRange = lumRangeToJpeg16_c; + c->chrConvertRange = chrRangeToJpeg16_c; + } + } + } if (!(isGray(srcFormat) || isGray(c->dstFormat) || srcFormat == PIX_FMT_MONOBLACK || srcFormat == PIX_FMT_MONOWHITE)) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index c1eed8ac96..cfb19d9c13 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -205,6 +205,7 @@ typedef struct SwsContext { enum PixelFormat srcFormat; ///< Source pixel format. int dstFormatBpp; ///< Number of bits per pixel of the destination pixel format. int srcFormatBpp; ///< Number of bits per pixel of the source pixel format. + int scalingBpp; int chrSrcHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image. int chrSrcVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image. int chrDstHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image. @@ -446,6 +447,15 @@ typedef struct SwsContext { void (*lumConvertRange)(int16_t *dst, int width); ///< Color range conversion function for luma plane if needed. void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width); ///< Color range conversion function for chroma planes if needed. + /** + * dst[..] = (src[..] << 8) | src[..]; + */ + void (*scale8To16Rv)(uint16_t *dst, const uint8_t *src, int len); + /** + * dst[..] = src[..] >> 4; + */ + void (*scale19To15Fw)(int16_t *dst, const int32_t *src, int len); + int needs_hcscale; ///< Set if there are chroma planes to be converted. } SwsContext; diff --git a/libswscale/utils.c b/libswscale/utils.c index 69714183d0..b7ccac94ba 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -877,8 +877,13 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) } } - FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW, 16) * 2, fail); - if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2) { + // FIXME it's even nicer if bpp isn't 16, but max({src,dst}formatbpp) + c->scalingBpp = FFMAX(av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1, + av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1) >= 8 ? 16 : 8; + if (c->scalingBpp == 16) + dst_stride <<= 1; + FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW, 16) * 2 * c->scalingBpp >> 3, fail); + if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2 && c->scalingBpp == 8) { c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0; if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) { if (flags&SWS_PRINT_INFO) diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index de0e4abfe0..54c7edc25e 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -1625,32 +1625,6 @@ static void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, assert(src1 == src2); } -static void RENAME(LEToUV)(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused) -{ - __asm__ volatile( - "mov %0, %%"REG_a" \n\t" - "1: \n\t" - "movq (%1, %%"REG_a",2), %%mm0 \n\t" - "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" - "movq (%2, %%"REG_a",2), %%mm2 \n\t" - "movq 8(%2, %%"REG_a",2), %%mm3 \n\t" - "psrlw $8, %%mm0 \n\t" - "psrlw $8, %%mm1 \n\t" - "psrlw $8, %%mm2 \n\t" - "psrlw $8, %%mm3 \n\t" - "packuswb %%mm1, %%mm0 \n\t" - "packuswb %%mm3, %%mm2 \n\t" - "movq %%mm0, (%3, %%"REG_a") \n\t" - "movq %%mm2, (%4, %%"REG_a") \n\t" - "add $8, %%"REG_a" \n\t" - " js 1b \n\t" - : : "g" ((x86_reg)-width), "r" (src1+width*2), "r" (src2+width*2), "r" (dstU+width), "r" (dstV+width) - : "%"REG_a - ); -} - /* This is almost identical to the previous, end exists only because * yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses. */ static void RENAME(uyvyToY)(uint8_t *dst, const uint8_t *src, @@ -1700,33 +1674,6 @@ static void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, assert(src1 == src2); } -static void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused) -{ - __asm__ volatile( - "movq "MANGLE(bm01010101)", %%mm4 \n\t" - "mov %0, %%"REG_a" \n\t" - "1: \n\t" - "movq (%1, %%"REG_a",2), %%mm0 \n\t" - "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" - "movq (%2, %%"REG_a",2), %%mm2 \n\t" - "movq 8(%2, %%"REG_a",2), %%mm3 \n\t" - "pand %%mm4, %%mm0 \n\t" - "pand %%mm4, %%mm1 \n\t" - "pand %%mm4, %%mm2 \n\t" - "pand %%mm4, %%mm3 \n\t" - "packuswb %%mm1, %%mm0 \n\t" - "packuswb %%mm3, %%mm2 \n\t" - "movq %%mm0, (%3, %%"REG_a") \n\t" - "movq %%mm2, (%4, %%"REG_a") \n\t" - "add $8, %%"REG_a" \n\t" - " js 1b \n\t" - : : "g" ((x86_reg)-width), "r" (src1+width*2), "r" (src2+width*2), "r" (dstU+width), "r" (dstV+width) - : "%"REG_a - ); -} - static av_always_inline void RENAME(nvXXtoUV)(uint8_t *dst1, uint8_t *dst2, const uint8_t *src, int width) { @@ -2268,6 +2215,7 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) } } + if (c->scalingBpp == 8) { #if !COMPILE_TEMPLATE_MMX2 c->hScale = RENAME(hScale ); #endif /* !COMPILE_TEMPLATE_MMX2 */ @@ -2285,6 +2233,7 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) #if COMPILE_TEMPLATE_MMX2 } #endif /* COMPILE_TEMPLATE_MMX2 */ + } #if !COMPILE_TEMPLATE_MMX2 switch(srcFormat) { @@ -2292,12 +2241,6 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) case PIX_FMT_UYVY422 : c->chrToYV12 = RENAME(uyvyToUV); break; case PIX_FMT_NV12 : c->chrToYV12 = RENAME(nv12ToUV); break; case PIX_FMT_NV21 : c->chrToYV12 = RENAME(nv21ToUV); break; - case PIX_FMT_YUV420P16BE: - case PIX_FMT_YUV422P16BE: - case PIX_FMT_YUV444P16BE: c->chrToYV12 = RENAME(BEToUV); break; - case PIX_FMT_YUV420P16LE: - case PIX_FMT_YUV422P16LE: - case PIX_FMT_YUV444P16LE: c->chrToYV12 = RENAME(LEToUV); break; default: break; } #endif /* !COMPILE_TEMPLATE_MMX2 */ @@ -2312,16 +2255,8 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) switch (srcFormat) { #if !COMPILE_TEMPLATE_MMX2 case PIX_FMT_YUYV422 : - case PIX_FMT_YUV420P16BE: - case PIX_FMT_YUV422P16BE: - case PIX_FMT_YUV444P16BE: - case PIX_FMT_Y400A : - case PIX_FMT_GRAY16BE : c->lumToYV12 = RENAME(yuy2ToY); break; - case PIX_FMT_UYVY422 : - case PIX_FMT_YUV420P16LE: - case PIX_FMT_YUV422P16LE: - case PIX_FMT_YUV444P16LE: - case PIX_FMT_GRAY16LE : c->lumToYV12 = RENAME(uyvyToY); break; + case PIX_FMT_Y400A : c->lumToYV12 = RENAME(yuy2ToY); break; + case PIX_FMT_UYVY422 : c->lumToYV12 = RENAME(uyvyToY); break; #endif /* !COMPILE_TEMPLATE_MMX2 */ case PIX_FMT_BGR24 : c->lumToYV12 = RENAME(bgr24ToY); break; case PIX_FMT_RGB24 : c->lumToYV12 = RENAME(rgb24ToY); break; diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc index de13e94cff..8695b1dea2 100644 --- a/tests/ref/lavfi/pixdesc +++ b/tests/ref/lavfi/pixdesc @@ -1,8 +1,8 @@ abgr 037bf9df6a765520ad6d490066bf4b89 argb c442a8261c2265a07212ef0f72e35f5a bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b -bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f -bgr48le d022bfdd6a07d5dcc693799322a386b4 +bgr48be 74dedaaacae8fd1ef46e05f78cf29d62 +bgr48le 0eb7d30801eac6058814bddd330b3c76 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b @@ -18,8 +18,8 @@ monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f rgb24 b41eba9651e1b5fe386289b506188105 -rgb48be 460b6de89b156290a12d3941db8bd731 -rgb48le cd93cb34d15996987367dabda3a10128 +rgb48be e3bc84c9af376fb6d0f0293cc7b713a6 +rgb48le f51c0e71638a822458329abb2f4052c7 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c @@ -38,12 +38,12 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p16be 5499502e1c29534a158a1fe60e889f60 -yuv422p16le e3d61fde6978591596bc36b914386623 +yuv422p16be 86ad3447f97969ce095afeef81fa9abf +yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be ea602a24b8e6969679265078bd8607b6 -yuv444p16le 1262a0dc57ee147967fc896d04206313 +yuv444p16be 95db370ae765dd3d10b7def14704ae73 +yuv444p16le 36b969179b5ad9d312a0d1e1cd6bc402 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index de13e94cff..8695b1dea2 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -1,8 +1,8 @@ abgr 037bf9df6a765520ad6d490066bf4b89 argb c442a8261c2265a07212ef0f72e35f5a bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b -bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f -bgr48le d022bfdd6a07d5dcc693799322a386b4 +bgr48be 74dedaaacae8fd1ef46e05f78cf29d62 +bgr48le 0eb7d30801eac6058814bddd330b3c76 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b @@ -18,8 +18,8 @@ monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f rgb24 b41eba9651e1b5fe386289b506188105 -rgb48be 460b6de89b156290a12d3941db8bd731 -rgb48le cd93cb34d15996987367dabda3a10128 +rgb48be e3bc84c9af376fb6d0f0293cc7b713a6 +rgb48le f51c0e71638a822458329abb2f4052c7 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c @@ -38,12 +38,12 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p16be 5499502e1c29534a158a1fe60e889f60 -yuv422p16le e3d61fde6978591596bc36b914386623 +yuv422p16be 86ad3447f97969ce095afeef81fa9abf +yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be ea602a24b8e6969679265078bd8607b6 -yuv444p16le 1262a0dc57ee147967fc896d04206313 +yuv444p16be 95db370ae765dd3d10b7def14704ae73 +yuv444p16le 36b969179b5ad9d312a0d1e1cd6bc402 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_crop b/tests/ref/lavfi/pixfmts_crop index af42cd3c4a..c7b59527fb 100644 --- a/tests/ref/lavfi/pixfmts_crop +++ b/tests/ref/lavfi/pixfmts_crop @@ -1,8 +1,8 @@ abgr cd761690872843d1b7ab0c695393c751 argb 2ec6ef18769bcd651c2e8904d5a3ee67 bgr24 3450fd00cf1493d1ded75544d82ba3ec -bgr48be 90cb5d373a1123432d63c6a10c101afa -bgr48le 9371f54ceda9010f1199e86f4930ac3f +bgr48be a9a7d177cef0914d3f1d266f00dff676 +bgr48le b475d1b529ed80c728ddbacd22d35281 bgr4_byte 2f6ac3cdd4676ab4e2982bdf0664945b bgr555be d3a7c273604723adeb7e5f5dd1c4272b bgr555le d22442fc13b464f9ba455b08df4e981f @@ -14,8 +14,8 @@ gray 8c4850e66562a587a292dc728a65ea4a gray16be daa5a6b98fb4a280c57c57bff1a2ab5a gray16le 84f5ea7259073edcb893113b42213c8e rgb24 3b90ed64b687d3dc186c6ef521dc71a8 -rgb48be a808128041a1962deaa8620c7448feba -rgb48le ce92d02cc322608d5be377cb1940677b +rgb48be b8f9fd6aaa24d75275ee2f8b8a7b9e55 +rgb48le 3e52e831a040f086c3ae983241172cce rgb4_byte 6958029f73c6cdfed4f71020d816f027 rgb555be 41a7d1836837bc90f2cae19a9c9df3b3 rgb555le eeb78f8ce6186fba55c941469e60ba67 @@ -29,12 +29,12 @@ yuv420p bfea0188ddd4889787c403caae119cc7 yuv420p16be 8365eff38b8c329aeb95fc605fa229bb yuv420p16le 5e8dd38d973d5854abe1ad4efad20cc1 yuv422p f2f930a91fe00d4252c4720b5ecd8961 -yuv422p16be 167e4338811a7d272925a4c6417d60da -yuv422p16le 3359395d5875d581fa1e975013d30114 +yuv422p16be 6647fe1c381c148f8207c988c0e22bf0 +yuv422p16le e1548c9dc51202db38a9625c8954203f yuv440p 2472417d980e395ad6843cbb8b633b29 yuv444p 1f151980486848c96bc5585ced99003e -yuv444p16be d69280c2856865d2ea94bd5292aac1c6 -yuv444p16le 33f43e030bedf9723be4f63c3e9fc80e +yuv444p16be ac3b159f8c858fcdf475a8c024ee79b6 +yuv444p16le 9a6863bfc5faee206065c11dc994bf0c yuva420p 7536753dfbc7932560fb50c921369a0e yuvj420p 21f891093006d42d7683b0e1d773a657 yuvj422p 9a43d474c407590ad8f213880586b45e diff --git a/tests/ref/lavfi/pixfmts_hflip b/tests/ref/lavfi/pixfmts_hflip index 3a3dbf0014..7f4342f35c 100644 --- a/tests/ref/lavfi/pixfmts_hflip +++ b/tests/ref/lavfi/pixfmts_hflip @@ -1,8 +1,8 @@ abgr 49468c6c9ceee5d52b08b1270a909323 argb 50ba9f16c6475530602f2983278b82d0 bgr24 cc53d2011d097972db0d22756c3699e3 -bgr48be 11641cf0f4516a9aed98f7872720f801 -bgr48le b5440734eed128554dd9f83b34ba582f +bgr48be 90374bc92471f1bd4931d71ef8b73f50 +bgr48le 696f628d0dd32121e60a0d61ac47d6e6 bgr4_byte aac987e7d1a6a96477cfc0b48a4285de bgr555be bc07265898440116772200390d70c092 bgr555le ccee08679bac84a1f960c6c9070c5538 @@ -14,8 +14,8 @@ gray 03efcb4ab52a24c0af0e03cfd26c9377 gray16be 9bcbca979601ddc4869f846f08f3d1dd gray16le c1b8965adcc7f847ee343149ff507073 rgb24 754f1722fc738590cc407ac65749bfe8 -rgb48be 10743e1577dc3198dbbc7c0b3b8f429e -rgb48le dd945a44f39119221407bf7a04f1bc49 +rgb48be 2397b9d3c296ac15f8a2325a703f81c7 +rgb48le 527043c72546d8b4bb1ce2dea4b294c3 rgb4_byte c8a3f995fcf3e0919239ea2c413ddc29 rgb555be 045ce8607d3910586f4d97481dda8632 rgb555le 8778ee0cf58ce9ad1d99a1eca9f95e87 @@ -29,12 +29,12 @@ yuv420p 2d5c80f9ba2ddd85b2aeda3564cc7d64 yuv420p16be 758b0c1e2113b15e7afde48da4e4d024 yuv420p16le 480ccd951dcb806bc875d307e02e50a0 yuv422p 6e728f4eb9eae287c224f396d84be6ea -yuv422p16be a05d43cd62b790087bd37083174557de -yuv422p16le 6954abebcbc62d81068d58d0c62bdd5b +yuv422p16be 9dbe0af0eb877987611cf04bfa577202 +yuv422p16le 2d8f37231110177cc5e1b61c8cb4b163 yuv440p a99e2b57ed601f39852715c9d675d0d3 yuv444p 947e47f7bb5fdccc659d19b7df2b6fc3 -yuv444p16be e5ef45bc3d2f5b0b2542d5151340c382 -yuv444p16le 70793e3d66d0c23a0cdedabe9c24c2a7 +yuv444p16be debc96a7ec4fec0a412f9d8995bc48a2 +yuv444p16le 5b5e1348a631fc2206bb7ff851a52687 yuva420p d83ec0c01498189f179ec574918185f1 yuvj420p df3aaaec3bb157c3bde5f0365af30f4f yuvj422p d113871528d510a192797af59df9c05c diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index de13e94cff..8695b1dea2 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -1,8 +1,8 @@ abgr 037bf9df6a765520ad6d490066bf4b89 argb c442a8261c2265a07212ef0f72e35f5a bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b -bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f -bgr48le d022bfdd6a07d5dcc693799322a386b4 +bgr48be 74dedaaacae8fd1ef46e05f78cf29d62 +bgr48le 0eb7d30801eac6058814bddd330b3c76 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b @@ -18,8 +18,8 @@ monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f rgb24 b41eba9651e1b5fe386289b506188105 -rgb48be 460b6de89b156290a12d3941db8bd731 -rgb48le cd93cb34d15996987367dabda3a10128 +rgb48be e3bc84c9af376fb6d0f0293cc7b713a6 +rgb48le f51c0e71638a822458329abb2f4052c7 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c @@ -38,12 +38,12 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p16be 5499502e1c29534a158a1fe60e889f60 -yuv422p16le e3d61fde6978591596bc36b914386623 +yuv422p16be 86ad3447f97969ce095afeef81fa9abf +yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be ea602a24b8e6969679265078bd8607b6 -yuv444p16le 1262a0dc57ee147967fc896d04206313 +yuv444p16be 95db370ae765dd3d10b7def14704ae73 +yuv444p16le 36b969179b5ad9d312a0d1e1cd6bc402 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index 670efe15bb..de41952a21 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -1,8 +1,8 @@ abgr d894cb97f6c80eb21bdbe8a4eea62d86 argb 54346f2b2eef10919e0f247241df3b24 bgr24 570f8d6b51a838aed022ef67535f6bdc -bgr48be fcc0f2dbf45d325f84f816c74cbeeebe -bgr48le 3f9c2b23eed3b8d196d1c14b38ce50f5 +bgr48be 07f7a0cc34feb3646434d47c0cec8cee +bgr48le 9abd2c3a66088e6c9078232064eba61e bgr4_byte ee1d35a7baf8e9016891929a2f565c0b bgr555be de8901c1358834fddea060fcb3a67beb bgr555le 36b745067197f9ca8c1731cac51329c9 @@ -11,15 +11,15 @@ bgr565le 3a514a298c6161a071ddf9963c06509d bgr8 7f007fa6c153a16e808a9c51605a4016 bgra a5e7040f9a80cccd65e5acf2ca09ace5 gray d7786a7d9d99ac74230cc045cab5632c -gray16be af39ce3a497f6734b157c8b94544f537 -gray16le 7ac1b788bcc472010df7a97e762485e0 +gray16be bba98532da29a31599df2feec3b08e3e +gray16le 30267f127d5734c4767f3944f1729a33 monob 88c4c050758e64d120f50c7eff694381 monow d31772ebaa877fc2a78565937f7f9673 nv12 4676d59db43d657dc12841f6bc3ab452 nv21 69c699510ff1fb777b118ebee1002f14 rgb24 514692e28e8ff6860e415ce4fcf6eb8c -rgb48be 1894cd30dabcd3180518e4d5f09f25e7 -rgb48le 1354e6e27ce3c1d4d4989ee56030c94b +rgb48be f18841c19fc6d9c817a3095f557b9bc5 +rgb48le 819e7b8acd8965ba57ba46198a5cc9bf rgb4_byte d81ffd3add95842a618eec81024f0b5c rgb555be 4607309f9f217d51cbb53d13b84b4537 rgb555le a350ef1dc2c9688ed49e7ba018843795 @@ -31,19 +31,19 @@ uyvy422 314bd486277111a95d9369b944fa0400 yuv410p 7df8f6d69b56a8dcb6c7ee908e5018b5 yuv411p 1143e7c5cc28fe0922b051b17733bc4c yuv420p fdad2d8df8985e3d17e73c71f713cb14 -yuv420p10be 6d335e75b553da590135cf8bb999610c -yuv420p10le d510ddbabefd03ef39ec943fcb51b709 -yuv420p16be 29a0265764530070f5cd3251cc01f66a -yuv420p16le 6f3a265b084a78baec229238d9f7945f -yuv420p9be ec4983b7a949c0472110a7a2c58e278a -yuv420p9le c136dce5913a722eee44ab72cff664b2 +yuv420p10be 8b5ad855229840a8fa87786cab83f856 +yuv420p10le 5264e87921d47b17411578d9c92672b1 +yuv420p16be f6ef3ba90f238b467c7e72ade927083d +yuv420p16le faf6aab3b1c16e8afbe160686dd360e0 +yuv420p9be c14bf746d161face61e1f39b491bf7ef +yuv420p9le 59457f9a51768bf1d4342238d50a9be3 yuv422p 918e37701ee7377d16a8a6c119c56a40 -yuv422p16be ef3e865fc1d0c68977c735323c50af6e -yuv422p16le 428a9b96214c09cb5a983ce36d6961ff +yuv422p16be 837945d3a771366a5a72a4ed095a4f53 +yuv422p16le b8292ae9b52eb7afc3d8b93e8fd895b4 yuv440p 461503fdb9b90451020aa3b25ddf041c yuv444p 81b2eba962d12e8d64f003ac56f6faf2 -yuv444p16be 99a3738c70c8fbdc5a0e4ad4bf50648d -yuv444p16le 385d0cc5240d62da0871915be5d86f0a +yuv444p16be cc7460f76477aa4b4c33442f67c06a89 +yuv444p16le 9a5ed60d68c0a4a5155f9d376174cdf7 yuva420p 8673a9131fb47de69788863f93a50eb7 yuvj420p 30427bd6caf5bda93a173dbebe759e09 yuvj422p fc8288f64fd149573f73cf8da05d8e6d diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index 0383ad9c08..89502d1745 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -1,8 +1,8 @@ abgr 25e72e9dbd01ab00727c976d577f7be5 argb 19869bf1a5ac0b6af4d8bbe2c104533c bgr24 89108a4ba00201f79b75b9305c42352d -bgr48be ed82382da09b64a8e04728fcf76e6814 -bgr48le 0f1f135608c2ff24d26d03e939fc2112 +bgr48be 908b4edb525fd154a95a3744c4ab5420 +bgr48le 796c2072d6fa13a091f5c5b175417ed5 bgr4_byte 407fcf564ed764c38e1d748f700ab921 bgr555be f739d2519f7e9d494359bf67a3821537 bgr555le bd7b3ec4d684dfad075d89a606cb8b74 @@ -18,8 +18,8 @@ monow ff9869d067ecb94eb9d90c9750c31fea nv12 046f00f598ce14d9854a3534a5c99114 nv21 01ea369dd2d0d3ed7451dc5c8d61497f rgb24 eaefabc168d0b14576bab45bc1e56e1e -rgb48be 4e0c384163ebab06a08e74637beb02bc -rgb48le a77bfeefcd96750cf0e1917a2e2bf1e7 +rgb48be 8e347deca2902e7dc1ece261322577d8 +rgb48le 2034e485f946e4064b5fb9be09865e55 rgb4_byte 8c6ff02df0b06dd2d574836c3741b2a2 rgb555be 40dc33cfb5cf56aac1c5a290ac486c36 rgb555le 4f8eaad29a17e0f8e9d8ab743e76b999 @@ -38,12 +38,12 @@ yuv420p16le 0f609e588e5a258644ef85170d70e030 yuv420p9be be40ec975fb2873891643cbbbddbc3b0 yuv420p9le 7e606310d3f5ff12badf911e8f333471 yuv422p d7f5cb44d9b0210d66d6a8762640ab34 -yuv422p16be 9bd8f8c961822b586fa4cf992be54acc -yuv422p16le 9c4a1239605c7952b736ac3130163f14 +yuv422p16be 8cdfbddf2dd4c44c3efef4ee00170eba +yuv422p16le a2f421f6a1af950544081c1797de01ae yuv440p 876385e96165acf51271b20e5d85a416 yuv444p 9c3c667d1613b72d15bc6d851c5eb8f7 -yuv444p16be 0f4afa4a4aacf4bb6b87641abde71ea9 -yuv444p16le 8f31557bc52adfe00ae8b40a9b8c23f8 +yuv444p16be b092690d22f0b26360fbf5cfd739be17 +yuv444p16le 18768b4ddca92d06f9713fef467276a9 yuva420p c705d1cf061d8c6580ac690b55f92276 yuvj420p 41fd02b204da0ab62452cd14b595e2e4 yuvj422p 7f6ca9bc1812cde02036d7d29a7cce43 From 9ed6cbc3ee2ae3e7472fb25192a7e36fd7b15533 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 28 Jun 2011 22:24:21 -0700 Subject: [PATCH 136/780] ogg: fix double free when finding length of small chained oggs. ogg_save() copies streams[], but doesn't keep track of free()'ed struct members. Thus, if in between a call to ogg_save() and ogg_restore(), streams[].private was free()'ed, this would result in a double free -> crash, which happened when e.g. playing small chained ogg fragments. --- libavformat/oggdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index f1ad630c5e..998a33b43c 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -238,7 +238,8 @@ static int ogg_read_page(AVFormatContext *s, int *str) for (n = 0; n < ogg->nstreams; n++) { av_freep(&ogg->streams[n].buf); - av_freep(&ogg->streams[n].private); + if (!ogg->state || ogg->state->streams[n].private != ogg->streams[n].private) + av_freep(&ogg->streams[n].private); } ogg->curidx = -1; ogg->nstreams = 0; From 0291ce840c0d2dd0fe79701e09f1d7a88def47a6 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 29 Jun 2011 19:01:25 +0100 Subject: [PATCH 137/780] fate: move amr[nw]b test rules into separate files Signed-off-by: Mans Rullgard --- tests/Makefile | 2 + tests/fate/amrnb.mak | 47 +++++++++++++++++++ tests/fate/amrwb.mak | 59 +++++++++++++++++++++++ tests/fate2.mak | 108 ------------------------------------------- 4 files changed, 108 insertions(+), 108 deletions(-) create mode 100644 tests/fate/amrnb.mak create mode 100644 tests/fate/amrwb.mak diff --git a/tests/Makefile b/tests/Makefile index 87ec0256de..38d85fbab7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -46,6 +46,8 @@ include $(SRC_PATH)/tests/fate2.mak include $(SRC_PATH)/tests/fate/aac.mak include $(SRC_PATH)/tests/fate/als.mak +include $(SRC_PATH)/tests/fate/amrnb.mak +include $(SRC_PATH)/tests/fate/amrwb.mak include $(SRC_PATH)/tests/fate/fft.mak include $(SRC_PATH)/tests/fate/h264.mak include $(SRC_PATH)/tests/fate/mp3.mak diff --git a/tests/fate/amrnb.mak b/tests/fate/amrnb.mak new file mode 100644 index 0000000000..e633fec65b --- /dev/null +++ b/tests/fate/amrnb.mak @@ -0,0 +1,47 @@ +FATE_TESTS += fate-amrnb-4k75 +fate-amrnb-4k75: CMD = pcm -i $(SAMPLES)/amrnb/4.75k.amr +fate-amrnb-4k75: CMP = stddev +fate-amrnb-4k75: REF = $(SAMPLES)/amrnb/4.75k.pcm +fate-amrnb-4k75: FUZZ = 1 + +FATE_TESTS += fate-amrnb-5k15 +fate-amrnb-5k15: CMD = pcm -i $(SAMPLES)/amrnb/5.15k.amr +fate-amrnb-5k15: CMP = stddev +fate-amrnb-5k15: REF = $(SAMPLES)/amrnb/5.15k.pcm +fate-amrnb-5k15: FUZZ = 1 + +FATE_TESTS += fate-amrnb-5k9 +fate-amrnb-5k9: CMD = pcm -i $(SAMPLES)/amrnb/5.9k.amr +fate-amrnb-5k9: CMP = stddev +fate-amrnb-5k9: REF = $(SAMPLES)/amrnb/5.9k.pcm +fate-amrnb-5k9: FUZZ = 1 + +FATE_TESTS += fate-amrnb-6k7 +fate-amrnb-6k7: CMD = pcm -i $(SAMPLES)/amrnb/6.7k.amr +fate-amrnb-6k7: CMP = stddev +fate-amrnb-6k7: REF = $(SAMPLES)/amrnb/6.7k.pcm +fate-amrnb-6k7: FUZZ = 1 + +FATE_TESTS += fate-amrnb-7k4 +fate-amrnb-7k4: CMD = pcm -i $(SAMPLES)/amrnb/7.4k.amr +fate-amrnb-7k4: CMP = stddev +fate-amrnb-7k4: REF = $(SAMPLES)/amrnb/7.4k.pcm +fate-amrnb-7k4: FUZZ = 1 + +FATE_TESTS += fate-amrnb-7k95 +fate-amrnb-7k95: CMD = pcm -i $(SAMPLES)/amrnb/7.95k.amr +fate-amrnb-7k95: CMP = stddev +fate-amrnb-7k95: REF = $(SAMPLES)/amrnb/7.95k.pcm +fate-amrnb-7k95: FUZZ = 1 + +FATE_TESTS += fate-amrnb-10k2 +fate-amrnb-10k2: CMD = pcm -i $(SAMPLES)/amrnb/10.2k.amr +fate-amrnb-10k2: CMP = stddev +fate-amrnb-10k2: REF = $(SAMPLES)/amrnb/10.2k.pcm +fate-amrnb-10k2: FUZZ = 1 + +FATE_TESTS += fate-amrnb-12k2 +fate-amrnb-12k2: CMD = pcm -i $(SAMPLES)/amrnb/12.2k.amr +fate-amrnb-12k2: CMP = stddev +fate-amrnb-12k2: REF = $(SAMPLES)/amrnb/12.2k.pcm +fate-amrnb-12k2: FUZZ = 1 diff --git a/tests/fate/amrwb.mak b/tests/fate/amrwb.mak new file mode 100644 index 0000000000..d3931c7ccb --- /dev/null +++ b/tests/fate/amrwb.mak @@ -0,0 +1,59 @@ +FATE_TESTS += fate-amrwb-6k60 +fate-amrwb-6k60: CMD = pcm -i $(SAMPLES)/amrwb/seed-6k60.awb +fate-amrwb-6k60: CMP = stddev +fate-amrwb-6k60: REF = $(SAMPLES)/amrwb/seed-6k60.pcm +fate-amrwb-6k60: FUZZ = 1 + +FATE_TESTS += fate-amrwb-8k85 +fate-amrwb-8k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-8k85.awb +fate-amrwb-8k85: CMP = stddev +fate-amrwb-8k85: REF = $(SAMPLES)/amrwb/seed-8k85.pcm +fate-amrwb-8k85: FUZZ = 1 + +FATE_TESTS += fate-amrwb-12k65 +fate-amrwb-12k65: CMD = pcm -i $(SAMPLES)/amrwb/seed-12k65.awb +fate-amrwb-12k65: CMP = stddev +fate-amrwb-12k65: REF = $(SAMPLES)/amrwb/seed-12k65.pcm +fate-amrwb-12k65: FUZZ = 1 + +FATE_TESTS += fate-amrwb-14k25 +fate-amrwb-14k25: CMD = pcm -i $(SAMPLES)/amrwb/seed-14k25.awb +fate-amrwb-14k25: CMP = stddev +fate-amrwb-14k25: REF = $(SAMPLES)/amrwb/seed-14k25.pcm +fate-amrwb-14k25: FUZZ = 2.6 + +FATE_TESTS += fate-amrwb-15k85 +fate-amrwb-15k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-15k85.awb +fate-amrwb-15k85: CMP = stddev +fate-amrwb-15k85: REF = $(SAMPLES)/amrwb/seed-15k85.pcm +fate-amrwb-15k85: FUZZ = 1 + +FATE_TESTS += fate-amrwb-18k25 +fate-amrwb-18k25: CMD = pcm -i $(SAMPLES)/amrwb/seed-18k25.awb +fate-amrwb-18k25: CMP = stddev +fate-amrwb-18k25: REF = $(SAMPLES)/amrwb/seed-18k25.pcm +fate-amrwb-18k25: FUZZ = 1 + +FATE_TESTS += fate-amrwb-19k85 +fate-amrwb-19k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-19k85.awb +fate-amrwb-19k85: CMP = stddev +fate-amrwb-19k85: REF = $(SAMPLES)/amrwb/seed-19k85.pcm +fate-amrwb-19k85: FUZZ = 1 + +FATE_TESTS += fate-amrwb-23k05 +fate-amrwb-23k05: CMD = pcm -i $(SAMPLES)/amrwb/seed-23k05.awb +fate-amrwb-23k05: CMP = stddev +fate-amrwb-23k05: REF = $(SAMPLES)/amrwb/seed-23k05.pcm +fate-amrwb-23k05: FUZZ = 2 + +FATE_TESTS += fate-amrwb-23k85 +fate-amrwb-23k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-23k85.awb +fate-amrwb-23k85: CMP = stddev +fate-amrwb-23k85: REF = $(SAMPLES)/amrwb/seed-23k85.pcm +fate-amrwb-23k85: FUZZ = 2 + +FATE_TESTS += fate-amrwb-23k85-2 +fate-amrwb-23k85-2: CMD = pcm -i $(SAMPLES)/amrwb/deus-23k85.awb +fate-amrwb-23k85-2: CMP = stddev +fate-amrwb-23k85-2: REF = $(SAMPLES)/amrwb/deus-23k85.pcm +fate-amrwb-23k85-2: FUZZ = 1 diff --git a/tests/fate2.mak b/tests/fate2.mak index b4139f35f7..f8bae65536 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -222,111 +222,3 @@ fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff fate-musepack7: REF = $(SAMPLES)/musepack/inside-mp7.pcm fate-musepack7: FUZZ = 1 - -FATE_TESTS += fate-amrnb-4k75 -fate-amrnb-4k75: CMD = pcm -i $(SAMPLES)/amrnb/4.75k.amr -fate-amrnb-4k75: CMP = stddev -fate-amrnb-4k75: REF = $(SAMPLES)/amrnb/4.75k.pcm -fate-amrnb-4k75: FUZZ = 1 - -FATE_TESTS += fate-amrnb-5k15 -fate-amrnb-5k15: CMD = pcm -i $(SAMPLES)/amrnb/5.15k.amr -fate-amrnb-5k15: CMP = stddev -fate-amrnb-5k15: REF = $(SAMPLES)/amrnb/5.15k.pcm -fate-amrnb-5k15: FUZZ = 1 - -FATE_TESTS += fate-amrnb-5k9 -fate-amrnb-5k9: CMD = pcm -i $(SAMPLES)/amrnb/5.9k.amr -fate-amrnb-5k9: CMP = stddev -fate-amrnb-5k9: REF = $(SAMPLES)/amrnb/5.9k.pcm -fate-amrnb-5k9: FUZZ = 1 - -FATE_TESTS += fate-amrnb-6k7 -fate-amrnb-6k7: CMD = pcm -i $(SAMPLES)/amrnb/6.7k.amr -fate-amrnb-6k7: CMP = stddev -fate-amrnb-6k7: REF = $(SAMPLES)/amrnb/6.7k.pcm -fate-amrnb-6k7: FUZZ = 1 - -FATE_TESTS += fate-amrnb-7k4 -fate-amrnb-7k4: CMD = pcm -i $(SAMPLES)/amrnb/7.4k.amr -fate-amrnb-7k4: CMP = stddev -fate-amrnb-7k4: REF = $(SAMPLES)/amrnb/7.4k.pcm -fate-amrnb-7k4: FUZZ = 1 - -FATE_TESTS += fate-amrnb-7k95 -fate-amrnb-7k95: CMD = pcm -i $(SAMPLES)/amrnb/7.95k.amr -fate-amrnb-7k95: CMP = stddev -fate-amrnb-7k95: REF = $(SAMPLES)/amrnb/7.95k.pcm -fate-amrnb-7k95: FUZZ = 1 - -FATE_TESTS += fate-amrnb-10k2 -fate-amrnb-10k2: CMD = pcm -i $(SAMPLES)/amrnb/10.2k.amr -fate-amrnb-10k2: CMP = stddev -fate-amrnb-10k2: REF = $(SAMPLES)/amrnb/10.2k.pcm -fate-amrnb-10k2: FUZZ = 1 - -FATE_TESTS += fate-amrnb-12k2 -fate-amrnb-12k2: CMD = pcm -i $(SAMPLES)/amrnb/12.2k.amr -fate-amrnb-12k2: CMP = stddev -fate-amrnb-12k2: REF = $(SAMPLES)/amrnb/12.2k.pcm -fate-amrnb-12k2: FUZZ = 1 - -FATE_TESTS += fate-amrwb-6k60 -fate-amrwb-6k60: CMD = pcm -i $(SAMPLES)/amrwb/seed-6k60.awb -fate-amrwb-6k60: CMP = stddev -fate-amrwb-6k60: REF = $(SAMPLES)/amrwb/seed-6k60.pcm -fate-amrwb-6k60: FUZZ = 1 - -FATE_TESTS += fate-amrwb-8k85 -fate-amrwb-8k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-8k85.awb -fate-amrwb-8k85: CMP = stddev -fate-amrwb-8k85: REF = $(SAMPLES)/amrwb/seed-8k85.pcm -fate-amrwb-8k85: FUZZ = 1 - -FATE_TESTS += fate-amrwb-12k65 -fate-amrwb-12k65: CMD = pcm -i $(SAMPLES)/amrwb/seed-12k65.awb -fate-amrwb-12k65: CMP = stddev -fate-amrwb-12k65: REF = $(SAMPLES)/amrwb/seed-12k65.pcm -fate-amrwb-12k65: FUZZ = 1 - -FATE_TESTS += fate-amrwb-14k25 -fate-amrwb-14k25: CMD = pcm -i $(SAMPLES)/amrwb/seed-14k25.awb -fate-amrwb-14k25: CMP = stddev -fate-amrwb-14k25: REF = $(SAMPLES)/amrwb/seed-14k25.pcm -fate-amrwb-14k25: FUZZ = 2.6 - -FATE_TESTS += fate-amrwb-15k85 -fate-amrwb-15k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-15k85.awb -fate-amrwb-15k85: CMP = stddev -fate-amrwb-15k85: REF = $(SAMPLES)/amrwb/seed-15k85.pcm -fate-amrwb-15k85: FUZZ = 1 - -FATE_TESTS += fate-amrwb-18k25 -fate-amrwb-18k25: CMD = pcm -i $(SAMPLES)/amrwb/seed-18k25.awb -fate-amrwb-18k25: CMP = stddev -fate-amrwb-18k25: REF = $(SAMPLES)/amrwb/seed-18k25.pcm -fate-amrwb-18k25: FUZZ = 1 - -FATE_TESTS += fate-amrwb-19k85 -fate-amrwb-19k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-19k85.awb -fate-amrwb-19k85: CMP = stddev -fate-amrwb-19k85: REF = $(SAMPLES)/amrwb/seed-19k85.pcm -fate-amrwb-19k85: FUZZ = 1 - -FATE_TESTS += fate-amrwb-23k05 -fate-amrwb-23k05: CMD = pcm -i $(SAMPLES)/amrwb/seed-23k05.awb -fate-amrwb-23k05: CMP = stddev -fate-amrwb-23k05: REF = $(SAMPLES)/amrwb/seed-23k05.pcm -fate-amrwb-23k05: FUZZ = 2 - -FATE_TESTS += fate-amrwb-23k85 -fate-amrwb-23k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-23k85.awb -fate-amrwb-23k85: CMP = stddev -fate-amrwb-23k85: REF = $(SAMPLES)/amrwb/seed-23k85.pcm -fate-amrwb-23k85: FUZZ = 2 - -FATE_TESTS += fate-amrwb-23k85-2 -fate-amrwb-23k85-2: CMD = pcm -i $(SAMPLES)/amrwb/deus-23k85.awb -fate-amrwb-23k85-2: CMP = stddev -fate-amrwb-23k85-2: REF = $(SAMPLES)/amrwb/deus-23k85.pcm -fate-amrwb-23k85-2: FUZZ = 1 From a3e1f80e8ba28151ea5d84c15ecf454b8170aa13 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 29 Jun 2011 20:59:24 +0100 Subject: [PATCH 138/780] ARM: remove check for PLD instruction PLD is present in ARMv5TE and later, which is checked for separately. Signed-off-by: Mans Rullgard --- configure | 4 ---- libavcodec/arm/dsputil_arm.S | 7 ++----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/configure b/configure index a1cc59ae5b..ca6a982dfd 100755 --- a/configure +++ b/configure @@ -1093,7 +1093,6 @@ HAVE_LIST=" memalign mkstemp mmap - pld posix_memalign round roundf @@ -2608,9 +2607,6 @@ EOF warn "Compiler does not indicate floating-point ABI, guessing $fpabi." fi - # We have to check if pld is a nop and disable it. - check_asm pld '"pld [r0]"' - enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"' enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"' enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"' diff --git a/libavcodec/arm/dsputil_arm.S b/libavcodec/arm/dsputil_arm.S index eb20ad6d9e..136551f4c9 100644 --- a/libavcodec/arm/dsputil_arm.S +++ b/libavcodec/arm/dsputil_arm.S @@ -24,11 +24,6 @@ preserve8 -#if !HAVE_PLD -.macro pld reg -.endm -#endif - #if HAVE_ARMV5TE function ff_prefetch_arm, export=1 subs r2, r2, #1 @@ -37,6 +32,8 @@ function ff_prefetch_arm, export=1 bne ff_prefetch_arm bx lr endfunc +#else +#define pld @ #endif .macro ALIGN_QWORD_D shift, Rd0, Rd1, Rd2, Rd3, Rn0, Rn1, Rn2, Rn3, Rn4 From 0bc01cc9fe83fe676690fd200e7d74cdab595f15 Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Wed, 15 Jun 2011 02:50:25 -0600 Subject: [PATCH 139/780] psymodel: Add channels and channel groups to the psymodel. --- libavcodec/aaccoder.c | 14 ++++++------ libavcodec/aacenc.c | 8 +++---- libavcodec/aacpsy.c | 5 ++-- libavcodec/psymodel.c | 36 +++++++++++++++++++++++++---- libavcodec/psymodel.h | 53 +++++++++++++++++++++++++++++++++++++------ 5 files changed, 91 insertions(+), 25 deletions(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index e752b63c7f..b64bf9fa2d 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -345,7 +345,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce float cost_stay_here, cost_get_here; float rd = 0.0f; for (w = 0; w < group_len; w++) { - FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(win+w)*16+swb]; + FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(win+w)*16+swb]; rd += quantize_band_cost(s, sce->coeffs + start + w*128, s->scoefs + start + w*128, size, sce->sf_idx[(win+w)*16+swb], cb, @@ -625,7 +625,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, qmin = INT_MAX; qmax = 0.0f; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { - FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; + FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; if (band->energy <= band->threshold || band->threshold == 0.0f) { sce->zeroes[(w+w2)*16+g] = 1; continue; @@ -654,7 +654,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, float dist = 0; int cb = find_min_book(maxval, sce->sf_idx[w*16+g]); for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { - FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; + FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; dist += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], q + q0, cb, lambda / band->threshold, INFINITY, NULL); } @@ -727,7 +727,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, int nz = 0; float uplim = 0.0f; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { - FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; + FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; uplim += band->threshold; if (band->energy <= band->threshold || band->threshold == 0.0f) { sce->zeroes[(w+w2)*16+g] = 1; @@ -1027,7 +1027,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (g = 0; g < sce->ics.num_swb; g++) { for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { - FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; + FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; if (band->energy <= band->threshold) { sce->sf_idx[(w+w2)*16+g] = 218; sce->zeroes[(w+w2)*16+g] = 1; @@ -1065,8 +1065,8 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe, if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) { float dist1 = 0.0f, dist2 = 0.0f; for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) { - FFPsyBand *band0 = &s->psy.psy_bands[(s->cur_channel+0)*PSY_MAX_BANDS+(w+w2)*16+g]; - FFPsyBand *band1 = &s->psy.psy_bands[(s->cur_channel+1)*PSY_MAX_BANDS+(w+w2)*16+g]; + FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g]; + FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g]; float minthr = FFMIN(band0->threshold, band1->threshold); float maxthr = FFMAX(band0->threshold, band1->threshold); for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 8c7ed87b4a..1df16ade27 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -210,7 +210,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) sizes[1] = swb_size_128[i]; lengths[0] = ff_aac_num_swb_1024[i]; lengths[1] = ff_aac_num_swb_128[i]; - ff_psy_init(&s->psy, avctx, 2, sizes, lengths); + ff_psy_init(&s->psy, avctx, 2, sizes, lengths, s->chan_map[0], &s->chan_map[1]); s->psypp = ff_psy_preprocess_init(avctx); s->coder = &ff_aac_coders[2]; @@ -570,8 +570,8 @@ static int aac_encode_frame(AVCodecContext *avctx, put_bits(&s->pb, 3, tag); put_bits(&s->pb, 4, chan_el_counter[tag]++); for (ch = 0; ch < chans; ch++) { - s->cur_channel = start_ch + ch; - s->psy.model->analyze(&s->psy, s->cur_channel, cpe->ch[ch].coeffs, &wi[ch]); + s->cur_channel = start_ch * 2 + ch; + s->psy.model->analyze(&s->psy, start_ch + ch, cpe->ch[ch].coeffs, &wi[ch]); s->coder->search_for_quantizers(avctx, s, &cpe->ch[ch], s->lambda); } cpe->common_window = 0; @@ -587,7 +587,7 @@ static int aac_encode_frame(AVCodecContext *avctx, } } } - s->cur_channel = start_ch; + s->cur_channel = start_ch * 2; if (s->options.stereo_mode && cpe->common_window) { if (s->options.stereo_mode > 0) { IndividualChannelStream *ics = &cpe->ch[0].ics; diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index cf8f7eb914..79d708439c 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -627,7 +627,7 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, } /* 5.6.1.3.2 "Calculation of the desired perceptual entropy" */ - ctx->pe[channel] = pe; + ctx->ch[channel].entropy = pe; desired_bits = calc_bit_demand(pctx, pe, ctx->bitres.bits, ctx->bitres.size, wi->num_windows == 8); desired_pe = PSY_3GPP_BITS_TO_PE(desired_bits); /* NOTE: PE correction is kept simple. During initial testing it had very @@ -731,7 +731,7 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, for (w = 0; w < wi->num_windows*16; w += 16) { for (g = 0; g < num_bands; g++) { AacPsyBand *band = &pch->band[w+g]; - FFPsyBand *psy_band = &ctx->psy_bands[channel*PSY_MAX_BANDS+w+g]; + FFPsyBand *psy_band = &ctx->ch[channel].psy_bands[w+g]; psy_band->threshold = band->thr; psy_band->energy = band->energy; @@ -921,5 +921,6 @@ const FFPsyModel ff_aac_psy_model = .init = psy_3gpp_init, .window = psy_lame_window, .analyze = psy_3gpp_analyze, + .analyze_group = NULL, .end = psy_3gpp_end, }; diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c index fe9363c7a9..740d859456 100644 --- a/libavcodec/psymodel.c +++ b/libavcodec/psymodel.c @@ -25,16 +25,31 @@ extern const FFPsyModel ff_aac_psy_model; -av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, - int num_lens, - const uint8_t **bands, const int* num_bands) +av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens, + const uint8_t **bands, const int* num_bands, + int num_groups, const uint8_t *group_map) { + int i, j, k = 0; + ctx->avctx = avctx; - ctx->psy_bands = av_mallocz(sizeof(FFPsyBand) * PSY_MAX_BANDS * avctx->channels); + ctx->ch = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2); + ctx->group = av_mallocz(sizeof(ctx->group[0]) * num_groups); ctx->bands = av_malloc (sizeof(ctx->bands[0]) * num_lens); ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens); memcpy(ctx->bands, bands, sizeof(ctx->bands[0]) * num_lens); memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) * num_lens); + + /* assign channels to groups (with virtual channels for coupling) */ + for (i = 0; i < num_groups; i++) { + /* NOTE: Add 1 to handle the AAC chan_config without modification. + * This has the side effect of allowing an array of 0s to map + * to one channel per group. + */ + ctx->group[i].num_ch = group_map[i] + 1; + for (j = 0; j < ctx->group[i].num_ch * 2; j++) + ctx->group[i].ch[j] = &ctx->ch[k++]; + } + switch (ctx->avctx->codec_id) { case CODEC_ID_AAC: ctx->model = &ff_aac_psy_model; @@ -45,13 +60,24 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, return 0; } +FFPsyChannelGroup *ff_psy_find_group(FFPsyContext *ctx, int channel) +{ + int i = 0, ch = 0; + + while (ch <= channel) + ch += ctx->group[i++].num_ch; + + return &ctx->group[i-1]; +} + av_cold void ff_psy_end(FFPsyContext *ctx) { if (ctx->model->end) ctx->model->end(ctx); av_freep(&ctx->bands); av_freep(&ctx->num_bands); - av_freep(&ctx->psy_bands); + av_freep(&ctx->group); + av_freep(&ctx->ch); } typedef struct FFPsyPreprocessContext{ diff --git a/libavcodec/psymodel.h b/libavcodec/psymodel.h index 02dc9c92b1..241f8ecdb3 100644 --- a/libavcodec/psymodel.h +++ b/libavcodec/psymodel.h @@ -40,6 +40,23 @@ typedef struct FFPsyBand { float perceptual_weight; } FFPsyBand; +/** + * single channel psychoacoustic information + */ +typedef struct FFPsyChannel { + FFPsyBand psy_bands[PSY_MAX_BANDS]; ///< channel bands information + float entropy; ///< total PE for this channel +} FFPsyChannel; + +/** + * psychoacoustic information for an arbitrary group of channels + */ +typedef struct FFPsyChannelGroup { + FFPsyChannel *ch[PSY_MAX_CHANS]; ///< pointers to the individual channels in the group + uint8_t num_ch; ///< number of channels in this group + uint8_t coupling[PSY_MAX_BANDS]; ///< allow coupling for this band in the group +} FFPsyChannelGroup; + /** * windowing related information */ @@ -58,14 +75,14 @@ typedef struct FFPsyContext { AVCodecContext *avctx; ///< encoder context const struct FFPsyModel *model; ///< encoder-specific model functions - FFPsyBand *psy_bands; ///< frame bands information + FFPsyChannel *ch; ///< single channel information + FFPsyChannelGroup *group; ///< channel group information + int num_groups; ///< number of channel groups uint8_t **bands; ///< scalefactor band sizes for possible frame sizes int *num_bands; ///< number of scalefactor bands for possible frame sizes int num_lens; ///< number of scalefactor band sets - float pe[PSY_MAX_CHANS]; ///< total PE for each channel in the frame - struct { int size; ///< size of the bitresevoir in bits int bits; ///< number of bits used in the bitresevoir @@ -95,7 +112,7 @@ typedef struct FFPsyModel { FFPsyWindowInfo (*window)(FFPsyContext *ctx, const int16_t *audio, const int16_t *la, int channel, int prev_type); /** - * Perform psychoacoustic analysis and set band info (threshold, energy). + * Perform psychoacoustic analysis and set band info (threshold, energy) for a single channel. * * @param ctx model context * @param channel audio channel number @@ -104,6 +121,16 @@ typedef struct FFPsyModel { */ void (*analyze)(FFPsyContext *ctx, int channel, const float *coeffs, const FFPsyWindowInfo *wi); + /** + * Perform psychoacoustic analysis and set band info (threshold, energy) for a group of channels. + * + * @param ctx model context + * @param channel channel number of the first channel in the group to perform analysis on + * @param coeffs array of pointers to the transformed coefficients + * @param wi window information for the channels in the group + */ + void (*analyze_group)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi); + void (*end) (FFPsyContext *apc); } FFPsyModel; @@ -115,12 +142,24 @@ typedef struct FFPsyModel { * @param num_lens number of possible frame lengths * @param bands scalefactor band lengths for all frame lengths * @param num_bands number of scalefactor bands for all frame lengths + * @param num_groups number of channel groups + * @param group_map array with # of channels in group - 1, for each group * * @return zero if successful, a negative value if not */ -av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, - int num_lens, - const uint8_t **bands, const int* num_bands); +av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens, + const uint8_t **bands, const int* num_bands, + int num_groups, const uint8_t *group_map); + +/** + * Determine what group a channel belongs to. + * + * @param ctx psymodel context + * @param channel channel to locate the group for + * + * @return pointer to the FFPsyChannelGroup this channel belongs to + */ +FFPsyChannelGroup *ff_psy_find_group(FFPsyContext *ctx, int channel); /** * Cleanup model context at the end. From 01344fe409da286cd377f9af610eb4c4888687ec Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Wed, 18 May 2011 23:14:59 -0600 Subject: [PATCH 140/780] aacenc: Implement dummy channel group analysis that just calls the single channel analysis for each channel. --- libavcodec/aacenc.c | 5 ++++- libavcodec/aacpsy.c | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 1df16ade27..385c6aa994 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -564,14 +564,17 @@ static int aac_encode_frame(AVCodecContext *avctx, memset(chan_el_counter, 0, sizeof(chan_el_counter)); for (i = 0; i < s->chan_map[0]; i++) { FFPsyWindowInfo* wi = windows + start_ch; + const float *coeffs[2]; tag = s->chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; put_bits(&s->pb, 3, tag); put_bits(&s->pb, 4, chan_el_counter[tag]++); + for (ch = 0; ch < chans; ch++) + coeffs[ch] = cpe->ch[ch].coeffs; + s->psy.model->analyze_group(&s->psy, start_ch, coeffs, wi); for (ch = 0; ch < chans; ch++) { s->cur_channel = start_ch * 2 + ch; - s->psy.model->analyze(&s->psy, start_ch + ch, cpe->ch[ch].coeffs, &wi[ch]); s->coder->search_for_quantizers(avctx, s, &cpe->ch[ch], s->lambda); } cpe->common_window = 0; diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index 79d708439c..ff17846e9d 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -741,6 +741,16 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, memcpy(pch->prev_band, pch->band, sizeof(pch->band)); } +static void psy_3gpp_analyze_group(FFPsyContext *ctx, int channel, + const float **coeffs, const FFPsyWindowInfo *wi) +{ + int ch; + FFPsyChannelGroup *group = ff_psy_find_group(ctx, channel); + + for (ch = 0; ch < group->num_ch; ch++) + psy_3gpp_analyze(ctx, channel + ch, coeffs[ch], &wi[ch]); +} + static av_cold void psy_3gpp_end(FFPsyContext *apc) { AacPsyContext *pctx = (AacPsyContext*) apc->model_priv_data; @@ -921,6 +931,6 @@ const FFPsyModel ff_aac_psy_model = .init = psy_3gpp_init, .window = psy_lame_window, .analyze = psy_3gpp_analyze, - .analyze_group = NULL, + .analyze_group = psy_3gpp_analyze_group, .end = psy_3gpp_end, }; From d3a6c2ab7e76f12f56932a087266b082dc1dc39b Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Wed, 18 May 2011 23:23:22 -0600 Subject: [PATCH 141/780] psymodel: Remove the single channel analysis function --- libavcodec/aacenc.c | 2 +- libavcodec/aacpsy.c | 9 ++++----- libavcodec/psymodel.h | 12 +----------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 385c6aa994..dd8a83c537 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -572,7 +572,7 @@ static int aac_encode_frame(AVCodecContext *avctx, put_bits(&s->pb, 4, chan_el_counter[tag]++); for (ch = 0; ch < chans; ch++) coeffs[ch] = cpe->ch[ch].coeffs; - s->psy.model->analyze_group(&s->psy, start_ch, coeffs, wi); + s->psy.model->analyze(&s->psy, start_ch, coeffs, wi); for (ch = 0; ch < chans; ch++) { s->cur_channel = start_ch * 2 + ch; s->coder->search_for_quantizers(avctx, s, &cpe->ch[ch], s->lambda); diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index ff17846e9d..93ff934b2a 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -557,8 +557,8 @@ static float calc_reduced_thr_3gpp(AacPsyBand *band, float min_snr, /** * Calculate band thresholds as suggested in 3GPP TS26.403 */ -static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, - const float *coefs, const FFPsyWindowInfo *wi) +static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel, + const float *coefs, const FFPsyWindowInfo *wi) { AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data; AacPsyChannel *pch = &pctx->ch[channel]; @@ -741,14 +741,14 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, memcpy(pch->prev_band, pch->band, sizeof(pch->band)); } -static void psy_3gpp_analyze_group(FFPsyContext *ctx, int channel, +static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi) { int ch; FFPsyChannelGroup *group = ff_psy_find_group(ctx, channel); for (ch = 0; ch < group->num_ch; ch++) - psy_3gpp_analyze(ctx, channel + ch, coeffs[ch], &wi[ch]); + psy_3gpp_analyze_channel(ctx, channel + ch, coeffs[ch], &wi[ch]); } static av_cold void psy_3gpp_end(FFPsyContext *apc) @@ -931,6 +931,5 @@ const FFPsyModel ff_aac_psy_model = .init = psy_3gpp_init, .window = psy_lame_window, .analyze = psy_3gpp_analyze, - .analyze_group = psy_3gpp_analyze_group, .end = psy_3gpp_end, }; diff --git a/libavcodec/psymodel.h b/libavcodec/psymodel.h index 241f8ecdb3..3e866e40cc 100644 --- a/libavcodec/psymodel.h +++ b/libavcodec/psymodel.h @@ -111,16 +111,6 @@ typedef struct FFPsyModel { */ FFPsyWindowInfo (*window)(FFPsyContext *ctx, const int16_t *audio, const int16_t *la, int channel, int prev_type); - /** - * Perform psychoacoustic analysis and set band info (threshold, energy) for a single channel. - * - * @param ctx model context - * @param channel audio channel number - * @param coeffs pointer to the transformed coefficients - * @param wi window information - */ - void (*analyze)(FFPsyContext *ctx, int channel, const float *coeffs, const FFPsyWindowInfo *wi); - /** * Perform psychoacoustic analysis and set band info (threshold, energy) for a group of channels. * @@ -129,7 +119,7 @@ typedef struct FFPsyModel { * @param coeffs array of pointers to the transformed coefficients * @param wi window information for the channels in the group */ - void (*analyze_group)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi); + void (*analyze)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi); void (*end) (FFPsyContext *apc); } FFPsyModel; From 98add74e85967441d6b7263d1eee79aa2d98cd82 Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Tue, 28 Jun 2011 21:11:39 -0600 Subject: [PATCH 142/780] aacenc: Fix determination of Mid/Side Mode. In adjust_frame_information(), msc is incremented for each sfb in each sub-window then compared against max_sfb which is for a single sub-window. This resulted in frames using EIGHT_SHORT_SEQUENCE where the first few sub-windows increment msc to a value that results in ms_mode == 2. Even though only some of the bands are actually using Mid/Side. --- libavcodec/aacenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index dd8a83c537..eae933235f 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -364,7 +364,7 @@ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in if (msc == 0 || ics0->max_sfb == 0) cpe->ms_mode = 0; else - cpe->ms_mode = msc < ics0->max_sfb ? 1 : 2; + cpe->ms_mode = msc < ics0->max_sfb * ics0->num_windows ? 1 : 2; } } From 08b4a667ef0ed02980a74f3b2174de2040fe1061 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 29 Jun 2011 23:49:44 +0200 Subject: [PATCH 143/780] Set channel_layout if channels is set when transcoding. --- ffmpeg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index f2716a35aa..295d71044f 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2282,8 +2282,10 @@ static int transcode(AVFormatContext **output_files, } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; - if (!codec->channels) + if (!codec->channels) { codec->channels = icodec->channels; + codec->channel_layout = icodec->channel_layout; + } if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) codec->channel_layout = 0; ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; From e1a54304be1ccbbff2fcd3ee955acfbceb71221f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Thu, 30 Jun 2011 00:01:14 +0200 Subject: [PATCH 144/780] Move SRC_PATH hack around to allow compilation from subdir again. --- Makefile | 2 +- common.mak | 6 ------ configure | 3 +++ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index cf6c596919..dd3a1f6f33 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +MAIN_MAKEFILE=1 include config.mak vpath %.c $(SRC_PATH) @@ -39,7 +40,6 @@ DATA_FILES := $(wildcard $(SRC_PATH)/ffpresets/*.ffpreset) SKIPHEADERS = cmdutils_common_opts.h -MAIN_MAKEFILE=1 include $(SRC_PATH)/common.mak FF_LDFLAGS := $(FFLDFLAGS) diff --git a/common.mak b/common.mak index ddaf45c370..9525dd44b6 100644 --- a/common.mak +++ b/common.mak @@ -7,12 +7,6 @@ all: all-yes ifndef SUBDIR -ifndef MAIN_MAKEFILE -ifeq ($(SRC_PATH),.) -SRC_PATH = .. -endif -endif - ifndef V Q = @ ECHO = printf "$(1)\t%s\n" $(2) diff --git a/configure b/configure index 9ca6193dbd..3092248f71 100755 --- a/configure +++ b/configure @@ -3297,6 +3297,9 @@ BINDIR=\$(DESTDIR)$bindir DATADIR=\$(DESTDIR)$datadir MANDIR=\$(DESTDIR)$mandir SRC_PATH=$source_path +ifndef MAIN_MAKEFILE +SRC_PATH:=\$(SRC_PATH:.%=..%) +endif CC_IDENT=$cc_ident ARCH=$arch CC=$cc From 59ca3955fbe13401bf49d456562264267d9991fe Mon Sep 17 00:00:00 2001 From: Ami Fischman Date: Wed, 29 Jun 2011 13:50:21 -0700 Subject: [PATCH 145/780] av_find_stream_info: simplify EAGAIN handling. Signed-off-by: Ronald S. Bultje --- libavformat/utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 7370c60bdf..b12f785565 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2306,7 +2306,10 @@ int av_find_stream_info(AVFormatContext *ic) /* NOTE: a new stream can be added there if no header in file (AVFMTCTX_NOHEADER) */ ret = av_read_frame_internal(ic, &pkt1); - if (ret < 0 && ret != AVERROR(EAGAIN)) { + if (ret == AVERROR(EAGAIN)) + continue; + + if (ret < 0) { /* EOF or error */ ret = -1; /* we could not have all the codec parameters before EOF */ for(i=0;inb_streams;i++) { @@ -2322,9 +2325,6 @@ int av_find_stream_info(AVFormatContext *ic) break; } - if (ret == AVERROR(EAGAIN)) - continue; - pkt= add_to_pktbuf(&ic->packet_buffer, &pkt1, &ic->packet_buffer_end); if ((ret = av_dup_packet(pkt)) < 0) goto find_stream_info_err; From 5dd514af937ff4d74c3c263e4ca428b14b62d5f1 Mon Sep 17 00:00:00 2001 From: Ami Fischman Date: Wed, 29 Jun 2011 13:54:49 -0700 Subject: [PATCH 146/780] matroskadec: forward parsing errors to caller. Signed-off-by: Ronald S. Bultje --- libavformat/matroskadec.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 57a8f624b8..c5f8e673dc 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1623,7 +1623,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, if (size <= 3 || !track || !track->stream) { av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %"PRIu64" or size %u\n", num, size); - return res; + return AVERROR_INVALIDDATA; } st = track->stream; if (st->discard >= AVDISCARD_ALL) @@ -1860,7 +1860,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) res = ebml_parse(matroska, matroska_clusters, &cluster); blocks_list = &cluster.blocks; blocks = blocks_list->elem; - for (i=0; inb_elem; i++) + for (i=0; inb_elem && !res; i++) if (blocks[i].bin.size > 0 && blocks[i].bin.data) { int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1; if (!blocks[i].non_simple) @@ -1879,14 +1879,15 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaDemuxContext *matroska = s->priv_data; + int ret = 0; - while (matroska_deliver_packet(matroska, pkt)) { + while (!ret && matroska_deliver_packet(matroska, pkt)) { if (matroska->done) return AVERROR_EOF; - matroska_parse_cluster(matroska); + ret = matroska_parse_cluster(matroska); } - return 0; + return ret; } static int matroska_read_seek(AVFormatContext *s, int stream_index, From cfa68a3381a7f67eed75bc503e75aab076fad3c6 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 29 Jun 2011 23:38:05 +0100 Subject: [PATCH 147/780] Remove unused, never built libavutil/pca.[ch] Signed-off-by: Mans Rullgard --- libavutil/Makefile | 2 +- libavutil/pca.c | 245 --------------------------------------------- libavutil/pca.h | 35 ------- 3 files changed, 1 insertion(+), 281 deletions(-) delete mode 100644 libavutil/pca.c delete mode 100644 libavutil/pca.h diff --git a/libavutil/Makefile b/libavutil/Makefile index 01344df2a3..c07217b803 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -75,7 +75,7 @@ OBJS-$(ARCH_ARM) += arm/cpu.o OBJS-$(ARCH_PPC) += ppc/cpu.o OBJS-$(ARCH_X86) += x86/cpu.o -TESTPROGS = adler32 aes base64 cpu crc des eval lls md5 pca sha tree +TESTPROGS = adler32 aes base64 cpu crc des eval lls md5 sha tree TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo DIRS = arm bfin sh4 x86 diff --git a/libavutil/pca.c b/libavutil/pca.c deleted file mode 100644 index 56bf707421..0000000000 --- a/libavutil/pca.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - * principal component analysis (PCA) - * Copyright (c) 2004 Michael Niedermayer - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * principal component analysis (PCA) - */ - -#include "common.h" -#include "pca.h" - -typedef struct PCA{ - int count; - int n; - double *covariance; - double *mean; -}PCA; - -PCA *ff_pca_init(int n){ - PCA *pca; - if(n<=0) - return NULL; - - pca= av_mallocz(sizeof(PCA)); - pca->n= n; - pca->count=0; - pca->covariance= av_mallocz(sizeof(double)*n*n); - pca->mean= av_mallocz(sizeof(double)*n); - - return pca; -} - -void ff_pca_free(PCA *pca){ - av_freep(&pca->covariance); - av_freep(&pca->mean); - av_free(pca); -} - -void ff_pca_add(PCA *pca, double *v){ - int i, j; - const int n= pca->n; - - for(i=0; imean[i] += v[i]; - for(j=i; jcovariance[j + i*n] += v[i]*v[j]; - } - pca->count++; -} - -int ff_pca(PCA *pca, double *eigenvector, double *eigenvalue){ - int i, j, pass; - int k=0; - const int n= pca->n; - double z[n]; - - memset(eigenvector, 0, sizeof(double)*n*n); - - for(j=0; jmean[j] /= pca->count; - eigenvector[j + j*n] = 1.0; - for(i=0; i<=j; i++){ - pca->covariance[j + i*n] /= pca->count; - pca->covariance[j + i*n] -= pca->mean[i] * pca->mean[j]; - pca->covariance[i + j*n] = pca->covariance[j + i*n]; - } - eigenvalue[j]= pca->covariance[j + j*n]; - z[j]= 0; - } - - for(pass=0; pass < 50; pass++){ - double sum=0; - - for(i=0; icovariance[j + i*n]); - - if(sum == 0){ - for(i=0; i maxvalue){ - maxvalue= eigenvalue[j]; - k= j; - } - } - eigenvalue[k]= eigenvalue[i]; - eigenvalue[i]= maxvalue; - for(j=0; jcovariance[j + i*n]; - double t,c,s,tau,theta, h; - - if(pass < 3 && fabs(covar) < sum / (5*n*n)) //FIXME why pass < 3 - continue; - if(fabs(covar) == 0.0) //FIXME should not be needed - continue; - if(pass >=3 && fabs((eigenvalue[j]+z[j])/covar) > (1LL<<32) && fabs((eigenvalue[i]+z[i])/covar) > (1LL<<32)){ - pca->covariance[j + i*n]=0.0; - continue; - } - - h= (eigenvalue[j]+z[j]) - (eigenvalue[i]+z[i]); - theta=0.5*h/covar; - t=1.0/(fabs(theta)+sqrt(1.0+theta*theta)); - if(theta < 0.0) t = -t; - - c=1.0/sqrt(1+t*t); - s=t*c; - tau=s/(1.0+c); - z[i] -= t*covar; - z[j] += t*covar; - -#define ROTATE(a,i,j,k,l) {\ - double g=a[j + i*n];\ - double h=a[l + k*n];\ - a[j + i*n]=g-s*(h+g*tau);\ - a[l + k*n]=h+s*(g-h*tau); } - for(k=0; kcovariance,FFMIN(k,i),FFMAX(k,i),FFMIN(k,j),FFMAX(k,j)) - } - ROTATE(eigenvector,k,i,k,j) - } - pca->covariance[j + i*n]=0.0; - } - } - for (i=0; i -#include -#include "lfg.h" - -int main(void){ - PCA *pca; - int i, j, k; -#define LEN 8 - double eigenvector[LEN*LEN]; - double eigenvalue[LEN]; - AVLFG prng; - - av_lfg_init(&prng, 1); - - pca= ff_pca_init(LEN); - - for(i=0; i<9000000; i++){ - double v[2*LEN+100]; - double sum=0; - int pos = av_lfg_get(&prng) % LEN; - int v2 = av_lfg_get(&prng) % 101 - 50; - v[0] = av_lfg_get(&prng) % 101 - 50; - for(j=1; j<8; j++){ - if(j<=pos) v[j]= v[0]; - else v[j]= v2; - sum += v[j]; - } -/* for(j=0; jcount= 1; - pca->mean[i]= 0; - -// (0.5^|x|)^2 = 0.5^2|x| = 0.25^|x| - - -// pca.covariance[i + i*LEN]= pow(0.5, fabs - for(j=i; jcovariance[i + j*LEN]); - } - printf("\n"); - } - - for(i=0; icovariance[FFMIN(k,j) + FFMAX(k,j)*LEN] * eigenvector[i + k*LEN]; - } - v[j] /= eigenvalue[i]; - error += fabs(v[j] - eigenvector[i + j*LEN]); - } - printf("%f ", error); - } - printf("\n"); - - for(i=0; i - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * principal component analysis (PCA) - */ - -#ifndef AVUTIL_PCA_H -#define AVUTIL_PCA_H - -struct PCA *ff_pca_init(int n); -void ff_pca_free(struct PCA *pca); -void ff_pca_add(struct PCA *pca, double *v); -int ff_pca(struct PCA *pca, double *eigenvector, double *eigenvalue); - -#endif /* AVUTIL_PCA_H */ From c562ba4c3d1037eb36cae5b7e93da1282ace9c53 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 8 Jun 2011 19:43:45 +0200 Subject: [PATCH 148/780] configure: Add vdpau and dxva2 to configure results output. --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index ca6a982dfd..9cde17805d 100755 --- a/configure +++ b/configure @@ -3124,6 +3124,9 @@ echo "network support ${network-no}" echo "threading support ${thread_type-no}" echo "SDL support ${sdl-no}" echo "Sun medialib support ${mlib-no}" +echo "libdxva2 enabled ${dxva2-no}" +echo "libva enabled ${vaapi-no}" +echo "libvdpau enabled ${vdpau-no}" echo "AVISynth enabled ${avisynth-no}" echo "frei0r enabled ${frei0r-no}" echo "libdc1394 support ${libdc1394-no}" @@ -3140,7 +3143,6 @@ echo "librtmp enabled ${librtmp-no}" echo "libschroedinger enabled ${libschroedinger-no}" echo "libspeex enabled ${libspeex-no}" echo "libtheora enabled ${libtheora-no}" -echo "libva enabled ${vaapi-no}" echo "libvo-aacenc support ${libvo_aacenc-no}" echo "libvo-amrwbenc support ${libvo_amrwbenc-no}" echo "libvorbis enabled ${libvorbis-no}" From 812f2376eecc19c40a95ade1f7a43b762106e0f7 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 27 Jun 2011 00:29:32 +0200 Subject: [PATCH 149/780] rational-test: Add proper main() declaration to fix gcc warnings. --- libavutil/rational.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavutil/rational.c b/libavutil/rational.c index b2b05cc4ee..ac5111b896 100644 --- a/libavutil/rational.c +++ b/libavutil/rational.c @@ -135,7 +135,8 @@ int av_find_nearest_q_idx(AVRational q, const AVRational* q_list) } #ifdef TEST -main(){ +int main(void) +{ AVRational a,b; for(a.num=-2; a.num<=2; a.num++){ for(a.den=-2; a.den<=2; a.den++){ @@ -151,5 +152,6 @@ main(){ } } } + return 0; } #endif From 623bf96678d2009d34e88ed7c2b73c00930cebae Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 29 Jun 2011 20:02:08 +0200 Subject: [PATCH 150/780] avcodec: increase padding, fixes ticket313 Signed-off-by: Michael Niedermayer --- libavcodec/avcodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 42eabdd623..2345b7e526 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -429,7 +429,7 @@ enum CodecID { * Note: If the first 23 bits of the additional bytes are not 0, then damaged * MPEG bitstreams could cause overread and segfault. */ -#define FF_INPUT_BUFFER_PADDING_SIZE 8 +#define FF_INPUT_BUFFER_PADDING_SIZE 16 /** * minimum encoding buffer size From ce2649af3d012d36d2f70d77867f18270f0e296d Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 29 Jun 2011 14:33:33 -0700 Subject: [PATCH 151/780] aacenc: Make chan_map const correct --- libavcodec/aacenc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h index 3f590fefea..acd185a809 100644 --- a/libavcodec/aacenc.h +++ b/libavcodec/aacenc.h @@ -61,7 +61,7 @@ typedef struct AACEncContext { int16_t *samples; ///< saved preprocessed input int samplerate_index; ///< MPEG-4 samplerate index - uint8_t *chan_map; ///< channel configuration map + const uint8_t *chan_map; ///< channel configuration map ChannelElement *cpe; ///< channel elements FFPsyContext psy; From 45f6ffe5e948f3ed2f136404f8386b03b150b702 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 29 Jun 2011 09:39:43 -0700 Subject: [PATCH 152/780] swscale: implement >8bit scaling support. This means that precision is retained when scaling between sample formats with >8 bits per component (48bit RGB, 16bit grayscale, 9/10/16bit YUV). --- libswscale/ppc/swscale_altivec.c | 4 +- libswscale/swscale.c | 690 ++++++++++++++++++++---------- libswscale/swscale_internal.h | 10 + libswscale/utils.c | 9 +- libswscale/x86/swscale_template.c | 73 +--- tests/ref/lavfi/pixdesc | 16 +- tests/ref/lavfi/pixfmts_copy | 16 +- tests/ref/lavfi/pixfmts_crop | 16 +- tests/ref/lavfi/pixfmts_hflip | 16 +- tests/ref/lavfi/pixfmts_null | 16 +- tests/ref/lavfi/pixfmts_scale | 32 +- tests/ref/lavfi/pixfmts_vflip | 16 +- 12 files changed, 543 insertions(+), 371 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 396b00ccc6..6fb3de0ee7 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -406,7 +406,9 @@ void ff_sws_init_swScale_altivec(SwsContext *c) if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; - c->hScale = hScale_altivec_real; + if (c->scalingBpp == 8) { + c->hScale = hScale_altivec_real; + } if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && dstFormat != PIX_FMT_NV12 && dstFormat != PIX_FMT_NV21 && !c->alpPixBuf) { diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 64ba97e7d4..987afff2d2 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -195,18 +195,18 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={ #endif static av_always_inline void -yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, +yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, - const int16_t **chrUSrc, const int16_t **chrVSrc, - int chrFilterSize, const int16_t **alpSrc, + const int32_t **chrUSrc, const int32_t **chrVSrc, + int chrFilterSize, const int32_t **alpSrc, uint16_t *dest[4], int dstW, int chrDstW, int big_endian, int output_bits) { //FIXME Optimize (just quickly written not optimized..) int i; - int shift = 11 + 16 - output_bits; uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; + int shift = 15 + 16 - output_bits; #define output_pixel(pos, val) \ if (big_endian) { \ @@ -223,7 +223,7 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, } \ } for (i = 0; i < dstW; i++) { - int val = 1 << (26-output_bits); + int val = 1 << (30-output_bits); int j; for (j = 0; j < lumFilterSize; j++) @@ -234,8 +234,8 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, if (uDest) { for (i = 0; i < chrDstW; i++) { - int u = 1 << (26-output_bits); - int v = 1 << (26-output_bits); + int u = 1 << (30-output_bits); + int v = 1 << (30-output_bits); int j; for (j = 0; j < chrFilterSize; j++) { @@ -250,7 +250,7 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, if (CONFIG_SWSCALE_ALPHA && aDest) { for (i = 0; i < dstW; i++) { - int val = 1 << (26-output_bits); + int val = 1 << (30-output_bits); int j; for (j = 0; j < lumFilterSize; j++) @@ -264,12 +264,16 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, #define yuv2NBPS(bits, BE_LE, is_be) \ static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFilter, \ - const int16_t **lumSrc, int lumFilterSize, \ - const int16_t *chrFilter, const int16_t **chrUSrc, \ - const int16_t **chrVSrc, \ - int chrFilterSize, const int16_t **alpSrc, \ + const int16_t **_lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, const int16_t **_chrUSrc, \ + const int16_t **_chrVSrc, \ + int chrFilterSize, const int16_t **_alpSrc, \ uint8_t *_dest[4], int dstW, int chrDstW) \ { \ + const int32_t **lumSrc = (const int32_t **) _lumSrc, \ + **chrUSrc = (const int32_t **) _chrUSrc, \ + **chrVSrc = (const int32_t **) _chrVSrc, \ + **alpSrc = (const int32_t **) _alpSrc; \ yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \ chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ alpSrc, (uint16_t **) _dest, \ @@ -418,109 +422,121 @@ static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, static av_always_inline void yuv2gray16_X_c_template(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, int dstW, + const int32_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int32_t **chrUSrc, + const int32_t **chrVSrc, int chrFilterSize, + const int32_t **alpSrc, uint16_t *dest, int dstW, int y, enum PixelFormat target) { int i; for (i = 0; i < (dstW >> 1); i++) { int j; - int Y1 = 1 << 18; - int Y2 = 1 << 18; - const int i2 = 2 * i; + int Y1 = 1 << 14; + int Y2 = 1 << 14; for (j = 0; j < lumFilterSize; j++) { - Y1 += lumSrc[j][i2] * lumFilter[j]; - Y2 += lumSrc[j][i2+1] * lumFilter[j]; + Y1 += lumSrc[j][i * 2] * lumFilter[j]; + Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j]; } - Y1 >>= 11; - Y2 >>= 11; + Y1 >>= 15; + Y2 >>= 15; if ((Y1 | Y2) & 0x10000) { Y1 = av_clip_uint16(Y1); Y2 = av_clip_uint16(Y2); } - output_pixel(&dest[2 * i2 + 0], Y1); - output_pixel(&dest[2 * i2 + 2], Y2); + output_pixel(&dest[i * 2 + 0], Y1); + output_pixel(&dest[i * 2 + 1], Y2); } } static av_always_inline void -yuv2gray16_2_c_template(SwsContext *c, const int16_t *buf[2], - const int16_t *ubuf[2], const int16_t *vbuf[2], - const int16_t *abuf[2], uint8_t *dest, int dstW, +yuv2gray16_2_c_template(SwsContext *c, const int32_t *buf[2], + const int32_t *ubuf[2], const int32_t *vbuf[2], + const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { int yalpha1 = 4095 - yalpha; int i; - const int16_t *buf0 = buf[0], *buf1 = buf[1]; + const int32_t *buf0 = buf[0], *buf1 = buf[1]; for (i = 0; i < (dstW >> 1); i++) { - const int i2 = 2 * i; - int Y1 = (buf0[i2 ] * yalpha1 + buf1[i2 ] * yalpha) >> 11; - int Y2 = (buf0[i2+1] * yalpha1 + buf1[i2+1] * yalpha) >> 11; + int Y1 = (buf0[i * 2 ] * yalpha1 + buf1[i * 2 ] * yalpha) >> 15; + int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 15; - output_pixel(&dest[2 * i2 + 0], Y1); - output_pixel(&dest[2 * i2 + 2], Y2); + output_pixel(&dest[i * 2 + 0], Y1); + output_pixel(&dest[i * 2 + 1], Y2); } } static av_always_inline void -yuv2gray16_1_c_template(SwsContext *c, const int16_t *buf0, - const int16_t *ubuf[2], const int16_t *vbuf[2], - const int16_t *abuf0, uint8_t *dest, int dstW, +yuv2gray16_1_c_template(SwsContext *c, const int32_t *buf0, + const int32_t *ubuf[2], const int32_t *vbuf[2], + const int32_t *abuf0, uint16_t *dest, int dstW, int uvalpha, int y, enum PixelFormat target) { int i; for (i = 0; i < (dstW >> 1); i++) { - const int i2 = 2 * i; - int Y1 = buf0[i2 ] << 1; - int Y2 = buf0[i2+1] << 1; + int Y1 = buf0[i * 2 ] << 1; + int Y2 = buf0[i * 2 + 1] << 1; - output_pixel(&dest[2 * i2 + 0], Y1); - output_pixel(&dest[2 * i2 + 2], Y2); + output_pixel(&dest[i * 2 + 0], Y1); + output_pixel(&dest[i * 2 + 1], Y2); } } #undef output_pixel -#define YUV2PACKEDWRAPPER(name, base, ext, fmt) \ +#define YUV2PACKED16WRAPPER(name, base, ext, fmt) \ static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ - const int16_t **lumSrc, int lumFilterSize, \ - const int16_t *chrFilter, const int16_t **chrUSrc, \ - const int16_t **chrVSrc, int chrFilterSize, \ - const int16_t **alpSrc, uint8_t *dest, int dstW, \ + const int16_t **_lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, const int16_t **_chrUSrc, \ + const int16_t **_chrVSrc, int chrFilterSize, \ + const int16_t **_alpSrc, uint8_t *_dest, int dstW, \ int y) \ { \ + const int32_t **lumSrc = (const int32_t **) _lumSrc, \ + **chrUSrc = (const int32_t **) _chrUSrc, \ + **chrVSrc = (const int32_t **) _chrVSrc, \ + **alpSrc = (const int32_t **) _alpSrc; \ + uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \ chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ alpSrc, dest, dstW, y, fmt); \ } \ \ -static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \ - const int16_t *ubuf[2], const int16_t *vbuf[2], \ - const int16_t *abuf[2], uint8_t *dest, int dstW, \ +static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \ + const int16_t *_ubuf[2], const int16_t *_vbuf[2], \ + const int16_t *_abuf[2], uint8_t *_dest, int dstW, \ int yalpha, int uvalpha, int y) \ { \ + const int32_t **buf = (const int32_t **) _buf, \ + **ubuf = (const int32_t **) _ubuf, \ + **vbuf = (const int32_t **) _vbuf, \ + **abuf = (const int32_t **) _abuf; \ + uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \ dest, dstW, yalpha, uvalpha, y, fmt); \ } \ \ -static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ - const int16_t *ubuf[2], const int16_t *vbuf[2], \ - const int16_t *abuf0, uint8_t *dest, int dstW, \ +static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \ + const int16_t *_ubuf[2], const int16_t *_vbuf[2], \ + const int16_t *_abuf0, uint8_t *_dest, int dstW, \ int uvalpha, int y) \ { \ + const int32_t *buf0 = (const int32_t *) _buf0, \ + **ubuf = (const int32_t **) _ubuf, \ + **vbuf = (const int32_t **) _vbuf, \ + *abuf0 = (const int32_t *) _abuf0; \ + uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \ dstW, uvalpha, y, fmt); \ } -YUV2PACKEDWRAPPER(yuv2gray16,, LE, PIX_FMT_GRAY16LE); -YUV2PACKEDWRAPPER(yuv2gray16,, BE, PIX_FMT_GRAY16BE); +YUV2PACKED16WRAPPER(yuv2gray16,, LE, PIX_FMT_GRAY16LE); +YUV2PACKED16WRAPPER(yuv2gray16,, BE, PIX_FMT_GRAY16BE); #define output_pixel(pos, acc) \ if (target == PIX_FMT_MONOBLACK) { \ @@ -616,6 +632,38 @@ yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0, #undef output_pixel +#define YUV2PACKEDWRAPPER(name, base, ext, fmt) \ +static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ + const int16_t **lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, const int16_t **chrUSrc, \ + const int16_t **chrVSrc, int chrFilterSize, \ + const int16_t **alpSrc, uint8_t *dest, int dstW, \ + int y) \ +{ \ + name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ + alpSrc, dest, dstW, y, fmt); \ +} \ + \ +static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \ + const int16_t *ubuf[2], const int16_t *vbuf[2], \ + const int16_t *abuf[2], uint8_t *dest, int dstW, \ + int yalpha, int uvalpha, int y) \ +{ \ + name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \ + dest, dstW, yalpha, uvalpha, y, fmt); \ +} \ + \ +static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ + const int16_t *ubuf[2], const int16_t *vbuf[2], \ + const int16_t *abuf0, uint8_t *dest, int dstW, \ + int uvalpha, int y) \ +{ \ + name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \ + abuf0, dest, dstW, uvalpha, \ + y, fmt); \ +} + YUV2PACKEDWRAPPER(yuv2mono,, white, PIX_FMT_MONOWHITE); YUV2PACKEDWRAPPER(yuv2mono,, black, PIX_FMT_MONOBLACK); @@ -731,26 +779,32 @@ yuv2422_1_c_template(SwsContext *c, const int16_t *buf0, YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, PIX_FMT_YUYV422); YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, PIX_FMT_UYVY422); -#define r_b ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? r : b) -#define b_r ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? b : r) +#define R_B ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? R : B) +#define B_R ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? B : R) +#define output_pixel(pos, val) \ + if (isBE(target)) { \ + AV_WB16(pos, val); \ + } else { \ + AV_WL16(pos, val); \ + } static av_always_inline void yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, int dstW, + const int32_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int32_t **chrUSrc, + const int32_t **chrVSrc, int chrFilterSize, + const int32_t **alpSrc, uint16_t *dest, int dstW, int y, enum PixelFormat target) { int i; for (i = 0; i < (dstW >> 1); i++) { int j; - int Y1 = 1 << 18; - int Y2 = 1 << 18; - int U = 1 << 18; - int V = 1 << 18; - const uint8_t *r, *g, *b; + int Y1 = 0; + int Y2 = 0; + int U = -128 << 23; // 19 + int V = -128 << 23; + int R, G, B; for (j = 0; j < lumFilterSize; j++) { Y1 += lumSrc[j][i * 2] * lumFilter[j]; @@ -760,40 +814,45 @@ yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter, U += chrUSrc[j][i] * chrFilter[j]; V += chrVSrc[j][i] * chrFilter[j]; } - Y1 >>= 19; - Y2 >>= 19; - U >>= 19; - V >>= 19; - if ((Y1 | Y2 | U | V) & 0x100) { - Y1 = av_clip_uint8(Y1); - Y2 = av_clip_uint8(Y2); - U = av_clip_uint8(U); - V = av_clip_uint8(V); - } - /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/ - r = (const uint8_t *) c->table_rV[V]; - g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]); - b = (const uint8_t *) c->table_bU[U]; + // 8bit: 12+15=27; 16-bit: 12+19=31 + Y1 >>= 14; // 10 + Y2 >>= 14; + U >>= 14; + V >>= 14; - dest[ 0] = dest[ 1] = r_b[Y1]; - dest[ 2] = dest[ 3] = g[Y1]; - dest[ 4] = dest[ 5] = b_r[Y1]; - dest[ 6] = dest[ 7] = r_b[Y2]; - dest[ 8] = dest[ 9] = g[Y2]; - dest[10] = dest[11] = b_r[Y2]; - dest += 12; + // 8bit: 27 -> 17bit, 16bit: 31 - 14 = 17bit + Y1 -= c->yuv2rgb_y_offset; + Y2 -= c->yuv2rgb_y_offset; + Y1 *= c->yuv2rgb_y_coeff; + Y2 *= c->yuv2rgb_y_coeff; + Y1 += 1 << 13; // 21 + Y2 += 1 << 13; + // 8bit: 17 + 13bit = 30bit, 16bit: 17 + 13bit = 30bit + + R = V * c->yuv2rgb_v2r_coeff; + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; + B = U * c->yuv2rgb_u2b_coeff; + + // 8bit: 30 - 22 = 8bit, 16bit: 30bit - 14 = 16bit + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; } } static av_always_inline void -yuv2rgb48_2_c_template(SwsContext *c, const int16_t *buf[2], - const int16_t *ubuf[2], const int16_t *vbuf[2], - const int16_t *abuf[2], uint8_t *dest, int dstW, +yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2], + const int32_t *ubuf[2], const int32_t *vbuf[2], + const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { - const int16_t *buf0 = buf[0], *buf1 = buf[1], + const int32_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; int yalpha1 = 4095 - yalpha; @@ -801,80 +860,108 @@ yuv2rgb48_2_c_template(SwsContext *c, const int16_t *buf[2], int i; for (i = 0; i < (dstW >> 1); i++) { - int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19; - int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19; - int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19; - int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19; - const uint8_t *r = (const uint8_t *) c->table_rV[V], - *g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]), - *b = (const uint8_t *) c->table_bU[U]; + int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14; + int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14; + int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14; + int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14; + int R, G, B; - dest[ 0] = dest[ 1] = r_b[Y1]; - dest[ 2] = dest[ 3] = g[Y1]; - dest[ 4] = dest[ 5] = b_r[Y1]; - dest[ 6] = dest[ 7] = r_b[Y2]; - dest[ 8] = dest[ 9] = g[Y2]; - dest[10] = dest[11] = b_r[Y2]; - dest += 12; + Y1 -= c->yuv2rgb_y_offset; + Y2 -= c->yuv2rgb_y_offset; + Y1 *= c->yuv2rgb_y_coeff; + Y2 *= c->yuv2rgb_y_coeff; + Y1 += 1 << 13; + Y2 += 1 << 13; + + R = V * c->yuv2rgb_v2r_coeff; + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; + B = U * c->yuv2rgb_u2b_coeff; + + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; } } static av_always_inline void -yuv2rgb48_1_c_template(SwsContext *c, const int16_t *buf0, - const int16_t *ubuf[2], const int16_t *vbuf[2], - const int16_t *abuf0, uint8_t *dest, int dstW, +yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0, + const int32_t *ubuf[2], const int32_t *vbuf[2], + const int32_t *abuf0, uint16_t *dest, int dstW, int uvalpha, int y, enum PixelFormat target) { - const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + const int32_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; int i; if (uvalpha < 2048) { for (i = 0; i < (dstW >> 1); i++) { - int Y1 = buf0[i * 2] >> 7; - int Y2 = buf0[i * 2 + 1] >> 7; - int U = ubuf1[i] >> 7; - int V = vbuf1[i] >> 7; - const uint8_t *r = (const uint8_t *) c->table_rV[V], - *g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]), - *b = (const uint8_t *) c->table_bU[U]; + int Y1 = (buf0[i * 2] ) >> 2; + int Y2 = (buf0[i * 2 + 1]) >> 2; + int U = (ubuf0[i] + (-128 << 11)) >> 2; + int V = (vbuf0[i] + (-128 << 11)) >> 2; + int R, G, B; - dest[ 0] = dest[ 1] = r_b[Y1]; - dest[ 2] = dest[ 3] = g[Y1]; - dest[ 4] = dest[ 5] = b_r[Y1]; - dest[ 6] = dest[ 7] = r_b[Y2]; - dest[ 8] = dest[ 9] = g[Y2]; - dest[10] = dest[11] = b_r[Y2]; - dest += 12; + Y1 -= c->yuv2rgb_y_offset; + Y2 -= c->yuv2rgb_y_offset; + Y1 *= c->yuv2rgb_y_coeff; + Y2 *= c->yuv2rgb_y_coeff; + Y1 += 1 << 13; + Y2 += 1 << 13; + + R = V * c->yuv2rgb_v2r_coeff; + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; + B = U * c->yuv2rgb_u2b_coeff; + + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; } } else { for (i = 0; i < (dstW >> 1); i++) { - int Y1 = buf0[i * 2] >> 7; - int Y2 = buf0[i * 2 + 1] >> 7; - int U = (ubuf0[i] + ubuf1[i]) >> 8; - int V = (vbuf0[i] + vbuf1[i]) >> 8; - const uint8_t *r = (const uint8_t *) c->table_rV[V], - *g = (const uint8_t *)(c->table_gU[U] + c->table_gV[V]), - *b = (const uint8_t *) c->table_bU[U]; + int Y1 = (buf0[i * 2] ) >> 2; + int Y2 = (buf0[i * 2 + 1]) >> 2; + int U = (ubuf0[i] + ubuf1[i] + (-128 << 11)) >> 3; + int V = (vbuf0[i] + vbuf1[i] + (-128 << 11)) >> 3; + int R, G, B; - dest[ 0] = dest[ 1] = r_b[Y1]; - dest[ 2] = dest[ 3] = g[Y1]; - dest[ 4] = dest[ 5] = b_r[Y1]; - dest[ 6] = dest[ 7] = r_b[Y2]; - dest[ 8] = dest[ 9] = g[Y2]; - dest[10] = dest[11] = b_r[Y2]; - dest += 12; + Y1 -= c->yuv2rgb_y_offset; + Y2 -= c->yuv2rgb_y_offset; + Y1 *= c->yuv2rgb_y_coeff; + Y2 *= c->yuv2rgb_y_coeff; + Y1 += 1 << 13; + Y2 += 1 << 13; + + R = V * c->yuv2rgb_v2r_coeff; + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; + B = U * c->yuv2rgb_u2b_coeff; + + output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; } } } +#undef output_pixel #undef r_b #undef b_r -YUV2PACKEDWRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE); -//YUV2PACKEDWRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE); -YUV2PACKEDWRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE); -//YUV2PACKEDWRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE); +YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE); +YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE); +YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE); +YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE); static av_always_inline void yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2, @@ -1025,7 +1112,7 @@ yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter, U = av_clip_uint8(U); V = av_clip_uint8(V); } - if (hasAlpha) {\ + if (hasAlpha) { A1 = 1 << 18; A2 = 1 << 18; for (j = 0; j < lumFilterSize; j++) { @@ -1318,50 +1405,50 @@ static av_always_inline void fillPlane(uint8_t* plane, int stride, #define b ((origin == PIX_FMT_BGR48BE || origin == PIX_FMT_BGR48LE) ? r_b : b_r) static av_always_inline void -rgb48ToY_c_template(uint8_t *dst, const uint8_t *src, int width, +rgb48ToY_c_template(uint16_t *dst, const uint16_t *src, int width, enum PixelFormat origin) { int i; for (i = 0; i < width; i++) { - int r_b = input_pixel(&src[i*6+0]) >> 8; - int g = input_pixel(&src[i*6+2]) >> 8; - int b_r = input_pixel(&src[i*6+4]) >> 8; + unsigned int r_b = input_pixel(&src[i*3+0]); + unsigned int g = input_pixel(&src[i*3+1]); + unsigned int b_r = input_pixel(&src[i*3+2]); - dst[i] = (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + dst[i] = (RY*r + GY*g + BY*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; } } static av_always_inline void -rgb48ToUV_c_template(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, +rgb48ToUV_c_template(uint16_t *dstU, uint16_t *dstV, + const uint16_t *src1, const uint16_t *src2, int width, enum PixelFormat origin) { int i; assert(src1==src2); for (i = 0; i < width; i++) { - int r_b = input_pixel(&src1[i*6+0]) >> 8; - int g = input_pixel(&src1[i*6+2]) >> 8; - int b_r = input_pixel(&src1[i*6+4]) >> 8; + int r_b = input_pixel(&src1[i*3+0]); + int g = input_pixel(&src1[i*3+1]); + int b_r = input_pixel(&src1[i*3+2]); - dstU[i] = (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; - dstV[i] = (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + dstU[i] = (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + dstV[i] = (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; } } static av_always_inline void -rgb48ToUV_half_c_template(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, +rgb48ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV, + const uint16_t *src1, const uint16_t *src2, int width, enum PixelFormat origin) { int i; assert(src1==src2); for (i = 0; i < width; i++) { - int r_b = (input_pixel(&src1[12*i + 0]) >> 8) + (input_pixel(&src1[12*i + 6]) >> 8); - int g = (input_pixel(&src1[12*i + 2]) >> 8) + (input_pixel(&src1[12*i + 8]) >> 8); - int b_r = (input_pixel(&src1[12*i + 4]) >> 8) + (input_pixel(&src1[12*i + 10]) >> 8); + int r_b = (input_pixel(&src1[6 * i + 0]) + input_pixel(&src1[6 * i + 3]) + 1) >> 1; + int g = (input_pixel(&src1[6 * i + 1]) + input_pixel(&src1[6 * i + 4]) + 1) >> 1; + int b_r = (input_pixel(&src1[6 * i + 2]) + input_pixel(&src1[6 * i + 5]) + 1) >> 1; - dstU[i]= (RU*r + GU*g + BU*b + (257<> (RGB2YUV_SHIFT+1); - dstV[i]= (RV*r + GV*g + BV*b + (257<> (RGB2YUV_SHIFT+1); + dstU[i]= (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + dstV[i]= (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; } } @@ -1370,23 +1457,31 @@ rgb48ToUV_half_c_template(uint8_t *dstU, uint8_t *dstV, #undef input_pixel #define rgb48funcs(pattern, BE_LE, origin) \ -static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *dst, const uint8_t *src, \ +static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, \ int width, uint32_t *unused) \ { \ + const uint16_t *src = (const uint16_t *) _src; \ + uint16_t *dst = (uint16_t *) _dst; \ rgb48ToY_c_template(dst, src, width, origin); \ } \ \ -static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \ - const uint8_t *src1, const uint8_t *src2, \ +static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ + const uint8_t *_src1, const uint8_t *_src2, \ int width, uint32_t *unused) \ { \ + const uint16_t *src1 = (const uint16_t *) _src1, \ + *src2 = (const uint16_t *) _src2; \ + uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin); \ } \ \ -static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \ - const uint8_t *src1, const uint8_t *src2, \ +static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \ + const uint8_t *_src1, const uint8_t *_src2, \ int width, uint32_t *unused) \ { \ + const uint16_t *src1 = (const uint16_t *) _src1, \ + *src2 = (const uint16_t *) _src2; \ + uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \ } @@ -1601,13 +1696,26 @@ static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, assert(src1 == src2); } -static void LEToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, - const uint8_t *src2, int width, uint32_t *unused) +static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, int width, uint32_t *unused) { int i; + const uint16_t *src = (const uint16_t *) _src; + uint16_t *dst = (uint16_t *) _dst; for (i=0; i> (depth - 8); - dstV[i] = input_pixel(&srcV[i]) >> (depth - 8); + int upx = input_pixel(&srcU[i]); + int vpx = input_pixel(&srcV[i]); + dstU[i] = (upx << (16 - depth)) | (upx >> (2 * depth - 16)); + dstV[i] = (vpx << (16 - depth)) | (vpx >> (2 * depth - 16)); } } static av_always_inline void -yuv9_or_10ToY_c_template(uint8_t *dstY, const uint8_t *_srcY, +yuv9_or_10ToY_c_template(uint16_t *dstY, const uint16_t *srcY, int width, enum PixelFormat origin, int depth) { int i; - const uint16_t *srcY = (const uint16_t*)_srcY; - for (i = 0; i < width; i++) - dstY[i] = input_pixel(&srcY[i]) >> (depth - 8); + for (i = 0; i < width; i++) { + int px = input_pixel(&srcY[i]); + dstY[i] = (px << (16 - depth)) | (px >> (2 * depth - 16)); + } } #undef input_pixel #define YUV_NBPS(depth, BE_LE, origin) \ -static void BE_LE ## depth ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \ - const uint8_t *srcU, const uint8_t *srcV, \ +static void BE_LE ## depth ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ + const uint8_t *_srcU, const uint8_t *_srcV, \ int width, uint32_t *unused) \ { \ + uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ + const uint16_t *srcU = (const uint16_t *) _srcU, \ + *srcV = (const uint16_t *) _srcV; \ yuv9_OR_10ToUV_c_template(dstU, dstV, srcU, srcV, width, origin, depth); \ } \ -static void BE_LE ## depth ## ToY_c(uint8_t *dstY, const uint8_t *srcY, \ +static void BE_LE ## depth ## ToY_c(uint8_t *_dstY, const uint8_t *_srcY, \ int width, uint32_t *unused) \ { \ + uint16_t *dstY = (uint16_t *) _dstY; \ + const uint16_t *srcY = (const uint16_t *) _srcY; \ yuv9_or_10ToY_c_template(dstY, srcY, width, origin, depth); \ } @@ -1801,6 +1905,27 @@ static void rgb24ToUV_half_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, } } +static void hScale16_c(int16_t *_dst, int dstW, const uint8_t *_src, + const int16_t *filter, + const int16_t *filterPos, int filterSize) +{ + int i; + int32_t *dst = (int32_t *) _dst; + const uint16_t *src = (const uint16_t *) _src; + + for (i = 0; i < dstW; i++) { + int j; + int srcPos = filterPos[i]; + unsigned int val = 0; + + for (j = 0; j < filterSize; j++) { + val += src[srcPos + j] * filter[filterSize * i + j]; + } + // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit + dst[i] = FFMIN(val >> 11, (1 << 19) - 1); + } +} + // bilinear / bicubic scaling static void hScale_c(int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, @@ -1851,6 +1976,41 @@ static void lumRangeFromJpeg_c(int16_t *dst, int width) dst[i] = (dst[i]*14071 + 33561947)>>14; } +static void chrRangeToJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) +{ + int i; + int32_t *dstU = (int32_t *) _dstU; + int32_t *dstV = (int32_t *) _dstV; + for (i = 0; i < width; i++) { + dstU[i] = (FFMIN(dstU[i],30775)*4663 - 9289992)>>12; //-264 + dstV[i] = (FFMIN(dstV[i],30775)*4663 - 9289992)>>12; //-264 + } +} +static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) +{ + int i; + int32_t *dstU = (int32_t *) _dstU; + int32_t *dstV = (int32_t *) _dstV; + for (i = 0; i < width; i++) { + dstU[i] = (dstU[i]*1799 + 4081085)>>11; //1469 + dstV[i] = (dstV[i]*1799 + 4081085)>>11; //1469 + } +} +static void lumRangeToJpeg16_c(int16_t *_dst, int width) +{ + int i; + int32_t *dst = (int32_t *) _dst; + for (i = 0; i < width; i++) + dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14; +} +static void lumRangeFromJpeg16_c(int16_t *_dst, int width) +{ + int i; + int32_t *dst = (int32_t *) _dst; + for (i = 0; i < width; i++) + dst[i] = (dst[i]*14071 + 33561947)>>14; +} + static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc) { @@ -1864,8 +2024,25 @@ static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, } } +static void scale8To16Rv_c(uint16_t *_dst, const uint8_t *src, int len) +{ + int i; + uint8_t *dst = (uint8_t *) _dst; + for (i = len - 1; i >= 0; i--) { + dst[i * 2] = dst[i * 2 + 1] = src[i]; + } +} + +static void scale19To15Fw_c(int16_t *dst, const int32_t *src, int len) +{ + int i; + for (i = 0; i < len; i++) { + dst[i] = src[i] >> 4; + } +} + // *** horizontal scale Y line to temp buffer -static av_always_inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, +static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc, const int16_t *hLumFilter, const int16_t *hLumFilterPos, int hLumFilterSize, @@ -1880,6 +2057,11 @@ static av_always_inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, src= formatConvBuffer; } + if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + c->scale8To16Rv((uint16_t *) formatConvBuffer, src, srcW); + src = formatConvBuffer; + } + if (!c->hyscale_fast) { c->hScale(dst, dstWidth, src, hLumFilter, hLumFilterPos, hLumFilterSize); } else { // fast bilinear upscale / crap downscale @@ -1888,6 +2070,10 @@ static av_always_inline void hyscale(SwsContext *c, uint16_t *dst, int dstWidth, if (convertRange) convertRange(dst, dstWidth); + + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + c->scale19To15Fw(dst, (int32_t *) dst, dstWidth); + } } static void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2, @@ -1905,19 +2091,27 @@ static void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2, } } -static av_always_inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *dst2, int dstWidth, +static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc, const int16_t *hChrFilter, const int16_t *hChrFilterPos, int hChrFilterSize, uint8_t *formatConvBuffer, uint32_t *pal) { if (c->chrToYV12) { - uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW, 16); + uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * c->scalingBpp >> 3, 16); c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); src1= formatConvBuffer; src2= buf2; } + if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + uint8_t *buf2 = (formatConvBuffer + FFALIGN(srcW * 2, 16)); + c->scale8To16Rv((uint16_t *) formatConvBuffer, src1, srcW); + c->scale8To16Rv((uint16_t *) buf2, src2, srcW); + src1 = formatConvBuffer; + src2 = buf2; + } + if (!c->hcscale_fast) { c->hScale(dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize); c->hScale(dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize); @@ -1927,6 +2121,11 @@ static av_always_inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *ds if (c->chrConvertRange) c->chrConvertRange(dst1, dst2, dstWidth); + + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + c->scale19To15Fw(dst1, (int32_t *) dst1, dstWidth); + c->scale19To15Fw(dst2, (int32_t *) dst2, dstWidth); + } } static av_always_inline void @@ -2049,20 +2248,20 @@ find_c_packed_planar_out_funcs(SwsContext *c, *yuv2packedX = yuv2uyvy422_X_c; break; case PIX_FMT_RGB48LE: - //*yuv2packed1 = yuv2rgb48le_1_c; - //*yuv2packed2 = yuv2rgb48le_2_c; - //*yuv2packedX = yuv2rgb48le_X_c; - //break; + *yuv2packed1 = yuv2rgb48le_1_c; + *yuv2packed2 = yuv2rgb48le_2_c; + *yuv2packedX = yuv2rgb48le_X_c; + break; case PIX_FMT_RGB48BE: *yuv2packed1 = yuv2rgb48be_1_c; *yuv2packed2 = yuv2rgb48be_2_c; *yuv2packedX = yuv2rgb48be_X_c; break; case PIX_FMT_BGR48LE: - //*yuv2packed1 = yuv2bgr48le_1_c; - //*yuv2packed2 = yuv2bgr48le_2_c; - //*yuv2packedX = yuv2bgr48le_X_c; - //break; + *yuv2packed1 = yuv2bgr48le_1_c; + *yuv2packed2 = yuv2bgr48le_2_c; + *yuv2packedX = yuv2bgr48le_X_c; + break; case PIX_FMT_BGR48BE: *yuv2packed1 = yuv2bgr48be_1_c; *yuv2packed2 = yuv2bgr48be_2_c; @@ -2435,13 +2634,6 @@ static av_cold void sws_init_swScale_c(SwsContext *c) &c->yuv2packed1, &c->yuv2packed2, &c->yuv2packedX); - c->hScale = hScale_c; - - if (c->flags & SWS_FAST_BILINEAR) { - c->hyscale_fast = hyscale_fast_c; - c->hcscale_fast = hcscale_fast_c; - } - c->chrToYV12 = NULL; switch(srcFormat) { case PIX_FMT_YUYV422 : c->chrToYV12 = yuy2ToUV_c; break; @@ -2453,22 +2645,25 @@ static av_cold void sws_init_swScale_c(SwsContext *c) case PIX_FMT_PAL8 : case PIX_FMT_BGR4_BYTE: case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break; - case PIX_FMT_YUV444P9BE: - case PIX_FMT_YUV420P9BE: c->chrToYV12 = BE9ToUV_c; break; case PIX_FMT_YUV444P9LE: - case PIX_FMT_YUV420P9LE: c->chrToYV12 = LE9ToUV_c; break; - case PIX_FMT_YUV444P10BE: - case PIX_FMT_YUV422P10BE: - case PIX_FMT_YUV420P10BE: c->chrToYV12 = BE10ToUV_c; break; + case PIX_FMT_YUV420P9LE: c->chrToYV12 = LE9ToUV_c; break; case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV444P10LE: case PIX_FMT_YUV420P10LE: c->chrToYV12 = LE10ToUV_c; break; - case PIX_FMT_YUV420P16BE: - case PIX_FMT_YUV422P16BE: - case PIX_FMT_YUV444P16BE: c->chrToYV12 = BEToUV_c; break; + case PIX_FMT_YUV444P9BE: + case PIX_FMT_YUV420P9BE: c->chrToYV12 = BE9ToUV_c; break; + case PIX_FMT_YUV444P10BE: + case PIX_FMT_YUV422P10BE: + case PIX_FMT_YUV420P10BE: c->chrToYV12 = BE10ToUV_c; break; +#if HAVE_BIGENDIAN case PIX_FMT_YUV420P16LE: case PIX_FMT_YUV422P16LE: - case PIX_FMT_YUV444P16LE: c->chrToYV12 = LEToUV_c; break; + case PIX_FMT_YUV444P16LE: c->chrToYV12 = bswap16UV_c; break; +#else + case PIX_FMT_YUV420P16BE: + case PIX_FMT_YUV422P16BE: + case PIX_FMT_YUV444P16BE: c->chrToYV12 = bswap16UV_c; break; +#endif } if (c->chrSrcHSubSample) { switch(srcFormat) { @@ -2517,27 +2712,30 @@ static av_cold void sws_init_swScale_c(SwsContext *c) c->lumToYV12 = NULL; c->alpToYV12 = NULL; switch (srcFormat) { - case PIX_FMT_YUV444P9BE: - case PIX_FMT_YUV420P9BE: c->lumToYV12 = BE9ToY_c; break; case PIX_FMT_YUV444P9LE: - case PIX_FMT_YUV420P9LE: c->lumToYV12 = LE9ToY_c; break; - case PIX_FMT_YUV444P10BE: - case PIX_FMT_YUV422P10BE: - case PIX_FMT_YUV420P10BE: c->lumToYV12 = BE10ToY_c; break; + case PIX_FMT_YUV420P9LE: c->lumToYV12 = LE9ToY_c; break; case PIX_FMT_YUV444P10LE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV420P10LE: c->lumToYV12 = LE10ToY_c; break; - case PIX_FMT_YUYV422 : - case PIX_FMT_YUV420P16BE: - case PIX_FMT_YUV422P16BE: - case PIX_FMT_YUV444P16BE: - case PIX_FMT_Y400A : - case PIX_FMT_GRAY16BE : c->lumToYV12 = yuy2ToY_c; break; - case PIX_FMT_UYVY422 : + case PIX_FMT_YUV444P9BE: + case PIX_FMT_YUV420P9BE: c->lumToYV12 = BE9ToY_c; break; + case PIX_FMT_YUV444P10BE: + case PIX_FMT_YUV422P10BE: + case PIX_FMT_YUV420P10BE: c->lumToYV12 = BE10ToY_c; break; +#if HAVE_BIGENDIAN case PIX_FMT_YUV420P16LE: case PIX_FMT_YUV422P16LE: case PIX_FMT_YUV444P16LE: - case PIX_FMT_GRAY16LE : c->lumToYV12 = uyvyToY_c; break; + case PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break; +#else + case PIX_FMT_YUV420P16BE: + case PIX_FMT_YUV422P16BE: + case PIX_FMT_YUV444P16BE: + case PIX_FMT_GRAY16BE: c->lumToYV12 = bswap16Y_c; break; +#endif + case PIX_FMT_YUYV422 : + case PIX_FMT_Y400A : c->lumToYV12 = yuy2ToY_c; break; + case PIX_FMT_UYVY422 : c->lumToYV12 = uyvyToY_c; break; case PIX_FMT_BGR24 : c->lumToYV12 = bgr24ToY_c; break; case PIX_FMT_BGR565LE : c->lumToYV12 = bgr16leToY_c; break; case PIX_FMT_BGR565BE : c->lumToYV12 = bgr16beToY_c; break; @@ -2574,6 +2772,13 @@ static av_cold void sws_init_swScale_c(SwsContext *c) } } + if (c->scalingBpp == 8) { + c->hScale = hScale_c; + if (c->flags & SWS_FAST_BILINEAR) { + c->hyscale_fast = hyscale_fast_c; + c->hcscale_fast = hcscale_fast_c; + } + if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { if (c->srcRange) { c->lumConvertRange = lumRangeFromJpeg_c; @@ -2583,6 +2788,21 @@ static av_cold void sws_init_swScale_c(SwsContext *c) c->chrConvertRange = chrRangeToJpeg_c; } } + } else { + c->hScale = hScale16_c; + c->scale19To15Fw = scale19To15Fw_c; + c->scale8To16Rv = scale8To16Rv_c; + + if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { + if (c->srcRange) { + c->lumConvertRange = lumRangeFromJpeg16_c; + c->chrConvertRange = chrRangeFromJpeg16_c; + } else { + c->lumConvertRange = lumRangeToJpeg16_c; + c->chrConvertRange = chrRangeToJpeg16_c; + } + } + } if (!(isGray(srcFormat) || isGray(c->dstFormat) || srcFormat == PIX_FMT_MONOBLACK || srcFormat == PIX_FMT_MONOWHITE)) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index c1eed8ac96..cfb19d9c13 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -205,6 +205,7 @@ typedef struct SwsContext { enum PixelFormat srcFormat; ///< Source pixel format. int dstFormatBpp; ///< Number of bits per pixel of the destination pixel format. int srcFormatBpp; ///< Number of bits per pixel of the source pixel format. + int scalingBpp; int chrSrcHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image. int chrSrcVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image. int chrDstHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image. @@ -446,6 +447,15 @@ typedef struct SwsContext { void (*lumConvertRange)(int16_t *dst, int width); ///< Color range conversion function for luma plane if needed. void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width); ///< Color range conversion function for chroma planes if needed. + /** + * dst[..] = (src[..] << 8) | src[..]; + */ + void (*scale8To16Rv)(uint16_t *dst, const uint8_t *src, int len); + /** + * dst[..] = src[..] >> 4; + */ + void (*scale19To15Fw)(int16_t *dst, const int32_t *src, int len); + int needs_hcscale; ///< Set if there are chroma planes to be converted. } SwsContext; diff --git a/libswscale/utils.c b/libswscale/utils.c index 69714183d0..b7ccac94ba 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -877,8 +877,13 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) } } - FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW, 16) * 2, fail); - if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2) { + // FIXME it's even nicer if bpp isn't 16, but max({src,dst}formatbpp) + c->scalingBpp = FFMAX(av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1, + av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1) >= 8 ? 16 : 8; + if (c->scalingBpp == 16) + dst_stride <<= 1; + FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW, 16) * 2 * c->scalingBpp >> 3, fail); + if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2 && c->scalingBpp == 8) { c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0; if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) { if (flags&SWS_PRINT_INFO) diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index de0e4abfe0..54c7edc25e 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -1625,32 +1625,6 @@ static void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, assert(src1 == src2); } -static void RENAME(LEToUV)(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused) -{ - __asm__ volatile( - "mov %0, %%"REG_a" \n\t" - "1: \n\t" - "movq (%1, %%"REG_a",2), %%mm0 \n\t" - "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" - "movq (%2, %%"REG_a",2), %%mm2 \n\t" - "movq 8(%2, %%"REG_a",2), %%mm3 \n\t" - "psrlw $8, %%mm0 \n\t" - "psrlw $8, %%mm1 \n\t" - "psrlw $8, %%mm2 \n\t" - "psrlw $8, %%mm3 \n\t" - "packuswb %%mm1, %%mm0 \n\t" - "packuswb %%mm3, %%mm2 \n\t" - "movq %%mm0, (%3, %%"REG_a") \n\t" - "movq %%mm2, (%4, %%"REG_a") \n\t" - "add $8, %%"REG_a" \n\t" - " js 1b \n\t" - : : "g" ((x86_reg)-width), "r" (src1+width*2), "r" (src2+width*2), "r" (dstU+width), "r" (dstV+width) - : "%"REG_a - ); -} - /* This is almost identical to the previous, end exists only because * yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses. */ static void RENAME(uyvyToY)(uint8_t *dst, const uint8_t *src, @@ -1700,33 +1674,6 @@ static void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, assert(src1 == src2); } -static void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused) -{ - __asm__ volatile( - "movq "MANGLE(bm01010101)", %%mm4 \n\t" - "mov %0, %%"REG_a" \n\t" - "1: \n\t" - "movq (%1, %%"REG_a",2), %%mm0 \n\t" - "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" - "movq (%2, %%"REG_a",2), %%mm2 \n\t" - "movq 8(%2, %%"REG_a",2), %%mm3 \n\t" - "pand %%mm4, %%mm0 \n\t" - "pand %%mm4, %%mm1 \n\t" - "pand %%mm4, %%mm2 \n\t" - "pand %%mm4, %%mm3 \n\t" - "packuswb %%mm1, %%mm0 \n\t" - "packuswb %%mm3, %%mm2 \n\t" - "movq %%mm0, (%3, %%"REG_a") \n\t" - "movq %%mm2, (%4, %%"REG_a") \n\t" - "add $8, %%"REG_a" \n\t" - " js 1b \n\t" - : : "g" ((x86_reg)-width), "r" (src1+width*2), "r" (src2+width*2), "r" (dstU+width), "r" (dstV+width) - : "%"REG_a - ); -} - static av_always_inline void RENAME(nvXXtoUV)(uint8_t *dst1, uint8_t *dst2, const uint8_t *src, int width) { @@ -2268,6 +2215,7 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) } } + if (c->scalingBpp == 8) { #if !COMPILE_TEMPLATE_MMX2 c->hScale = RENAME(hScale ); #endif /* !COMPILE_TEMPLATE_MMX2 */ @@ -2285,6 +2233,7 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) #if COMPILE_TEMPLATE_MMX2 } #endif /* COMPILE_TEMPLATE_MMX2 */ + } #if !COMPILE_TEMPLATE_MMX2 switch(srcFormat) { @@ -2292,12 +2241,6 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) case PIX_FMT_UYVY422 : c->chrToYV12 = RENAME(uyvyToUV); break; case PIX_FMT_NV12 : c->chrToYV12 = RENAME(nv12ToUV); break; case PIX_FMT_NV21 : c->chrToYV12 = RENAME(nv21ToUV); break; - case PIX_FMT_YUV420P16BE: - case PIX_FMT_YUV422P16BE: - case PIX_FMT_YUV444P16BE: c->chrToYV12 = RENAME(BEToUV); break; - case PIX_FMT_YUV420P16LE: - case PIX_FMT_YUV422P16LE: - case PIX_FMT_YUV444P16LE: c->chrToYV12 = RENAME(LEToUV); break; default: break; } #endif /* !COMPILE_TEMPLATE_MMX2 */ @@ -2312,16 +2255,8 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) switch (srcFormat) { #if !COMPILE_TEMPLATE_MMX2 case PIX_FMT_YUYV422 : - case PIX_FMT_YUV420P16BE: - case PIX_FMT_YUV422P16BE: - case PIX_FMT_YUV444P16BE: - case PIX_FMT_Y400A : - case PIX_FMT_GRAY16BE : c->lumToYV12 = RENAME(yuy2ToY); break; - case PIX_FMT_UYVY422 : - case PIX_FMT_YUV420P16LE: - case PIX_FMT_YUV422P16LE: - case PIX_FMT_YUV444P16LE: - case PIX_FMT_GRAY16LE : c->lumToYV12 = RENAME(uyvyToY); break; + case PIX_FMT_Y400A : c->lumToYV12 = RENAME(yuy2ToY); break; + case PIX_FMT_UYVY422 : c->lumToYV12 = RENAME(uyvyToY); break; #endif /* !COMPILE_TEMPLATE_MMX2 */ case PIX_FMT_BGR24 : c->lumToYV12 = RENAME(bgr24ToY); break; case PIX_FMT_RGB24 : c->lumToYV12 = RENAME(rgb24ToY); break; diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc index de13e94cff..8695b1dea2 100644 --- a/tests/ref/lavfi/pixdesc +++ b/tests/ref/lavfi/pixdesc @@ -1,8 +1,8 @@ abgr 037bf9df6a765520ad6d490066bf4b89 argb c442a8261c2265a07212ef0f72e35f5a bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b -bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f -bgr48le d022bfdd6a07d5dcc693799322a386b4 +bgr48be 74dedaaacae8fd1ef46e05f78cf29d62 +bgr48le 0eb7d30801eac6058814bddd330b3c76 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b @@ -18,8 +18,8 @@ monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f rgb24 b41eba9651e1b5fe386289b506188105 -rgb48be 460b6de89b156290a12d3941db8bd731 -rgb48le cd93cb34d15996987367dabda3a10128 +rgb48be e3bc84c9af376fb6d0f0293cc7b713a6 +rgb48le f51c0e71638a822458329abb2f4052c7 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c @@ -38,12 +38,12 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p16be 5499502e1c29534a158a1fe60e889f60 -yuv422p16le e3d61fde6978591596bc36b914386623 +yuv422p16be 86ad3447f97969ce095afeef81fa9abf +yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be ea602a24b8e6969679265078bd8607b6 -yuv444p16le 1262a0dc57ee147967fc896d04206313 +yuv444p16be 95db370ae765dd3d10b7def14704ae73 +yuv444p16le 36b969179b5ad9d312a0d1e1cd6bc402 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index de13e94cff..8695b1dea2 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -1,8 +1,8 @@ abgr 037bf9df6a765520ad6d490066bf4b89 argb c442a8261c2265a07212ef0f72e35f5a bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b -bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f -bgr48le d022bfdd6a07d5dcc693799322a386b4 +bgr48be 74dedaaacae8fd1ef46e05f78cf29d62 +bgr48le 0eb7d30801eac6058814bddd330b3c76 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b @@ -18,8 +18,8 @@ monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f rgb24 b41eba9651e1b5fe386289b506188105 -rgb48be 460b6de89b156290a12d3941db8bd731 -rgb48le cd93cb34d15996987367dabda3a10128 +rgb48be e3bc84c9af376fb6d0f0293cc7b713a6 +rgb48le f51c0e71638a822458329abb2f4052c7 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c @@ -38,12 +38,12 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p16be 5499502e1c29534a158a1fe60e889f60 -yuv422p16le e3d61fde6978591596bc36b914386623 +yuv422p16be 86ad3447f97969ce095afeef81fa9abf +yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be ea602a24b8e6969679265078bd8607b6 -yuv444p16le 1262a0dc57ee147967fc896d04206313 +yuv444p16be 95db370ae765dd3d10b7def14704ae73 +yuv444p16le 36b969179b5ad9d312a0d1e1cd6bc402 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_crop b/tests/ref/lavfi/pixfmts_crop index af42cd3c4a..c7b59527fb 100644 --- a/tests/ref/lavfi/pixfmts_crop +++ b/tests/ref/lavfi/pixfmts_crop @@ -1,8 +1,8 @@ abgr cd761690872843d1b7ab0c695393c751 argb 2ec6ef18769bcd651c2e8904d5a3ee67 bgr24 3450fd00cf1493d1ded75544d82ba3ec -bgr48be 90cb5d373a1123432d63c6a10c101afa -bgr48le 9371f54ceda9010f1199e86f4930ac3f +bgr48be a9a7d177cef0914d3f1d266f00dff676 +bgr48le b475d1b529ed80c728ddbacd22d35281 bgr4_byte 2f6ac3cdd4676ab4e2982bdf0664945b bgr555be d3a7c273604723adeb7e5f5dd1c4272b bgr555le d22442fc13b464f9ba455b08df4e981f @@ -14,8 +14,8 @@ gray 8c4850e66562a587a292dc728a65ea4a gray16be daa5a6b98fb4a280c57c57bff1a2ab5a gray16le 84f5ea7259073edcb893113b42213c8e rgb24 3b90ed64b687d3dc186c6ef521dc71a8 -rgb48be a808128041a1962deaa8620c7448feba -rgb48le ce92d02cc322608d5be377cb1940677b +rgb48be b8f9fd6aaa24d75275ee2f8b8a7b9e55 +rgb48le 3e52e831a040f086c3ae983241172cce rgb4_byte 6958029f73c6cdfed4f71020d816f027 rgb555be 41a7d1836837bc90f2cae19a9c9df3b3 rgb555le eeb78f8ce6186fba55c941469e60ba67 @@ -29,12 +29,12 @@ yuv420p bfea0188ddd4889787c403caae119cc7 yuv420p16be 8365eff38b8c329aeb95fc605fa229bb yuv420p16le 5e8dd38d973d5854abe1ad4efad20cc1 yuv422p f2f930a91fe00d4252c4720b5ecd8961 -yuv422p16be 167e4338811a7d272925a4c6417d60da -yuv422p16le 3359395d5875d581fa1e975013d30114 +yuv422p16be 6647fe1c381c148f8207c988c0e22bf0 +yuv422p16le e1548c9dc51202db38a9625c8954203f yuv440p 2472417d980e395ad6843cbb8b633b29 yuv444p 1f151980486848c96bc5585ced99003e -yuv444p16be d69280c2856865d2ea94bd5292aac1c6 -yuv444p16le 33f43e030bedf9723be4f63c3e9fc80e +yuv444p16be ac3b159f8c858fcdf475a8c024ee79b6 +yuv444p16le 9a6863bfc5faee206065c11dc994bf0c yuva420p 7536753dfbc7932560fb50c921369a0e yuvj420p 21f891093006d42d7683b0e1d773a657 yuvj422p 9a43d474c407590ad8f213880586b45e diff --git a/tests/ref/lavfi/pixfmts_hflip b/tests/ref/lavfi/pixfmts_hflip index 3a3dbf0014..7f4342f35c 100644 --- a/tests/ref/lavfi/pixfmts_hflip +++ b/tests/ref/lavfi/pixfmts_hflip @@ -1,8 +1,8 @@ abgr 49468c6c9ceee5d52b08b1270a909323 argb 50ba9f16c6475530602f2983278b82d0 bgr24 cc53d2011d097972db0d22756c3699e3 -bgr48be 11641cf0f4516a9aed98f7872720f801 -bgr48le b5440734eed128554dd9f83b34ba582f +bgr48be 90374bc92471f1bd4931d71ef8b73f50 +bgr48le 696f628d0dd32121e60a0d61ac47d6e6 bgr4_byte aac987e7d1a6a96477cfc0b48a4285de bgr555be bc07265898440116772200390d70c092 bgr555le ccee08679bac84a1f960c6c9070c5538 @@ -14,8 +14,8 @@ gray 03efcb4ab52a24c0af0e03cfd26c9377 gray16be 9bcbca979601ddc4869f846f08f3d1dd gray16le c1b8965adcc7f847ee343149ff507073 rgb24 754f1722fc738590cc407ac65749bfe8 -rgb48be 10743e1577dc3198dbbc7c0b3b8f429e -rgb48le dd945a44f39119221407bf7a04f1bc49 +rgb48be 2397b9d3c296ac15f8a2325a703f81c7 +rgb48le 527043c72546d8b4bb1ce2dea4b294c3 rgb4_byte c8a3f995fcf3e0919239ea2c413ddc29 rgb555be 045ce8607d3910586f4d97481dda8632 rgb555le 8778ee0cf58ce9ad1d99a1eca9f95e87 @@ -29,12 +29,12 @@ yuv420p 2d5c80f9ba2ddd85b2aeda3564cc7d64 yuv420p16be 758b0c1e2113b15e7afde48da4e4d024 yuv420p16le 480ccd951dcb806bc875d307e02e50a0 yuv422p 6e728f4eb9eae287c224f396d84be6ea -yuv422p16be a05d43cd62b790087bd37083174557de -yuv422p16le 6954abebcbc62d81068d58d0c62bdd5b +yuv422p16be 9dbe0af0eb877987611cf04bfa577202 +yuv422p16le 2d8f37231110177cc5e1b61c8cb4b163 yuv440p a99e2b57ed601f39852715c9d675d0d3 yuv444p 947e47f7bb5fdccc659d19b7df2b6fc3 -yuv444p16be e5ef45bc3d2f5b0b2542d5151340c382 -yuv444p16le 70793e3d66d0c23a0cdedabe9c24c2a7 +yuv444p16be debc96a7ec4fec0a412f9d8995bc48a2 +yuv444p16le 5b5e1348a631fc2206bb7ff851a52687 yuva420p d83ec0c01498189f179ec574918185f1 yuvj420p df3aaaec3bb157c3bde5f0365af30f4f yuvj422p d113871528d510a192797af59df9c05c diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index de13e94cff..8695b1dea2 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -1,8 +1,8 @@ abgr 037bf9df6a765520ad6d490066bf4b89 argb c442a8261c2265a07212ef0f72e35f5a bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b -bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f -bgr48le d022bfdd6a07d5dcc693799322a386b4 +bgr48be 74dedaaacae8fd1ef46e05f78cf29d62 +bgr48le 0eb7d30801eac6058814bddd330b3c76 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b @@ -18,8 +18,8 @@ monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f rgb24 b41eba9651e1b5fe386289b506188105 -rgb48be 460b6de89b156290a12d3941db8bd731 -rgb48le cd93cb34d15996987367dabda3a10128 +rgb48be e3bc84c9af376fb6d0f0293cc7b713a6 +rgb48le f51c0e71638a822458329abb2f4052c7 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c @@ -38,12 +38,12 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p16be 5499502e1c29534a158a1fe60e889f60 -yuv422p16le e3d61fde6978591596bc36b914386623 +yuv422p16be 86ad3447f97969ce095afeef81fa9abf +yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be ea602a24b8e6969679265078bd8607b6 -yuv444p16le 1262a0dc57ee147967fc896d04206313 +yuv444p16be 95db370ae765dd3d10b7def14704ae73 +yuv444p16le 36b969179b5ad9d312a0d1e1cd6bc402 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index 670efe15bb..de41952a21 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -1,8 +1,8 @@ abgr d894cb97f6c80eb21bdbe8a4eea62d86 argb 54346f2b2eef10919e0f247241df3b24 bgr24 570f8d6b51a838aed022ef67535f6bdc -bgr48be fcc0f2dbf45d325f84f816c74cbeeebe -bgr48le 3f9c2b23eed3b8d196d1c14b38ce50f5 +bgr48be 07f7a0cc34feb3646434d47c0cec8cee +bgr48le 9abd2c3a66088e6c9078232064eba61e bgr4_byte ee1d35a7baf8e9016891929a2f565c0b bgr555be de8901c1358834fddea060fcb3a67beb bgr555le 36b745067197f9ca8c1731cac51329c9 @@ -11,15 +11,15 @@ bgr565le 3a514a298c6161a071ddf9963c06509d bgr8 7f007fa6c153a16e808a9c51605a4016 bgra a5e7040f9a80cccd65e5acf2ca09ace5 gray d7786a7d9d99ac74230cc045cab5632c -gray16be af39ce3a497f6734b157c8b94544f537 -gray16le 7ac1b788bcc472010df7a97e762485e0 +gray16be bba98532da29a31599df2feec3b08e3e +gray16le 30267f127d5734c4767f3944f1729a33 monob 88c4c050758e64d120f50c7eff694381 monow d31772ebaa877fc2a78565937f7f9673 nv12 4676d59db43d657dc12841f6bc3ab452 nv21 69c699510ff1fb777b118ebee1002f14 rgb24 514692e28e8ff6860e415ce4fcf6eb8c -rgb48be 1894cd30dabcd3180518e4d5f09f25e7 -rgb48le 1354e6e27ce3c1d4d4989ee56030c94b +rgb48be f18841c19fc6d9c817a3095f557b9bc5 +rgb48le 819e7b8acd8965ba57ba46198a5cc9bf rgb4_byte d81ffd3add95842a618eec81024f0b5c rgb555be 4607309f9f217d51cbb53d13b84b4537 rgb555le a350ef1dc2c9688ed49e7ba018843795 @@ -31,19 +31,19 @@ uyvy422 314bd486277111a95d9369b944fa0400 yuv410p 7df8f6d69b56a8dcb6c7ee908e5018b5 yuv411p 1143e7c5cc28fe0922b051b17733bc4c yuv420p fdad2d8df8985e3d17e73c71f713cb14 -yuv420p10be 6d335e75b553da590135cf8bb999610c -yuv420p10le d510ddbabefd03ef39ec943fcb51b709 -yuv420p16be 29a0265764530070f5cd3251cc01f66a -yuv420p16le 6f3a265b084a78baec229238d9f7945f -yuv420p9be ec4983b7a949c0472110a7a2c58e278a -yuv420p9le c136dce5913a722eee44ab72cff664b2 +yuv420p10be 8b5ad855229840a8fa87786cab83f856 +yuv420p10le 5264e87921d47b17411578d9c92672b1 +yuv420p16be f6ef3ba90f238b467c7e72ade927083d +yuv420p16le faf6aab3b1c16e8afbe160686dd360e0 +yuv420p9be c14bf746d161face61e1f39b491bf7ef +yuv420p9le 59457f9a51768bf1d4342238d50a9be3 yuv422p 918e37701ee7377d16a8a6c119c56a40 -yuv422p16be ef3e865fc1d0c68977c735323c50af6e -yuv422p16le 428a9b96214c09cb5a983ce36d6961ff +yuv422p16be 837945d3a771366a5a72a4ed095a4f53 +yuv422p16le b8292ae9b52eb7afc3d8b93e8fd895b4 yuv440p 461503fdb9b90451020aa3b25ddf041c yuv444p 81b2eba962d12e8d64f003ac56f6faf2 -yuv444p16be 99a3738c70c8fbdc5a0e4ad4bf50648d -yuv444p16le 385d0cc5240d62da0871915be5d86f0a +yuv444p16be cc7460f76477aa4b4c33442f67c06a89 +yuv444p16le 9a5ed60d68c0a4a5155f9d376174cdf7 yuva420p 8673a9131fb47de69788863f93a50eb7 yuvj420p 30427bd6caf5bda93a173dbebe759e09 yuvj422p fc8288f64fd149573f73cf8da05d8e6d diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index 0383ad9c08..89502d1745 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -1,8 +1,8 @@ abgr 25e72e9dbd01ab00727c976d577f7be5 argb 19869bf1a5ac0b6af4d8bbe2c104533c bgr24 89108a4ba00201f79b75b9305c42352d -bgr48be ed82382da09b64a8e04728fcf76e6814 -bgr48le 0f1f135608c2ff24d26d03e939fc2112 +bgr48be 908b4edb525fd154a95a3744c4ab5420 +bgr48le 796c2072d6fa13a091f5c5b175417ed5 bgr4_byte 407fcf564ed764c38e1d748f700ab921 bgr555be f739d2519f7e9d494359bf67a3821537 bgr555le bd7b3ec4d684dfad075d89a606cb8b74 @@ -18,8 +18,8 @@ monow ff9869d067ecb94eb9d90c9750c31fea nv12 046f00f598ce14d9854a3534a5c99114 nv21 01ea369dd2d0d3ed7451dc5c8d61497f rgb24 eaefabc168d0b14576bab45bc1e56e1e -rgb48be 4e0c384163ebab06a08e74637beb02bc -rgb48le a77bfeefcd96750cf0e1917a2e2bf1e7 +rgb48be 8e347deca2902e7dc1ece261322577d8 +rgb48le 2034e485f946e4064b5fb9be09865e55 rgb4_byte 8c6ff02df0b06dd2d574836c3741b2a2 rgb555be 40dc33cfb5cf56aac1c5a290ac486c36 rgb555le 4f8eaad29a17e0f8e9d8ab743e76b999 @@ -38,12 +38,12 @@ yuv420p16le 0f609e588e5a258644ef85170d70e030 yuv420p9be be40ec975fb2873891643cbbbddbc3b0 yuv420p9le 7e606310d3f5ff12badf911e8f333471 yuv422p d7f5cb44d9b0210d66d6a8762640ab34 -yuv422p16be 9bd8f8c961822b586fa4cf992be54acc -yuv422p16le 9c4a1239605c7952b736ac3130163f14 +yuv422p16be 8cdfbddf2dd4c44c3efef4ee00170eba +yuv422p16le a2f421f6a1af950544081c1797de01ae yuv440p 876385e96165acf51271b20e5d85a416 yuv444p 9c3c667d1613b72d15bc6d851c5eb8f7 -yuv444p16be 0f4afa4a4aacf4bb6b87641abde71ea9 -yuv444p16le 8f31557bc52adfe00ae8b40a9b8c23f8 +yuv444p16be b092690d22f0b26360fbf5cfd739be17 +yuv444p16le 18768b4ddca92d06f9713fef467276a9 yuva420p c705d1cf061d8c6580ac690b55f92276 yuvj420p 41fd02b204da0ab62452cd14b595e2e4 yuvj422p 7f6ca9bc1812cde02036d7d29a7cce43 From e0b8fff6c7a293e35079ba1931bd19372686b3f6 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 29 Jun 2011 21:04:45 -0700 Subject: [PATCH 153/780] swscale: fix yuv range correction when using 16-bit scaling. --- libswscale/swscale.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 987afff2d2..644f84858c 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1982,8 +1982,8 @@ static void chrRangeToJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) int32_t *dstU = (int32_t *) _dstU; int32_t *dstV = (int32_t *) _dstV; for (i = 0; i < width; i++) { - dstU[i] = (FFMIN(dstU[i],30775)*4663 - 9289992)>>12; //-264 - dstV[i] = (FFMIN(dstV[i],30775)*4663 - 9289992)>>12; //-264 + dstU[i] = (FFMIN(dstU[i],30775<<4)*4663 - (9289992<<4))>>12; //-264 + dstV[i] = (FFMIN(dstV[i],30775<<4)*4663 - (9289992<<4))>>12; //-264 } } static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) @@ -1992,8 +1992,8 @@ static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) int32_t *dstU = (int32_t *) _dstU; int32_t *dstV = (int32_t *) _dstV; for (i = 0; i < width; i++) { - dstU[i] = (dstU[i]*1799 + 4081085)>>11; //1469 - dstV[i] = (dstV[i]*1799 + 4081085)>>11; //1469 + dstU[i] = (dstU[i]*1799 + (4081085<<4))>>11; //1469 + dstV[i] = (dstV[i]*1799 + (4081085<<4))>>11; //1469 } } static void lumRangeToJpeg16_c(int16_t *_dst, int width) @@ -2001,14 +2001,14 @@ static void lumRangeToJpeg16_c(int16_t *_dst, int width) int i; int32_t *dst = (int32_t *) _dst; for (i = 0; i < width; i++) - dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14; + dst[i] = (FFMIN(dst[i],30189<<4)*19077 - (39057361<<4))>>14; } static void lumRangeFromJpeg16_c(int16_t *_dst, int width) { int i; int32_t *dst = (int32_t *) _dst; for (i = 0; i < width; i++) - dst[i] = (dst[i]*14071 + 33561947)>>14; + dst[i] = (dst[i]*14071 + (33561947<<4))>>14; } static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, From 3713cf11c62df4d993272843c7ef57a1dca3a386 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Thu, 30 Jun 2011 09:02:14 +0200 Subject: [PATCH 154/780] Fix linesize for some rawvideo samples with odd width. --- libavcodec/rawdec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 04aa51edc2..6644d6c7e4 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -192,7 +192,13 @@ static int raw_decode(AVCodecContext *avctx, frame->palette_has_changed = 1; } } - if(avctx->pix_fmt==PIX_FMT_BGR24 && ((frame->linesize[0]+3)&~3)*avctx->height <= buf_size) + if((avctx->pix_fmt==PIX_FMT_BGR24 || + avctx->pix_fmt==PIX_FMT_GRAY8 || + avctx->pix_fmt==PIX_FMT_RGB555LE || + avctx->pix_fmt==PIX_FMT_RGB555BE || + avctx->pix_fmt==PIX_FMT_RGB565LE || + avctx->pix_fmt==PIX_FMT_PAL8) && + ((frame->linesize[0]+3)&~3)*avctx->height <= buf_size) frame->linesize[0] = (frame->linesize[0]+3)&~3; if(context->flip) From f6252b48455dc8aa5413a480bc208ea4ac0c9136 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 29 Jun 2011 19:33:10 +0100 Subject: [PATCH 155/780] adler32: make test program more useful and add fate test Signed-off-by: Mans Rullgard --- libavutil/adler32.c | 22 +++++++++++++++------- tests/fate2.mak | 5 +++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/libavutil/adler32.c b/libavutil/adler32.c index 4f2001025b..ee1f70e479 100644 --- a/libavutil/adler32.c +++ b/libavutil/adler32.c @@ -52,22 +52,30 @@ unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, unsigne } #ifdef TEST +#include #include "log.h" #include "timer.h" #define LEN 7001 volatile int checksum; -int main(void){ +int main(int argc, char **argv) +{ int i; char data[LEN]; av_log_set_level(AV_LOG_DEBUG); for(i=0; i>3) + 123*i; - for(i=0; i<1000; i++){ - START_TIMER - checksum= av_adler32_update(1, data, LEN); - STOP_TIMER("adler") + + if (argc > 1 && !strcmp(argv[1], "-t")) { + for (i = 0; i < 1000; i++) { + START_TIMER; + checksum = av_adler32_update(1, data, LEN); + STOP_TIMER("adler"); + } + } else { + checksum = av_adler32_update(1, data, LEN); } - av_log(NULL, AV_LOG_DEBUG, "%X == 50E6E508\n", checksum); - return 0; + + av_log(NULL, AV_LOG_DEBUG, "%X (expected 50E6E508)\n", checksum); + return checksum == 0x50e6e508? 0 : 1; } #endif diff --git a/tests/fate2.mak b/tests/fate2.mak index f8bae65536..d247dededb 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -217,6 +217,11 @@ FATE_TESTS += fate-sha fate-sha: libavutil/sha-test$(EXESUF) fate-sha: CMD = run libavutil/sha-test +FATE_TESTS += fate-adler32 +fate-adler32: libavutil/adler32-test$(EXESUF) +fate-adler32: CMD = run libavutil/adler32-test +fate-adler32: REF = /dev/null + FATE_TESTS += fate-musepack7 fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff From 744765a9c58107951136a3552f441662f231e91d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 29 Jun 2011 23:27:07 +0100 Subject: [PATCH 156/780] aes: improve test program and add fate test Signed-off-by: Mans Rullgard --- libavutil/aes.c | 54 ++++++++++++++++++++++++++++++------------------- tests/fate2.mak | 5 +++++ 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/libavutil/aes.c b/libavutil/aes.c index 346676bae3..72ddf99a16 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -203,12 +203,14 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) { } #ifdef TEST +#include #include "lfg.h" #include "log.h" -int main(void){ +int main(int argc, char **argv) +{ int i,j; - AVAES ae, ad, b; + AVAES b; uint8_t rkey[2][16]= { {0}, {0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59}}; @@ -219,37 +221,47 @@ int main(void){ {0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7, 0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf}, {0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0, 0x4e, 0xaa, 0x6f, 0xb4, 0xdb, 0xf7, 0x84, 0x65}}; uint8_t temp[16]; - AVLFG prng; + int err = 0; - av_aes_init(&ae, "PI=3.141592654..", 128, 0); - av_aes_init(&ad, "PI=3.141592654..", 128, 1); av_log_set_level(AV_LOG_DEBUG); - av_lfg_init(&prng, 1); for(i=0; i<2; i++){ av_aes_init(&b, rkey[i], 128, 1); av_aes_crypt(&b, temp, rct[i], 1, NULL, 1); for(j=0; j<16; j++) - if(rpt[i][j] != temp[j]) + if(rpt[i][j] != temp[j]) { av_log(NULL, AV_LOG_ERROR, "%d %02X %02X\n", j, rpt[i][j], temp[j]); + err = 1; + } } - for(i=0; i<10000; i++){ - for(j=0; j<16; j++){ - pt[j] = av_lfg_get(&prng); - } -{START_TIMER - av_aes_crypt(&ae, temp, pt, 1, NULL, 0); - if(!(i&(i-1))) - av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", temp[0], temp[5], temp[10], temp[15]); - av_aes_crypt(&ad, temp, temp, 1, NULL, 1); -STOP_TIMER("aes")} - for(j=0; j<16; j++){ - if(pt[j] != temp[j]){ - av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", i,j, pt[j], temp[j]); + if (argc > 1 && !strcmp(argv[1], "-t")) { + AVAES ae, ad; + AVLFG prng; + + av_aes_init(&ae, "PI=3.141592654..", 128, 0); + av_aes_init(&ad, "PI=3.141592654..", 128, 1); + av_lfg_init(&prng, 1); + + for(i=0; i<10000; i++){ + for(j=0; j<16; j++){ + pt[j] = av_lfg_get(&prng); + } + { + START_TIMER; + av_aes_crypt(&ae, temp, pt, 1, NULL, 0); + if(!(i&(i-1))) + av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", temp[0], temp[5], temp[10], temp[15]); + av_aes_crypt(&ad, temp, temp, 1, NULL, 1); + STOP_TIMER("aes"); + } + for(j=0; j<16; j++){ + if(pt[j] != temp[j]){ + av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", i,j, pt[j], temp[j]); + } } } } - return 0; + return err; } #endif diff --git a/tests/fate2.mak b/tests/fate2.mak index d247dededb..ad0309f305 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -222,6 +222,11 @@ fate-adler32: libavutil/adler32-test$(EXESUF) fate-adler32: CMD = run libavutil/adler32-test fate-adler32: REF = /dev/null +FATE_TESTS += fate-aes +fate-aes: libavutil/aes-test$(EXESUF) +fate-aes: CMD = run libavutil/aes-test +fate-aes: REF = /dev/null + FATE_TESTS += fate-musepack7 fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff From 71f029146c963f5bab61bce000839f20bd06549a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 29 Jun 2011 23:34:09 +0100 Subject: [PATCH 157/780] base64: add fate test Signed-off-by: Mans Rullgard --- tests/fate2.mak | 4 ++++ tests/ref/fate/base64 | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 tests/ref/fate/base64 diff --git a/tests/fate2.mak b/tests/fate2.mak index ad0309f305..5603c314dd 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -227,6 +227,10 @@ fate-aes: libavutil/aes-test$(EXESUF) fate-aes: CMD = run libavutil/aes-test fate-aes: REF = /dev/null +FATE_TESTS += fate-base64 +fate-base64: libavutil/base64-test$(EXESUF) +fate-base64: CMD = run libavutil/base64-test + FATE_TESTS += fate-musepack7 fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff diff --git a/tests/ref/fate/base64 b/tests/ref/fate/base64 new file mode 100644 index 0000000000..24fa9ad909 --- /dev/null +++ b/tests/ref/fate/base64 @@ -0,0 +1,9 @@ +Encoding/decoding tests +Passed! +Passed! +Passed! +Passed! +Passed! +Passed! +Passed! +Passed! From 705b21a06ed357ed2b432b967c4fcb09fb992d02 Mon Sep 17 00:00:00 2001 From: Mohamed Naufal Date: Thu, 30 Jun 2011 11:57:32 +0300 Subject: [PATCH 158/780] swscale: Unbreak build with --enable-small MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes building with --enable-small, by using the correct variable name. Signed-off-by: Martin Storsjö --- libswscale/swscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 644f84858c..1e4994ca6b 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -977,7 +977,7 @@ yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2, const uint32_t *b = (const uint32_t *) _b; #if CONFIG_SMALL - int sh = hasAlpha ? ((fmt == PIX_FMT_RGB32_1 || fmt == PIX_FMT_BGR32_1) ? 0 : 24) : 0; + int sh = hasAlpha ? ((target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24) : 0; dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0); dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0); From 5d62d0b114807cc143079a8a0430b86d585ab606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 17 Jun 2011 10:08:23 +0300 Subject: [PATCH 159/780] udp: Fix a compilation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes this compilation warning, by making endptr a non-const pointer, as required by strtol: In function ‘udp_open’: warning: passing argument 2 of ‘strtol’ from incompatible pointer type Signed-off-by: Martin Storsjö --- libavformat/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index 724ff0197d..bd95a811de 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -328,7 +328,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) p = strchr(uri, '?'); if (p) { if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) { - const char *endptr=NULL; + char *endptr = NULL; s->reuse_socket = strtol(buf, &endptr, 10); /* assume if no digits were found it is a request to enable it */ if (buf == endptr) From 5a931a158fbe2ea413dcf28c43c4d6bace3514a1 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 30 Jun 2011 11:09:13 +0200 Subject: [PATCH 160/780] lavu: bump minor and add APIchanges entry for AV_PICTURE_TYPE_NONE The symbols was added in the git commit 512933671409f9f88cc9fdfc8f29525d32240bab. --- doc/APIchanges | 3 +++ libavutil/avutil.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 2fd79b877a..6860b57e2b 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-06-28 - 5129336 - lavu 51.11.0 - avutil.h + Define the AV_PICTURE_TYPE_NONE value in AVPictureType enum. + 2011-06-19 - xxxxxxx - lavfi 2.23.0 - avfilter.h Add layout negotiation fields and helper functions. diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 1b196a916d..568f66b989 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -40,7 +40,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 10 +#define LIBAVUTIL_VERSION_MINOR 11 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From bd9a9a2f1801895c8e69fcb50ce31a35d1938146 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 25 Jun 2011 18:12:36 +0200 Subject: [PATCH 161/780] build: Eliminate obsolete test targets. The targets are now part of FATE and can be run as individual FATE targets. --- Makefile | 2 -- tests/Makefile | 9 +-------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Makefile b/Makefile index da12fba8a4..2cb5f65c6f 100644 --- a/Makefile +++ b/Makefile @@ -185,8 +185,6 @@ distclean:: config: $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION) -check: test checkheaders - include $(SRC_PATH)/doc/Makefile include $(SRC_PATH)/tests/Makefile diff --git a/tests/Makefile b/tests/Makefile index 38d85fbab7..e6640b35dd 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,12 +1,5 @@ -fulltest test: codectest lavftest lavfitest seektest - FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref -codectest: fate-codec -lavftest: fate-lavf -lavfitest: fate-lavfi -seektest: fate-seek - AREF = fate-acodec-aref VREF = fate-vsynth1-vref fate-vsynth2-vref REFS = $(AREF) $(VREF) @@ -120,4 +113,4 @@ testclean: -include $(wildcard tests/*.d) -.PHONY: fate* *test +.PHONY: fate* From ce1e181b1346ee3fc32cd4159e1ebae75fa7d4bb Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 26 Jun 2011 13:50:37 +0200 Subject: [PATCH 162/780] opt-test: Add missing braces to silence compiler warnings. libavutil/opt.c:604:1: warning: missing braces around initializer [-Wmissing-braces] --- libavutil/opt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 518863a8b8..f65f31fcda 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -601,14 +601,14 @@ typedef struct TestContext #define TEST_FLAG_MU 04 static const AVOption test_options[]= { -{"num", "set num", OFFSET(num), FF_OPT_TYPE_INT, 0, 0, 100 }, -{"toggle", "set toggle", OFFSET(toggle), FF_OPT_TYPE_INT, 0, 0, 1 }, -{"rational", "set rational", OFFSET(rational), FF_OPT_TYPE_RATIONAL, 0, 0, 10 }, -{"string", "set string", OFFSET(string), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX }, -{"flags", "set flags", OFFSET(flags), FF_OPT_TYPE_FLAGS, 0, 0, INT_MAX, 0, "flags" }, -{"cool", "set cool flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_COOL, INT_MIN, INT_MAX, 0, "flags" }, -{"lame", "set lame flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_LAME, INT_MIN, INT_MAX, 0, "flags" }, -{"mu", "set mu flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_MU, INT_MIN, INT_MAX, 0, "flags" }, +{"num", "set num", OFFSET(num), FF_OPT_TYPE_INT, {0}, 0, 100 }, +{"toggle", "set toggle", OFFSET(toggle), FF_OPT_TYPE_INT, {0}, 0, 1 }, +{"rational", "set rational", OFFSET(rational), FF_OPT_TYPE_RATIONAL, {0}, 0, 10 }, +{"string", "set string", OFFSET(string), FF_OPT_TYPE_STRING, {0}, CHAR_MIN, CHAR_MAX }, +{"flags", "set flags", OFFSET(flags), FF_OPT_TYPE_FLAGS, {0}, 0, INT_MAX, 0, "flags" }, +{"cool", "set cool flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_COOL}, INT_MIN, INT_MAX, 0, "flags" }, +{"lame", "set lame flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" }, +{"mu", "set mu flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" }, {NULL}, }; From c31bc5371e1b261f487a8795e8f57eb88290cd06 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 30 Jun 2011 14:03:54 +0100 Subject: [PATCH 163/780] Fix cpu flags test program Signed-off-by: Mans Rullgard --- libavutil/cpu.c | 55 ++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/libavutil/cpu.c b/libavutil/cpu.c index ddccd000bc..baa7922daa 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -39,32 +39,45 @@ int av_get_cpu_flags(void) #undef printf #include +static const struct { + int flag; + const char *name; +} cpu_flag_tab[] = { +#if ARCH_ARM + { AV_CPU_FLAG_IWMMXT, "iwmmxt" }, +#elif ARCH_PPC + { AV_CPU_FLAG_ALTIVEC, "altivec" }, +#elif ARCH_X86 + { AV_CPU_FLAG_MMX, "mmx" }, + { AV_CPU_FLAG_MMX2, "mmx2" }, + { AV_CPU_FLAG_SSE, "sse" }, + { AV_CPU_FLAG_SSE2, "sse2" }, + { AV_CPU_FLAG_SSE2SLOW, "sse2(slow)" }, + { AV_CPU_FLAG_SSE3, "sse3" }, + { AV_CPU_FLAG_SSE3SLOW, "sse3(slow)" }, + { AV_CPU_FLAG_SSSE3, "ssse3" }, + { AV_CPU_FLAG_ATOM, "atom" }, + { AV_CPU_FLAG_SSE4, "sse4.1" }, + { AV_CPU_FLAG_SSE42, "sse4.2" }, + { AV_CPU_FLAG_AVX, "avx" }, + { AV_CPU_FLAG_3DNOW, "3dnow" }, + { AV_CPU_FLAG_3DNOWEXT, "3dnowext" }, +#endif + { 0 } +}; + int main(void) { int cpu_flags = av_get_cpu_flags(); + int i; printf("cpu_flags = 0x%08X\n", cpu_flags); - printf("cpu_flags = %s%s%s%s%s%s%s%s%s%s%s%s%s\n", -#if ARCH_ARM - cpu_flags & AV_CPU_FLAG_IWMMXT ? "IWMMXT " : "", -#elif ARCH_PPC - cpu_flags & AV_CPU_FLAG_ALTIVEC ? "ALTIVEC " : "", -#elif ARCH_X86 - cpu_flags & AV_CPU_FLAG_MMX ? "MMX " : "", - cpu_flags & AV_CPU_FLAG_MMX2 ? "MMX2 " : "", - cpu_flags & AV_CPU_FLAG_SSE ? "SSE " : "", - cpu_flags & AV_CPU_FLAG_SSE2 ? "SSE2 " : "", - cpu_flags & AV_CPU_FLAG_SSE2SLOW ? "SSE2(slow) " : "", - cpu_flags & AV_CPU_FLAG_SSE3 ? "SSE3 " : "", - cpu_flags & AV_CPU_FLAG_SSE3SLOW ? "SSE3(slow) " : "", - cpu_flags & AV_CPU_FLAG_SSSE3 ? "SSSE3 " : "", - cpu_flags & AV_CPU_FLAG_ATOM ? "Atom " : "", - cpu_flags & AV_CPU_FLAG_SSE4 ? "SSE4.1 " : "", - cpu_flags & AV_CPU_FLAG_SSE42 ? "SSE4.2 " : "", - cpu_flags & AV_CPU_FLAG_AVX ? "AVX " : "", - cpu_flags & AV_CPU_FLAG_3DNOW ? "3DNow " : "", - cpu_flags & AV_CPU_FLAG_3DNOWEXT ? "3DNowExt " : ""); -#endif + printf("cpu_flags ="); + for (i = 0; cpu_flag_tab[i].flag; i++) + if (cpu_flags & cpu_flag_tab[i].flag) + printf(" %s", cpu_flag_tab[i].name); + printf("\n"); + return 0; } From 81cc7d0bd1eab0aa782ff8dd49e087025a42cdee Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 30 Jun 2011 07:05:52 -0700 Subject: [PATCH 164/780] swscale: fix another yuv range conversion overflow in 16bit scaling. --- libswscale/swscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 1e4994ca6b..ef8fc39c48 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2001,7 +2001,7 @@ static void lumRangeToJpeg16_c(int16_t *_dst, int width) int i; int32_t *dst = (int32_t *) _dst; for (i = 0; i < width; i++) - dst[i] = (FFMIN(dst[i],30189<<4)*19077 - (39057361<<4))>>14; + dst[i] = (FFMIN(dst[i],30189<<4)*4769 - (39057361<<2))>>12; } static void lumRangeFromJpeg16_c(int16_t *_dst, int width) { From a09918335f1305e2d6bf6a9b0001ac5f167c1aea Mon Sep 17 00:00:00 2001 From: Jeff Downs Date: Wed, 29 Jun 2011 12:38:46 -0400 Subject: [PATCH 165/780] Make all option parsing functions match the function pointer type through which they are called. All option parsing functions now match the function pointer signature through which they are called (int f(const char *, const char *), thereby working reliably on all platforms. Prefix all option processing functions with opt_ --- cmdutils.c | 24 ++++++++++++++++-------- cmdutils.h | 26 +++++++++++++++++--------- cmdutils_common_opts.h | 24 ++++++++++++------------ ffmpeg.c | 14 +++++++++----- ffplay.c | 5 +++-- ffprobe.c | 3 ++- ffserver.c | 3 ++- 7 files changed, 61 insertions(+), 38 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index f538d98f14..a3f643bff6 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -574,12 +574,13 @@ void show_banner(void) print_all_libs_info(stderr, INDENT|SHOW_VERSION); } -void show_version(void) { +int opt_version(const char *opt, const char *arg) { printf("%s " FFMPEG_VERSION "\n", program_name); print_all_libs_info(stdout, SHOW_VERSION); + return 0; } -void show_license(void) +int opt_license(const char *opt, const char *arg) { printf( #if CONFIG_NONFREE @@ -646,9 +647,10 @@ void show_license(void) program_name, program_name, program_name #endif ); + return 0; } -void show_formats(void) +int opt_formats(const char *opt, const char *arg) { AVInputFormat *ifmt=NULL; AVOutputFormat *ofmt=NULL; @@ -695,9 +697,10 @@ void show_formats(void) name, long_name ? long_name:" "); } + return 0; } -void show_codecs(void) +int opt_codecs(const char *opt, const char *arg) { AVCodec *p=NULL, *p2; const char *last_name; @@ -771,9 +774,10 @@ void show_codecs(void) "even though both encoding and decoding are supported. For example, the h263\n" "decoder corresponds to the h263 and h263p encoders, for file formats it is even\n" "worse.\n"); + return 0; } -void show_bsfs(void) +int opt_bsfs(const char *opt, const char *arg) { AVBitStreamFilter *bsf=NULL; @@ -781,9 +785,10 @@ void show_bsfs(void) while((bsf = av_bitstream_filter_next(bsf))) printf("%s\n", bsf->name); printf("\n"); + return 0; } -void show_protocols(void) +int opt_protocols(const char *opt, const char *arg) { URLProtocol *up=NULL; @@ -799,9 +804,10 @@ void show_protocols(void) up->url_write ? 'O' : '.', up->url_seek ? 'S' : '.', up->name); + return 0; } -void show_filters(void) +int opt_filters(const char *opt, const char *arg) { AVFilter av_unused(**filter) = NULL; @@ -810,9 +816,10 @@ void show_filters(void) while ((filter = av_filter_next(filter)) && *filter) printf("%-16s %s\n", (*filter)->name, (*filter)->description); #endif + return 0; } -void show_pix_fmts(void) +int opt_pix_fmts(const char *opt, const char *arg) { enum PixelFormat pix_fmt; @@ -843,6 +850,7 @@ void show_pix_fmts(void) pix_desc->nb_components, av_get_bits_per_pixel(pix_desc)); } + return 0; } int read_yesno(void) diff --git a/cmdutils.h b/cmdutils.h index e001ab9201..b05828cd0a 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -62,7 +62,7 @@ void uninit_opts(void); /** * Trivial log callback. - * Only suitable for show_help and similar since it lacks prefix handling. + * Only suitable for opt_help and similar since it lacks prefix handling. */ void log_callback_help(void* ptr, int level, const char* fmt, va_list vl); @@ -177,50 +177,58 @@ void show_banner(void); * Print the version of the program to stdout. The version message * depends on the current versions of the repository and of the libav* * libraries. + * This option processing function does not utilize the arguments. */ -void show_version(void); +int opt_version(const char *opt, const char *arg); /** * Print the license of the program to stdout. The license depends on * the license of the libraries compiled into the program. + * This option processing function does not utilize the arguments. */ -void show_license(void); +int opt_license(const char *opt, const char *arg); /** * Print a listing containing all the formats supported by the * program. + * This option processing function does not utilize the arguments. */ -void show_formats(void); +int opt_formats(const char *opt, const char *arg); /** * Print a listing containing all the codecs supported by the * program. + * This option processing function does not utilize the arguments. */ -void show_codecs(void); +int opt_codecs(const char *opt, const char *arg); /** * Print a listing containing all the filters supported by the * program. + * This option processing function does not utilize the arguments. */ -void show_filters(void); +int opt_filters(const char *opt, const char *arg); /** * Print a listing containing all the bit stream filters supported by the * program. + * This option processing function does not utilize the arguments. */ -void show_bsfs(void); +int opt_bsfs(const char *opt, const char *arg); /** * Print a listing containing all the protocols supported by the * program. + * This option processing function does not utilize the arguments. */ -void show_protocols(void); +int opt_protocols(const char *opt, const char *arg); /** * Print a listing containing all the pixel formats supported by the * program. + * This option processing function does not utilize the arguments. */ -void show_pix_fmts(void); +int opt_pix_fmts(const char *opt, const char *arg); /** * Return a positive value if a line read from standard input diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h index 9b5e5d22cd..8e680490fe 100644 --- a/cmdutils_common_opts.h +++ b/cmdutils_common_opts.h @@ -1,13 +1,13 @@ - { "L", OPT_EXIT, {(void*)show_license}, "show license" }, - { "h", OPT_EXIT, {(void*)show_help}, "show help" }, - { "?", OPT_EXIT, {(void*)show_help}, "show help" }, - { "help", OPT_EXIT, {(void*)show_help}, "show help" }, - { "-help", OPT_EXIT, {(void*)show_help}, "show help" }, - { "version", OPT_EXIT, {(void*)show_version}, "show version" }, - { "formats" , OPT_EXIT, {(void*)show_formats }, "show available formats" }, - { "codecs" , OPT_EXIT, {(void*)show_codecs }, "show available codecs" }, - { "bsfs" , OPT_EXIT, {(void*)show_bsfs }, "show available bit stream filters" }, - { "protocols", OPT_EXIT, {(void*)show_protocols}, "show available protocols" }, - { "filters", OPT_EXIT, {(void*)show_filters }, "show available filters" }, - { "pix_fmts" , OPT_EXIT, {(void*)show_pix_fmts }, "show available pixel formats" }, + { "L", OPT_EXIT, {(void*)opt_license}, "show license" }, + { "h", OPT_EXIT, {(void*)opt_help}, "show help" }, + { "?", OPT_EXIT, {(void*)opt_help}, "show help" }, + { "help", OPT_EXIT, {(void*)opt_help}, "show help" }, + { "-help", OPT_EXIT, {(void*)opt_help}, "show help" }, + { "version", OPT_EXIT, {(void*)opt_version}, "show version" }, + { "formats" , OPT_EXIT, {(void*)opt_formats }, "show available formats" }, + { "codecs" , OPT_EXIT, {(void*)opt_codecs }, "show available codecs" }, + { "bsfs" , OPT_EXIT, {(void*)opt_bsfs }, "show available bit stream filters" }, + { "protocols", OPT_EXIT, {(void*)opt_protocols}, "show available protocols" }, + { "filters", OPT_EXIT, {(void*)opt_filters }, "show available filters" }, + { "pix_fmts" , OPT_EXIT, {(void*)opt_pix_fmts }, "show available pixel formats" }, { "loglevel", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" }, diff --git a/ffmpeg.c b/ffmpeg.c index 295d71044f..bd595348f3 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2943,7 +2943,7 @@ static int opt_frame_pix_fmt(const char *opt, const char *arg) return AVERROR(EINVAL); } } else { - show_pix_fmts(); + opt_pix_fmts(NULL, NULL); ffmpeg_exit(0); } return 0; @@ -4073,16 +4073,18 @@ static void parse_matrix_coeffs(uint16_t *dest, const char *str) } } -static void opt_inter_matrix(const char *opt, const char *arg) +static int opt_inter_matrix(const char *opt, const char *arg) { inter_matrix = av_mallocz(sizeof(uint16_t) * 64); parse_matrix_coeffs(inter_matrix, arg); + return 0; } -static void opt_intra_matrix(const char *opt, const char *arg) +static int opt_intra_matrix(const char *opt, const char *arg) { intra_matrix = av_mallocz(sizeof(uint16_t) * 64); parse_matrix_coeffs(intra_matrix, arg); + return 0; } static void show_usage(void) @@ -4092,7 +4094,7 @@ static void show_usage(void) printf("\n"); } -static void show_help(void) +static int opt_help(const char *opt, const char *arg) { AVCodec *c; AVOutputFormat *oformat = NULL; @@ -4147,6 +4149,7 @@ static void show_help(void) } av_opt_show2(sws_opts, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); + return 0; } static int opt_target(const char *opt, const char *arg) @@ -4377,10 +4380,11 @@ static void log_callback_null(void* ptr, int level, const char* fmt, va_list vl) { } -static void opt_passlogfile(const char *opt, const char *arg) +static int opt_passlogfile(const char *opt, const char *arg) { pass_logfilename_prefix = arg; opt_default("passlogfile", arg); + return 0; } static const OptionDef options[] = { diff --git a/ffplay.c b/ffplay.c index 8788771491..599b288529 100644 --- a/ffplay.c +++ b/ffplay.c @@ -212,7 +212,7 @@ typedef struct VideoState { int refresh; } VideoState; -static void show_help(void); +static int opt_help(const char *opt, const char *arg); /* options specified by the user */ static AVInputFormat *file_iformat; @@ -2950,7 +2950,7 @@ static void show_usage(void) printf("\n"); } -static void show_help(void) +static int opt_help(const char *opt, const char *arg) { av_log_set_callback(log_callback_help); show_usage(); @@ -2982,6 +2982,7 @@ static void show_help(void) "down/up seek backward/forward 1 minute\n" "mouse click seek to percentage in file corresponding to fraction of width\n" ); + return 0; } /* Called from the main */ diff --git a/ffprobe.c b/ffprobe.c index a2b27c3745..fdcdf70273 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -353,7 +353,7 @@ static int opt_input_file(const char *opt, const char *arg) return 0; } -static void show_help(void) +static int opt_help(const char *opt, const char *arg) { av_log_set_callback(log_callback_help); show_usage(); @@ -361,6 +361,7 @@ static void show_help(void) printf("\n"); av_opt_show2(avformat_opts, NULL, AV_OPT_FLAG_DECODING_PARAM, 0); + return 0; } static void opt_pretty(void) diff --git a/ffserver.c b/ffserver.c index 15ea00f4f8..83dd986dc2 100644 --- a/ffserver.c +++ b/ffserver.c @@ -4654,12 +4654,13 @@ static void opt_debug(void) logfilename[0] = '-'; } -static void show_help(void) +static int opt_help(const char *opt, const char *arg) { printf("usage: ffserver [options]\n" "Hyper fast multi format Audio/Video streaming server\n"); printf("\n"); show_help_options(options, "Main options:\n", 0, 0); + return 0; } static const OptionDef options[] = { From bd55da1c08b5d560db357f0023dadf38d8c0cf7d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 30 Jun 2011 10:15:10 +0100 Subject: [PATCH 166/780] adler32: whitespace cosmetics Signed-off-by: Mans Rullgard --- libavutil/adler32.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/libavutil/adler32.c b/libavutil/adler32.c index ee1f70e479..9d3d896506 100644 --- a/libavutil/adler32.c +++ b/libavutil/adler32.c @@ -26,24 +26,28 @@ #define BASE 65521L /* largest prime smaller than 65536 */ -#define DO1(buf) {s1 += *buf++; s2 += s1;} +#define DO1(buf) { s1 += *buf++; s2 += s1; } #define DO4(buf) DO1(buf); DO1(buf); DO1(buf); DO1(buf); #define DO16(buf) DO4(buf); DO4(buf); DO4(buf); DO4(buf); -unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, unsigned int len) +unsigned long av_adler32_update(unsigned long adler, const uint8_t * buf, + unsigned int len) { unsigned long s1 = adler & 0xffff; unsigned long s2 = adler >> 16; - while (len>0) { + while (len > 0) { #if CONFIG_SMALL - while(len>4 && s2 < (1U<<31)){ - DO4(buf); len-=4; -#else - while(len>16 && s2 < (1U<<31)){ - DO16(buf); len-=16; -#endif + while (len > 4 && s2 < (1U << 31)) { + DO4(buf); + len -= 4; } +#else + while (len > 16 && s2 < (1U << 31)) { + DO16(buf); + len -= 16; + } +#endif DO1(buf); len--; s1 %= BASE; s2 %= BASE; @@ -61,9 +65,11 @@ int main(int argc, char **argv) { int i; char data[LEN]; + av_log_set_level(AV_LOG_DEBUG); - for(i=0; i>3) + 123*i; + + for (i = 0; i < LEN; i++) + data[i] = ((i * i) >> 3) + 123 * i; if (argc > 1 && !strcmp(argv[1], "-t")) { for (i = 0; i < 1000; i++) { @@ -76,6 +82,6 @@ int main(int argc, char **argv) } av_log(NULL, AV_LOG_DEBUG, "%X (expected 50E6E508)\n", checksum); - return checksum == 0x50e6e508? 0 : 1; + return checksum == 0x50e6e508 ? 0 : 1; } #endif From 4bfe0644606264c2c81ccc8b044ca46e52e7b24a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 30 Jun 2011 12:29:25 +0100 Subject: [PATCH 167/780] aes: whitespace cosmetics Signed-off-by: Mans Rullgard --- libavutil/aes.c | 219 +++++++++++++++++++++++++++++------------------- 1 file changed, 132 insertions(+), 87 deletions(-) diff --git a/libavutil/aes.c b/libavutil/aes.c index 72ddf99a16..fc6c4168cd 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -30,13 +30,13 @@ typedef union { uint8_t u8[16]; } av_aes_block; -typedef struct AVAES{ +typedef struct AVAES { // Note: round_key[16] is accessed in the init code, but this only // overwrites state, which does not matter (see also r7471). av_aes_block round_key[15]; av_aes_block state[2]; int rounds; -}AVAES; +} AVAES; const int av_aes_size= sizeof(AVAES); @@ -54,18 +54,34 @@ static uint32_t enc_multbl[4][256]; static uint32_t dec_multbl[4][256]; #endif -static inline void addkey(av_aes_block *dst, const av_aes_block *src, const av_aes_block *round_key){ +static inline void addkey(av_aes_block *dst, const av_aes_block *src, + const av_aes_block *round_key) +{ dst->u64[0] = src->u64[0] ^ round_key->u64[0]; dst->u64[1] = src->u64[1] ^ round_key->u64[1]; } -static void subshift(av_aes_block s0[2], int s, const uint8_t *box){ - av_aes_block *s1= (av_aes_block *)(s0[0].u8 - s); - av_aes_block *s3= (av_aes_block *)(s0[0].u8 + s); - s0[0].u8[0]=box[s0[1].u8[ 0]]; s0[0].u8[ 4]=box[s0[1].u8[ 4]]; s0[0].u8[ 8]=box[s0[1].u8[ 8]]; s0[0].u8[12]=box[s0[1].u8[12]]; - s1[0].u8[3]=box[s1[1].u8[ 7]]; s1[0].u8[ 7]=box[s1[1].u8[11]]; s1[0].u8[11]=box[s1[1].u8[15]]; s1[0].u8[15]=box[s1[1].u8[ 3]]; - s0[0].u8[2]=box[s0[1].u8[10]]; s0[0].u8[10]=box[s0[1].u8[ 2]]; s0[0].u8[ 6]=box[s0[1].u8[14]]; s0[0].u8[14]=box[s0[1].u8[ 6]]; - s3[0].u8[1]=box[s3[1].u8[13]]; s3[0].u8[13]=box[s3[1].u8[ 9]]; s3[0].u8[ 9]=box[s3[1].u8[ 5]]; s3[0].u8[ 5]=box[s3[1].u8[ 1]]; +static void subshift(av_aes_block s0[2], int s, const uint8_t *box) +{ + av_aes_block *s1 = (av_aes_block *) (s0[0].u8 - s); + av_aes_block *s3 = (av_aes_block *) (s0[0].u8 + s); + + s0[0].u8[ 0] = box[s0[1].u8[ 0]]; + s0[0].u8[ 4] = box[s0[1].u8[ 4]]; + s0[0].u8[ 8] = box[s0[1].u8[ 8]]; + s0[0].u8[12] = box[s0[1].u8[12]]; + s1[0].u8[ 3] = box[s1[1].u8[ 7]]; + s1[0].u8[ 7] = box[s1[1].u8[11]]; + s1[0].u8[11] = box[s1[1].u8[15]]; + s1[0].u8[15] = box[s1[1].u8[ 3]]; + s0[0].u8[ 2] = box[s0[1].u8[10]]; + s0[0].u8[10] = box[s0[1].u8[ 2]]; + s0[0].u8[ 6] = box[s0[1].u8[14]]; + s0[0].u8[14] = box[s0[1].u8[ 6]]; + s3[0].u8[ 1] = box[s3[1].u8[13]]; + s3[0].u8[13] = box[s3[1].u8[ 9]]; + s3[0].u8[ 9] = box[s3[1].u8[ 5]]; + s3[0].u8[ 5] = box[s3[1].u8[ 1]]; } static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){ @@ -85,116 +101,134 @@ static inline void mix(av_aes_block state[2], uint32_t multbl[][256], int s1, in state[0].u32[3] = mix_core(multbl, src[3][0], src[s1-1][1], src[1][2], src[s3-1][3]); } -static inline void crypt(AVAES *a, int s, const uint8_t *sbox, uint32_t multbl[][256]){ +static inline void crypt(AVAES *a, int s, const uint8_t *sbox, + uint32_t multbl[][256]) +{ int r; - for(r=a->rounds-1; r>0; r--){ - mix(a->state, multbl, 3-s, 1+s); + for (r = a->rounds - 1; r > 0; r--) { + mix(a->state, multbl, 3 - s, 1 + s); addkey(&a->state[1], &a->state[0], &a->round_key[r]); } + subshift(&a->state[0], s, sbox); } -void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_, int count, uint8_t *iv_, int decrypt){ - av_aes_block *dst = (av_aes_block *)dst_; - const av_aes_block *src = (const av_aes_block *)src_; - av_aes_block *iv = (av_aes_block *)iv_; - while(count--){ +void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_, + int count, uint8_t *iv_, int decrypt) +{ + av_aes_block *dst = (av_aes_block *) dst_; + const av_aes_block *src = (const av_aes_block *) src_; + av_aes_block *iv = (av_aes_block *) iv_; + + while (count--) { addkey(&a->state[1], src, &a->round_key[a->rounds]); - if(decrypt) { + if (decrypt) { crypt(a, 0, inv_sbox, dec_multbl); - if(iv){ + if (iv) { addkey(&a->state[0], &a->state[0], iv); memcpy(iv, src, 16); } addkey(dst, &a->state[0], &a->round_key[0]); - }else{ - if(iv) addkey(&a->state[1], &a->state[1], iv); - crypt(a, 2, sbox, enc_multbl); + } else { + if (iv) + addkey(&a->state[1], &a->state[1], iv); + crypt(a, 2, sbox, enc_multbl); addkey(dst, &a->state[0], &a->round_key[0]); - if(iv) memcpy(iv, dst, 16); + if (iv) + memcpy(iv, dst, 16); } src++; dst++; } } -static void init_multbl2(uint8_t tbl[1024], const int c[4], const uint8_t *log8, const uint8_t *alog8, const uint8_t *sbox){ +static void init_multbl2(uint8_t tbl[1024], const int c[4], + const uint8_t *log8, const uint8_t *alog8, + const uint8_t *sbox) +{ int i, j; - for(i=0; i<1024; i++){ - int x= sbox[i>>2]; - if(x) tbl[i]= alog8[ log8[x] + log8[c[i&3]] ]; + + for (i = 0; i < 1024; i++) { + int x = sbox[i >> 2]; + if (x) + tbl[i] = alog8[log8[x] + log8[c[i & 3]]]; } #if !CONFIG_SMALL - for(j=256; j<1024; j++) - for(i=0; i<4; i++) - tbl[4*j+i]= tbl[4*j + ((i-1)&3) - 1024]; + for (j = 256; j < 1024; j++) + for (i = 0; i < 4; i++) + tbl[4*j + i] = tbl[4*j + ((i - 1) & 3) - 1024]; #endif } // this is based on the reference AES code by Paulo Barreto and Vincent Rijmen -int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) { +int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) +{ int i, j, t, rconpointer = 0; uint8_t tk[8][4]; - int KC= key_bits>>5; - int rounds= KC + 6; - uint8_t log8[256]; + int KC = key_bits >> 5; + int rounds = KC + 6; + uint8_t log8[256]; uint8_t alog8[512]; - if(!enc_multbl[FF_ARRAY_ELEMS(enc_multbl)-1][FF_ARRAY_ELEMS(enc_multbl[0])-1]){ - j=1; - for(i=0; i<255; i++){ - alog8[i]= - alog8[i+255]= j; - log8[j]= i; - j^= j+j; - if(j>255) j^= 0x11B; + if (!enc_multbl[FF_ARRAY_ELEMS(enc_multbl)-1][FF_ARRAY_ELEMS(enc_multbl[0])-1]) { + j = 1; + for (i = 0; i < 255; i++) { + alog8[i] = alog8[i + 255] = j; + log8[j] = i; + j ^= j + j; + if (j > 255) + j ^= 0x11B; } - for(i=0; i<256; i++){ - j= i ? alog8[255-log8[i]] : 0; - j ^= (j<<1) ^ (j<<2) ^ (j<<3) ^ (j<<4); - j = (j ^ (j>>8) ^ 99) & 255; - inv_sbox[j]= i; - sbox [i]= j; + for (i = 0; i < 256; i++) { + j = i ? alog8[255 - log8[i]] : 0; + j ^= (j << 1) ^ (j << 2) ^ (j << 3) ^ (j << 4); + j = (j ^ (j >> 8) ^ 99) & 255; + inv_sbox[j] = i; + sbox[i] = j; } - init_multbl2(dec_multbl[0], (const int[4]){0xe, 0x9, 0xd, 0xb}, log8, alog8, inv_sbox); - init_multbl2(enc_multbl[0], (const int[4]){0x2, 0x1, 0x1, 0x3}, log8, alog8, sbox); + init_multbl2(dec_multbl[0], (const int[4]) { 0xe, 0x9, 0xd, 0xb }, + log8, alog8, inv_sbox); + init_multbl2(enc_multbl[0], (const int[4]) { 0x2, 0x1, 0x1, 0x3 }, + log8, alog8, sbox); } - if(key_bits!=128 && key_bits!=192 && key_bits!=256) + if (key_bits != 128 && key_bits != 192 && key_bits != 256) return -1; - a->rounds= rounds; + a->rounds = rounds; - memcpy(tk, key, KC*4); + memcpy(tk, key, KC * 4); - for(t= 0; t < (rounds+1)*16;) { - memcpy(a->round_key[0].u8+t, tk, KC*4); - t+= KC*4; + for (t = 0; t < (rounds + 1) * 16;) { + memcpy(a->round_key[0].u8 + t, tk, KC * 4); + t += KC * 4; - for(i = 0; i < 4; i++) - tk[0][i] ^= sbox[tk[KC-1][(i+1)&3]]; + for (i = 0; i < 4; i++) + tk[0][i] ^= sbox[tk[KC - 1][(i + 1) & 3]]; tk[0][0] ^= rcon[rconpointer++]; - for(j = 1; j < KC; j++){ - if(KC != 8 || j != KC>>1) - for(i = 0; i < 4; i++) tk[j][i] ^= tk[j-1][i]; + for (j = 1; j < KC; j++) { + if (KC != 8 || j != KC >> 1) + for (i = 0; i < 4; i++) + tk[j][i] ^= tk[j - 1][i]; else - for(i = 0; i < 4; i++) tk[j][i] ^= sbox[tk[j-1][i]]; + for (i = 0; i < 4; i++) + tk[j][i] ^= sbox[tk[j - 1][i]]; } } - if(decrypt){ - for(i=1; iround_key[i], 16); subshift(&tmp[1], 0, sbox); mix(tmp, dec_multbl, 1, 3); memcpy(&a->round_key[i], &tmp[0], 16); } - }else{ - for(i=0; i<(rounds+1)>>1; i++){ - for(j=0; j<16; j++) + } else { + for (i = 0; i < (rounds + 1) >> 1; i++) { + for (j = 0; j < 16; j++) FFSWAP(int, a->round_key[i].u8[j], a->round_key[rounds-i].u8[j]); } } @@ -209,30 +243,39 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) { int main(int argc, char **argv) { - int i,j; + int i, j; AVAES b; - uint8_t rkey[2][16]= { - {0}, - {0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59}}; + uint8_t rkey[2][16] = { + { 0 }, + { 0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, + 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59 } + }; uint8_t pt[16], rpt[2][16]= { - {0x6a, 0x84, 0x86, 0x7c, 0xd7, 0x7e, 0x12, 0xad, 0x07, 0xea, 0x1b, 0xe8, 0x95, 0xc5, 0x3f, 0xa3}, - {0}}; + { 0x6a, 0x84, 0x86, 0x7c, 0xd7, 0x7e, 0x12, 0xad, + 0x07, 0xea, 0x1b, 0xe8, 0x95, 0xc5, 0x3f, 0xa3 }, + { 0 } + }; uint8_t rct[2][16]= { - {0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7, 0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf}, - {0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0, 0x4e, 0xaa, 0x6f, 0xb4, 0xdb, 0xf7, 0x84, 0x65}}; + { 0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7, + 0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf }, + { 0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0, + 0x4e, 0xaa, 0x6f, 0xb4, 0xdb, 0xf7, 0x84, 0x65 } + }; uint8_t temp[16]; int err = 0; av_log_set_level(AV_LOG_DEBUG); - for(i=0; i<2; i++){ + for (i = 0; i < 2; i++) { av_aes_init(&b, rkey[i], 128, 1); av_aes_crypt(&b, temp, rct[i], 1, NULL, 1); - for(j=0; j<16; j++) - if(rpt[i][j] != temp[j]) { - av_log(NULL, AV_LOG_ERROR, "%d %02X %02X\n", j, rpt[i][j], temp[j]); + for (j = 0; j < 16; j++) { + if (rpt[i][j] != temp[j]) { + av_log(NULL, AV_LOG_ERROR, "%d %02X %02X\n", + j, rpt[i][j], temp[j]); err = 1; } + } } if (argc > 1 && !strcmp(argv[1], "-t")) { @@ -243,21 +286,23 @@ int main(int argc, char **argv) av_aes_init(&ad, "PI=3.141592654..", 128, 1); av_lfg_init(&prng, 1); - for(i=0; i<10000; i++){ - for(j=0; j<16; j++){ + for (i = 0; i < 10000; i++) { + for (j = 0; j < 16; j++) { pt[j] = av_lfg_get(&prng); } { START_TIMER; av_aes_crypt(&ae, temp, pt, 1, NULL, 0); - if(!(i&(i-1))) - av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", temp[0], temp[5], temp[10], temp[15]); + if (!(i & (i - 1))) + av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", + temp[0], temp[5], temp[10], temp[15]); av_aes_crypt(&ad, temp, temp, 1, NULL, 1); STOP_TIMER("aes"); } - for(j=0; j<16; j++){ - if(pt[j] != temp[j]){ - av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", i,j, pt[j], temp[j]); + for (j = 0; j < 16; j++) { + if (pt[j] != temp[j]) { + av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", + i, j, pt[j], temp[j]); } } } From dafaef2fe1e1af7c40adc1855547fd4cba9862a9 Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Mon, 27 Jun 2011 23:39:12 -0700 Subject: [PATCH 168/780] Add support for aac streams in mp4/mov without extradata. --- libavcodec/aacdec.c | 42 ++++++++++++++++++++++++++++++++++++++++++ libavformat/utils.c | 25 +++++++++++-------------- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 26ce204257..f26a4b74a7 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -530,6 +530,22 @@ static void reset_all_predictors(PredictorState *ps) reset_predict_state(&ps[i]); } +static int sample_rate_idx (int rate) +{ + if (92017 <= rate) return 0; + else if (75132 <= rate) return 1; + else if (55426 <= rate) return 2; + else if (46009 <= rate) return 3; + else if (37566 <= rate) return 4; + else if (27713 <= rate) return 5; + else if (23004 <= rate) return 6; + else if (18783 <= rate) return 7; + else if (13856 <= rate) return 8; + else if (11502 <= rate) return 9; + else if (9391 <= rate) return 10; + else return 11; +} + static void reset_predictor_group(PredictorState *ps, int group_num) { int i; @@ -552,10 +568,33 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) ac->m4ac.sample_rate = avctx->sample_rate; if (avctx->extradata_size > 0) { + avctx->channels = 0; + avctx->frame_size = 0; + avctx->sample_rate = 0; if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, avctx->extradata, avctx->extradata_size) < 0) return -1; + } else { + int sr, i; + enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; + + sr = sample_rate_idx(avctx->sample_rate); + ac->m4ac.sampling_index = sr; + ac->m4ac.channels = avctx->channels; + + for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++) + if (ff_mpeg4audio_channels[i] == avctx->channels) + break; + if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) { + i = 0; + } + ac->m4ac.chan_config = i; + + if (ac->m4ac.chan_config) { + set_default_channel_config(avctx, new_che_pos, ac->m4ac.chan_config); + output_configure(ac, ac->che_pos, new_che_pos, ac->m4ac.chan_config, OC_GLOBAL_HDR); + } } if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) { @@ -2047,6 +2086,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME)) return -7; } else if (ac->output_configured != OC_LOCKED) { + ac->m4ac.chan_config = 0; ac->output_configured = OC_NONE; } if (ac->output_configured != OC_LOCKED) { @@ -2514,6 +2554,7 @@ AVCodec ff_aac_decoder = { .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .capabilities = CODEC_CAP_CHANNEL_CONF, .channel_layouts = aac_channel_layout, }; @@ -2534,5 +2575,6 @@ AVCodec ff_aac_latm_decoder = { .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .capabilities = CODEC_CAP_CHANNEL_CONF, .channel_layouts = aac_channel_layout, }; diff --git a/libavformat/utils.c b/libavformat/utils.c index b12f785565..776697b5bb 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2207,11 +2207,7 @@ int av_find_stream_info(AVFormatContext *ic) for(i=0;inb_streams;i++) { AVCodec *codec; st = ic->streams[i]; - if (st->codec->codec_id == CODEC_ID_AAC) { - st->codec->sample_rate = 0; - st->codec->frame_size = 0; - st->codec->channels = 0; - } + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { /* if(!st->time_base.num) @@ -2229,13 +2225,6 @@ int av_find_stream_info(AVFormatContext *ic) assert(!st->codec->codec); codec = avcodec_find_decoder(st->codec->codec_id); - /* Force decoding of at least one frame of codec data - * this makes sure the codec initializes the channel configuration - * and does not trust the values from the container. - */ - if (codec && codec->capabilities & CODEC_CAP_CHANNEL_CONF) - st->codec->channels = 0; - /* Ensure that subtitle_header is properly set. */ if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE && codec && !st->codec->codec) @@ -2377,8 +2366,16 @@ int av_find_stream_info(AVFormatContext *ic) /* if still no information, we try to open the codec and to decompress the frame. We try to avoid that in most cases as it takes longer and uses more memory. For MPEG-4, we need to - decompress for QuickTime. */ - if (!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st)) + decompress for QuickTime. + + If CODEC_CAP_CHANNEL_CONF is set this will force decoding of at + least one frame of codec data, this makes sure the codec initializes + the channel configuration and does not only trust the values from the container. + */ + if (!has_codec_parameters(st->codec) || + !has_decode_delay_been_guessed(st) || + (st->codec->codec && + st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF)) try_decode_frame(st, pkt); st->codec_info_nb_frames++; From 192bfbc1f18d50afea03c2d62ce5325fabb2f141 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 30 Jun 2011 20:44:46 +0200 Subject: [PATCH 169/780] avutil: elaborate documentation for av_get_random_seed --- libavutil/random_seed.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavutil/random_seed.h b/libavutil/random_seed.h index 8157d42d73..5bfeb8b835 100644 --- a/libavutil/random_seed.h +++ b/libavutil/random_seed.h @@ -24,7 +24,12 @@ #include /** - * Get a seed to use in conjunction with random functions. + * Get random data. + * + * This function can be called repeatedly to generate more random bits + * as needed. It is generally quite slow, and usually used to seed a + * PRNG. As it uses /dev/urandom and /dev/random, the quality of the + * returned random data depends on the platform. */ uint32_t av_get_random_seed(void); From d7537a6fce140876405a66f059f14e190527388d Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 30 Jun 2011 21:06:25 +0200 Subject: [PATCH 170/780] doxygen: Include libavcodec and libavformat examples into the documentation --- Doxyfile | 2 +- libavcodec/api-example.c | 3 ++- libavformat/output-example.c | 13 ++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Doxyfile b/Doxyfile index 5d80a2b6f5..6f32da6540 100644 --- a/Doxyfile +++ b/Doxyfile @@ -591,7 +591,7 @@ EXCLUDE_SYMBOLS = # directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = libavcodec/api-example.c libavformat/output-example.c # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp diff --git a/libavcodec/api-example.c b/libavcodec/api-example.c index 0221a30925..1792d60d77 100644 --- a/libavcodec/api-example.c +++ b/libavcodec/api-example.c @@ -20,8 +20,9 @@ /** * @file - * avcodec API use example. + * libavcodec API use example. * + * @example libavcodec/api-example.c * Note that this library only handles codecs (mpeg, mpeg4, etc...), * not file formats (avi, vob, etc...). See library 'libavformat' for the * format handling diff --git a/libavformat/output-example.c b/libavformat/output-example.c index ddd16f1eed..4453c03039 100644 --- a/libavformat/output-example.c +++ b/libavformat/output-example.c @@ -1,7 +1,4 @@ /* - * Libavformat API example: Output a media file in any supported - * libavformat format. The default codecs are used. - * * Copyright (c) 2003 Fabrice Bellard * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -22,6 +19,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +/** + * @file + * libavformat API example. + * + * @example libavformat/output-example.c + * Output a media file in any supported libavformat format. + * The default codecs are used. + */ + #include #include #include From be73d76b34481686020e423ccabcca77042d0ede Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 20:53:59 +0200 Subject: [PATCH 171/780] cosmetics: fix some then/than typos --- libavcodec/avcodec.h | 2 +- libavcodec/dca.c | 2 +- libavcodec/dsputil.h | 4 ++-- libavcodec/get_bits.h | 4 ++-- libavcodec/mpegvideo_enc.c | 4 ++-- libavcodec/pgssubdec.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 40c30fc8e4..1a45009968 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1363,7 +1363,7 @@ typedef struct AVCodecContext { * A demuxer should set this to what is stored in the field used to identify the codec. * If there are multiple such fields in a container then the demuxer should choose the one * which maximizes the information about the used codec. - * If the codec tag field in a container is larger then 32 bits then the demuxer should + * If the codec tag field in a container is larger than 32 bits then the demuxer should * remap the longer ID to 32 bits with a table or other structure. Alternatively a new * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated * first. diff --git a/libavcodec/dca.c b/libavcodec/dca.c index 68731c9033..e87a9e3ed4 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -1316,7 +1316,7 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds PutBitContext pb; if ((unsigned)src_size > (unsigned)max_size) { -// av_log(NULL, AV_LOG_ERROR, "Input frame size larger then DCA_MAX_FRAME_SIZE!\n"); +// av_log(NULL, AV_LOG_ERROR, "Input frame size larger than DCA_MAX_FRAME_SIZE!\n"); // return -1; src_size = max_size; } diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 7a28b06fd5..ea135ca1ba 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -150,7 +150,7 @@ void clear_blocks_c(DCTELEM *blocks); /* add and put pixel (decoding) */ // blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16 -//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller then 4 +//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller than 4 typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h); typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h); typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride); @@ -183,7 +183,7 @@ static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ } /* motion estimation */ -// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller then 2 +// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller than 2 // although currently h<4 is not used as functions with width <8 are neither used nor implemented typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size, int h)/* __attribute__ ((const))*/; diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h index 4136498c71..b592b9a9a5 100644 --- a/libavcodec/get_bits.h +++ b/libavcodec/get_bits.h @@ -381,7 +381,7 @@ static inline int check_marker(GetBitContext *s, const char *msg) /** * init GetBitContext. - * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits + * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger than the actual read bits * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end * @param bit_size the size of the buffer in bits * @@ -504,7 +504,7 @@ void free_vlc(VLC *vlc); /** - * parses a vlc code, faster then get_vlc() + * parses a vlc code, faster than get_vlc() * @param bits is the number of bits which will be read at once, must be * identical to nb_bits in init_vlc() * @param max_depth is the number of times bits bits must be read to completely diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index b5a1872eb1..f3885626c1 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1787,7 +1787,7 @@ static av_always_inline void encode_mb(MpegEncContext *s, int motion_x, int moti static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){ int i; - memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster then a loop? + memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster than a loop? /* mpeg1 */ d->mb_skip_run= s->mb_skip_run; @@ -1816,7 +1816,7 @@ static inline void copy_context_after_encode(MpegEncContext *d, MpegEncContext * int i; memcpy(d->mv, s->mv, 2*4*2*sizeof(int)); - memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster then a loop? + memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster than a loop? /* mpeg1 */ d->mb_skip_run= s->mb_skip_run; diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 9546c38882..71b8242e70 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -198,7 +198,7 @@ static int parse_picture_segment(AVCodecContext *avctx, /* Make sure the bitmap is not too large */ if (avctx->width < width || avctx->height < height) { - av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger then video.\n"); + av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n"); return -1; } From 807aa2d8f398bf2b005fa1ecdf98b48be7cf54f9 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 30 Jun 2011 21:57:43 +0200 Subject: [PATCH 172/780] doxygen: Help doxygen parser to understand the DECLARE_ALIGNED and offsetof macros Without this, members that have been declare with the DECLARE_ALIGNED macro don't show up at all in the generated documentation. --- Doxyfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Doxyfile b/Doxyfile index 6f32da6540..bc9e7a1253 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1160,6 +1160,7 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = __attribute__(x)="" "RENAME(x)=x ## _TMPL" "DEF(x)=x ## _TMPL" \ HAVE_AV_CONFIG_H HAVE_MMX HAVE_MMX2 HAVE_AMD3DNOW \ + "DECLARE_ALIGNED(a,t,n)=t n" "offsetof(x,y)=0x42" \ # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. From dec126a932c8dc0605054dc3be07791b629cc275 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 1 Jul 2011 02:34:33 +0200 Subject: [PATCH 173/780] Fix internal buffer size for 2bpp and 4bpp raw video. --- libavcodec/rawdec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 6644d6c7e4..d48cbed3e7 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -103,13 +103,15 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx) } ff_set_systematic_pal2(context->palette, avctx->pix_fmt); - context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); if((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) && avctx->pix_fmt==PIX_FMT_PAL8 && (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))){ + context->length = avpicture_get_size(avctx->pix_fmt, (avctx->width+3)&~3, avctx->height); context->buffer = av_malloc(context->length); if (!context->buffer) return -1; + } else { + context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); } context->pic.pict_type = AV_PICTURE_TYPE_I; context->pic.key_frame = 1; From 315f0e3fd8dcbd1362276b7407dad2e97cccc4b7 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 1 Jul 2011 02:38:28 +0200 Subject: [PATCH 174/780] Fix possible double free when encoding using xvid. --- libavcodec/libxvidff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c index 9b5c17c59d..effd2db158 100644 --- a/libavcodec/libxvidff.c +++ b/libavcodec/libxvidff.c @@ -528,6 +528,7 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx) { if( x->twopassbuffer != NULL ) { av_free(x->twopassbuffer); av_free(x->old_twopassbuffer); + avctx->stats_out = NULL; } av_free(x->twopassfile); av_free(x->intra_matrix); From 9251942ca728e7807a2a95306415b27b36a8b8e7 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 1 Jul 2011 02:51:10 +0200 Subject: [PATCH 175/780] Fix mpeg4 padding bug detection with more than 128bit trash and slices. Fixes ticket302 The second hunk is from anatoly Signed-off-by: Michael Niedermayer --- libavcodec/h263dec.c | 2 +- libavcodec/mpeg4videodec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index f079557759..7b42046843 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -269,7 +269,7 @@ static int decode_slice(MpegEncContext *s){ if( s->codec_id==CODEC_ID_MPEG4 && (s->workaround_bugs&FF_BUG_AUTODETECT) && get_bits_left(&s->gb) >=0 - && get_bits_left(&s->gb) < 48 + && get_bits_left(&s->gb) < 137 // && !s->resync_marker && !s->data_partitioning){ diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 6b7b4bfbc0..7cc30c2bf5 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -113,7 +113,7 @@ static inline int mpeg4_is_resync(MpegEncContext *s){ int bits_count= get_bits_count(&s->gb); int v= show_bits(&s->gb, 16); - if(s->workaround_bugs&FF_BUG_NO_PADDING){ + if(s->workaround_bugs&FF_BUG_NO_PADDING && !s->resync_marker){ return 0; } From ebb0d6035394eaeddc346173e7c0a314fe568fd9 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 29 Jun 2011 21:04:45 -0700 Subject: [PATCH 176/780] swscale: fix yuv range correction when using 16-bit scaling. (cherry picked from commit e0b8fff6c7a293e35079ba1931bd19372686b3f6) --- libswscale/swscale.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 987afff2d2..644f84858c 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1982,8 +1982,8 @@ static void chrRangeToJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) int32_t *dstU = (int32_t *) _dstU; int32_t *dstV = (int32_t *) _dstV; for (i = 0; i < width; i++) { - dstU[i] = (FFMIN(dstU[i],30775)*4663 - 9289992)>>12; //-264 - dstV[i] = (FFMIN(dstV[i],30775)*4663 - 9289992)>>12; //-264 + dstU[i] = (FFMIN(dstU[i],30775<<4)*4663 - (9289992<<4))>>12; //-264 + dstV[i] = (FFMIN(dstV[i],30775<<4)*4663 - (9289992<<4))>>12; //-264 } } static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) @@ -1992,8 +1992,8 @@ static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) int32_t *dstU = (int32_t *) _dstU; int32_t *dstV = (int32_t *) _dstV; for (i = 0; i < width; i++) { - dstU[i] = (dstU[i]*1799 + 4081085)>>11; //1469 - dstV[i] = (dstV[i]*1799 + 4081085)>>11; //1469 + dstU[i] = (dstU[i]*1799 + (4081085<<4))>>11; //1469 + dstV[i] = (dstV[i]*1799 + (4081085<<4))>>11; //1469 } } static void lumRangeToJpeg16_c(int16_t *_dst, int width) @@ -2001,14 +2001,14 @@ static void lumRangeToJpeg16_c(int16_t *_dst, int width) int i; int32_t *dst = (int32_t *) _dst; for (i = 0; i < width; i++) - dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14; + dst[i] = (FFMIN(dst[i],30189<<4)*19077 - (39057361<<4))>>14; } static void lumRangeFromJpeg16_c(int16_t *_dst, int width) { int i; int32_t *dst = (int32_t *) _dst; for (i = 0; i < width; i++) - dst[i] = (dst[i]*14071 + 33561947)>>14; + dst[i] = (dst[i]*14071 + (33561947<<4))>>14; } static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, From afb9d4e8f10a78d52750e59bfd06d6fbd88e98f3 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 30 Jun 2011 07:05:52 -0700 Subject: [PATCH 177/780] swscale: fix another yuv range conversion overflow in 16bit scaling. (cherry picked from commit 81cc7d0bd1eab0aa782ff8dd49e087025a42cdee) --- libswscale/swscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 644f84858c..06ce8ff417 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2001,7 +2001,7 @@ static void lumRangeToJpeg16_c(int16_t *_dst, int width) int i; int32_t *dst = (int32_t *) _dst; for (i = 0; i < width; i++) - dst[i] = (FFMIN(dst[i],30189<<4)*19077 - (39057361<<4))>>14; + dst[i] = (FFMIN(dst[i],30189<<4)*4769 - (39057361<<2))>>12; } static void lumRangeFromJpeg16_c(int16_t *_dst, int width) { From d1b029dec97cd740943eb0222a519a571e3349c5 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 30 Jun 2011 19:47:52 +0200 Subject: [PATCH 178/780] ALSA encoder: correctly set time_base. --- libavdevice/alsa-audio-enc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c index a53c1763d5..22a1ea7ff6 100644 --- a/libavdevice/alsa-audio-enc.c +++ b/libavdevice/alsa-audio-enc.c @@ -61,6 +61,7 @@ static av_cold int audio_write_header(AVFormatContext *s1) st->codec->sample_rate, sample_rate); goto fail; } + av_set_pts_info(st, 64, 1, sample_rate); return res; From b442ca69d9d3cc50f00b43a25b200631cfb1e9ec Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 30 Jun 2011 19:45:22 +0200 Subject: [PATCH 179/780] lavf: add an API to get output timestamps. --- libavformat/avformat.h | 21 +++++++++++++++++++++ libavformat/utils.c | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 1734649a95..6069f19950 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -316,6 +316,9 @@ typedef struct AVOutputFormat { const AVClass *priv_class; ///< AVClass for the private context + void (*get_output_timestamp)(struct AVFormatContext *s, int stream, + int64_t *dts, int64_t *wall); + /* private fields */ struct AVOutputFormat *next; } AVOutputFormat; @@ -1518,6 +1521,24 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, */ int av_write_trailer(AVFormatContext *s); +/** + * Get timing information for the data currently output. + * The exact meaning of "currently output" depends on the format. + * It is mostly relevant for devices that have an internal buffer and/or + * work in real time. + * @param s media file handle + * @param stream stream in the media file + * @param dts[out] DTS of the last packet output for the stream, in stream + * time_base units + * @param wall[out] absolute time when that packet whas output, + * in microsecond + * @return 0 if OK, AVERROR(ENOSYS) if the format does not support it + * Note: some formats or devices may not allow to measure dts and wall + * atomically. + */ +int av_get_output_timestamp(struct AVFormatContext *s, int stream, + int64_t *dts, int64_t *wall); + #if FF_API_DUMP_FORMAT /** * @deprecated Deprecated in favor of av_dump_format(). diff --git a/libavformat/utils.c b/libavformat/utils.c index b3f0e12a65..da240f68e8 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3285,6 +3285,15 @@ fail: return ret; } +int av_get_output_timestamp(struct AVFormatContext *s, int stream, + int64_t *dts, int64_t *wall) +{ + if (!s->oformat || !s->oformat->get_output_timestamp) + return AVERROR(ENOSYS); + s->oformat->get_output_timestamp(s, stream, dts, wall); + return 0; +} + void ff_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx) { int i, j; From 84c2d8af135695e829fb5ce5e8569d02678550a8 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 30 Jun 2011 19:46:02 +0200 Subject: [PATCH 180/780] ALSA: implement get_output_timestamp. --- libavdevice/alsa-audio-enc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c index 22a1ea7ff6..0da22bb070 100644 --- a/libavdevice/alsa-audio-enc.c +++ b/libavdevice/alsa-audio-enc.c @@ -102,6 +102,17 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) return 0; } +static void +audio_get_output_timestamp(AVFormatContext *s1, int stream, + int64_t *dts, int64_t *wall) +{ + AlsaData *s = s1->priv_data; + snd_pcm_sframes_t delay = 0; + *wall = av_gettime(); + snd_pcm_delay(s->h, &delay); + *dts = s1->streams[0]->cur_dts - delay; +} + AVOutputFormat ff_alsa_muxer = { "alsa", NULL_IF_CONFIG_SMALL("ALSA audio output"), @@ -113,5 +124,6 @@ AVOutputFormat ff_alsa_muxer = { audio_write_header, audio_write_packet, ff_alsa_close, + .get_output_timestamp = audio_get_output_timestamp, .flags = AVFMT_NOFILE, }; From 34ab23f226669a6e198b1504dd2e90b72e35718e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 1 Jul 2011 10:47:07 +0200 Subject: [PATCH 181/780] dict: fix another typo achive -> achieve --- libavutil/dict.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/dict.h b/libavutil/dict.h index b960923f17..9890e9ec0e 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -24,7 +24,7 @@ * implementation as well as API inefficient. It does not scale and is * extremely slow with large dictionaries. * It is recommended that new code uses our tree container from tree.c/h - * where applicable, which uses AVL trees to achive O(log n) performance. + * where applicable, which uses AVL trees to achieve O(log n) performance. */ #ifndef AVUTIL_DICT_H From cb7e3202eca057b814865e876c6cd5abf5c097dc Mon Sep 17 00:00:00 2001 From: Jonathan Baldwin Date: Fri, 1 Jul 2011 10:48:49 +0200 Subject: [PATCH 182/780] openal: prefer ISC license Signed-off-by: Stefano Sabatini --- libavdevice/openal-dec.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/libavdevice/openal-dec.c b/libavdevice/openal-dec.c index f01dff7d87..c1bc351393 100644 --- a/libavdevice/openal-dec.c +++ b/libavdevice/openal-dec.c @@ -3,23 +3,17 @@ * * This file is part of FFmpeg. * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. */ /** From 518d8d436566e6260d73346cd999ff69eeb94e49 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Fri, 1 Jul 2011 10:09:04 +0200 Subject: [PATCH 183/780] lavf: bump minor and add APIchanges entry for av_get_output_timestamp --- doc/APIchanges | 3 +++ libavformat/version.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 6860b57e2b..52d700189b 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-07-01 - b442ca6 - lavf 53.5.0 - avformat.h + Add function av_get_output_timestamp(). + 2011-06-28 - 5129336 - lavu 51.11.0 - avutil.h Define the AV_PICTURE_TYPE_NONE value in AVPictureType enum. diff --git a/libavformat/version.h b/libavformat/version.h index 691f9c0569..d358285e3c 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -24,7 +24,7 @@ #include "libavutil/avutil.h" #define LIBAVFORMAT_VERSION_MAJOR 53 -#define LIBAVFORMAT_VERSION_MINOR 4 +#define LIBAVFORMAT_VERSION_MINOR 5 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ From 7464a53aaa5a241858ffbcb0194d3fc44a7aa441 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 30 Jun 2011 09:51:17 +0200 Subject: [PATCH 184/780] lavfi: make pix_fmt_is_in() in vf_lut.c an internal function Also generalize it, making it accept ints rather than pixel formats. Allow factorization. --- libavfilter/avfilter.h | 2 +- libavfilter/formats.c | 12 ++++++++++++ libavfilter/internal.h | 3 +++ libavfilter/vf_lut.c | 15 +++------------ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 5d25c72289..0b8f2d4bc7 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -27,7 +27,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 24 -#define LIBAVFILTER_VERSION_MICRO 0 +#define LIBAVFILTER_VERSION_MICRO 1 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/formats.c b/libavfilter/formats.c index eccb52304b..b6e30e7ab4 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -22,6 +22,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/audioconvert.h" #include "avfilter.h" +#include "internal.h" /** * Add all refs from a to ret and destroy a. @@ -73,6 +74,17 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) return ret; } +int ff_fmt_is_in(int fmt, const int *fmts) +{ + const int *p; + + for (p = fmts; *p != -1; p++) { + if (fmt == *p) + return 1; + } + return 0; +} + #define MAKE_FORMAT_LIST() \ AVFilterFormats *formats; \ int count = 0; \ diff --git a/libavfilter/internal.h b/libavfilter/internal.h index be1e9b08f2..7537565768 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -58,4 +58,7 @@ int ff_avfilter_graph_config_formats(AVFilterGraph *graphctx, AVClass *log_ctx); /** default handler for freeing audio/video buffer when there are no references left */ void ff_avfilter_default_free_buffer(AVFilterBuffer *buf); +/** Tell is a format is contained in the provided list terminated by -1. */ +int ff_fmt_is_in(int fmt, const int *fmts); + #endif /* AVFILTER_INTERNAL_H */ diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index fdab6941a4..8607ee906c 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -28,6 +28,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "internal.h" static const char *var_names[] = { "E", @@ -165,16 +166,6 @@ static int query_formats(AVFilterContext *ctx) return 0; } -static int pix_fmt_is_in(enum PixelFormat pix_fmt, enum PixelFormat *pix_fmts) -{ - enum PixelFormat *p; - for (p = pix_fmts; *p != PIX_FMT_NONE; p++) { - if (pix_fmt == *p) - return 1; - } - return 0; -} - /** * Clip value val in the minval - maxval range. */ @@ -245,8 +236,8 @@ static int config_props(AVFilterLink *inlink) } lut->is_yuv = lut->is_rgb = 0; - if (pix_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1; - else if (pix_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1; + if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1; + else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1; if (lut->is_rgb) { switch (inlink->format) { From 46edd3a01b68f7a1ca833510bef39f599a5055c9 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 1 Jul 2011 12:52:46 +0200 Subject: [PATCH 185/780] ffprobe: fix opt_pretty() signature This is required after the OPT_FUNC2 removal. --- ffprobe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ffprobe.c b/ffprobe.c index fdcdf70273..7da77eda2c 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -364,12 +364,13 @@ static int opt_help(const char *opt, const char *arg) return 0; } -static void opt_pretty(void) +static int opt_pretty(const char *opt, const char *arg) { show_value_unit = 1; use_value_prefix = 1; use_byte_value_binary_prefix = 1; use_value_sexagesimal_format = 1; + return 0; } static const OptionDef options[] = { From 134557f3a47697a7b5e5da2bd7e5a4b8f8d56b1c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 30 Jun 2011 23:00:46 +0200 Subject: [PATCH 186/780] doxygen: fix usage of @file directive in libavutil/{dict,file}.h --- libavutil/dict.h | 3 ++- libavutil/file.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libavutil/dict.h b/libavutil/dict.h index ff24b36f81..397ce3852f 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -18,7 +18,8 @@ */ /** - * @file Public dictionary API. + * @file + * Public dictionary API. */ #ifndef AVUTIL_DICT_H diff --git a/libavutil/file.h b/libavutil/file.h index 8b65bfb01d..c481c37f93 100644 --- a/libavutil/file.h +++ b/libavutil/file.h @@ -22,7 +22,8 @@ #include "avutil.h" /** - * @file misc file utilities + * @file + * Misc file utilities. */ /** From cdc2c1c57616956d975c57b4b69eb73865f513f5 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Fri, 1 Jul 2011 08:57:42 -0700 Subject: [PATCH 187/780] matroskadec: matroska_read_seek after after EBML_STOP leads to failure. EBML_STOP leaves matroska->current_id set. Then matroska_read_seek changes the stream position without resetting current_id. The next matroska_parse_cluster fails due to calculation of incorrect pos. So clear current_id when avio_seek happens in matroska_read_seek. Signed-off-by: Ronald S. Bultje --- libavformat/matroskadec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index c5f8e673dc..a1e827f093 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1904,6 +1904,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) { avio_seek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET); + matroska->current_id = 0; while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) { matroska_clear_queue(matroska); if (matroska_parse_cluster(matroska) < 0) @@ -1932,6 +1933,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, } avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET); + matroska->current_id = 0; matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY); matroska->skip_to_timecode = st->index_entries[index].timestamp; matroska->done = 0; From 8a8d0ce208b77f506759185ff580fa61b5c41f70 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 30 Jun 2011 17:35:13 -0700 Subject: [PATCH 188/780] swscale: for >8bit scaling, read in native bit-depth. For 9/10bit, it means we don't have to upscale to 16bit before actual scaling or pixel format conversion, and thus a performance gain. --- libswscale/ppc/swscale_altivec.c | 2 +- libswscale/swscale.c | 99 ++++++++----------------------- libswscale/swscale_internal.h | 2 +- libswscale/utils.c | 1 - libswscale/x86/swscale_template.c | 2 +- tests/ref/lavfi/pixfmts_scale | 8 +-- 6 files changed, 31 insertions(+), 83 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 6fb3de0ee7..369e93b85a 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -220,7 +220,7 @@ yuv2yuvX_altivec_real(SwsContext *c, } } -static void hScale_altivec_real(int16_t *dst, int dstW, +static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize) { diff --git a/libswscale/swscale.c b/libswscale/swscale.c index ef8fc39c48..dacf40ed8a 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1766,59 +1766,6 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV, #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos)) -// FIXME Maybe dither instead. -static av_always_inline void -yuv9_OR_10ToUV_c_template(uint16_t *dstU, uint16_t *dstV, - const uint16_t *srcU, const uint16_t *srcV, - int width, enum PixelFormat origin, int depth) -{ - int i; - - for (i = 0; i < width; i++) { - int upx = input_pixel(&srcU[i]); - int vpx = input_pixel(&srcV[i]); - dstU[i] = (upx << (16 - depth)) | (upx >> (2 * depth - 16)); - dstV[i] = (vpx << (16 - depth)) | (vpx >> (2 * depth - 16)); - } -} - -static av_always_inline void -yuv9_or_10ToY_c_template(uint16_t *dstY, const uint16_t *srcY, - int width, enum PixelFormat origin, int depth) -{ - int i; - - for (i = 0; i < width; i++) { - int px = input_pixel(&srcY[i]); - dstY[i] = (px << (16 - depth)) | (px >> (2 * depth - 16)); - } -} - -#undef input_pixel - -#define YUV_NBPS(depth, BE_LE, origin) \ -static void BE_LE ## depth ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ - const uint8_t *_srcU, const uint8_t *_srcV, \ - int width, uint32_t *unused) \ -{ \ - uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ - const uint16_t *srcU = (const uint16_t *) _srcU, \ - *srcV = (const uint16_t *) _srcV; \ - yuv9_OR_10ToUV_c_template(dstU, dstV, srcU, srcV, width, origin, depth); \ -} \ -static void BE_LE ## depth ## ToY_c(uint8_t *_dstY, const uint8_t *_srcY, \ - int width, uint32_t *unused) \ -{ \ - uint16_t *dstY = (uint16_t *) _dstY; \ - const uint16_t *srcY = (const uint16_t *) _srcY; \ - yuv9_or_10ToY_c_template(dstY, srcY, width, origin, depth); \ -} - -YUV_NBPS( 9, LE, PIX_FMT_YUV420P9LE); -YUV_NBPS( 9, BE, PIX_FMT_YUV420P9BE); -YUV_NBPS(10, LE, PIX_FMT_YUV420P10LE); -YUV_NBPS(10, BE, PIX_FMT_YUV420P10BE); - static void bgr24ToY_c(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused) { @@ -1905,13 +1852,15 @@ static void rgb24ToUV_half_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, } } -static void hScale16_c(int16_t *_dst, int dstW, const uint8_t *_src, +static void hScale16_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int16_t *filterPos, int filterSize) { int i; int32_t *dst = (int32_t *) _dst; const uint16_t *src = (const uint16_t *) _src; + int bits = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; + int sh = (bits <= 7) ? 11 : (bits - 4); for (i = 0; i < dstW; i++) { int j; @@ -1922,12 +1871,12 @@ static void hScale16_c(int16_t *_dst, int dstW, const uint8_t *_src, val += src[srcPos + j] * filter[filterSize * i + j]; } // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit - dst[i] = FFMIN(val >> 11, (1 << 19) - 1); + dst[i] = FFMIN(val >> sh, (1 << 19) - 1); } } // bilinear / bicubic scaling -static void hScale_c(int16_t *dst, int dstW, const uint8_t *src, +static void hScale_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize) { @@ -2063,7 +2012,7 @@ static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, } if (!c->hyscale_fast) { - c->hScale(dst, dstWidth, src, hLumFilter, hLumFilterPos, hLumFilterSize); + c->hScale(c, dst, dstWidth, src, hLumFilter, hLumFilterPos, hLumFilterSize); } else { // fast bilinear upscale / crap downscale c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc); } @@ -2113,8 +2062,8 @@ static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2 } if (!c->hcscale_fast) { - c->hScale(dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize); - c->hScale(dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize); + c->hScale(c, dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize); + c->hScale(c, dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize); } else { // fast bilinear upscale / crap downscale c->hcscale_fast(c, dst1, dst2, dstWidth, src1, src2, srcW, xInc); } @@ -2645,21 +2594,21 @@ static av_cold void sws_init_swScale_c(SwsContext *c) case PIX_FMT_PAL8 : case PIX_FMT_BGR4_BYTE: case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break; +#if HAVE_BIGENDIAN case PIX_FMT_YUV444P9LE: - case PIX_FMT_YUV420P9LE: c->chrToYV12 = LE9ToUV_c; break; + case PIX_FMT_YUV420P9LE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV444P10LE: - case PIX_FMT_YUV420P10LE: c->chrToYV12 = LE10ToUV_c; break; - case PIX_FMT_YUV444P9BE: - case PIX_FMT_YUV420P9BE: c->chrToYV12 = BE9ToUV_c; break; - case PIX_FMT_YUV444P10BE: - case PIX_FMT_YUV422P10BE: - case PIX_FMT_YUV420P10BE: c->chrToYV12 = BE10ToUV_c; break; -#if HAVE_BIGENDIAN + case PIX_FMT_YUV420P10LE: case PIX_FMT_YUV420P16LE: case PIX_FMT_YUV422P16LE: case PIX_FMT_YUV444P16LE: c->chrToYV12 = bswap16UV_c; break; #else + case PIX_FMT_YUV444P9BE: + case PIX_FMT_YUV420P9BE: + case PIX_FMT_YUV444P10BE: + case PIX_FMT_YUV422P10BE: + case PIX_FMT_YUV420P10BE: case PIX_FMT_YUV420P16BE: case PIX_FMT_YUV422P16BE: case PIX_FMT_YUV444P16BE: c->chrToYV12 = bswap16UV_c; break; @@ -2712,22 +2661,22 @@ static av_cold void sws_init_swScale_c(SwsContext *c) c->lumToYV12 = NULL; c->alpToYV12 = NULL; switch (srcFormat) { +#if HAVE_BIGENDIAN case PIX_FMT_YUV444P9LE: - case PIX_FMT_YUV420P9LE: c->lumToYV12 = LE9ToY_c; break; + case PIX_FMT_YUV420P9LE: case PIX_FMT_YUV444P10LE: case PIX_FMT_YUV422P10LE: - case PIX_FMT_YUV420P10LE: c->lumToYV12 = LE10ToY_c; break; - case PIX_FMT_YUV444P9BE: - case PIX_FMT_YUV420P9BE: c->lumToYV12 = BE9ToY_c; break; - case PIX_FMT_YUV444P10BE: - case PIX_FMT_YUV422P10BE: - case PIX_FMT_YUV420P10BE: c->lumToYV12 = BE10ToY_c; break; -#if HAVE_BIGENDIAN + case PIX_FMT_YUV420P10LE: case PIX_FMT_YUV420P16LE: case PIX_FMT_YUV422P16LE: case PIX_FMT_YUV444P16LE: case PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break; #else + case PIX_FMT_YUV444P9BE: + case PIX_FMT_YUV420P9BE: + case PIX_FMT_YUV444P10BE: + case PIX_FMT_YUV422P10BE: + case PIX_FMT_YUV420P10BE: case PIX_FMT_YUV420P16BE: case PIX_FMT_YUV422P16BE: case PIX_FMT_YUV444P16BE: diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index cfb19d9c13..e4b93c595b 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -440,7 +440,7 @@ typedef struct SwsContext { * (and input coefficients thus padded with zeroes) * to simplify creating SIMD code. */ - void (*hScale)(int16_t *dst, int dstW, const uint8_t *src, + void (*hScale)(struct SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize); diff --git a/libswscale/utils.c b/libswscale/utils.c index b7ccac94ba..eea32a130a 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -877,7 +877,6 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) } } - // FIXME it's even nicer if bpp isn't 16, but max({src,dst}formatbpp) c->scalingBpp = FFMAX(av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1, av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1) >= 8 ? 16 : 8; if (c->scalingBpp == 16) diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 54c7edc25e..f58ac520e1 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -1859,7 +1859,7 @@ static void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, #if !COMPILE_TEMPLATE_MMX2 // bilinear / bicubic scaling -static void RENAME(hScale)(int16_t *dst, int dstW, +static void RENAME(hScale)(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize) { diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index de41952a21..8901fe9132 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -31,12 +31,12 @@ uyvy422 314bd486277111a95d9369b944fa0400 yuv410p 7df8f6d69b56a8dcb6c7ee908e5018b5 yuv411p 1143e7c5cc28fe0922b051b17733bc4c yuv420p fdad2d8df8985e3d17e73c71f713cb14 -yuv420p10be 8b5ad855229840a8fa87786cab83f856 -yuv420p10le 5264e87921d47b17411578d9c92672b1 +yuv420p10be 2343beaf83fccc2ab23a590b2049d38b +yuv420p10le 94d511d783d175f573e7be5cce75ba4d yuv420p16be f6ef3ba90f238b467c7e72ade927083d yuv420p16le faf6aab3b1c16e8afbe160686dd360e0 -yuv420p9be c14bf746d161face61e1f39b491bf7ef -yuv420p9le 59457f9a51768bf1d4342238d50a9be3 +yuv420p9be fdafb9ad473a559246c4cb0a1f416cd8 +yuv420p9le fccfd3c3941da635b13739f579819b5a yuv422p 918e37701ee7377d16a8a6c119c56a40 yuv422p16be 837945d3a771366a5a72a4ed095a4f53 yuv422p16le b8292ae9b52eb7afc3d8b93e8fd895b4 From 392acaedcb052fa64386d5d0aea4931386f72d64 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Fri, 1 Jul 2011 14:58:24 +0200 Subject: [PATCH 189/780] ALSA: fix use of period_size. period_size is in frames, while the demuxer assumed it was in bytes, resulting in short reads. --- libavdevice/alsa-audio-dec.c | 4 ++-- libavdevice/alsa-audio.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavdevice/alsa-audio-dec.c b/libavdevice/alsa-audio-dec.c index 2424c022d3..e3ad98b7f3 100644 --- a/libavdevice/alsa-audio-dec.c +++ b/libavdevice/alsa-audio-dec.c @@ -127,11 +127,11 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) snd_htimestamp_t timestamp; snd_pcm_uframes_t ts_delay; - if (av_new_packet(pkt, s->period_size) < 0) { + if (av_new_packet(pkt, s->period_size * s->frame_size) < 0) { return AVERROR(EIO); } - while ((res = snd_pcm_readi(s->h, pkt->data, pkt->size / s->frame_size)) < 0) { + while ((res = snd_pcm_readi(s->h, pkt->data, s->period_size)) < 0) { if (res == -EAGAIN) { av_free_packet(pkt); diff --git a/libavdevice/alsa-audio.h b/libavdevice/alsa-audio.h index 0f467e34c9..9b1ecb1696 100644 --- a/libavdevice/alsa-audio.h +++ b/libavdevice/alsa-audio.h @@ -45,8 +45,8 @@ typedef void (*ff_reorder_func)(const void *, void *, int); typedef struct { AVClass *class; snd_pcm_t *h; - int frame_size; ///< preferred size for reads and writes - int period_size; ///< bytes per sample * channels + int frame_size; ///< bytes per sample * channels + int period_size; ///< preferred size for reads and writes, in frames int sample_rate; ///< sample rate set by user int channels; ///< number of channels set by user void (*reorder_func)(const void *, void *, int); From 6054cd25b4d7dce97c4fa3cc6e4757ba1e59ab86 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Thu, 2 Jun 2011 14:00:50 -0400 Subject: [PATCH 190/780] ac3enc: add int32_t array clipping function to DSPUtil, including x86 versions. --- libavcodec/dsputil.c | 17 +++++ libavcodec/dsputil.h | 16 +++++ libavcodec/x86/dsputil_mmx.c | 23 +++++++ libavcodec/x86/dsputil_yasm.asm | 115 ++++++++++++++++++++++++++++++++ 4 files changed, 171 insertions(+) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 4389289d82..4f17b435d1 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -2676,6 +2676,22 @@ static void apply_window_int16_c(int16_t *output, const int16_t *input, } } +static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len) +{ + do { + *dst++ = av_clip(*src++, min, max); + *dst++ = av_clip(*src++, min, max); + *dst++ = av_clip(*src++, min, max); + *dst++ = av_clip(*src++, min, max); + *dst++ = av_clip(*src++, min, max); + *dst++ = av_clip(*src++, min, max); + *dst++ = av_clip(*src++, min, max); + *dst++ = av_clip(*src++, min, max); + len -= 8; + } while (len > 0); +} + #define W0 2048 #define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */ #define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */ @@ -3122,6 +3138,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->scalarproduct_int16 = scalarproduct_int16_c; c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c; c->apply_window_int16 = apply_window_int16_c; + c->vector_clip_int32 = vector_clip_int32_c; c->scalarproduct_float = scalarproduct_float_c; c->butterflies_float = butterflies_float_c; c->vector_fmul_scalar = vector_fmul_scalar_c; diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index ea135ca1ba..ef2956eecb 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -555,6 +555,22 @@ typedef struct DSPContext { void (*apply_window_int16)(int16_t *output, const int16_t *input, const int16_t *window, unsigned int len); + /** + * Clip each element in an array of int32_t to a given minimum and maximum value. + * @param dst destination array + * constraints: 16-byte aligned + * @param src source array + * constraints: 16-byte aligned + * @param min minimum value + * constraints: must in the the range [-(1<<24), 1<<24] + * @param max maximum value + * constraints: must in the the range [-(1<<24), 1<<24] + * @param len number of elements in the array + * constraints: multiple of 32 greater than zero + */ + void (*vector_clip_int32)(int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len); + /* rv30 functions */ qpel_mc_func put_rv30_tpel_pixels_tab[4][16]; qpel_mc_func avg_rv30_tpel_pixels_tab[4][16]; diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 4d4bbc5b6f..03c094533f 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2429,6 +2429,15 @@ int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src, int w, i float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order); +void ff_vector_clip_int32_mmx (int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len); +void ff_vector_clip_int32_sse2 (int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len); +void ff_vector_clip_int32_sse2_int(int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len); +void ff_vector_clip_int32_sse41 (int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len); + void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) { int mm_flags = av_get_cpu_flags(); @@ -2570,6 +2579,8 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->put_rv40_chroma_pixels_tab[0]= ff_put_rv40_chroma_mc8_mmx; c->put_rv40_chroma_pixels_tab[1]= ff_put_rv40_chroma_mc4_mmx; + + c->vector_clip_int32 = ff_vector_clip_int32_mmx; #endif if (mm_flags & AV_CPU_FLAG_MMX2) { @@ -2855,6 +2866,11 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) #if HAVE_YASM c->scalarproduct_int16 = ff_scalarproduct_int16_sse2; c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_sse2; + if (mm_flags & AV_CPU_FLAG_ATOM) { + c->vector_clip_int32 = ff_vector_clip_int32_sse2_int; + } else { + c->vector_clip_int32 = ff_vector_clip_int32_sse2; + } if (avctx->flags & CODEC_FLAG_BITEXACT) { c->apply_window_int16 = ff_apply_window_int16_sse2_ba; } else { @@ -2880,6 +2896,13 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) } #endif } + + if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) { +#if HAVE_YASM + c->vector_clip_int32 = ff_vector_clip_int32_sse41; +#endif + } + #if HAVE_AVX && HAVE_YASM if (mm_flags & AV_CPU_FLAG_AVX) { if (bit_depth == 10) { diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm index 8b19cc1441..4e1ec24a7a 100644 --- a/libavcodec/x86/dsputil_yasm.asm +++ b/libavcodec/x86/dsputil_yasm.asm @@ -1048,3 +1048,118 @@ emu_edge sse %ifdef ARCH_X86_32 emu_edge mmx %endif + +;----------------------------------------------------------------------------- +; void ff_vector_clip_int32(int32_t *dst, const int32_t *src, int32_t min, +; int32_t max, unsigned int len) +;----------------------------------------------------------------------------- + +%macro PMINSD_MMX 3 ; dst, src, tmp + mova %3, %2 + pcmpgtd %3, %1 + pxor %1, %2 + pand %1, %3 + pxor %1, %2 +%endmacro + +%macro PMAXSD_MMX 3 ; dst, src, tmp + mova %3, %1 + pcmpgtd %3, %2 + pand %1, %3 + pandn %3, %2 + por %1, %3 +%endmacro + +%macro CLIPD_MMX 3-4 ; src/dst, min, max, tmp + PMINSD_MMX %1, %3, %4 + PMAXSD_MMX %1, %2, %4 +%endmacro + +%macro CLIPD_SSE2 3-4 ; src/dst, min (float), max (float), unused + cvtdq2ps %1, %1 + minps %1, %3 + maxps %1, %2 + cvtps2dq %1, %1 +%endmacro + +%macro CLIPD_SSE41 3-4 ; src/dst, min, max, unused + pminsd %1, %3 + pmaxsd %1, %2 +%endmacro + +%macro SPLATD_MMX 1 + punpckldq %1, %1 +%endmacro + +%macro SPLATD_SSE2 1 + pshufd %1, %1, 0 +%endmacro + +%macro VECTOR_CLIP_INT32 4 +cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len +%ifidn %1, sse2 + cvtsi2ss m4, minm + cvtsi2ss m5, maxm +%else + movd m4, minm + movd m5, maxm +%endif + SPLATD m4 + SPLATD m5 +.loop: +%assign %%i 1 +%rep %3 + mova m0, [srcq+mmsize*0*%%i] + mova m1, [srcq+mmsize*1*%%i] + mova m2, [srcq+mmsize*2*%%i] + mova m3, [srcq+mmsize*3*%%i] +%if %4 + mova m7, [srcq+mmsize*4*%%i] + mova m8, [srcq+mmsize*5*%%i] + mova m9, [srcq+mmsize*6*%%i] + mova m10, [srcq+mmsize*7*%%i] +%endif + CLIPD m0, m4, m5, m6 + CLIPD m1, m4, m5, m6 + CLIPD m2, m4, m5, m6 + CLIPD m3, m4, m5, m6 +%if %4 + CLIPD m7, m4, m5, m6 + CLIPD m8, m4, m5, m6 + CLIPD m9, m4, m5, m6 + CLIPD m10, m4, m5, m6 +%endif + mova [dstq+mmsize*0*%%i], m0 + mova [dstq+mmsize*1*%%i], m1 + mova [dstq+mmsize*2*%%i], m2 + mova [dstq+mmsize*3*%%i], m3 +%if %4 + mova [dstq+mmsize*4*%%i], m7 + mova [dstq+mmsize*5*%%i], m8 + mova [dstq+mmsize*6*%%i], m9 + mova [dstq+mmsize*7*%%i], m10 +%endif +%assign %%i %%i+1 +%endrep + add srcq, mmsize*4*(%3+%4) + add dstq, mmsize*4*(%3+%4) + sub lend, mmsize*(%3+%4) + jg .loop + REP_RET +%endmacro + +INIT_MMX +%define SPLATD SPLATD_MMX +%define CLIPD CLIPD_MMX +VECTOR_CLIP_INT32 mmx, 0, 1, 0 +INIT_XMM +%define SPLATD SPLATD_SSE2 +VECTOR_CLIP_INT32 sse2_int, 6, 1, 0 +%define CLIPD CLIPD_SSE2 +VECTOR_CLIP_INT32 sse2, 6, 2, 0 +%define CLIPD CLIPD_SSE41 +%ifdef m8 +VECTOR_CLIP_INT32 sse41, 11, 1, 1 +%else +VECTOR_CLIP_INT32 sse41, 6, 1, 0 +%endif From 523b7eba19590652b7ba19c5bdd85dd257bfe4f7 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 27 Jun 2011 14:29:33 -0400 Subject: [PATCH 191/780] ac3enc: clip coefficients after MDCT. This ensures that any processing between the MDCT and exponent extraction will be using clipped coefficients. --- libavcodec/ac3enc.h | 4 ++++ libavcodec/ac3enc_fixed.c | 9 +++++++++ libavcodec/ac3enc_float.c | 9 +++++++++ libavcodec/ac3enc_template.c | 16 +++++++++++++--- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index be62656650..54f427a523 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -50,12 +50,16 @@ #if CONFIG_AC3ENC_FLOAT #define AC3_NAME(x) ff_ac3_float_ ## x #define MAC_COEF(d,a,b) ((d)+=(a)*(b)) +#define COEF_MIN (-16777215.0/16777216.0) +#define COEF_MAX ( 16777215.0/16777216.0) typedef float SampleType; typedef float CoefType; typedef float CoefSumType; #else #define AC3_NAME(x) ff_ac3_fixed_ ## x #define MAC_COEF(d,a,b) MAC64(d,a,b) +#define COEF_MIN -16777215 +#define COEF_MAX 16777215 typedef int16_t SampleType; typedef int32_t CoefType; typedef int64_t CoefSumType; diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index d55720eb80..ea3a46cdfa 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -104,6 +104,15 @@ static void scale_coefficients(AC3EncodeContext *s) } +/** + * Clip MDCT coefficients to allowable range. + */ +static void clip_coefficients(DSPContext *dsp, int32_t *coef, unsigned int len) +{ + dsp->vector_clip_int32(coef, coef, COEF_MIN, COEF_MAX, len); +} + + static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx) { AC3EncodeContext *s = avctx->priv_data; diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 12d6b19241..718cc1f2b2 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -111,6 +111,15 @@ static void scale_coefficients(AC3EncodeContext *s) } +/** + * Clip MDCT coefficients to allowable range. + */ +static void clip_coefficients(DSPContext *dsp, float *coef, unsigned int len) +{ + dsp->vector_clipf(coef, coef, COEF_MIN, COEF_MAX, len); +} + + #if CONFIG_AC3_ENCODER AVCodec ff_ac3_encoder = { "ac3", diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index 85eea54a4a..c7243c7644 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -41,6 +41,8 @@ static void apply_window(DSPContext *dsp, SampleType *output, static int normalize_samples(AC3EncodeContext *s); +static void clip_coefficients(DSPContext *dsp, CoefType *coef, unsigned int len); + int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s) { @@ -171,8 +173,8 @@ static void apply_channel_coupling(AC3EncodeContext *s) cpl_coef[i] += ch_coef[i]; } - /* coefficients must be clipped to +/- 1.0 in order to be encoded */ - s->dsp.vector_clipf(cpl_coef, cpl_coef, -1.0f, 1.0f, num_cpl_coefs); + /* coefficients must be clipped in order to be encoded */ + clip_coefficients(&s->dsp, cpl_coef, num_cpl_coefs); /* scale coupling coefficients from float to 24-bit fixed-point */ s->ac3dsp.float_to_fixed24(&block->fixed_coef[CPL_CH][cpl_start], @@ -300,6 +302,7 @@ static void apply_channel_coupling(AC3EncodeContext *s) if (!block->cpl_in_use || !block->new_cpl_coords) continue; + clip_coefficients(&s->dsp, cpl_coords[blk][1], s->fbw_channels * 16); s->ac3dsp.float_to_fixed24(fixed_cpl_coords[blk][1], cpl_coords[blk][1], s->fbw_channels * 16); @@ -433,7 +436,11 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame, apply_mdct(s); - scale_coefficients(s); + if (s->fixed_point) + scale_coefficients(s); + + clip_coefficients(&s->dsp, s->blocks[0].mdct_coef[1], + AC3_MAX_COEFS * AC3_MAX_BLOCKS * s->channels); s->cpl_on = s->cpl_enabled; ff_ac3_compute_coupling_strategy(s); @@ -443,6 +450,9 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame, compute_rematrixing_strategy(s); + if (!s->fixed_point) + scale_coefficients(s); + ff_ac3_apply_rematrixing(s); ff_ac3_process_exponents(s); From 8b7b2d6aaee8cef0051beb3a4cf3e1c5a87cf40f Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Thu, 16 Jun 2011 16:55:33 -0400 Subject: [PATCH 192/780] ac3dsp: simplify extract_exponents() now that it does not need to do clipping. --- libavcodec/ac3dsp.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c index 8ce5f8d2c5..98c73573cb 100644 --- a/libavcodec/ac3dsp.c +++ b/libavcodec/ac3dsp.c @@ -164,21 +164,8 @@ static void ac3_extract_exponents_c(uint8_t *exp, int32_t *coef, int nb_coefs) int i; for (i = 0; i < nb_coefs; i++) { - int e; int v = abs(coef[i]); - if (v == 0) - e = 24; - else { - e = 23 - av_log2(v); - if (e >= 24) { - e = 24; - coef[i] = 0; - } else if (e < 0) { - e = 0; - coef[i] = av_clip(coef[i], -16777215, 16777215); - } - } - exp[i] = e; + exp[i] = v ? 23 - av_log2(v) : 24; } } From f99a5ef92e5aba87a2d861822274147c994041d5 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Thu, 30 Jun 2011 17:48:44 -0400 Subject: [PATCH 193/780] ac3dsp: add x86-optimized versions of ac3dsp.extract_exponents(). --- libavcodec/x86/ac3dsp.asm | 102 ++++++++++++++++++++++++++++++++++++ libavcodec/x86/ac3dsp_mmx.c | 9 ++++ 2 files changed, 111 insertions(+) diff --git a/libavcodec/x86/ac3dsp.asm b/libavcodec/x86/ac3dsp.asm index 6892ec2765..c1b0906a85 100644 --- a/libavcodec/x86/ac3dsp.asm +++ b/libavcodec/x86/ac3dsp.asm @@ -32,6 +32,11 @@ cextern ac3_bap_bits pw_bap_mul1: dw 21846, 21846, 0, 32768, 21846, 21846, 0, 32768 pw_bap_mul2: dw 5, 7, 0, 7, 5, 7, 0, 7 +; used in ff_ac3_extract_exponents() +pd_1: times 4 dd 1 +pd_151: times 4 dd 151 +pb_shuf_4dwb: db 0, 4, 8, 12 + SECTION .text ;----------------------------------------------------------------------------- @@ -346,3 +351,100 @@ cglobal ac3_compute_mantissa_size_sse2, 1,2,4, mant_cnt, sum movd eax, m0 add eax, sumd RET + +;------------------------------------------------------------------------------ +; void ff_ac3_extract_exponents(uint8_t *exp, int32_t *coef, int nb_coefs) +;------------------------------------------------------------------------------ + +%macro PABSD_MMX 2 ; src/dst, tmp + pxor %2, %2 + pcmpgtd %2, %1 + pxor %1, %2 + psubd %1, %2 +%endmacro + +%macro PABSD_SSSE3 1-2 ; src/dst, unused + pabsd %1, %1 +%endmacro + +%ifdef HAVE_AMD3DNOW +INIT_MMX +cglobal ac3_extract_exponents_3dnow, 3,3,0, exp, coef, len + add expq, lenq + lea coefq, [coefq+4*lenq] + neg lenq + movq m3, [pd_1] + movq m4, [pd_151] +.loop: + movq m0, [coefq+4*lenq ] + movq m1, [coefq+4*lenq+8] + PABSD_MMX m0, m2 + PABSD_MMX m1, m2 + pslld m0, 1 + por m0, m3 + pi2fd m2, m0 + psrld m2, 23 + movq m0, m4 + psubd m0, m2 + pslld m1, 1 + por m1, m3 + pi2fd m2, m1 + psrld m2, 23 + movq m1, m4 + psubd m1, m2 + packssdw m0, m0 + packuswb m0, m0 + packssdw m1, m1 + packuswb m1, m1 + punpcklwd m0, m1 + movd [expq+lenq], m0 + add lenq, 4 + jl .loop + REP_RET +%endif + +%macro AC3_EXTRACT_EXPONENTS 1 +cglobal ac3_extract_exponents_%1, 3,3,5, exp, coef, len + add expq, lenq + lea coefq, [coefq+4*lenq] + neg lenq + mova m2, [pd_1] + mova m3, [pd_151] +%ifidn %1, ssse3 ; + movd m4, [pb_shuf_4dwb] +%endif +.loop: + ; move 4 32-bit coefs to xmm0 + mova m0, [coefq+4*lenq] + ; absolute value + PABSD m0, m1 + ; convert to float and extract exponents + pslld m0, 1 + por m0, m2 + cvtdq2ps m1, m0 + psrld m1, 23 + mova m0, m3 + psubd m0, m1 + ; move the lowest byte in each of 4 dwords to the low dword +%ifidn %1, ssse3 + pshufb m0, m4 +%else + packssdw m0, m0 + packuswb m0, m0 +%endif + movd [expq+lenq], m0 + + add lenq, 4 + jl .loop + REP_RET +%endmacro + +%ifdef HAVE_SSE +INIT_XMM +%define PABSD PABSD_MMX +AC3_EXTRACT_EXPONENTS sse2 +%ifdef HAVE_SSSE3 +%define PABSD PABSD_SSSE3 +AC3_EXTRACT_EXPONENTS ssse3 +%endif +%endif diff --git a/libavcodec/x86/ac3dsp_mmx.c b/libavcodec/x86/ac3dsp_mmx.c index 2664736bb6..692d240d4c 100644 --- a/libavcodec/x86/ac3dsp_mmx.c +++ b/libavcodec/x86/ac3dsp_mmx.c @@ -44,6 +44,10 @@ extern void ff_float_to_fixed24_sse2 (int32_t *dst, const float *src, unsigned i extern int ff_ac3_compute_mantissa_size_sse2(uint16_t mant_cnt[6][16]); +extern void ff_ac3_extract_exponents_3dnow(uint8_t *exp, int32_t *coef, int nb_coefs); +extern void ff_ac3_extract_exponents_sse2 (uint8_t *exp, int32_t *coef, int nb_coefs); +extern void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs); + av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact) { int mm_flags = av_get_cpu_flags(); @@ -56,6 +60,7 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact) c->ac3_rshift_int32 = ff_ac3_rshift_int32_mmx; } if (mm_flags & AV_CPU_FLAG_3DNOW && HAVE_AMD3DNOW) { + c->extract_exponents = ff_ac3_extract_exponents_3dnow; if (!bit_exact) { c->float_to_fixed24 = ff_float_to_fixed24_3dnow; } @@ -72,6 +77,7 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact) c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_sse2; c->float_to_fixed24 = ff_float_to_fixed24_sse2; c->compute_mantissa_size = ff_ac3_compute_mantissa_size_sse2; + c->extract_exponents = ff_ac3_extract_exponents_sse2; if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) { c->ac3_lshift_int16 = ff_ac3_lshift_int16_sse2; c->ac3_rshift_int32 = ff_ac3_rshift_int32_sse2; @@ -79,6 +85,9 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact) } if (mm_flags & AV_CPU_FLAG_SSSE3 && HAVE_SSSE3) { c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_ssse3; + if (!(mm_flags & AV_CPU_FLAG_ATOM)) { + c->extract_exponents = ff_ac3_extract_exponents_ssse3; + } } #endif } From 29651e1d44f7e702a43133752a31398f4e73fe09 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Mon, 27 Jun 2011 23:12:55 -0700 Subject: [PATCH 194/780] fate-aac: Expand coverage. Add al05_44, al06_44, al17_44. --- tests/fate/aac.mak | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak index 6701e149d2..8c805575f3 100644 --- a/tests/fate/aac.mak +++ b/tests/fate/aac.mak @@ -2,10 +2,22 @@ FATE_AAC += fate-aac-al04_44 fate-aac-al04_44: CMD = pcm -i $(SAMPLES)/aac/al04_44.mp4 fate-aac-al04_44: REF = $(SAMPLES)/aac/al04_44.s16 +FATE_AAC += fate-aac-al05_44 +fate-aac-al05_44: CMD = pcm -i $(SAMPLES)/aac/al05_44.mp4 +fate-aac-al05_44: REF = $(SAMPLES)/aac/al05_44.s16 + +FATE_AAC += fate-aac-al06_44 +fate-aac-al06_44: CMD = pcm -i $(SAMPLES)/aac/al06_44.mp4 +fate-aac-al06_44: REF = $(SAMPLES)/aac/al06_44.s16 + FATE_AAC += fate-aac-al07_96 fate-aac-al07_96: CMD = pcm -i $(SAMPLES)/aac/al07_96.mp4 fate-aac-al07_96: REF = $(SAMPLES)/aac/al07_96.s16 +FATE_AAC += fate-aac-al17_44 +fate-aac-al17_44: CMD = pcm -i $(SAMPLES)/aac/al17_44.mp4 +fate-aac-al17_44: REF = $(SAMPLES)/aac/al17_44.s16 + FATE_AAC += fate-aac-am00_88 fate-aac-am00_88: CMD = pcm -i $(SAMPLES)/aac/am00_88.mp4 fate-aac-am00_88: REF = $(SAMPLES)/aac/am00_88.s16 From 8b84af748865105a6520a1e486792e8a5a82e2a6 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 29 Jun 2011 13:30:09 -0700 Subject: [PATCH 195/780] avidec: Factor out the sync fucntionality. --- libavformat/avidec.c | 244 +++++++++++++++++++++++-------------------- 1 file changed, 128 insertions(+), 116 deletions(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 85fc794362..7e509ce8ce 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -836,13 +836,137 @@ static int get_stream_idx(int *d){ } } -static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) +static int avi_sync(AVFormatContext *s) { AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; int n, d[8]; unsigned int size; int64_t i, sync; + +start_sync: + memset(d, -1, sizeof(int)*8); + for(i=sync=avio_tell(pb); !pb->eof_reached; i++) { + int j; + + for(j=0; j<7; j++) + d[j]= d[j+1]; + d[7]= avio_r8(pb); + + size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24); + + n= get_stream_idx(d+2); +//av_log(s, AV_LOG_DEBUG, "%X %X %X %X %X %X %X %X %"PRId64" %d %d\n", d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], i, size, n); + if(i + (uint64_t)size > avi->fsize || d[0]<0) + continue; + + //parse ix## + if( (d[0] == 'i' && d[1] == 'x' && n < s->nb_streams) + //parse JUNK + ||(d[0] == 'J' && d[1] == 'U' && d[2] == 'N' && d[3] == 'K') + ||(d[0] == 'i' && d[1] == 'd' && d[2] == 'x' && d[3] == '1')){ + avio_skip(pb, size); +//av_log(s, AV_LOG_DEBUG, "SKIP\n"); + goto start_sync; + } + + //parse stray LIST + if(d[0] == 'L' && d[1] == 'I' && d[2] == 'S' && d[3] == 'T'){ + avio_skip(pb, 4); + goto start_sync; + } + + n= get_stream_idx(d); + + if(!((i-avi->last_pkt_pos)&1) && get_stream_idx(d+1) < s->nb_streams) + continue; + + //detect ##ix chunk and skip + if(d[2] == 'i' && d[3] == 'x' && n < s->nb_streams){ + avio_skip(pb, size); + goto start_sync; + } + + //parse ##dc/##wb + if(n < s->nb_streams){ + AVStream *st; + AVIStream *ast; + st = s->streams[n]; + ast = st->priv_data; + + if(s->nb_streams>=2){ + AVStream *st1 = s->streams[1]; + AVIStream *ast1= st1->priv_data; + //workaround for broken small-file-bug402.avi + if( d[2] == 'w' && d[3] == 'b' + && n==0 + && st ->codec->codec_type == AVMEDIA_TYPE_VIDEO + && st1->codec->codec_type == AVMEDIA_TYPE_AUDIO + && ast->prefix == 'd'*256+'c' + && (d[2]*256+d[3] == ast1->prefix || !ast1->prefix_count) + ){ + n=1; + st = st1; + ast = ast1; + av_log(s, AV_LOG_WARNING, "Invalid stream + prefix combination, assuming audio.\n"); + } + } + + + if( (st->discard >= AVDISCARD_DEFAULT && size==0) + /*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/ //FIXME needs a little reordering + || st->discard >= AVDISCARD_ALL){ + ast->frame_offset += get_duration(ast, size); + avio_skip(pb, size); + goto start_sync; + } + + if (d[2] == 'p' && d[3] == 'c' && size<=4*256+4) { + int k = avio_r8(pb); + int last = (k + avio_r8(pb) - 1) & 0xFF; + + avio_rl16(pb); //flags + + for (; k <= last; k++) + ast->pal[k] = avio_rb32(pb)>>8;// b + (g << 8) + (r << 16); + ast->has_pal= 1; + goto start_sync; + } else if( ((ast->prefix_count<5 || sync+9 > i) && d[2]<128 && d[3]<128) || + d[2]*256+d[3] == ast->prefix /*|| + (d[2] == 'd' && d[3] == 'c') || + (d[2] == 'w' && d[3] == 'b')*/) { + +//av_log(s, AV_LOG_DEBUG, "OK\n"); + if(d[2]*256+d[3] == ast->prefix) + ast->prefix_count++; + else{ + ast->prefix= d[2]*256+d[3]; + ast->prefix_count= 0; + } + + avi->stream_index= n; + ast->packet_size= size + 8; + ast->remaining= size; + + if(size || !ast->sample_size){ + uint64_t pos= avio_tell(pb) - 8; + if(!st->index_entries || !st->nb_index_entries || st->index_entries[st->nb_index_entries - 1].pos < pos){ + av_add_index_entry(st, pos, ast->frame_offset, size, 0, AVINDEX_KEYFRAME); + } + } + return 0; + } + } + } + + return AVERROR_EOF; +} + +static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + AVIContext *avi = s->priv_data; + AVIOContext *pb = s->pb; + int err; void* dstr; if (CONFIG_DV_DEMUXER && avi->dv_demux) { @@ -993,121 +1117,9 @@ resync: return size; } - memset(d, -1, sizeof(int)*8); - for(i=sync=avio_tell(pb); !pb->eof_reached; i++) { - int j; - - for(j=0; j<7; j++) - d[j]= d[j+1]; - d[7]= avio_r8(pb); - - size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24); - - n= get_stream_idx(d+2); -//av_log(s, AV_LOG_DEBUG, "%X %X %X %X %X %X %X %X %"PRId64" %d %d\n", d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], i, size, n); - if(i + (uint64_t)size > avi->fsize || d[0]<0) - continue; - - //parse ix## - if( (d[0] == 'i' && d[1] == 'x' && n < s->nb_streams) - //parse JUNK - ||(d[0] == 'J' && d[1] == 'U' && d[2] == 'N' && d[3] == 'K') - ||(d[0] == 'i' && d[1] == 'd' && d[2] == 'x' && d[3] == '1')){ - avio_skip(pb, size); -//av_log(s, AV_LOG_DEBUG, "SKIP\n"); - goto resync; - } - - //parse stray LIST - if(d[0] == 'L' && d[1] == 'I' && d[2] == 'S' && d[3] == 'T'){ - avio_skip(pb, 4); - goto resync; - } - - n= get_stream_idx(d); - - if(!((i-avi->last_pkt_pos)&1) && get_stream_idx(d+1) < s->nb_streams) - continue; - - //detect ##ix chunk and skip - if(d[2] == 'i' && d[3] == 'x' && n < s->nb_streams){ - avio_skip(pb, size); - goto resync; - } - - //parse ##dc/##wb - if(n < s->nb_streams){ - AVStream *st; - AVIStream *ast; - st = s->streams[n]; - ast = st->priv_data; - - if(s->nb_streams>=2){ - AVStream *st1 = s->streams[1]; - AVIStream *ast1= st1->priv_data; - //workaround for broken small-file-bug402.avi - if( d[2] == 'w' && d[3] == 'b' - && n==0 - && st ->codec->codec_type == AVMEDIA_TYPE_VIDEO - && st1->codec->codec_type == AVMEDIA_TYPE_AUDIO - && ast->prefix == 'd'*256+'c' - && (d[2]*256+d[3] == ast1->prefix || !ast1->prefix_count) - ){ - n=1; - st = st1; - ast = ast1; - av_log(s, AV_LOG_WARNING, "Invalid stream + prefix combination, assuming audio.\n"); - } - } - - - if( (st->discard >= AVDISCARD_DEFAULT && size==0) - /*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/ //FIXME needs a little reordering - || st->discard >= AVDISCARD_ALL){ - ast->frame_offset += get_duration(ast, size); - avio_skip(pb, size); - goto resync; - } - - if (d[2] == 'p' && d[3] == 'c' && size<=4*256+4) { - int k = avio_r8(pb); - int last = (k + avio_r8(pb) - 1) & 0xFF; - - avio_rl16(pb); //flags - - for (; k <= last; k++) - ast->pal[k] = avio_rb32(pb)>>8;// b + (g << 8) + (r << 16); - ast->has_pal= 1; - goto resync; - } else if( ((ast->prefix_count<5 || sync+9 > i) && d[2]<128 && d[3]<128) || - d[2]*256+d[3] == ast->prefix /*|| - (d[2] == 'd' && d[3] == 'c') || - (d[2] == 'w' && d[3] == 'b')*/) { - -//av_log(s, AV_LOG_DEBUG, "OK\n"); - if(d[2]*256+d[3] == ast->prefix) - ast->prefix_count++; - else{ - ast->prefix= d[2]*256+d[3]; - ast->prefix_count= 0; - } - - avi->stream_index= n; - ast->packet_size= size + 8; - ast->remaining= size; - - if(size || !ast->sample_size){ - uint64_t pos= avio_tell(pb) - 8; - if(!st->index_entries || !st->nb_index_entries || st->index_entries[st->nb_index_entries - 1].pos < pos){ - av_add_index_entry(st, pos, ast->frame_offset, size, 0, AVINDEX_KEYFRAME); - } - } - goto resync; - } - } - } - - return AVERROR_EOF; + if ((err = avi_sync(s)) < 0) + return err; + goto resync; } /* XXX: We make the implicit supposition that the positions are sorted From fccab0180748c7e796f7e5911cb5c63cf8a97697 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 1 Jul 2011 15:49:53 +0200 Subject: [PATCH 196/780] doc: Remove outdated information about our issue tracker We have now switched to http://bugzilla.libav.org. --- doc/issue_tracker.txt | 228 ------------------------------------------ 1 file changed, 228 deletions(-) delete mode 100644 doc/issue_tracker.txt diff --git a/doc/issue_tracker.txt b/doc/issue_tracker.txt deleted file mode 100644 index e5733ec9d5..0000000000 --- a/doc/issue_tracker.txt +++ /dev/null @@ -1,228 +0,0 @@ -Libav's bug/patch/feature request tracker manual -================================================ - -NOTE: This is a draft. - -Overview: ---------- -Libav uses Roundup for tracking issues, new issues and changes to -existing issues can be done through a web interface and through email. -It is possible to subscribe to individual issues by adding yourself to the -nosy list or to subscribe to the ffmpeg-issues mailing list which receives -a mail for every change to every issue. Replies to such mails will also -be properly added to the respective issue. -(the above does all work already after light testing) -The subscription URL for the ffmpeg-issues list is: -http://live.polito/mailman/listinfo/ffmpeg-issues -The URL of the webinterface of the tracker is: -http(s)://roundup.libav.org/ -Note the URLs in this document are obfuscated, you must append the top level -domain for non-profit organizations to the tracker, and of Italy to the -mailing list. - -Email Interface: ----------------- -There is a mailing list to which all new issues and changes to existing issues -are sent. You can subscribe through -http://live.polito/mailman/listinfo/ffmpeg-issues -Replies to messages there will have their text added to the specific issues. -Attachments will be added as if they had been uploaded via the web interface. -You can change the status, substatus, topic, ... by changing the subject in -your reply like: -Re: [issue94] register_avcodec and allcodecs.h [type=patch;status=open;substatus=approved] -Roundup will then change things as you requested and remove the [...] from -the subject before forwarding the mail to the mailing list. - - -NOTE: issue = (bug report || patch || feature request) - -Type: ------ -bug - An error, flaw, mistake, failure, or fault in ffmpeg or libav* that - prevents it from behaving as intended. - -feature request - Request of support for encoding or decoding of a new codec, container - or variant. - Request of support for more, less or plain different output or behavior - where the current implementation cannot be considered wrong. - -patch - A patch as generated by diff which conforms to the patch submission and - development policy. - - -Priority: ---------- -critical - Bugs and patches which deal with data loss and security issues. - No feature request can be critical. - -important - Bugs which make Libav unusable for a significant number of users, and - patches fixing them. - Examples here might be completely broken MPEG-4 decoding or a build issue - on Linux. - While broken 4xm decoding or a broken OS/2 build would not be important, - the separation to normal is somewhat fuzzy. - For feature requests this priority would be used for things many people - want. - -normal - - -minor - Bugs and patches about things like spelling errors, "mp2" instead of - "mp3" being shown and such. - Feature requests about things few people want or which do not make a big - difference. - -wish - Something that is desirable to have but that there is no urgency at - all to implement, e.g. something completely cosmetic like a website - restyle or a personalized doxy template or the Libav logo. - This priority is not valid for bugs. - - -Status: -------- -new - initial state - -open - intermediate states - -closed - final state - - -Type/Status/Substatus: ----------- -*/new/new - Initial state of new bugs, patches and feature requests submitted by - users. - -*/open/open - Issues which have been briefly looked at and which did not look outright - invalid. - This implicates that no real more detailed state applies yet. Conversely, - the more detailed states below implicate that the issue has been briefly - looked at. - -*/closed/duplicate - Bugs, patches or feature requests which are duplicates. - Note that patches dealing with the same thing in a different way are not - duplicates. - Note, if you mark something as duplicate, do not forget setting the - superseder so bug reports are properly linked. - -*/closed/invalid - Bugs caused by user errors, random ineligible or otherwise nonsense stuff. - -*/closed/needs_more_info - Issues for which some information has been requested by the developers, - but which has not been provided by anyone within reasonable time. - -bug/open/reproduced - Bugs which have been reproduced. - -bug/open/analyzed - Bugs which have been analyzed and where it is understood what causes them - and which exact chain of events triggers them. This analysis should be - available as a message in the bug report. - Note, do not change the status to analyzed without also providing a clear - and understandable analysis. - This state implicates that the bug either has been reproduced or that - reproduction is not needed as the bug is already understood. - -bug/open/needs_more_info - Bug reports which are incomplete and or where more information is needed - from the submitter or another person who can provide it. - This state implicates that the bug has not been analyzed or reproduced. - Note, the idea behind needs_more_info is to offload work from the - developers to the users whenever possible. - -bug/closed/fixed - Bugs which have to the best of our knowledge been fixed. - -bug/closed/wont_fix - Bugs which we will not fix. Possible reasons include legality, high - complexity for the sake of supporting obscure corner cases, speed loss - for similarly esoteric purposes, et cetera. - This also means that we would reject a patch. - If we are just too lazy to fix a bug then the correct state is open - and unassigned. Closed means that the case is closed which is not - the case if we are just waiting for a patch. - -bug/closed/works_for_me - Bugs for which sufficient information was provided to reproduce but - reproduction failed - that is the code seems to work correctly to the - best of our knowledge. - -patch/open/approved - Patches which have been reviewed and approved by a developer. - Such patches can be applied anytime by any other developer after some - reasonable testing (compile + regression tests + does the patch do - what the author claimed). - -patch/open/needs_changes - Patches which have been reviewed and need changes to be accepted. - -patch/closed/applied - Patches which have been applied. - -patch/closed/rejected - Patches which have been rejected. - -feature_request/open/needs_more_info - Feature requests where it is not clear what exactly is wanted - (these also could be closed as invalid ...). - -feature_request/closed/implemented - Feature requests which have been implemented. - -feature_request/closed/wont_implement - Feature requests which will not be implemented. The reasons here could - be legal, philosophical or others. - -Note, please do not use type-status-substatus combinations other than the -above without asking on libav-devel first! - -Note2, if you provide the requested info do not forget to remove the -needs_more_info substate. - -Topic: ------- -A topic is a tag you should add to your issue in order to make grouping them -easier. - -avcodec - issues in libavcodec/* - -avformat - issues in libavformat/* - -avutil - issues in libavutil/* - -regression test - issues in tests/* - -ffmpeg - issues in or related to ffmpeg.c - -ffplay - issues in or related to ffplay.c - -ffserver - issues in or related to ffserver.c - -build system - issues in or related to configure/Makefile - -regression - bugs which were working in a past revision - -roundup - issues related to our issue tracker From 23ce6e72123a40895baaeefeb27c7c18748bd67e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 1 Jul 2011 12:47:36 +0100 Subject: [PATCH 197/780] get_bits: remove x86 inline asm in A32 bitstream reader x86 does not use this variant so having inline asm there is pointless. Signed-off-by: Mans Rullgard --- libavcodec/get_bits.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h index b592b9a9a5..d2ae345315 100644 --- a/libavcodec/get_bits.h +++ b/libavcodec/get_bits.h @@ -201,19 +201,11 @@ static inline void skip_bits_long(GetBitContext *s, int n){ } \ } while (0) -#if ARCH_X86 -# define SKIP_CACHE(name, gb, num) \ - __asm__("shldl %2, %1, %0 \n\t" \ - "shll %2, %1 \n\t" \ - : "+r" (name##_cache0), "+r" (name##_cache1) \ - : "Ic" ((uint8_t)(num))) -#else # define SKIP_CACHE(name, gb, num) do { \ name##_cache0 <<= (num); \ name##_cache0 |= NEG_USR32(name##_cache1,num); \ name##_cache1 <<= (num); \ } while (0) -#endif # define SKIP_COUNTER(name, gb, num) name##_bit_count += (num) From d3f610c186b6e8430e4cf97667750e720f6983c8 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 1 Jun 2011 17:33:38 -0700 Subject: [PATCH 198/780] avidec: infer absolute vs relative index from first packet --- libavformat/avidec.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 7e509ce8ce..871da0bb40 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -836,7 +836,7 @@ static int get_stream_idx(int *d){ } } -static int avi_sync(AVFormatContext *s) +static int avi_sync(AVFormatContext *s, int exit_early) { AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; @@ -916,7 +916,9 @@ start_sync: if( (st->discard >= AVDISCARD_DEFAULT && size==0) /*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/ //FIXME needs a little reordering || st->discard >= AVDISCARD_ALL){ - ast->frame_offset += get_duration(ast, size); + if (!exit_early) { + ast->frame_offset += get_duration(ast, size); + } avio_skip(pb, size); goto start_sync; } @@ -936,6 +938,8 @@ start_sync: (d[2] == 'd' && d[3] == 'c') || (d[2] == 'w' && d[3] == 'b')*/) { + if (exit_early) + return 0; //av_log(s, AV_LOG_DEBUG, "OK\n"); if(d[2]*256+d[3] == ast->prefix) ast->prefix_count++; @@ -1117,7 +1121,7 @@ resync: return size; } - if ((err = avi_sync(s)) < 0) + if ((err = avi_sync(s, 0)) < 0) return err; goto resync; } @@ -1131,13 +1135,22 @@ static int avi_read_idx1(AVFormatContext *s, int size) int nb_index_entries, i; AVStream *st; AVIStream *ast; - unsigned int index, tag, flags, pos, len; + unsigned int index, tag, flags, pos, len, first_packet = 1; unsigned last_pos= -1; + int64_t idx1_pos, first_packet_pos = 0, data_offset = 0; nb_index_entries = size / 16; if (nb_index_entries <= 0) return -1; + idx1_pos = avio_tell(pb); + avio_seek(pb, avi->movi_list+4, SEEK_SET); + if (avi_sync(s, 1) == 0) { + first_packet_pos = avio_tell(pb) - 8; + } + avi->stream_index = -1; + avio_seek(pb, idx1_pos, SEEK_SET); + /* Read the entries and sort them in each stream component. */ for(i = 0; i < nb_index_entries; i++) { tag = avio_rl32(pb); @@ -1146,9 +1159,6 @@ static int avi_read_idx1(AVFormatContext *s, int size) len = avio_rl32(pb); av_dlog(s, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/", i, tag, flags, pos, len); - if(i==0 && pos > avi->movi_list) - avi->movi_list= 0; //FIXME better check - pos += avi->movi_list; index = ((tag & 0xff) - '0') * 10; index += ((tag >> 8) & 0xff) - '0'; @@ -1157,6 +1167,12 @@ static int avi_read_idx1(AVFormatContext *s, int size) st = s->streams[index]; ast = st->priv_data; + if(first_packet && first_packet_pos && len) { + data_offset = first_packet_pos - pos; + first_packet = 0; + } + pos += data_offset; + av_dlog(s, "%d cum_len=%"PRId64"\n", len, ast->cum_len); if(pb->eof_reached) From 5001d6ef4a2b70fe903b1d2e3e64c6ad7cc1cfa6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 1 Jul 2011 21:24:17 +0200 Subject: [PATCH 199/780] lavf: use the correct pointer in av_open_input_stream(). --- libavformat/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 776697b5bb..92debd5404 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -461,8 +461,9 @@ int av_open_input_stream(AVFormatContext **ic_ptr, } ic->pb = pb; - err = avformat_open_input(ic_ptr, filename, fmt, &opts); + err = avformat_open_input(&ic, filename, fmt, &opts); + *ic_ptr = ic; fail: av_dict_free(&opts); return err; From 4f731c4429e1fe66a5c92ff15feb63253a36d8fb Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 24 Jun 2011 07:58:16 +0200 Subject: [PATCH 200/780] lavf: restore old behavior for custom AVIOContex with an AVFMT_NOFILE format. av_open_input_stream used to allow this, even though it makes no sense. Make it just print a warning instead of failing, thus restoring compatibility. Note that avformat_open_input() will still reject this combination. Signed-off-by: Anton Khirnov --- libavformat/utils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 92debd5404..de26a1886e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -459,9 +459,14 @@ int av_open_input_stream(AVFormatContext **ic_ptr, err = AVERROR(ENOMEM); goto fail; } - ic->pb = pb; + if (pb && fmt && fmt->flags & AVFMT_NOFILE) + av_log(ic, AV_LOG_WARNING, "Custom AVIOContext makes no sense and " + "will be ignored with AVFMT_NOFILE format.\n"); + else + ic->pb = pb; err = avformat_open_input(&ic, filename, fmt, &opts); + ic->pb = ic->pb ? ic->pb : pb; // don't leak custom pb if it wasn't set above *ic_ptr = ic; fail: From 1a53a438dc04e74628b39f29d3ff81ae4aa086a0 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 1 Jul 2011 20:49:14 +0200 Subject: [PATCH 201/780] avformat: doxify the Metadata API convert the comment that documents the metadata API to use the doxygen markup --- libavformat/avformat.h | 73 ++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 9abc9c51a4..05e80f1922 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -48,63 +48,68 @@ const char *avformat_license(void); struct AVFormatContext; -/* - * Public Metadata API. +/** + * @defgroup metadata_api Public Metadata API + * @{ * The metadata API allows libavformat to export metadata tags to a client * application using a sequence of key/value pairs. Like all strings in Libav, * metadata must be stored as UTF-8 encoded Unicode. Note that metadata * exported by demuxers isn't checked to be valid UTF-8 in most cases. * Important concepts to keep in mind: - * 1. Keys are unique; there can never be 2 tags with the same key. This is + * - Keys are unique; there can never be 2 tags with the same key. This is * also meant semantically, i.e., a demuxer should not knowingly produce * several keys that are literally different but semantically identical. * E.g., key=Author5, key=Author6. In this example, all authors must be * placed in the same tag. - * 2. Metadata is flat, not hierarchical; there are no subtags. If you + * - Metadata is flat, not hierarchical; there are no subtags. If you * want to store, e.g., the email address of the child of producer Alice * and actor Bob, that could have key=alice_and_bobs_childs_email_address. - * 3. Several modifiers can be applied to the tag name. This is done by + * - Several modifiers can be applied to the tag name. This is done by * appending a dash character ('-') and the modifier name in the order * they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng. - * a) language -- a tag whose value is localized for a particular language + * - language -- a tag whose value is localized for a particular language * is appended with the ISO 639-2/B 3-letter language code. * For example: Author-ger=Michael, Author-eng=Mike * The original/default language is in the unqualified "Author" tag. * A demuxer should set a default if it sets any translated tag. - * b) sorting -- a modified version of a tag that should be used for + * - sorting -- a modified version of a tag that should be used for * sorting will have '-sort' appended. E.g. artist="The Beatles", * artist-sort="Beatles, The". * - * 4. Demuxers attempt to export metadata in a generic format, however tags + * - Demuxers attempt to export metadata in a generic format, however tags * with no generic equivalents are left as they are stored in the container. * Follows a list of generic tag names: * - * album -- name of the set this work belongs to - * album_artist -- main creator of the set/album, if different from artist. - * e.g. "Various Artists" for compilation albums. - * artist -- main creator of the work - * comment -- any additional description of the file. - * composer -- who composed the work, if different from artist. - * copyright -- name of copyright holder. - * creation_time-- date when the file was created, preferably in ISO 8601. - * date -- date when the work was created, preferably in ISO 8601. - * disc -- number of a subset, e.g. disc in a multi-disc collection. - * encoder -- name/settings of the software/hardware that produced the file. - * encoded_by -- person/group who created the file. - * filename -- original name of the file. - * genre -- . - * language -- main language in which the work is performed, preferably - * in ISO 639-2 format. Multiple languages can be specified by - * separating them with commas. - * performer -- artist who performed the work, if different from artist. - * E.g for "Also sprach Zarathustra", artist would be "Richard - * Strauss" and performer "London Philharmonic Orchestra". - * publisher -- name of the label/publisher. - * service_name -- name of the service in broadcasting (channel name). - * service_provider -- name of the service provider in broadcasting. - * title -- name of the work. - * track -- number of this work in the set, can be in form current/total. - * variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of + @verbatim + album -- name of the set this work belongs to + album_artist -- main creator of the set/album, if different from artist. + e.g. "Various Artists" for compilation albums. + artist -- main creator of the work + comment -- any additional description of the file. + composer -- who composed the work, if different from artist. + copyright -- name of copyright holder. + creation_time-- date when the file was created, preferably in ISO 8601. + date -- date when the work was created, preferably in ISO 8601. + disc -- number of a subset, e.g. disc in a multi-disc collection. + encoder -- name/settings of the software/hardware that produced the file. + encoded_by -- person/group who created the file. + filename -- original name of the file. + genre -- . + language -- main language in which the work is performed, preferably + in ISO 639-2 format. Multiple languages can be specified by + separating them with commas. + performer -- artist who performed the work, if different from artist. + E.g for "Also sprach Zarathustra", artist would be "Richard + Strauss" and performer "London Philharmonic Orchestra". + publisher -- name of the label/publisher. + service_name -- name of the service in broadcasting (channel name). + service_provider -- name of the service provider in broadcasting. + title -- name of the work. + track -- number of this work in the set, can be in form current/total. + variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of + @endverbatim + * + * @} */ #if FF_API_OLD_METADATA2 From 7655cfb1b8d8a70e8cc4b1ca811bfc3f293768d8 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 1 Jul 2011 20:53:09 +0200 Subject: [PATCH 202/780] doxygen: be more permissive when searching for API examples --- Doxyfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doxyfile b/Doxyfile index bc9e7a1253..2502548aed 100644 --- a/Doxyfile +++ b/Doxyfile @@ -591,14 +591,14 @@ EXCLUDE_SYMBOLS = # directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = libavcodec/api-example.c libavformat/output-example.c +EXAMPLE_PATH = libavcodec/ libavformat/ # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = +EXAMPLE_PATTERNS = *-example.c # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude From 5d35b279e21814b3b1499ae0b2e0e0dad7d7f782 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Fri, 1 Jul 2011 15:26:40 +0200 Subject: [PATCH 203/780] ALSA demuxer: use av_gettime and a timefilter. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PTS for captured audio was measured using snd_pcm_htimestamp. snd_pcm_htimestamp hangs when the input is a dsnoop plugin. Furthermore, at some point, snd_pcm_htimestamp started returning monotonic timestamps rather than wall clock timestamps, in most but not all situations. Monotonic timestamps are fine, but ffmpeg uses wall clock timestamps everywhere else, and we have no API to inform the user which kind of timestamps it is. A separate snd_pcm_htimestamp is only slightly less accurate than snd_pcm_htimestamp: the standard deviation for the difference between two consecutive timestamps is (on my hardware): - ~13 µs with snd_pcm_htimestamp; - ~35 µs with av_gettime; - ~5 µs with av_gettime and a timefilter. --- libavdevice/alsa-audio-common.c | 1 + libavdevice/alsa-audio-dec.c | 44 ++++++++++----------------------- libavdevice/alsa-audio.h | 2 ++ libavformat/Makefile | 1 + 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index 8c5be3c864..6188721f48 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -316,6 +316,7 @@ av_cold int ff_alsa_close(AVFormatContext *s1) AlsaData *s = s1->priv_data; av_freep(&s->reorder_buf); + ff_timefilter_destroy(s->timefilter); snd_pcm_close(s->h); return 0; } diff --git a/libavdevice/alsa-audio-dec.c b/libavdevice/alsa-audio-dec.c index e3ad98b7f3..f8977a10f9 100644 --- a/libavdevice/alsa-audio-dec.c +++ b/libavdevice/alsa-audio-dec.c @@ -59,6 +59,7 @@ static av_cold int audio_read_header(AVFormatContext *s1, int ret; enum CodecID codec_id; snd_pcm_sw_params_t *sw_params; + double o; #if FF_API_FORMAT_PARAMETERS if (ap->sample_rate > 0) @@ -82,35 +83,17 @@ static av_cold int audio_read_header(AVFormatContext *s1, return AVERROR(EIO); } - if (snd_pcm_type(s->h) != SND_PCM_TYPE_HW) - av_log(s1, AV_LOG_WARNING, - "capture with some ALSA plugins, especially dsnoop, " - "may hang.\n"); - - ret = snd_pcm_sw_params_malloc(&sw_params); - if (ret < 0) { - av_log(s1, AV_LOG_ERROR, "cannot allocate software parameters structure (%s)\n", - snd_strerror(ret)); - goto fail; - } - - snd_pcm_sw_params_current(s->h, sw_params); - snd_pcm_sw_params_set_tstamp_mode(s->h, sw_params, SND_PCM_TSTAMP_ENABLE); - - ret = snd_pcm_sw_params(s->h, sw_params); - snd_pcm_sw_params_free(sw_params); - if (ret < 0) { - av_log(s1, AV_LOG_ERROR, "cannot install ALSA software parameters (%s)\n", - snd_strerror(ret)); - goto fail; - } - /* take real parameters */ st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = codec_id; st->codec->sample_rate = s->sample_rate; st->codec->channels = s->channels; av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ + o = 2 * M_PI * s->period_size / s->sample_rate * 1.5; // bandwidth: 1.5Hz + s->timefilter = ff_timefilter_new(1000000.0 / s->sample_rate, + sqrt(2 * o), o * o); + if (!s->timefilter) + goto fail; return 0; @@ -124,8 +107,8 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) AlsaData *s = s1->priv_data; AVStream *st = s1->streams[0]; int res; - snd_htimestamp_t timestamp; - snd_pcm_uframes_t ts_delay; + int64_t dts; + snd_pcm_sframes_t delay = 0; if (av_new_packet(pkt, s->period_size * s->frame_size) < 0) { return AVERROR(EIO); @@ -144,14 +127,13 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) return AVERROR(EIO); } + ff_timefilter_reset(s->timefilter); } - snd_pcm_htimestamp(s->h, &ts_delay, ×tamp); - ts_delay += res; - pkt->pts = timestamp.tv_sec * 1000000LL - + (timestamp.tv_nsec * st->codec->sample_rate - - ts_delay * 1000000000LL + st->codec->sample_rate * 500LL) - / (st->codec->sample_rate * 1000LL); + dts = av_gettime(); + snd_pcm_delay(s->h, &delay); + dts -= av_rescale(delay + res, 1000000, s->sample_rate); + pkt->pts = ff_timefilter_update(s->timefilter, dts, res); pkt->size = res * s->frame_size; diff --git a/libavdevice/alsa-audio.h b/libavdevice/alsa-audio.h index 9b1ecb1696..0226632479 100644 --- a/libavdevice/alsa-audio.h +++ b/libavdevice/alsa-audio.h @@ -33,6 +33,7 @@ #include #include "config.h" #include "libavutil/log.h" +#include "libavformat/timefilter.h" #include "avdevice.h" /* XXX: we make the assumption that the soundcard accepts this format */ @@ -49,6 +50,7 @@ typedef struct { int period_size; ///< preferred size for reads and writes, in frames int sample_rate; ///< sample rate set by user int channels; ///< number of channels set by user + TimeFilter *timefilter; void (*reorder_func)(const void *, void *, int); void *reorder_buf; int reorder_buf_size; ///< in frames diff --git a/libavformat/Makefile b/libavformat/Makefile index 3d9017b3e4..6d7a342c9e 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -338,6 +338,7 @@ OBJS-$(CONFIG_TCP_PROTOCOL) += tcp.o OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o # libavdevice dependencies +OBJS-$(CONFIG_ALSA_INDEV) += timefilter.o OBJS-$(CONFIG_JACK_INDEV) += timefilter.o TESTPROGS = timefilter From 3db9002f36ab1b40e75e28410650133a44bfe023 Mon Sep 17 00:00:00 2001 From: Etienne Buira Date: Fri, 1 Jul 2011 22:44:53 +0200 Subject: [PATCH 204/780] cmdutils: fix an opt name/val swap in set_context_opts() Signed-off-by: Stefano Sabatini --- cmdutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmdutils.c b/cmdutils.c index a3f643bff6..53266d4ebe 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -494,7 +494,7 @@ void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec) if (av_find_opt(priv_ctx, opt_names[i], NULL, flags, flags)) { if (av_set_string3(priv_ctx, opt_names[i], opt_values[i], 1, NULL) < 0) { fprintf(stderr, "Invalid value '%s' for option '%s'\n", - opt_names[i], opt_values[i]); + opt_values[i], opt_names[i]); exit(1); } } else From 25119a7f082ba2432df528f70348f5bd83aa8c07 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Fri, 1 Jul 2011 15:48:04 +0200 Subject: [PATCH 205/780] ffprobe: flush stdout after each group. --- ffprobe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ffprobe.c b/ffprobe.c index 7da77eda2c..61ddc3d5ee 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -143,6 +143,7 @@ static void show_packet(AVFormatContext *fmt_ctx, AVPacket *pkt) printf("pos=%"PRId64"\n" , pkt->pos); printf("flags=%c\n" , pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_'); printf("[/PACKET]\n"); + fflush(stdout); } static void show_packets(AVFormatContext *fmt_ctx) @@ -231,6 +232,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) printf("TAG:%s=%s\n", tag->key, tag->value); printf("[/STREAM]\n"); + fflush(stdout); } static void show_format(AVFormatContext *fmt_ctx) @@ -257,6 +259,7 @@ static void show_format(AVFormatContext *fmt_ctx) printf("TAG:%s=%s\n", tag->key, tag->value); printf("[/FORMAT]\n"); + fflush(stdout); } static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) From 21a19b7912fe0622f3d1748ff102fcc7bc7a974a Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 1 Jul 2011 15:32:21 +0200 Subject: [PATCH 206/780] doxygen: Prefer member groups over grouping into modules Before this, almost all module groups have been used for grouping functions and fields in structures semantically. This causes them to not appear properly in the file documentation and needlessly clutters up the "Modules" index. Additionally, this commit streamlines some spelling and appearances. --- libavcodec/aac.h | 9 +-- libavcodec/ac3.h | 4 +- libavcodec/ac3dec.h | 30 ++++---- libavcodec/amrnbdec.c | 16 ++--- libavcodec/apedec.c | 2 +- libavcodec/ass.h | 3 +- libavcodec/avcodec.h | 4 +- libavcodec/h264.h | 2 +- libavcodec/qcelpdata.h | 4 +- libavcodec/rv34.c | 155 ++++++++++++++++++++-------------------- libavcodec/rv40data.h | 2 +- libavcodec/sbr.h | 8 +-- libavcodec/tableprint.h | 2 +- libavcodec/vc1.c | 2 +- libavcodec/vc1dec.c | 6 +- libavcodec/wmavoice.c | 22 +++--- libavformat/avio.h | 12 ++-- libavformat/rtmppkt.h | 2 +- libavutil/lzo.h | 2 +- 19 files changed, 143 insertions(+), 144 deletions(-) diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 76b6a7821b..4861ec0320 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -258,7 +258,7 @@ typedef struct { DynamicRangeControl che_drc; /** - * @defgroup elements Channel element related data. + * @name Channel element related data * @{ */ enum ChannelPosition che_pos[4][MAX_ELEM_ID]; /**< channel element channel mapping with the @@ -270,14 +270,15 @@ typedef struct { /** @} */ /** - * @defgroup temporary aligned temporary buffers (We do not want to have these on the stack.) + * @name temporary aligned temporary buffers + * (We do not want to have these on the stack.) * @{ */ DECLARE_ALIGNED(32, float, buf_mdct)[1024]; /** @} */ /** - * @defgroup tables Computed / set up during initialization. + * @name Computed / set up during initialization * @{ */ FFTContext mdct; @@ -289,7 +290,7 @@ typedef struct { /** @} */ /** - * @defgroup output Members used for output interleaving. + * @name Members used for output interleaving * @{ */ float *output_data[MAX_CHANNELS]; ///< Points to each element's 'ret' buffer (PCM output). diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h index c06f3d542d..9adad93db8 100644 --- a/libavcodec/ac3.h +++ b/libavcodec/ac3.h @@ -92,7 +92,7 @@ typedef struct AC3BitAllocParameters { * Coded AC-3 header values up to the lfeon element, plus derived values. */ typedef struct { - /** @defgroup coded Coded elements + /** @name Coded elements * @{ */ uint16_t sync_word; @@ -110,7 +110,7 @@ typedef struct { int num_blocks; ///< number of audio blocks /** @} */ - /** @defgroup derived Derived values + /** @name Derived values * @{ */ uint8_t sr_shift; diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h index 590bee6b6d..aed87432f5 100644 --- a/libavcodec/ac3dec.h +++ b/libavcodec/ac3dec.h @@ -67,7 +67,7 @@ typedef struct { GetBitContext gbc; ///< bitstream reader uint8_t *input_buffer; ///< temp buffer to prevent overread -///@defgroup bsi bit stream information +///@name Bit stream information ///@{ int frame_type; ///< frame type (strmtyp) int substreamid; ///< substream identification @@ -85,7 +85,7 @@ typedef struct { int eac3; ///< indicates if current frame is E-AC-3 ///@} -///@defgroup audfrm frame syntax parameters +///@name Frame syntax parameters int snr_offset_strategy; ///< SNR offset strategy (snroffststr) int block_switch_syntax; ///< block switch syntax enabled (blkswe) int dither_flag_syntax; ///< dither flag syntax enabled (dithflage) @@ -95,7 +95,7 @@ typedef struct { int skip_syntax; ///< skip field syntax enabled (skipflde) ///@} -///@defgroup cpl standard coupling +///@name Standard coupling int cpl_in_use[AC3_MAX_BLOCKS]; ///< coupling in use (cplinu) int cpl_strategy_exists[AC3_MAX_BLOCKS];///< coupling strategy exists (cplstre) int channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl) @@ -108,7 +108,7 @@ typedef struct { int cpl_coords[AC3_MAX_CHANNELS][AC3_MAX_CPL_BANDS]; ///< coupling coordinates (cplco) ///@} -///@defgroup spx spectral extension +///@name Spectral extension ///@{ int spx_in_use; ///< spectral extension in use (spxinu) uint8_t channel_uses_spx[AC3_MAX_CHANNELS]; ///< channel uses spectral extension (chinspx) @@ -124,12 +124,12 @@ typedef struct { float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];///< spx signal blending factor (sblendfact) ///@} -///@defgroup aht adaptive hybrid transform +///@name Adaptive hybrid transform int channel_uses_aht[AC3_MAX_CHANNELS]; ///< channel AHT in use (chahtinu) int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS]; ///< pre-IDCT mantissas ///@} -///@defgroup channel channel +///@name Channel int fbw_channels; ///< number of full-bandwidth channels int channels; ///< number of total channels int lfe_ch; ///< index of LFE channel @@ -139,27 +139,27 @@ typedef struct { int out_channels; ///< number of output channels ///@} -///@defgroup dynrng dynamic range +///@name Dynamic range float dynamic_range[2]; ///< dynamic range ///@} -///@defgroup bandwidth bandwidth +///@name Bandwidth int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin (strtmant) int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant) ///@} -///@defgroup rematrixing rematrixing +///@name Rematrixing int num_rematrixing_bands; ///< number of rematrixing bands (nrematbnd) int rematrixing_flags[4]; ///< rematrixing flags (rematflg) ///@} -///@defgroup exponents exponents +///@name Exponents int num_exp_groups[AC3_MAX_CHANNELS]; ///< Number of exponent groups (nexpgrp) int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< decoded exponents int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]; ///< exponent strategies (expstr) ///@} -///@defgroup bitalloc bit allocation +///@name Bit allocation AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters int first_cpl_leak; ///< first coupling leak state (firstcplleak) int snr_offset[AC3_MAX_CHANNELS]; ///< signal-to-noise ratio offsets (snroffst) @@ -175,25 +175,25 @@ typedef struct { uint8_t dba_values[AC3_MAX_CHANNELS][8]; ///< delta values for each segment ///@} -///@defgroup dithering zero-mantissa dithering +///@name Zero-mantissa dithering int dither_flag[AC3_MAX_CHANNELS]; ///< dither flags (dithflg) AVLFG dith_state; ///< for dither generation ///@} -///@defgroup imdct IMDCT +///@name IMDCT int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags (blksw) FFTContext imdct_512; ///< for 512 sample IMDCT FFTContext imdct_256; ///< for 256 sample IMDCT ///@} -///@defgroup opt optimization +///@name Optimization DSPContext dsp; ///< for optimization AC3DSPContext ac3dsp; FmtConvertContext fmt_conv; ///< optimized conversion functions float mul_bias; ///< scaling for float_to_int16 conversion ///@} -///@defgroup arrays aligned arrays +///@name Aligned arrays DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< fixed-point transform coefficients DECLARE_ALIGNED(32, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< transform coefficients DECLARE_ALIGNED(32, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< delay - added to the next block diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index 4e24e26d68..1c90aadb12 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -204,7 +204,7 @@ static enum Mode unpack_bitstream(AMRContext *p, const uint8_t *buf, } -/// @defgroup amr_lpc_decoding AMR pitch LPC coefficient decoding functions +/// @name AMR pitch LPC coefficient decoding functions /// @{ /** @@ -341,7 +341,7 @@ static void lsf2lsp_3(AMRContext *p) /// @} -/// @defgroup amr_pitch_vector_decoding AMR pitch vector decoding functions +/// @name AMR pitch vector decoding functions /// @{ /** @@ -403,7 +403,7 @@ static void decode_pitch_vector(AMRContext *p, /// @} -/// @defgroup amr_algebraic_code_book AMR algebraic code book (fixed) vector decoding functions +/// @name AMR algebraic code book (fixed) vector decoding functions /// @{ /** @@ -547,7 +547,7 @@ static void pitch_sharpening(AMRContext *p, int subframe, enum Mode mode, /// @} -/// @defgroup amr_gain_decoding AMR gain decoding functions +/// @name AMR gain decoding functions /// @{ /** @@ -633,7 +633,7 @@ static void decode_gains(AMRContext *p, const AMRNBSubframe *amr_subframe, /// @} -/// @defgroup amr_pre_processing AMR pre-processing functions +/// @name AMR preprocessing functions /// @{ /** @@ -751,7 +751,7 @@ static const float *anti_sparseness(AMRContext *p, AMRFixed *fixed_sparse, /// @} -/// @defgroup amr_synthesis AMR synthesis functions +/// @name AMR synthesis functions /// @{ /** @@ -812,7 +812,7 @@ static int synthesis(AMRContext *p, float *lpc, /// @} -/// @defgroup amr_update AMR update functions +/// @name AMR update functions /// @{ /** @@ -837,7 +837,7 @@ static void update_state(AMRContext *p) /// @} -/// @defgroup amr_postproc AMR Post processing functions +/// @name AMR Postprocessing functions /// @{ /** diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index d5a7efd94d..f92b37527e 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -217,7 +217,7 @@ static av_cold int ape_decode_close(AVCodecContext * avctx) } /** - * @defgroup rangecoder APE range decoder + * @name APE range decoding functions * @{ */ diff --git a/libavcodec/ass.h b/libavcodec/ass.h index d350cf3fc2..594b5f3ac6 100644 --- a/libavcodec/ass.h +++ b/libavcodec/ass.h @@ -25,8 +25,7 @@ #include "avcodec.h" /** - * Default values for ASS style. - * @defgroup ass_default + * @name Default values for ASS style * @{ */ #define ASS_DEFAULT_FONT "Arial" diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 1a45009968..45785e4d82 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2488,7 +2488,7 @@ typedef struct AVCodecContext { #if FF_API_FLAC_GLOBAL_OPTS /** - * @defgroup flac_opts FLAC options + * @name FLAC options * @deprecated Use FLAC encoder private options instead. * @{ */ @@ -2897,7 +2897,7 @@ typedef struct AVCodec { const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} /** - * @defgroup framethreading Frame-level threading support functions. + * @name Frame-level threading support functions * @{ */ /** diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 3abf895010..e3cc815565 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -507,7 +507,7 @@ typedef struct H264Context{ int cabac_init_idc; /** - * @defgroup multithreading Members for slice based multithreading + * @name Members for slice based multithreading * @{ */ struct H264Context *thread_context[MAX_THREADS]; diff --git a/libavcodec/qcelpdata.h b/libavcodec/qcelpdata.h index 457e856fa3..5822299348 100644 --- a/libavcodec/qcelpdata.h +++ b/libavcodec/qcelpdata.h @@ -38,14 +38,14 @@ * QCELP unpacked data frame */ typedef struct { -/// @defgroup qcelp_codebook_parameters QCELP excitation codebook parameters +/// @name QCELP excitation codebook parameters /// @{ uint8_t cbsign[16]; ///!< sign of the codebook gain for each codebook subframe uint8_t cbgain[16]; ///!< unsigned codebook gain for each codebook subframe uint8_t cindex[16]; ///!< codebook index for each codebook subframe /// @} -/// @defgroup qcelp_pitch_parameters QCELP pitch prediction parameters +/// @name QCELP pitch prediction parameters /// @{ uint8_t plag[4]; ///!< pitch lag for each pitch subframe uint8_t pfrac[4]; ///!< fractional pitch lag for each pitch subframe diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index b5d314cf0f..c5dcfdcba4 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -62,8 +62,10 @@ static const int rv34_mb_type_to_lavc[12] = { static RV34VLC intra_vlcs[NUM_INTRA_TABLES], inter_vlcs[NUM_INTER_TABLES]; +static int rv34_decode_mv(RV34DecContext *r, int block_type); + /** - * @defgroup vlc RV30/40 VLC generating functions + * @name RV30/40 VLC generating functions * @{ */ @@ -171,7 +173,7 @@ static av_cold void rv34_init_tables(void) /** - * @defgroup transform RV30/40 inverse transform functions + * @name RV30/40 inverse transform functions * @{ */ @@ -246,7 +248,7 @@ static void rv34_inv_transform_noround(DCTELEM *block){ /** - * @defgroup block RV30/40 4x4 block decoding functions + * @name RV30/40 4x4 block decoding functions * @{ */ @@ -393,7 +395,7 @@ static inline void rv34_dequant4x4_16x16(DCTELEM *block, int Qdc, int Q) /** - * @defgroup rv3040_bitstream RV30/40 bitstream parsing + * @name RV30/40 bitstream parsing * @{ */ @@ -432,10 +434,76 @@ static inline int rv34_decode_dquant(GetBitContext *gb, int quant) return get_bits(gb, 5); } +/** + * Decode macroblock header and return CBP in case of success, -1 otherwise. + */ +static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types) +{ + MpegEncContext *s = &r->s; + GetBitContext *gb = &s->gb; + int mb_pos = s->mb_x + s->mb_y * s->mb_stride; + int i, t; + + if(!r->si.type){ + r->is16 = get_bits1(gb); + if(!r->is16 && !r->rv30){ + if(!get_bits1(gb)) + av_log(s->avctx, AV_LOG_ERROR, "Need DQUANT\n"); + } + s->current_picture_ptr->mb_type[mb_pos] = r->is16 ? MB_TYPE_INTRA16x16 : MB_TYPE_INTRA; + r->block_type = r->is16 ? RV34_MB_TYPE_INTRA16x16 : RV34_MB_TYPE_INTRA; + }else{ + r->block_type = r->decode_mb_info(r); + if(r->block_type == -1) + return -1; + s->current_picture_ptr->mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type]; + r->mb_type[mb_pos] = r->block_type; + if(r->block_type == RV34_MB_SKIP){ + if(s->pict_type == AV_PICTURE_TYPE_P) + r->mb_type[mb_pos] = RV34_MB_P_16x16; + if(s->pict_type == AV_PICTURE_TYPE_B) + r->mb_type[mb_pos] = RV34_MB_B_DIRECT; + } + r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->mb_type[mb_pos]); + rv34_decode_mv(r, r->block_type); + if(r->block_type == RV34_MB_SKIP){ + fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0])); + return 0; + } + r->chroma_vlc = 1; + r->luma_vlc = 0; + } + if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])){ + if(r->is16){ + t = get_bits(gb, 2); + fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0])); + r->luma_vlc = 2; + }else{ + if(r->decode_intra_types(r, gb, intra_types) < 0) + return -1; + r->luma_vlc = 1; + } + r->chroma_vlc = 0; + r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); + }else{ + for(i = 0; i < 16; i++) + intra_types[(i & 3) + (i>>2) * r->intra_types_stride] = 0; + r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); + if(r->mb_type[mb_pos] == RV34_MB_P_MIX16x16){ + r->is16 = 1; + r->chroma_vlc = 1; + r->luma_vlc = 2; + r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); + } + } + + return rv34_decode_cbp(gb, r->cur_vlcs, r->is16); +} + /** @} */ //bitstream functions /** - * @defgroup mv motion vector related code (prediction, reconstruction, motion compensation) + * @name motion vector related code (prediction, reconstruction, motion compensation) * @{ */ @@ -885,7 +953,7 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type) /** @} */ // mv group /** - * @defgroup recons Macroblock reconstruction functions + * @name Macroblock reconstruction functions * @{ */ /** mapping of RV30/40 intra prediction types to standard H.264 types */ @@ -1027,79 +1095,6 @@ static void rv34_output_macroblock(RV34DecContext *r, int8_t *intra_types, int c } } -/** @} */ // recons group - -/** - * @addtogroup bitstream - * Decode macroblock header and return CBP in case of success, -1 otherwise. - */ -static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types) -{ - MpegEncContext *s = &r->s; - GetBitContext *gb = &s->gb; - int mb_pos = s->mb_x + s->mb_y * s->mb_stride; - int i, t; - - if(!r->si.type){ - r->is16 = get_bits1(gb); - if(!r->is16 && !r->rv30){ - if(!get_bits1(gb)) - av_log(s->avctx, AV_LOG_ERROR, "Need DQUANT\n"); - } - s->current_picture_ptr->mb_type[mb_pos] = r->is16 ? MB_TYPE_INTRA16x16 : MB_TYPE_INTRA; - r->block_type = r->is16 ? RV34_MB_TYPE_INTRA16x16 : RV34_MB_TYPE_INTRA; - }else{ - r->block_type = r->decode_mb_info(r); - if(r->block_type == -1) - return -1; - s->current_picture_ptr->mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type]; - r->mb_type[mb_pos] = r->block_type; - if(r->block_type == RV34_MB_SKIP){ - if(s->pict_type == AV_PICTURE_TYPE_P) - r->mb_type[mb_pos] = RV34_MB_P_16x16; - if(s->pict_type == AV_PICTURE_TYPE_B) - r->mb_type[mb_pos] = RV34_MB_B_DIRECT; - } - r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->mb_type[mb_pos]); - rv34_decode_mv(r, r->block_type); - if(r->block_type == RV34_MB_SKIP){ - fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0])); - return 0; - } - r->chroma_vlc = 1; - r->luma_vlc = 0; - } - if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])){ - if(r->is16){ - t = get_bits(gb, 2); - fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0])); - r->luma_vlc = 2; - }else{ - if(r->decode_intra_types(r, gb, intra_types) < 0) - return -1; - r->luma_vlc = 1; - } - r->chroma_vlc = 0; - r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); - }else{ - for(i = 0; i < 16; i++) - intra_types[(i & 3) + (i>>2) * r->intra_types_stride] = 0; - r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); - if(r->mb_type[mb_pos] == RV34_MB_P_MIX16x16){ - r->is16 = 1; - r->chroma_vlc = 1; - r->luma_vlc = 2; - r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); - } - } - - return rv34_decode_cbp(gb, r->cur_vlcs, r->is16); -} - -/** - * @addtogroup recons - * @{ - */ /** * mask for retrieving all bits in coded block pattern * corresponding to one 8x8 block @@ -1109,6 +1104,8 @@ static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types) #define U_CBP_MASK 0x0F0000 #define V_CBP_MASK 0xF00000 +/** @} */ // recons group + static void rv34_apply_differences(RV34DecContext *r, int cbp) { diff --git a/libavcodec/rv40data.h b/libavcodec/rv40data.h index 4787075742..1b6e8c31b1 100644 --- a/libavcodec/rv40data.h +++ b/libavcodec/rv40data.h @@ -65,7 +65,7 @@ static const uint8_t rv40_luma_dc_quant[2][32] = { }; /** - * @defgroup loopfilter coefficients used by the RV40 loop filter + * @name Coefficients used by the RV40 loop filter * @{ */ /** diff --git a/libavcodec/sbr.h b/libavcodec/sbr.h index cbf3e23e6b..5b0f334219 100644 --- a/libavcodec/sbr.h +++ b/libavcodec/sbr.h @@ -42,7 +42,7 @@ typedef struct { uint8_t bs_xover_band; /** - * @defgroup bs_header_extra_1 Variables associated with bs_header_extra_1 + * @name Variables associated with bs_header_extra_1 * @{ */ uint8_t bs_freq_scale; @@ -58,7 +58,7 @@ typedef struct { */ typedef struct { /** - * @defgroup aac_bitstream Main bitstream data variables + * @name Main bitstream data variables * @{ */ unsigned bs_frame_class; @@ -74,7 +74,7 @@ typedef struct { /** @} */ /** - * @defgroup state State variables + * @name State variables * @{ */ DECLARE_ALIGNED(16, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE]; @@ -116,7 +116,7 @@ typedef struct { SpectrumParameters spectrum_params; int bs_amp_res_header; /** - * @defgroup bs_header_extra_2 variables associated with bs_header_extra_2 + * @name Variables associated with bs_header_extra_2 * @{ */ unsigned bs_limiter_bands; diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index f6c72fe716..6f46a7cc8a 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -56,7 +56,7 @@ void write_##type##_2d_array(const void *arg, int len, int len2)\ } /** - * @defgroup printfuncs Predefined functions for printing tables + * @name Predefined functions for printing tables * * \{ */ diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 7b878c18d7..32869b97d1 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -40,7 +40,7 @@ /***********************************************************************/ /** - * @defgroup vc1bitplane VC-1 Bitplane decoding + * @name VC-1 Bitplane decoding * @see 8.7, p56 * @{ */ diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 186610ea95..8fca2da738 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -137,7 +137,7 @@ static int vc1_init_common(VC1Context *v) /***********************************************************************/ /** - * @defgroup vc1bitplane VC-1 Bitplane decoding + * @name VC-1 Bitplane decoding * @see 8.7, p56 * @{ */ @@ -774,7 +774,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v) /***********************************************************************/ /** - * @defgroup vc1block VC-1 Block-level functions + * @name VC-1 Block-level functions * @see 7.1.4, p91 and 8.1.1.7, p(1)04 * @{ */ @@ -1512,7 +1512,7 @@ static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, /** @} */ // Block group /** - * @defgroup vc1_std_mb VC1 Macroblock-level functions in Simple/Main Profiles + * @name VC1 Macroblock-level functions in Simple/Main Profiles * @see 7.1.4, p91 and 8.1.1.7, p(1)04 * @{ */ diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 4e69b83b32..eb3bcb0629 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -128,9 +128,7 @@ static const struct frame_type_desc { */ typedef struct { /** - * @defgroup struct_global Global values - * Global values, specified in the stream header / extradata or used - * all over. + * @name Global values specified in the stream header / extradata or used all over. * @{ */ GetBitContext gb; ///< packet bitreader. During decoder init, @@ -182,8 +180,9 @@ typedef struct { /** * @} - * @defgroup struct_packet Packet values - * Packet values, specified in the packet header or related to a packet. + * + * @name Packet values specified in the packet header or related to a packet. + * * A packet is considered to be a single unit of data provided to this * decoder by the demuxer. * @{ @@ -213,7 +212,8 @@ typedef struct { /** * @} - * @defgroup struct_frame Frame and superframe values + * + * @name Frame and superframe values * Superframe and frame data - these can change from frame to frame, * although some of them do in that case serve as a cache / history for * the next frame or superframe. @@ -256,7 +256,9 @@ typedef struct { float synth_history[MAX_LSPS]; ///< see #excitation_history /** * @} - * @defgroup post_filter Postfilter values + * + * @name Postfilter values + * * Variables used for postfilter implementation, mostly history for * smoothing and so on, and context variables for FFT/iFFT. * @{ @@ -432,7 +434,7 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) } /** - * @defgroup postfilter Postfilter functions + * @name Postfilter functions * Postfilter functions (gain control, wiener denoise filter, DC filter, * kalman smoothening, plus surrounding code to wrap it) * @{ @@ -825,7 +827,7 @@ static void dequant_lsps(double *lsps, int num, } /** - * @defgroup lsp_dequant LSP dequantization routines + * @name LSP dequantization routines * LSP dequantization routines, for 10/16LSPs and independent/residual coding. * @note we assume enough bits are available, caller should check. * lsp10i() consumes 24 bits; lsp10r() consumes an additional 24 bits; @@ -969,7 +971,7 @@ static void dequant_lsp16r(GetBitContext *gb, /** * @} - * @defgroup aw Pitch-adaptive window coding functions + * @name Pitch-adaptive window coding functions * The next few functions are for pitch-adaptive window coding. * @{ */ diff --git a/libavformat/avio.h b/libavformat/avio.h index bb2d9f85a6..be14e3c89d 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -145,7 +145,7 @@ typedef struct URLPollEntry { attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout); /** - * @defgroup open_modes URL open modes + * @name URL open modes * The flags argument to url_open and cosins must be one of the following * constants, optionally ORed with other flags. * @{ @@ -176,7 +176,7 @@ extern URLInterruptCB *url_interrupt_cb; /** * @defgroup old_url_funcs Old url_* functions - * @deprecated use the buffered API based on AVIOContext instead + * The following functions are deprecated. Use the buffered API based on #AVIOContext instead. * @{ */ attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up, @@ -235,7 +235,7 @@ attribute_deprecated AVIOContext *av_alloc_put_byte( /** * @defgroup old_avio_funcs Old put_/get_*() functions - * @deprecated use the avio_ -prefixed functions instead. + * The following functions are deprecated. Use the "avio_"-prefixed functions instead. * @{ */ attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size); @@ -272,7 +272,7 @@ attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h, int stream_in /** * @defgroup old_url_f_funcs Old url_f* functions - * @deprecated use the avio_ -prefixed functions instead. + * The following functions are deprecated, use the "avio_"-prefixed functions instead. * @{ */ attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags); @@ -471,7 +471,7 @@ void avio_flush(AVIOContext *s); int avio_read(AVIOContext *s, unsigned char *buf, int size); /** - * @defgroup avio_read Functions for reading from AVIOContext. + * @name Functions for reading from AVIOContext * @{ * * @note return 0 if EOF, so you cannot use it if EOF handling is @@ -515,7 +515,7 @@ int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); /** - * @defgroup open_modes URL open modes + * @name URL open modes * The flags argument to avio_open must be one of the following * constants, optionally ORed with other flags. * @{ diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h index bb3475811e..8372484fbd 100644 --- a/libavformat/rtmppkt.h +++ b/libavformat/rtmppkt.h @@ -138,7 +138,7 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *p, void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p); /** - * @defgroup amffuncs functions used to work with AMF format (which is also used in .flv) + * @name Functions used to work with the AMF format (which is also used in .flv) * @see amf_* funcs in libavformat/flvdec.c * @{ */ diff --git a/libavutil/lzo.h b/libavutil/lzo.h index 41ee6b1d67..be86bba6bc 100644 --- a/libavutil/lzo.h +++ b/libavutil/lzo.h @@ -24,7 +24,7 @@ #include -/** @defgroup errflags Error flags returned by av_lzo1x_decode +/** @name Error flags returned by av_lzo1x_decode * \{ */ //! end of the input buffer reached before decoding finished #define AV_LZO_INPUT_DEPLETED 1 From 12489443dec228d60fa3dc56695f6ddae08beb37 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Fri, 1 Jul 2011 20:50:33 +0200 Subject: [PATCH 207/780] libavformat: Add an example how to use the metadata API Also include it into the doxygen documentation --- libavformat/Makefile | 2 +- libavformat/avformat.h | 2 ++ libavformat/metadata-example.c | 56 ++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 libavformat/metadata-example.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 3d22c6f265..a20db26b03 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -333,7 +333,7 @@ OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o # libavdevice dependencies OBJS-$(CONFIG_JACK_INDEV) += timefilter.o -EXAMPLES = output +EXAMPLES = metadata output TESTPROGS = timefilter include $(SRC_PATH)/subdir.mak diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 05e80f1922..8561a50c01 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -109,6 +109,8 @@ struct AVFormatContext; variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of @endverbatim * + * Look in the examples section for an application example how to use the Metadata API. + * * @} */ diff --git a/libavformat/metadata-example.c b/libavformat/metadata-example.c new file mode 100644 index 0000000000..7bf77e7378 --- /dev/null +++ b/libavformat/metadata-example.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011 Reinhard Tartler + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * @file + * @example libavformat/metadata-example.c + * Shows how the metadata API can be used in application programs. + */ + +#include + +#include +#include + +int main (int argc, char **argv) +{ + AVFormatContext *fmt_ctx = NULL; + AVDictionaryEntry *tag = NULL; + int ret; + + if (argc != 2) { + printf("usage: %s \n" + "example program to demonstrate the use of the libavformat metadata API.\n" + "\n", argv[0]); + return 1; + } + + av_register_all(); + if ((ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL))) + return ret; + + while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) + printf("%s=%s\n", tag->key, tag->value); + + avformat_free_context(fmt_ctx); + return 0; +} From 2b550beb2299e30d5fc13596c619457c13b49d5f Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 15:06:02 +0200 Subject: [PATCH 208/780] vf_lut: add plane validity check in draw_slice() The value for inpic->data[plane] with plane >=4 is undefined, and it will contain in general random data. This change adds a check for exiting the loop when plane reaches the value 4. Fix crash (occurring for example with: format=rgba,lut). --- libavfilter/vf_lut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index 8607ee906c..b74aa235bc 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -319,7 +319,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) } } else { /* planar */ - for (plane = 0; inpic->data[plane]; plane++) { + for (plane = 0; plane < 4 && inpic->data[plane]; plane++) { int vsub = plane == 1 || plane == 2 ? lut->vsub : 0; int hsub = plane == 1 || plane == 2 ? lut->hsub : 0; From 59bd0fef6691f5b23eebbd7dd2f3e74c8d60c6a7 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 15:23:56 +0200 Subject: [PATCH 209/780] vf_lut: set minimum and maximum alpha value for yuva420p --- libavfilter/vf_lut.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index b74aa235bc..a1f93ffc91 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -229,6 +229,7 @@ static int config_props(AVFilterLink *inlink) min[Y] = min[U] = min[V] = 16; max[Y] = 235; max[U] = max[V] = 240; + min[A] = 0; max[A] = 255; break; default: min[0] = min[1] = min[2] = min[3] = 0; From 30b05520c8b1d1574d7b62dee59776b50d231590 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 1 Jul 2011 16:35:37 +0100 Subject: [PATCH 210/780] put_bits: always use intreadwrite.h macros This fixes invalid unaligned stores in some ARM configurations. Signed-off-by: Mans Rullgard --- libavcodec/put_bits.h | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index 3849e6d339..b91e0f8f5a 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -70,8 +70,7 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_s s->buf_end = s->buf + buffer_size; #ifdef ALT_BITSTREAM_WRITER s->index=0; - ((uint32_t*)(s->buf))[0]=0; -// memset(buffer, 0, buffer_size); + AV_ZERO32(s->buf); #else s->buf_ptr = s->buf; s->bit_left=32; @@ -164,12 +163,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) #ifdef BITSTREAM_WRITER_LE bit_buf |= value << (32 - bit_left); if (n >= bit_left) { -#if !HAVE_FAST_UNALIGNED - if (3 & (intptr_t) s->buf_ptr) { - AV_WL32(s->buf_ptr, bit_buf); - } else -#endif - *(uint32_t *)s->buf_ptr = av_le2ne32(bit_buf); + AV_WL32(s->buf_ptr, bit_buf); s->buf_ptr+=4; bit_buf = (bit_left==32)?0:value >> bit_left; bit_left+=32; @@ -182,12 +176,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) } else { bit_buf<<=bit_left; bit_buf |= value >> (n - bit_left); -#if !HAVE_FAST_UNALIGNED - if (3 & (intptr_t) s->buf_ptr) { - AV_WB32(s->buf_ptr, bit_buf); - } else -#endif - *(uint32_t *)s->buf_ptr = av_be2ne32(bit_buf); + AV_WB32(s->buf_ptr, bit_buf); //printf("bitbuf = %08x\n", bit_buf); s->buf_ptr+=4; bit_left+=32 - n; From 0d5c349ac45a22da4944f5e7447d98c154590d24 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 2 Jul 2011 11:50:24 +0100 Subject: [PATCH 211/780] put_bits: remove ALT_BITSTREAM_WRITER The code for this variant does not compile. Signed-off-by: Mans Rullgard --- libavcodec/bitstream.c | 4 -- libavcodec/mpegvideo_enc.c | 2 - libavcodec/put_bits.h | 102 +------------------------------------ 3 files changed, 1 insertion(+), 107 deletions(-) diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 17b1c69c84..70717883c1 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -43,11 +43,7 @@ const uint8_t ff_log2_run[41]={ void align_put_bits(PutBitContext *s) { -#ifdef ALT_BITSTREAM_WRITER - put_bits(s,( - s->index) & 7,0); -#else put_bits(s,s->bit_left & 7,0); -#endif } void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index f3885626c1..cd13a5cd2b 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2170,9 +2170,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ int d= 100 / s->avctx->error_rate; if(r % d == 0){ current_packet_size=0; -#ifndef ALT_BITSTREAM_WRITER s->pb.buf_ptr= s->ptr_lastgob; -#endif assert(put_bits_ptr(&s->pb) == s->ptr_lastgob); } } diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index b91e0f8f5a..c10dd818f0 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -36,19 +36,10 @@ #include "mathops.h" #include "config.h" -//#define ALT_BITSTREAM_WRITER -//#define ALIGNED_BITSTREAM_WRITER - -/* buf and buf_end must be present and used by every alternative writer. */ typedef struct PutBitContext { -#ifdef ALT_BITSTREAM_WRITER - uint8_t *buf, *buf_end; - int index; -#else uint32_t bit_buf; int bit_left; uint8_t *buf, *buf_ptr, *buf_end; -#endif int size_in_bits; } PutBitContext; @@ -68,14 +59,9 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_s s->size_in_bits= 8*buffer_size; s->buf = buffer; s->buf_end = s->buf + buffer_size; -#ifdef ALT_BITSTREAM_WRITER - s->index=0; - AV_ZERO32(s->buf); -#else s->buf_ptr = s->buf; s->bit_left=32; s->bit_buf=0; -#endif } /** @@ -83,11 +69,7 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_s */ static inline int put_bits_count(PutBitContext *s) { -#ifdef ALT_BITSTREAM_WRITER - return s->index; -#else return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left; -#endif } /** @@ -95,9 +77,6 @@ static inline int put_bits_count(PutBitContext *s) */ static inline void flush_put_bits(PutBitContext *s) { -#ifdef ALT_BITSTREAM_WRITER - align_put_bits(s); -#else #ifndef BITSTREAM_WRITER_LE s->bit_buf<<= s->bit_left; #endif @@ -114,10 +93,9 @@ static inline void flush_put_bits(PutBitContext *s) } s->bit_left=32; s->bit_buf=0; -#endif } -#if defined(ALT_BITSTREAM_WRITER) || defined(BITSTREAM_WRITER_LE) +#ifdef BITSTREAM_WRITER_LE #define align_put_bits align_put_bits_unsupported_here #define ff_put_string ff_put_string_unsupported_here #define ff_copy_bits ff_copy_bits_unsupported_here @@ -147,7 +125,6 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); * Use put_bits32 to write 32 bits. */ static inline void put_bits(PutBitContext *s, int n, unsigned int value) -#ifndef ALT_BITSTREAM_WRITER { unsigned int bit_buf; int bit_left; @@ -187,70 +164,6 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) s->bit_buf = bit_buf; s->bit_left = bit_left; } -#else /* ALT_BITSTREAM_WRITER defined */ -{ -# ifdef ALIGNED_BITSTREAM_WRITER -# if ARCH_X86 - __asm__ volatile( - "movl %0, %%ecx \n\t" - "xorl %%eax, %%eax \n\t" - "shrdl %%cl, %1, %%eax \n\t" - "shrl %%cl, %1 \n\t" - "movl %0, %%ecx \n\t" - "shrl $3, %%ecx \n\t" - "andl $0xFFFFFFFC, %%ecx \n\t" - "bswapl %1 \n\t" - "orl %1, (%2, %%ecx) \n\t" - "bswapl %%eax \n\t" - "addl %3, %0 \n\t" - "movl %%eax, 4(%2, %%ecx) \n\t" - : "=&r" (s->index), "=&r" (value) - : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n)) - : "%eax", "%ecx" - ); -# else - int index= s->index; - uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5); - - value<<= 32-n; - - ptr[0] |= av_be2ne32(value>>(index&31)); - ptr[1] = av_be2ne32(value<<(32-(index&31))); -//if(n>24) printf("%d %d\n", n, value); - index+= n; - s->index= index; -# endif -# else //ALIGNED_BITSTREAM_WRITER -# if ARCH_X86 - __asm__ volatile( - "movl $7, %%ecx \n\t" - "andl %0, %%ecx \n\t" - "addl %3, %%ecx \n\t" - "negl %%ecx \n\t" - "shll %%cl, %1 \n\t" - "bswapl %1 \n\t" - "movl %0, %%ecx \n\t" - "shrl $3, %%ecx \n\t" - "orl %1, (%%ecx, %2) \n\t" - "addl %3, %0 \n\t" - "movl $0, 4(%%ecx, %2) \n\t" - : "=&r" (s->index), "=&r" (value) - : "r" (s->buf), "r" (n), "0" (s->index), "1" (value) - : "%ecx" - ); -# else - int index= s->index; - uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3)); - - ptr[0] |= av_be2ne32(value<<(32-n-(index&7) )); - ptr[1] = 0; -//if(n>24) printf("%d %d\n", n, value); - index+= n; - s->index= index; -# endif -# endif //!ALIGNED_BITSTREAM_WRITER -} -#endif static inline void put_sbits(PutBitContext *pb, int n, int32_t value) { @@ -281,11 +194,7 @@ static void av_unused put_bits32(PutBitContext *s, uint32_t value) */ static inline uint8_t* put_bits_ptr(PutBitContext *s) { -#ifdef ALT_BITSTREAM_WRITER - return s->buf + (s->index>>3); -#else return s->buf_ptr; -#endif } /** @@ -295,13 +204,8 @@ static inline uint8_t* put_bits_ptr(PutBitContext *s) static inline void skip_put_bytes(PutBitContext *s, int n) { assert((put_bits_count(s)&7)==0); -#ifdef ALT_BITSTREAM_WRITER - FIXME may need some cleaning of the buffer - s->index += n<<3; -#else assert(s->bit_left==32); s->buf_ptr += n; -#endif } /** @@ -311,13 +215,9 @@ static inline void skip_put_bytes(PutBitContext *s, int n) */ static inline void skip_put_bits(PutBitContext *s, int n) { -#ifdef ALT_BITSTREAM_WRITER - s->index += n; -#else s->bit_left -= n; s->buf_ptr-= 4*(s->bit_left>>5); s->bit_left &= 31; -#endif } /** From f6d6783a4df127d2ad1cf755ac4f363decbd7fbb Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 13:22:18 +0200 Subject: [PATCH 212/780] ffmpeg: use av_get_bytes_per_sample() in place of av_get_bits_per_sample_fmt() av_get_bits_per_sample_fmt() was deprecated. Signed-off-by: Ronald S. Bultje --- ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index 9f2d5b98b4..b9309aed43 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1801,7 +1801,7 @@ static int output_packet(AVInputStream *ist, int ist_index, ret = 0; /* encode any samples remaining in fifo */ if (fifo_bytes > 0) { - int osize = av_get_bits_per_sample_fmt(enc->sample_fmt) >> 3; + int osize = av_get_bytes_per_sample(enc->sample_fmt); int fs_tmp = enc->frame_size; av_fifo_generic_read(ost->fifo, audio_buf, fifo_bytes, NULL); From ccfa626db863b6019fd4c316d19d8f7018543bed Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 13:22:35 +0200 Subject: [PATCH 213/780] suggest to use av_get_bytes_per_sample() in av_get_bits_per_sample_format() doxy The previously suggested replacement - av_get_bits_per_sample_fmt() - was also deprecated. Signed-off-by: Ronald S. Bultje --- libavcodec/avcodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 45785e4d82..fbd70395c4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3847,7 +3847,7 @@ int av_get_bits_per_sample(enum CodecID codec_id); #if FF_API_OLD_SAMPLE_FMT /** - * @deprecated Use av_get_bits_per_sample_fmt() instead. + * @deprecated Use av_get_bytes_per_sample() instead. */ attribute_deprecated int av_get_bits_per_sample_format(enum AVSampleFormat sample_fmt); From 8f440223f6cb2b557ea6e34ca4079fbe415ecb9d Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 26 Jun 2011 15:52:01 -0700 Subject: [PATCH 214/780] swscale: disable full_chroma_int when converting to non-24/32bpp RGB. This functionality is only implemented for RGB24/32 and causes crashes otherwise. --- libswscale/utils.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libswscale/utils.c b/libswscale/utils.c index eea32a130a..9f0bb7a8b9 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -845,6 +845,19 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat); // reuse chroma for 2 pixels RGB/BGR unless user wants full chroma interpolation + if (flags & SWS_FULL_CHR_H_INT && + dstFormat != PIX_FMT_RGBA && + dstFormat != PIX_FMT_ARGB && + dstFormat != PIX_FMT_BGRA && + dstFormat != PIX_FMT_ABGR && + dstFormat != PIX_FMT_RGB24 && + dstFormat != PIX_FMT_BGR24) { + av_log(c, AV_LOG_ERROR, + "full chroma interpolation for destination format '%s' not yet implemented\n", + sws_format_name(dstFormat)); + flags &= ~SWS_FULL_CHR_H_INT; + c->flags = flags; + } if (isAnyRGB(dstFormat) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1; // drop some chroma lines if the user wants it From 8aa63f0b31544a63e107c67c519d6ccd11c94810 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 2 Jul 2011 17:21:02 +0100 Subject: [PATCH 215/780] ARM: NEON optimised vector_clip_int32() Signed-off-by: Mans Rullgard --- libavcodec/arm/dsputil_init_neon.c | 3 +++ libavcodec/arm/dsputil_neon.S | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libavcodec/arm/dsputil_init_neon.c b/libavcodec/arm/dsputil_init_neon.c index 3bc053c864..3f58dea9cd 100644 --- a/libavcodec/arm/dsputil_init_neon.c +++ b/libavcodec/arm/dsputil_init_neon.c @@ -160,6 +160,8 @@ void ff_vector_fmul_add_neon(float *dst, const float *src0, const float *src1, void ff_vector_clipf_neon(float *dst, const float *src, float min, float max, int len); +void ff_vector_clip_int32_neon(int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len); void ff_vorbis_inverse_coupling_neon(float *mag, float *ang, int blocksize); @@ -316,6 +318,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) c->vector_fmul_reverse = ff_vector_fmul_reverse_neon; c->vector_fmul_add = ff_vector_fmul_add_neon; c->vector_clipf = ff_vector_clipf_neon; + c->vector_clip_int32 = ff_vector_clip_int32_neon; c->vector_fmul_sv_scalar[0] = ff_vector_fmul_sv_scalar_2_neon; c->vector_fmul_sv_scalar[1] = ff_vector_fmul_sv_scalar_4_neon; diff --git a/libavcodec/arm/dsputil_neon.S b/libavcodec/arm/dsputil_neon.S index 5e3bf27f67..3b9b542a68 100644 --- a/libavcodec/arm/dsputil_neon.S +++ b/libavcodec/arm/dsputil_neon.S @@ -815,3 +815,19 @@ function ff_apply_window_int16_neon, export=1 pop {r4,pc} endfunc + +function ff_vector_clip_int32_neon, export=1 + vdup.32 q0, r2 + vdup.32 q1, r3 + ldr r2, [sp] +1: + vld1.32 {q2-q3}, [r1,:128]! + vmin.s32 q2, q2, q1 + vmin.s32 q3, q3, q1 + vmax.s32 q2, q2, q0 + vmax.s32 q3, q3, q0 + vst1.32 {q2-q3}, [r0,:128]! + subs r2, r2, #8 + bgt 1b + bx lr +endfunc From 5dd045ebc11933dca4d6af06e6b1e62be56802f7 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 2 Jul 2011 18:24:13 +0100 Subject: [PATCH 216/780] ARM: ac3: update ff_ac3_extract_exponents_neon per 8b7b2d6 Signed-off-by: Mans Rullgard --- libavcodec/arm/ac3dsp_neon.S | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libavcodec/arm/ac3dsp_neon.S b/libavcodec/arm/ac3dsp_neon.S index fdf1deabc9..e97197c27a 100644 --- a/libavcodec/arm/ac3dsp_neon.S +++ b/libavcodec/arm/ac3dsp_neon.S @@ -95,19 +95,14 @@ function ff_float_to_fixed24_neon, export=1 endfunc function ff_ac3_extract_exponents_neon, export=1 - vmov.i32 q14, #24 vmov.i32 q15, #8 1: - vld1.32 {q0}, [r1,:128] + vld1.32 {q0}, [r1,:128]! vabs.s32 q1, q0 vclz.i32 q3, q1 vsub.i32 q3, q3, q15 - vcge.s32 q2, q3, q14 - vbit q3, q14, q2 - vbic q0, q0, q2 vmovn.i32 d6, q3 vmovn.i16 d6, q3 - vst1.32 {q0}, [r1,:128]! vst1.32 {d6[0]}, [r0,:32]! subs r2, r2, #4 bgt 1b From af2ea724951b4b12b4522b462047eebbf9566b84 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 00:46:23 +0100 Subject: [PATCH 217/780] aes: use direct assignments instead of memcpy() or loops Signed-off-by: Mans Rullgard --- libavutil/aes.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavutil/aes.c b/libavutil/aes.c index fc6c4168cd..f3f13bfe41 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -127,7 +127,7 @@ void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_, crypt(a, 0, inv_sbox, dec_multbl); if (iv) { addkey(&a->state[0], &a->state[0], iv); - memcpy(iv, src, 16); + *iv = *src; } addkey(dst, &a->state[0], &a->round_key[0]); } else { @@ -136,7 +136,7 @@ void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_, crypt(a, 2, sbox, enc_multbl); addkey(dst, &a->state[0], &a->round_key[0]); if (iv) - memcpy(iv, dst, 16); + *iv = *dst; } src++; dst++; @@ -221,15 +221,14 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) if (decrypt) { for (i = 1; i < rounds; i++) { av_aes_block tmp[3]; - memcpy(&tmp[2], &a->round_key[i], 16); + tmp[2] = a->round_key[i]; subshift(&tmp[1], 0, sbox); mix(tmp, dec_multbl, 1, 3); - memcpy(&a->round_key[i], &tmp[0], 16); + a->round_key[i] = tmp[0]; } } else { for (i = 0; i < (rounds + 1) >> 1; i++) { - for (j = 0; j < 16; j++) - FFSWAP(int, a->round_key[i].u8[j], a->round_key[rounds-i].u8[j]); + FFSWAP(av_aes_block, a->round_key[i], a->round_key[rounds-i]); } } From 21accb3bb26c874d95796a77feeab049f6f6f80d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 02:37:31 +0100 Subject: [PATCH 218/780] h264: remove assert() immediately following return statement Signed-off-by: Mans Rullgard --- libavcodec/h264_mvpred.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h index 1359072dc8..f603e7ff38 100644 --- a/libavcodec/h264_mvpred.h +++ b/libavcodec/h264_mvpred.h @@ -64,7 +64,6 @@ static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, in if(!MB_FIELD && IS_INTERLACED(h->left_type[0])){ SET_DIAG_MV(*2, >>1, h->left_mb_xy[0]+s->mb_stride, (s->mb_y&1)*2+(i>>5)); - assert(h->left_mb_xy[0] == h->left_mb_xy[1]); } if(MB_FIELD && !IS_INTERLACED(h->left_type[0])){ From 5d20f19be25c973fe10d0d17db9245002585710d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 2 Jul 2011 22:10:25 +0100 Subject: [PATCH 219/780] aes: fix invalid array indexing in init code This makes the code work with clang/x86_32 and removes several warnings. Signed-off-by: Mans Rullgard --- libavutil/aes.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/libavutil/aes.c b/libavutil/aes.c index f3f13bfe41..8a8bfc2b25 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -54,6 +54,8 @@ static uint32_t enc_multbl[4][256]; static uint32_t dec_multbl[4][256]; #endif +#define ROT(x, s) ((x << s) | (x >> (32-s))) + static inline void addkey(av_aes_block *dst, const av_aes_block *src, const av_aes_block *round_key) { @@ -86,7 +88,6 @@ static void subshift(av_aes_block s0[2], int s, const uint8_t *box) static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){ #if CONFIG_SMALL -#define ROT(x,s) ((x<>(32-s))) return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24); #else return multbl[0][a] ^ multbl[1][b] ^ multbl[2][c] ^ multbl[3][d]; @@ -143,22 +144,29 @@ void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_, } } -static void init_multbl2(uint8_t tbl[1024], const int c[4], +static void init_multbl2(uint32_t tbl[][256], const int c[4], const uint8_t *log8, const uint8_t *alog8, const uint8_t *sbox) { - int i, j; + int i; - for (i = 0; i < 1024; i++) { - int x = sbox[i >> 2]; - if (x) - tbl[i] = alog8[log8[x] + log8[c[i & 3]]]; - } + for (i = 0; i < 256; i++) { + int x = sbox[i]; + if (x) { + int k, l, m, n; + x = log8[x]; + k = alog8[x + log8[c[0]]]; + l = alog8[x + log8[c[1]]]; + m = alog8[x + log8[c[2]]]; + n = alog8[x + log8[c[3]]]; + tbl[0][i] = AV_NE(MKBETAG(k,l,m,n), MKTAG(k,l,m,n)); #if !CONFIG_SMALL - for (j = 256; j < 1024; j++) - for (i = 0; i < 4; i++) - tbl[4*j + i] = tbl[4*j + ((i - 1) & 3) - 1024]; + tbl[1][i] = ROT(tbl[0][i], 8); + tbl[2][i] = ROT(tbl[0][i], 16); + tbl[3][i] = ROT(tbl[0][i], 24); #endif + } + } } // this is based on the reference AES code by Paulo Barreto and Vincent Rijmen @@ -187,9 +195,9 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) inv_sbox[j] = i; sbox[i] = j; } - init_multbl2(dec_multbl[0], (const int[4]) { 0xe, 0x9, 0xd, 0xb }, + init_multbl2(dec_multbl, (const int[4]) { 0xe, 0x9, 0xd, 0xb }, log8, alog8, inv_sbox); - init_multbl2(enc_multbl[0], (const int[4]) { 0x2, 0x1, 0x1, 0x3 }, + init_multbl2(enc_multbl, (const int[4]) { 0x2, 0x1, 0x1, 0x3 }, log8, alog8, sbox); } From 050f2b3e7f3a98bc824cfcaf4c825ed4c643e21c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 02:34:27 +0100 Subject: [PATCH 220/780] mjpeg: remove pointless braces around block of code Signed-off-by: Mans Rullgard --- libavcodec/mjpegdec.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 391d58de6b..3946df6472 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1520,28 +1520,26 @@ eoi_parser: av_log(avctx, AV_LOG_WARNING, "Found EOI before any SOF, ignoring\n"); break; } - { - if (s->interlaced) { - s->bottom_field ^= 1; - /* if not bottom field, do not output image yet */ - if (s->bottom_field == !s->interlace_polarity) - goto not_the_end; - } - *picture = *s->picture_ptr; - *data_size = sizeof(AVFrame); - - if(!s->lossless){ - picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]); - picture->qstride= 0; - picture->qscale_table= s->qscale_table; - memset(picture->qscale_table, picture->quality, (s->width+15)/16); - if(avctx->debug & FF_DEBUG_QP) - av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality); - picture->quality*= FF_QP2LAMBDA; - } - - goto the_end; + if (s->interlaced) { + s->bottom_field ^= 1; + /* if not bottom field, do not output image yet */ + if (s->bottom_field == !s->interlace_polarity) + goto not_the_end; } + *picture = *s->picture_ptr; + *data_size = sizeof(AVFrame); + + if(!s->lossless){ + picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]); + picture->qstride= 0; + picture->qscale_table= s->qscale_table; + memset(picture->qscale_table, picture->quality, (s->width+15)/16); + if(avctx->debug & FF_DEBUG_QP) + av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality); + picture->quality*= FF_QP2LAMBDA; + } + + goto the_end; break; case SOS: if (!s->got_picture) { From b27565b1432f8bb2c933afa184ace6582ad650ee Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 02:37:03 +0100 Subject: [PATCH 221/780] Remove statements immediately following unconditional jumps This removes a number of compiler warnings. Signed-off-by: Mans Rullgard --- libavcodec/cook.c | 1 - libavcodec/flicvideo.c | 1 - libavcodec/mjpegdec.c | 1 - libavcodec/pcm.c | 1 - libavcodec/shorten.c | 3 --- libavformat/a64.c | 1 - libavformat/idroqdec.c | 1 - libavformat/oma.c | 1 - libavformat/psxstr.c | 1 - libavformat/wc3movie.c | 1 - 10 files changed, 12 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 84211a6d08..8d1078145e 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -1156,7 +1156,6 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) default: av_log_ask_for_sample(avctx, "Unknown Cook version.\n"); return -1; - break; } if(s > 1 && q->subpacket[s].samples_per_channel != q->samples_per_channel) { diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c index ed9972c018..e8c0e14386 100644 --- a/libavcodec/flicvideo.c +++ b/libavcodec/flicvideo.c @@ -112,7 +112,6 @@ static av_cold int flic_decode_init(AVCodecContext *avctx) case 24 : avctx->pix_fmt = PIX_FMT_BGR24; /* Supposedly BGR, but havent any files to test with */ av_log(avctx, AV_LOG_ERROR, "24Bpp FLC/FLX is unsupported due to no test files.\n"); return -1; - break; default : av_log(avctx, AV_LOG_ERROR, "Unknown FLC/FLX depth of %d Bpp is unsupported.\n",depth); return -1; diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 3946df6472..4684190e08 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1540,7 +1540,6 @@ eoi_parser: } goto the_end; - break; case SOS: if (!s->got_picture) { av_log(avctx, AV_LOG_WARNING, "Can not process SOS before SOF, skipping\n"); diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index 9100646179..2ad395dd0e 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -440,7 +440,6 @@ static int pcm_decode_frame(AVCodecContext *avctx, default: av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n"); return -1; - break; } samples = (short *) dst_int32_t; break; diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index a6e00750e9..e4dfa7c59f 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -471,7 +471,6 @@ static int shorten_decode_frame(AVCodecContext *avctx, s->cur_chan = 0; goto frame_done; } - break; } break; case FN_VERBATIM: @@ -489,11 +488,9 @@ static int shorten_decode_frame(AVCodecContext *avctx, case FN_QUIT: *data_size = 0; return buf_size; - break; default: av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd); return -1; - break; } } frame_done: diff --git a/libavformat/a64.c b/libavformat/a64.c index 0e5576b651..3d313e5fba 100644 --- a/libavformat/a64.c +++ b/libavformat/a64.c @@ -55,7 +55,6 @@ static int a64_write_header(struct AVFormatContext *s) break; default: return AVERROR(EINVAL); - break; } avio_write(s->pb, header, 2); c->prev_pkt.size = 0; diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c index 8e991c57d9..d9315966ea 100644 --- a/libavformat/idroqdec.c +++ b/libavformat/idroqdec.c @@ -209,7 +209,6 @@ static int roq_read_packet(AVFormatContext *s, default: av_log(s, AV_LOG_ERROR, " unknown RoQ chunk (%04X)\n", chunk_type); return AVERROR_INVALIDDATA; - break; } } diff --git a/libavformat/oma.c b/libavformat/oma.c index 6fdf75f17c..0ec81ebefb 100644 --- a/libavformat/oma.c +++ b/libavformat/oma.c @@ -149,7 +149,6 @@ static int oma_read_header(AVFormatContext *s, default: av_log(s, AV_LOG_ERROR, "Unsupported codec %d!\n",buf[32]); return -1; - break; } st->codec->block_align = framesize; diff --git a/libavformat/psxstr.c b/libavformat/psxstr.c index b7a9d3b250..646244238c 100644 --- a/libavformat/psxstr.c +++ b/libavformat/psxstr.c @@ -234,7 +234,6 @@ static int str_read_packet(AVFormatContext *s, pkt->stream_index = str->channels[channel].audio_stream_index; return 0; - break; default: av_log(s, AV_LOG_WARNING, "Unknown sector type %02X\n", sector[0x12]); /* drop the sector and move on */ diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c index e57a9bf844..03483de737 100644 --- a/libavformat/wc3movie.c +++ b/libavformat/wc3movie.c @@ -152,7 +152,6 @@ static int wc3_read_header(AVFormatContext *s, (uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24), (uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24)); return AVERROR_INVALIDDATA; - break; } fourcc_tag = avio_rl32(pb); From 6728aaf6d8046ec0a82b6955b8bf27bf87358046 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 01:52:37 +0100 Subject: [PATCH 222/780] ffv1: remove unused tables Signed-off-by: Mans Rullgard --- libavcodec/ffv1.c | 74 +---------------------------------------------- 1 file changed, 1 insertion(+), 73 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 50f1062ad4..1f1d4d1c62 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -42,25 +42,6 @@ extern const uint8_t ff_log2_run[41]; -static const int8_t quant3[256]={ - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, -}; - static const int8_t quant5_10bit[256]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -98,42 +79,7 @@ static const int8_t quant5[256]={ -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-1,-1,-1, }; -static const int8_t quant7[256]={ - 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-1,-1, -}; -static const int8_t quant9[256]={ - 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-1,-1, -}; + static const int8_t quant9_10bit[256]={ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, @@ -171,24 +117,6 @@ static const int8_t quant11[256]={ -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, -4,-4,-4,-4,-4,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-1, }; -static const int8_t quant13[256]={ - 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, --6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, --6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, --6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, --6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, --6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-5, --5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, --5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, --4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3,-2,-2,-1, -}; static const uint8_t ver2_state[256]= { 0, 10, 10, 10, 10, 16, 16, 16, 28, 16, 16, 29, 42, 49, 20, 49, From c9403419b25e36328cd25dc0855fd946c261a233 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 02:54:58 +0100 Subject: [PATCH 223/780] avidec: simplify convoluted flow in avi_load_index() Signed-off-by: Mans Rullgard --- libavformat/avidec.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 871da0bb40..a00b9ced2d 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -1241,20 +1241,16 @@ static int avi_load_index(AVFormatContext *s) (tag >> 16) & 0xff, (tag >> 24) & 0xff, size); - switch(tag) { - case MKTAG('i', 'd', 'x', '1'): - if (avi_read_idx1(s, size) < 0) - goto skip; + + if (tag == MKTAG('i', 'd', 'x', '1') && + avi_read_idx1(s, size) >= 0) { ret = 0; - goto the_end; - break; - default: - skip: - size += (size & 1); - if (avio_skip(pb, size) < 0) - goto the_end; // something is wrong here break; } + + size += (size & 1); + if (avio_skip(pb, size) < 0) + break; // something is wrong here } the_end: avio_seek(pb, pos, SEEK_SET); From 2a375bb400febf8c1a2dfa87c29fd4185663454c Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Sun, 3 Jul 2011 13:19:44 +0200 Subject: [PATCH 224/780] Add mode to yadif to enable/disable deinterlacing based on src frame "interlaced" flag Signed-off-by: Joakim Plate --- doc/filters.texi | 14 +++++++++++++- libavfilter/vf_yadif.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index b4ffcd9a04..c96de41bfa 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1737,7 +1737,7 @@ Flip the input video vertically. Deinterlace the input video ("yadif" means "yet another deinterlacing filter"). -It accepts the optional parameters: @var{mode}:@var{parity}. +It accepts the optional parameters: @var{mode}:@var{parity}:@var(auto). @var{mode} specifies the interlacing mode to adopt, accepts one of the following values: @@ -1771,6 +1771,18 @@ Default value is -1. If interlacing is unknown or decoder does not export this information, top field first will be assumed. +@var{auto] specifies if deinterlacer should trust the interlaced flag +and only deinterlace frames marked as interlaced + +@table @option +@item 0 +deinterlace all frames +@item 1 +only deinterlace frames marked as interlaced +@end table + +Default value is 0. + @c man end VIDEO FILTERS @chapter Video Sources diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 296328b71a..56e4489986 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -44,6 +44,12 @@ typedef struct { int frame_pending; + /** + * 0: deinterlace all frames + * 1: only deinterlace frames marked as interlaced + */ + int auto_enable; + AVFilterBufferRef *cur; AVFilterBufferRef *next; AVFilterBufferRef *prev; @@ -240,6 +246,14 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) if (!yadif->cur) return; + if (yadif->auto_enable && !yadif->cur->video->interlaced) { + yadif->out = avfilter_ref_buffer(yadif->cur, AV_PERM_READ); + avfilter_unref_buffer(yadif->prev); + yadif->prev = NULL; + avfilter_start_frame(ctx->outputs[0], yadif->out); + return; + } + if (!yadif->prev) yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ); @@ -259,6 +273,12 @@ static void end_frame(AVFilterLink *link) if (!yadif->out) return; + if (yadif->auto_enable && !yadif->cur->video->interlaced) { + avfilter_draw_slice(ctx->outputs[0], 0, link->h, 1); + avfilter_end_frame(ctx->outputs[0]); + return; + } + return_frame(ctx, 0); } @@ -299,6 +319,9 @@ static int poll_frame(AVFilterLink *link) } assert(yadif->next || !val); + if (yadif->auto_enable && yadif->next && !yadif->next->video->interlaced) + return val; + return val * ((yadif->mode&1)+1); } @@ -344,9 +367,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) yadif->mode = 0; yadif->parity = -1; + yadif->auto_enable = 0; yadif->csp = NULL; - if (args) sscanf(args, "%d:%d", &yadif->mode, &yadif->parity); + if (args) sscanf(args, "%d:%d:%d", &yadif->mode, &yadif->parity, &yadif->auto_enable); yadif->filter_line = filter_line_c; if (HAVE_SSSE3 && cpu_flags & AV_CPU_FLAG_SSSE3) @@ -356,7 +380,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) yadif->filter_line = ff_yadif_filter_line_mmx; - av_log(ctx, AV_LOG_INFO, "mode:%d parity:%d\n", yadif->mode, yadif->parity); + av_log(ctx, AV_LOG_INFO, "mode:%d parity:%d auto_enable:%d\n", yadif->mode, yadif->parity, yadif->auto_enable); return 0; } From 904b5d302d4e6b22226d2144c727f58793f3e547 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 12:54:57 +0100 Subject: [PATCH 225/780] fate: add DES test Signed-off-by: Mans Rullgard --- tests/fate2.mak | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/fate2.mak b/tests/fate2.mak index 5603c314dd..47804c4d8a 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -231,6 +231,11 @@ FATE_TESTS += fate-base64 fate-base64: libavutil/base64-test$(EXESUF) fate-base64: CMD = run libavutil/base64-test +FATE_TESTS += fate-des +fate-des: libavutil/des-test$(EXESUF) +fate-des: CMD = run libavutil/des-test +fate-des: REF = /dev/null + FATE_TESTS += fate-musepack7 fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff From 66fe5970abdad0964d0e0d0e100b62e715922886 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 12:55:54 +0100 Subject: [PATCH 226/780] des: reduce number of iterations in test program Testing a million random keys takes annoying long time. 1000 iterations should be enough. Signed-off-by: Mans Rullgard --- libavutil/des.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/des.c b/libavutil/des.c index a30ef3ba7c..857ca91319 100644 --- a/libavutil/des.c +++ b/libavutil/des.c @@ -402,7 +402,7 @@ int main(void) { printf("Partial Monte-Carlo test failed\n"); return 1; } - for (i = 0; i < 1000000; i++) { + for (i = 0; i < 1000; i++) { key[0] = rand64(); key[1] = rand64(); key[2] = rand64(); data = rand64(); av_des_init(&d, key, 192, 0); From 8f175810beba0e4d7fb76c6eb747e5aab76071b4 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 11:20:39 +0100 Subject: [PATCH 227/780] aes: fix for big endian systems This was missed in 5d20f19 since CONFIG_SMALL was always broken for big endian. Signed-off-by: Mans Rullgard --- libavutil/aes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavutil/aes.c b/libavutil/aes.c index 8a8bfc2b25..d1fe857914 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -54,7 +54,11 @@ static uint32_t enc_multbl[4][256]; static uint32_t dec_multbl[4][256]; #endif -#define ROT(x, s) ((x << s) | (x >> (32-s))) +#if HAVE_BIGENDIAN +# define ROT(x, s) ((x >> s) | (x << (32-s))) +#else +# define ROT(x, s) ((x << s) | (x >> (32-s))) +#endif static inline void addkey(av_aes_block *dst, const av_aes_block *src, const av_aes_block *round_key) From 10dde477c77e0ac0fecda49fdb1dc71329aa7513 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 3 Jul 2011 11:54:24 +0200 Subject: [PATCH 228/780] Update Doxyfile to the format preferred by Doxygen 1.7.1 (via 'doxygen -u'). This is the version available in Debian stable, so it should be a reasonable baseline that can be expected to be present on all developer machines. Moreover, this is the version that is used by the nightly cronjob that generates the online html version. --- Doxyfile | 346 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 283 insertions(+), 63 deletions(-) diff --git a/Doxyfile b/Doxyfile index 2502548aed..a4beaba323 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.5.6 +# Doxyfile 1.7.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project @@ -54,11 +54,11 @@ CREATE_SUBDIRS = NO # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, -# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, -# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, -# and Ukrainian. +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English @@ -155,13 +155,6 @@ QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. @@ -214,6 +207,18 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and @@ -268,6 +273,22 @@ SUBGROUPING = YES TYPEDEF_HIDES_STRUCT = NO +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -366,6 +387,12 @@ HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = YES +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. @@ -385,6 +412,16 @@ SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. @@ -459,7 +496,8 @@ SHOW_DIRECTORIES = NO SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. This will remove the Namespaces entry from the Quick Index +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES @@ -474,6 +512,15 @@ SHOW_NAMESPACES = YES FILE_VERSION_FILTER = +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- @@ -577,7 +624,8 @@ EXCLUDE_SYMLINKS = NO # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = *.git *.d +EXCLUDE_PATTERNS = *.git \ + *.d # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -591,7 +639,8 @@ EXCLUDE_SYMBOLS = # directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = libavcodec/ libavformat/ +EXAMPLE_PATH = libavcodec/ \ + libavformat/ # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp @@ -618,14 +667,17 @@ IMAGE_PATH = # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. @@ -675,7 +727,8 @@ REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. +# link to the source code. +# Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES @@ -758,18 +811,50 @@ HTML_FOOTER = HTML_STYLESHEET = +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). -GENERATE_HTMLHELP = NO +HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 @@ -779,6 +864,8 @@ GENERATE_HTMLHELP = NO # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. GENERATE_DOCSET = NO @@ -796,13 +883,22 @@ DOCSET_FEEDNAME = "Doxygen generated docs" DOCSET_BUNDLE_ID = org.doxygen.Project -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. -HTML_DYNAMIC_SECTIONS = NO +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You @@ -841,6 +937,76 @@ BINARY_TOC = NO TOC_EXPAND = NO +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. @@ -854,27 +1020,30 @@ ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. -# If the tag value is set to FRAME, a side panel will be generated +# If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. Other possible values -# for this tag are: HIERARCHIES, which will generate the Groups, Directories, -# and Class Hiererachy pages using a tree view instead of an ordered list; -# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which -# disables this behavior completely. For backwards compatibility with previous -# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE -# respectively. +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = NO +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need @@ -883,6 +1052,34 @@ TREEVIEW_WIDTH = 250 FORMULA_FONTSIZE = 10 +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = NO + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvances is that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- @@ -900,6 +1097,9 @@ LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. LATEX_CMD_NAME = latex @@ -959,6 +1159,13 @@ LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -1095,8 +1302,10 @@ GENERATE_PERLMOD = NO PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. @@ -1158,17 +1367,22 @@ INCLUDE_FILE_PATTERNS = # undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = __attribute__(x)="" "RENAME(x)=x ## _TMPL" "DEF(x)=x ## _TMPL" \ - HAVE_AV_CONFIG_H HAVE_MMX HAVE_MMX2 HAVE_AMD3DNOW \ - "DECLARE_ALIGNED(a,t,n)=t n" "offsetof(x,y)=0x42" \ +PREDEFINED = "__attribute__(x)=" \ + "RENAME(x)=x ## _TMPL" \ + "DEF(x)=x ## _TMPL" \ + HAVE_AV_CONFIG_H \ + HAVE_MMX \ + HAVE_MMX2 \ + HAVE_AMD3DNOW \ + "DECLARE_ALIGNED(a,t,n)=t n" \ + "offsetof(x,y)=0x42" # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. -#EXPAND_AS_DEFINED = FF_COMMON_FRAME -EXPAND_AS_DEFINED = declare_idct(idct, table, idct_row_head, idct_row, idct_row_tail, idct_row_mid) +EXPAND_AS_DEFINED = declare_idct # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone @@ -1186,9 +1400,11 @@ SKIP_FUNCTION_MACROS = YES # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: -# TAGFILES = file1 file2 ... +# +# TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... +# +# TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. @@ -1256,6 +1472,14 @@ HIDE_UNDOC_RELATIONS = YES HAVE_DOT = NO +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This # font does not include all possible unicode characters however, so when you need @@ -1267,6 +1491,11 @@ HAVE_DOT = NO DOT_FONTNAME = FreeSans +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot @@ -1384,10 +1613,10 @@ DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is enabled by default, which results in a transparent -# background. Warning: Depending on the platform used, enabling this option -# may lead to badly anti-aliased labels on the edges of a graph (i.e. they -# become hard to read). +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). DOT_TRANSPARENT = YES @@ -1409,12 +1638,3 @@ GENERATE_LEGEND = YES # the various graphs. DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO From 9bfa5363da21a5ba7bed174a82c86f2a089fc917 Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Sat, 2 Jul 2011 22:18:39 -0400 Subject: [PATCH 229/780] H.264: Add x86 assembly for 10-bit H.264 qpel functions. Mainly ported from 8-bit H.264 qpel. Some code ported from x264. LGPL ok by author. Signed-off-by: Ronald S. Bultje --- libavcodec/x86/Makefile | 1 + libavcodec/x86/dsputil_mmx.c | 134 +++-- libavcodec/x86/h264_qpel_10bit.asm | 891 +++++++++++++++++++++++++++++ libavcodec/x86/h264_qpel_mmx.c | 98 ++++ 4 files changed, 1075 insertions(+), 49 deletions(-) create mode 100644 libavcodec/x86/h264_qpel_10bit.asm diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 022ab27766..d3cf0da72b 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -46,6 +46,7 @@ MMX-OBJS-$(HAVE_YASM) += x86/dsputil_yasm.o \ x86/fmtconvert.o \ x86/h264_chromamc.o \ x86/h264_chromamc_10bit.o \ + x86/h264_qpel_10bit.o \ $(YASM-OBJS-yes) MMX-OBJS-$(CONFIG_FFT) += x86/fft.o diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 03c094533f..d6eed82dd8 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2627,44 +2627,56 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_exact_mmx2; } -#define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU) \ - c->PFX ## _pixels_tab[IDX][ 0] = PFX ## SIZE ## _mc00_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][ 1] = PFX ## SIZE ## _mc10_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][ 2] = PFX ## SIZE ## _mc20_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][ 3] = PFX ## SIZE ## _mc30_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][ 4] = PFX ## SIZE ## _mc01_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][ 5] = PFX ## SIZE ## _mc11_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][ 6] = PFX ## SIZE ## _mc21_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][ 7] = PFX ## SIZE ## _mc31_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][ 8] = PFX ## SIZE ## _mc02_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][ 9] = PFX ## SIZE ## _mc12_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][10] = PFX ## SIZE ## _mc22_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][11] = PFX ## SIZE ## _mc32_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][12] = PFX ## SIZE ## _mc03_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][13] = PFX ## SIZE ## _mc13_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][14] = PFX ## SIZE ## _mc23_ ## CPU; \ - c->PFX ## _pixels_tab[IDX][15] = PFX ## SIZE ## _mc33_ ## CPU +#define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU, PREFIX) \ + c->PFX ## _pixels_tab[IDX][ 0] = PREFIX ## PFX ## SIZE ## _mc00_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][ 1] = PREFIX ## PFX ## SIZE ## _mc10_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][ 2] = PREFIX ## PFX ## SIZE ## _mc20_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][ 3] = PREFIX ## PFX ## SIZE ## _mc30_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][ 4] = PREFIX ## PFX ## SIZE ## _mc01_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][ 5] = PREFIX ## PFX ## SIZE ## _mc11_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][ 6] = PREFIX ## PFX ## SIZE ## _mc21_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][ 7] = PREFIX ## PFX ## SIZE ## _mc31_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][ 8] = PREFIX ## PFX ## SIZE ## _mc02_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][ 9] = PREFIX ## PFX ## SIZE ## _mc12_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][10] = PREFIX ## PFX ## SIZE ## _mc22_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][11] = PREFIX ## PFX ## SIZE ## _mc32_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][12] = PREFIX ## PFX ## SIZE ## _mc03_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][13] = PREFIX ## PFX ## SIZE ## _mc13_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][14] = PREFIX ## PFX ## SIZE ## _mc23_ ## CPU; \ + c->PFX ## _pixels_tab[IDX][15] = PREFIX ## PFX ## SIZE ## _mc33_ ## CPU - SET_QPEL_FUNCS(put_qpel, 0, 16, mmx2); - SET_QPEL_FUNCS(put_qpel, 1, 8, mmx2); - SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmx2); - SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmx2); - SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2); - SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2); + SET_QPEL_FUNCS(put_qpel, 0, 16, mmx2, ); + SET_QPEL_FUNCS(put_qpel, 1, 8, mmx2, ); + SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmx2, ); + SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmx2, ); + SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2, ); + SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2, ); if (!high_bit_depth) { - SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2); - SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2); - SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2); - SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmx2); - SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmx2); - SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmx2); + SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2, ); + SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2, ); + SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2, ); + SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmx2, ); + SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmx2, ); + SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmx2, ); } +#if HAVE_YASM + else if (bit_depth == 10) { +#if !ARCH_X86_64 + SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 10_mmxext, ff_); + SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_mmxext, ff_); + SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 10_mmxext, ff_); + SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 10_mmxext, ff_); +#endif + SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 10_mmxext, ff_); + SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 10_mmxext, ff_); + } +#endif - SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmx2); - SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmx2); - SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmx2); - SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmx2); + SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmx2, ); + SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmx2, ); + SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmx2, ); + SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmx2, ); #if HAVE_YASM c->avg_rv40_chroma_pixels_tab[0]= ff_avg_rv40_chroma_mc8_mmx2; @@ -2725,26 +2737,26 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_exact_3dnow; } - SET_QPEL_FUNCS(put_qpel, 0, 16, 3dnow); - SET_QPEL_FUNCS(put_qpel, 1, 8, 3dnow); - SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, 3dnow); - SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, 3dnow); - SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow); - SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow); + SET_QPEL_FUNCS(put_qpel, 0, 16, 3dnow, ); + SET_QPEL_FUNCS(put_qpel, 1, 8, 3dnow, ); + SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, 3dnow, ); + SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, 3dnow, ); + SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow, ); + SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow, ); if (!high_bit_depth) { - SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow); - SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow); - SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow); - SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 3dnow); - SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 3dnow); - SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 3dnow); + SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow, ); + SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow, ); + SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow, ); + SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 3dnow, ); + SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 3dnow, ); + SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 3dnow, ); } - SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, 3dnow); - SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, 3dnow); - SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, 3dnow); - SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow); + SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, 3dnow, ); + SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, 3dnow, ); + SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, 3dnow, ); + SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow, ); #if HAVE_YASM if (!high_bit_depth) { @@ -2788,7 +2800,20 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) H264_QPEL_FUNCS(3, 3, sse2); } #if HAVE_YASM +#define H264_QPEL_FUNCS_10(x, y, CPU)\ + c->put_h264_qpel_pixels_tab[0][x+y*4] = ff_put_h264_qpel16_mc##x##y##_10_##CPU;\ + c->put_h264_qpel_pixels_tab[1][x+y*4] = ff_put_h264_qpel8_mc##x##y##_10_##CPU;\ + c->avg_h264_qpel_pixels_tab[0][x+y*4] = ff_avg_h264_qpel16_mc##x##y##_10_##CPU;\ + c->avg_h264_qpel_pixels_tab[1][x+y*4] = ff_avg_h264_qpel8_mc##x##y##_10_##CPU; if (bit_depth == 10) { + SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_sse2, ff_); + SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 10_sse2, ff_); + SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 10_sse2, ff_); + SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 10_sse2, ff_); + H264_QPEL_FUNCS_10(1, 0, sse2_cache64) + H264_QPEL_FUNCS_10(2, 0, sse2_cache64) + H264_QPEL_FUNCS_10(3, 0, sse2_cache64) + c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_10_sse2; c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_10_sse2; } @@ -2810,6 +2835,11 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) H264_QPEL_FUNCS(3, 2, ssse3); H264_QPEL_FUNCS(3, 3, ssse3); } + else if (bit_depth == 10) { + H264_QPEL_FUNCS_10(1, 0, ssse3_cache64) + H264_QPEL_FUNCS_10(2, 0, ssse3_cache64) + H264_QPEL_FUNCS_10(3, 0, ssse3_cache64) + } c->add_png_paeth_prediction= add_png_paeth_prediction_ssse3; #if HAVE_YASM if (!high_bit_depth) { @@ -2906,6 +2936,12 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) #if HAVE_AVX && HAVE_YASM if (mm_flags & AV_CPU_FLAG_AVX) { if (bit_depth == 10) { + //AVX implies !cache64. + //TODO: Port cache(32|64) detection from x264. + H264_QPEL_FUNCS_10(1, 0, sse2) + H264_QPEL_FUNCS_10(2, 0, sse2) + H264_QPEL_FUNCS_10(3, 0, sse2) + c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_10_avx; c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_10_avx; } diff --git a/libavcodec/x86/h264_qpel_10bit.asm b/libavcodec/x86/h264_qpel_10bit.asm new file mode 100644 index 0000000000..15dd72ca36 --- /dev/null +++ b/libavcodec/x86/h264_qpel_10bit.asm @@ -0,0 +1,891 @@ +;***************************************************************************** +;* MMX/SSE2/AVX-optimized 10-bit H.264 qpel code +;***************************************************************************** +;* Copyright (C) 2011 x264 project +;* +;* Authors: Daniel Kang +;* +;* This file is part of Libav. +;* +;* Libav is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* Libav 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 +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with Libav; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" +%include "x86util.asm" + +SECTION_RODATA 32 + +cextern pw_16 +cextern pw_1 +cextern pb_0 + +pw_pixel_max: times 8 dw ((1 << 10)-1) + +pad10: times 8 dw 10*1023 +pad20: times 8 dw 20*1023 +pad30: times 8 dw 30*1023 +depad: times 4 dd 32*20*1023 + 512 +depad2: times 8 dw 20*1023 + 16*1022 + 16 +unpad: times 8 dw 16*1022/32 ; needs to be mod 16 + +tap1: times 4 dw 1, -5 +tap2: times 4 dw 20, 20 +tap3: times 4 dw -5, 1 +pd_0f: times 4 dd 0xffff + +SECTION .text + + +%macro AVG_MOV 2 + pavgw %2, %1 + mova %1, %2 +%endmacro + +%macro ADDW 3 +%if mmsize == 8 + paddw %1, %2 +%else + movu %3, %2 + paddw %1, %3 +%endif +%endmacro + +%macro FILT_H 4 + paddw %1, %4 + psubw %1, %2 ; a-b + psraw %1, 2 ; (a-b)/4 + psubw %1, %2 ; (a-b)/4-b + paddw %1, %3 ; (a-b)/4-b+c + psraw %1, 2 ; ((a-b)/4-b+c)/4 + paddw %1, %3 ; ((a-b)/4-b+c)/4+c = (a-5*b+20*c)/16 +%endmacro + +%macro PRELOAD_V 0 + lea r3, [r2*3] + sub r1, r3 + movu m0, [r1+r2] + movu m1, [r1+r2*2] + add r1, r3 + movu m2, [r1] + movu m3, [r1+r2] + movu m4, [r1+r2*2] + add r1, r3 +%endmacro + +%macro FILT_V 8 + movu %6, [r1] + paddw %1, %6 + mova %7, %2 + paddw %7, %5 + mova %8, %3 + paddw %8, %4 + FILT_H %1, %7, %8, [pw_16] + psraw %1, 1 + CLIPW %1, [pb_0], [pw_pixel_max] +%endmacro + +%macro MC 1 +%define OP_MOV mova +INIT_MMX +%1 mmxext, put, 4 +INIT_XMM +%1 sse2 , put, 8 + +%define OP_MOV AVG_MOV +INIT_MMX +%1 mmxext, avg, 4 +INIT_XMM +%1 sse2 , avg, 8 +%endmacro + +%macro MCAxA 8 +%ifdef ARCH_X86_64 +%ifnidn %1,mmxext +MCAxA_OP %1,%2,%3,%4,%5,%6,%7,%8 +%endif +%else +MCAxA_OP %1,%2,%3,%4,%5,%6,%7,%8 +%endif +%endmacro + +%macro MCAxA_OP 8 +cglobal %2_h264_qpel%5_%3_10_%1, %6,%7,%8 +%ifdef ARCH_X86_32 + call stub_%2_h264_qpel%4_%3_10_%1 + mov r0, r0m + mov r1, r1m + add r0, %4*2 + add r1, %4*2 + call stub_%2_h264_qpel%4_%3_10_%1 + mov r0, r0m + mov r1, r1m + lea r0, [r0+r2*%4] + lea r1, [r1+r2*%4] + call stub_%2_h264_qpel%4_%3_10_%1 + mov r0, r0m + mov r1, r1m + lea r0, [r0+r2*%4+%4*2] + lea r1, [r1+r2*%4+%4*2] + call stub_%2_h264_qpel%4_%3_10_%1 + RET +%else ; ARCH_X86_64 + mov r10, r0 + mov r11, r1 + call stub_%2_h264_qpel%4_%3_10_%1 + lea r0, [r10+%4*2] + lea r1, [r11+%4*2] + call stub_%2_h264_qpel%4_%3_10_%1 + lea r0, [r10+r2*%4] + lea r1, [r11+r2*%4] + call stub_%2_h264_qpel%4_%3_10_%1 + lea r0, [r10+r2*%4+%4*2] + lea r1, [r11+r2*%4+%4*2] +%ifndef UNIX64 ; fall through to function + call stub_%2_h264_qpel%4_%3_10_%1 + RET +%endif +%endif +%endmacro + +;cpu, put/avg, mc, 4/8, ... +%macro cglobal_mc 7 +%assign i %4*2 +MCAxA %1, %2, %3, %4, i, %5,%6,%7 + +cglobal %2_h264_qpel%4_%3_10_%1, %5,%6,%7 +%ifndef UNIX64 ; no prologue or epilogue for UNIX64 + call stub_%2_h264_qpel%4_%3_10_%1 + RET +%endif + +stub_%2_h264_qpel%4_%3_10_%1: +%endmacro + +;----------------------------------------------------------------------------- +; void h264_qpel_mc00(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro COPY4 0 + movu m0, [r1 ] + OP_MOV [r0 ], m0 + movu m0, [r1+r2 ] + OP_MOV [r0+r2 ], m0 + movu m0, [r1+r2*2] + OP_MOV [r0+r2*2], m0 + movu m0, [r1+r3 ] + OP_MOV [r0+r3 ], m0 +%endmacro + +%macro MC00 1 +INIT_MMX +cglobal_mc mmxext, %1, mc00, 4, 3,4,0 + lea r3, [r2*3] + COPY4 + ret + +INIT_XMM +cglobal %1_h264_qpel8_mc00_10_sse2, 3,4 + lea r3, [r2*3] + COPY4 + lea r0, [r0+r2*4] + lea r1, [r1+r2*4] + COPY4 + RET + +cglobal %1_h264_qpel16_mc00_10_sse2, 3,4 + mov r3d, 8 +.loop: + movu m0, [r1 ] + movu m1, [r1 +16] + OP_MOV [r0 ], m0 + OP_MOV [r0 +16], m1 + movu m0, [r1+r2 ] + movu m1, [r1+r2+16] + OP_MOV [r0+r2 ], m0 + OP_MOV [r0+r2+16], m1 + lea r0, [r0+r2*2] + lea r1, [r1+r2*2] + dec r3d + jg .loop + REP_RET +%endmacro + +%define OP_MOV mova +MC00 put + +%define OP_MOV AVG_MOV +MC00 avg + +;----------------------------------------------------------------------------- +; void h264_qpel_mc20(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC_CACHE 1 +%define OP_MOV mova +%define PALIGNR PALIGNR_MMX +INIT_MMX +%1 mmxext , put, 4 +INIT_XMM +%1 sse2_cache64 , put, 8 +%define PALIGNR PALIGNR_SSSE3 +%1 ssse3_cache64, put, 8 +%1 sse2 , put, 8, 0 + +%define OP_MOV AVG_MOV +%define PALIGNR PALIGNR_MMX +INIT_MMX +%1 mmxext , avg, 4 +INIT_XMM +%1 sse2_cache64 , avg, 8 +%define PALIGNR PALIGNR_SSSE3 +%1 ssse3_cache64, avg, 8 +%1 sse2 , avg, 8, 0 +%endmacro + +%macro MC20 3-4 +cglobal_mc %1, %2, mc20, %3, 3,4,9 + mov r3d, %3 + mova m1, [pw_pixel_max] +%if num_mmregs > 8 + mova m8, [pw_16] + %define p16 m8 +%else + %define p16 [pw_16] +%endif +.nextrow +%if %0 == 4 + movu m2, [r1-4] + movu m3, [r1-2] + movu m4, [r1+0] + ADDW m2, [r1+6], m5 + ADDW m3, [r1+4], m5 + ADDW m4, [r1+2], m5 +%else ; movu is slow on these processors +%if mmsize==16 + movu m2, [r1-4] + movu m0, [r1+6] + mova m6, m0 + psrldq m0, 6 + + paddw m6, m2 + PALIGNR m3, m0, m2, 2, m5 + PALIGNR m7, m0, m2, 8, m5 + paddw m3, m7 + PALIGNR m4, m0, m2, 4, m5 + PALIGNR m7, m0, m2, 6, m5 + paddw m4, m7 + SWAP 2, 6 +%else + movu m2, [r1-4] + movu m6, [r1+4] + PALIGNR m3, m6, m2, 2, m5 + paddw m3, m6 + PALIGNR m4, m6, m2, 4, m5 + PALIGNR m7, m6, m2, 6, m5 + paddw m4, m7 + paddw m2, [r1+6] +%endif +%endif + + FILT_H m2, m3, m4, p16 + psraw m2, 1 + pxor m0, m0 + CLIPW m2, m0, m1 + OP_MOV [r0], m2 + add r0, r2 + add r1, r2 + dec r3d + jg .nextrow + rep ret +%endmacro + +MC_CACHE MC20 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc30(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC30 3-4 +cglobal_mc %1, %2, mc30, %3, 3,5,9 + lea r4, [r1+2] + jmp stub_%2_h264_qpel%3_mc10_10_%1.body +%endmacro + +MC_CACHE MC30 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc10(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC10 3-4 +cglobal_mc %1, %2, mc10, %3, 3,5,9 + mov r4, r1 +.body + mov r3d, %3 + mova m1, [pw_pixel_max] +%if num_mmregs > 8 + mova m8, [pw_16] + %define p16 m8 +%else + %define p16 [pw_16] +%endif +.nextrow +%if %0 == 4 + movu m2, [r1-4] + movu m3, [r1-2] + movu m4, [r1+0] + ADDW m2, [r1+6], m5 + ADDW m3, [r1+4], m5 + ADDW m4, [r1+2], m5 +%else ; movu is slow on these processors +%if mmsize==16 + movu m2, [r1-4] + movu m0, [r1+6] + mova m6, m0 + psrldq m0, 6 + + paddw m6, m2 + PALIGNR m3, m0, m2, 2, m5 + PALIGNR m7, m0, m2, 8, m5 + paddw m3, m7 + PALIGNR m4, m0, m2, 4, m5 + PALIGNR m7, m0, m2, 6, m5 + paddw m4, m7 + SWAP 2, 6 +%else + movu m2, [r1-4] + movu m6, [r1+4] + PALIGNR m3, m6, m2, 2, m5 + paddw m3, m6 + PALIGNR m4, m6, m2, 4, m5 + PALIGNR m7, m6, m2, 6, m5 + paddw m4, m7 + paddw m2, [r1+6] +%endif +%endif + + FILT_H m2, m3, m4, p16 + psraw m2, 1 + pxor m0, m0 + CLIPW m2, m0, m1 + movu m3, [r4] + pavgw m2, m3 + OP_MOV [r0], m2 + add r0, r2 + add r1, r2 + add r4, r2 + dec r3d + jg .nextrow + rep ret +%endmacro + +MC_CACHE MC10 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc02(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro V_FILT 11 +v_filt%9_%10_10_%11: + add r4, r2 +.no_addr4: + FILT_V m0, m1, m2, m3, m4, m5, m6, m7 + add r1, r2 + add r0, r2 + ret +%endmacro + +INIT_MMX +RESET_MM_PERMUTATION +%assign i 0 +%rep 4 +V_FILT m0, m1, m2, m3, m4, m5, m6, m7, 4, i, mmxext +SWAP 0,1,2,3,4,5 +%assign i i+1 +%endrep + +INIT_XMM +RESET_MM_PERMUTATION +%assign i 0 +%rep 6 +V_FILT m0, m1, m2, m3, m4, m5, m6, m7, 8, i, sse2 +SWAP 0,1,2,3,4,5 +%assign i i+1 +%endrep + +%macro MC02 3 +cglobal_mc %1, %2, mc02, %3, 3,4,8 + PRELOAD_V + + sub r0, r2 +%assign j 0 +%rep %3 + %assign i (j % 6) + call v_filt%3_ %+ i %+ _10_%1.no_addr4 + OP_MOV [r0], m0 + SWAP 0,1,2,3,4,5 + %assign j j+1 +%endrep + ret +%endmacro + +MC MC02 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc01(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC01 3 +cglobal_mc %1, %2, mc01, %3, 3,5,8 + mov r4, r1 +.body + PRELOAD_V + + sub r4, r2 + sub r0, r2 +%assign j 0 +%rep %3 + %assign i (j % 6) + call v_filt%3_ %+ i %+ _10_%1 + movu m7, [r4] + pavgw m0, m7 + OP_MOV [r0], m0 + SWAP 0,1,2,3,4,5 + %assign j j+1 +%endrep + ret +%endmacro + +MC MC01 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc03(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC03 3 +cglobal_mc %1, %2, mc03, %3, 3,5,8 + lea r4, [r1+r2] + jmp stub_%2_h264_qpel%3_mc01_10_%1.body +%endmacro + +MC MC03 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc11(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro H_FILT_AVG 3-4 +h_filt%2_%3_10_%1: +;FILT_H with fewer registers and averaged with the FILT_V result +;m6,m7 are tmp registers, m0 is the FILT_V result, the rest are to be used next in the next iteration +;unfortunately I need three registers, so m5 will have to be re-read from memory + movu m5, [r4-4] + ADDW m5, [r4+6], m7 + movu m6, [r4-2] + ADDW m6, [r4+4], m7 + paddw m5, [pw_16] + psubw m5, m6 ; a-b + psraw m5, 2 ; (a-b)/4 + psubw m5, m6 ; (a-b)/4-b + movu m6, [r4+0] + ADDW m6, [r4+2], m7 + paddw m5, m6 ; (a-b)/4-b+c + psraw m5, 2 ; ((a-b)/4-b+c)/4 + paddw m5, m6 ; ((a-b)/4-b+c)/4+c = (a-5*b+20*c)/16 + psraw m5, 1 + CLIPW m5, [pb_0], [pw_pixel_max] +;avg FILT_V, FILT_H + pavgw m0, m5 +%if %0!=4 + movu m5, [r1+r5] +%endif + ret +%endmacro + +INIT_MMX +RESET_MM_PERMUTATION +%assign i 0 +%rep 3 +H_FILT_AVG mmxext, 4, i +SWAP 0,1,2,3,4,5 +%assign i i+1 +%endrep +H_FILT_AVG mmxext, 4, i, 0 + +INIT_XMM +RESET_MM_PERMUTATION +%assign i 0 +%rep 6 +%if i==1 +H_FILT_AVG sse2, 8, i, 0 +%else +H_FILT_AVG sse2, 8, i +%endif +SWAP 0,1,2,3,4,5 +%assign i i+1 +%endrep + +%macro MC11 3 +; this REALLY needs x86_64 +cglobal_mc %1, %2, mc11, %3, 3,6,8 + mov r4, r1 +.body + PRELOAD_V + + sub r0, r2 + sub r4, r2 + mov r5, r2 + neg r5 +%assign j 0 +%rep %3 + %assign i (j % 6) + call v_filt%3_ %+ i %+ _10_%1 + call h_filt%3_ %+ i %+ _10_%1 +%if %3==8 && i==1 + movu m5, [r1+r5] +%endif + OP_MOV [r0], m0 + SWAP 0,1,2,3,4,5 + %assign j j+1 +%endrep + ret +%endmacro + +MC MC11 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc31(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC31 3 +cglobal_mc %1, %2, mc31, %3, 3,6,8 + mov r4, r1 + add r1, 2 + jmp stub_%2_h264_qpel%3_mc11_10_%1.body +%endmacro + +MC MC31 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc13(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC13 3 +cglobal_mc %1, %2, mc13, %3, 3,7,12 + lea r4, [r1+r2] + jmp stub_%2_h264_qpel%3_mc11_10_%1.body +%endmacro + +MC MC13 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc33(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC33 3 +cglobal_mc %1, %2, mc33, %3, 3,6,8 + lea r4, [r1+r2] + add r1, 2 + jmp stub_%2_h264_qpel%3_mc11_10_%1.body +%endmacro + +MC MC33 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc22(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro FILT_H2 3 + psubw %1, %2 ; a-b + psubw %2, %3 ; b-c + psllw %2, 2 + psubw %1, %2 ; a-5*b+4*c + psllw %3, 4 + paddw %1, %3 ; a-5*b+20*c +%endmacro + +%macro FILT_VNRD 8 + movu %6, [r1] + paddw %1, %6 + mova %7, %2 + paddw %7, %5 + mova %8, %3 + paddw %8, %4 + FILT_H2 %1, %7, %8 +%endmacro + +%macro HV 2 +%ifidn %1,sse2 +%define PAD 12 +%define COUNT 2 +%else +%define PAD 0 +%define COUNT 3 +%endif +put_hv%2_10_%1: + neg r2 ; This actually saves instructions + lea r1, [r1+r2*2-mmsize+PAD] + lea r4, [rsp+PAD+gprsize] + mov r3d, COUNT +.v_loop: + movu m0, [r1] + sub r1, r2 + movu m1, [r1] + sub r1, r2 + movu m2, [r1] + sub r1, r2 + movu m3, [r1] + sub r1, r2 + movu m4, [r1] + sub r1, r2 +%assign i 0 +%rep %2-1 + FILT_VNRD m0, m1, m2, m3, m4, m5, m6, m7 + psubw m0, [pad20] + movu [r4+i*mmsize*3], m0 + sub r1, r2 + SWAP 0,1,2,3,4,5 +%assign i i+1 +%endrep + FILT_VNRD m0, m1, m2, m3, m4, m5, m6, m7 + psubw m0, [pad20] + movu [r4+i*mmsize*3], m0 + add r4, mmsize + lea r1, [r1+r2*8+mmsize] +%if %2==8 + lea r1, [r1+r2*4] +%endif + dec r3d + jg .v_loop + neg r2 + ret +%endmacro + +INIT_MMX +HV mmxext, 4 +INIT_XMM +HV sse2 , 8 + +%macro H_LOOP 2 +%if num_mmregs > 8 + %define s1 m8 + %define s2 m9 + %define s3 m10 + %define d1 m11 +%else + %define s1 [tap1] + %define s2 [tap2] + %define s3 [tap3] + %define d1 [depad] +%endif +h%2_loop_op_%1: + movu m1, [r1+mmsize-4] + movu m2, [r1+mmsize-2] + mova m3, [r1+mmsize+0] + movu m4, [r1+mmsize+2] + movu m5, [r1+mmsize+4] + movu m6, [r1+mmsize+6] +%if num_mmregs > 8 + pmaddwd m1, s1 + pmaddwd m2, s1 + pmaddwd m3, s2 + pmaddwd m4, s2 + pmaddwd m5, s3 + pmaddwd m6, s3 + paddd m1, d1 + paddd m2, d1 +%else + mova m0, s1 + pmaddwd m1, m0 + pmaddwd m2, m0 + mova m0, s2 + pmaddwd m3, m0 + pmaddwd m4, m0 + mova m0, s3 + pmaddwd m5, m0 + pmaddwd m6, m0 + mova m0, d1 + paddd m1, m0 + paddd m2, m0 +%endif + paddd m3, m5 + paddd m4, m6 + paddd m1, m3 + paddd m2, m4 + psrad m1, 10 + psrad m2, 10 + pslld m2, 16 + pand m1, [pd_0f] + por m1, m2 +%if num_mmregs <= 8 + pxor m0, m0 +%endif + CLIPW m1, m0, m7 + add r1, mmsize*3 + ret +%endmacro + +INIT_MMX +H_LOOP mmxext, 4 +INIT_XMM +H_LOOP sse2 , 8 + +%macro MC22 3 +cglobal_mc %1, %2, mc22, %3, 3,7,12 +%define PAD mmsize*8*4*2 ; SIZE*16*4*sizeof(pixel) + mov r6, rsp ; backup stack pointer + and rsp, ~(mmsize-1) ; align stack + sub rsp, PAD + + call put_hv%3_10_%1 + + mov r3d, %3 + mova m7, [pw_pixel_max] +%if num_mmregs > 8 + pxor m0, m0 + mova m8, [tap1] + mova m9, [tap2] + mova m10, [tap3] + mova m11, [depad] +%endif + mov r1, rsp +.h_loop: + call h%3_loop_op_%1 + + OP_MOV [r0], m1 + add r0, r2 + dec r3d + jg .h_loop + + mov rsp, r6 ; restore stack pointer + ret +%endmacro + +MC MC22 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc12(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC12 3 +cglobal_mc %1, %2, mc12, %3, 3,7,12 +%define PAD mmsize*8*4*2 ; SIZE*16*4*sizeof(pixel) + mov r6, rsp ; backup stack pointer + and rsp, ~(mmsize-1) ; align stack + sub rsp, PAD + + call put_hv%3_10_%1 + + xor r4d, r4d +.body + mov r3d, %3 + pxor m0, m0 + mova m7, [pw_pixel_max] +%if num_mmregs > 8 + mova m8, [tap1] + mova m9, [tap2] + mova m10, [tap3] + mova m11, [depad] +%endif + mov r1, rsp +.h_loop: + call h%3_loop_op_%1 + + movu m3, [r1+r4-2*mmsize] ; movu needed for mc32, etc + paddw m3, [depad2] + psrlw m3, 5 + psubw m3, [unpad] + CLIPW m3, m0, m7 + pavgw m1, m3 + + OP_MOV [r0], m1 + add r0, r2 + dec r3d + jg .h_loop + + mov rsp, r6 ; restore stack pointer + ret +%endmacro + +MC MC12 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc32(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC32 3 +cglobal_mc %1, %2, mc32, %3, 3,7,12 +%define PAD mmsize*8*3*2 ; SIZE*16*4*sizeof(pixel) + mov r6, rsp ; backup stack pointer + and rsp, ~(mmsize-1) ; align stack + sub rsp, PAD + + call put_hv%3_10_%1 + + mov r4d, 2 ; sizeof(pixel) + jmp stub_%2_h264_qpel%3_mc12_10_%1.body +%endmacro + +MC MC32 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc21(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro H_NRD 2 +put_h%2_10_%1: + add rsp, gprsize + mov r3d, %2 + xor r4d, r4d + mova m6, [pad20] +.nextrow + movu m2, [r5-4] + movu m3, [r5-2] + movu m4, [r5+0] + ADDW m2, [r5+6], m5 + ADDW m3, [r5+4], m5 + ADDW m4, [r5+2], m5 + + FILT_H2 m2, m3, m4 + psubw m2, m6 + mova [rsp+r4], m2 + add r4d, mmsize*3 + add r5, r2 + dec r3d + jg .nextrow + sub rsp, gprsize + ret +%endmacro + +INIT_MMX +H_NRD mmxext, 4 +INIT_XMM +H_NRD sse2 , 8 + +%macro MC21 3 +cglobal_mc %1, %2, mc21, %3, 3,7,12 + mov r5, r1 +.body +%define PAD mmsize*8*3*2 ; SIZE*16*4*sizeof(pixel) + mov r6, rsp ; backup stack pointer + and rsp, ~(mmsize-1) ; align stack + + sub rsp, PAD + call put_h%3_10_%1 + + sub rsp, PAD + call put_hv%3_10_%1 + + mov r4d, PAD-mmsize ; H buffer + jmp stub_%2_h264_qpel%3_mc12_10_%1.body +%endmacro + +MC MC21 + +;----------------------------------------------------------------------------- +; void h264_qpel_mc23(uint8_t *dst, uint8_t *src, int stride) +;----------------------------------------------------------------------------- +%macro MC23 3 +cglobal_mc %1, %2, mc23, %3, 3,7,12 + lea r5, [r1+r2] + jmp stub_%2_h264_qpel%3_mc21_10_%1.body +%endmacro + +MC MC23 diff --git a/libavcodec/x86/h264_qpel_mmx.c b/libavcodec/x86/h264_qpel_mmx.c index 066f794fb6..c313c0e079 100644 --- a/libavcodec/x86/h264_qpel_mmx.c +++ b/libavcodec/x86/h264_qpel_mmx.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt + * Copyright (c) 2011 Daniel Kang * * This file is part of Libav. * @@ -1199,3 +1200,100 @@ H264_MC_816(H264_MC_HV, sse2) H264_MC_816(H264_MC_H, ssse3) H264_MC_816(H264_MC_HV, ssse3) #endif + + + +//10bit +#define LUMA_MC_OP(OP, NUM, DEPTH, TYPE, OPT) \ +void ff_ ## OP ## _h264_qpel ## NUM ## _ ## TYPE ## _ ## DEPTH ## _ ## OPT \ + (uint8_t *dst, uint8_t *src, int stride); + +#define LUMA_MC_ALL(DEPTH, TYPE, OPT) \ + LUMA_MC_OP(put, 4, DEPTH, TYPE, OPT) \ + LUMA_MC_OP(avg, 4, DEPTH, TYPE, OPT) \ + LUMA_MC_OP(put, 8, DEPTH, TYPE, OPT) \ + LUMA_MC_OP(avg, 8, DEPTH, TYPE, OPT) \ + LUMA_MC_OP(put, 16, DEPTH, TYPE, OPT) \ + LUMA_MC_OP(avg, 16, DEPTH, TYPE, OPT) + +#define LUMA_MC_816(DEPTH, TYPE, OPT) \ + LUMA_MC_OP(put, 8, DEPTH, TYPE, OPT) \ + LUMA_MC_OP(avg, 8, DEPTH, TYPE, OPT) \ + LUMA_MC_OP(put, 16, DEPTH, TYPE, OPT) \ + LUMA_MC_OP(avg, 16, DEPTH, TYPE, OPT) + +LUMA_MC_ALL(10, mc00, mmxext) +LUMA_MC_ALL(10, mc10, mmxext) +LUMA_MC_ALL(10, mc20, mmxext) +LUMA_MC_ALL(10, mc30, mmxext) +LUMA_MC_ALL(10, mc01, mmxext) +LUMA_MC_ALL(10, mc11, mmxext) +LUMA_MC_ALL(10, mc21, mmxext) +LUMA_MC_ALL(10, mc31, mmxext) +LUMA_MC_ALL(10, mc02, mmxext) +LUMA_MC_ALL(10, mc12, mmxext) +LUMA_MC_ALL(10, mc22, mmxext) +LUMA_MC_ALL(10, mc32, mmxext) +LUMA_MC_ALL(10, mc03, mmxext) +LUMA_MC_ALL(10, mc13, mmxext) +LUMA_MC_ALL(10, mc23, mmxext) +LUMA_MC_ALL(10, mc33, mmxext) + +LUMA_MC_816(10, mc00, sse2) +LUMA_MC_816(10, mc10, sse2) +LUMA_MC_816(10, mc10, sse2_cache64) +LUMA_MC_816(10, mc10, ssse3_cache64) +LUMA_MC_816(10, mc20, sse2) +LUMA_MC_816(10, mc20, sse2_cache64) +LUMA_MC_816(10, mc20, ssse3_cache64) +LUMA_MC_816(10, mc30, sse2) +LUMA_MC_816(10, mc30, sse2_cache64) +LUMA_MC_816(10, mc30, ssse3_cache64) +LUMA_MC_816(10, mc01, sse2) +LUMA_MC_816(10, mc11, sse2) +LUMA_MC_816(10, mc21, sse2) +LUMA_MC_816(10, mc31, sse2) +LUMA_MC_816(10, mc02, sse2) +LUMA_MC_816(10, mc12, sse2) +LUMA_MC_816(10, mc22, sse2) +LUMA_MC_816(10, mc32, sse2) +LUMA_MC_816(10, mc03, sse2) +LUMA_MC_816(10, mc13, sse2) +LUMA_MC_816(10, mc23, sse2) +LUMA_MC_816(10, mc33, sse2) + +#define QPEL16_OPMC(OP, MC, MMX)\ +void ff_ ## OP ## _h264_qpel16_ ## MC ## _10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ + ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst , src , stride);\ + ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst+16, src+16, stride);\ + src += 8*stride;\ + dst += 8*stride;\ + ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst , src , stride);\ + ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst+16, src+16, stride);\ +} + +#define QPEL16_OP(MC, MMX)\ +QPEL16_OPMC(put, MC, MMX)\ +QPEL16_OPMC(avg, MC, MMX) + +#define QPEL16(MMX)\ +QPEL16_OP(mc00, MMX)\ +QPEL16_OP(mc01, MMX)\ +QPEL16_OP(mc02, MMX)\ +QPEL16_OP(mc03, MMX)\ +QPEL16_OP(mc10, MMX)\ +QPEL16_OP(mc11, MMX)\ +QPEL16_OP(mc12, MMX)\ +QPEL16_OP(mc13, MMX)\ +QPEL16_OP(mc20, MMX)\ +QPEL16_OP(mc21, MMX)\ +QPEL16_OP(mc22, MMX)\ +QPEL16_OP(mc23, MMX)\ +QPEL16_OP(mc30, MMX)\ +QPEL16_OP(mc31, MMX)\ +QPEL16_OP(mc32, MMX)\ +QPEL16_OP(mc33, MMX) + +#if ARCH_X86_32 // ARCH_X86_64 implies sse2+ +QPEL16(mmxext) +#endif From c558122e4ee53dc4cb82f87749a9c28c38ca9401 Mon Sep 17 00:00:00 2001 From: Gavin Kinsey Date: Tue, 21 Jun 2011 13:13:37 +0100 Subject: [PATCH 230/780] Fix segmentation fault in ffprobe --- ffprobe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ffprobe.c b/ffprobe.c index 711a17246d..edda454cde 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -393,6 +393,7 @@ int main(int argc, char **argv) int ret; av_register_all(); + init_opts(); #if CONFIG_AVDEVICE avdevice_register_all(); #endif From 8c94eab011b1d2d1c5f70c2deff3a05e876fbb7d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 17:05:22 +0100 Subject: [PATCH 231/780] configure: do not blank $LIBNAME if static libs disabled Whatever reason this was done for no longer applies, and it causes lots of make warnings. Signed-off-by: Mans Rullgard --- configure | 2 -- 1 file changed, 2 deletions(-) diff --git a/configure b/configure index 9cde17805d..e315afa1cb 100755 --- a/configure +++ b/configure @@ -2524,8 +2524,6 @@ EOF exit 1; fi -disabled static && LIBNAME="" - die_license_disabled() { enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; } } From 03256d96e42f9fba88cc64751da925d65aa2e3f2 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 16:07:37 +0100 Subject: [PATCH 232/780] fate: move libavutil test rules to a separate file Signed-off-by: Mans Rullgard --- tests/Makefile | 1 + tests/fate/libavutil.mak | 22 ++++++++++++++++++++++ tests/fate2.mak | 23 ----------------------- 3 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 tests/fate/libavutil.mak diff --git a/tests/Makefile b/tests/Makefile index e6640b35dd..f69acf7e23 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -43,6 +43,7 @@ include $(SRC_PATH)/tests/fate/amrnb.mak include $(SRC_PATH)/tests/fate/amrwb.mak include $(SRC_PATH)/tests/fate/fft.mak include $(SRC_PATH)/tests/fate/h264.mak +include $(SRC_PATH)/tests/fate/libavutil.mak include $(SRC_PATH)/tests/fate/mp3.mak include $(SRC_PATH)/tests/fate/vorbis.mak include $(SRC_PATH)/tests/fate/vp8.mak diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak new file mode 100644 index 0000000000..2f394ec2df --- /dev/null +++ b/tests/fate/libavutil.mak @@ -0,0 +1,22 @@ +FATE_TESTS += fate-adler32 +fate-adler32: libavutil/adler32-test$(EXESUF) +fate-adler32: CMD = run libavutil/adler32-test +fate-adler32: REF = /dev/null + +FATE_TESTS += fate-aes +fate-aes: libavutil/aes-test$(EXESUF) +fate-aes: CMD = run libavutil/aes-test +fate-aes: REF = /dev/null + +FATE_TESTS += fate-base64 +fate-base64: libavutil/base64-test$(EXESUF) +fate-base64: CMD = run libavutil/base64-test + +FATE_TESTS += fate-des +fate-des: libavutil/des-test$(EXESUF) +fate-des: CMD = run libavutil/des-test +fate-des: REF = /dev/null + +FATE_TESTS += fate-sha +fate-sha: libavutil/sha-test$(EXESUF) +fate-sha: CMD = run libavutil/sha-test diff --git a/tests/fate2.mak b/tests/fate2.mak index 47804c4d8a..ef8c3b8d5b 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -213,29 +213,6 @@ fate-mjpegb: CMD = framecrc -idct simple -flags +bitexact -i $(SAMPLES)/mjpegb/m FATE_TESTS += fate-rv30 fate-rv30: CMD = framecrc -flags +bitexact -dct fastint -idct simple -i $(SAMPLES)/real/rv30.rm -an -FATE_TESTS += fate-sha -fate-sha: libavutil/sha-test$(EXESUF) -fate-sha: CMD = run libavutil/sha-test - -FATE_TESTS += fate-adler32 -fate-adler32: libavutil/adler32-test$(EXESUF) -fate-adler32: CMD = run libavutil/adler32-test -fate-adler32: REF = /dev/null - -FATE_TESTS += fate-aes -fate-aes: libavutil/aes-test$(EXESUF) -fate-aes: CMD = run libavutil/aes-test -fate-aes: REF = /dev/null - -FATE_TESTS += fate-base64 -fate-base64: libavutil/base64-test$(EXESUF) -fate-base64: CMD = run libavutil/base64-test - -FATE_TESTS += fate-des -fate-des: libavutil/des-test$(EXESUF) -fate-des: CMD = run libavutil/des-test -fate-des: REF = /dev/null - FATE_TESTS += fate-musepack7 fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff From 14376a53b20bed4463a0998dfd25012f8a927838 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 16:12:51 +0100 Subject: [PATCH 233/780] crc: add fate test Signed-off-by: Mans Rullgard --- tests/fate/libavutil.mak | 4 ++++ tests/ref/fate/crc | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 tests/ref/fate/crc diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index 2f394ec2df..9fdd450255 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -12,6 +12,10 @@ FATE_TESTS += fate-base64 fate-base64: libavutil/base64-test$(EXESUF) fate-base64: CMD = run libavutil/base64-test +FATE_TESTS += fate-crc +fate-crc: libavutil/crc-test$(EXESUF) +fate-crc: CMD = run libavutil/crc-test + FATE_TESTS += fate-des fate-des: libavutil/des-test$(EXESUF) fate-des: CMD = run libavutil/des-test diff --git a/tests/ref/fate/crc b/tests/ref/fate/crc new file mode 100644 index 0000000000..4a82680490 --- /dev/null +++ b/tests/ref/fate/crc @@ -0,0 +1,4 @@ +crc EDB88320 =3D5CDD04 +crc 04C11DB7 =E0BAF5C0 +crc 00008005 =BB1F +crc 00000007 =E3 From 91c9aa0941869531ce8cadbea8cd333a9c4b1244 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 3 Jul 2011 16:57:26 +0200 Subject: [PATCH 234/780] Move some conditionally used code below the appropriate #ifdef. --- libavformat/asfdec.c | 4 +--- libavutil/des.c | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 16bba93c37..4fafb26259 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -84,13 +84,11 @@ static const ff_asf_guid index_guid = { 0x90, 0x08, 0x00, 0x33, 0xb1, 0xe5, 0xcf, 0x11, 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb }; +#ifdef DEBUG static const ff_asf_guid stream_bitrate_guid = { /* (http://get.to/sdp) */ 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2 }; -/**********************************/ -/* decoding */ -#ifdef DEBUG #define PRINT_IF_GUID(g,cmp) \ if (!ff_guidcmp(g, &cmp)) \ av_dlog(NULL, "(GUID: %s) ", #cmp) diff --git a/libavutil/des.c b/libavutil/des.c index 857ca91319..5de816387f 100644 --- a/libavutil/des.c +++ b/libavutil/des.c @@ -39,6 +39,7 @@ static const uint8_t IP_shuffle[] = { }; #undef T +#if defined(CONFIG_SMALL) || defined(GENTABLES) #define T(a, b, c, d) 32-a,32-b,32-c,32-d static const uint8_t P_shuffle[] = { T(16, 7, 20, 21), @@ -51,6 +52,7 @@ static const uint8_t P_shuffle[] = { T(22, 11, 4, 25) }; #undef T +#endif #define T(a, b, c, d, e, f, g) 64-a,64-b,64-c,64-d,64-e,64-f,64-g static const uint8_t PC1_shuffle[] = { From 050f509065b4f328c4621ef4116848303f0d1db0 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 3 Jul 2011 16:56:21 +0200 Subject: [PATCH 235/780] snow: Remove unused code. --- libavcodec/snow.c | 342 ---------------------------------------------- 1 file changed, 342 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 28f04f119b..4ab029de5c 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -33,42 +33,6 @@ #undef NDEBUG #include -static const int8_t quant3[256]={ - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, -}; -static const int8_t quant3b[256]={ - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -}; static const int8_t quant3bA[256]={ 0, 0, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, @@ -87,153 +51,7 @@ static const int8_t quant3bA[256]={ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, }; -static const int8_t quant5[256]={ - 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-1,-1,-1, -}; -static const int8_t quant7[256]={ - 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, --2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-1,-1, -}; -static const int8_t quant9[256]={ - 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-1,-1, -}; -static const int8_t quant11[256]={ - 0, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, --5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, --5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, --5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, --5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, --5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, --5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-1, -}; -static const int8_t quant13[256]={ - 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, --6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, --6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, --6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, --6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6, --6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-5, --5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, --5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, --4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3,-2,-2,-1, -}; -#if 0 //64*cubic -static const uint8_t obmc32[1024]={ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 4, 4, 4, 4, 8, 8, 12, 12, 12, 16, 16, 16, 16, 16, 16, 16, 16, 12, 12, 12, 8, 8, 4, 4, 4, 4, 0, 0, 0, - 0, 0, 4, 4, 8, 8, 12, 16, 16, 20, 24, 24, 28, 28, 32, 32, 32, 32, 28, 28, 24, 24, 20, 16, 16, 12, 8, 8, 4, 4, 0, 0, - 0, 0, 4, 8, 8, 12, 16, 24, 28, 32, 36, 40, 44, 48, 48, 48, 48, 48, 48, 44, 40, 36, 32, 28, 24, 16, 12, 8, 8, 4, 0, 0, - 0, 4, 4, 8, 12, 20, 24, 32, 40, 44, 52, 56, 60, 64, 68, 72, 72, 68, 64, 60, 56, 52, 44, 40, 32, 24, 20, 12, 8, 4, 4, 0, - 0, 4, 4, 12, 16, 24, 32, 40, 52, 60, 68, 76, 80, 88, 88, 92, 92, 88, 88, 80, 76, 68, 60, 52, 40, 32, 24, 16, 12, 4, 4, 0, - 0, 4, 8, 16, 24, 32, 40, 52, 64, 76, 84, 92,100,108,112,116,116,112,108,100, 92, 84, 76, 64, 52, 40, 32, 24, 16, 8, 4, 0, - 0, 4, 8, 16, 28, 40, 52, 64, 76, 88,100,112,124,132,136,140,140,136,132,124,112,100, 88, 76, 64, 52, 40, 28, 16, 8, 4, 0, - 0, 4, 12, 20, 32, 44, 60, 76, 88,104,120,132,144,152,160,164,164,160,152,144,132,120,104, 88, 76, 60, 44, 32, 20, 12, 4, 0, - 0, 4, 12, 24, 36, 48, 68, 84,100,120,136,152,164,176,180,184,184,180,176,164,152,136,120,100, 84, 68, 48, 36, 24, 12, 4, 0, - 0, 4, 12, 24, 40, 56, 76, 92,112,132,152,168,180,192,204,208,208,204,192,180,168,152,132,112, 92, 76, 56, 40, 24, 12, 4, 0, - 0, 4, 16, 28, 44, 60, 80,100,124,144,164,180,196,208,220,224,224,220,208,196,180,164,144,124,100, 80, 60, 44, 28, 16, 4, 0, - 0, 8, 16, 28, 48, 64, 88,108,132,152,176,192,208,224,232,240,240,232,224,208,192,176,152,132,108, 88, 64, 48, 28, 16, 8, 0, - 0, 4, 16, 32, 48, 68, 88,112,136,160,180,204,220,232,244,248,248,244,232,220,204,180,160,136,112, 88, 68, 48, 32, 16, 4, 0, - 1, 8, 16, 32, 48, 72, 92,116,140,164,184,208,224,240,248,255,255,248,240,224,208,184,164,140,116, 92, 72, 48, 32, 16, 8, 1, - 1, 8, 16, 32, 48, 72, 92,116,140,164,184,208,224,240,248,255,255,248,240,224,208,184,164,140,116, 92, 72, 48, 32, 16, 8, 1, - 0, 4, 16, 32, 48, 68, 88,112,136,160,180,204,220,232,244,248,248,244,232,220,204,180,160,136,112, 88, 68, 48, 32, 16, 4, 0, - 0, 8, 16, 28, 48, 64, 88,108,132,152,176,192,208,224,232,240,240,232,224,208,192,176,152,132,108, 88, 64, 48, 28, 16, 8, 0, - 0, 4, 16, 28, 44, 60, 80,100,124,144,164,180,196,208,220,224,224,220,208,196,180,164,144,124,100, 80, 60, 44, 28, 16, 4, 0, - 0, 4, 12, 24, 40, 56, 76, 92,112,132,152,168,180,192,204,208,208,204,192,180,168,152,132,112, 92, 76, 56, 40, 24, 12, 4, 0, - 0, 4, 12, 24, 36, 48, 68, 84,100,120,136,152,164,176,180,184,184,180,176,164,152,136,120,100, 84, 68, 48, 36, 24, 12, 4, 0, - 0, 4, 12, 20, 32, 44, 60, 76, 88,104,120,132,144,152,160,164,164,160,152,144,132,120,104, 88, 76, 60, 44, 32, 20, 12, 4, 0, - 0, 4, 8, 16, 28, 40, 52, 64, 76, 88,100,112,124,132,136,140,140,136,132,124,112,100, 88, 76, 64, 52, 40, 28, 16, 8, 4, 0, - 0, 4, 8, 16, 24, 32, 40, 52, 64, 76, 84, 92,100,108,112,116,116,112,108,100, 92, 84, 76, 64, 52, 40, 32, 24, 16, 8, 4, 0, - 0, 4, 4, 12, 16, 24, 32, 40, 52, 60, 68, 76, 80, 88, 88, 92, 92, 88, 88, 80, 76, 68, 60, 52, 40, 32, 24, 16, 12, 4, 4, 0, - 0, 4, 4, 8, 12, 20, 24, 32, 40, 44, 52, 56, 60, 64, 68, 72, 72, 68, 64, 60, 56, 52, 44, 40, 32, 24, 20, 12, 8, 4, 4, 0, - 0, 0, 4, 8, 8, 12, 16, 24, 28, 32, 36, 40, 44, 48, 48, 48, 48, 48, 48, 44, 40, 36, 32, 28, 24, 16, 12, 8, 8, 4, 0, 0, - 0, 0, 4, 4, 8, 8, 12, 16, 16, 20, 24, 24, 28, 28, 32, 32, 32, 32, 28, 28, 24, 24, 20, 16, 16, 12, 8, 8, 4, 4, 0, 0, - 0, 0, 0, 4, 4, 4, 4, 8, 8, 12, 12, 12, 16, 16, 16, 16, 16, 16, 16, 16, 12, 12, 12, 8, 8, 4, 4, 4, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -//error:0.000022 -}; -static const uint8_t obmc16[256]={ - 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, - 0, 4, 4, 8, 16, 20, 20, 24, 24, 20, 20, 16, 8, 4, 4, 0, - 0, 4, 16, 24, 36, 44, 52, 60, 60, 52, 44, 36, 24, 16, 4, 0, - 0, 8, 24, 44, 60, 80, 96,104,104, 96, 80, 60, 44, 24, 8, 0, - 0, 16, 36, 60, 92,116,136,152,152,136,116, 92, 60, 36, 16, 0, - 0, 20, 44, 80,116,152,180,196,196,180,152,116, 80, 44, 20, 0, - 4, 20, 52, 96,136,180,212,228,228,212,180,136, 96, 52, 20, 4, - 4, 24, 60,104,152,196,228,248,248,228,196,152,104, 60, 24, 4, - 4, 24, 60,104,152,196,228,248,248,228,196,152,104, 60, 24, 4, - 4, 20, 52, 96,136,180,212,228,228,212,180,136, 96, 52, 20, 4, - 0, 20, 44, 80,116,152,180,196,196,180,152,116, 80, 44, 20, 0, - 0, 16, 36, 60, 92,116,136,152,152,136,116, 92, 60, 36, 16, 0, - 0, 8, 24, 44, 60, 80, 96,104,104, 96, 80, 60, 44, 24, 8, 0, - 0, 4, 16, 24, 36, 44, 52, 60, 60, 52, 44, 36, 24, 16, 4, 0, - 0, 4, 4, 8, 16, 20, 20, 24, 24, 20, 20, 16, 8, 4, 4, 0, - 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, -//error:0.000033 -}; -#elif 1 // 64*linear static const uint8_t obmc32[1024]={ 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 16, 20, 20, 20, 24, 24, 20, 20, 20, 16, 16, 16, 12, 12, 8, 8, 8, 4, 4, 4, 0, @@ -288,62 +106,6 @@ static const uint8_t obmc16[256]={ 0, 4, 4, 8, 8, 12, 12, 16, 16, 12, 12, 8, 8, 4, 4, 0, //error:0.000015 }; -#else //64*cos -static const uint8_t obmc32[1024]={ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 4, 4, 4, 4, 8, 8, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16, 12, 12, 12, 12, 8, 8, 4, 4, 4, 4, 0, 0, 0, - 0, 0, 4, 4, 4, 8, 8, 12, 16, 20, 20, 24, 28, 28, 28, 28, 28, 28, 28, 28, 24, 20, 20, 16, 12, 8, 8, 4, 4, 4, 0, 0, - 0, 0, 4, 4, 8, 12, 16, 20, 24, 28, 36, 40, 44, 44, 48, 48, 48, 48, 44, 44, 40, 36, 28, 24, 20, 16, 12, 8, 4, 4, 0, 0, - 0, 0, 4, 8, 12, 20, 24, 32, 36, 44, 48, 56, 60, 64, 68, 68, 68, 68, 64, 60, 56, 48, 44, 36, 32, 24, 20, 12, 8, 4, 0, 0, - 0, 4, 4, 8, 16, 24, 32, 40, 48, 60, 68, 76, 80, 84, 88, 92, 92, 88, 84, 80, 76, 68, 60, 48, 40, 32, 24, 16, 8, 4, 4, 0, - 0, 4, 8, 12, 20, 32, 40, 52, 64, 76, 84, 96,104,108,112,116,116,112,108,104, 96, 84, 76, 64, 52, 40, 32, 20, 12, 8, 4, 0, - 0, 4, 8, 16, 24, 36, 48, 64, 76, 92,104,116,124,132,136,140,140,136,132,124,116,104, 92, 76, 64, 48, 36, 24, 16, 8, 4, 0, - 0, 4, 12, 20, 28, 44, 60, 76, 92,104,120,136,148,156,160,164,164,160,156,148,136,120,104, 92, 76, 60, 44, 28, 20, 12, 4, 0, - 0, 4, 12, 20, 36, 48, 68, 84,104,120,140,152,168,176,184,188,188,184,176,168,152,140,120,104, 84, 68, 48, 36, 20, 12, 4, 0, - 0, 4, 12, 24, 36, 56, 76, 96,116,136,152,172,184,196,204,208,208,204,196,184,172,152,136,116, 96, 76, 56, 36, 24, 12, 4, 0, - 0, 4, 12, 24, 44, 60, 80,104,124,148,168,184,200,212,224,228,228,224,212,200,184,168,148,124,104, 80, 60, 44, 24, 12, 4, 0, - 0, 4, 12, 28, 44, 64, 84,108,132,156,176,196,212,228,236,240,240,236,228,212,196,176,156,132,108, 84, 64, 44, 28, 12, 4, 0, - 0, 4, 16, 28, 48, 68, 88,112,136,160,184,204,224,236,244,252,252,244,236,224,204,184,160,136,112, 88, 68, 48, 28, 16, 4, 0, - 1, 4, 16, 28, 48, 68, 92,116,140,164,188,208,228,240,252,255,255,252,240,228,208,188,164,140,116, 92, 68, 48, 28, 16, 4, 1, - 1, 4, 16, 28, 48, 68, 92,116,140,164,188,208,228,240,252,255,255,252,240,228,208,188,164,140,116, 92, 68, 48, 28, 16, 4, 1, - 0, 4, 16, 28, 48, 68, 88,112,136,160,184,204,224,236,244,252,252,244,236,224,204,184,160,136,112, 88, 68, 48, 28, 16, 4, 0, - 0, 4, 12, 28, 44, 64, 84,108,132,156,176,196,212,228,236,240,240,236,228,212,196,176,156,132,108, 84, 64, 44, 28, 12, 4, 0, - 0, 4, 12, 24, 44, 60, 80,104,124,148,168,184,200,212,224,228,228,224,212,200,184,168,148,124,104, 80, 60, 44, 24, 12, 4, 0, - 0, 4, 12, 24, 36, 56, 76, 96,116,136,152,172,184,196,204,208,208,204,196,184,172,152,136,116, 96, 76, 56, 36, 24, 12, 4, 0, - 0, 4, 12, 20, 36, 48, 68, 84,104,120,140,152,168,176,184,188,188,184,176,168,152,140,120,104, 84, 68, 48, 36, 20, 12, 4, 0, - 0, 4, 12, 20, 28, 44, 60, 76, 92,104,120,136,148,156,160,164,164,160,156,148,136,120,104, 92, 76, 60, 44, 28, 20, 12, 4, 0, - 0, 4, 8, 16, 24, 36, 48, 64, 76, 92,104,116,124,132,136,140,140,136,132,124,116,104, 92, 76, 64, 48, 36, 24, 16, 8, 4, 0, - 0, 4, 8, 12, 20, 32, 40, 52, 64, 76, 84, 96,104,108,112,116,116,112,108,104, 96, 84, 76, 64, 52, 40, 32, 20, 12, 8, 4, 0, - 0, 4, 4, 8, 16, 24, 32, 40, 48, 60, 68, 76, 80, 84, 88, 92, 92, 88, 84, 80, 76, 68, 60, 48, 40, 32, 24, 16, 8, 4, 4, 0, - 0, 0, 4, 8, 12, 20, 24, 32, 36, 44, 48, 56, 60, 64, 68, 68, 68, 68, 64, 60, 56, 48, 44, 36, 32, 24, 20, 12, 8, 4, 0, 0, - 0, 0, 4, 4, 8, 12, 16, 20, 24, 28, 36, 40, 44, 44, 48, 48, 48, 48, 44, 44, 40, 36, 28, 24, 20, 16, 12, 8, 4, 4, 0, 0, - 0, 0, 4, 4, 4, 8, 8, 12, 16, 20, 20, 24, 28, 28, 28, 28, 28, 28, 28, 28, 24, 20, 20, 16, 12, 8, 8, 4, 4, 4, 0, 0, - 0, 0, 0, 4, 4, 4, 4, 8, 8, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16, 12, 12, 12, 12, 8, 8, 4, 4, 4, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -//error:0.000022 -}; -static const uint8_t obmc16[256]={ - 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, - 0, 0, 4, 8, 12, 16, 20, 20, 20, 20, 16, 12, 8, 4, 0, 0, - 0, 4, 12, 24, 32, 44, 52, 56, 56, 52, 44, 32, 24, 12, 4, 0, - 0, 8, 24, 40, 60, 80, 96,104,104, 96, 80, 60, 40, 24, 8, 0, - 0, 12, 32, 64, 92,120,140,152,152,140,120, 92, 64, 32, 12, 0, - 4, 16, 44, 80,120,156,184,196,196,184,156,120, 80, 44, 16, 4, - 4, 20, 52, 96,140,184,216,232,232,216,184,140, 96, 52, 20, 4, - 0, 20, 56,104,152,196,232,252,252,232,196,152,104, 56, 20, 0, - 0, 20, 56,104,152,196,232,252,252,232,196,152,104, 56, 20, 0, - 4, 20, 52, 96,140,184,216,232,232,216,184,140, 96, 52, 20, 4, - 4, 16, 44, 80,120,156,184,196,196,184,156,120, 80, 44, 16, 4, - 0, 12, 32, 64, 92,120,140,152,152,140,120, 92, 64, 32, 12, 0, - 0, 8, 24, 40, 60, 80, 96,104,104, 96, 80, 60, 40, 24, 8, 0, - 0, 4, 12, 24, 32, 44, 52, 56, 56, 52, 44, 32, 24, 12, 4, 0, - 0, 0, 4, 8, 12, 16, 20, 20, 20, 20, 16, 12, 8, 4, 0, 0, - 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, -//error:0.000022 -}; -#endif /* 0 */ //linear *64 static const uint8_t obmc8[64]={ @@ -509,7 +271,6 @@ static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signe if(v){ const int a= FFABS(v); const int e= av_log2(a); -#if 1 const int el= FFMIN(e, 10); put_rac(c, state+0, 0); @@ -530,35 +291,6 @@ static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signe if(is_signed) put_rac(c, state+11 + el, v < 0); //11..21 -#else - - put_rac(c, state+0, 0); - if(e<=9){ - for(i=0; i=0; i--){ - put_rac(c, state+22+i, (a>>i)&1); //22..31 - } - - if(is_signed) - put_rac(c, state+11 + e, v < 0); //11..21 - }else{ - for(i=0; i=0; i--){ - put_rac(c, state+22+FFMIN(i,9), (a>>i)&1); //22..31 - } - - if(is_signed) - put_rac(c, state+11 + 10, v < 0); //11..21 - } -#endif /* 1 */ }else{ put_rac(c, state+0, 1); } @@ -789,14 +521,6 @@ static int alloc_blocks(SnowContext *s){ return 0; } -static inline void copy_rac_state(RangeCoder *d, RangeCoder *s){ - uint8_t *bytestream= d->bytestream; - uint8_t *bytestream_start= d->bytestream_start; - *d= *s; - d->bytestream= bytestream; - d->bytestream_start= bytestream_start; -} - static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, int cb, int cr, int mx, int my, int ref, int type){ const int w= s->b_width << s->block_max_depth; const int rem_depth= s->block_max_depth - level; @@ -1323,40 +1047,6 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer block[3]= ptmp; pred_block(s, block[3], tmp, src_stride, src_x, src_y, b_w, b_h, rb, plane_index, w, h); } -#if 0 - for(y=0; y>1); - for(x=0; x>1); - for(x=0; x>1); - uint8_t *obmc4= obmc3+ (obmc_stride>>1); - for(x=0; xdwt.inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8); }else{ @@ -1387,7 +1077,6 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer } } } -#endif /* 0 */ } static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, IDWTELEM * old_buffer, int plane_index, int add, int mb_y){ @@ -4042,27 +3731,6 @@ int main(void){ for(i=0; i20) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]); -#if 0 - printf("testing AC coder\n"); - memset(s.header_state, 0, sizeof(s.header_state)); - ff_init_range_encoder(&s.c, buffer[0], 256*256); - ff_init_cabac_states(&s.c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64); - - for(i=-256; i<256; i++){ - put_symbol(&s.c, s.header_state, i*i*i/3*FFABS(i), 1); - } - ff_rac_terminate(&s.c); - - memset(s.header_state, 0, sizeof(s.header_state)); - ff_init_range_decoder(&s.c, buffer[0], 256*256); - ff_init_cabac_states(&s.c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64); - - for(i=-256; i<256; i++){ - int j; - j= get_symbol(&s.c, s.header_state, 1); - if(j!=i*i*i/3*FFABS(i)) printf("fsck: %d != %d\n", i, j); - } -#endif { int level, orientation, x, y; int64_t errors[8][4]; @@ -4120,7 +3788,6 @@ int main(void){ buf+=stride>>1; memset(buffer[0], 0, sizeof(int)*width*height); -#if 1 for(y=0; y Date: Sun, 3 Jul 2011 13:45:23 +0200 Subject: [PATCH 236/780] doxygen: Fix execute_code() @return documentation. --- libavcodec/ansi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c index e46879dd6b..32c7ce4ecd 100644 --- a/libavcodec/ansi.c +++ b/libavcodec/ansi.c @@ -153,7 +153,7 @@ static void draw_char(AVCodecContext *avctx, int c) /** * Execute ANSI escape code - * @param <0 error + * @return 0 on success, negative on error */ static int execute_code(AVCodecContext * avctx, int c) { From 01c17c88ede76f8321cf2c59a535dbbc5b5ff989 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 3 Jul 2011 16:11:16 +0200 Subject: [PATCH 237/780] doxygen: Remove spurious documentation for non-existing function parameters. --- libavcodec/h264idct_template.c | 1 - libswscale/swscale.h | 1 - 2 files changed, 2 deletions(-) diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c index e7f9af7fb0..e288f9bf1b 100644 --- a/libavcodec/h264idct_template.c +++ b/libavcodec/h264idct_template.c @@ -237,7 +237,6 @@ void FUNCC(ff_h264_idct_add8)(uint8_t **dest, const int *block_offset, DCTELEM * } /** * IDCT transforms the 16 dc values and dequantizes them. - * @param qp quantization parameter */ void FUNCC(ff_h264_luma_dc_dequant_idct)(DCTELEM *_output, DCTELEM *_input, int qmul){ #define stride 16 diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 2aa5e50ab2..3899596983 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -235,7 +235,6 @@ int sws_scale(struct SwsContext *context, const uint8_t* const srcSlice[], const /** * @param inv_table the yuv2rgb coefficients, normally ff_yuv2rgb_coeffs[x] - * @param fullRange if 1 then the luma range is 0..255 if 0 it is 16..235 * @return -1 if not supported */ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], From 24c9babaaf458f943ed1ef74628d157ac29c5d5f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 2 Jul 2011 13:23:35 +0200 Subject: [PATCH 238/780] doxygen: Fix parameter names to match the function prototypes. --- libavcodec/aacps.c | 2 +- libavcodec/lpc.c | 2 +- libavcodec/vp8.c | 2 +- libavfilter/graphparser.c | 2 +- libavformat/wtv.c | 2 +- libavutil/imgutils.h | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c index 724c13256a..d818790a6f 100644 --- a/libavcodec/aacps.c +++ b/libavcodec/aacps.c @@ -77,7 +77,7 @@ static VLC vlc_ps[10]; * @param avctx contains the current codec context * @param gb pointer to the input bitstream * @param ps pointer to the Parametric Stereo context - * @param par pointer to the parameter to be read + * @param PAR pointer to the parameter to be read * @param e envelope to decode * @param dt 1: time delta-coded, 0: frequency delta-coded */ diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c index ed985d36ff..31fa324216 100644 --- a/libavcodec/lpc.c +++ b/libavcodec/lpc.c @@ -149,7 +149,7 @@ static int estimate_best_order(double *ref, int min_order, int max_order) /** * Calculate LPC coefficients for multiple orders * - * @param use_lpc LPC method for determining coefficients + * @param lpc_type LPC method for determining coefficients * 0 = LPC with fixed pre-defined coeffs * 1 = LPC with coeffs determined by Levinson-Durbin recursion * 2+ = LPC with coeffs determined by Cholesky factorization using (use_lpc-1) passes. diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 282d2fdb4e..fdf63f095d 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -1039,7 +1039,7 @@ static const uint8_t subpel_idx[3][8] = { * @param s VP8 decoding context * @param luma 1 for luma (Y) planes, 0 for chroma (Cb/Cr) planes * @param dst target buffer for block data at block position - * @param src reference picture buffer at origin (0, 0) + * @param ref reference picture buffer at origin (0, 0) * @param mv motion vector (relative to block position) to get pixel data from * @param x_off horizontal position of block from origin (0, 0) * @param y_off vertical position of block from origin (0, 0) diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index 00fb57ad57..c1624d8471 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -83,8 +83,8 @@ static char *parse_link_name(const char **buf, AVClass *log_ctx) * Create an instance of a filter, initialize and insert it in the * filtergraph in *ctx. * + * @param filt_ctx put here a filter context in case of successful creation and configuration, NULL otherwise. * @param ctx the filtergraph context - * @param put here a filter context in case of successful creation and configuration, NULL otherwise. * @param index an index which is supposed to be unique for each filter instance added to the filtergraph * @param filt_name the name of the filter to create * @param args the arguments provided to the filter during its initialization diff --git a/libavformat/wtv.c b/libavformat/wtv.c index 0f9fdeff06..cc6fc8be48 100644 --- a/libavformat/wtv.c +++ b/libavformat/wtv.c @@ -766,7 +766,7 @@ enum { * Parse WTV chunks * @param mode SEEK_TO_DATA or SEEK_TO_PTS * @param seekts timestamp - * @param[out] len Length of data chunk + * @param[out] len_ptr Length of data chunk * @return stream index of data chunk, or <0 on error */ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_ptr) diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index b569eb1ca4..0666a28ef5 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -106,8 +106,8 @@ void av_image_copy_plane(uint8_t *dst, int dst_linesize, /** * Copy image in src_data to dst_data. * - * @param dst_linesize linesizes for the image in dst_data - * @param src_linesize linesizes for the image in src_data + * @param dst_linesizes linesizes for the image in dst_data + * @param src_linesizes linesizes for the image in src_data */ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], From ff993cd7fcdfeffcac10337c0c6b69c599060c2b Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 2 Jul 2011 14:42:27 +0200 Subject: [PATCH 239/780] doxygen: Drop array size declarations from Doxygen parameter names. Adding [] to a Doxygen parameter name clashes with Doxygen syntax. --- libavcodec/cook.c | 2 +- libavcodec/motion_est_template.c | 2 +- libavutil/imgutils.h | 2 +- libavutil/lfg.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 8d1078145e..b5492db27b 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -335,7 +335,7 @@ static av_cold int cook_decode_close(AVCodecContext *avctx) * Fill the gain array for the timedomain quantization. * * @param gb pointer to the GetBitContext - * @param gaininfo[9] array of gain indexes + * @param gaininfo array[9] of gain indexes */ static void decode_gain_info(GetBitContext *gb, int *gaininfo) diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index b451c76bb4..576bb3da43 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -991,7 +991,7 @@ static av_always_inline int diamond_search(MpegEncContext * s, int *best, int dm } /** - @param P[10][2] a list of candidate mvs to check before starting the + @param P a list of candidate mvs to check before starting the iterative search. If one of the candidates is close to the optimal mv, then it takes fewer iterations. And it increases the chance that we find the optimal mv. diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index 0666a28ef5..6017a70f71 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -69,7 +69,7 @@ int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int widt * * @param data pointers array to be filled with the pointer for each image plane * @param ptr the pointer to a buffer which will contain the image - * @param linesizes[4] the array containing the linesize for each + * @param linesizes the array containing the linesize for each * plane, should be filled by av_image_fill_linesizes() * @return the size in bytes required for the image buffer, a negative * error code in case of failure diff --git a/libavutil/lfg.h b/libavutil/lfg.h index 89a635a1b0..904d00a669 100644 --- a/libavutil/lfg.h +++ b/libavutil/lfg.h @@ -55,7 +55,7 @@ static inline unsigned int av_mlfg_get(AVLFG *c){ * Get the next two numbers generated by a Box-Muller Gaussian * generator using the random numbers issued by lfg. * - * @param out[2] array where the two generated numbers are placed + * @param out array where the two generated numbers are placed */ void av_bmg_get(AVLFG *lfg, double out[2]); From edf4dbff33d8ab5653ecc9124bf4333cf05bab2a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 17:50:38 +0100 Subject: [PATCH 240/780] md5: fix test program This makes the md5-test program print something meaningful and not smash the stack. Signed-off-by: Mans Rullgard --- libavutil/md5.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libavutil/md5.c b/libavutil/md5.c index 271d71f48f..b0c678bc27 100644 --- a/libavutil/md5.c +++ b/libavutil/md5.c @@ -162,21 +162,29 @@ void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len){ } #ifdef TEST -#include -#include #undef printf +#include + +static void print_md5(uint8_t *md5) +{ + int i; + for (i = 0; i < 16; i++) + printf("%02x", md5[i]); + printf("\n"); +} + int main(void){ - uint64_t md5val; + uint8_t md5val[16]; int i; uint8_t in[1000]; for(i=0; i<1000; i++) in[i]= i*i; - av_md5_sum( (uint8_t*)&md5val, in, 1000); printf("%"PRId64"\n", md5val); - av_md5_sum( (uint8_t*)&md5val, in, 63); printf("%"PRId64"\n", md5val); - av_md5_sum( (uint8_t*)&md5val, in, 64); printf("%"PRId64"\n", md5val); - av_md5_sum( (uint8_t*)&md5val, in, 65); printf("%"PRId64"\n", md5val); + av_md5_sum(md5val, in, 1000); print_md5(md5val); + av_md5_sum(md5val, in, 63); print_md5(md5val); + av_md5_sum(md5val, in, 64); print_md5(md5val); + av_md5_sum(md5val, in, 65); print_md5(md5val); for(i=0; i<1000; i++) in[i]= i % 127; - av_md5_sum( (uint8_t*)&md5val, in, 999); printf("%"PRId64"\n", md5val); + av_md5_sum(md5val, in, 999); print_md5(md5val); return 0; } From 44496ff2d60d3f49b55ea794284504a16c2ba4c5 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 17:51:02 +0100 Subject: [PATCH 241/780] md5: include correct headers This file needs stdint.h but not string.h Signed-off-by: Mans Rullgard --- libavutil/md5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/md5.c b/libavutil/md5.c index b0c678bc27..74e109b72d 100644 --- a/libavutil/md5.c +++ b/libavutil/md5.c @@ -30,7 +30,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include #include "bswap.h" #include "md5.h" From 8b53755ebd8310bfa9d92013712d2abc07af59ef Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 17:51:34 +0100 Subject: [PATCH 242/780] md5: add fate test Signed-off-by: Mans Rullgard --- tests/fate/libavutil.mak | 4 ++++ tests/ref/fate/md5 | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 tests/ref/fate/md5 diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index 9fdd450255..d83ced8a98 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -21,6 +21,10 @@ fate-des: libavutil/des-test$(EXESUF) fate-des: CMD = run libavutil/des-test fate-des: REF = /dev/null +FATE_TESTS += fate-md5 +fate-md5: libavutil/md5-test$(EXESUF) +fate-md5: CMD = run libavutil/md5-test + FATE_TESTS += fate-sha fate-sha: libavutil/sha-test$(EXESUF) fate-sha: CMD = run libavutil/sha-test diff --git a/tests/ref/fate/md5 b/tests/ref/fate/md5 new file mode 100644 index 0000000000..af08a8477f --- /dev/null +++ b/tests/ref/fate/md5 @@ -0,0 +1,5 @@ +0bf1bcc8a1d72e2cf58d42182b637e56 +993a3eb298e52aca83ecfbb6a766b4d0 +07c01ca7c733475fad38c84c56f305c1 +9fc8404827cac26385f48f4f58fd32ce +a22bfef14302c5ca46e0ae91092bc0e0 From fa49fc72d9f25c1b2dccf7a4c43aa9b027e80e4b Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 18:01:26 +0100 Subject: [PATCH 243/780] md5: use AV_WL32 to write result This is simpler, safer, and removes the undocumented requirement of aligned output buffer. Signed-off-by: Mans Rullgard --- libavutil/md5.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavutil/md5.c b/libavutil/md5.c index 74e109b72d..a06e5eae81 100644 --- a/libavutil/md5.c +++ b/libavutil/md5.c @@ -32,6 +32,7 @@ #include #include "bswap.h" +#include "intreadwrite.h" #include "md5.h" typedef struct AVMD5{ @@ -150,7 +151,7 @@ void av_md5_final(AVMD5 *ctx, uint8_t *dst){ av_md5_update(ctx, (uint8_t*)&finalcount, 8); for(i=0; i<4; i++) - ((uint32_t*)dst)[i]= av_le2ne32(ctx->ABCD[3-i]); + AV_WL32(dst + 4*i, ctx->ABCD[3-i]); } void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len){ From 82494cad9db1f32f13b6643b7dce15f2688e3f27 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 18:18:26 +0100 Subject: [PATCH 244/780] md5: cosmetics Signed-off-by: Mans Rullgard --- libavutil/md5.c | 107 +++++++++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 47 deletions(-) diff --git a/libavutil/md5.c b/libavutil/md5.c index a06e5eae81..ca0e598d2e 100644 --- a/libavutil/md5.c +++ b/libavutil/md5.c @@ -41,7 +41,7 @@ typedef struct AVMD5{ uint32_t ABCD[4]; } AVMD5; -const int av_md5_size= sizeof(AVMD5); +const int av_md5_size = sizeof(AVMD5); static const uint8_t S[4][4] = { { 7, 12, 17, 22 }, /* round 1 */ @@ -72,42 +72,49 @@ static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32) 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391, }; -#define CORE(i, a, b, c, d) \ - t = S[i>>4][i&3];\ - a += T[i];\ -\ - if(i<32){\ - if(i<16) a += (d ^ (b&(c^d))) + X[ i &15 ];\ - else a += (c ^ (d&(c^b))) + X[ (1+5*i)&15 ];\ - }else{\ - if(i<48) a += (b^c^d) + X[ (5+3*i)&15 ];\ - else a += (c^(b|~d)) + X[ ( 7*i)&15 ];\ - }\ - a = b + (( a << t ) | ( a >> (32 - t) )); - -static void body(uint32_t ABCD[4], uint32_t X[16]){ +#define CORE(i, a, b, c, d) do { \ + t = S[i >> 4][i & 3]; \ + a += T[i]; \ + \ + if (i < 32) { \ + if (i < 16) a += (d ^ (b & (c ^ d))) + X[ i & 15]; \ + else a += (c ^ (d & (c ^ b))) + X[(1 + 5*i) & 15]; \ + } else { \ + if (i < 48) a += (b ^ c ^ d) + X[(5 + 3*i) & 15]; \ + else a += (c ^ (b | ~d)) + X[( 7*i) & 15]; \ + } \ + a = b + (a << t | a >> (32 - t)); \ + } while (0) +static void body(uint32_t ABCD[4], uint32_t X[16]) +{ int t; int i av_unused; - unsigned int a= ABCD[3]; - unsigned int b= ABCD[2]; - unsigned int c= ABCD[1]; - unsigned int d= ABCD[0]; + unsigned int a = ABCD[3]; + unsigned int b = ABCD[2]; + unsigned int c = ABCD[1]; + unsigned int d = ABCD[0]; #if HAVE_BIGENDIAN - for(i=0; i<16; i++) - X[i]= av_bswap32(X[i]); + for (i = 0; i < 16; i++) + X[i] = av_bswap32(X[i]); #endif #if CONFIG_SMALL - for( i = 0; i < 64; i++ ){ - CORE(i,a,b,c,d) - t=d; d=c; c=b; b=a; a=t; + for (i = 0; i < 64; i++) { + CORE(i, a, b, c, d); + t = d; + d = c; + c = b; + b = a; + a = t; } #else -#define CORE2(i) CORE(i,a,b,c,d) CORE((i+1),d,a,b,c) CORE((i+2),c,d,a,b) CORE((i+3),b,c,d,a) -#define CORE4(i) CORE2(i) CORE2((i+4)) CORE2((i+8)) CORE2((i+12)) -CORE4(0) CORE4(16) CORE4(32) CORE4(48) +#define CORE2(i) \ + CORE( i, a,b,c,d); CORE((i+1),d,a,b,c); \ + CORE((i+2),c,d,a,b); CORE((i+3),b,c,d,a) +#define CORE4(i) CORE2(i); CORE2((i+4)); CORE2((i+8)); CORE2((i+12)) + CORE4(0); CORE4(16); CORE4(32); CORE4(48); #endif ABCD[0] += d; @@ -116,8 +123,9 @@ CORE4(0) CORE4(16) CORE4(32) CORE4(48) ABCD[3] += a; } -void av_md5_init(AVMD5 *ctx){ - ctx->len = 0; +void av_md5_init(AVMD5 *ctx) +{ + ctx->len = 0; ctx->ABCD[0] = 0x10325476; ctx->ABCD[1] = 0x98badcfe; @@ -125,41 +133,44 @@ void av_md5_init(AVMD5 *ctx){ ctx->ABCD[3] = 0x67452301; } -void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len){ +void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len) +{ int i, j; - j= ctx->len & 63; + j = ctx->len & 63; ctx->len += len; - for( i = 0; i < len; i++ ){ + for (i = 0; i < len; i++) { ctx->block[j++] = src[i]; - if( 64 == j ){ - body(ctx->ABCD, (uint32_t*) ctx->block); + if (j == 64) { + body(ctx->ABCD, (uint32_t *) ctx->block); j = 0; } } } -void av_md5_final(AVMD5 *ctx, uint8_t *dst){ +void av_md5_final(AVMD5 *ctx, uint8_t *dst) +{ int i; - uint64_t finalcount= av_le2ne64(ctx->len<<3); + uint64_t finalcount = av_le2ne64(ctx->len << 3); av_md5_update(ctx, "\200", 1); - while((ctx->len & 63)!=56) + while ((ctx->len & 63) != 56) av_md5_update(ctx, "", 1); - av_md5_update(ctx, (uint8_t*)&finalcount, 8); + av_md5_update(ctx, (uint8_t *)&finalcount, 8); - for(i=0; i<4; i++) - AV_WL32(dst + 4*i, ctx->ABCD[3-i]); + for (i = 0; i < 4; i++) + AV_WL32(dst + 4*i, ctx->ABCD[3 - i]); } -void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len){ - AVMD5 ctx[1]; +void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len) +{ + AVMD5 ctx; - av_md5_init(ctx); - av_md5_update(ctx, src, len); - av_md5_final(ctx, dst); + av_md5_init(&ctx); + av_md5_update(&ctx, src, len); + av_md5_final(&ctx, dst); } #ifdef TEST @@ -179,12 +190,14 @@ int main(void){ int i; uint8_t in[1000]; - for(i=0; i<1000; i++) in[i]= i*i; + for (i = 0; i < 1000; i++) + in[i] = i * i; av_md5_sum(md5val, in, 1000); print_md5(md5val); av_md5_sum(md5val, in, 63); print_md5(md5val); av_md5_sum(md5val, in, 64); print_md5(md5val); av_md5_sum(md5val, in, 65); print_md5(md5val); - for(i=0; i<1000; i++) in[i]= i % 127; + for (i = 0; i < 1000; i++) + in[i] = i % 127; av_md5_sum(md5val, in, 999); print_md5(md5val); return 0; From c81a2b9b4f5488c831dc27635152394ab632c46a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 3 Jul 2011 16:33:25 +0200 Subject: [PATCH 245/780] doxygen: Escape '\' in Doxygen documentation. --- libavformat/internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 30faa00e95..aba890def4 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -157,14 +157,14 @@ void ff_put_v(AVIOContext *bc, uint64_t val); /** * Read a whole line of text from AVIOContext. Stop reading after reaching - * either a \n, a \0 or EOF. The returned string is always \0 terminated, + * either a \\n, a \\0 or EOF. The returned string is always \\0-terminated, * and may be truncated if the buffer is too small. * * @param s the read-only AVIOContext * @param buf buffer to store the read line * @param maxlen size of the buffer * @return the length of the string written in the buffer, not including the - * final \0 + * final \\0 */ int ff_get_line(AVIOContext *s, char *buf, int maxlen); From f75e3da535f297ddbe501ce866e57ccca7645455 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 3 Jul 2011 16:35:10 +0200 Subject: [PATCH 246/780] RTSP: Doxygen comment cleanup Do not use Doxygen for comments that apply to specific implementation details; merge some duplicated Doxygen comment blocks. --- libavformat/rtsp.c | 18 +++++------------- libavformat/rtsp.h | 6 ++++-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index eeea9be4a0..80cd587144 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -428,11 +428,6 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, } } -/** - * Parse the sdp description and allocate the rtp streams and the - * pollfd array used for udp ones. - */ - int ff_sdp_parse(AVFormatContext *s, const char *content) { RTSPState *rt = s->priv_data; @@ -1050,9 +1045,6 @@ retry: return 0; } -/** - * @return 0 on success, <0 on error, 1 if protocol is unavailable. - */ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, int lower_transport, const char *real_challenge) { @@ -1078,7 +1070,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, for (j = RTSP_RTP_PORT_MIN, i = 0; i < rt->nb_rtsp_streams; ++i) { char transport[2048]; - /** + /* * WMS serves all UDP data over a single connection, the RTX, which * isn't necessarily the first in the SDP but has to be the first * to be set up, else the second/third SETUP will fail with a 461. @@ -1151,7 +1143,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, /* RTP/TCP */ else if (lower_transport == RTSP_LOWER_TRANSPORT_TCP) { - /** For WMS streams, the application streams are only used for + /* For WMS streams, the application streams are only used for * UDP. When trying to set it up for TCP streams, the server * will return an error. Therefore, we skip those streams. */ if (rt->server_type == RTSP_SERVER_WMS && @@ -1482,14 +1474,14 @@ redirect: cmd[0] = 0; if (rt->server_type == RTSP_SERVER_REAL) av_strlcat(cmd, - /** + /* * The following entries are required for proper * streaming from a Realmedia server. They are * interdependent in some way although we currently * don't quite understand how. Values were copied * from mplayer SVN r23589. - * @param CompanyID is a 16-byte ID in base64 - * @param ClientChallenge is a 16-byte ID in hex + * ClientChallenge is a 16-byte ID in hex + * CompanyID is a 16-byte ID in base64 */ "ClientChallenge: 9e26d33f2984236010ef6253fb1887f7\r\n" "PlayerStarttime: [28/03/2003:22:50:23 00:00]\r\n" diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 5eae6bf4f3..7d2460fe2f 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -505,8 +505,9 @@ int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply); int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr); /** - * Parse a SDP description of streams by populating an RTSPState struct - * within the AVFormatContext. + * Parse an SDP description of streams by populating an RTSPState struct + * within the AVFormatContext; also allocate the RTP streams and the + * pollfd array used for UDP streams. */ int ff_sdp_parse(AVFormatContext *s, const char *content); @@ -525,6 +526,7 @@ int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt); /** * Do the SETUP requests for each stream for the chosen * lower transport mode. + * @return 0 on success, <0 on error, 1 if protocol is unavailable */ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, int lower_transport, const char *real_challenge); From add41decd94b2d3581a3715ba10f27168b8cdb1b Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 21:02:18 +0100 Subject: [PATCH 247/780] Remove return statements following infinite loops without break These statements cannot be reached and are thus not needed. This removes a number of compiler warnings. Signed-off-by: Mans Rullgard --- libavcodec/h264.c | 1 - libavcodec/mpeg12.c | 2 -- libavformat/asfdec.c | 2 -- libavformat/bethsoftvid.c | 2 -- libavformat/mm.c | 2 -- libavformat/mmsh.c | 1 - libavformat/mov.c | 1 - libavformat/rtmpproto.c | 1 - libavformat/swfdec.c | 1 - libavutil/opt.c | 1 - libavutil/parseutils.c | 1 - 11 files changed, 15 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 2c000a3420..37dab73dc0 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3552,7 +3552,6 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){ ff_draw_horiz_band(s, 16*s->mb_y, 16); } #endif - return -1; //not reached } /** diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 03c95c191d..986cad5fd2 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -1928,8 +1928,6 @@ static int slice_decode_thread(AVCodecContext *c, void *arg){ if(mb_y < 0 || mb_y >= s->end_mb_y) return -1; } - - return 0; //not reached } /** diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 4fafb26259..38fe4f9fa2 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -1099,8 +1099,6 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt) assert(asf->packet_size_left < FRAME_HEADER_SIZE || asf->packet_segments < 1); asf->packet_time_start = 0; } - - return 0; } // Added to support seeking after packets have been read diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c index 01e6f55cd4..5e6a776824 100644 --- a/libavformat/bethsoftvid.c +++ b/libavformat/bethsoftvid.c @@ -220,8 +220,6 @@ static int vid_read_packet(AVFormatContext *s, av_log(s, AV_LOG_ERROR, "unknown block (character = %c, decimal = %d, hex = %x)!!!\n", block_type, block_type, block_type); return -1; } - - return 0; } AVInputFormat ff_bethsoftvid_demuxer = { diff --git a/libavformat/mm.c b/libavformat/mm.c index bea6161315..dae659f3c6 100644 --- a/libavformat/mm.c +++ b/libavformat/mm.c @@ -184,8 +184,6 @@ static int read_packet(AVFormatContext *s, avio_skip(pb, length); } } - - return 0; } AVInputFormat ff_mm_demuxer = { diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c index af040e27a9..0ce282c906 100644 --- a/libavformat/mmsh.c +++ b/libavformat/mmsh.c @@ -208,7 +208,6 @@ static int get_http_header_data(MMSHContext *mmsh) } } } - return 0; } static int mmsh_open(URLContext *h, const char *uri, int flags) diff --git a/libavformat/mov.c b/libavformat/mov.c index c720440472..194c2f86dd 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2308,7 +2308,6 @@ static int mov_probe(AVProbeData *p) return score; } } - return score; } // must be done after parsing all trak because there's no order requirement diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index f499bd3b71..e841f9b8d1 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -761,7 +761,6 @@ static int get_packet(URLContext *s, int for_header) } ff_rtmp_packet_destroy(&rpkt); } - return 0; } static int rtmp_close(URLContext *h) diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index eec9524ecf..c838fa8e61 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -204,7 +204,6 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) skip: avio_skip(pb, len); } - return 0; } AVInputFormat ff_swf_demuxer = { diff --git a/libavutil/opt.c b/libavutil/opt.c index f65f31fcda..acb745cf3d 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -196,7 +196,6 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons return 0; notfirst=1; } - return AVERROR(EINVAL); } if (alloc) { diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index 0272c3ef67..c8124c532e 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -462,7 +462,6 @@ const char *small_strptime(const char *p, const char *fmt, p++; } } - return p; } static time_t mktimegm(struct tm *tm) From ee8aecd23a962914d7c264c2169eed8b69d031aa Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 12:42:16 +0100 Subject: [PATCH 248/780] Do not include intfloat_readwrite.h in avutil.h Signed-off-by: Mans Rullgard --- libavformat/4xm.c | 1 + libavformat/aiffenc.c | 1 + libavformat/cafdec.c | 1 + libavformat/ffmdec.c | 1 + libavformat/ffmenc.c | 1 + libavformat/flvdec.c | 1 + libavformat/flvenc.c | 2 ++ libavformat/gxfenc.c | 1 + libavformat/matroskaenc.c | 1 + libavformat/mov.c | 1 + libavformat/movenc.c | 1 + libavformat/nuv.c | 1 + libavformat/rtmppkt.c | 1 + libavformat/rtmpproto.c | 1 + libavformat/soxdec.c | 1 + libavformat/soxenc.c | 1 + libavformat/thp.c | 1 + libavutil/avutil.h | 1 - 18 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libavformat/4xm.c b/libavformat/4xm.c index 93c90e8cbc..32699da439 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -28,6 +28,7 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/intfloat_readwrite.h" #include "avformat.h" #define RIFF_TAG MKTAG('R', 'I', 'F', 'F') diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index 3bdb4f4f8c..5a64688483 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/intfloat_readwrite.h" #include "avformat.h" #include "aiff.h" #include "avio_internal.h" diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index dff3b41281..68686cab97 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -29,6 +29,7 @@ #include "riff.h" #include "isom.h" #include "libavutil/intreadwrite.h" +#include "libavutil/intfloat_readwrite.h" #include "libavutil/dict.h" #include "caf.h" diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index dfd86cb28b..91ab2e4370 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -20,6 +20,7 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/intfloat_readwrite.h" #include "avformat.h" #include "ffm.h" #if CONFIG_FFSERVER diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c index 71d93e5c43..9a3eb40ad7 100644 --- a/libavformat/ffmenc.c +++ b/libavformat/ffmenc.c @@ -20,6 +20,7 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/intfloat_readwrite.h" #include "avformat.h" #include "ffm.h" diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index c6b386e28f..3b7db0e6ca 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -26,6 +26,7 @@ #include "libavutil/avstring.h" #include "libavutil/dict.h" +#include "libavutil/intfloat_readwrite.h" #include "libavcodec/bytestream.h" #include "libavcodec/mpeg4audio.h" #include "avformat.h" diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 487993cd9a..a3e7e25692 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -18,6 +18,8 @@ * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "libavutil/intfloat_readwrite.h" #include "avformat.h" #include "flv.h" #include "internal.h" diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 98126fa2c4..ac88475984 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/intfloat_readwrite.h" #include "avformat.h" #include "gxf.h" #include "riff.h" diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index e485539a26..34c65d07a4 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -28,6 +28,7 @@ #include "avlanguage.h" #include "libavutil/samplefmt.h" #include "libavutil/intreadwrite.h" +#include "libavutil/intfloat_readwrite.h" #include "libavutil/random_seed.h" #include "libavutil/lfg.h" #include "libavutil/dict.h" diff --git a/libavformat/mov.c b/libavformat/mov.c index 194c2f86dd..f0b87dd84c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -26,6 +26,7 @@ //#define MOV_EXPORT_ALL_METADATA #include "libavutil/intreadwrite.h" +#include "libavutil/intfloat_readwrite.h" #include "libavutil/avstring.h" #include "libavutil/dict.h" #include "avformat.h" diff --git a/libavformat/movenc.c b/libavformat/movenc.c index dcc5581443..2e2f869338 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -32,6 +32,7 @@ #include "libavcodec/put_bits.h" #include "internal.h" #include "libavutil/avstring.h" +#include "libavutil/intfloat_readwrite.h" #include "libavutil/opt.h" #include "libavutil/dict.h" #include "rtpenc.h" diff --git a/libavformat/nuv.c b/libavformat/nuv.c index 4e1ee5702b..854aadd990 100644 --- a/libavformat/nuv.c +++ b/libavformat/nuv.c @@ -20,6 +20,7 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/intfloat_readwrite.h" #include "avformat.h" #include "riff.h" diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index 35ef7fdaae..6bf641a742 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -21,6 +21,7 @@ #include "libavcodec/bytestream.h" #include "libavutil/avstring.h" +#include "libavutil/intfloat_readwrite.h" #include "avformat.h" #include "rtmppkt.h" diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index e841f9b8d1..de4eb0fd23 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -26,6 +26,7 @@ #include "libavcodec/bytestream.h" #include "libavutil/avstring.h" +#include "libavutil/intfloat_readwrite.h" #include "libavutil/lfg.h" #include "libavutil/sha.h" #include "avformat.h" diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c index fb7b063f8c..b3b35b12fd 100644 --- a/libavformat/soxdec.c +++ b/libavformat/soxdec.c @@ -30,6 +30,7 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/intfloat_readwrite.h" #include "libavutil/dict.h" #include "avformat.h" #include "pcm.h" diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c index 01d0cda2cf..a0faa466df 100644 --- a/libavformat/soxenc.c +++ b/libavformat/soxenc.c @@ -30,6 +30,7 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/intfloat_readwrite.h" #include "libavutil/dict.h" #include "avformat.h" #include "avio_internal.h" diff --git a/libavformat/thp.c b/libavformat/thp.c index 6cdcefd377..51dbd810cd 100644 --- a/libavformat/thp.c +++ b/libavformat/thp.c @@ -20,6 +20,7 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/intfloat_readwrite.h" #include "avformat.h" typedef struct ThpDemuxContext { diff --git a/libavutil/avutil.h b/libavutil/avutil.h index d6e4668b88..b8882a705e 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -123,7 +123,6 @@ char av_get_picture_type_char(enum AVPictureType pict_type); #include "error.h" #include "mathematics.h" #include "rational.h" -#include "intfloat_readwrite.h" #include "log.h" #include "pixfmt.h" From 0ebcdf5cdad6bf20a5170735a7f77b23ecc081ac Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 12:58:23 +0100 Subject: [PATCH 249/780] Do not include mathematics.h in avutil.h Signed-off-by: Mans Rullgard --- ffmpeg.c | 1 + ffplay.c | 1 + ffserver.c | 1 + libavcodec/acelp_pitch_delay.c | 1 + libavcodec/ituh263dec.c | 1 + libavcodec/mpegvideo_enc.c | 1 + libavcodec/snow.c | 1 + libavcodec/utils.c | 1 + libavcodec/xsubdec.c | 2 ++ libavfilter/vf_aspect.c | 1 + libavfilter/vf_crop.c | 1 + libavfilter/vf_overlay.c | 1 + libavfilter/vf_pad.c | 1 + libavfilter/vf_scale.c | 1 + libavfilter/vf_setpts.c | 1 + libavfilter/vf_settb.c | 1 + libavfilter/vsrc_color.c | 1 + libavfilter/vsrc_nullsrc.c | 1 + libavformat/applehttp.c | 1 + libavformat/asfdec.c | 1 + libavformat/assdec.c | 1 + libavformat/audiointerleave.c | 1 + libavformat/avidec.c | 1 + libavformat/dv.c | 1 + libavformat/dvenc.c | 1 + libavformat/ffmetadec.c | 1 + libavformat/gxfenc.c | 1 + libavformat/matroskaenc.c | 1 + libavformat/mov.c | 1 + libavformat/movenc.c | 1 + libavformat/mp3dec.c | 1 + libavformat/mpegenc.c | 1 + libavformat/mpegtsenc.c | 1 + libavformat/mxfdec.c | 1 + libavformat/nsvdec.c | 2 ++ libavformat/nut.c | 1 + libavformat/nutdec.c | 1 + libavformat/nutenc.c | 1 + libavformat/oggenc.c | 1 + libavformat/output-example.c | 1 + libavformat/pcm.c | 1 + libavformat/r3d.c | 1 + libavformat/riff.c | 1 + libavformat/rl2.c | 1 + libavformat/rtpdec.c | 1 + libavformat/rtpenc.c | 1 + libavformat/rtsp.c | 1 + libavformat/rtspdec.c | 1 + libavformat/seek.c | 1 + libavformat/utils.c | 1 + libavformat/vqf.c | 1 + libavformat/wav.c | 2 ++ libavutil/avutil.h | 1 - tests/seek_test.c | 1 + 54 files changed, 56 insertions(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index b9309aed43..1a4d2a1204 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -40,6 +40,7 @@ #include "libavutil/fifo.h" #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" +#include "libavutil/mathematics.h" #include "libavutil/pixdesc.h" #include "libavutil/avstring.h" #include "libavutil/libm.h" diff --git a/ffplay.c b/ffplay.c index 73b30c400b..706ee25d65 100644 --- a/ffplay.c +++ b/ffplay.c @@ -25,6 +25,7 @@ #include #include "libavutil/avstring.h" #include "libavutil/colorspace.h" +#include "libavutil/mathematics.h" #include "libavutil/pixdesc.h" #include "libavutil/imgutils.h" #include "libavutil/dict.h" diff --git a/ffserver.c b/ffserver.c index 65a97b20cc..f80ad972e5 100644 --- a/ffserver.c +++ b/ffserver.c @@ -37,6 +37,7 @@ #include "libavutil/avstring.h" #include "libavutil/lfg.h" #include "libavutil/dict.h" +#include "libavutil/mathematics.h" #include "libavutil/random_seed.h" #include "libavutil/parseutils.h" #include "libavutil/opt.h" diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c index 4e44bc9122..2b791b5aa3 100644 --- a/libavcodec/acelp_pitch_delay.c +++ b/libavcodec/acelp_pitch_delay.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mathematics.h" #include "avcodec.h" #include "dsputil.h" #include "acelp_pitch_delay.h" diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 0bb92da833..7071b845fc 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -30,6 +30,7 @@ //#define DEBUG #include +#include "libavutil/mathematics.h" #include "dsputil.h" #include "avcodec.h" #include "mpegvideo.h" diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index cd13a5cd2b..73bcc5b229 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -28,6 +28,7 @@ */ #include "libavutil/intmath.h" +#include "libavutil/mathematics.h" #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 4ab029de5c..6a63da7aa8 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -3697,6 +3697,7 @@ AVCodec ff_snow_encoder = { #undef printf #include "libavutil/lfg.h" +#include "libavutil/mathematics.h" int main(void){ int width=256; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 44a6f8c232..722f758231 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -27,6 +27,7 @@ #include "libavutil/avstring.h" #include "libavutil/crc.h" +#include "libavutil/mathematics.h" #include "libavutil/pixdesc.h" #include "libavutil/audioconvert.h" #include "libavutil/imgutils.h" diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 097cbc6c1d..4afefac2c4 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -18,6 +18,8 @@ * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "libavutil/mathematics.h" #include "libavutil/imgutils.h" #include "avcodec.h" #include "get_bits.h" diff --git a/libavfilter/vf_aspect.c b/libavfilter/vf_aspect.c index 2ede0fd959..b43aa86bea 100644 --- a/libavfilter/vf_aspect.c +++ b/libavfilter/vf_aspect.c @@ -23,6 +23,7 @@ * aspect ratio modification video filters */ +#include "libavutil/mathematics.h" #include "avfilter.h" typedef struct { diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index 69e5a520c8..0880d4e5f9 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -30,6 +30,7 @@ #include "libavutil/avstring.h" #include "libavutil/libm.h" #include "libavutil/imgutils.h" +#include "libavutil/mathematics.h" static const char *var_names[] = { "E", diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index c8bdf51642..39b2375235 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -30,6 +30,7 @@ #include "libavutil/avstring.h" #include "libavutil/pixdesc.h" #include "libavutil/imgutils.h" +#include "libavutil/mathematics.h" #include "internal.h" static const char *var_names[] = { diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 18873b8837..851172c058 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -32,6 +32,7 @@ #include "libavutil/avassert.h" #include "libavutil/imgutils.h" #include "libavutil/parseutils.h" +#include "libavutil/mathematics.h" #include "drawutils.h" static const char *var_names[] = { diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 65fe01c9ae..9ec686f8f9 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -26,6 +26,7 @@ #include "avfilter.h" #include "libavutil/avstring.h" #include "libavutil/eval.h" +#include "libavutil/mathematics.h" #include "libavutil/pixdesc.h" #include "libswscale/swscale.h" diff --git a/libavfilter/vf_setpts.c b/libavfilter/vf_setpts.c index bece3736b0..f2650923d0 100644 --- a/libavfilter/vf_setpts.c +++ b/libavfilter/vf_setpts.c @@ -27,6 +27,7 @@ /* #define DEBUG */ #include "libavutil/eval.h" +#include "libavutil/mathematics.h" #include "avfilter.h" static const char *var_names[] = { diff --git a/libavfilter/vf_settb.c b/libavfilter/vf_settb.c index 9575483c59..eeb4353915 100644 --- a/libavfilter/vf_settb.c +++ b/libavfilter/vf_settb.c @@ -25,6 +25,7 @@ #include "libavutil/avstring.h" #include "libavutil/eval.h" +#include "libavutil/mathematics.h" #include "libavutil/rational.h" #include "avfilter.h" #include "internal.h" diff --git a/libavfilter/vsrc_color.c b/libavfilter/vsrc_color.c index 6d41c8ab71..0fb08d7dc6 100644 --- a/libavfilter/vsrc_color.c +++ b/libavfilter/vsrc_color.c @@ -22,6 +22,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/colorspace.h" #include "libavutil/imgutils.h" +#include "libavutil/mathematics.h" #include "libavutil/parseutils.h" #include "drawutils.h" diff --git a/libavfilter/vsrc_nullsrc.c b/libavfilter/vsrc_nullsrc.c index 629de78a18..dfd56fa495 100644 --- a/libavfilter/vsrc_nullsrc.c +++ b/libavfilter/vsrc_nullsrc.c @@ -23,6 +23,7 @@ #include "libavutil/avstring.h" #include "libavutil/eval.h" +#include "libavutil/mathematics.h" #include "libavutil/parseutils.h" #include "avfilter.h" diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index 38f33a24f3..7e0c930271 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -27,6 +27,7 @@ #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "libavutil/dict.h" #include "avformat.h" diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 38fe4f9fa2..ac559a0edd 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -25,6 +25,7 @@ #include "libavutil/common.h" #include "libavutil/avstring.h" #include "libavutil/dict.h" +#include "libavutil/mathematics.h" #include "libavcodec/mpegaudio.h" #include "avformat.h" #include "avio_internal.h" diff --git a/libavformat/assdec.c b/libavformat/assdec.c index b270200af2..08b520e656 100644 --- a/libavformat/assdec.c +++ b/libavformat/assdec.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mathematics.h" #include "avformat.h" #include "internal.h" diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c index e4cb1b8edc..e48f826e14 100644 --- a/libavformat/audiointerleave.c +++ b/libavformat/audiointerleave.c @@ -21,6 +21,7 @@ */ #include "libavutil/fifo.h" +#include "libavutil/mathematics.h" #include "avformat.h" #include "audiointerleave.h" #include "internal.h" diff --git a/libavformat/avidec.c b/libavformat/avidec.c index a00b9ced2d..2ea156e9ec 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -21,6 +21,7 @@ #include #include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/bswap.h" #include "libavutil/dict.h" #include "avformat.h" diff --git a/libavformat/dv.c b/libavformat/dv.c index 4b41e0aa8e..f38b954605 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -32,6 +32,7 @@ #include "avformat.h" #include "libavcodec/dvdata.h" #include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" #include "dv.h" struct DVDemuxContext { diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 537581ac3a..504e3ee26f 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -35,6 +35,7 @@ #include "libavcodec/dvdata.h" #include "dv.h" #include "libavutil/fifo.h" +#include "libavutil/mathematics.h" struct DVMuxContext { const DVprofile* sys; /* current DV profile, e.g.: 525/60, 625/50 */ diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c index e3d800d3c4..73d3b83ed7 100644 --- a/libavformat/ffmetadec.c +++ b/libavformat/ffmetadec.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mathematics.h" #include "avformat.h" #include "ffmeta.h" #include "internal.h" diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index ac88475984..5a3ff39ab2 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -20,6 +20,7 @@ */ #include "libavutil/intfloat_readwrite.h" +#include "libavutil/mathematics.h" #include "avformat.h" #include "gxf.h" #include "riff.h" diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 34c65d07a4..d132b65f5b 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -29,6 +29,7 @@ #include "libavutil/samplefmt.h" #include "libavutil/intreadwrite.h" #include "libavutil/intfloat_readwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/random_seed.h" #include "libavutil/lfg.h" #include "libavutil/dict.h" diff --git a/libavformat/mov.c b/libavformat/mov.c index f0b87dd84c..acde35d97e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -27,6 +27,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat_readwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/avstring.h" #include "libavutil/dict.h" #include "avformat.h" diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 2e2f869338..0de7c4d44d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -33,6 +33,7 @@ #include "internal.h" #include "libavutil/avstring.h" #include "libavutil/intfloat_readwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "libavutil/dict.h" #include "rtpenc.h" diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index a1db2323ac..70ced02218 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -22,6 +22,7 @@ #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" +#include "libavutil/mathematics.h" #include "avformat.h" #include "id3v2.h" #include "id3v1.h" diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 820c5bd5e1..5859254492 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -20,6 +20,7 @@ */ #include "libavutil/fifo.h" +#include "libavutil/mathematics.h" #include "libavcodec/put_bits.h" #include "avformat.h" #include "mpeg.h" diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 26d2cb229f..83ede1d79b 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -22,6 +22,7 @@ #include "libavutil/bswap.h" #include "libavutil/crc.h" #include "libavutil/dict.h" +#include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "libavcodec/mpegvideo.h" #include "avformat.h" diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 82daa2a002..cf2bb6cc65 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -46,6 +46,7 @@ //#define DEBUG #include "libavutil/aes.h" +#include "libavutil/mathematics.h" #include "libavcodec/bytestream.h" #include "avformat.h" #include "mxf.h" diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index 6e9cfe3a84..4787331def 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -18,6 +18,8 @@ * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "libavutil/mathematics.h" #include "avformat.h" #include "riff.h" #include "libavutil/dict.h" diff --git a/libavformat/nut.c b/libavformat/nut.c index 9a2ee6b0b0..1ce048d645 100644 --- a/libavformat/nut.c +++ b/libavformat/nut.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mathematics.h" #include "libavutil/tree.h" #include "nut.h" #include "internal.h" diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index db1b999c90..93888a2bd6 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -24,6 +24,7 @@ #include "libavutil/avstring.h" #include "libavutil/bswap.h" #include "libavutil/dict.h" +#include "libavutil/mathematics.h" #include "libavutil/tree.h" #include "avio_internal.h" #include "nut.h" diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 260a7607d8..412c670387 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -20,6 +20,7 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/tree.h" #include "libavutil/dict.h" #include "libavcodec/mpegaudiodata.h" diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index bc4b3c10b2..2b2189c10e 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -20,6 +20,7 @@ */ #include "libavutil/crc.h" +#include "libavutil/mathematics.h" #include "libavutil/random_seed.h" #include "libavcodec/xiph.h" #include "libavcodec/bytestream.h" diff --git a/libavformat/output-example.c b/libavformat/output-example.c index 4453c03039..3b28b7c7c6 100644 --- a/libavformat/output-example.c +++ b/libavformat/output-example.c @@ -34,6 +34,7 @@ #include #include +#include "libavutil/mathematics.h" #include "libavformat/avformat.h" #include "libswscale/swscale.h" diff --git a/libavformat/pcm.c b/libavformat/pcm.c index 26ab1424b2..7d5fed5601 100644 --- a/libavformat/pcm.c +++ b/libavformat/pcm.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mathematics.h" #include "avformat.h" #include "pcm.h" diff --git a/libavformat/r3d.c b/libavformat/r3d.c index 619c6a7b6c..5dd7f997e5 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" +#include "libavutil/mathematics.h" #include "avformat.h" typedef struct { diff --git a/libavformat/riff.c b/libavformat/riff.c index 817349cb82..27f45b91d9 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mathematics.h" #include "libavcodec/avcodec.h" #include "avformat.h" #include "avio_internal.h" diff --git a/libavformat/rl2.c b/libavformat/rl2.c index b4172c284a..12cb391ad8 100644 --- a/libavformat/rl2.c +++ b/libavformat/rl2.c @@ -34,6 +34,7 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" #include "avformat.h" #define EXTRADATA1_SIZE (6 + 256 * 3) ///< video base, clr, palette diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index a910cf08bb..2c262d9bd3 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mathematics.h" #include "libavcodec/get_bits.h" #include "avformat.h" #include "mpegts.h" diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index 3da6dfb3a9..c412158778 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -22,6 +22,7 @@ #include "avformat.h" #include "mpegts.h" #include "internal.h" +#include "libavutil/mathematics.h" #include "libavutil/random_seed.h" #include "libavutil/opt.h" diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 80cd587144..ce9bf1e1eb 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -22,6 +22,7 @@ #include "libavutil/base64.h" #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/parseutils.h" #include "libavutil/random_seed.h" #include "libavutil/dict.h" diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index 9cd9be1d4b..2dff46d1de 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -21,6 +21,7 @@ #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "avformat.h" diff --git a/libavformat/seek.c b/libavformat/seek.c index 71e2f8a6b4..6c4286bb8e 100644 --- a/libavformat/seek.c +++ b/libavformat/seek.c @@ -21,6 +21,7 @@ */ #include "seek.h" +#include "libavutil/mathematics.h" #include "libavutil/mem.h" #include "internal.h" diff --git a/libavformat/utils.c b/libavformat/utils.c index de26a1886e..060e58e9b2 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -31,6 +31,7 @@ #include "metadata.h" #include "id3v2.h" #include "libavutil/avstring.h" +#include "libavutil/mathematics.h" #include "riff.h" #include "audiointerleave.h" #include "url.h" diff --git a/libavformat/vqf.c b/libavformat/vqf.c index 5be7dfea21..dd02abd70a 100644 --- a/libavformat/vqf.c +++ b/libavformat/vqf.c @@ -22,6 +22,7 @@ #include "avformat.h" #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" +#include "libavutil/mathematics.h" typedef struct VqfContext { int frame_bit_len; diff --git a/libavformat/wav.c b/libavformat/wav.c index 92c9bfcbc4..391461044b 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -22,6 +22,8 @@ * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "libavutil/mathematics.h" #include "avformat.h" #include "avio_internal.h" #include "pcm.h" diff --git a/libavutil/avutil.h b/libavutil/avutil.h index b8882a705e..53dba004e7 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -121,7 +121,6 @@ char av_get_picture_type_char(enum AVPictureType pict_type); #include "common.h" #include "error.h" -#include "mathematics.h" #include "rational.h" #include "log.h" #include "pixfmt.h" diff --git a/tests/seek_test.c b/tests/seek_test.c index 5d4f41c528..71b2a2d6c0 100644 --- a/tests/seek_test.c +++ b/tests/seek_test.c @@ -25,6 +25,7 @@ #include #include "libavutil/common.h" +#include "libavutil/mathematics.h" #include "libavformat/avformat.h" #undef exit From e91709ca178800faf7f6ce228eb260a6efaa2451 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 13:05:35 +0100 Subject: [PATCH 250/780] Do not include rational.h in avutil.h Signed-off-by: Mans Rullgard --- libavcodec/avcodec.h | 1 + libavfilter/avfilter.h | 1 + libavutil/avutil.h | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index fbd70395c4..9502a0018b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -30,6 +30,7 @@ #include "libavutil/samplefmt.h" #include "libavutil/avutil.h" #include "libavutil/cpu.h" +#include "libavutil/rational.h" #include "libavcodec/version.h" diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 33e93e27fc..b84539c942 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -24,6 +24,7 @@ #include "libavutil/avutil.h" #include "libavutil/samplefmt.h" +#include "libavutil/rational.h" #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 4 diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 53dba004e7..0cdeef2157 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -121,7 +121,6 @@ char av_get_picture_type_char(enum AVPictureType pict_type); #include "common.h" #include "error.h" -#include "rational.h" #include "log.h" #include "pixfmt.h" From d49ea4afb4e39e4af33435452dee8ef4c852d83d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 13:12:08 +0100 Subject: [PATCH 251/780] Do not include pixfmt.h in avutil.h Signed-off-by: Mans Rullgard --- libavcodec/avcodec.h | 1 + libavfilter/avfilter.h | 1 + libavutil/avutil.h | 1 - libswscale/swscale.h | 1 + libswscale/swscale_internal.h | 1 + 5 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 9502a0018b..a23c3cbf05 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -30,6 +30,7 @@ #include "libavutil/samplefmt.h" #include "libavutil/avutil.h" #include "libavutil/cpu.h" +#include "libavutil/pixfmt.h" #include "libavutil/rational.h" #include "libavcodec/version.h" diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index b84539c942..d3c977a7e2 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -24,6 +24,7 @@ #include "libavutil/avutil.h" #include "libavutil/samplefmt.h" +#include "libavutil/pixfmt.h" #include "libavutil/rational.h" #define LIBAVFILTER_VERSION_MAJOR 2 diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 0cdeef2157..782de7d2aa 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -122,6 +122,5 @@ char av_get_picture_type_char(enum AVPictureType pict_type); #include "common.h" #include "error.h" #include "log.h" -#include "pixfmt.h" #endif /* AVUTIL_AVUTIL_H */ diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 3899596983..451f07c72a 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -28,6 +28,7 @@ */ #include "libavutil/avutil.h" +#include "libavutil/pixfmt.h" #define LIBSWSCALE_VERSION_MAJOR 2 #define LIBSWSCALE_VERSION_MINOR 0 diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index e4b93c595b..8d03cb629d 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -28,6 +28,7 @@ #endif #include "libavutil/avutil.h" +#include "libavutil/pixfmt.h" #define STR(s) AV_TOSTRING(s) //AV_STRINGIFY is too long From abc78a5a7c158e9813db502cedce096101e38890 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 13:34:27 +0100 Subject: [PATCH 252/780] Do not include log.h in avutil.h Signed-off-by: Mans Rullgard --- libavcodec/avcodec.h | 1 + libavfilter/avfilter.h | 1 + libavformat/avformat.h | 1 + libavutil/avutil.h | 1 - libavutil/eval.c | 1 + libavutil/file.c | 1 + libavutil/imgutils.c | 1 + libavutil/opt.c | 1 + libavutil/parseutils.c | 1 + libpostproc/postprocess_internal.h | 1 + libswscale/swscale.h | 1 + libswscale/swscale_internal.h | 1 + 12 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index a23c3cbf05..b26bac7bef 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -30,6 +30,7 @@ #include "libavutil/samplefmt.h" #include "libavutil/avutil.h" #include "libavutil/cpu.h" +#include "libavutil/log.h" #include "libavutil/pixfmt.h" #include "libavutil/rational.h" diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index d3c977a7e2..f8295e77c5 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -23,6 +23,7 @@ #define AVFILTER_AVFILTER_H #include "libavutil/avutil.h" +#include "libavutil/log.h" #include "libavutil/samplefmt.h" #include "libavutil/pixfmt.h" #include "libavutil/rational.h" diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 8561a50c01..12490c1209 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -41,6 +41,7 @@ const char *avformat_license(void); #include /* FILE */ #include "libavcodec/avcodec.h" #include "libavutil/dict.h" +#include "libavutil/log.h" #include "avio.h" #include "libavformat/version.h" diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 782de7d2aa..01e4e2fb7f 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -121,6 +121,5 @@ char av_get_picture_type_char(enum AVPictureType pict_type); #include "common.h" #include "error.h" -#include "log.h" #endif /* AVUTIL_AVUTIL_H */ diff --git a/libavutil/eval.c b/libavutil/eval.c index a3788210e3..4bba343bec 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -28,6 +28,7 @@ #include "avutil.h" #include "eval.h" +#include "log.h" typedef struct Parser { const AVClass *class; diff --git a/libavutil/file.c b/libavutil/file.c index f0e48b5b2f..649bb767a0 100644 --- a/libavutil/file.c +++ b/libavutil/file.c @@ -17,6 +17,7 @@ */ #include "file.h" +#include "log.h" #include #include #include diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 46853cafcb..5cd71e21ce 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -23,6 +23,7 @@ #include "imgutils.h" #include "internal.h" +#include "log.h" #include "pixdesc.h" void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], diff --git a/libavutil/opt.c b/libavutil/opt.c index acb745cf3d..65e02135d5 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -30,6 +30,7 @@ #include "opt.h" #include "eval.h" #include "dict.h" +#include "log.h" #if FF_API_FIND_OPT //FIXME order them and do a bin search diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index c8124c532e..9bac7ab9ce 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -28,6 +28,7 @@ #include "avstring.h" #include "avutil.h" #include "eval.h" +#include "log.h" #include "random_seed.h" #include "parseutils.h" diff --git a/libpostproc/postprocess_internal.h b/libpostproc/postprocess_internal.h index 010e629390..331a96b2dd 100644 --- a/libpostproc/postprocess_internal.h +++ b/libpostproc/postprocess_internal.h @@ -28,6 +28,7 @@ #include #include "libavutil/avutil.h" +#include "libavutil/log.h" #include "postprocess.h" #define V_DEBLOCK 0x01 diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 451f07c72a..80e5eaab00 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -28,6 +28,7 @@ */ #include "libavutil/avutil.h" +#include "libavutil/log.h" #include "libavutil/pixfmt.h" #define LIBSWSCALE_VERSION_MAJOR 2 diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 8d03cb629d..340227dc00 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -28,6 +28,7 @@ #endif #include "libavutil/avutil.h" +#include "libavutil/log.h" #include "libavutil/pixfmt.h" #define STR(s) AV_TOSTRING(s) //AV_STRINGIFY is too long From 4320a309ce10a7eec93aef239a0776a33b1a5a34 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Mon, 27 Jun 2011 13:07:26 -0700 Subject: [PATCH 253/780] H.264: make filter_mb_fast support the case of unavailable top mb Significantly faster deblocking in streams with lots of slices. --- libavcodec/h264_loopfilter.c | 42 ++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index bdfbce79f0..1575b1b3d9 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -215,19 +215,20 @@ static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, int16_t void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { MpegEncContext * const s = &h->s; int mb_xy; - int mb_type, left_type; + int mb_type, left_type, top_type; int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh; int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)); int chroma444 = CHROMA444; mb_xy = h->mb_xy; - if(!h->top_type || !h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) { + if(!h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) { ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize); return; } assert(!FRAME_MBAFF); left_type= h->left_type[0]; + top_type= h->top_type; mb_type = s->current_picture.mb_type[mb_xy]; qp = s->current_picture.qscale_table[mb_xy]; @@ -253,13 +254,17 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, h); if( IS_8x8DCT(mb_type) ) { filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h); - filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h); + if(top_type){ + filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h); + } filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h); } else { filter_mb_edgev( &img_y[4*1], linesize, bS3, qp, h); filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h); filter_mb_edgev( &img_y[4*3], linesize, bS3, qp, h); - filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h); + if(top_type){ + filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h); + } filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, h); filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h); filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, h); @@ -273,8 +278,10 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, if( IS_8x8DCT(mb_type) ) { filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h); filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h); - filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h); - filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h); + if(top_type){ + filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h); + filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h); + } filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h); filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h); } else { @@ -284,8 +291,10 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h); filter_mb_edgev( &img_cb[4*3], linesize, bS3, qpc, h); filter_mb_edgev( &img_cr[4*3], linesize, bS3, qpc, h); - filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h); - filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h); + if(top_type){ + filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h); + filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h); + } filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, h); filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, h); filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h); @@ -300,9 +309,11 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, } filter_mb_edgecv( &img_cb[2*2], uvlinesize, bS3, qpc, h); filter_mb_edgecv( &img_cr[2*2], uvlinesize, bS3, qpc, h); - filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h); + if(top_type){ + filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h); + filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h); + } filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, h); - filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h); filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, h); } } @@ -326,7 +337,7 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, } if( IS_INTRA(left_type) ) AV_WN64A(bS[0][0], 0x0004000400040004ULL); - if( IS_INTRA(h->top_type) ) + if( IS_INTRA(top_type) ) AV_WN64A(bS[1][0], FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL); #define FILTER(hv,dir,edge)\ @@ -345,16 +356,19 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, if(left_type) FILTER(v,0,0); if( edges == 1 ) { - FILTER(h,1,0); + if(top_type) + FILTER(h,1,0); } else if( IS_8x8DCT(mb_type) ) { FILTER(v,0,2); - FILTER(h,1,0); + if(top_type) + FILTER(h,1,0); FILTER(h,1,2); } else { FILTER(v,0,1); FILTER(v,0,2); FILTER(v,0,3); - FILTER(h,1,0); + if(top_type) + FILTER(h,1,0); FILTER(h,1,1); FILTER(h,1,2); FILTER(h,1,3); From cb5469462d427ea38625e255306f07b37d75280f Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Mon, 27 Jun 2011 17:41:28 -0700 Subject: [PATCH 254/780] H.264: faster fill_filter_caches Reduce aliasing problems and unroll mv/ref loop. --- libavcodec/h264.c | 228 ++++++++++++++++++++++------------------------ 1 file changed, 110 insertions(+), 118 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 37dab73dc0..b5a9bc0dfc 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3054,6 +3054,82 @@ int ff_h264_get_slice_type(const H264Context *h) } } +static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncContext * const s, int mb_type, int top_xy, + int left_xy[2], int top_type, int left_type[2], int mb_xy, int list) +{ + int b_stride = h->b_stride; + int16_t (*mv_dst)[2] = &h->mv_cache[list][scan8[0]]; + int8_t *ref_cache = &h->ref_cache[list][scan8[0]]; + if(IS_INTER(mb_type) || IS_DIRECT(mb_type)){ + if(USES_LIST(top_type, list)){ + const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride; + const int b8_xy= 4*top_xy + 2; + int (*ref2frm)[64] = h->ref2frm[ h->slice_table[top_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); + AV_COPY128(mv_dst - 1*8, s->current_picture.motion_val[list][b_xy + 0]); + ref_cache[0 - 1*8]= + ref_cache[1 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 0]]; + ref_cache[2 - 1*8]= + ref_cache[3 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 1]]; + }else{ + AV_ZERO128(mv_dst - 1*8); + AV_WN32A(&ref_cache[0 - 1*8], ((LIST_NOT_USED)&0xFF)*0x01010101u); + } + + if(!IS_INTERLACED(mb_type^left_type[0])){ + if(USES_LIST(left_type[0], list)){ + const int b_xy= h->mb2b_xy[left_xy[0]] + 3; + const int b8_xy= 4*left_xy[0] + 1; + int (*ref2frm)[64] = h->ref2frm[ h->slice_table[left_xy[0]]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); + AV_COPY32(mv_dst - 1 + 0, s->current_picture.motion_val[list][b_xy + b_stride*0]); + AV_COPY32(mv_dst - 1 + 8, s->current_picture.motion_val[list][b_xy + b_stride*1]); + AV_COPY32(mv_dst - 1 +16, s->current_picture.motion_val[list][b_xy + b_stride*2]); + AV_COPY32(mv_dst - 1 +24, s->current_picture.motion_val[list][b_xy + b_stride*3]); + ref_cache[-1 + 0]= + ref_cache[-1 + 8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 2*0]]; + ref_cache[-1 + 16]= + ref_cache[-1 + 24]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 2*1]]; + }else{ + AV_ZERO32(mv_dst - 1 + 0); + AV_ZERO32(mv_dst - 1 + 8); + AV_ZERO32(mv_dst - 1 +16); + AV_ZERO32(mv_dst - 1 +24); + ref_cache[-1 + 0]= + ref_cache[-1 + 8]= + ref_cache[-1 + 16]= + ref_cache[-1 + 24]= LIST_NOT_USED; + } + } + } + + if(!USES_LIST(mb_type, list)){ + fill_rectangle(mv_dst, 4, 4, 8, pack16to32(0,0), 4); + AV_WN32A(&ref_cache[0*8], ((LIST_NOT_USED)&0xFF)*0x01010101u); + AV_WN32A(&ref_cache[1*8], ((LIST_NOT_USED)&0xFF)*0x01010101u); + AV_WN32A(&ref_cache[2*8], ((LIST_NOT_USED)&0xFF)*0x01010101u); + AV_WN32A(&ref_cache[3*8], ((LIST_NOT_USED)&0xFF)*0x01010101u); + return; + } + + { + int8_t *ref = &s->current_picture.ref_index[list][4*mb_xy]; + int (*ref2frm)[64] = h->ref2frm[ h->slice_num&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); + uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101; + uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]],ref2frm[list][ref[3]])&0x00FF00FF)*0x0101; + AV_WN32A(&ref_cache[0*8], ref01); + AV_WN32A(&ref_cache[1*8], ref01); + AV_WN32A(&ref_cache[2*8], ref23); + AV_WN32A(&ref_cache[3*8], ref23); + } + + { + int16_t (*mv_src)[2] = &s->current_picture.motion_val[list][4*s->mb_x + 4*s->mb_y*b_stride]; + AV_COPY128(mv_dst + 8*0, mv_src + 0*b_stride); + AV_COPY128(mv_dst + 8*1, mv_src + 1*b_stride); + AV_COPY128(mv_dst + 8*2, mv_src + 2*b_stride); + AV_COPY128(mv_dst + 8*3, mv_src + 3*b_stride); + } +} + /** * * @return non zero if the loop filter can be skiped @@ -3063,11 +3139,11 @@ static int fill_filter_caches(H264Context *h, int mb_type){ const int mb_xy= h->mb_xy; int top_xy, left_xy[2]; int top_type, left_type[2]; + uint8_t *nnz; + uint8_t *nnz_cache; top_xy = mb_xy - (s->mb_stride << MB_FIELD); - //FIXME deblocking could skip the intra and nnz parts. - /* Wow, what a mess, why didn't they simplify the interlacing & intra * stuff, I can't imagine that these complex rules are worth it. */ @@ -3125,144 +3201,60 @@ static int fill_filter_caches(H264Context *h, int mb_type){ if(IS_INTRA(mb_type)) return 0; - AV_COPY32(&h->non_zero_count_cache[4+8* 1], &h->non_zero_count[mb_xy][ 0]); - AV_COPY32(&h->non_zero_count_cache[4+8* 2], &h->non_zero_count[mb_xy][ 4]); - AV_COPY32(&h->non_zero_count_cache[4+8* 3], &h->non_zero_count[mb_xy][ 8]); - AV_COPY32(&h->non_zero_count_cache[4+8* 4], &h->non_zero_count[mb_xy][12]); + fill_filter_caches_inter(h, s, mb_type, top_xy, left_xy, top_type, left_type, mb_xy, 0); + if(h->list_count == 2) + fill_filter_caches_inter(h, s, mb_type, top_xy, left_xy, top_type, left_type, mb_xy, 1); + nnz = h->non_zero_count[mb_xy]; + nnz_cache = h->non_zero_count_cache; + AV_COPY32(&nnz_cache[4+8*1], &nnz[ 0]); + AV_COPY32(&nnz_cache[4+8*2], &nnz[ 4]); + AV_COPY32(&nnz_cache[4+8*3], &nnz[ 8]); + AV_COPY32(&nnz_cache[4+8*4], &nnz[12]); h->cbp= h->cbp_table[mb_xy]; - { - int list; - for(list=0; listlist_count; list++){ - int8_t *ref; - int y, b_stride; - int16_t (*mv_dst)[2]; - int16_t (*mv_src)[2]; - - if(!USES_LIST(mb_type, list)){ - fill_rectangle( h->mv_cache[list][scan8[0]], 4, 4, 8, pack16to32(0,0), 4); - AV_WN32A(&h->ref_cache[list][scan8[ 0]], ((LIST_NOT_USED)&0xFF)*0x01010101u); - AV_WN32A(&h->ref_cache[list][scan8[ 2]], ((LIST_NOT_USED)&0xFF)*0x01010101u); - AV_WN32A(&h->ref_cache[list][scan8[ 8]], ((LIST_NOT_USED)&0xFF)*0x01010101u); - AV_WN32A(&h->ref_cache[list][scan8[10]], ((LIST_NOT_USED)&0xFF)*0x01010101u); - continue; - } - - ref = &s->current_picture.ref_index[list][4*mb_xy]; - { - int (*ref2frm)[64] = h->ref2frm[ h->slice_num&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); - AV_WN32A(&h->ref_cache[list][scan8[ 0]], (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101); - AV_WN32A(&h->ref_cache[list][scan8[ 2]], (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101); - ref += 2; - AV_WN32A(&h->ref_cache[list][scan8[ 8]], (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101); - AV_WN32A(&h->ref_cache[list][scan8[10]], (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101); - } - - b_stride = h->b_stride; - mv_dst = &h->mv_cache[list][scan8[0]]; - mv_src = &s->current_picture.motion_val[list][4*s->mb_x + 4*s->mb_y*b_stride]; - for(y=0; y<4; y++){ - AV_COPY128(mv_dst + 8*y, mv_src + y*b_stride); - } - - } - } - - -/* -0 . T T. T T T T -1 L . .L . . . . -2 L . .L . . . . -3 . T TL . . . . -4 L . .L . . . . -5 L . .. . . . . -*/ -//FIXME constraint_intra_pred & partitioning & nnz (let us hope this is just a typo in the spec) if(top_type){ - AV_COPY32(&h->non_zero_count_cache[4+8*0], &h->non_zero_count[top_xy][3*4]); + nnz = h->non_zero_count[top_xy]; + AV_COPY32(&nnz_cache[4+8*0], &nnz[3*4]); } if(left_type[0]){ - h->non_zero_count_cache[3+8*1]= h->non_zero_count[left_xy[0]][3+0*4]; - h->non_zero_count_cache[3+8*2]= h->non_zero_count[left_xy[0]][3+1*4]; - h->non_zero_count_cache[3+8*3]= h->non_zero_count[left_xy[0]][3+2*4]; - h->non_zero_count_cache[3+8*4]= h->non_zero_count[left_xy[0]][3+3*4]; + nnz = h->non_zero_count[left_xy[0]]; + nnz_cache[3+8*1]= nnz[3+0*4]; + nnz_cache[3+8*2]= nnz[3+1*4]; + nnz_cache[3+8*3]= nnz[3+2*4]; + nnz_cache[3+8*4]= nnz[3+3*4]; } // CAVLC 8x8dct requires NNZ values for residual decoding that differ from what the loop filter needs if(!CABAC && h->pps.transform_8x8_mode){ if(IS_8x8DCT(top_type)){ - h->non_zero_count_cache[4+8*0]= - h->non_zero_count_cache[5+8*0]= (h->cbp_table[top_xy] & 0x4000) >> 12; - h->non_zero_count_cache[6+8*0]= - h->non_zero_count_cache[7+8*0]= (h->cbp_table[top_xy] & 0x8000) >> 12; + nnz_cache[4+8*0]= + nnz_cache[5+8*0]= (h->cbp_table[top_xy] & 0x4000) >> 12; + nnz_cache[6+8*0]= + nnz_cache[7+8*0]= (h->cbp_table[top_xy] & 0x8000) >> 12; } if(IS_8x8DCT(left_type[0])){ - h->non_zero_count_cache[3+8*1]= - h->non_zero_count_cache[3+8*2]= (h->cbp_table[left_xy[0]]&0x2000) >> 12; //FIXME check MBAFF + nnz_cache[3+8*1]= + nnz_cache[3+8*2]= (h->cbp_table[left_xy[0]]&0x2000) >> 12; //FIXME check MBAFF } if(IS_8x8DCT(left_type[1])){ - h->non_zero_count_cache[3+8*3]= - h->non_zero_count_cache[3+8*4]= (h->cbp_table[left_xy[1]]&0x8000) >> 12; //FIXME check MBAFF + nnz_cache[3+8*3]= + nnz_cache[3+8*4]= (h->cbp_table[left_xy[1]]&0x8000) >> 12; //FIXME check MBAFF } if(IS_8x8DCT(mb_type)){ - h->non_zero_count_cache[scan8[0 ]]= h->non_zero_count_cache[scan8[1 ]]= - h->non_zero_count_cache[scan8[2 ]]= h->non_zero_count_cache[scan8[3 ]]= (h->cbp & 0x1000) >> 12; + nnz_cache[scan8[0 ]]= nnz_cache[scan8[1 ]]= + nnz_cache[scan8[2 ]]= nnz_cache[scan8[3 ]]= (h->cbp & 0x1000) >> 12; - h->non_zero_count_cache[scan8[0+ 4]]= h->non_zero_count_cache[scan8[1+ 4]]= - h->non_zero_count_cache[scan8[2+ 4]]= h->non_zero_count_cache[scan8[3+ 4]]= (h->cbp & 0x2000) >> 12; + nnz_cache[scan8[0+ 4]]= nnz_cache[scan8[1+ 4]]= + nnz_cache[scan8[2+ 4]]= nnz_cache[scan8[3+ 4]]= (h->cbp & 0x2000) >> 12; - h->non_zero_count_cache[scan8[0+ 8]]= h->non_zero_count_cache[scan8[1+ 8]]= - h->non_zero_count_cache[scan8[2+ 8]]= h->non_zero_count_cache[scan8[3+ 8]]= (h->cbp & 0x4000) >> 12; + nnz_cache[scan8[0+ 8]]= nnz_cache[scan8[1+ 8]]= + nnz_cache[scan8[2+ 8]]= nnz_cache[scan8[3+ 8]]= (h->cbp & 0x4000) >> 12; - h->non_zero_count_cache[scan8[0+12]]= h->non_zero_count_cache[scan8[1+12]]= - h->non_zero_count_cache[scan8[2+12]]= h->non_zero_count_cache[scan8[3+12]]= (h->cbp & 0x8000) >> 12; - } - } - - if(IS_INTER(mb_type) || IS_DIRECT(mb_type)){ - int list; - for(list=0; listlist_count; list++){ - if(USES_LIST(top_type, list)){ - const int b_xy= h->mb2b_xy[top_xy] + 3*h->b_stride; - const int b8_xy= 4*top_xy + 2; - int (*ref2frm)[64] = h->ref2frm[ h->slice_table[top_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); - AV_COPY128(h->mv_cache[list][scan8[0] + 0 - 1*8], s->current_picture.motion_val[list][b_xy + 0]); - h->ref_cache[list][scan8[0] + 0 - 1*8]= - h->ref_cache[list][scan8[0] + 1 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 0]]; - h->ref_cache[list][scan8[0] + 2 - 1*8]= - h->ref_cache[list][scan8[0] + 3 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 1]]; - }else{ - AV_ZERO128(h->mv_cache[list][scan8[0] + 0 - 1*8]); - AV_WN32A(&h->ref_cache[list][scan8[0] + 0 - 1*8], ((LIST_NOT_USED)&0xFF)*0x01010101u); - } - - if(!IS_INTERLACED(mb_type^left_type[0])){ - if(USES_LIST(left_type[0], list)){ - const int b_xy= h->mb2b_xy[left_xy[0]] + 3; - const int b8_xy= 4*left_xy[0] + 1; - int (*ref2frm)[64] = h->ref2frm[ h->slice_table[left_xy[0]]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); - AV_COPY32(h->mv_cache[list][scan8[0] - 1 + 0 ], s->current_picture.motion_val[list][b_xy + h->b_stride*0]); - AV_COPY32(h->mv_cache[list][scan8[0] - 1 + 8 ], s->current_picture.motion_val[list][b_xy + h->b_stride*1]); - AV_COPY32(h->mv_cache[list][scan8[0] - 1 +16 ], s->current_picture.motion_val[list][b_xy + h->b_stride*2]); - AV_COPY32(h->mv_cache[list][scan8[0] - 1 +24 ], s->current_picture.motion_val[list][b_xy + h->b_stride*3]); - h->ref_cache[list][scan8[0] - 1 + 0 ]= - h->ref_cache[list][scan8[0] - 1 + 8 ]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 2*0]]; - h->ref_cache[list][scan8[0] - 1 +16 ]= - h->ref_cache[list][scan8[0] - 1 +24 ]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 2*1]]; - }else{ - AV_ZERO32(h->mv_cache [list][scan8[0] - 1 + 0 ]); - AV_ZERO32(h->mv_cache [list][scan8[0] - 1 + 8 ]); - AV_ZERO32(h->mv_cache [list][scan8[0] - 1 +16 ]); - AV_ZERO32(h->mv_cache [list][scan8[0] - 1 +24 ]); - h->ref_cache[list][scan8[0] - 1 + 0 ]= - h->ref_cache[list][scan8[0] - 1 + 8 ]= - h->ref_cache[list][scan8[0] - 1 + 16 ]= - h->ref_cache[list][scan8[0] - 1 + 24 ]= LIST_NOT_USED; - } - } + nnz_cache[scan8[0+12]]= nnz_cache[scan8[1+12]]= + nnz_cache[scan8[2+12]]= nnz_cache[scan8[3+12]]= (h->cbp & 0x8000) >> 12; } } From 3b7ebeb4d52a25c7e1038ae90c6c19b0d6f11877 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 29 Jun 2011 13:27:36 -0700 Subject: [PATCH 255/780] H.264: faster write_back_* Avoid aliasing, unroll loops, and inline more functions. --- libavcodec/h264.c | 9 --- libavcodec/h264.h | 123 ++++++++++++++++++++++------------------ libavcodec/h264_cabac.c | 21 +++---- libavcodec/h264_cavlc.c | 2 +- libavcodec/svq3.c | 2 +- 5 files changed, 81 insertions(+), 76 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index b5a9bc0dfc..db3d93d5d7 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -60,15 +60,6 @@ static const enum PixelFormat hwaccel_pixfmt_list_h264_jpeg_420[] = { PIX_FMT_NONE }; -void ff_h264_write_back_intra_pred_mode(H264Context *h){ - int8_t *mode= h->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy]; - - AV_COPY32(mode, h->intra4x4_pred_mode_cache + 4 + 8*4); - mode[4]= h->intra4x4_pred_mode_cache[7+8*3]; - mode[5]= h->intra4x4_pred_mode_cache[7+8*2]; - mode[6]= h->intra4x4_pred_mode_cache[7+8*1]; -} - /** * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks. */ diff --git a/libavcodec/h264.h b/libavcodec/h264.h index e3cc815565..8e04db4f22 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -658,7 +658,6 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h); */ int ff_h264_check_intra_pred_mode(H264Context *h, int mode); -void ff_h264_write_back_intra_pred_mode(H264Context *h); void ff_h264_hl_decode_mb(H264Context *h); int ff_h264_frame_start(H264Context *h); int ff_h264_decode_extradata(H264Context *h); @@ -1185,7 +1184,7 @@ static void fill_decode_caches(H264Context *h, int mb_type){ /** * gets the predicted intra4x4 prediction mode. */ -static inline int pred_intra_mode(H264Context *h, int n){ +static av_always_inline int pred_intra_mode(H264Context *h, int n){ const int index8= scan8[n]; const int left= h->intra4x4_pred_mode_cache[index8 - 1]; const int top = h->intra4x4_pred_mode_cache[index8 - 8]; @@ -1197,69 +1196,83 @@ static inline int pred_intra_mode(H264Context *h, int n){ else return min; } -static inline void write_back_non_zero_count(H264Context *h){ - const int mb_xy= h->mb_xy; +static av_always_inline void write_back_intra_pred_mode(H264Context *h){ + int8_t *i4x4= h->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy]; + int8_t *i4x4_cache= h->intra4x4_pred_mode_cache; - AV_COPY32(&h->non_zero_count[mb_xy][ 0], &h->non_zero_count_cache[4+8* 1]); - AV_COPY32(&h->non_zero_count[mb_xy][ 4], &h->non_zero_count_cache[4+8* 2]); - AV_COPY32(&h->non_zero_count[mb_xy][ 8], &h->non_zero_count_cache[4+8* 3]); - AV_COPY32(&h->non_zero_count[mb_xy][12], &h->non_zero_count_cache[4+8* 4]); - AV_COPY32(&h->non_zero_count[mb_xy][16], &h->non_zero_count_cache[4+8* 6]); - AV_COPY32(&h->non_zero_count[mb_xy][20], &h->non_zero_count_cache[4+8* 7]); - AV_COPY32(&h->non_zero_count[mb_xy][32], &h->non_zero_count_cache[4+8*11]); - AV_COPY32(&h->non_zero_count[mb_xy][36], &h->non_zero_count_cache[4+8*12]); + AV_COPY32(i4x4, i4x4_cache + 4 + 8*4); + i4x4[4]= i4x4_cache[7+8*3]; + i4x4[5]= i4x4_cache[7+8*2]; + i4x4[6]= i4x4_cache[7+8*1]; +} + +static av_always_inline void write_back_non_zero_count(H264Context *h){ + const int mb_xy= h->mb_xy; + uint8_t *nnz = h->non_zero_count[mb_xy]; + uint8_t *nnz_cache = h->non_zero_count_cache; + + AV_COPY32(&nnz[ 0], &nnz_cache[4+8* 1]); + AV_COPY32(&nnz[ 4], &nnz_cache[4+8* 2]); + AV_COPY32(&nnz[ 8], &nnz_cache[4+8* 3]); + AV_COPY32(&nnz[12], &nnz_cache[4+8* 4]); + AV_COPY32(&nnz[16], &nnz_cache[4+8* 6]); + AV_COPY32(&nnz[20], &nnz_cache[4+8* 7]); + AV_COPY32(&nnz[32], &nnz_cache[4+8*11]); + AV_COPY32(&nnz[36], &nnz_cache[4+8*12]); if(CHROMA444){ - AV_COPY32(&h->non_zero_count[mb_xy][24], &h->non_zero_count_cache[4+8* 8]); - AV_COPY32(&h->non_zero_count[mb_xy][28], &h->non_zero_count_cache[4+8* 9]); - AV_COPY32(&h->non_zero_count[mb_xy][40], &h->non_zero_count_cache[4+8*13]); - AV_COPY32(&h->non_zero_count[mb_xy][44], &h->non_zero_count_cache[4+8*14]); + AV_COPY32(&nnz[24], &nnz_cache[4+8* 8]); + AV_COPY32(&nnz[28], &nnz_cache[4+8* 9]); + AV_COPY32(&nnz[40], &nnz_cache[4+8*13]); + AV_COPY32(&nnz[44], &nnz_cache[4+8*14]); } } -static inline void write_back_motion(H264Context *h, int mb_type){ +static av_always_inline void write_back_motion_list(H264Context *h, MpegEncContext * const s, int b_stride, + int b_xy, int b8_xy, int mb_type, int list ) +{ + int16_t (*mv_dst)[2] = &s->current_picture.motion_val[list][b_xy]; + int16_t (*mv_src)[2] = &h->mv_cache[list][scan8[0]]; + AV_COPY128(mv_dst + 0*b_stride, mv_src + 8*0); + AV_COPY128(mv_dst + 1*b_stride, mv_src + 8*1); + AV_COPY128(mv_dst + 2*b_stride, mv_src + 8*2); + AV_COPY128(mv_dst + 3*b_stride, mv_src + 8*3); + if( CABAC ) { + uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8*h->mb_xy : h->mb2br_xy[h->mb_xy]]; + uint8_t (*mvd_src)[2] = &h->mvd_cache[list][scan8[0]]; + if(IS_SKIP(mb_type)) + AV_ZERO128(mvd_dst); + else{ + AV_COPY64(mvd_dst, mvd_src + 8*3); + AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8*0); + AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8*1); + AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8*2); + } + } + + { + int8_t *ref_index = &s->current_picture.ref_index[list][b8_xy]; + int8_t *ref_cache = h->ref_cache[list]; + ref_index[0+0*2]= ref_cache[scan8[0]]; + ref_index[1+0*2]= ref_cache[scan8[4]]; + ref_index[0+1*2]= ref_cache[scan8[8]]; + ref_index[1+1*2]= ref_cache[scan8[12]]; + } +} + +static av_always_inline void write_back_motion(H264Context *h, int mb_type){ MpegEncContext * const s = &h->s; + const int b_stride = h->b_stride; const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride; //try mb2b(8)_xy const int b8_xy= 4*h->mb_xy; - int list; - if(!USES_LIST(mb_type, 0)) + if(USES_LIST(mb_type, 0)){ + write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0); + }else{ fill_rectangle(&s->current_picture.ref_index[0][b8_xy], 2, 2, 2, (uint8_t)LIST_NOT_USED, 1); - - for(list=0; listlist_count; list++){ - int y, b_stride; - int16_t (*mv_dst)[2]; - int16_t (*mv_src)[2]; - - if(!USES_LIST(mb_type, list)) - continue; - - b_stride = h->b_stride; - mv_dst = &s->current_picture.motion_val[list][b_xy]; - mv_src = &h->mv_cache[list][scan8[0]]; - for(y=0; y<4; y++){ - AV_COPY128(mv_dst + y*b_stride, mv_src + 8*y); - } - if( CABAC ) { - uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8*h->mb_xy : h->mb2br_xy[h->mb_xy]]; - uint8_t (*mvd_src)[2] = &h->mvd_cache[list][scan8[0]]; - if(IS_SKIP(mb_type)) - AV_ZERO128(mvd_dst); - else{ - AV_COPY64(mvd_dst, mvd_src + 8*3); - AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8*0); - AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8*1); - AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8*2); - } - } - - { - int8_t *ref_index = &s->current_picture.ref_index[list][b8_xy]; - ref_index[0+0*2]= h->ref_cache[list][scan8[0]]; - ref_index[1+0*2]= h->ref_cache[list][scan8[4]]; - ref_index[0+1*2]= h->ref_cache[list][scan8[8]]; - ref_index[1+1*2]= h->ref_cache[list][scan8[12]]; - } + } + if(USES_LIST(mb_type, 1)){ + write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1); } if(h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC){ @@ -1272,7 +1285,7 @@ static inline void write_back_motion(H264Context *h, int mb_type){ } } -static inline int get_dct8x8_allowed(H264Context *h){ +static av_always_inline int get_dct8x8_allowed(H264Context *h){ if(h->sps.direct_8x8_inference_flag) return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8 )*0x0001000100010001ULL)); else diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index f30f4e1c9c..a643297f8a 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1999,7 +1999,7 @@ decode_intra_mb: //av_log( s->avctx, AV_LOG_ERROR, "i4x4 pred=%d mode=%d\n", pred, h->intra4x4_pred_mode_cache[ scan8[i] ] ); } } - ff_h264_write_back_intra_pred_mode(h); + write_back_intra_pred_mode(h); if( ff_h264_check_intra4x4_pred_mode(h) < 0 ) return -1; } else { h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode( h, h->intra16x16_pred_mode ); @@ -2248,21 +2248,22 @@ decode_intra_mb: * the transform mode of the current macroblock there. */ if (CHROMA444 && IS_8x8DCT(mb_type)){ int i; + uint8_t *nnz_cache = h->non_zero_count_cache; for (i = 0; i < 2; i++){ if (h->left_type[i] && !IS_8x8DCT(h->left_type[i])){ - h->non_zero_count_cache[3+8* 1 + 2*8*i]= - h->non_zero_count_cache[3+8* 2 + 2*8*i]= - h->non_zero_count_cache[3+8* 6 + 2*8*i]= - h->non_zero_count_cache[3+8* 7 + 2*8*i]= - h->non_zero_count_cache[3+8*11 + 2*8*i]= - h->non_zero_count_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0; + nnz_cache[3+8* 1 + 2*8*i]= + nnz_cache[3+8* 2 + 2*8*i]= + nnz_cache[3+8* 6 + 2*8*i]= + nnz_cache[3+8* 7 + 2*8*i]= + nnz_cache[3+8*11 + 2*8*i]= + nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0; } } if (h->top_type && !IS_8x8DCT(h->top_type)){ uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040; - AV_WN32A(&h->non_zero_count_cache[4+8* 0], top_empty); - AV_WN32A(&h->non_zero_count_cache[4+8* 5], top_empty); - AV_WN32A(&h->non_zero_count_cache[4+8*10], top_empty); + AV_WN32A(&nnz_cache[4+8* 0], top_empty); + AV_WN32A(&nnz_cache[4+8* 5], top_empty); + AV_WN32A(&nnz_cache[4+8*10], top_empty); } } s->current_picture.mb_type[mb_xy]= mb_type; diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index 497166b423..90c411002e 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -731,7 +731,7 @@ decode_intra_mb: else h->intra4x4_pred_mode_cache[ scan8[i] ] = mode; } - ff_h264_write_back_intra_pred_mode(h); + write_back_intra_pred_mode(h); if( ff_h264_check_intra4x4_pred_mode(h) < 0) return -1; }else{ diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 23ab209312..a88b069daf 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -589,7 +589,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) } } - ff_h264_write_back_intra_pred_mode(h); + write_back_intra_pred_mode(h); if (mb_type == 8) { ff_h264_check_intra4x4_pred_mode(h); From ca80f11ec30834566f7b16c46a8f4eeacc9c2ce4 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 29 Jun 2011 15:02:31 -0700 Subject: [PATCH 256/780] H.264: faster fill_decode_caches Aliasing avoidance and general cleanup. --- libavcodec/h264.h | 241 +++++++++++++++++++++++----------------------- 1 file changed, 121 insertions(+), 120 deletions(-) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 8e04db4f22..6afbced56e 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -307,11 +307,6 @@ typedef struct H264Context{ #define LIST_NOT_USED -1 //FIXME rename? #define PART_NOT_AVAILABLE -2 - /** - * is 1 if the specific list MV&references are set to 0,0,-2. - */ - int mv_cache_clean[2]; - /** * number of neighbors (top and/or left) that used 8x8 dct */ @@ -857,6 +852,8 @@ static void fill_decode_caches(H264Context *h, int mb_type){ int topleft_type, top_type, topright_type, left_type[2]; const uint8_t * left_block= h->left_block; int i; + uint8_t *nnz; + uint8_t *nnz_cache; topleft_xy = h->topleft_mb_xy ; top_xy = h->top_mb_xy ; @@ -946,42 +943,45 @@ static void fill_decode_caches(H264Context *h, int mb_type){ 5 L . .. . . . . */ //FIXME constraint_intra_pred & partitioning & nnz (let us hope this is just a typo in the spec) + nnz_cache = h->non_zero_count_cache; if(top_type){ - AV_COPY32(&h->non_zero_count_cache[4+8* 0], &h->non_zero_count[top_xy][4*3]); + nnz = h->non_zero_count[top_xy]; + AV_COPY32(&nnz_cache[4+8* 0], &nnz[4*3]); if(CHROMA444){ - AV_COPY32(&h->non_zero_count_cache[4+8* 5], &h->non_zero_count[top_xy][4* 7]); - AV_COPY32(&h->non_zero_count_cache[4+8*10], &h->non_zero_count[top_xy][4*11]); + AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 7]); + AV_COPY32(&nnz_cache[4+8*10], &nnz[4*11]); }else{ - AV_COPY32(&h->non_zero_count_cache[4+8* 5], &h->non_zero_count[top_xy][4* 5]); - AV_COPY32(&h->non_zero_count_cache[4+8*10], &h->non_zero_count[top_xy][4* 9]); + AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 5]); + AV_COPY32(&nnz_cache[4+8*10], &nnz[4* 9]); } }else{ uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040; - AV_WN32A(&h->non_zero_count_cache[4+8* 0], top_empty); - AV_WN32A(&h->non_zero_count_cache[4+8* 5], top_empty); - AV_WN32A(&h->non_zero_count_cache[4+8*10], top_empty); + AV_WN32A(&nnz_cache[4+8* 0], top_empty); + AV_WN32A(&nnz_cache[4+8* 5], top_empty); + AV_WN32A(&nnz_cache[4+8*10], top_empty); } for (i=0; i<2; i++) { if(left_type[i]){ - h->non_zero_count_cache[3+8* 1 + 2*8*i]= h->non_zero_count[left_xy[i]][left_block[8+0+2*i]]; - h->non_zero_count_cache[3+8* 2 + 2*8*i]= h->non_zero_count[left_xy[i]][left_block[8+1+2*i]]; + nnz = h->non_zero_count[left_xy[i]]; + nnz_cache[3+8* 1 + 2*8*i]= nnz[left_block[8+0+2*i]]; + nnz_cache[3+8* 2 + 2*8*i]= nnz[left_block[8+1+2*i]]; if(CHROMA444){ - h->non_zero_count_cache[3+8* 6 + 2*8*i]= h->non_zero_count[left_xy[i]][left_block[8+0+2*i]+4*4]; - h->non_zero_count_cache[3+8* 7 + 2*8*i]= h->non_zero_count[left_xy[i]][left_block[8+1+2*i]+4*4]; - h->non_zero_count_cache[3+8*11 + 2*8*i]= h->non_zero_count[left_xy[i]][left_block[8+0+2*i]+8*4]; - h->non_zero_count_cache[3+8*12 + 2*8*i]= h->non_zero_count[left_xy[i]][left_block[8+1+2*i]+8*4]; + nnz_cache[3+8* 6 + 2*8*i]= nnz[left_block[8+0+2*i]+4*4]; + nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]+4*4]; + nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]+8*4]; + nnz_cache[3+8*12 + 2*8*i]= nnz[left_block[8+1+2*i]+8*4]; }else{ - h->non_zero_count_cache[3+8* 6 + 8*i]= h->non_zero_count[left_xy[i]][left_block[8+4+2*i]]; - h->non_zero_count_cache[3+8*11 + 8*i]= h->non_zero_count[left_xy[i]][left_block[8+5+2*i]]; + nnz_cache[3+8* 6 + 8*i]= nnz[left_block[8+4+2*i]]; + nnz_cache[3+8*11 + 8*i]= nnz[left_block[8+5+2*i]]; } }else{ - h->non_zero_count_cache[3+8* 1 + 2*8*i]= - h->non_zero_count_cache[3+8* 2 + 2*8*i]= - h->non_zero_count_cache[3+8* 6 + 2*8*i]= - h->non_zero_count_cache[3+8* 7 + 2*8*i]= - h->non_zero_count_cache[3+8*11 + 2*8*i]= - h->non_zero_count_cache[3+8*12 + 2*8*i]= CABAC && !IS_INTRA(mb_type) ? 0 : 64; + nnz_cache[3+8* 1 + 2*8*i]= + nnz_cache[3+8* 2 + 2*8*i]= + nnz_cache[3+8* 6 + 2*8*i]= + nnz_cache[3+8* 7 + 2*8*i]= + nnz_cache[3+8*11 + 2*8*i]= + nnz_cache[3+8*12 + 2*8*i]= CABAC && !IS_INTRA(mb_type) ? 0 : 64; } } @@ -1005,144 +1005,145 @@ static void fill_decode_caches(H264Context *h, int mb_type){ if(IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)){ int list; + int b_stride = h->b_stride; for(list=0; listlist_count; list++){ + int8_t *ref_cache = &h->ref_cache[list][scan8[0]]; + int8_t *ref = s->current_picture.ref_index[list]; + int16_t (*mv_cache)[2] = &h->mv_cache[list][scan8[0]]; + int16_t (*mv)[2] = s->current_picture.motion_val[list]; if(!USES_LIST(mb_type, list)){ - /*if(!h->mv_cache_clean[list]){ - memset(h->mv_cache [list], 0, 8*5*2*sizeof(int16_t)); //FIXME clean only input? clean at all? - memset(h->ref_cache[list], PART_NOT_AVAILABLE, 8*5*sizeof(int8_t)); - h->mv_cache_clean[list]= 1; - }*/ continue; } assert(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred)); - h->mv_cache_clean[list]= 0; - if(USES_LIST(top_type, list)){ - const int b_xy= h->mb2b_xy[top_xy] + 3*h->b_stride; - AV_COPY128(h->mv_cache[list][scan8[0] + 0 - 1*8], s->current_picture.motion_val[list][b_xy + 0]); - h->ref_cache[list][scan8[0] + 0 - 1*8]= - h->ref_cache[list][scan8[0] + 1 - 1*8]= s->current_picture.ref_index[list][4*top_xy + 2]; - h->ref_cache[list][scan8[0] + 2 - 1*8]= - h->ref_cache[list][scan8[0] + 3 - 1*8]= s->current_picture.ref_index[list][4*top_xy + 3]; + const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride; + AV_COPY128(mv_cache[0 - 1*8], mv[b_xy + 0]); + ref_cache[0 - 1*8]= + ref_cache[1 - 1*8]= ref[4*top_xy + 2]; + ref_cache[2 - 1*8]= + ref_cache[3 - 1*8]= ref[4*top_xy + 3]; }else{ - AV_ZERO128(h->mv_cache[list][scan8[0] + 0 - 1*8]); - AV_WN32A(&h->ref_cache[list][scan8[0] + 0 - 1*8], ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101); + AV_ZERO128(mv_cache[0 - 1*8]); + AV_WN32A(&ref_cache[0 - 1*8], ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101); } if(mb_type & (MB_TYPE_16x8|MB_TYPE_8x8)){ for(i=0; i<2; i++){ - int cache_idx = scan8[0] - 1 + i*2*8; + int cache_idx = -1 + i*2*8; if(USES_LIST(left_type[i], list)){ const int b_xy= h->mb2b_xy[left_xy[i]] + 3; const int b8_xy= 4*left_xy[i] + 1; - AV_COPY32(h->mv_cache[list][cache_idx ], s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[0+i*2]]); - AV_COPY32(h->mv_cache[list][cache_idx+8], s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[1+i*2]]); - h->ref_cache[list][cache_idx ]= s->current_picture.ref_index[list][b8_xy + (left_block[0+i*2]&~1)]; - h->ref_cache[list][cache_idx+8]= s->current_picture.ref_index[list][b8_xy + (left_block[1+i*2]&~1)]; + AV_COPY32(mv_cache[cache_idx ], mv[b_xy + b_stride*left_block[0+i*2]]); + AV_COPY32(mv_cache[cache_idx+8], mv[b_xy + b_stride*left_block[1+i*2]]); + ref_cache[cache_idx ]= ref[b8_xy + (left_block[0+i*2]&~1)]; + ref_cache[cache_idx+8]= ref[b8_xy + (left_block[1+i*2]&~1)]; }else{ - AV_ZERO32(h->mv_cache [list][cache_idx ]); - AV_ZERO32(h->mv_cache [list][cache_idx+8]); - h->ref_cache[list][cache_idx ]= - h->ref_cache[list][cache_idx+8]= (left_type[i]) ? LIST_NOT_USED : PART_NOT_AVAILABLE; + AV_ZERO32(mv_cache[cache_idx ]); + AV_ZERO32(mv_cache[cache_idx+8]); + ref_cache[cache_idx ]= + ref_cache[cache_idx+8]= (left_type[i]) ? LIST_NOT_USED : PART_NOT_AVAILABLE; } } }else{ if(USES_LIST(left_type[0], list)){ const int b_xy= h->mb2b_xy[left_xy[0]] + 3; const int b8_xy= 4*left_xy[0] + 1; - AV_COPY32(h->mv_cache[list][scan8[0] - 1], s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[0]]); - h->ref_cache[list][scan8[0] - 1]= s->current_picture.ref_index[list][b8_xy + (left_block[0]&~1)]; + AV_COPY32(mv_cache[-1], mv[b_xy + b_stride*left_block[0]]); + ref_cache[-1]= ref[b8_xy + (left_block[0]&~1)]; }else{ - AV_ZERO32(h->mv_cache [list][scan8[0] - 1]); - h->ref_cache[list][scan8[0] - 1]= left_type[0] ? LIST_NOT_USED : PART_NOT_AVAILABLE; + AV_ZERO32(mv_cache[-1]); + ref_cache[-1]= left_type[0] ? LIST_NOT_USED : PART_NOT_AVAILABLE; } } if(USES_LIST(topright_type, list)){ - const int b_xy= h->mb2b_xy[topright_xy] + 3*h->b_stride; - AV_COPY32(h->mv_cache[list][scan8[0] + 4 - 1*8], s->current_picture.motion_val[list][b_xy]); - h->ref_cache[list][scan8[0] + 4 - 1*8]= s->current_picture.ref_index[list][4*topright_xy + 2]; + const int b_xy= h->mb2b_xy[topright_xy] + 3*b_stride; + AV_COPY32(mv_cache[4 - 1*8], mv[b_xy]); + ref_cache[4 - 1*8]= ref[4*topright_xy + 2]; }else{ - AV_ZERO32(h->mv_cache [list][scan8[0] + 4 - 1*8]); - h->ref_cache[list][scan8[0] + 4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; + AV_ZERO32(mv_cache[4 - 1*8]); + ref_cache[4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; } - if(h->ref_cache[list][scan8[0] + 4 - 1*8] < 0){ + if(ref_cache[4 - 1*8] < 0){ if(USES_LIST(topleft_type, list)){ - const int b_xy = h->mb2b_xy [topleft_xy] + 3 + h->b_stride + (h->topleft_partition & 2*h->b_stride); + const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride + (h->topleft_partition & 2*b_stride); const int b8_xy= 4*topleft_xy + 1 + (h->topleft_partition & 2); - AV_COPY32(h->mv_cache[list][scan8[0] - 1 - 1*8], s->current_picture.motion_val[list][b_xy]); - h->ref_cache[list][scan8[0] - 1 - 1*8]= s->current_picture.ref_index[list][b8_xy]; + AV_COPY32(mv_cache[-1 - 1*8], mv[b_xy]); + ref_cache[-1 - 1*8]= ref[b8_xy]; }else{ - AV_ZERO32(h->mv_cache[list][scan8[0] - 1 - 1*8]); - h->ref_cache[list][scan8[0] - 1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; + AV_ZERO32(mv_cache[-1 - 1*8]); + ref_cache[-1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; } } if((mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2)) && !FRAME_MBAFF) continue; - if(!(mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2))) { - h->ref_cache[list][scan8[4 ]] = - h->ref_cache[list][scan8[12]] = PART_NOT_AVAILABLE; - AV_ZERO32(h->mv_cache [list][scan8[4 ]]); - AV_ZERO32(h->mv_cache [list][scan8[12]]); + if(!(mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2))){ + uint8_t (*mvd_cache)[2] = &h->mvd_cache[list][scan8[0]]; + uint8_t (*mvd)[2] = h->mvd_table[list]; + ref_cache[2+8*0] = + ref_cache[2+8*2] = PART_NOT_AVAILABLE; + AV_ZERO32(mv_cache[2+8*0]); + AV_ZERO32(mv_cache[2+8*2]); - if( CABAC ) { - /* XXX beurk, Load mvd */ - if(USES_LIST(top_type, list)){ - const int b_xy= h->mb2br_xy[top_xy]; - AV_COPY64(h->mvd_cache[list][scan8[0] + 0 - 1*8], h->mvd_table[list][b_xy + 0]); - }else{ - AV_ZERO64(h->mvd_cache[list][scan8[0] + 0 - 1*8]); - } - if(USES_LIST(left_type[0], list)){ - const int b_xy= h->mb2br_xy[left_xy[0]] + 6; - AV_COPY16(h->mvd_cache[list][scan8[0] - 1 + 0*8], h->mvd_table[list][b_xy - left_block[0]]); - AV_COPY16(h->mvd_cache[list][scan8[0] - 1 + 1*8], h->mvd_table[list][b_xy - left_block[1]]); - }else{ - AV_ZERO16(h->mvd_cache [list][scan8[0] - 1 + 0*8]); - AV_ZERO16(h->mvd_cache [list][scan8[0] - 1 + 1*8]); - } - if(USES_LIST(left_type[1], list)){ - const int b_xy= h->mb2br_xy[left_xy[1]] + 6; - AV_COPY16(h->mvd_cache[list][scan8[0] - 1 + 2*8], h->mvd_table[list][b_xy - left_block[2]]); - AV_COPY16(h->mvd_cache[list][scan8[0] - 1 + 3*8], h->mvd_table[list][b_xy - left_block[3]]); - }else{ - AV_ZERO16(h->mvd_cache [list][scan8[0] - 1 + 2*8]); - AV_ZERO16(h->mvd_cache [list][scan8[0] - 1 + 3*8]); - } - AV_ZERO16(h->mvd_cache [list][scan8[4 ]]); - AV_ZERO16(h->mvd_cache [list][scan8[12]]); - if(h->slice_type_nos == AV_PICTURE_TYPE_B){ - fill_rectangle(&h->direct_cache[scan8[0]], 4, 4, 8, MB_TYPE_16x16>>1, 1); - - if(IS_DIRECT(top_type)){ - AV_WN32A(&h->direct_cache[scan8[0] - 1*8], 0x01010101u*(MB_TYPE_DIRECT2>>1)); - }else if(IS_8X8(top_type)){ - int b8_xy = 4*top_xy; - h->direct_cache[scan8[0] + 0 - 1*8]= h->direct_table[b8_xy + 2]; - h->direct_cache[scan8[0] + 2 - 1*8]= h->direct_table[b8_xy + 3]; + if( CABAC ) { + if(USES_LIST(top_type, list)){ + const int b_xy= h->mb2br_xy[top_xy]; + AV_COPY64(mvd_cache[0 - 1*8], mvd[b_xy + 0]); }else{ - AV_WN32A(&h->direct_cache[scan8[0] - 1*8], 0x01010101*(MB_TYPE_16x16>>1)); + AV_ZERO64(mvd_cache[0 - 1*8]); } + if(USES_LIST(left_type[0], list)){ + const int b_xy= h->mb2br_xy[left_xy[0]] + 6; + AV_COPY16(mvd_cache[-1 + 0*8], mvd[b_xy - left_block[0]]); + AV_COPY16(mvd_cache[-1 + 1*8], mvd[b_xy - left_block[1]]); + }else{ + AV_ZERO16(mvd_cache[-1 + 0*8]); + AV_ZERO16(mvd_cache[-1 + 1*8]); + } + if(USES_LIST(left_type[1], list)){ + const int b_xy= h->mb2br_xy[left_xy[1]] + 6; + AV_COPY16(mvd_cache[-1 + 2*8], mvd[b_xy - left_block[2]]); + AV_COPY16(mvd_cache[-1 + 3*8], mvd[b_xy - left_block[3]]); + }else{ + AV_ZERO16(mvd_cache[-1 + 2*8]); + AV_ZERO16(mvd_cache[-1 + 3*8]); + } + AV_ZERO16(mvd_cache[2+8*0]); + AV_ZERO16(mvd_cache[2+8*2]); + if(h->slice_type_nos == AV_PICTURE_TYPE_B){ + uint8_t *direct_cache = &h->direct_cache[scan8[0]]; + uint8_t *direct_table = h->direct_table; + fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16>>1, 1); - if(IS_DIRECT(left_type[0])) - h->direct_cache[scan8[0] - 1 + 0*8]= MB_TYPE_DIRECT2>>1; - else if(IS_8X8(left_type[0])) - h->direct_cache[scan8[0] - 1 + 0*8]= h->direct_table[4*left_xy[0] + 1 + (left_block[0]&~1)]; - else - h->direct_cache[scan8[0] - 1 + 0*8]= MB_TYPE_16x16>>1; + if(IS_DIRECT(top_type)){ + AV_WN32A(&direct_cache[-1*8], 0x01010101u*(MB_TYPE_DIRECT2>>1)); + }else if(IS_8X8(top_type)){ + int b8_xy = 4*top_xy; + direct_cache[0 - 1*8]= direct_table[b8_xy + 2]; + direct_cache[2 - 1*8]= direct_table[b8_xy + 3]; + }else{ + AV_WN32A(&direct_cache[-1*8], 0x01010101*(MB_TYPE_16x16>>1)); + } - if(IS_DIRECT(left_type[1])) - h->direct_cache[scan8[0] - 1 + 2*8]= MB_TYPE_DIRECT2>>1; - else if(IS_8X8(left_type[1])) - h->direct_cache[scan8[0] - 1 + 2*8]= h->direct_table[4*left_xy[1] + 1 + (left_block[2]&~1)]; - else - h->direct_cache[scan8[0] - 1 + 2*8]= MB_TYPE_16x16>>1; + if(IS_DIRECT(left_type[0])) + direct_cache[-1 + 0*8]= MB_TYPE_DIRECT2>>1; + else if(IS_8X8(left_type[0])) + direct_cache[-1 + 0*8]= direct_table[4*left_xy[0] + 1 + (left_block[0]&~1)]; + else + direct_cache[-1 + 0*8]= MB_TYPE_16x16>>1; + + if(IS_DIRECT(left_type[1])) + direct_cache[-1 + 2*8]= MB_TYPE_DIRECT2>>1; + else if(IS_8X8(left_type[1])) + direct_cache[-1 + 2*8]= direct_table[4*left_xy[1] + 1 + (left_block[2]&~1)]; + else + direct_cache[-1 + 2*8]= MB_TYPE_16x16>>1; + } } } - } if(FRAME_MBAFF){ #define MAP_MVS\ MAP_F2F(scan8[0] - 1 - 1*8, topleft_type)\ From 556f8a066cb33241bf29e85d7e24c9acf7ea9043 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 29 Jun 2011 15:38:39 -0700 Subject: [PATCH 257/780] H.264: template left MB handling Faster H.264 decoding with ALLOW_INTERLACE off. --- libavcodec/h264.c | 66 ++++++++-------- libavcodec/h264.h | 142 ++++++++++++++++++----------------- libavcodec/h264_cabac.c | 12 +-- libavcodec/h264_loopfilter.c | 14 ++-- 4 files changed, 121 insertions(+), 113 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index db3d93d5d7..dbac4fda95 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3046,7 +3046,7 @@ int ff_h264_get_slice_type(const H264Context *h) } static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncContext * const s, int mb_type, int top_xy, - int left_xy[2], int top_type, int left_type[2], int mb_xy, int list) + int left_xy[LEFT_MBS], int top_type, int left_type[LEFT_MBS], int mb_xy, int list) { int b_stride = h->b_stride; int16_t (*mv_dst)[2] = &h->mv_cache[list][scan8[0]]; @@ -3066,11 +3066,11 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon AV_WN32A(&ref_cache[0 - 1*8], ((LIST_NOT_USED)&0xFF)*0x01010101u); } - if(!IS_INTERLACED(mb_type^left_type[0])){ - if(USES_LIST(left_type[0], list)){ - const int b_xy= h->mb2b_xy[left_xy[0]] + 3; - const int b8_xy= 4*left_xy[0] + 1; - int (*ref2frm)[64] = h->ref2frm[ h->slice_table[left_xy[0]]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); + if(!IS_INTERLACED(mb_type^left_type[LTOP])){ + if(USES_LIST(left_type[LTOP], list)){ + const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3; + const int b8_xy= 4*left_xy[LTOP] + 1; + int (*ref2frm)[64] = h->ref2frm[ h->slice_table[left_xy[LTOP]]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); AV_COPY32(mv_dst - 1 + 0, s->current_picture.motion_val[list][b_xy + b_stride*0]); AV_COPY32(mv_dst - 1 + 8, s->current_picture.motion_val[list][b_xy + b_stride*1]); AV_COPY32(mv_dst - 1 +16, s->current_picture.motion_val[list][b_xy + b_stride*2]); @@ -3128,8 +3128,8 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon static int fill_filter_caches(H264Context *h, int mb_type){ MpegEncContext * const s = &h->s; const int mb_xy= h->mb_xy; - int top_xy, left_xy[2]; - int top_type, left_type[2]; + int top_xy, left_xy[LEFT_MBS]; + int top_type, left_type[LEFT_MBS]; uint8_t *nnz; uint8_t *nnz_cache; @@ -3138,56 +3138,56 @@ static int fill_filter_caches(H264Context *h, int mb_type){ /* Wow, what a mess, why didn't they simplify the interlacing & intra * stuff, I can't imagine that these complex rules are worth it. */ - left_xy[1] = left_xy[0] = mb_xy-1; + left_xy[LBOT] = left_xy[LTOP] = mb_xy-1; if(FRAME_MBAFF){ const int left_mb_field_flag = IS_INTERLACED(s->current_picture.mb_type[mb_xy-1]); const int curr_mb_field_flag = IS_INTERLACED(mb_type); if(s->mb_y&1){ if (left_mb_field_flag != curr_mb_field_flag) { - left_xy[0] -= s->mb_stride; + left_xy[LTOP] -= s->mb_stride; } }else{ if(curr_mb_field_flag){ top_xy += s->mb_stride & (((s->current_picture.mb_type[top_xy ]>>7)&1)-1); } if (left_mb_field_flag != curr_mb_field_flag) { - left_xy[1] += s->mb_stride; + left_xy[LBOT] += s->mb_stride; } } } h->top_mb_xy = top_xy; - h->left_mb_xy[0] = left_xy[0]; - h->left_mb_xy[1] = left_xy[1]; + h->left_mb_xy[LTOP] = left_xy[LTOP]; + h->left_mb_xy[LBOT] = left_xy[LBOT]; { //for sufficiently low qp, filtering wouldn't do anything //this is a conservative estimate: could also check beta_offset and more accurate chroma_qp int qp_thresh = h->qp_thresh; //FIXME strictly we should store qp_thresh for each mb of a slice int qp = s->current_picture.qscale_table[mb_xy]; if(qp <= qp_thresh - && (left_xy[0]<0 || ((qp + s->current_picture.qscale_table[left_xy[0]] + 1)>>1) <= qp_thresh) - && (top_xy < 0 || ((qp + s->current_picture.qscale_table[top_xy ] + 1)>>1) <= qp_thresh)){ + && (left_xy[LTOP]<0 || ((qp + s->current_picture.qscale_table[left_xy[LTOP]] + 1)>>1) <= qp_thresh) + && (top_xy <0 || ((qp + s->current_picture.qscale_table[top_xy ] + 1)>>1) <= qp_thresh)){ if(!FRAME_MBAFF) return 1; - if( (left_xy[0]< 0 || ((qp + s->current_picture.qscale_table[left_xy[1] ] + 1)>>1) <= qp_thresh) - && (top_xy < s->mb_stride || ((qp + s->current_picture.qscale_table[top_xy -s->mb_stride] + 1)>>1) <= qp_thresh)) + if( (left_xy[LTOP]< 0 || ((qp + s->current_picture.qscale_table[left_xy[LBOT] ] + 1)>>1) <= qp_thresh) + && (top_xy < s->mb_stride || ((qp + s->current_picture.qscale_table[top_xy -s->mb_stride] + 1)>>1) <= qp_thresh)) return 1; } } - top_type = s->current_picture.mb_type[top_xy] ; - left_type[0] = s->current_picture.mb_type[left_xy[0]]; - left_type[1] = s->current_picture.mb_type[left_xy[1]]; + top_type = s->current_picture.mb_type[top_xy]; + left_type[LTOP] = s->current_picture.mb_type[left_xy[LTOP]]; + left_type[LBOT] = s->current_picture.mb_type[left_xy[LBOT]]; if(h->deblocking_filter == 2){ - if(h->slice_table[top_xy ] != h->slice_num) top_type= 0; - if(h->slice_table[left_xy[0] ] != h->slice_num) left_type[0]= left_type[1]= 0; + if(h->slice_table[top_xy ] != h->slice_num) top_type= 0; + if(h->slice_table[left_xy[LBOT]] != h->slice_num) left_type[LTOP]= left_type[LBOT]= 0; }else{ - if(h->slice_table[top_xy ] == 0xFFFF) top_type= 0; - if(h->slice_table[left_xy[0] ] == 0xFFFF) left_type[0]= left_type[1] =0; + if(h->slice_table[top_xy ] == 0xFFFF) top_type= 0; + if(h->slice_table[left_xy[LBOT]] == 0xFFFF) left_type[LTOP]= left_type[LBOT] =0; } - h->top_type = top_type ; - h->left_type[0]= left_type[0]; - h->left_type[1]= left_type[1]; + h->top_type = top_type; + h->left_type[LTOP]= left_type[LTOP]; + h->left_type[LBOT]= left_type[LBOT]; if(IS_INTRA(mb_type)) return 0; @@ -3209,8 +3209,8 @@ static int fill_filter_caches(H264Context *h, int mb_type){ AV_COPY32(&nnz_cache[4+8*0], &nnz[3*4]); } - if(left_type[0]){ - nnz = h->non_zero_count[left_xy[0]]; + if(left_type[LTOP]){ + nnz = h->non_zero_count[left_xy[LTOP]]; nnz_cache[3+8*1]= nnz[3+0*4]; nnz_cache[3+8*2]= nnz[3+1*4]; nnz_cache[3+8*3]= nnz[3+2*4]; @@ -3225,13 +3225,13 @@ static int fill_filter_caches(H264Context *h, int mb_type){ nnz_cache[6+8*0]= nnz_cache[7+8*0]= (h->cbp_table[top_xy] & 0x8000) >> 12; } - if(IS_8x8DCT(left_type[0])){ + if(IS_8x8DCT(left_type[LTOP])){ nnz_cache[3+8*1]= - nnz_cache[3+8*2]= (h->cbp_table[left_xy[0]]&0x2000) >> 12; //FIXME check MBAFF + nnz_cache[3+8*2]= (h->cbp_table[left_xy[LTOP]]&0x2000) >> 12; //FIXME check MBAFF } - if(IS_8x8DCT(left_type[1])){ + if(IS_8x8DCT(left_type[LBOT])){ nnz_cache[3+8*3]= - nnz_cache[3+8*4]= (h->cbp_table[left_xy[1]]&0x8000) >> 12; //FIXME check MBAFF + nnz_cache[3+8*4]= (h->cbp_table[left_xy[LBOT]]&0x8000) >> 12; //FIXME check MBAFF } if(IS_8x8DCT(mb_type)){ diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 6afbced56e..dad06e2007 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -70,6 +70,10 @@ #define MB_FIELD h->mb_field_decoding_flag #define FRAME_MBAFF h->mb_aff_frame #define FIELD_PICTURE (s->picture_structure != PICT_FRAME) +#define LEFT_MBS 2 +#define LTOP 0 +#define LBOT 1 +#define LEFT(i) (i) #else #define MB_MBAFF 0 #define MB_FIELD 0 @@ -77,6 +81,10 @@ #define FIELD_PICTURE 0 #undef IS_INTERLACED #define IS_INTERLACED(mb_type) 0 +#define LEFT_MBS 1 +#define LTOP 0 +#define LBOT 0 +#define LEFT(i) 0 #endif #define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE) @@ -272,12 +280,12 @@ typedef struct H264Context{ int topleft_mb_xy; int top_mb_xy; int topright_mb_xy; - int left_mb_xy[2]; + int left_mb_xy[LEFT_MBS]; int topleft_type; int top_type; int topright_type; - int left_type[2]; + int left_type[LEFT_MBS]; const uint8_t * left_block; int topleft_partition; @@ -767,7 +775,7 @@ static inline void pred_pskip_motion(H264Context * const h, int * const mx, int static void fill_decode_neighbors(H264Context *h, int mb_type){ MpegEncContext * const s = &h->s; const int mb_xy= h->mb_xy; - int topleft_xy, top_xy, topright_xy, left_xy[2]; + int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; static const uint8_t left_block_options[4][32]={ {0,1,2,3,7,10,8,11,3+0*4, 3+1*4, 3+2*4, 3+3*4, 1+4*4, 1+8*4, 1+5*4, 1+9*4}, {2,2,3,3,8,11,8,11,3+2*4, 3+2*4, 3+3*4, 3+3*4, 1+5*4, 1+9*4, 1+5*4, 1+9*4}, @@ -784,16 +792,16 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ topleft_xy = top_xy - 1; topright_xy= top_xy + 1; - left_xy[1] = left_xy[0] = mb_xy-1; + left_xy[LBOT] = left_xy[LTOP] = mb_xy-1; h->left_block = left_block_options[0]; if(FRAME_MBAFF){ const int left_mb_field_flag = IS_INTERLACED(s->current_picture.mb_type[mb_xy-1]); const int curr_mb_field_flag = IS_INTERLACED(mb_type); if(s->mb_y&1){ if (left_mb_field_flag != curr_mb_field_flag) { - left_xy[1] = left_xy[0] = mb_xy - s->mb_stride - 1; + left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1; if (curr_mb_field_flag) { - left_xy[1] += s->mb_stride; + left_xy[LBOT] += s->mb_stride; h->left_block = left_block_options[3]; } else { topleft_xy += s->mb_stride; @@ -810,7 +818,7 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ } if (left_mb_field_flag != curr_mb_field_flag) { if (curr_mb_field_flag) { - left_xy[1] += s->mb_stride; + left_xy[LBOT] += s->mb_stride; h->left_block = left_block_options[3]; } else { h->left_block = left_block_options[2]; @@ -822,25 +830,25 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ h->topleft_mb_xy = topleft_xy; h->top_mb_xy = top_xy; h->topright_mb_xy= topright_xy; - h->left_mb_xy[0] = left_xy[0]; - h->left_mb_xy[1] = left_xy[1]; + h->left_mb_xy[LTOP] = left_xy[LTOP]; + h->left_mb_xy[LBOT] = left_xy[LBOT]; //FIXME do we need all in the context? h->topleft_type = s->current_picture.mb_type[topleft_xy] ; h->top_type = s->current_picture.mb_type[top_xy] ; h->topright_type= s->current_picture.mb_type[topright_xy]; - h->left_type[0] = s->current_picture.mb_type[left_xy[0]] ; - h->left_type[1] = s->current_picture.mb_type[left_xy[1]] ; + h->left_type[LTOP] = s->current_picture.mb_type[left_xy[LTOP]] ; + h->left_type[LBOT] = s->current_picture.mb_type[left_xy[LBOT]] ; if(FMO){ - if(h->slice_table[topleft_xy ] != h->slice_num) h->topleft_type = 0; - if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; - if(h->slice_table[left_xy[0] ] != h->slice_num) h->left_type[0] = h->left_type[1] = 0; + if(h->slice_table[topleft_xy ] != h->slice_num) h->topleft_type = 0; + if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; + if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0; }else{ if(h->slice_table[topleft_xy ] != h->slice_num){ h->topleft_type = 0; - if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; - if(h->slice_table[left_xy[0] ] != h->slice_num) h->left_type[0] = h->left_type[1] = 0; + if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; + if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0; } } if(h->slice_table[topright_xy] != h->slice_num) h->topright_type= 0; @@ -848,23 +856,23 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ static void fill_decode_caches(H264Context *h, int mb_type){ MpegEncContext * const s = &h->s; - int topleft_xy, top_xy, topright_xy, left_xy[2]; - int topleft_type, top_type, topright_type, left_type[2]; + int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; + int topleft_type, top_type, topright_type, left_type[LEFT_MBS]; const uint8_t * left_block= h->left_block; int i; uint8_t *nnz; uint8_t *nnz_cache; - topleft_xy = h->topleft_mb_xy ; - top_xy = h->top_mb_xy ; - topright_xy = h->topright_mb_xy; - left_xy[0] = h->left_mb_xy[0] ; - left_xy[1] = h->left_mb_xy[1] ; - topleft_type = h->topleft_type ; - top_type = h->top_type ; - topright_type= h->topright_type ; - left_type[0] = h->left_type[0] ; - left_type[1] = h->left_type[1] ; + topleft_xy = h->topleft_mb_xy; + top_xy = h->top_mb_xy; + topright_xy = h->topright_mb_xy; + left_xy[LTOP] = h->left_mb_xy[LTOP]; + left_xy[LBOT] = h->left_mb_xy[LBOT]; + topleft_type = h->topleft_type; + top_type = h->top_type; + topright_type = h->topright_type; + left_type[LTOP]= h->left_type[LTOP]; + left_type[LBOT]= h->left_type[LBOT]; if(!IS_SKIP(mb_type)){ if(IS_INTRA(mb_type)){ @@ -879,27 +887,27 @@ static void fill_decode_caches(H264Context *h, int mb_type){ h->top_samples_available= 0x33FF; h->topright_samples_available= 0x26EA; } - if(IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[0])){ + if(IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])){ if(IS_INTERLACED(mb_type)){ - if(!(left_type[0] & type_mask)){ + if(!(left_type[LTOP] & type_mask)){ h->topleft_samples_available&= 0xDFFF; h->left_samples_available&= 0x5FFF; } - if(!(left_type[1] & type_mask)){ + if(!(left_type[LBOT] & type_mask)){ h->topleft_samples_available&= 0xFF5F; h->left_samples_available&= 0xFF5F; } }else{ - int left_typei = s->current_picture.mb_type[left_xy[0] + s->mb_stride]; + int left_typei = s->current_picture.mb_type[left_xy[LTOP] + s->mb_stride]; - assert(left_xy[0] == left_xy[1]); - if(!((left_typei & type_mask) && (left_type[0] & type_mask))){ + assert(left_xy[LTOP] == left_xy[LBOT]); + if(!((left_typei & type_mask) && (left_type[LTOP] & type_mask))){ h->topleft_samples_available&= 0xDF5F; h->left_samples_available&= 0x5F5F; } } }else{ - if(!(left_type[0] & type_mask)){ + if(!(left_type[LTOP] & type_mask)){ h->topleft_samples_available&= 0xDF5F; h->left_samples_available&= 0x5F5F; } @@ -921,13 +929,13 @@ static void fill_decode_caches(H264Context *h, int mb_type){ h->intra4x4_pred_mode_cache[7+8*0]= 2 - 3*!(top_type & type_mask); } for(i=0; i<2; i++){ - if(IS_INTRA4x4(left_type[i])){ - int8_t *mode= h->intra4x4_pred_mode + h->mb2br_xy[left_xy[i]]; + if(IS_INTRA4x4(left_type[LEFT(i)])){ + int8_t *mode= h->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]]; h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= mode[6-left_block[0+2*i]]; h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= mode[6-left_block[1+2*i]]; }else{ h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= - h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= 2 - 3*!(left_type[i] & type_mask); + h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= 2 - 3*!(left_type[LEFT(i)] & type_mask); } } } @@ -962,8 +970,8 @@ static void fill_decode_caches(H264Context *h, int mb_type){ } for (i=0; i<2; i++) { - if(left_type[i]){ - nnz = h->non_zero_count[left_xy[i]]; + if(left_type[LEFT(i)]){ + nnz = h->non_zero_count[left_xy[LEFT(i)]]; nnz_cache[3+8* 1 + 2*8*i]= nnz[left_block[8+0+2*i]]; nnz_cache[3+8* 2 + 2*8*i]= nnz[left_block[8+1+2*i]]; if(CHROMA444){ @@ -993,10 +1001,10 @@ static void fill_decode_caches(H264Context *h, int mb_type){ h->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; } // left_cbp - if (left_type[0]) { - h->left_cbp = (h->cbp_table[left_xy[0]] & 0x7F0) - | ((h->cbp_table[left_xy[0]]>>(left_block[0]&(~1)))&2) - | (((h->cbp_table[left_xy[1]]>>(left_block[2]&(~1)))&2) << 2); + if (left_type[LTOP]) { + h->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) + | ((h->cbp_table[left_xy[LTOP]]>>(left_block[0]&(~1)))&2) + | (((h->cbp_table[left_xy[LBOT]]>>(left_block[2]&(~1)))&2) << 2); } else { h->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; } @@ -1031,9 +1039,9 @@ static void fill_decode_caches(H264Context *h, int mb_type){ if(mb_type & (MB_TYPE_16x8|MB_TYPE_8x8)){ for(i=0; i<2; i++){ int cache_idx = -1 + i*2*8; - if(USES_LIST(left_type[i], list)){ - const int b_xy= h->mb2b_xy[left_xy[i]] + 3; - const int b8_xy= 4*left_xy[i] + 1; + if(USES_LIST(left_type[LEFT(i)], list)){ + const int b_xy= h->mb2b_xy[left_xy[LEFT(i)]] + 3; + const int b8_xy= 4*left_xy[LEFT(i)] + 1; AV_COPY32(mv_cache[cache_idx ], mv[b_xy + b_stride*left_block[0+i*2]]); AV_COPY32(mv_cache[cache_idx+8], mv[b_xy + b_stride*left_block[1+i*2]]); ref_cache[cache_idx ]= ref[b8_xy + (left_block[0+i*2]&~1)]; @@ -1042,18 +1050,18 @@ static void fill_decode_caches(H264Context *h, int mb_type){ AV_ZERO32(mv_cache[cache_idx ]); AV_ZERO32(mv_cache[cache_idx+8]); ref_cache[cache_idx ]= - ref_cache[cache_idx+8]= (left_type[i]) ? LIST_NOT_USED : PART_NOT_AVAILABLE; + ref_cache[cache_idx+8]= (left_type[LEFT(i)]) ? LIST_NOT_USED : PART_NOT_AVAILABLE; } } }else{ - if(USES_LIST(left_type[0], list)){ - const int b_xy= h->mb2b_xy[left_xy[0]] + 3; - const int b8_xy= 4*left_xy[0] + 1; + if(USES_LIST(left_type[LTOP], list)){ + const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3; + const int b8_xy= 4*left_xy[LTOP] + 1; AV_COPY32(mv_cache[-1], mv[b_xy + b_stride*left_block[0]]); ref_cache[-1]= ref[b8_xy + (left_block[0]&~1)]; }else{ AV_ZERO32(mv_cache[-1]); - ref_cache[-1]= left_type[0] ? LIST_NOT_USED : PART_NOT_AVAILABLE; + ref_cache[-1]= left_type[LTOP] ? LIST_NOT_USED : PART_NOT_AVAILABLE; } } @@ -1095,16 +1103,16 @@ static void fill_decode_caches(H264Context *h, int mb_type){ }else{ AV_ZERO64(mvd_cache[0 - 1*8]); } - if(USES_LIST(left_type[0], list)){ - const int b_xy= h->mb2br_xy[left_xy[0]] + 6; + if(USES_LIST(left_type[LTOP], list)){ + const int b_xy= h->mb2br_xy[left_xy[LTOP]] + 6; AV_COPY16(mvd_cache[-1 + 0*8], mvd[b_xy - left_block[0]]); AV_COPY16(mvd_cache[-1 + 1*8], mvd[b_xy - left_block[1]]); }else{ AV_ZERO16(mvd_cache[-1 + 0*8]); AV_ZERO16(mvd_cache[-1 + 1*8]); } - if(USES_LIST(left_type[1], list)){ - const int b_xy= h->mb2br_xy[left_xy[1]] + 6; + if(USES_LIST(left_type[LBOT], list)){ + const int b_xy= h->mb2br_xy[left_xy[LBOT]] + 6; AV_COPY16(mvd_cache[-1 + 2*8], mvd[b_xy - left_block[2]]); AV_COPY16(mvd_cache[-1 + 3*8], mvd[b_xy - left_block[3]]); }else{ @@ -1128,17 +1136,17 @@ static void fill_decode_caches(H264Context *h, int mb_type){ AV_WN32A(&direct_cache[-1*8], 0x01010101*(MB_TYPE_16x16>>1)); } - if(IS_DIRECT(left_type[0])) + if(IS_DIRECT(left_type[LTOP])) direct_cache[-1 + 0*8]= MB_TYPE_DIRECT2>>1; - else if(IS_8X8(left_type[0])) - direct_cache[-1 + 0*8]= direct_table[4*left_xy[0] + 1 + (left_block[0]&~1)]; + else if(IS_8X8(left_type[LTOP])) + direct_cache[-1 + 0*8]= direct_table[4*left_xy[LTOP] + 1 + (left_block[0]&~1)]; else direct_cache[-1 + 0*8]= MB_TYPE_16x16>>1; - if(IS_DIRECT(left_type[1])) + if(IS_DIRECT(left_type[LBOT])) direct_cache[-1 + 2*8]= MB_TYPE_DIRECT2>>1; - else if(IS_8X8(left_type[1])) - direct_cache[-1 + 2*8]= direct_table[4*left_xy[1] + 1 + (left_block[2]&~1)]; + else if(IS_8X8(left_type[LBOT])) + direct_cache[-1 + 2*8]= direct_table[4*left_xy[LBOT] + 1 + (left_block[2]&~1)]; else direct_cache[-1 + 2*8]= MB_TYPE_16x16>>1; } @@ -1152,10 +1160,10 @@ static void fill_decode_caches(H264Context *h, int mb_type){ MAP_F2F(scan8[0] + 2 - 1*8, top_type)\ MAP_F2F(scan8[0] + 3 - 1*8, top_type)\ MAP_F2F(scan8[0] + 4 - 1*8, topright_type)\ - MAP_F2F(scan8[0] - 1 + 0*8, left_type[0])\ - MAP_F2F(scan8[0] - 1 + 1*8, left_type[0])\ - MAP_F2F(scan8[0] - 1 + 2*8, left_type[1])\ - MAP_F2F(scan8[0] - 1 + 3*8, left_type[1]) + MAP_F2F(scan8[0] - 1 + 0*8, left_type[LTOP])\ + MAP_F2F(scan8[0] - 1 + 1*8, left_type[LTOP])\ + MAP_F2F(scan8[0] - 1 + 2*8, left_type[LBOT])\ + MAP_F2F(scan8[0] - 1 + 3*8, left_type[LBOT]) if(MB_FIELD){ #define MAP_F2F(idx, mb_type)\ if(!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ @@ -1179,7 +1187,7 @@ static void fill_decode_caches(H264Context *h, int mb_type){ } } - h->neighbor_transform_size= !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[0]); + h->neighbor_transform_size= !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]); } /** diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index a643297f8a..6dacf7a336 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1296,9 +1296,9 @@ static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_sl if(intra_slice){ int ctx=0; - if( h->left_type[0] & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)) + if( h->left_type[LTOP] & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)) ctx++; - if( h->top_type & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)) + if( h->top_type & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)) ctx++; if( get_cabac_noinline( &h->cabac, &state[ctx] ) == 0 ) return 0; /* I4x4 */ @@ -1376,10 +1376,10 @@ static int decode_cabac_mb_chroma_pre_mode( H264Context *h) { int ctx = 0; /* No need to test for IS_INTRA4x4 and IS_INTRA16x16, as we set chroma_pred_mode_table to 0 */ - if( h->left_type[0] && h->chroma_pred_mode_table[mba_xy] != 0 ) + if( h->left_type[LTOP] && h->chroma_pred_mode_table[mba_xy] != 0 ) ctx++; - if( h->top_type && h->chroma_pred_mode_table[mbb_xy] != 0 ) + if( h->top_type && h->chroma_pred_mode_table[mbb_xy] != 0 ) ctx++; if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+ctx] ) == 0 ) @@ -1880,7 +1880,7 @@ int ff_h264_decode_mb_cabac(H264Context *h) { int ctx = 0; assert(h->slice_type_nos == AV_PICTURE_TYPE_B); - if( !IS_DIRECT( h->left_type[0]-1 ) ) + if( !IS_DIRECT( h->left_type[LTOP]-1 ) ) ctx++; if( !IS_DIRECT( h->top_type-1 ) ) ctx++; @@ -2250,7 +2250,7 @@ decode_intra_mb: int i; uint8_t *nnz_cache = h->non_zero_count_cache; for (i = 0; i < 2; i++){ - if (h->left_type[i] && !IS_8x8DCT(h->left_type[i])){ + if (h->left_type[LEFT(i)] && !IS_8x8DCT(h->left_type[LEFT(i)])){ nnz_cache[3+8* 1 + 2*8*i]= nnz_cache[3+8* 2 + 2*8*i]= nnz_cache[3+8* 6 + 2*8*i]= diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 1575b1b3d9..e6b6141f13 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -227,7 +227,7 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, return; } assert(!FRAME_MBAFF); - left_type= h->left_type[0]; + left_type= h->left_type[LTOP]; top_type= h->top_type; mb_type = s->current_picture.mb_type[mb_xy]; @@ -329,7 +329,7 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, AV_WN64A(bS[1][2], 0x0002000200020002ULL); } else { int mask_edge1 = (3*(((5*mb_type)>>5)&1)) | (mb_type>>4); //(mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) ? 3 : (mb_type & MB_TYPE_16x8) ? 1 : 0; - int mask_edge0 = 3*((mask_edge1>>1) & ((5*left_type)>>5)&1); // (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) && (h->left_type[0] & (MB_TYPE_16x16 | MB_TYPE_8x16)) ? 3 : 0; + int mask_edge0 = 3*((mask_edge1>>1) & ((5*left_type)>>5)&1); // (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) && (h->left_type[LTOP] & (MB_TYPE_16x16 | MB_TYPE_8x16)) ? 3 : 0; int step = 1+(mb_type>>24); //IS_8x8DCT(mb_type) ? 2 : 1; edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15)); //(mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4; h->h264dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache, @@ -411,7 +411,7 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u int edge; int chroma_qp_avg[2]; const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; - const int mbm_type = dir == 0 ? h->left_type[0] : h->top_type; + const int mbm_type = dir == 0 ? h->left_type[LTOP] : h->top_type; // how often to recheck mv-based bS when iterating between edges static const uint8_t mask_edge_tab[2][8]={{0,3,3,3,1,1,1,1}, @@ -647,9 +647,9 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint if (FRAME_MBAFF // and current and left pair do not have the same interlaced type - && IS_INTERLACED(mb_type^h->left_type[0]) + && IS_INTERLACED(mb_type^h->left_type[LTOP]) // and left mb is in available to us - && h->left_type[0]) { + && h->left_type[LTOP]) { /* First vertical edge is different in MBAFF frames * There are 8 different bS to compute and 2 different Qp */ @@ -677,8 +677,8 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint const uint8_t *off= offset[MB_FIELD][mb_y&1]; for( i = 0; i < 8; i++ ) { int j= MB_FIELD ? i>>2 : i&1; - int mbn_xy = h->left_mb_xy[j]; - int mbn_type= h->left_type[j]; + int mbn_xy = h->left_mb_xy[LEFT(j)]; + int mbn_type= h->left_type[LEFT(j)]; if( IS_INTRA( mbn_type ) ) bS[i] = 4; From 082768f0b189b1706fdcd15b42dcca5fd0822315 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Sun, 3 Jul 2011 22:47:10 +0000 Subject: [PATCH 258/780] vf_gradfun: relicense x86 asm to LGPL Actually I gave permission for LGPL long ago, but the original import failed to update the license header. --- libavfilter/x86/gradfun.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libavfilter/x86/gradfun.c b/libavfilter/x86/gradfun.c index c9ade8294a..ff3b19d38d 100644 --- a/libavfilter/x86/gradfun.c +++ b/libavfilter/x86/gradfun.c @@ -1,19 +1,21 @@ /* + * Copyright (C) 2009 Loren Merritt + * * This file is part of Libav. * - * Libav 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. + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * Libav 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with Libav; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavutil/cpu.h" From 889639969bf8106c05e2958370dbe290ef283c42 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 4 Jul 2011 02:02:24 +0200 Subject: [PATCH 259/780] dsputil_mmx: try to fix compilation without yasm. Signed-off-by: Michael Niedermayer --- libavcodec/x86/dsputil_mmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 13530418ff..1fcce36f08 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2737,12 +2737,12 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) H264_QPEL_FUNCS(3, 2, ssse3); H264_QPEL_FUNCS(3, 3, ssse3); } +#if HAVE_YASM else if (bit_depth == 10) { H264_QPEL_FUNCS_10(1, 0, ssse3_cache64) H264_QPEL_FUNCS_10(2, 0, ssse3_cache64) H264_QPEL_FUNCS_10(3, 0, ssse3_cache64) } -#if HAVE_YASM if (!high_bit_depth) { c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_ssse3_rnd; c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_ssse3_rnd; From 145293b33566d0029e61281233750ed363cd8cee Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 4 Jul 2011 03:05:24 +0200 Subject: [PATCH 260/780] h264_qpel_mmx: add another forgotten have_yasm Signed-off-by: Michael Niedermayer --- libavcodec/x86/h264_qpel_mmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/x86/h264_qpel_mmx.c b/libavcodec/x86/h264_qpel_mmx.c index 4dac05cfa3..66dee45134 100644 --- a/libavcodec/x86/h264_qpel_mmx.c +++ b/libavcodec/x86/h264_qpel_mmx.c @@ -1294,6 +1294,6 @@ QPEL16_OP(mc31, MMX)\ QPEL16_OP(mc32, MMX)\ QPEL16_OP(mc33, MMX) -#if ARCH_X86_32 // ARCH_X86_64 implies sse2+ +#if HAVE_YASM && ARCH_X86_32 // ARCH_X86_64 implies sse2+ QPEL16(mmxext) #endif From 58f7aad05125058407a3e15ad0125ec3e6d48ffa Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Sun, 3 Jul 2011 22:28:47 -0400 Subject: [PATCH 261/780] Fix build with --disable-yasm. Signed-off-by: Ronald S. Bultje --- libavcodec/x86/dsputil_mmx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index d6eed82dd8..cfec97c8af 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2835,11 +2835,13 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) H264_QPEL_FUNCS(3, 2, ssse3); H264_QPEL_FUNCS(3, 3, ssse3); } +#if HAVE_YASM else if (bit_depth == 10) { H264_QPEL_FUNCS_10(1, 0, ssse3_cache64) H264_QPEL_FUNCS_10(2, 0, ssse3_cache64) H264_QPEL_FUNCS_10(3, 0, ssse3_cache64) } +#endif c->add_png_paeth_prediction= add_png_paeth_prediction_ssse3; #if HAVE_YASM if (!high_bit_depth) { From a4ab70f92e4d8705434a2fee42a2b69a8bfa6bb1 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 27 Jun 2011 07:25:58 +0000 Subject: [PATCH 262/780] ffmpeg: Fix VDPAU decoding for some H264 samples. --- libavcodec/vdpau.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 98616e8da6..bdc596ce24 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -183,7 +183,8 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s) render->info.h264.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; render->info.h264.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present; memcpy(render->info.h264.scaling_lists_4x4, h->pps.scaling_matrix4, sizeof(render->info.h264.scaling_lists_4x4)); - memcpy(render->info.h264.scaling_lists_8x8, h->pps.scaling_matrix8, sizeof(render->info.h264.scaling_lists_8x8)); + memcpy(render->info.h264.scaling_lists_8x8[0], h->pps.scaling_matrix8[0], sizeof(render->info.h264.scaling_lists_8x8[0])); + memcpy(render->info.h264.scaling_lists_8x8[1], h->pps.scaling_matrix8[3], sizeof(render->info.h264.scaling_lists_8x8[0])); ff_draw_horiz_band(s, 0, s->avctx->height); render->bitstream_buffers_used = 0; From 954a6532160b9eac7773613be105fd706d639ade Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Mon, 4 Jul 2011 08:44:49 +0200 Subject: [PATCH 263/780] vorbis: vpxenc: Add missing include for av_rescale* Signed-off-by: Mans Rullgard --- libavcodec/libvorbis.c | 1 + libavcodec/libvpxenc.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c index 88da705a32..85cb9c5989 100644 --- a/libavcodec/libvorbis.c +++ b/libavcodec/libvorbis.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "bytestream.h" #include "vorbis.h" +#include "libavutil/mathematics.h" #undef NDEBUG #include diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 02f8135381..ca2e6157d5 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "libavutil/base64.h" +#include "libavutil/mathematics.h" /** * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h. From 412594ed0ac72ea66391eb3fa9dc8e644237ea61 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 23:19:46 +0100 Subject: [PATCH 264/780] dct-test: remove commented out code Signed-off-by: Mans Rullgard --- libavcodec/dct-test.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index d0fe34e1d7..b40fcc8593 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -177,7 +177,6 @@ static void idct_mmx_init(void) /* the mmx/mmxext idct uses a reordered input, so we patch scan tables */ for (i = 0; i < 64; i++) { idct_mmx_perm[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); -// idct_simple_mmx_perm[i] = simple_block_permute_op(i); } } @@ -235,15 +234,6 @@ static void dct_error(const char *name, int is_idct, break; } -#if 0 // simulate mismatch control -{ int sum=0; - for(i=0;i<64;i++) - sum+=block1[i]; - - if((sum&1)==0) block1[63]^=1; -} -#endif - for(i=0; i<64; i++) block_org[i]= block1[i]; @@ -264,14 +254,6 @@ static void dct_error(const char *name, int is_idct, for(i=0; i<64; i++) block[i]= block1[i]; } -#if 0 // simulate mismatch control for tested IDCT but not the ref -{ int sum=0; - for(i=0;i<64;i++) - sum+=block[i]; - - if((sum&1)==0) block[63]^=1; -} -#endif fdct_func(block); mmx_emms(); @@ -296,19 +278,6 @@ static void dct_error(const char *name, int is_idct, if( abs(block[i])>maxout) maxout=abs(block[i]); } if(blockSumErrMax < blockSumErr) blockSumErrMax= blockSumErr; -#if 0 // print different matrix pairs - if(blockSumErr){ - printf("\n"); - for(i=0; i<64; i++){ - if((i&7)==0) printf("\n"); - printf("%4d ", block_org[i]); - } - for(i=0; i<64; i++){ - if((i&7)==0) printf("\n"); - printf("%4d ", block[i] - block1[i]); - } - } -#endif } for(i=0; i<64; i++) sysErrMax= FFMAX(sysErrMax, FFABS(sysErr[i])); @@ -362,8 +331,6 @@ static void dct_error(const char *name, int is_idct, for(it=0;it Date: Sun, 3 Jul 2011 22:59:03 +0100 Subject: [PATCH 265/780] dct-test: whitespace cosmetics Signed-off-by: Mans Rullgard --- libavcodec/dct-test.c | 376 +++++++++++++++++++++--------------------- 1 file changed, 192 insertions(+), 184 deletions(-) diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index b40fcc8593..c5e29c44a8 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -68,12 +68,13 @@ void ff_simple_idct_neon(DCTELEM *data); void ff_simple_idct_axp(DCTELEM *data); struct algo { - const char *name; - enum { FDCT, IDCT } is_idct; - void (* func) (DCTELEM *block); - void (* ref) (DCTELEM *block); - enum formattag { NO_PERM,MMX_PERM, MMX_SIMPLE_PERM, SCALE_PERM, SSE2_PERM, PARTTRANS_PERM } format; - int mm_support; + const char *name; + enum { FDCT, IDCT } is_idct; + void (*func)(DCTELEM *block); + void (*ref) (DCTELEM *block); + enum formattag { NO_PERM, MMX_PERM, MMX_SIMPLE_PERM, SCALE_PERM, + SSE2_PERM, PARTTRANS_PERM } format; + int mm_support; }; #ifndef FAAN_POSTSCALE @@ -85,60 +86,60 @@ struct algo { static int cpu_flags; struct algo algos[] = { - {"REF-DBL", 0, ff_ref_fdct, ff_ref_fdct, NO_PERM}, - {"FAAN", 0, ff_faandct, ff_ref_fdct, FAAN_SCALE}, - {"FAANI", 1, ff_faanidct, ff_ref_idct, NO_PERM}, - {"IJG-AAN-INT", 0, fdct_ifast, ff_ref_fdct, SCALE_PERM}, - {"IJG-LLM-INT", 0, ff_jpeg_fdct_islow, ff_ref_fdct, NO_PERM}, - {"REF-DBL", 1, ff_ref_idct, ff_ref_idct, NO_PERM}, - {"INT", 1, j_rev_dct, ff_ref_idct, MMX_PERM}, - {"SIMPLE-C", 1, ff_simple_idct, ff_ref_idct, NO_PERM}, + {"REF-DBL", 0, ff_ref_fdct, ff_ref_fdct, NO_PERM}, + {"FAAN", 0, ff_faandct, ff_ref_fdct, FAAN_SCALE}, + {"FAANI", 1, ff_faanidct, ff_ref_idct, NO_PERM}, + {"IJG-AAN-INT", 0, fdct_ifast, ff_ref_fdct, SCALE_PERM}, + {"IJG-LLM-INT", 0, ff_jpeg_fdct_islow, ff_ref_fdct, NO_PERM}, + {"REF-DBL", 1, ff_ref_idct, ff_ref_idct, NO_PERM}, + {"INT", 1, j_rev_dct, ff_ref_idct, MMX_PERM}, + {"SIMPLE-C", 1, ff_simple_idct, ff_ref_idct, NO_PERM}, #if HAVE_MMX - {"MMX", 0, ff_fdct_mmx, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX}, + {"MMX", 0, ff_fdct_mmx, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX}, #if HAVE_MMX2 - {"MMX2", 0, ff_fdct_mmx2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX2}, - {"SSE2", 0, ff_fdct_sse2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_SSE2}, + {"MMX2", 0, ff_fdct_mmx2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX2}, + {"SSE2", 0, ff_fdct_sse2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_SSE2}, #endif #if CONFIG_GPL - {"LIBMPEG2-MMX", 1, ff_mmx_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX}, - {"LIBMPEG2-MMX2", 1, ff_mmxext_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX2}, + {"LIBMPEG2-MMX", 1, ff_mmx_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX}, + {"LIBMPEG2-MMX2", 1, ff_mmxext_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX2}, #endif - {"SIMPLE-MMX", 1, ff_simple_idct_mmx, ff_ref_idct, MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX}, - {"XVID-MMX", 1, ff_idct_xvid_mmx, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX}, - {"XVID-MMX2", 1, ff_idct_xvid_mmx2, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX2}, - {"XVID-SSE2", 1, ff_idct_xvid_sse2, ff_ref_idct, SSE2_PERM, AV_CPU_FLAG_SSE2}, + {"SIMPLE-MMX", 1, ff_simple_idct_mmx, ff_ref_idct, MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX}, + {"XVID-MMX", 1, ff_idct_xvid_mmx, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX}, + {"XVID-MMX2", 1, ff_idct_xvid_mmx2, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX2}, + {"XVID-SSE2", 1, ff_idct_xvid_sse2, ff_ref_idct, SSE2_PERM, AV_CPU_FLAG_SSE2}, #endif #if HAVE_ALTIVEC - {"altivecfdct", 0, fdct_altivec, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_ALTIVEC}, + {"altivecfdct", 0, fdct_altivec, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_ALTIVEC}, #endif #if ARCH_BFIN - {"BFINfdct", 0, ff_bfin_fdct, ff_ref_fdct, NO_PERM}, - {"BFINidct", 1, ff_bfin_idct, ff_ref_idct, NO_PERM}, + {"BFINfdct", 0, ff_bfin_fdct, ff_ref_fdct, NO_PERM}, + {"BFINidct", 1, ff_bfin_idct, ff_ref_idct, NO_PERM}, #endif #if ARCH_ARM - {"SIMPLE-ARM", 1, ff_simple_idct_arm, ff_ref_idct, NO_PERM }, - {"INT-ARM", 1, ff_j_rev_dct_arm, ff_ref_idct, MMX_PERM }, + {"SIMPLE-ARM", 1, ff_simple_idct_arm, ff_ref_idct, NO_PERM }, + {"INT-ARM", 1, ff_j_rev_dct_arm, ff_ref_idct, MMX_PERM }, #if HAVE_ARMV5TE - {"SIMPLE-ARMV5TE", 1, ff_simple_idct_armv5te, ff_ref_idct, NO_PERM }, + {"SIMPLE-ARMV5TE", 1, ff_simple_idct_armv5te, ff_ref_idct, NO_PERM }, #endif #if HAVE_ARMV6 - {"SIMPLE-ARMV6", 1, ff_simple_idct_armv6, ff_ref_idct, MMX_PERM }, + {"SIMPLE-ARMV6", 1, ff_simple_idct_armv6, ff_ref_idct, MMX_PERM }, #endif #if HAVE_NEON - {"SIMPLE-NEON", 1, ff_simple_idct_neon, ff_ref_idct, PARTTRANS_PERM }, + {"SIMPLE-NEON", 1, ff_simple_idct_neon, ff_ref_idct, PARTTRANS_PERM }, #endif #endif /* ARCH_ARM */ #if ARCH_ALPHA - {"SIMPLE-ALPHA", 1, ff_simple_idct_axp, ff_ref_idct, NO_PERM }, + {"SIMPLE-ALPHA", 1, ff_simple_idct_axp, ff_ref_idct, NO_PERM }, #endif - { 0 } + { 0 } }; #define AANSCALE_BITS 12 @@ -148,7 +149,7 @@ uint8_t cropTbl[256 + 2 * MAX_NEG_CROP]; static int64_t gettime(void) { struct timeval tv; - gettimeofday(&tv,NULL); + gettimeofday(&tv, NULL); return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; } @@ -157,18 +158,18 @@ static int64_t gettime(void) static short idct_mmx_perm[64]; -static short idct_simple_mmx_perm[64]={ - 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D, - 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D, - 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D, - 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F, - 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F, - 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D, - 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F, - 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F, +static short idct_simple_mmx_perm[64] = { + 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D, + 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D, + 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D, + 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F, + 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F, + 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D, + 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F, + 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F, }; -static const uint8_t idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7}; +static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 }; static void idct_mmx_init(void) { @@ -181,8 +182,8 @@ static void idct_mmx_init(void) } DECLARE_ALIGNED(16, static DCTELEM, block)[64]; -DECLARE_ALIGNED(8, static DCTELEM, block1)[64]; -DECLARE_ALIGNED(8, static DCTELEM, block_org)[64]; +DECLARE_ALIGNED(8, static DCTELEM, block1)[64]; +DECLARE_ALIGNED(8, static DCTELEM, block_org)[64]; static inline void mmx_emms(void) { @@ -193,144 +194,151 @@ static inline void mmx_emms(void) } static void dct_error(const char *name, int is_idct, - void (*fdct_func)(DCTELEM *block), - void (*fdct_ref)(DCTELEM *block), int form, int test) + void (*fdct_func)(DCTELEM *block), + void (*fdct_ref)(DCTELEM *block), int form, + int test) { int it, i, scale; int err_inf, v; int64_t err2, ti, ti1, it1; - int64_t sysErr[64], sysErrMax=0; - int maxout=0; - int blockSumErrMax=0, blockSumErr; + int64_t sysErr[64], sysErrMax = 0; + int maxout = 0; + int blockSumErrMax = 0, blockSumErr; AVLFG prng; av_lfg_init(&prng, 1); err_inf = 0; err2 = 0; - for(i=0; i<64; i++) sysErr[i]=0; - for(it=0;it>=3; + for (i = 0; i < 64; i++) + block1[i] >>= 3; } - break; - case 1:{ - int num = av_lfg_get(&prng) % 10 + 1; - for(i=0;i>3)&3)] = block1[i]; + for (i = 0; i < 64; i++) + block[(i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3)] = block1[i]; } else { - for(i=0; i<64; i++) - block[i]= block1[i]; + for (i = 0; i < 64; i++) + block[i] = block1[i]; } fdct_func(block); mmx_emms(); if (form == SCALE_PERM) { - for(i=0; i<64; i++) { - scale = 8*(1 << (AANSCALE_BITS + 11)) / ff_aanscales[i]; - block[i] = (block[i] * scale /*+ (1<<(AANSCALE_BITS-1))*/) >> AANSCALE_BITS; + for (i = 0; i < 64; i++) { + scale = 8 * (1 << (AANSCALE_BITS + 11)) / ff_aanscales[i]; + block[i] = (block[i] * scale) >> AANSCALE_BITS; } } fdct_ref(block1); - blockSumErr=0; - for(i=0;i<64;i++) { + blockSumErr = 0; + for (i = 0; i < 64; i++) { v = abs(block[i] - block1[i]); if (v > err_inf) err_inf = v; err2 += v * v; sysErr[i] += block[i] - block1[i]; blockSumErr += v; - if( abs(block[i])>maxout) maxout=abs(block[i]); + if (abs(block[i]) > maxout) + maxout = abs(block[i]); } - if(blockSumErrMax < blockSumErr) blockSumErrMax= blockSumErr; + if (blockSumErrMax < blockSumErr) + blockSumErrMax = blockSumErr; } - for(i=0; i<64; i++) sysErrMax= FFMAX(sysErrMax, FFABS(sysErr[i])); + for (i = 0; i < 64; i++) + sysErrMax = FFMAX(sysErrMax, FFABS(sysErr[i])); - for(i=0; i<64; i++){ - if(i%8==0) printf("\n"); - printf("%7d ", (int)sysErr[i]); + for (i = 0; i < 64; i++) { + if (i % 8 == 0) + printf("\n"); + printf("%7d ", (int) sysErr[i]); } printf("\n"); printf("%s %s: err_inf=%d err2=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n", - is_idct ? "IDCT" : "DCT", - name, err_inf, (double)err2 / NB_ITS / 64.0, (double)sysErrMax / NB_ITS, maxout, blockSumErrMax); + is_idct ? "IDCT" : "DCT", name, err_inf, + (double) err2 / NB_ITS / 64.0, (double) sysErrMax / NB_ITS, + maxout, blockSumErrMax); /* speed test */ - for(i=0;i<64;i++) + for (i = 0; i < 64; i++) block1[i] = 0; - switch(test){ - case 0: - for(i=0;i<64;i++) - block1[i] = av_lfg_get(&prng) % 512 -256; - if (is_idct){ - ff_ref_fdct(block1); - for(i=0;i<64;i++) - block1[i]>>=3; + switch (test) { + case 0: + for (i = 0; i < 64; i++) + block1[i] = av_lfg_get(&prng) % 512 - 256; + if (is_idct) { + ff_ref_fdct(block1); + for (i = 0; i < 64; i++) + block1[i] >>= 3; } - break; - case 1:{ + break; + case 1: case 2: - block1[0] = av_lfg_get(&prng) % 512 -256; - block1[1] = av_lfg_get(&prng) % 512 -256; - block1[2] = av_lfg_get(&prng) % 512 -256; - block1[3] = av_lfg_get(&prng) % 512 -256; - }break; + block1[0] = av_lfg_get(&prng) % 512 - 256; + block1[1] = av_lfg_get(&prng) % 512 - 256; + block1[2] = av_lfg_get(&prng) % 512 - 256; + block1[3] = av_lfg_get(&prng) % 512 - 256; + break; } if (form == MMX_PERM) { - for(i=0;i<64;i++) + for (i = 0; i < 64; i++) block[idct_mmx_perm[i]] = block1[i]; - } else if(form == MMX_SIMPLE_PERM) { - for(i=0;i<64;i++) + } else if (form == MMX_SIMPLE_PERM) { + for (i = 0; i < 64; i++) block[idct_simple_mmx_perm[i]] = block1[i]; } else { - for(i=0; i<64; i++) - block[i]= block1[i]; + for (i = 0; i < 64; i++) + block[i] = block1[i]; } ti = gettime(); it1 = 0; do { - for(it=0;it 255) - v = 255; - dest[i * linesize + j] = (int)rint(v); + for (i = 0; i < 8; i++) { + for (j = 0; j < 8; j++) { + v = block3[8 * i + j]; + if (v < 0) v = 0; + else if (v > 255) v = 255; + dest[i * linesize + j] = (int) rint(v); } } } static void idct248_error(const char *name, - void (*idct248_put)(uint8_t *dest, int line_size, int16_t *block)) + void (*idct248_put)(uint8_t *dest, int line_size, + int16_t *block)) { int it, i, it1, ti, ti1, err_max, v; - AVLFG prng; av_lfg_init(&prng, 1); @@ -438,39 +445,36 @@ static void idct248_error(const char *name, /* just one test to see if code is correct (precision is less important here) */ err_max = 0; - for(it=0;it err_max) err_max = v; } } - printf("%s %s: err_inf=%d\n", - 1 ? "IDCT248" : "DCT248", - name, err_max); + printf("%s %s: err_inf=%d\n", 1 ? "IDCT248" : "DCT248", name, err_max); ti = gettime(); it1 = 0; do { - for(it=0;it Date: Sun, 3 Jul 2011 22:48:53 +0100 Subject: [PATCH 266/780] dct-test: simplify calling dct_error() Pass a pointer to the DCT descriptor instead of each field individually. Signed-off-by: Mans Rullgard --- libavcodec/dct-test.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index c5e29c44a8..7602cfa137 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -193,10 +193,7 @@ static inline void mmx_emms(void) #endif } -static void dct_error(const char *name, int is_idct, - void (*fdct_func)(DCTELEM *block), - void (*fdct_ref)(DCTELEM *block), int form, - int test) +static void dct_error(const struct algo *dct, int test) { int it, i, scale; int err_inf, v; @@ -219,7 +216,7 @@ static void dct_error(const char *name, int is_idct, case 0: for (i = 0; i < 64; i++) block1[i] = (av_lfg_get(&prng) % 512) - 256; - if (is_idct) { + if (dct->is_idct) { ff_ref_fdct(block1); for (i = 0; i < 64; i++) block1[i] >>= 3; @@ -241,16 +238,16 @@ static void dct_error(const char *name, int is_idct, for (i = 0; i < 64; i++) block_org[i] = block1[i]; - if (form == MMX_PERM) { + if (dct->format == MMX_PERM) { for (i = 0; i < 64; i++) block[idct_mmx_perm[i]] = block1[i]; - } else if (form == MMX_SIMPLE_PERM) { + } else if (dct->format == MMX_SIMPLE_PERM) { for (i = 0; i < 64; i++) block[idct_simple_mmx_perm[i]] = block1[i]; - } else if (form == SSE2_PERM) { + } else if (dct->format == SSE2_PERM) { for (i = 0; i < 64; i++) block[(i & 0x38) | idct_sse2_row_perm[i & 7]] = block1[i]; - } else if (form == PARTTRANS_PERM) { + } else if (dct->format == PARTTRANS_PERM) { for (i = 0; i < 64; i++) block[(i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3)] = block1[i]; } else { @@ -258,17 +255,17 @@ static void dct_error(const char *name, int is_idct, block[i] = block1[i]; } - fdct_func(block); + dct->func(block); mmx_emms(); - if (form == SCALE_PERM) { + if (dct->format == SCALE_PERM) { for (i = 0; i < 64; i++) { scale = 8 * (1 << (AANSCALE_BITS + 11)) / ff_aanscales[i]; block[i] = (block[i] * scale) >> AANSCALE_BITS; } } - fdct_ref(block1); + dct->ref(block1); blockSumErr = 0; for (i = 0; i < 64; i++) { @@ -295,7 +292,7 @@ static void dct_error(const char *name, int is_idct, printf("\n"); printf("%s %s: err_inf=%d err2=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n", - is_idct ? "IDCT" : "DCT", name, err_inf, + dct->is_idct ? "IDCT" : "DCT", dct->name, err_inf, (double) err2 / NB_ITS / 64.0, (double) sysErrMax / NB_ITS, maxout, blockSumErrMax); @@ -307,7 +304,7 @@ static void dct_error(const char *name, int is_idct, case 0: for (i = 0; i < 64; i++) block1[i] = av_lfg_get(&prng) % 512 - 256; - if (is_idct) { + if (dct->is_idct) { ff_ref_fdct(block1); for (i = 0; i < 64; i++) block1[i] >>= 3; @@ -322,10 +319,10 @@ static void dct_error(const char *name, int is_idct, break; } - if (form == MMX_PERM) { + if (dct->format == MMX_PERM) { for (i = 0; i < 64; i++) block[idct_mmx_perm[i]] = block1[i]; - } else if (form == MMX_SIMPLE_PERM) { + } else if (dct->format == MMX_SIMPLE_PERM) { for (i = 0; i < 64; i++) block[idct_simple_mmx_perm[i]] = block1[i]; } else { @@ -339,14 +336,14 @@ static void dct_error(const char *name, int is_idct, for (it = 0; it < NB_ITS_SPEED; it++) { for (i = 0; i < 64; i++) block[i] = block1[i]; - fdct_func(block); + dct->func(block); } it1 += NB_ITS_SPEED; ti1 = gettime() - ti; } while (ti1 < 1000000); mmx_emms(); - printf("%s %s: %0.1f kdct/s\n", is_idct ? "IDCT" : "DCT", name, + printf("%s %s: %0.1f kdct/s\n", dct->is_idct ? "IDCT" : "DCT", dct->name, (double) it1 * 1000.0 / (double) ti1); } @@ -543,8 +540,7 @@ int main(int argc, char **argv) for (i = 0; algos[i].name; i++) if (algos[i].is_idct == test_idct && !(~cpu_flags & algos[i].mm_support)) { - dct_error(algos[i].name, algos[i].is_idct, algos[i].func, - algos[i].ref, algos[i].format, test); + dct_error(&algos[i], test); } } return 0; From 4b357756b1a6e4a8d47d5e8def7c8561efc61c60 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 23:03:11 +0100 Subject: [PATCH 267/780] dct-test: split table in two for idct and fdct Signed-off-by: Mans Rullgard --- libavcodec/dct-test.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index 7602cfa137..9a38304ab6 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -85,23 +85,36 @@ struct algo { static int cpu_flags; -struct algo algos[] = { +static const struct algo fdct_tab[] = { {"REF-DBL", 0, ff_ref_fdct, ff_ref_fdct, NO_PERM}, {"FAAN", 0, ff_faandct, ff_ref_fdct, FAAN_SCALE}, - {"FAANI", 1, ff_faanidct, ff_ref_idct, NO_PERM}, {"IJG-AAN-INT", 0, fdct_ifast, ff_ref_fdct, SCALE_PERM}, {"IJG-LLM-INT", 0, ff_jpeg_fdct_islow, ff_ref_fdct, NO_PERM}, + +#if HAVE_MMX + {"MMX", 0, ff_fdct_mmx, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX}, + {"MMX2", 0, ff_fdct_mmx2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX2}, + {"SSE2", 0, ff_fdct_sse2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_SSE2}, +#endif + +#if HAVE_ALTIVEC + {"altivecfdct", 0, fdct_altivec, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_ALTIVEC}, +#endif + +#if ARCH_BFIN + {"BFINfdct", 0, ff_bfin_fdct, ff_ref_fdct, NO_PERM}, +#endif + + { 0 } +}; + +static const struct algo idct_tab[] = { + {"FAANI", 1, ff_faanidct, ff_ref_idct, NO_PERM}, {"REF-DBL", 1, ff_ref_idct, ff_ref_idct, NO_PERM}, {"INT", 1, j_rev_dct, ff_ref_idct, MMX_PERM}, {"SIMPLE-C", 1, ff_simple_idct, ff_ref_idct, NO_PERM}, #if HAVE_MMX - {"MMX", 0, ff_fdct_mmx, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX}, -#if HAVE_MMX2 - {"MMX2", 0, ff_fdct_mmx2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX2}, - {"SSE2", 0, ff_fdct_sse2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_SSE2}, -#endif - #if CONFIG_GPL {"LIBMPEG2-MMX", 1, ff_mmx_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX}, {"LIBMPEG2-MMX2", 1, ff_mmxext_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX2}, @@ -112,18 +125,14 @@ struct algo algos[] = { {"XVID-SSE2", 1, ff_idct_xvid_sse2, ff_ref_idct, SSE2_PERM, AV_CPU_FLAG_SSE2}, #endif -#if HAVE_ALTIVEC - {"altivecfdct", 0, fdct_altivec, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_ALTIVEC}, -#endif - #if ARCH_BFIN - {"BFINfdct", 0, ff_bfin_fdct, ff_ref_fdct, NO_PERM}, {"BFINidct", 1, ff_bfin_idct, ff_ref_idct, NO_PERM}, #endif #if ARCH_ARM {"SIMPLE-ARM", 1, ff_simple_idct_arm, ff_ref_idct, NO_PERM }, {"INT-ARM", 1, ff_j_rev_dct_arm, ff_ref_idct, MMX_PERM }, +#endif #if HAVE_ARMV5TE {"SIMPLE-ARMV5TE", 1, ff_simple_idct_armv5te, ff_ref_idct, NO_PERM }, #endif @@ -133,7 +142,6 @@ struct algo algos[] = { #if HAVE_NEON {"SIMPLE-NEON", 1, ff_simple_idct_neon, ff_ref_idct, PARTTRANS_PERM }, #endif -#endif /* ARCH_ARM */ #if ARCH_ALPHA {"SIMPLE-ALPHA", 1, ff_simple_idct_axp, ff_ref_idct, NO_PERM }, @@ -537,9 +545,9 @@ int main(int argc, char **argv) if (test_248_dct) { idct248_error("SIMPLE-C", ff_simple_idct248_put); } else { + const struct algo *algos = test_idct ? idct_tab : fdct_tab; for (i = 0; algos[i].name; i++) - if (algos[i].is_idct == test_idct && - !(~cpu_flags & algos[i].mm_support)) { + if (!(~cpu_flags & algos[i].mm_support)) { dct_error(&algos[i], test); } } From cf2b4f884d6155a22053e22db73e6da339233062 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 23:05:21 +0100 Subject: [PATCH 268/780] dct-test: remove is_idct field from tables Signed-off-by: Mans Rullgard --- libavcodec/dct-test.c | 65 +++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index 9a38304ab6..3c71993900 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -69,7 +69,6 @@ void ff_simple_idct_axp(DCTELEM *data); struct algo { const char *name; - enum { FDCT, IDCT } is_idct; void (*func)(DCTELEM *block); void (*ref) (DCTELEM *block); enum formattag { NO_PERM, MMX_PERM, MMX_SIMPLE_PERM, SCALE_PERM, @@ -86,65 +85,65 @@ struct algo { static int cpu_flags; static const struct algo fdct_tab[] = { - {"REF-DBL", 0, ff_ref_fdct, ff_ref_fdct, NO_PERM}, - {"FAAN", 0, ff_faandct, ff_ref_fdct, FAAN_SCALE}, - {"IJG-AAN-INT", 0, fdct_ifast, ff_ref_fdct, SCALE_PERM}, - {"IJG-LLM-INT", 0, ff_jpeg_fdct_islow, ff_ref_fdct, NO_PERM}, + {"REF-DBL", ff_ref_fdct, ff_ref_fdct, NO_PERM}, + {"FAAN", ff_faandct, ff_ref_fdct, FAAN_SCALE}, + {"IJG-AAN-INT", fdct_ifast, ff_ref_fdct, SCALE_PERM}, + {"IJG-LLM-INT", ff_jpeg_fdct_islow, ff_ref_fdct, NO_PERM}, #if HAVE_MMX - {"MMX", 0, ff_fdct_mmx, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX}, - {"MMX2", 0, ff_fdct_mmx2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX2}, - {"SSE2", 0, ff_fdct_sse2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_SSE2}, + {"MMX", ff_fdct_mmx, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX}, + {"MMX2", ff_fdct_mmx2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX2}, + {"SSE2", ff_fdct_sse2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_SSE2}, #endif #if HAVE_ALTIVEC - {"altivecfdct", 0, fdct_altivec, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_ALTIVEC}, + {"altivecfdct", fdct_altivec, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_ALTIVEC}, #endif #if ARCH_BFIN - {"BFINfdct", 0, ff_bfin_fdct, ff_ref_fdct, NO_PERM}, + {"BFINfdct", ff_bfin_fdct, ff_ref_fdct, NO_PERM}, #endif { 0 } }; static const struct algo idct_tab[] = { - {"FAANI", 1, ff_faanidct, ff_ref_idct, NO_PERM}, - {"REF-DBL", 1, ff_ref_idct, ff_ref_idct, NO_PERM}, - {"INT", 1, j_rev_dct, ff_ref_idct, MMX_PERM}, - {"SIMPLE-C", 1, ff_simple_idct, ff_ref_idct, NO_PERM}, + {"FAANI", ff_faanidct, ff_ref_idct, NO_PERM}, + {"REF-DBL", ff_ref_idct, ff_ref_idct, NO_PERM}, + {"INT", j_rev_dct, ff_ref_idct, MMX_PERM}, + {"SIMPLE-C", ff_simple_idct, ff_ref_idct, NO_PERM}, #if HAVE_MMX #if CONFIG_GPL - {"LIBMPEG2-MMX", 1, ff_mmx_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX}, - {"LIBMPEG2-MMX2", 1, ff_mmxext_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX2}, + {"LIBMPEG2-MMX", ff_mmx_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX}, + {"LIBMPEG2-MMX2", ff_mmxext_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX2}, #endif - {"SIMPLE-MMX", 1, ff_simple_idct_mmx, ff_ref_idct, MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX}, - {"XVID-MMX", 1, ff_idct_xvid_mmx, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX}, - {"XVID-MMX2", 1, ff_idct_xvid_mmx2, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX2}, - {"XVID-SSE2", 1, ff_idct_xvid_sse2, ff_ref_idct, SSE2_PERM, AV_CPU_FLAG_SSE2}, + {"SIMPLE-MMX", ff_simple_idct_mmx, ff_ref_idct, MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX}, + {"XVID-MMX", ff_idct_xvid_mmx, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX}, + {"XVID-MMX2", ff_idct_xvid_mmx2, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX2}, + {"XVID-SSE2", ff_idct_xvid_sse2, ff_ref_idct, SSE2_PERM, AV_CPU_FLAG_SSE2}, #endif #if ARCH_BFIN - {"BFINidct", 1, ff_bfin_idct, ff_ref_idct, NO_PERM}, + {"BFINidct", ff_bfin_idct, ff_ref_idct, NO_PERM}, #endif #if ARCH_ARM - {"SIMPLE-ARM", 1, ff_simple_idct_arm, ff_ref_idct, NO_PERM }, - {"INT-ARM", 1, ff_j_rev_dct_arm, ff_ref_idct, MMX_PERM }, + {"SIMPLE-ARM", ff_simple_idct_arm, ff_ref_idct, NO_PERM }, + {"INT-ARM", ff_j_rev_dct_arm, ff_ref_idct, MMX_PERM }, #endif #if HAVE_ARMV5TE - {"SIMPLE-ARMV5TE", 1, ff_simple_idct_armv5te, ff_ref_idct, NO_PERM }, + {"SIMPLE-ARMV5TE", ff_simple_idct_armv5te, ff_ref_idct, NO_PERM }, #endif #if HAVE_ARMV6 - {"SIMPLE-ARMV6", 1, ff_simple_idct_armv6, ff_ref_idct, MMX_PERM }, + {"SIMPLE-ARMV6", ff_simple_idct_armv6, ff_ref_idct, MMX_PERM }, #endif #if HAVE_NEON - {"SIMPLE-NEON", 1, ff_simple_idct_neon, ff_ref_idct, PARTTRANS_PERM }, + {"SIMPLE-NEON", ff_simple_idct_neon, ff_ref_idct, PARTTRANS_PERM }, #endif #if ARCH_ALPHA - {"SIMPLE-ALPHA", 1, ff_simple_idct_axp, ff_ref_idct, NO_PERM }, + {"SIMPLE-ALPHA", ff_simple_idct_axp, ff_ref_idct, NO_PERM }, #endif { 0 } @@ -201,7 +200,7 @@ static inline void mmx_emms(void) #endif } -static void dct_error(const struct algo *dct, int test) +static void dct_error(const struct algo *dct, int test, int is_idct) { int it, i, scale; int err_inf, v; @@ -224,7 +223,7 @@ static void dct_error(const struct algo *dct, int test) case 0: for (i = 0; i < 64; i++) block1[i] = (av_lfg_get(&prng) % 512) - 256; - if (dct->is_idct) { + if (is_idct) { ff_ref_fdct(block1); for (i = 0; i < 64; i++) block1[i] >>= 3; @@ -300,7 +299,7 @@ static void dct_error(const struct algo *dct, int test) printf("\n"); printf("%s %s: err_inf=%d err2=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n", - dct->is_idct ? "IDCT" : "DCT", dct->name, err_inf, + is_idct ? "IDCT" : "DCT", dct->name, err_inf, (double) err2 / NB_ITS / 64.0, (double) sysErrMax / NB_ITS, maxout, blockSumErrMax); @@ -312,7 +311,7 @@ static void dct_error(const struct algo *dct, int test) case 0: for (i = 0; i < 64; i++) block1[i] = av_lfg_get(&prng) % 512 - 256; - if (dct->is_idct) { + if (is_idct) { ff_ref_fdct(block1); for (i = 0; i < 64; i++) block1[i] >>= 3; @@ -351,7 +350,7 @@ static void dct_error(const struct algo *dct, int test) } while (ti1 < 1000000); mmx_emms(); - printf("%s %s: %0.1f kdct/s\n", dct->is_idct ? "IDCT" : "DCT", dct->name, + printf("%s %s: %0.1f kdct/s\n", is_idct ? "IDCT" : "DCT", dct->name, (double) it1 * 1000.0 / (double) ti1); } @@ -548,7 +547,7 @@ int main(int argc, char **argv) const struct algo *algos = test_idct ? idct_tab : fdct_tab; for (i = 0; algos[i].name; i++) if (!(~cpu_flags & algos[i].mm_support)) { - dct_error(&algos[i], test); + dct_error(&algos[i], test, test_idct); } } return 0; From 7fd2c138880c61b646090475c90a5607fcd7ddc8 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 23:19:13 +0100 Subject: [PATCH 269/780] dct-test: make speed test optional Signed-off-by: Mans Rullgard --- libavcodec/dct-test.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index 3c71993900..054d0f378d 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -200,7 +200,7 @@ static inline void mmx_emms(void) #endif } -static void dct_error(const struct algo *dct, int test, int is_idct) +static void dct_error(const struct algo *dct, int test, int is_idct, int speed) { int it, i, scale; int err_inf, v; @@ -303,6 +303,9 @@ static void dct_error(const struct algo *dct, int test, int is_idct) (double) err2 / NB_ITS / 64.0, (double) sysErrMax / NB_ITS, maxout, blockSumErrMax); + if (!speed) + return; + /* speed test */ for (i = 0; i < 64; i++) block1[i] = 0; @@ -439,7 +442,8 @@ static void idct248_ref(uint8_t *dest, int linesize, int16_t *block) static void idct248_error(const char *name, void (*idct248_put)(uint8_t *dest, int line_size, - int16_t *block)) + int16_t *block), + int speed) { int it, i, it1, ti, ti1, err_max, v; AVLFG prng; @@ -473,6 +477,9 @@ static void idct248_error(const char *name, } printf("%s %s: err_inf=%d\n", 1 ? "IDCT248" : "DCT248", name, err_max); + if (!speed) + return; + ti = gettime(); it1 = 0; do { @@ -497,7 +504,8 @@ static void help(void) " 1 -> test with random sparse matrixes\n" " 2 -> do 3. test from mpeg4 std\n" "-i test IDCT implementations\n" - "-4 test IDCT248 implementations\n"); + "-4 test IDCT248 implementations\n" + "-t speed test\n"); } int main(int argc, char **argv) @@ -505,6 +513,7 @@ int main(int argc, char **argv) int test_idct = 0, test_248_dct = 0; int c, i; int test = 1; + int speed = 0; cpu_flags = av_get_cpu_flags(); @@ -519,7 +528,7 @@ int main(int argc, char **argv) } for (;;) { - c = getopt(argc, argv, "ih4"); + c = getopt(argc, argv, "ih4t"); if (c == -1) break; switch (c) { @@ -529,6 +538,9 @@ int main(int argc, char **argv) case '4': test_248_dct = 1; break; + case 't': + speed = 1; + break; default: case 'h': help(); @@ -542,12 +554,12 @@ int main(int argc, char **argv) printf("ffmpeg DCT/IDCT test\n"); if (test_248_dct) { - idct248_error("SIMPLE-C", ff_simple_idct248_put); + idct248_error("SIMPLE-C", ff_simple_idct248_put, speed); } else { const struct algo *algos = test_idct ? idct_tab : fdct_tab; for (i = 0; algos[i].name; i++) if (!(~cpu_flags & algos[i].mm_support)) { - dct_error(&algos[i], test, test_idct); + dct_error(&algos[i], test, test_idct, speed); } } return 0; From 84757de0f5b32b2e7dab52b4409fcb99c3e8f65b Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 4 Jul 2011 00:56:38 +0100 Subject: [PATCH 270/780] fate: add 'null' comparison method Setting CMP=null uses stdout from the test as the diff record in the report without further inspection. This can be useful when the exit status of the test itself determines success while the output is informative. Signed-off-by: Mans Rullgard --- tests/fate-run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 2c744b880f..10497c497e 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -123,6 +123,7 @@ if test -e "$ref"; then diff) diff -u -w "$ref" "$outfile" >$cmpfile ;; oneoff) oneoff "$ref" "$outfile" "$fuzz" >$cmpfile ;; stddev) stddev "$ref" "$outfile" "$fuzz" >$cmpfile ;; + null) cat "$outfile" >$cmpfile ;; esac cmperr=$? test $err = 0 && err=$cmperr From 79f3384ce15db4bbf3aa49a526d79ae58ad231c2 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 13:15:16 +0200 Subject: [PATCH 271/780] examples: rename "-example" suffix from examples files The suffix is redundant since the containing directory itself is called "examples". Simplify. --- doc/examples/Makefile | 2 +- doc/examples/{encoding-example.c => encoding.c} | 0 doc/examples/{muxing-example.c => muxing.c} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename doc/examples/{encoding-example.c => encoding.c} (100%) rename doc/examples/{muxing-example.c => muxing.c} (100%) diff --git a/doc/examples/Makefile b/doc/examples/Makefile index c32d524da4..4561b10bad 100644 --- a/doc/examples/Makefile +++ b/doc/examples/Makefile @@ -3,7 +3,7 @@ FFMPEG_LIBS=libavdevice libavformat libavfilter libavcodec libswscale libavutil CFLAGS+=$(shell pkg-config --cflags $(FFMPEG_LIBS)) LDFLAGS+=$(shell pkg-config --libs $(FFMPEG_LIBS)) -EXAMPLES=encoding-example muxing-example +EXAMPLES=encoding muxing OBJS=$(addsuffix .o,$(EXAMPLES)) diff --git a/doc/examples/encoding-example.c b/doc/examples/encoding.c similarity index 100% rename from doc/examples/encoding-example.c rename to doc/examples/encoding.c diff --git a/doc/examples/muxing-example.c b/doc/examples/muxing.c similarity index 100% rename from doc/examples/muxing-example.c rename to doc/examples/muxing.c From 01151a26c03c5df85509150d393e039f574d005f Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 17:27:31 +0200 Subject: [PATCH 272/780] vf_scale: add a "sar" variable Also create a "dar" alias for the "a" variable, for avoiding possible confusion between dar/sar. --- doc/filters.texi | 5 ++++- libavfilter/avfilter.h | 2 +- libavfilter/vf_scale.c | 10 +++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c96de41bfa..6707683982 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1231,9 +1231,12 @@ the output (cropped) width and heigth @item ow, oh same as @var{out_w} and @var{out_h} -@item a +@item dar, a input display aspect ratio, same as @var{iw} / @var{ih} +@item sar +input sample aspect ratio + @item hsub, vsub horizontal and vertical chroma subsample values. For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 55bc095de8..a6869cc53a 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 24 -#define LIBAVFILTER_VERSION_MICRO 1 +#define LIBAVFILTER_VERSION_MICRO 2 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index ef439bdbe8..3be5d99e96 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -39,7 +39,8 @@ static const char *var_names[] = { "in_h", "ih", "out_w", "ow", "out_h", "oh", - "a", + "a", "dar", + "sar", "hsub", "vsub", NULL @@ -53,7 +54,8 @@ enum var_name { VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH, - VAR_A, + VAR_A, VAR_DAR, + VAR_SAR, VAR_HSUB, VAR_VSUB, VARS_NB @@ -158,7 +160,9 @@ static int config_props(AVFilterLink *outlink) var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; - var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_DAR] = var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? + (float) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; var_values[VAR_HSUB] = 1<format].log2_chroma_w; var_values[VAR_VSUB] = 1<format].log2_chroma_h; From 0bf02fb1ea57962b97fb3ffc7c827d4b12e439f3 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 17:31:18 +0200 Subject: [PATCH 273/780] vf_pad: add support for a "sar" variable Also add a "dar" alias for "a", for avoiding confusion with sar/dar. --- doc/filters.texi | 5 ++++- libavfilter/avfilter.h | 2 +- libavfilter/vf_pad.c | 10 +++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 6707683982..b3e4681885 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1129,9 +1129,12 @@ same as @var{out_w} and @var{out_h} x and y offsets as specified by the @var{x} and @var{y} expressions, or NAN if not yet specified -@item a +@item dar, a input display aspect ratio, same as @var{iw} / @var{ih} +@item sar +input sample aspect ratio + @item hsub, vsub horizontal and vertical chroma subsample values. For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index a6869cc53a..704b77d3e4 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 24 -#define LIBAVFILTER_VERSION_MICRO 2 +#define LIBAVFILTER_VERSION_MICRO 3 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 809e458b9f..879a0b5fe8 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -45,7 +45,8 @@ static const char *var_names[] = { "out_h", "oh", "x", "y", - "a", + "a", "dar", + "sar", "hsub", "vsub", NULL @@ -61,7 +62,8 @@ enum var_name { VAR_OUT_H, VAR_OH, VAR_X, VAR_Y, - VAR_A, + VAR_A, VAR_DAR, + VAR_SAR, VAR_HSUB, VAR_VSUB, VARS_NB @@ -156,7 +158,9 @@ static int config_input(AVFilterLink *inlink) var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; - var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_DAR] = var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? + (float) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; var_values[VAR_HSUB] = 1<hsub; var_values[VAR_VSUB] = 2<vsub; From 8b59caca7b4a3b7058a1991f8babd2715df5dd10 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 4 Jul 2011 11:10:50 +0200 Subject: [PATCH 274/780] filters.texi: fix @var{auto} misc typos in yadif docs --- doc/filters.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index b3e4681885..9fde89cd9f 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1743,7 +1743,7 @@ Flip the input video vertically. Deinterlace the input video ("yadif" means "yet another deinterlacing filter"). -It accepts the optional parameters: @var{mode}:@var{parity}:@var(auto). +It accepts the optional parameters: @var{mode}:@var{parity}:@var{auto}. @var{mode} specifies the interlacing mode to adopt, accepts one of the following values: @@ -1777,7 +1777,7 @@ Default value is -1. If interlacing is unknown or decoder does not export this information, top field first will be assumed. -@var{auto] specifies if deinterlacer should trust the interlaced flag +@var{auto} specifies if deinterlacer should trust the interlaced flag and only deinterlace frames marked as interlaced @table @option From 80f1cfd09d15be441d6b22c259397aaec29a7b27 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 4 Jul 2011 11:15:14 +0200 Subject: [PATCH 275/780] vf_pad: fix "vsub" variable value computation It was shifting 2 rather than 1, +10l. --- libavfilter/vf_pad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 879a0b5fe8..e01a750d94 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -162,7 +162,7 @@ static int config_input(AVFilterLink *inlink) var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? (float) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; var_values[VAR_HSUB] = 1<hsub; - var_values[VAR_VSUB] = 2<vsub; + var_values[VAR_VSUB] = 1<vsub; /* evaluate width and height */ av_expr_parse_and_eval(&res, (expr = pad->w_expr), From 6da812e4ee6d6620d3a77ca1ac47a32161ba5aab Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 19:34:10 +0100 Subject: [PATCH 276/780] eval: make timing optional in test program Signed-off-by: Mans Rullgard --- libavutil/eval.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libavutil/eval.c b/libavutil/eval.c index 4bba343bec..8ce687df19 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -533,6 +533,8 @@ int av_expr_parse_and_eval(double *d, const char *s, #ifdef TEST #undef printf +#include + static double const_values[] = { M_PI, M_E, @@ -545,7 +547,7 @@ static const char *const_names[] = { 0 }; -int main(void) +int main(int argc, char **argv) { int i; double d; @@ -617,13 +619,16 @@ int main(void) NULL, NULL, NULL, NULL, NULL, 0, NULL); printf("%f == 0.931322575\n", d); - for (i=0; i<1050; i++) { - START_TIMER + if (argc > 1 && !strcmp(argv[1], "-t")) { + for (i = 0; i < 1050; i++) { + START_TIMER; av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, NULL); - STOP_TIMER("av_expr_parse_and_eval") + STOP_TIMER("av_expr_parse_and_eval"); + } } + return 0; } #endif From 883fd9e393cea378bda99ddc6ee5d5ef2141a9f8 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 19:35:30 +0100 Subject: [PATCH 277/780] eval: add fate test Signed-off-by: Mans Rullgard --- tests/fate/libavutil.mak | 4 ++ tests/ref/fate/eval | 134 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 tests/ref/fate/eval diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index d83ced8a98..4299f081ac 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -21,6 +21,10 @@ fate-des: libavutil/des-test$(EXESUF) fate-des: CMD = run libavutil/des-test fate-des: REF = /dev/null +FATE_TESTS += fate-eval +fate-eval: libavutil/eval-test$(EXESUF) +fate-eval: CMD = run libavutil/eval-test + FATE_TESTS += fate-md5 fate-md5: libavutil/md5-test$(EXESUF) fate-md5: CMD = run libavutil/md5-test diff --git a/tests/ref/fate/eval b/tests/ref/fate/eval new file mode 100644 index 0000000000..bcc1a505b0 --- /dev/null +++ b/tests/ref/fate/eval @@ -0,0 +1,134 @@ +Evaluating '' +'' -> nan + +Evaluating '1;2' +'1;2' -> 2.000000 + +Evaluating '-20' +'-20' -> -20.000000 + +Evaluating '-PI' +'-PI' -> -3.141593 + +Evaluating '+PI' +'+PI' -> 3.141593 + +Evaluating '1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)' +'1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)' -> 12.700000 + +Evaluating '80G/80Gi1k' +'80G/80Gi1k' -> nan + +Evaluating '1Gi' +'1Gi' -> 1073741824.000000 + +Evaluating '1gi' +'1gi' -> nan + +Evaluating '1GiFoo' +'1GiFoo' -> nan + +Evaluating '1k+1k' +'1k+1k' -> 2000.000000 + +Evaluating '1Gi*3foo' +'1Gi*3foo' -> nan + +Evaluating 'foo' +'foo' -> nan + +Evaluating 'foo(' +'foo(' -> nan + +Evaluating 'foo()' +'foo()' -> nan + +Evaluating 'foo)' +'foo)' -> nan + +Evaluating 'sin' +'sin' -> nan + +Evaluating 'sin(' +'sin(' -> nan + +Evaluating 'sin()' +'sin()' -> nan + +Evaluating 'sin)' +'sin)' -> nan + +Evaluating 'sin 10' +'sin 10' -> nan + +Evaluating 'sin(1,2,3)' +'sin(1,2,3)' -> nan + +Evaluating 'sin(1 )' +'sin(1 )' -> 0.841471 + +Evaluating '1' +'1' -> 1.000000 + +Evaluating '1foo' +'1foo' -> nan + +Evaluating 'bar + PI + E + 100f*2 + foo' +'bar + PI + E + 100f*2 + foo' -> nan + +Evaluating '13k + 12f - foo(1, 2)' +'13k + 12f - foo(1, 2)' -> nan + +Evaluating '1gi' +'1gi' -> nan + +Evaluating '1Gi' +'1Gi' -> 1073741824.000000 + +Evaluating 'st(0, 123)' +'st(0, 123)' -> 123.000000 + +Evaluating 'st(1, 123); ld(1)' +'st(1, 123); ld(1)' -> 123.000000 + +Evaluating 'st(0, 1); while(lte(ld(0), 100), st(1, ld(1)+ld(0));st(0, ld(0)+1)); ld(1)' +'st(0, 1); while(lte(ld(0), 100), st(1, ld(1)+ld(0));st(0, ld(0)+1)); ld(1)' -> 5073.000000 + +Evaluating 'st(1, 1); st(2, 2); st(0, 1); while(lte(ld(0),10), st(3, ld(1)+ld(2)); st(1, ld(2)); st(2, ld(3)); st(0, ld(0)+1)); ld(3)' +'st(1, 1); st(2, 2); st(0, 1); while(lte(ld(0),10), st(3, ld(1)+ld(2)); st(1, ld(2)); st(2, ld(3)); st(0, ld(0)+1)); ld(3)' -> 144.000000 + +Evaluating 'while(0, 10)' +'while(0, 10)' -> nan + +Evaluating 'st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))' +'st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))' -> 100.000000 + +Evaluating 'isnan(1)' +'isnan(1)' -> 0.000000 + +Evaluating 'isnan(NAN)' +'isnan(NAN)' -> 1.000000 + +Evaluating 'floor(NAN)' +'floor(NAN)' -> nan + +Evaluating 'floor(123.123)' +'floor(123.123)' -> 123.000000 + +Evaluating 'floor(-123.123)' +'floor(-123.123)' -> -124.000000 + +Evaluating 'trunc(123.123)' +'trunc(123.123)' -> 123.000000 + +Evaluating 'trunc(-123.123)' +'trunc(-123.123)' -> -123.000000 + +Evaluating 'ceil(123.123)' +'ceil(123.123)' -> 124.000000 + +Evaluating 'ceil(-123.123)' +'ceil(-123.123)' -> -123.000000 + +12.700000 == 12.7 +0.931323 == 0.931322575 From dbf396d497e6d6f14b838092ed4ba4283a9505a0 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 4 Jul 2011 00:53:39 +0100 Subject: [PATCH 278/780] dct-test: exit with non-zero status if an IDCT fails IDCTs are partially evaluated according to IEEE 1180-1990 (more or less). An override is added to the table for implementations known to not meet the spec requirements. These variants are run but not checked for accuracy. Signed-off-by: Mans Rullgard --- libavcodec/dct-test.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index 054d0f378d..cd68d48ebc 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -74,6 +74,7 @@ struct algo { enum formattag { NO_PERM, MMX_PERM, MMX_SIMPLE_PERM, SCALE_PERM, SSE2_PERM, PARTTRANS_PERM } format; int mm_support; + int nonspec; }; #ifndef FAAN_POSTSCALE @@ -115,13 +116,13 @@ static const struct algo idct_tab[] = { #if HAVE_MMX #if CONFIG_GPL - {"LIBMPEG2-MMX", ff_mmx_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX}, - {"LIBMPEG2-MMX2", ff_mmxext_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX2}, + {"LIBMPEG2-MMX", ff_mmx_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX, 1}, + {"LIBMPEG2-MMX2", ff_mmxext_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX2, 1}, #endif {"SIMPLE-MMX", ff_simple_idct_mmx, ff_ref_idct, MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX}, - {"XVID-MMX", ff_idct_xvid_mmx, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX}, - {"XVID-MMX2", ff_idct_xvid_mmx2, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX2}, - {"XVID-SSE2", ff_idct_xvid_sse2, ff_ref_idct, SSE2_PERM, AV_CPU_FLAG_SSE2}, + {"XVID-MMX", ff_idct_xvid_mmx, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX, 1}, + {"XVID-MMX2", ff_idct_xvid_mmx2, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX2, 1}, + {"XVID-SSE2", ff_idct_xvid_sse2, ff_ref_idct, SSE2_PERM, AV_CPU_FLAG_SSE2, 1}, #endif #if ARCH_BFIN @@ -200,15 +201,17 @@ static inline void mmx_emms(void) #endif } -static void dct_error(const struct algo *dct, int test, int is_idct, int speed) +static int dct_error(const struct algo *dct, int test, int is_idct, int speed) { int it, i, scale; int err_inf, v; - int64_t err2, ti, ti1, it1; + int64_t err2, ti, ti1, it1, err_sum = 0; int64_t sysErr[64], sysErrMax = 0; int maxout = 0; int blockSumErrMax = 0, blockSumErr; AVLFG prng; + double omse, ome; + int spec_err; av_lfg_init(&prng, 1); @@ -276,7 +279,9 @@ static void dct_error(const struct algo *dct, int test, int is_idct, int speed) blockSumErr = 0; for (i = 0; i < 64; i++) { - v = abs(block[i] - block1[i]); + int err = block[i] - block1[i]; + err_sum += err; + v = abs(err); if (v > err_inf) err_inf = v; err2 += v * v; @@ -298,13 +303,21 @@ static void dct_error(const struct algo *dct, int test, int is_idct, int speed) } printf("\n"); - printf("%s %s: err_inf=%d err2=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n", + omse = (double) err2 / NB_ITS / 64; + ome = (double) err_sum / NB_ITS / 64; + + spec_err = is_idct && (err_inf > 1 || omse > 0.02 || fabs(ome) > 0.0015); + + printf("%s %s: ppe=%d omse=%0.8f ome=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n", is_idct ? "IDCT" : "DCT", dct->name, err_inf, - (double) err2 / NB_ITS / 64.0, (double) sysErrMax / NB_ITS, + omse, ome, (double) sysErrMax / NB_ITS, maxout, blockSumErrMax); + if (spec_err && !dct->nonspec) + return 1; + if (!speed) - return; + return 0; /* speed test */ for (i = 0; i < 64; i++) @@ -355,6 +368,8 @@ static void dct_error(const struct algo *dct, int test, int is_idct, int speed) printf("%s %s: %0.1f kdct/s\n", is_idct ? "IDCT" : "DCT", dct->name, (double) it1 * 1000.0 / (double) ti1); + + return 0; } DECLARE_ALIGNED(8, static uint8_t, img_dest)[64]; @@ -514,6 +529,7 @@ int main(int argc, char **argv) int c, i; int test = 1; int speed = 0; + int err = 0; cpu_flags = av_get_cpu_flags(); @@ -559,8 +575,9 @@ int main(int argc, char **argv) const struct algo *algos = test_idct ? idct_tab : fdct_tab; for (i = 0; algos[i].name; i++) if (!(~cpu_flags & algos[i].mm_support)) { - dct_error(&algos[i], test, test_idct, speed); + err |= dct_error(&algos[i], test, test_idct, speed); } } - return 0; + + return err; } From 27e714435043f52ef818642489c1fb698717496e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 4 Jul 2011 00:58:56 +0100 Subject: [PATCH 279/780] fate: add idct8x8 test This tests the IDCT implementations available in the build. Signed-off-by: Mans Rullgard --- tests/Makefile | 1 + tests/fate/dct.mak | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 tests/fate/dct.mak diff --git a/tests/Makefile b/tests/Makefile index f69acf7e23..431a404219 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -41,6 +41,7 @@ include $(SRC_PATH)/tests/fate/aac.mak include $(SRC_PATH)/tests/fate/als.mak include $(SRC_PATH)/tests/fate/amrnb.mak include $(SRC_PATH)/tests/fate/amrwb.mak +include $(SRC_PATH)/tests/fate/dct.mak include $(SRC_PATH)/tests/fate/fft.mak include $(SRC_PATH)/tests/fate/h264.mak include $(SRC_PATH)/tests/fate/libavutil.mak diff --git a/tests/fate/dct.mak b/tests/fate/dct.mak new file mode 100644 index 0000000000..8f2ab7a8e0 --- /dev/null +++ b/tests/fate/dct.mak @@ -0,0 +1,5 @@ +FATE_TESTS += fate-idct8x8 +fate-idct8x8: libavcodec/dct-test$(EXESUF) +fate-idct8x8: CMD = run libavcodec/dct-test -i +fate-idct8x8: REF = /dev/null +fate-idct8x8: CMP = null From 6c374bc0b40306c84e35a4002ab7fa96ace11c6c Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Mon, 4 Jul 2011 10:41:04 +0100 Subject: [PATCH 280/780] libxvid: add missing include of libavutil/mathematics.h Signed-off-by: Mans Rullgard --- libavcodec/libxvidff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c index 1e887a2a8c..fd0aea58fa 100644 --- a/libavcodec/libxvidff.c +++ b/libavcodec/libxvidff.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "libavutil/cpu.h" #include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" #include "libxvid_internal.h" #if !HAVE_MKSTEMP #include From d04d9f24a0f1ff5d903a8222f6933a7482ddde19 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 19:13:20 +0100 Subject: [PATCH 281/780] aes: allow unaligned input and output buffers Signed-off-by: Mans Rullgard --- libavutil/aes.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/libavutil/aes.c b/libavutil/aes.c index d1fe857914..ace317f38a 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -22,6 +22,7 @@ #include "common.h" #include "aes.h" +#include "intreadwrite.h" typedef union { uint64_t u64[2]; @@ -67,6 +68,20 @@ static inline void addkey(av_aes_block *dst, const av_aes_block *src, dst->u64[1] = src->u64[1] ^ round_key->u64[1]; } +static inline void addkey_s(av_aes_block *dst, const uint8_t *src, + const av_aes_block *round_key) +{ + dst->u64[0] = AV_RN64(src) ^ round_key->u64[0]; + dst->u64[1] = AV_RN64(src + 8) ^ round_key->u64[1]; +} + +static inline void addkey_d(uint8_t *dst, const av_aes_block *src, + const av_aes_block *round_key) +{ + AV_WN64(dst, src->u64[0] ^ round_key->u64[0]); + AV_WN64(dst + 8, src->u64[1] ^ round_key->u64[1]); +} + static void subshift(av_aes_block s0[2], int s, const uint8_t *box) { av_aes_block *s1 = (av_aes_block *) (s0[0].u8 - s); @@ -119,32 +134,28 @@ static inline void crypt(AVAES *a, int s, const uint8_t *sbox, subshift(&a->state[0], s, sbox); } -void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_, - int count, uint8_t *iv_, int decrypt) +void av_aes_crypt(AVAES *a, uint8_t *dst, const uint8_t *src, + int count, uint8_t *iv, int decrypt) { - av_aes_block *dst = (av_aes_block *) dst_; - const av_aes_block *src = (const av_aes_block *) src_; - av_aes_block *iv = (av_aes_block *) iv_; - while (count--) { - addkey(&a->state[1], src, &a->round_key[a->rounds]); + addkey_s(&a->state[1], src, &a->round_key[a->rounds]); if (decrypt) { crypt(a, 0, inv_sbox, dec_multbl); if (iv) { - addkey(&a->state[0], &a->state[0], iv); - *iv = *src; + addkey_s(&a->state[0], iv, &a->state[0]); + memcpy(iv, src, 16); } - addkey(dst, &a->state[0], &a->round_key[0]); + addkey_d(dst, &a->state[0], &a->round_key[0]); } else { if (iv) - addkey(&a->state[1], &a->state[1], iv); + addkey_s(&a->state[1], iv, &a->state[1]); crypt(a, 2, sbox, enc_multbl); - addkey(dst, &a->state[0], &a->round_key[0]); + addkey_d(dst, &a->state[0], &a->round_key[0]); if (iv) - *iv = *dst; + memcpy(iv, dst, 16); } - src++; - dst++; + src += 16; + dst += 16; } } From 9e52a40695609259d1f2fe1d9381ea45f9824272 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 3 Jul 2011 19:14:01 +0100 Subject: [PATCH 282/780] des: allow unaligned input and output buffers Signed-off-by: Mans Rullgard --- libavutil/des.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavutil/des.c b/libavutil/des.c index 5de816387f..db2227b6ec 100644 --- a/libavutil/des.c +++ b/libavutil/des.c @@ -299,10 +299,10 @@ int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt) { } void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt) { - uint64_t iv_val = iv ? av_be2ne64(*(uint64_t *)iv) : 0; + uint64_t iv_val = iv ? AV_RB64(iv) : 0; while (count-- > 0) { uint64_t dst_val; - uint64_t src_val = src ? av_be2ne64(*(const uint64_t *)src) : 0; + uint64_t src_val = src ? AV_RB64(src) : 0; if (decrypt) { uint64_t tmp = src_val; if (d->triple_des) { @@ -319,12 +319,12 @@ void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t } iv_val = iv ? dst_val : 0; } - *(uint64_t *)dst = av_be2ne64(dst_val); + AV_WB64(dst, dst_val); src += 8; dst += 8; } if (iv) - *(uint64_t *)iv = av_be2ne64(iv_val); + AV_WB64(iv, iv_val); } #ifdef TEST From 3e2aa268f652be8828b6351f54d41914c1ec3dae Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Mon, 4 Jul 2011 11:57:46 +0200 Subject: [PATCH 283/780] sha: use AV_RB32() instead of assuming buffer can be cast to uint32_t* Signed-off-by: Mans Rullgard --- libavutil/sha.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/sha.c b/libavutil/sha.c index ae6069dd34..5af742dc48 100644 --- a/libavutil/sha.c +++ b/libavutil/sha.c @@ -42,7 +42,7 @@ const int av_sha_size = sizeof(AVSHA); #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ -#define blk0(i) (block[i] = av_be2ne32(((const uint32_t*)buffer)[i])) +#define blk0(i) (block[i] = AV_RB32(buffer + 4 * (i))) #define blk(i) (block[i] = rol(block[i-3] ^ block[i-8] ^ block[i-14] ^ block[i-16], 1)) #define R0(v,w,x,y,z,i) z += ((w&(x^y))^y) + blk0(i) + 0x5A827999 + rol(v, 5); w = rol(w, 30); @@ -67,7 +67,7 @@ static void sha1_transform(uint32_t state[5], const uint8_t buffer[64]) for (i = 0; i < 80; i++) { int t; if (i < 16) - t = av_be2ne32(((uint32_t*)buffer)[i]); + t = AV_RB32(buffer + 4 * i); else t = rol(block[i-3] ^ block[i-8] ^ block[i-14] ^ block[i-16], 1); block[i] = t; From 3c432e1186443fae474fa4e8613fbc21fd8a6c63 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 3 Jul 2011 16:09:37 +0200 Subject: [PATCH 284/780] doxygen: Fix documentation for some VP8 functions. --- libavcodec/vp8.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index fdf63f095d..e8d3621ea7 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -641,8 +641,6 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_ * @param block destination for block coefficients * @param probs probabilities to use when reading trees from the bitstream * @param i initial coeff index, 0 unless a separate DC block is coded - * @param zero_nhood the initial prediction context for number of surrounding - * all-zero blocks (only left/top, so 0-2) * @param qmul array holding the dc/ac dequant factor at position 0/1 * @return 0 if no coeffs were decoded * otherwise, the index of the last coeff decoded plus one @@ -701,6 +699,17 @@ skip_eob: } #endif +/** + * @param c arithmetic bitstream reader context + * @param block destination for block coefficients + * @param probs probabilities to use when reading trees from the bitstream + * @param i initial coeff index, 0 unless a separate DC block is coded + * @param zero_nhood the initial prediction context for number of surrounding + * all-zero blocks (only left/top, so 0-2) + * @param qmul array holding the dc/ac dequant factor at position 0/1 + * @return 0 if no coeffs were decoded + * otherwise, the index of the last coeff decoded plus one + */ static av_always_inline int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16], uint8_t probs[16][3][NUM_DCT_TOKENS-1], @@ -1034,10 +1043,9 @@ static const uint8_t subpel_idx[3][8] = { }; /** - * Generic MC function. + * luma MC function * * @param s VP8 decoding context - * @param luma 1 for luma (Y) planes, 0 for chroma (Cb/Cr) planes * @param dst target buffer for block data at block position * @param ref reference picture buffer at origin (0, 0) * @param mv motion vector (relative to block position) to get pixel data from @@ -1083,6 +1091,23 @@ void vp8_mc_luma(VP8Context *s, uint8_t *dst, AVFrame *ref, const VP56mv *mv, } } +/** + * chroma MC function + * + * @param s VP8 decoding context + * @param dst1 target buffer for block data at block position (U plane) + * @param dst2 target buffer for block data at block position (V plane) + * @param ref reference picture buffer at origin (0, 0) + * @param mv motion vector (relative to block position) to get pixel data from + * @param x_off horizontal position of block from origin (0, 0) + * @param y_off vertical position of block from origin (0, 0) + * @param block_w width of block (16, 8 or 4) + * @param block_h height of block (always same as block_w) + * @param width width of src/dst plane data + * @param height height of src/dst plane data + * @param linesize size of a single line of plane data, including padding + * @param mc_func motion compensation function pointers (bilinear or sixtap MC) + */ static av_always_inline void vp8_mc_chroma(VP8Context *s, uint8_t *dst1, uint8_t *dst2, AVFrame *ref, const VP56mv *mv, int x_off, int y_off, From 19b6127365ca12c9bbed2b90a250c4860257166d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Mon, 4 Jul 2011 10:19:47 +0200 Subject: [PATCH 285/780] mxfenc: small typo fix Signed-off-by: Diego Biurrun --- libavformat/mxfenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index c448e14b00..c87f2334ba 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1549,7 +1549,7 @@ static uint32_t ff_framenum_to_12m_time_code(unsigned frame, int drop, int fps) ((((frame / (fps * 60)) % 60) / 10) << 12) | // tens of minutes ((((frame / (fps * 60)) % 60) % 10) << 8) | // units of minutes (0 << 7) | // b1 - (0 << 6) | // b2 (NSC), field phase (PAL) + (0 << 6) | // b2 (NTSC), field phase (PAL) ((((frame / (fps * 3600) % 24)) / 10) << 4) | // tens of hours ( (frame / (fps * 3600) % 24)) % 10; // units of hours } From e3759c567db42c8dff255ef9f7258326da470755 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 3 Jul 2011 19:40:34 +0200 Subject: [PATCH 286/780] Add LGPL license boilerplate to files lacking it. --- libavcodec/high_bit_depth.h | 18 ++++++++++++++++++ libavcodec/opt.h | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/libavcodec/high_bit_depth.h b/libavcodec/high_bit_depth.h index 511cd00f3a..c0a6eafe89 100644 --- a/libavcodec/high_bit_depth.h +++ b/libavcodec/high_bit_depth.h @@ -1,3 +1,21 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #include "dsputil.h" #ifndef BIT_DEPTH diff --git a/libavcodec/opt.h b/libavcodec/opt.h index 70de27d192..2380e74332 100644 --- a/libavcodec/opt.h +++ b/libavcodec/opt.h @@ -1,3 +1,21 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + /** * @file * This header is provided for compatibility only and will be removed From 0a94020b5b073d1abf442e28b6db3be785aa680a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Mon, 4 Jul 2011 02:57:47 +0200 Subject: [PATCH 287/780] oggdec: Abort Ogg header parsing when encountering a data packet. Fixes Bugzilla #11. Signed-off-by: Diego Biurrun --- libavformat/oggdec.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 998a33b43c..49f24e9b9b 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -373,8 +373,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, // We have reached the first non-header packet in this stream. // Unfortunately more header packets may still follow for others, - // so we reset this later unless we are done with the headers - // for all streams. + // but if we continue with header parsing we may lose data packets. ogg->headers = 1; // Update the header state for all streams and @@ -383,8 +382,6 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, s->data_offset = os->sync_pos; for (i = 0; i < ogg->nstreams; i++) { struct ogg_stream *cur_os = ogg->streams + i; - if (cur_os->header > 0) - ogg->headers = 0; // if we have a partial non-header packet, its start is // obviously at or after the data start From db54be09c20917081031c73816bfa79c08a1cd5b Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 13:46:58 +0200 Subject: [PATCH 288/780] build: Remove deleted 'check' target from .PHONY list. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2cb5f65c6f..9f7b4361d4 100644 --- a/Makefile +++ b/Makefile @@ -199,5 +199,5 @@ $(sort $(OBJDIRS)): # so this saves some time on slow systems. .SUFFIXES: -.PHONY: all all-yes alltools *clean check config examples install* +.PHONY: all all-yes alltools *clean config examples install* .PHONY: testprogs uninstall* From 74965f2644e3af4d21a1d52841b5b48b2bc0895b Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 4 Jul 2011 11:54:22 +0100 Subject: [PATCH 289/780] dct-test: remove 'ref' function pointer from tables The reference function can be inferred from the direction of the transform, no need for storing it with each entry. Signed-off-by: Mans Rullgard --- libavcodec/dct-test.c | 56 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index cd68d48ebc..689aef8fa9 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -70,7 +70,6 @@ void ff_simple_idct_axp(DCTELEM *data); struct algo { const char *name; void (*func)(DCTELEM *block); - void (*ref) (DCTELEM *block); enum formattag { NO_PERM, MMX_PERM, MMX_SIMPLE_PERM, SCALE_PERM, SSE2_PERM, PARTTRANS_PERM } format; int mm_support; @@ -86,65 +85,65 @@ struct algo { static int cpu_flags; static const struct algo fdct_tab[] = { - {"REF-DBL", ff_ref_fdct, ff_ref_fdct, NO_PERM}, - {"FAAN", ff_faandct, ff_ref_fdct, FAAN_SCALE}, - {"IJG-AAN-INT", fdct_ifast, ff_ref_fdct, SCALE_PERM}, - {"IJG-LLM-INT", ff_jpeg_fdct_islow, ff_ref_fdct, NO_PERM}, + { "REF-DBL", ff_ref_fdct, NO_PERM }, + { "FAAN", ff_faandct, FAAN_SCALE }, + { "IJG-AAN-INT", fdct_ifast, SCALE_PERM }, + { "IJG-LLM-INT", ff_jpeg_fdct_islow, NO_PERM }, #if HAVE_MMX - {"MMX", ff_fdct_mmx, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX}, - {"MMX2", ff_fdct_mmx2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX2}, - {"SSE2", ff_fdct_sse2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_SSE2}, + { "MMX", ff_fdct_mmx, NO_PERM, AV_CPU_FLAG_MMX }, + { "MMX2", ff_fdct_mmx2, NO_PERM, AV_CPU_FLAG_MMX2 }, + { "SSE2", ff_fdct_sse2, NO_PERM, AV_CPU_FLAG_SSE2 }, #endif #if HAVE_ALTIVEC - {"altivecfdct", fdct_altivec, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_ALTIVEC}, + { "altivecfdct", fdct_altivec, NO_PERM, AV_CPU_FLAG_ALTIVEC }, #endif #if ARCH_BFIN - {"BFINfdct", ff_bfin_fdct, ff_ref_fdct, NO_PERM}, + { "BFINfdct", ff_bfin_fdct, NO_PERM }, #endif { 0 } }; static const struct algo idct_tab[] = { - {"FAANI", ff_faanidct, ff_ref_idct, NO_PERM}, - {"REF-DBL", ff_ref_idct, ff_ref_idct, NO_PERM}, - {"INT", j_rev_dct, ff_ref_idct, MMX_PERM}, - {"SIMPLE-C", ff_simple_idct, ff_ref_idct, NO_PERM}, + { "FAANI", ff_faanidct, NO_PERM }, + { "REF-DBL", ff_ref_idct, NO_PERM }, + { "INT", j_rev_dct, MMX_PERM }, + { "SIMPLE-C", ff_simple_idct, NO_PERM }, #if HAVE_MMX #if CONFIG_GPL - {"LIBMPEG2-MMX", ff_mmx_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX, 1}, - {"LIBMPEG2-MMX2", ff_mmxext_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX2, 1}, + { "LIBMPEG2-MMX", ff_mmx_idct, MMX_PERM, AV_CPU_FLAG_MMX, 1 }, + { "LIBMPEG2-MMX2", ff_mmxext_idct, MMX_PERM, AV_CPU_FLAG_MMX2, 1 }, #endif - {"SIMPLE-MMX", ff_simple_idct_mmx, ff_ref_idct, MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX}, - {"XVID-MMX", ff_idct_xvid_mmx, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX, 1}, - {"XVID-MMX2", ff_idct_xvid_mmx2, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX2, 1}, - {"XVID-SSE2", ff_idct_xvid_sse2, ff_ref_idct, SSE2_PERM, AV_CPU_FLAG_SSE2, 1}, + { "SIMPLE-MMX", ff_simple_idct_mmx, MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX }, + { "XVID-MMX", ff_idct_xvid_mmx, NO_PERM, AV_CPU_FLAG_MMX, 1 }, + { "XVID-MMX2", ff_idct_xvid_mmx2, NO_PERM, AV_CPU_FLAG_MMX2, 1 }, + { "XVID-SSE2", ff_idct_xvid_sse2, SSE2_PERM, AV_CPU_FLAG_SSE2, 1 }, #endif #if ARCH_BFIN - {"BFINidct", ff_bfin_idct, ff_ref_idct, NO_PERM}, + { "BFINidct", ff_bfin_idct, NO_PERM }, #endif #if ARCH_ARM - {"SIMPLE-ARM", ff_simple_idct_arm, ff_ref_idct, NO_PERM }, - {"INT-ARM", ff_j_rev_dct_arm, ff_ref_idct, MMX_PERM }, + { "SIMPLE-ARM", ff_simple_idct_arm, NO_PERM }, + { "INT-ARM", ff_j_rev_dct_arm, MMX_PERM }, #endif #if HAVE_ARMV5TE - {"SIMPLE-ARMV5TE", ff_simple_idct_armv5te, ff_ref_idct, NO_PERM }, + { "SIMPLE-ARMV5TE", ff_simple_idct_armv5te,NO_PERM }, #endif #if HAVE_ARMV6 - {"SIMPLE-ARMV6", ff_simple_idct_armv6, ff_ref_idct, MMX_PERM }, + { "SIMPLE-ARMV6", ff_simple_idct_armv6, MMX_PERM }, #endif #if HAVE_NEON - {"SIMPLE-NEON", ff_simple_idct_neon, ff_ref_idct, PARTTRANS_PERM }, + { "SIMPLE-NEON", ff_simple_idct_neon, PARTTRANS_PERM }, #endif #if ARCH_ALPHA - {"SIMPLE-ALPHA", ff_simple_idct_axp, ff_ref_idct, NO_PERM }, + { "SIMPLE-ALPHA", ff_simple_idct_axp, NO_PERM }, #endif { 0 } @@ -203,6 +202,7 @@ static inline void mmx_emms(void) static int dct_error(const struct algo *dct, int test, int is_idct, int speed) { + void (*ref)(DCTELEM *block) = is_idct ? ff_ref_idct : ff_ref_fdct; int it, i, scale; int err_inf, v; int64_t err2, ti, ti1, it1, err_sum = 0; @@ -275,7 +275,7 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) } } - dct->ref(block1); + ref(block1); blockSumErr = 0; for (i = 0; i < 64; i++) { From 94350ab986dfce1c93fa720baf28b548c60a9879 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 4 Jul 2011 12:26:59 +0100 Subject: [PATCH 290/780] eval: clear Parser instances before using This prevents random values from the stack being used as "variables" in expressions. Signed-off-by: Mans Rullgard --- libavutil/eval.c | 4 ++-- tests/ref/fate/eval | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/eval.c b/libavutil/eval.c index 8ce687df19..4d55f42664 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -461,7 +461,7 @@ int av_expr_parse(AVExpr **expr, const char *s, const char * const *func2_names, double (* const *funcs2)(void *, double, double), int log_offset, void *log_ctx) { - Parser p; + Parser p = { 0 }; AVExpr *e = NULL; char *w = av_malloc(strlen(s) + 1); char *wp = w; @@ -506,7 +506,7 @@ end: double av_expr_eval(AVExpr *e, const double *const_values, void *opaque) { - Parser p; + Parser p = { 0 }; p.const_values = const_values; p.opaque = opaque; diff --git a/tests/ref/fate/eval b/tests/ref/fate/eval index bcc1a505b0..fb7a925b77 100644 --- a/tests/ref/fate/eval +++ b/tests/ref/fate/eval @@ -92,7 +92,7 @@ Evaluating 'st(1, 123); ld(1)' 'st(1, 123); ld(1)' -> 123.000000 Evaluating 'st(0, 1); while(lte(ld(0), 100), st(1, ld(1)+ld(0));st(0, ld(0)+1)); ld(1)' -'st(0, 1); while(lte(ld(0), 100), st(1, ld(1)+ld(0));st(0, ld(0)+1)); ld(1)' -> 5073.000000 +'st(0, 1); while(lte(ld(0), 100), st(1, ld(1)+ld(0));st(0, ld(0)+1)); ld(1)' -> 4950.000000 Evaluating 'st(1, 1); st(2, 2); st(0, 1); while(lte(ld(0),10), st(3, ld(1)+ld(2)); st(1, ld(2)); st(2, ld(3)); st(0, ld(0)+1)); ld(3)' 'st(1, 1); st(2, 2); st(0, 1); while(lte(ld(0),10), st(3, ld(1)+ld(2)); st(1, ld(2)); st(2, ld(3)); st(0, ld(0)+1)); ld(3)' -> 144.000000 From e589e4b82de49526e5d900fdda5b8321727be004 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 3 Jul 2011 16:58:55 +0200 Subject: [PATCH 291/780] Remove unused static tables and static inline functions. --- libavcodec/rv34.c | 20 -------------------- libavcodec/vc1dec.c | 1 - libswscale/swscale.c | 11 ----------- 3 files changed, 32 deletions(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index c5dcfdcba4..98607ea7ff 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -423,17 +423,6 @@ static inline RV34VLC* choose_vlc_set(int quant, int mod, int type) : &intra_vlcs[rv34_quant_to_vlc_set[0][av_clip(quant, 0, 30)]]; } -/** - * Decode quantizer difference and return modified quantizer. - */ -static inline int rv34_decode_dquant(GetBitContext *gb, int quant) -{ - if(get_bits1(gb)) - return rv34_dquant_tab[get_bits1(gb)][quant]; - else - return get_bits(gb, 5); -} - /** * Decode macroblock header and return CBP in case of success, -1 otherwise. */ @@ -1255,15 +1244,6 @@ static int check_slice_end(RV34DecContext *r, MpegEncContext *s) return 0; } -static inline int slice_compare(SliceInfo *si1, SliceInfo *si2) -{ - return si1->type != si2->type || - si1->start >= si2->start || - si1->width != si2->width || - si1->height != si2->height|| - si1->pts != si2->pts; -} - static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int buf_size) { MpegEncContext *s = &r->s; diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 8fca2da738..cf828dd1f0 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -45,7 +45,6 @@ #define MB_INTRA_VLC_BITS 9 #define DC_VLC_BITS 9 #define AC_VLC_BITS 9 -static const uint16_t table_mb_intra[64][2]; static const uint16_t vlc_offs[] = { diff --git a/libswscale/swscale.c b/libswscale/swscale.c index dacf40ed8a..14807fdc46 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -80,17 +80,6 @@ untested special converters #define RV ( (int)(0.500*224/255*(1< Date: Mon, 4 Jul 2011 06:05:34 -0700 Subject: [PATCH 292/780] H.264: fix overreads of qscale_table filter_mb_fast assumed that qscale_table was padded like many of the other tables. --- libavcodec/mpegvideo.c | 5 +++-- libavcodec/mpegvideo.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 4978d28b49..ceed41f230 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -285,9 +285,10 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){ } FF_ALLOCZ_OR_GOTO(s->avctx, pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2, fail) //the +2 is for the slice end check - FF_ALLOCZ_OR_GOTO(s->avctx, pic->qscale_table , mb_array_size * sizeof(uint8_t) , fail) + FF_ALLOCZ_OR_GOTO(s->avctx, pic->qscale_table_base , (big_mb_num + s->mb_stride) * sizeof(uint8_t) , fail) FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_type_base , (big_mb_num + s->mb_stride) * sizeof(uint32_t), fail) pic->mb_type= pic->mb_type_base + 2*s->mb_stride+1; + pic->qscale_table = pic->qscale_table_base + 2*s->mb_stride + 1; if(s->out_format == FMT_H264){ for(i=0; i<2; i++){ FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b4_array_size+4) * sizeof(int16_t), fail) @@ -339,7 +340,7 @@ static void free_picture(MpegEncContext *s, Picture *pic){ av_freep(&pic->mc_mb_var); av_freep(&pic->mb_mean); av_freep(&pic->mbskip_table); - av_freep(&pic->qscale_table); + av_freep(&pic->qscale_table_base); av_freep(&pic->mb_type_base); av_freep(&pic->dct_coeff); av_freep(&pic->pan_scan); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index e072aa7c33..d309fcb83b 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -88,6 +88,7 @@ typedef struct Picture{ * halfpel luma planes. */ uint8_t *interpolated[3]; + int8_t *qscale_table_base; int16_t (*motion_val_base[2])[2]; uint32_t *mb_type_base; #define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if there is just one type From 9cec1bbd1477b1e38907b37779ab9a7f5800eca2 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Fri, 24 Jun 2011 12:02:41 +0200 Subject: [PATCH 293/780] ogg: propagate return values and return more meaningful error values Signed-off-by: Diego Biurrun --- libavformat/oggdec.c | 59 +++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 49f24e9b9b..e33de7d978 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -192,7 +192,7 @@ static int ogg_read_page(AVFormatContext *s, int *str) AVIOContext *bc = s->pb; struct ogg *ogg = s->priv_data; struct ogg_stream *os; - int i = 0; + int ret, i = 0; int flags, nsegs; uint64_t gp; uint32_t serial; @@ -200,8 +200,9 @@ static int ogg_read_page(AVFormatContext *s, int *str) uint8_t sync[4]; int sp = 0; - if (avio_read (bc, sync, 4) < 4) - return -1; + ret = avio_read(bc, sync, 4); + if (ret < 4) + return ret < 0 ? ret : AVERROR_EOF; do{ int c; @@ -213,17 +214,17 @@ static int ogg_read_page(AVFormatContext *s, int *str) c = avio_r8(bc); if (bc->eof_reached) - return -1; + return AVERROR_EOF; sync[sp++ & 3] = c; }while (i++ < MAX_PAGE_SIZE); if (i >= MAX_PAGE_SIZE){ av_log (s, AV_LOG_INFO, "ogg, can't find sync word\n"); - return -1; + return AVERROR_INVALIDDATA; } if (avio_r8(bc) != 0) /* version */ - return -1; + return AVERROR_INVALIDDATA; flags = avio_r8(bc); gp = avio_rl64 (bc); @@ -248,7 +249,7 @@ static int ogg_read_page(AVFormatContext *s, int *str) idx = ogg_new_stream(s, serial, 1); } if (idx < 0) - return -1; + return idx; } os = ogg->streams + idx; @@ -257,8 +258,9 @@ static int ogg_read_page(AVFormatContext *s, int *str) if(os->psize > 0) ogg_new_buf(ogg, idx); - if (avio_read (bc, os->segments, nsegs) < nsegs) - return -1; + ret = avio_read(bc, os->segments, nsegs); + if (ret < nsegs) + return ret < 0 ? ret : AVERROR_EOF; os->nsegs = nsegs; os->segp = 0; @@ -289,8 +291,9 @@ static int ogg_read_page(AVFormatContext *s, int *str) os->buf = nb; } - if (avio_read (bc, os->buf + os->bufpos, size) < size) - return -1; + ret = avio_read(bc, os->buf + os->bufpos, size); + if (ret < size) + return ret < 0 ? ret : AVERROR_EOF; os->bufpos += size; os->granule = gp; @@ -306,7 +309,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, int64_t *fpos) { struct ogg *ogg = s->priv_data; - int idx, i; + int idx, i, ret; struct ogg_stream *os; int complete = 0; int segp = 0, psize = 0; @@ -317,8 +320,9 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, idx = ogg->curidx; while (idx < 0){ - if (ogg_read_page (s, &idx) < 0) - return -1; + ret = ogg_read_page(s, &idx); + if (ret < 0) + return ret; } os = ogg->streams + idx; @@ -330,6 +334,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, if (os->header < 0){ os->codec = ogg_find_codec (os->buf, os->bufpos); if (!os->codec){ + av_log(s, AV_LOG_WARNING, "Codec not found\n"); os->header = 0; return 0; } @@ -428,10 +433,12 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, static int ogg_get_headers(AVFormatContext *s) { struct ogg *ogg = s->priv_data; + int ret; do{ - if (ogg_packet (s, NULL, NULL, NULL, NULL) < 0) - return -1; + ret = ogg_packet(s, NULL, NULL, NULL, NULL); + if (ret < 0) + return ret; }while (!ogg->headers); av_dlog(s, "found headers\n"); @@ -478,12 +485,12 @@ static int ogg_get_length(AVFormatContext *s) static int ogg_read_header(AVFormatContext *s, AVFormatParameters *ap) { struct ogg *ogg = s->priv_data; - int i; + int ret, i; ogg->curidx = -1; //linear headers seek from start - if (ogg_get_headers (s) < 0){ - return -1; - } + ret = ogg_get_headers(s); + if (ret < 0) + return ret; for (i = 0; i < ogg->nstreams; i++) if (ogg->streams[i].header < 0) @@ -530,15 +537,16 @@ static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt) { struct ogg *ogg; struct ogg_stream *os; - int idx = -1; + int idx = -1, ret; int pstart, psize; int64_t fpos, pts, dts; //Get an ogg packet retry: do{ - if (ogg_packet (s, &idx, &pstart, &psize, &fpos) < 0) - return AVERROR(EIO); + ret = ogg_packet(s, &idx, &pstart, &psize, &fpos); + if (ret < 0) + return ret; }while (idx < 0 || !s->streams[idx]); ogg = s->priv_data; @@ -552,8 +560,9 @@ retry: os->keyframe_seek = 0; //Alloc a pkt - if (av_new_packet (pkt, psize) < 0) - return AVERROR(EIO); + ret = av_new_packet(pkt, psize); + if (ret < 0) + return ret; pkt->stream_index = idx; memcpy (pkt->data, os->buf + pstart, psize); From 66e2dd11876395c3ad053744b19fd46b0618155a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 3 Jul 2011 19:29:18 +0200 Subject: [PATCH 294/780] doxygen: Add qmul docs. --- libavcodec/h264idct_template.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c index e288f9bf1b..c024538db5 100644 --- a/libavcodec/h264idct_template.c +++ b/libavcodec/h264idct_template.c @@ -237,6 +237,7 @@ void FUNCC(ff_h264_idct_add8)(uint8_t **dest, const int *block_offset, DCTELEM * } /** * IDCT transforms the 16 dc values and dequantizes them. + * @param qmul quantization parameter */ void FUNCC(ff_h264_luma_dc_dequant_idct)(DCTELEM *_output, DCTELEM *_input, int qmul){ #define stride 16 From 96676e1abfece89e20bc962255b48cb2d9e417bd Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 4 Jul 2011 17:13:05 +0200 Subject: [PATCH 295/780] Unbreak libavutil API. --- libavutil/avutil.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavutil/avutil.h b/libavutil/avutil.h index d0d5d8d3dc..568f66b989 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -126,5 +126,9 @@ char av_get_picture_type_char(enum AVPictureType pict_type); #include "common.h" #include "error.h" #include "mathematics.h" +#include "rational.h" +#include "intfloat_readwrite.h" +#include "log.h" +#include "pixfmt.h" #endif /* AVUTIL_AVUTIL_H */ From 75a24bef4a33a36d1bcd9dbd87c105d5893d0728 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 4 Jul 2011 16:26:03 +0100 Subject: [PATCH 296/780] iirfilter: add fate test Change the test program to output text instead of binary files so it can be compared easily in FATE. Signed-off-by: Mans Rullgard --- libavcodec/iirfilter.c | 13 +- tests/fate2.mak | 4 + tests/ref/fate/iirfilter | 1024 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 1033 insertions(+), 8 deletions(-) create mode 100644 tests/ref/fate/iirfilter diff --git a/libavcodec/iirfilter.c b/libavcodec/iirfilter.c index a942068aee..34d3962807 100644 --- a/libavcodec/iirfilter.c +++ b/libavcodec/iirfilter.c @@ -311,6 +311,9 @@ av_cold void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs) } #ifdef TEST +#undef printf +#include + #define FILT_ORDER 4 #define SIZE 1024 int main(void) @@ -320,7 +323,6 @@ int main(void) float cutoff_coeff = 0.4; int16_t x[SIZE], y[SIZE]; int i; - FILE* fd; fcoeffs = ff_iir_filter_init_coeffs(NULL, FF_FILTER_TYPE_BUTTERWORTH, FF_FILTER_MODE_LOWPASS, FILT_ORDER, @@ -333,13 +335,8 @@ int main(void) ff_iir_filter(fcoeffs, fstate, SIZE, x, 1, y, 1); - fd = fopen("in.bin", "w"); - fwrite(x, sizeof(x[0]), SIZE, fd); - fclose(fd); - - fd = fopen("out.bin", "w"); - fwrite(y, sizeof(y[0]), SIZE, fd); - fclose(fd); + for (i = 0; i < SIZE; i++) + printf("%6d %6d\n", x[i], y[i]); ff_iir_filter_free_coeffs(fcoeffs); ff_iir_filter_free_state(fstate); diff --git a/tests/fate2.mak b/tests/fate2.mak index ef8c3b8d5b..a743f0cd59 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -218,3 +218,7 @@ fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff fate-musepack7: REF = $(SAMPLES)/musepack/inside-mp7.pcm fate-musepack7: FUZZ = 1 + +FATE_TESTS += fate-iirfilter +fate-iirfilter: libavcodec/iirfilter-test$(EXESUF) +fate-iirfilter: CMD = run libavcodec/iirfilter-test diff --git a/tests/ref/fate/iirfilter b/tests/ref/fate/iirfilter new file mode 100644 index 0000000000..2e5902d766 --- /dev/null +++ b/tests/ref/fate/iirfilter @@ -0,0 +1,1024 @@ + 0 0 + 38 2 + 151 15 + 339 65 + 603 182 + 942 381 + 1356 664 + 1845 1021 + 2409 1450 + 3046 1953 + 3755 2530 + 4535 3182 + 5384 3907 + 6300 4700 + 7278 5563 + 8315 6491 + 9405 7481 + 10541 8529 + 11717 9629 + 12924 10773 + 14151 11956 + 15385 13167 + 16615 14396 + 17825 15630 + 18997 16857 + 20114 18060 + 21156 19222 + 22102 20325 + 22929 21349 + 23613 22273 + 24132 23073 + 24461 23726 + 24575 24208 + 24453 24495 + 24073 24564 + 23416 24392 + 22467 23959 + 21213 23245 + 19649 22236 + 17773 20922 + 15590 19296 + 13116 17360 + 10371 15119 + 7386 12591 + 4201 9797 + 867 6771 + -2559 3554 + -6008 199 + -9405 -3235 +-12667 -6678 +-15707 -10053 +-18435 -13277 +-20762 -16261 +-22602 -18916 +-23875 -21153 +-24511 -22887 +-24457 -24040 +-23675 -24546 +-22151 -24352 +-19895 -23428 +-16946 -21762 +-13370 -19370 + -9265 -16296 + -4757 -12613 + 0 -8423 + 4831 -3858 + 9544 923 + 13934 5743 + 17799 10406 + 20942 14708 + 23189 18447 + 24395 21430 + 24457 23488 + 23323 24483 + 21001 24321 + 17563 22963 + 13148 20426 + 7959 16795 + 2259 12223 + -3643 6922 + -9405 1166 +-14670 -4731 +-19092 -10421 +-22359 -15550 +-24213 -19777 +-24481 -22797 +-23087 -24368 +-20071 -24334 +-15590 -22639 + -9924 -19343 + -3457 -14629 + 3345 -8793 + 9959 -2236 + 15851 4563 + 20517 11078 + 23528 16779 + 24575 21171 + 23506 23846 + 20349 24522 + 15327 23076 + 8845 19572 + 1469 14264 + -6117 7589 +-13180 135 +-18997 -7403 +-22942 -14289 +-24553 -19814 +-23592 -23377 +-20092 -24551 +-14366 -23145 + -6989 -19239 + 1244 -13192 + 9405 -5620 + 16532 2656 + 21744 10697 + 24357 17548 + 23978 22356 + 20579 24483 + 14518 23593 + 6518 19723 + -2409 13293 +-11083 5078 +-18310 -3876 +-23048 -12378 +-24568 -19252 +-22573 -23500 +-17270 -24458 + -9370 -21908 + 0 -16140 + 9439 -7935 + 17484 1526 + 22832 10824 + 24568 18508 + 22327 23330 + 16392 24452 + 7673 21608 + -2409 15181 +-12146 6168 +-19828 -3955 +-24050 -13466 +-23978 -20689 +-19535 -24292 +-11451 -23552 + -1168 -18512 + 9405 -10015 + 18234 416 + 23560 10836 + 24257 19234 + 20092 23929 + 11817 23916 + 1055 19105 + -9993 10379 +-18997 -540 +-23986 -11413 +-23802 -19939 +-18385 -24246 + -8845 -23318 + 2746 -17260 + 13778 -7325 + 21691 4319 + 24575 15045 + 21656 22357 + 13528 24482 + 2071 20823 + -9959 12152 +-19581 484 +-24331 -11367 +-22915 -20460 +-15590 -24459 + -4164 -22257 + 8421 -14315 + 18828 -2603 + 24213 9857 + 23022 19756 + 15474 24383 + 3569 22388 + -9405 14211 +-19761 2031 +-24471 -10785 +-22069 -20591 +-13148 -24512 + -264 -21311 + 12763 -11818 + 21968 1241 + 24457 13990 + 19351 22545 + 8137 24211 + -5715 18362 +-17799 6720 +-24167 -7108 +-22646 -18722 +-13622 -24326 + 0 -21995 + 13685 -12382 + 22762 1409 + 24035 14788 + 16946 23188 + 3867 23644 +-10643 15884 +-21401 2514 +-24457 -11806 +-18584 -21960 + -5825 -24220 + 9160 -17649 + 20762 -4546 + 24527 10303 + 18901 21343 + 5935 24337 + -9405 18028 +-21098 4727 +-24442 -10470 +-17979 -21608 + -4201 -24206 + 11351 -17110 + 22280 -3064 + 23970 12287 + 15590 22636 + 565 23615 +-14760 14693 +-23773 -479 +-22467 -15504 +-11284 -23907 + 4942 -21954 + 19021 -10373 + 24575 5837 + 18973 19502 + 4646 24445 +-11883 18316 +-22929 3786 +-23226 -12541 +-12505 -23090 + 4239 -22841 + 18997 -11784 + 24567 4932 + 18107 19331 + 2671 24403 +-14151 17558 +-23919 2036 +-21602 -14549 + -8244 -23897 + 9405 -21206 + 22232 -7710 + 23473 9785 + 12342 22272 + -5384 23186 +-20286 11920 +-24287 -5693 +-15090 -20319 + 2409 -24060 + 18633 -14771 + 24538 2613 + 16698 18608 + -603 24329 +-17616 16471 +-24575 -682 +-17351 -17495 + 0 -24355 + 17404 -17211 + 24575 -65 + 17136 17163 + -603 24334 +-18031 17094 +-24538 -374 +-16023 -17660 + 2409 -24287 + 19397 -16108 + 24287 1992 + 13872 18902 + -5384 24066 +-21251 14131 +-23473 -4761 +-10473 -20664 + 9405 -23351 + 23151 -10967 + 21602 8573 + 5642 22543 +-14151 21682 +-24430 6431 +-18107 -13147 + 641 -23920 + 18997 -18514 + 24207 -475 + 12505 17922 + -8030 23970 +-22929 13357 +-21511 -6625 + -4646 -21972 + 15619 -21758 + 24575 -6009 + 15561 14083 + -4942 24019 +-21831 16485 +-22467 -3138 + -6227 -20474 + 14760 -22641 + 24569 -7904 + 15590 12791 + -5421 23839 +-22280 16760 +-21797 -3160 + -4201 -20666 + 16754 -22169 + 24442 -6381 + 12602 14430 + -9405 23865 +-23848 14348 +-18901 -6644 + 1545 -22308 + 20762 -19937 + 22804 -1339 + 5825 18365 +-16080 22954 +-24457 8529 +-12080 -13009 + 10643 -23650 + 24269 -14353 + 16946 7119 + -5127 22521 +-22762 18602 +-20413 -1370 + 0 -20152 + 20454 -21342 + 22646 -3797 + 4461 17096 +-17799 22804 +-23902 8148 + -8137 -13817 + 15149 -23296 + 24457 -11618 + 11016 10660 +-12763 23135 +-24574 14243 +-13148 -7861 + 10813 -22608 + 24471 -16124 + 14609 5565 + -9405 21949 +-24315 17379 +-15474 -3849 + 8598 -21336 + 24213 -18120 + 15793 2745 + -8421 20885 +-24220 18429 +-15590 -2263 + 8880 -20663 + 24331 -18359 + 14851 2398 + -9959 20685 +-24488 17917 +-13528 -3137 + 11618 -20918 + 24575 -17075 + 11551 4460 +-13778 21286 +-24421 15770 + -8845 -6328 + 16307 -21661 + 23802 -13916 + 5348 8671 +-18997 21868 +-22452 11421 + -1055 -11371 + 21548 -21685 + 20092 -8212 + -3941 14242 +-23560 20853 +-16476 4267 + 9405 -17009 + 24547 -19106 + 11451 343 +-14911 19309 +-23978 16208 + -5053 -5409 + 19828 -20699 + 21364 -12016 + -2409 10553 +-23347 20700 +-16392 6559 + 10268 -15211 + 24568 -18879 + 9090 -118 +-17484 18664 +-22690 14969 + 0 -6714 + 22719 -20134 + 17270 -9014 + -9717 13022 +-24568 18943 + -8527 1506 + 18310 -17662 + 21934 -14749 + -2409 6538 +-23695 19463 +-14518 7789 + 13433 -13633 + 23978 -17566 + 3270 935 +-21744 18075 +-18184 11812 + 9405 -9654 + 24544 -18394 + 6989 -3082 +-19939 16117 +-20092 13945 + 6881 -6613 + 24553 -18196 + 8809 -5437 +-18997 14458 +-20742 14731 + 6117 -4859 + 24531 -17657 + 8845 -6307 +-19210 13526 +-20349 14588 + 7170 -4444 + 24575 -17109 + 7098 -5874 +-20517 13412 +-18780 13691 + 9959 -5272 + 24347 -16558 + 3457 -4241 +-22482 13949 +-15590 11979 + 14181 -7142 + 23087 -15723 + -2146 -1459 +-24213 14726 +-10200 9228 + 19092 -9692 + 19717 -14108 + -9405 2343 +-24304 15085 + -2259 5221 + 23251 -12286 + 13148 -11127 +-17190 6746 +-21001 14161 + 7745 2 + 24457 -13938 + 2971 -6372 +-23189 10842 +-12860 11094 + 17799 -5795 + 20243 -13421 + -9544 -30 +-24096 13184 + 0 5498 + 24110 -10713 + 9265 -9718 +-20620 6673 +-16946 12155 + 14427 -1883 + 22151 -12653 + -6591 -2861 +-24457 11378 + -1770 6908 + 23875 -8726 + 9648 -9817 +-20762 5209 +-16251 11385 + 15707 -1358 + 21059 -11610 + -9405 -2353 +-23830 10656 + 2559 5560 + 24560 -8789 + 4201 -8028 +-23439 6314 +-10371 9643 + 20783 -3542 + 15590 -10404 +-16973 742 +-19649 10386 + 12407 1870 + 22467 -9720 + -7458 -4144 +-24073 8562 + 2446 5991 + 24575 -7072 + 2371 -7375 +-24132 5398 + -6808 8306 + 22929 -3667 + 10745 -8824 +-21156 1980 +-14120 8987 + 18997 -408 + 16918 -8863 +-16615 -1001 +-19163 8521 + 14151 2220 + 20902 -8027 +-11717 -3241 +-22200 7441 + 9405 4071 + 23126 -6811 + -7278 -4722 +-23754 6177 + 5384 5213 + 24153 -5571 + -3755 -5566 +-24386 5013 + 2409 5801 + 24506 -4521 + -1356 -5939 +-24557 4104 + 603 5999 + 24573 -3765 + -151 -5994 +-24575 3508 + 0 5937 + 24575 -3331 + -151 -5835 +-24573 3232 + 603 5694 + 24557 -3205 + -1356 -5517 +-24506 3244 + 2409 5303 + 24386 -3343 + -3755 -5049 +-24153 3494 + 5384 4752 + 23754 -3685 + -7278 -4407 +-23126 3906 + 9405 4007 + 22200 -4143 +-11717 -3547 +-20902 4380 + 14151 3025 + 19163 -4598 +-16615 -2434 +-16918 4778 + 18997 1780 + 14120 -4898 +-21156 -1066 +-10745 4934 + 22929 304 + 6808 -4862 +-24132 489 + -2371 4664 + 24575 -1288 + -2446 -4320 +-24073 2060 + 7458 3820 + 22467 -2767 +-12407 -3162 +-19649 3365 + 16973 2357 + 15590 -3808 +-20783 -1429 +-10371 4050 + 23439 419 + 4201 -4055 +-24560 616 + 2559 3795 + 23830 -1607 + -9405 -3266 +-21059 2473 + 15707 2486 + 16251 -3130 +-20762 -1499 + -9648 3505 + 23875 386 + 1770 -3539 +-24457 754 + 6591 3205 + 22151 -1798 +-14427 -2518 +-16946 2618 + 20620 1540 + 9265 -3101 +-24110 -381 + 0 3162 + 24096 -809 + -9544 -2775 +-20243 1859 + 17799 1978 + 12860 -2598 +-23189 -879 + -2971 2893 + 24457 -344 + -7745 -2674 +-21001 1478 + 17190 1966 + 13148 -2304 +-23251 -890 + -2259 2647 + 24304 -341 + -9405 -2421 +-19717 1467 + 19092 1662 + 10200 -2229 +-24213 -535 + 2146 2434 + 23087 -692 +-14181 -2022 +-15590 1706 + 22482 1090 + 3457 -2230 +-24347 115 + 9959 2111 + 18780 -1251 +-20517 -1374 + -7098 1975 + 24575 238 + -7170 -2057 +-20349 938 + 19210 1464 + 8845 -1763 +-24531 -392 + 6117 1949 + 20742 -783 +-18997 -1425 + -8809 1630 + 24553 385 + -6881 -1825 +-20092 770 + 19939 1291 + 6989 -1572 +-24544 -244 + 9405 1688 + 18184 -869 +-21744 -1069 + -3270 1559 + 23978 -7 +-13433 -1511 +-14518 1041 + 23695 753 + -2409 -1536 +-21934 344 + 18310 1251 + 8527 -1225 +-24568 -337 + 9717 1436 + 17270 -719 +-22719 -869 + 0 1342 + 22690 -157 +-17484 -1188 + -9090 1051 + 24568 353 +-10268 -1293 +-16392 658 + 23347 745 + -2409 -1224 +-21364 244 + 19828 996 + 5053 -1036 +-23978 -132 + 14911 1114 + 11451 -783 +-24547 -437 + 9405 1124 + 16476 -513 +-23560 -661 + 3941 1058 + 20092 -257 +-21548 -807 + -1055 945 + 22452 -37 +-18997 -887 + -5348 815 + 23802 142 +-16307 -917 + -8845 682 + 24421 276 +-13778 -913 +-11551 563 + 24575 371 +-11618 -888 +-13528 463 + 24488 431 + -9959 -854 +-14851 386 + 24331 462 + -8880 -815 +-15590 333 + 24220 471 + -8421 -779 +-15793 302 + 24213 460 + -8598 -746 +-15474 292 + 24315 433 + -9405 -717 +-14609 300 + 24471 391 +-10813 -689 +-13148 324 + 24574 336 +-12763 -660 +-11016 359 + 24457 267 +-15149 -627 + -8137 400 + 23902 184 +-17799 -584 + -4461 444 + 22646 90 +-20454 -527 + 0 483 + 20413 -15 +-22762 -452 + 5127 511 + 16946 -124 +-24269 -357 + 10643 517 + 12080 -232 +-24457 -241 + 16080 495 + 5825 -328 +-22804 -107 + 20762 440 + -1545 -400 +-18901 35 + 23848 347 + -9405 -437 +-12602 173 + 24442 220 +-16754 -426 + -4201 290 + 21797 69 +-22280 -362 + 5421 366 + 15590 -89 +-24569 -247 + 14760 384 + 6227 -228 +-22467 -95 + 21831 335 + -4942 -321 +-15561 71 + 24575 222 +-15619 -344 + -4646 214 + 21511 65 +-22929 -288 + 8030 300 + 12505 -102 +-24207 -162 + 18997 304 + -641 -232 +-18107 4 + 24430 218 +-14151 -286 + -5642 160 + 21602 68 +-23151 -244 + 9405 253 + 10473 -97 +-23473 -115 + 21251 247 + -5384 -216 +-13872 49 + 24287 142 +-19397 -238 + 2409 183 + 16023 -17 +-24538 -153 + 18031 224 + -603 -158 +-17136 0 + 24575 153 +-17404 -209 + 0 142 + 17351 6 +-24575 -144 + 17616 196 + -603 -133 +-16698 -1 + 24538 131 +-18633 -182 + 2409 132 + 15090 -11 +-24287 -111 + 20286 169 + -5384 -134 +-12342 30 + 23473 86 +-22232 -152 + 9405 138 + 8244 -53 +-21602 -56 + 23919 132 +-14151 -138 + -2671 76 + 18107 21 +-24567 -104 + 18997 134 + -4239 -98 +-12505 16 + 23226 69 +-22929 -119 + 11883 111 + 4646 -53 +-18973 -28 + 24575 92 +-19021 -113 + 4942 82 + 11284 -16 +-22467 -54 + 23773 97 +-14760 -97 + -565 56 + 15590 8 +-23970 -65 + 22280 93 +-11351 -82 + -4201 37 + 17979 21 +-24442 -67 + 21098 85 + -9405 -69 + -5935 26 + 18901 24 +-24527 -64 + 20762 77 + -9160 -61 + -5825 23 + 18584 21 +-24457 -56 + 21401 69 +-10643 -57 + -3867 25 + 16946 15 +-24035 -47 + 22762 62 +-13685 -55 + 0 29 + 13622 4 +-22646 -35 + 24167 53 +-17799 -52 + 5715 36 + 8137 -8 +-19351 -21 + 24457 41 +-21968 -49 + 12763 41 + 264 -21 +-13148 -4 + 22069 27 +-24471 -40 + 19761 42 + -9405 -31 + -3569 12 + 15474 9 +-23022 -27 + 24213 36 +-18828 -35 + 8421 25 + 4164 -9 +-15590 -9 + 22915 23 +-24331 -31 + 19581 31 + -9959 -23 + -2071 10 + 13528 5 +-21656 -18 + 24575 26 +-21691 -27 + 13778 22 + -2746 -12 + -8845 0 + 18385 11 +-23802 -20 + 23986 23 +-18997 -22 + 9993 15 + 1055 -7 +-11817 -3 + 20092 11 +-24257 -17 + 23560 19 +-18234 -17 + 9405 12 + 1168 -5 +-11451 -3 + 19535 10 +-23978 -14 + 24050 16 +-19828 -14 + 12146 11 + -2409 -5 + -7673 0 + 16392 6 +-22327 -10 + 24568 12 +-22832 -12 + 17484 11 + -9439 -7 + 0 3 + 9370 2 +-17270 -5 + 22573 8 +-24568 -9 + 23048 10 +-18310 -8 + 11083 5 + -2409 -3 + -6518 -1 + 14518 3 +-20579 -5 + 23978 7 +-24357 -7 + 21744 7 +-16532 -6 + 9405 3 + -1244 -1 + -6989 -1 + 14366 3 +-20092 -4 + 23592 5 +-24553 -5 + 22942 5 +-18997 -4 + 13180 3 + -6117 -2 + -1469 1 + 8845 2 +-15327 -2 + 20349 3 +-23506 -4 + 24575 3 +-23528 -4 + 20517 3 +-15851 -2 + 9959 1 + -3345 0 + -3457 0 + 9924 1 +-15590 -2 + 20071 2 +-23087 -2 + 24481 3 +-24213 -2 + 22359 2 +-19092 -1 + 14670 1 + -9405 0 + 3643 0 + 2259 0 + -7959 -1 + 13148 1 +-17563 -1 + 21001 1 +-23323 -1 + 24457 1 +-24395 -1 + 23189 1 +-20942 -1 + 17799 1 +-13934 0 + 9544 0 + -4831 0 + 0 0 + 4757 1 + -9265 0 + 13370 0 +-16946 -1 + 19895 0 +-22151 -1 + 23675 0 +-24457 -1 + 24511 0 +-23875 0 + 22602 0 +-20762 0 + 18435 0 +-15707 0 + 12667 0 + -9405 0 + 6008 0 + -2559 0 + -867 0 + 4201 0 + -7386 0 + 10371 0 +-13116 0 + 15590 0 +-17773 0 + 19649 0 +-21213 0 + 22467 0 +-23416 0 + 24073 0 +-24453 0 + 24575 0 +-24461 0 + 24132 0 +-23613 0 + 22929 0 +-22102 0 + 21156 0 +-20114 0 + 18997 0 +-17825 0 + 16615 0 +-15385 0 + 14151 0 +-12924 0 + 11717 0 +-10541 0 + 9405 0 + -8315 0 + 7278 0 + -6300 0 + 5384 0 + -4535 0 + 3755 0 + -3046 0 + 2409 0 + -1845 0 + 1356 0 + -942 0 + 603 0 + -339 0 + 151 0 + -38 0 From 567a32b5b26dcc9c27e2c5ecb9c6c60d65b0e78d Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Mon, 4 Jul 2011 11:44:59 -0400 Subject: [PATCH 297/780] x86_32: Fix build on x86_32 with --disable-yasm. Signed-off-by: Ronald S. Bultje --- libavcodec/x86/h264_qpel_mmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/x86/h264_qpel_mmx.c b/libavcodec/x86/h264_qpel_mmx.c index c313c0e079..91ba39f1da 100644 --- a/libavcodec/x86/h264_qpel_mmx.c +++ b/libavcodec/x86/h264_qpel_mmx.c @@ -1294,6 +1294,6 @@ QPEL16_OP(mc31, MMX)\ QPEL16_OP(mc32, MMX)\ QPEL16_OP(mc33, MMX) -#if ARCH_X86_32 // ARCH_X86_64 implies sse2+ +#if ARCH_X86_32 && HAVE_YASM // ARCH_X86_64 implies sse2+ QPEL16(mmxext) #endif From 3c7c16fde3c2b758bb3c9f038c9a7d3461664f98 Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Mon, 4 Jul 2011 11:53:21 -0400 Subject: [PATCH 298/780] YASM: Shut up unused variable compiler warning with --disable-yasm. Signed-off-by: Diego Biurrun --- libavcodec/x86/dsputil_mmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index cfec97c8af..7842370fcd 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2660,8 +2660,8 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmx2, ); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmx2, ); } -#if HAVE_YASM else if (bit_depth == 10) { +#if HAVE_YASM #if !ARCH_X86_64 SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 10_mmxext, ff_); SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_mmxext, ff_); @@ -2670,8 +2670,8 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) #endif SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 10_mmxext, ff_); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 10_mmxext, ff_); - } #endif + } SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmx2, ); SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmx2, ); From 49c7006c7e815d4330247624a9e6ba30e288cd02 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Mon, 4 Jul 2011 09:55:19 -0700 Subject: [PATCH 299/780] dca: set AVCodecContext frame_size for DTS audio Set the frame size when decoding DTS audio. This has the side effect of fixing the computation of timestamps for DTS-HD in compute_pkt_fields. Since frame_size is not currently set, the duration of a frame is being guessed based on the streams bitrate. But for DTS-HD, the bitrate currently used is the rate of the DTS core which is much different than the whole DTS-HD stream and leads to a wildly inaccurate frame duration estimate. Signed-off-by: Ronald S. Bultje --- libavcodec/dca.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/dca.c b/libavcodec/dca.c index e87a9e3ed4..58f3420586 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -1650,6 +1650,7 @@ static int dca_decode_frame(AVCodecContext * avctx, //set AVCodec values with parsed data avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate; + avctx->frame_size = s->sample_blocks * 32; s->profile = FF_PROFILE_DTS; From 240c5d6f3b2d676888a873b0e5c1dc82a2493c65 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 4 Jul 2011 18:08:02 +0100 Subject: [PATCH 300/780] fate: test more FFT etc sizes This tests sizes from 16 to 4096, not only the default 512. Signed-off-by: Mans Rullgard --- tests/fate/fft.mak | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/tests/fate/fft.mak b/tests/fate/fft.mak index 042a7bf322..feb47afe00 100644 --- a/tests/fate/fft.mak +++ b/tests/fate/fft.mak @@ -1,28 +1,36 @@ -FATE_FFT = fate-fft fate-ifft \ - fate-mdct fate-imdct \ - fate-rdft fate-irdft \ - fate-dct1d fate-idct1d +define DEF_FFT +FATE_FFT += fate-fft-$(1) fate-ifft-$(1) \ + fate-mdct-$(1) fate-imdct-$(1) \ + fate-rdft-$(1) fate-irdft-$(1) \ + fate-dct1d-$(1) fate-idct1d-$(1) -fate-fft: CMD = run libavcodec/fft-test -fate-ifft: CMD = run libavcodec/fft-test -i -fate-mdct: CMD = run libavcodec/fft-test -m -fate-imdct: CMD = run libavcodec/fft-test -m -i -fate-rdft: CMD = run libavcodec/fft-test -r -fate-irdft: CMD = run libavcodec/fft-test -r -i -fate-dct1d: CMD = run libavcodec/fft-test -d -fate-idct1d: CMD = run libavcodec/fft-test -d -i +fate-fft-$(N): CMD = run libavcodec/fft-test -n$(1) +fate-ifft-$(N): CMD = run libavcodec/fft-test -n$(1) -i +fate-mdct-$(N): CMD = run libavcodec/fft-test -n$(1) -m +fate-imdct-$(N): CMD = run libavcodec/fft-test -n$(1) -m -i +fate-rdft-$(N): CMD = run libavcodec/fft-test -n$(1) -r +fate-irdft-$(N): CMD = run libavcodec/fft-test -n$(1) -r -i +fate-dct1d-$(N): CMD = run libavcodec/fft-test -n$(1) -d +fate-idct1d-$(N): CMD = run libavcodec/fft-test -n$(1) -d -i +endef + +$(foreach N, 4 5 6 7 8 9 10 11 12, $(eval $(call DEF_FFT,$(N)))) fate-fft-test: $(FATE_FFT) $(FATE_FFT): libavcodec/fft-test$(EXESUF) $(FATE_FFT): REF = /dev/null -FATE_FFT_FIXED = fate-fft-fixed fate-ifft-fixed \ - fate-mdct-fixed fate-imdct-fixed +define DEF_FFT_FIXED +FATE_FFT_FIXED += fate-fft-fixed-$(1) fate-ifft-fixed-$(1) \ + fate-mdct-fixed-$(1) fate-imdct-fixed-$(1) -fate-fft-fixed: CMD = run libavcodec/fft-fixed-test -fate-ifft-fixed: CMD = run libavcodec/fft-fixed-test -i -fate-mdct-fixed: CMD = run libavcodec/fft-fixed-test -m -fate-imdct-fixed: CMD = run libavcodec/fft-fixed-test -m -i +fate-fft-fixed-$(1): CMD = run libavcodec/fft-fixed-test -n$(1) +fate-ifft-fixed-$(1): CMD = run libavcodec/fft-fixed-test -n$(1) -i +fate-mdct-fixed-$(1): CMD = run libavcodec/fft-fixed-test -n$(1) -m +fate-imdct-fixed-$(1): CMD = run libavcodec/fft-fixed-test -n$(1) -m -i +endef + +$(foreach N, 4 5 6 7 8 9 10 11 12, $(eval $(call DEF_FFT_FIXED,$(N)))) fate-fft-fixed-test: $(FATE_FFT_FIXED) $(FATE_FFT_FIXED): libavcodec/fft-fixed-test$(EXESUF) From 3824ef08e0878aa9f100f33ef22b61daf68058c2 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 4 Jul 2011 20:36:35 +0100 Subject: [PATCH 301/780] ARM: allow unaligned buffer in fixed-point NEON FFT4 This function is called with only 8-byte alignment from imdct for size 16. The fft4 function is not called for the larger FFT or MDCT sizes, so this has no impact on typical uses. Signed-off-by: Mans Rullgard --- libavcodec/arm/fft_fixed_neon.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/arm/fft_fixed_neon.S b/libavcodec/arm/fft_fixed_neon.S index 14884d3736..2cfd817fc9 100644 --- a/libavcodec/arm/fft_fixed_neon.S +++ b/libavcodec/arm/fft_fixed_neon.S @@ -75,9 +75,9 @@ .endm function fft4_neon - vld1.16 {d0-d1}, [r0,:128] + vld1.16 {d0-d1}, [r0] fft4 d0, d1, d2, d3 - vst1.16 {d0-d1}, [r0,:128] + vst1.16 {d0-d1}, [r0] bx lr endfunc From e6d88f63a805be3a866fe76f7453e8da71bc2e00 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Mon, 4 Jul 2011 20:43:37 +0200 Subject: [PATCH 302/780] libavfilter: add a default to silence a warning. --- libavfilter/avfilter.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 704b77d3e4..226d7beacb 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -162,6 +162,7 @@ static inline void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilt switch (src->type) { case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break; case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break; + default: break; } } From 16a565d0cbb7e753f594236c60bbcc66657024f6 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 5 Jul 2011 10:46:11 +0200 Subject: [PATCH 303/780] eval/fate: try to fix nan printing format failures. Signed-off-by: Michael Niedermayer --- libavutil/eval.c | 6 +++++- tests/ref/fate/eval | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libavutil/eval.c b/libavutil/eval.c index 066bf7bab5..3833ca87f2 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -659,7 +659,11 @@ int main(int argc, char **argv) av_expr_parse_and_eval(&d, *expr, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, NULL); - printf("'%s' -> %f\n\n", *expr, d); + if(isnan(d)){ + printf("'%s' -> nan\n\n", *expr); + }else{ + printf("'%s' -> %f\n\n", *expr, d); + } } av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", diff --git a/tests/ref/fate/eval b/tests/ref/fate/eval index 278c282344..7042a017fd 100644 --- a/tests/ref/fate/eval +++ b/tests/ref/fate/eval @@ -134,7 +134,7 @@ Evaluating 'sqrt(1764)' 'sqrt(1764)' -> 42.000000 Evaluating 'sqrt(-1)' -'sqrt(-1)' -> -nan +'sqrt(-1)' -> nan Evaluating 'not(1)' 'not(1)' -> 0.000000 @@ -155,7 +155,7 @@ Evaluating 'PI^1.23' 'PI^1.23' -> 4.087844 Evaluating 'pow(-1,1.23)' -'pow(-1,1.23)' -> -nan +'pow(-1,1.23)' -> nan 12.700000 == 12.7 0.931323 == 0.931322575 From 965dbe09b01c45eaf5d6dacde4bf03267751ebc9 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 5 Jul 2011 02:34:28 +0200 Subject: [PATCH 304/780] configure: simplify -rpath-link linker flag Lists of ':'-separated directories can be passed to -rpath-link directly. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index e315afa1cb..e77340f74a 100755 --- a/configure +++ b/configure @@ -2958,7 +2958,7 @@ enabled extra_warnings && check_cflags -Winline # add some linker flags check_ldflags -Wl,--warn-common -check_ldflags -Wl,-rpath-link,libpostproc -Wl,-rpath-link,libswscale -Wl,-rpath-link,libavfilter -Wl,-rpath-link,libavdevice -Wl,-rpath-link,libavformat -Wl,-rpath-link,libavcodec -Wl,-rpath-link,libavutil +check_ldflags -Wl,-rpath-link=libpostproc:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic echo "X{};" > $TMPV From 65614321db88fc52100db9d7ca1a3e1eee762729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Tue, 5 Jul 2011 10:30:48 +0200 Subject: [PATCH 305/780] dv: fix comment spelling Signed-off-by: Diego Biurrun --- libavcodec/dv.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 4fde2a7899..fd33998aed 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -370,7 +370,6 @@ typedef struct BlockInfo { /* bit budget for AC only in 5 MBs */ static const int vs_total_ac_bits = (100 * 4 + 68*2) * 5; -/* see dv_88_areas and dv_248_areas for details */ static const int mb_area_start[5] = { 1, 6, 21, 43, 64 }; static inline int put_bits_left(PutBitContext* s) @@ -378,7 +377,7 @@ static inline int put_bits_left(PutBitContext* s) return (s->buf_end - s->buf) * 8 - put_bits_count(s); } -/* decode ac coefficients */ +/* decode AC coefficients */ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) { int last_index = gb->size_in_bits; @@ -391,7 +390,7 @@ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) OPEN_READER(re, gb); UPDATE_CACHE(re, gb); - /* if we must parse a partial vlc, we do it here */ + /* if we must parse a partial VLC, we do it here */ if (partial_bit_count > 0) { re_cache = ((unsigned)re_cache >> partial_bit_count) | (mb->partial_bit_buffer << (sizeof(re_cache) * 8 - partial_bit_count)); @@ -486,7 +485,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock)); - /* pass 1 : read DC and AC coefficients in blocks */ + /* pass 1: read DC and AC coefficients in blocks */ buf_ptr = &s->buf[work_chunk->buf_offset*80]; block1 = &sblock[0][0]; mb1 = mb_data; @@ -503,7 +502,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) last_index = s->sys->block_sizes[j]; init_get_bits(&gb, buf_ptr, last_index); - /* get the dc */ + /* get the DC */ dc = get_sbits(&gb, 9); dct_mode = get_bits1(&gb); class1 = get_bits(&gb, 2); @@ -530,7 +529,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) av_dlog(avctx, "MB block: %d, %d ", mb_index, j); dv_decode_ac(&gb, mb, block); - /* write the remaining bits in a new buffer only if the + /* write the remaining bits in a new buffer only if the block is finished */ if (mb->pos >= 64) bit_copy(&pb, &gb); @@ -539,7 +538,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) mb++; } - /* pass 2 : we can do it just after */ + /* pass 2: we can do it just after */ av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); block = block1; mb = mb1; @@ -559,7 +558,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) bit_copy(&vs_pb, &gb); } - /* we need a pass other the whole video segment */ + /* we need a pass over the whole video segment */ av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb)); block = &sblock[0][0]; mb = mb_data; @@ -640,7 +639,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) } #if CONFIG_SMALL -/* Converts run and level (where level != 0) pair into vlc, returning bit size */ +/* Converts run and level (where level != 0) pair into VLC, returning bit size */ static av_always_inline int dv_rl2vlc(int run, int level, int sign, uint32_t* vlc) { int size; @@ -817,7 +816,7 @@ static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, i if (level + 15 > 30U) { bi->sign[i] = (level >> 31) & 1; - /* weigh it and and shift down into range, adding for rounding */ + /* weight it and and shift down into range, adding for rounding */ /* the extra division by a factor of 2^4 reverses the 8x expansion of the DCT AND the 2x doubling of the weights */ level = (FFABS(level) * weight[i] + (1 << (dv_weight_bits+3))) >> (dv_weight_bits+4); From 6cbf2420b95db9c65921c2f1c23105b9f7998338 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 5 Jul 2011 15:53:05 +0100 Subject: [PATCH 306/780] PPC: use Altivec IMDCT only for supported sizes The Altivec IMDCT works with size 32 and higher only. Signed-off-by: Mans Rullgard --- libavcodec/ppc/fft_altivec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/ppc/fft_altivec.c b/libavcodec/ppc/fft_altivec.c index 435024a0cb..39830b29a0 100644 --- a/libavcodec/ppc/fft_altivec.c +++ b/libavcodec/ppc/fft_altivec.c @@ -141,7 +141,9 @@ av_cold void ff_fft_init_altivec(FFTContext *s) { #if HAVE_GNU_AS s->fft_calc = ff_fft_calc_interleave_altivec; - s->imdct_calc = ff_imdct_calc_altivec; - s->imdct_half = ff_imdct_half_altivec; + if (s->mdct_bits >= 5) { + s->imdct_calc = ff_imdct_calc_altivec; + s->imdct_half = ff_imdct_half_altivec; + } #endif } From 4d5e7ab5c48451404038706ef3113c9925a83087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Mon, 4 Jul 2011 10:19:46 +0200 Subject: [PATCH 307/780] mxfenc: fix ignored drop flag in binary timecode representation. Signed-off-by: Ronald S. Bultje --- libavformat/mxfenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index c87f2334ba..16fa0dadd1 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1539,7 +1539,7 @@ static const uint8_t system_metadata_package_set_key[] = { 0x06,0x0E,0x2B,0x34,0 static uint32_t ff_framenum_to_12m_time_code(unsigned frame, int drop, int fps) { return (0 << 31) | // color frame flag - (0 << 30) | // drop frame flag + (drop << 30) | // drop frame flag ( ((frame % fps) / 10) << 28) | // tens of frames ( ((frame % fps) % 10) << 24) | // units of frames (0 << 23) | // field phase (NTSC), b0 (PAL) From 68e39d6efeacbf95144e3fd47b34fc79f907df3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Tue, 5 Jul 2011 16:02:56 +0200 Subject: [PATCH 308/780] dv: fix valgrind use of uninitialised value warnings. Signed-off-by: Ronald S. Bultje --- libavcodec/dv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index fd33998aed..e5cade5033 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -475,8 +475,8 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) GetBitContext gb; BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]); - LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 4]); /* allow some slack */ - LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5 * 80 + 4]); /* allow some slack */ + LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [ 80 + FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ + LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5*80 + FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ const int log2_blocksize = 3-s->avctx->lowres; int is_field_mode[5]; @@ -543,6 +543,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) block = block1; mb = mb1; init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb)); + put_bits32(&pb, 0); // padding must be zero'ed flush_put_bits(&pb); for (j = 0; j < s->sys->bpm; j++, block += 64, mb++) { if (mb->pos < 64 && get_bits_left(&gb) > 0) { @@ -563,6 +564,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) block = &sblock[0][0]; mb = mb_data; init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb)); + put_bits32(&vs_pb, 0); // padding must be zero'ed flush_put_bits(&vs_pb); for (mb_index = 0; mb_index < 5; mb_index++) { for (j = 0; j < s->sys->bpm; j++) { From 50f8c26579f4c88ad2a4c1460cdf05459ee7993d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Tue, 5 Jul 2011 10:30:48 +0200 Subject: [PATCH 309/780] dv: fix comment spelling. --- libavcodec/dv.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index d6c49c86cb..b6f7852d7a 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -370,7 +370,6 @@ typedef struct BlockInfo { /* bit budget for AC only in 5 MBs */ static const int vs_total_ac_bits = (100 * 4 + 68*2) * 5; -/* see dv_88_areas and dv_248_areas for details */ static const int mb_area_start[5] = { 1, 6, 21, 43, 64 }; static inline int put_bits_left(PutBitContext* s) @@ -378,7 +377,7 @@ static inline int put_bits_left(PutBitContext* s) return (s->buf_end - s->buf) * 8 - put_bits_count(s); } -/* decode ac coefficients */ +/* decode AC coefficients */ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) { int last_index = gb->size_in_bits; @@ -391,7 +390,7 @@ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) OPEN_READER(re, gb); UPDATE_CACHE(re, gb); - /* if we must parse a partial vlc, we do it here */ + /* if we must parse a partial VLC, we do it here */ if (partial_bit_count > 0) { re_cache = ((unsigned)re_cache >> partial_bit_count) | (mb->partial_bit_buffer << (sizeof(re_cache) * 8 - partial_bit_count)); @@ -486,7 +485,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock)); - /* pass 1 : read DC and AC coefficients in blocks */ + /* pass 1: read DC and AC coefficients in blocks */ buf_ptr = &s->buf[work_chunk->buf_offset*80]; block1 = &sblock[0][0]; mb1 = mb_data; @@ -503,7 +502,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) last_index = s->sys->block_sizes[j]; init_get_bits(&gb, buf_ptr, last_index); - /* get the dc */ + /* get the DC */ dc = get_sbits(&gb, 9); dct_mode = get_bits1(&gb); class1 = get_bits(&gb, 2); @@ -530,7 +529,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) av_dlog(avctx, "MB block: %d, %d ", mb_index, j); dv_decode_ac(&gb, mb, block); - /* write the remaining bits in a new buffer only if the + /* write the remaining bits in a new buffer only if the block is finished */ if (mb->pos >= 64) bit_copy(&pb, &gb); @@ -539,7 +538,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) mb++; } - /* pass 2 : we can do it just after */ + /* pass 2: we can do it just after */ av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); block = block1; mb = mb1; @@ -559,7 +558,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) bit_copy(&vs_pb, &gb); } - /* we need a pass other the whole video segment */ + /* we need a pass over the whole video segment */ av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb)); block = &sblock[0][0]; mb = mb_data; @@ -640,7 +639,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) } #if CONFIG_SMALL -/* Converts run and level (where level != 0) pair into vlc, returning bit size */ +/* Converts run and level (where level != 0) pair into VLC, returning bit size */ static av_always_inline int dv_rl2vlc(int run, int level, int sign, uint32_t* vlc) { int size; @@ -817,7 +816,7 @@ static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, i if (level + 15 > 30U) { bi->sign[i] = (level >> 31) & 1; - /* weigh it and and shift down into range, adding for rounding */ + /* weight it and and shift down into range, adding for rounding */ /* the extra division by a factor of 2^4 reverses the 8x expansion of the DCT AND the 2x doubling of the weights */ level = (FFABS(level) * weight[i] + (1 << (dv_weight_bits+3))) >> (dv_weight_bits+4); From afd06c68734e251a616fa53abdcf864e31c302e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Tue, 5 Jul 2011 16:02:56 +0200 Subject: [PATCH 310/780] dv: fix valgrind use of uninitialised value warnings. --- libavcodec/dv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index b6f7852d7a..2dc03734f6 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -475,8 +475,8 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) GetBitContext gb; BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]); - LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 4]); /* allow some slack */ - LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5 * 80 + 4]); /* allow some slack */ + LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [ 80 + FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ + LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5*80 + FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ const int log2_blocksize = 3-s->avctx->lowres; int is_field_mode[5]; @@ -543,6 +543,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) block = block1; mb = mb1; init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb)); + put_bits32(&pb, 0); // padding must be zero'ed flush_put_bits(&pb); for (j = 0; j < s->sys->bpm; j++, block += 64, mb++) { if (mb->pos < 64 && get_bits_left(&gb) > 0) { @@ -563,6 +564,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) block = &sblock[0][0]; mb = mb_data; init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb)); + put_bits32(&vs_pb, 0); // padding must be zero'ed flush_put_bits(&vs_pb); for (mb_index = 0; mb_index < 5; mb_index++) { for (j = 0; j < s->sys->bpm; j++) { From 76f105967bb5340754ee693658ad87199682fe1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Mon, 4 Jul 2011 10:19:46 +0200 Subject: [PATCH 311/780] mxfenc: fix ignored drop flag in binary timecode representation. --- libavformat/mxfenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 9b5b4b7455..d44e7676d6 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1539,7 +1539,7 @@ static const uint8_t system_metadata_package_set_key[] = { 0x06,0x0E,0x2B,0x34,0 static uint32_t ff_framenum_to_12m_time_code(unsigned frame, int drop, int fps) { return (0 << 31) | // color frame flag - (0 << 30) | // drop frame flag + (drop << 30) | // drop frame flag ( ((frame % fps) / 10) << 28) | // tens of frames ( ((frame % fps) % 10) << 24) | // units of frames (0 << 23) | // field phase (NTSC), b0 (PAL) From f428c29c23931620eafe692bede0773f66fe17e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Tue, 5 Jul 2011 17:30:00 +0200 Subject: [PATCH 312/780] dv: fix comment wording mistake --- libavcodec/dv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 2dc03734f6..bfd5ae4413 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -543,7 +543,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) block = block1; mb = mb1; init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb)); - put_bits32(&pb, 0); // padding must be zero'ed + put_bits32(&pb, 0); // padding must be zeroed flush_put_bits(&pb); for (j = 0; j < s->sys->bpm; j++, block += 64, mb++) { if (mb->pos < 64 && get_bits_left(&gb) > 0) { @@ -564,7 +564,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) block = &sblock[0][0]; mb = mb_data; init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb)); - put_bits32(&vs_pb, 0); // padding must be zero'ed + put_bits32(&vs_pb, 0); // padding must be zeroed flush_put_bits(&vs_pb); for (mb_index = 0; mb_index < 5; mb_index++) { for (j = 0; j < s->sys->bpm; j++) { From c45f629576151f05ce7010967683385d277859fe Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 5 Jul 2011 17:33:24 +0200 Subject: [PATCH 313/780] Rename libavcodec/high_bit_depth.h ---> libavcodec/bit_depth_template.c This naming scheme is used elsewhere, so it's sensible to be consistent. --- libavcodec/{high_bit_depth.h => bit_depth_template.c} | 0 libavcodec/dsputil_template.c | 2 +- libavcodec/h264dsp_template.c | 2 +- libavcodec/h264idct_template.c | 2 +- libavcodec/h264pred_template.c | 3 ++- 5 files changed, 5 insertions(+), 4 deletions(-) rename libavcodec/{high_bit_depth.h => bit_depth_template.c} (100%) diff --git a/libavcodec/high_bit_depth.h b/libavcodec/bit_depth_template.c similarity index 100% rename from libavcodec/high_bit_depth.h rename to libavcodec/bit_depth_template.c diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index b85931856a..645a881a19 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -27,7 +27,7 @@ * DSP utils */ -#include "high_bit_depth.h" +#include "bit_depth_template.c" static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h) { diff --git a/libavcodec/h264dsp_template.c b/libavcodec/h264dsp_template.c index be88f7487f..d11eff0919 100644 --- a/libavcodec/h264dsp_template.c +++ b/libavcodec/h264dsp_template.c @@ -25,7 +25,7 @@ * @author Michael Niedermayer */ -#include "high_bit_depth.h" +#include "bit_depth_template.c" #define op_scale1(x) block[x] = av_clip_pixel( (block[x]*weight + offset) >> log2_denom ) #define op_scale2(x) dst[x] = av_clip_pixel( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1)) diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c index c024538db5..55c1d3a4d8 100644 --- a/libavcodec/h264idct_template.c +++ b/libavcodec/h264idct_template.c @@ -25,7 +25,7 @@ * @author Michael Niedermayer */ -#include "high_bit_depth.h" +#include "bit_depth_template.c" #ifndef AVCODEC_H264IDCT_INTERNAL_H #define AVCODEC_H264IDCT_INTERNAL_H diff --git a/libavcodec/h264pred_template.c b/libavcodec/h264pred_template.c index 1c1fe0bc31..e5d91555b8 100644 --- a/libavcodec/h264pred_template.c +++ b/libavcodec/h264pred_template.c @@ -26,7 +26,8 @@ */ #include "mathops.h" -#include "high_bit_depth.h" + +#include "bit_depth_template.c" static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; From 6d75fb01eb9d3cf72fff45aa757932cced3bcd4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Tue, 5 Jul 2011 17:30:00 +0200 Subject: [PATCH 314/780] dv: fix comment wording mistake --- libavcodec/dv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index e5cade5033..a35bb2f2ed 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -543,7 +543,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) block = block1; mb = mb1; init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb)); - put_bits32(&pb, 0); // padding must be zero'ed + put_bits32(&pb, 0); // padding must be zeroed flush_put_bits(&pb); for (j = 0; j < s->sys->bpm; j++, block += 64, mb++) { if (mb->pos < 64 && get_bits_left(&gb) > 0) { @@ -564,7 +564,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) block = &sblock[0][0]; mb = mb_data; init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb)); - put_bits32(&vs_pb, 0); // padding must be zero'ed + put_bits32(&vs_pb, 0); // padding must be zeroed flush_put_bits(&vs_pb); for (mb_index = 0; mb_index < 5; mb_index++) { for (j = 0; j < s->sys->bpm; j++) { From fce1e43410bdc032c4cf2b1c66166a9ed99cc8f1 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 5 Jul 2011 18:29:35 +0100 Subject: [PATCH 315/780] ARM: workaround for bug in GNU assembler Some versions of the GNU assembler do not handle 64-bit immediate operands containing arithmetic. Writing the value out in full works correctly. Signed-off-by: Mans Rullgard --- libavcodec/arm/fft_fixed_neon.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/arm/fft_fixed_neon.S b/libavcodec/arm/fft_fixed_neon.S index 2cfd817fc9..0508088590 100644 --- a/libavcodec/arm/fft_fixed_neon.S +++ b/libavcodec/arm/fft_fixed_neon.S @@ -56,7 +56,7 @@ vhsub.s16 \r0, \d0, \d1 @ t3, t4, t8, t7 vhsub.s16 \r1, \d1, \d0 vhadd.s16 \d0, \d0, \d1 @ t1, t2, t6, t5 - vmov.i64 \d1, #0xffff<<32 + vmov.i64 \d1, #0xffff00000000 vbit \r0, \r1, \d1 vrev64.16 \r1, \r0 @ t7, t8, t4, t3 vtrn.32 \r0, \r1 @ t3, t4, t7, t8 From 8dd52d82029febc3effd981c3107846904559c6d Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 15 Jun 2011 00:04:48 +0200 Subject: [PATCH 316/780] opencore-amr: Add missing initializer braces to shut up gcc warning. This fixes the warning: libavcodec/libopencore-amr.c:91: warning: missing braces around initializer --- libavcodec/libopencore-amr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index cf8bdbbcb8..edf372ffad 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -88,7 +88,7 @@ typedef struct AMRContext { } AMRContext; static const AVOption options[] = { - { "dtx", "Allow DTX (generate comfort noise)", offsetof(AMRContext, enc_dtx), FF_OPT_TYPE_INT, 0, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, + { "dtx", "Allow DTX (generate comfort noise)", offsetof(AMRContext, enc_dtx), FF_OPT_TYPE_INT, { 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, { NULL } }; From d3f751e6030545c5e1f312c5a83c1e6ed5794f18 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 5 Jul 2011 00:42:31 +0200 Subject: [PATCH 317/780] Add some missing mathematics.h #includes for av_rescale(). --- libavdevice/libdc1394.c | 1 + libavfilter/vf_frei0r.c | 1 + libavformat/flvdec.c | 1 + libavformat/librtmp.c | 1 + libavformat/mpegts.c | 1 + 5 files changed, 5 insertions(+) diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c index bf4e27e51b..e6161a1386 100644 --- a/libavdevice/libdc1394.c +++ b/libavdevice/libdc1394.c @@ -23,6 +23,7 @@ #include "config.h" #include "libavformat/avformat.h" #include "libavutil/log.h" +#include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c index 48683f4fea..455e24a7f1 100644 --- a/libavfilter/vf_frei0r.c +++ b/libavfilter/vf_frei0r.c @@ -28,6 +28,7 @@ #include #include "libavutil/avstring.h" #include "libavutil/imgutils.h" +#include "libavutil/mathematics.h" #include "libavutil/parseutils.h" #include "avfilter.h" diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 3b7db0e6ca..57eaa84696 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -27,6 +27,7 @@ #include "libavutil/avstring.h" #include "libavutil/dict.h" #include "libavutil/intfloat_readwrite.h" +#include "libavutil/mathematics.h" #include "libavcodec/bytestream.h" #include "libavcodec/mpeg4audio.h" #include "avformat.h" diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c index 30fe8a196b..6ccb66bd8c 100644 --- a/libavformat/librtmp.c +++ b/libavformat/librtmp.c @@ -24,6 +24,7 @@ * RTMP protocol based on http://rtmpdump.mplayerhq.hu/ librtmp */ +#include "libavutil/mathematics.h" #include "avformat.h" #include "url.h" diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index f2ae567789..43cd1fbd6f 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -25,6 +25,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/log.h" #include "libavutil/dict.h" +#include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "libavcodec/bytestream.h" #include "avformat.h" From a625e13208ad0ebf1554aa73c9bf41452520f176 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Tue, 5 Jul 2011 16:27:54 -0700 Subject: [PATCH 318/780] H.264: make loopfilter bS const where applicable --- libavcodec/h264_loopfilter.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index e6b6141f13..c7163472d3 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -100,7 +100,7 @@ static const uint8_t tc0_table[52*3][4] = { {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, }; -static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h) { +static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; @@ -118,7 +118,7 @@ static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, int16_t h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta); } } -static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) { +static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; @@ -137,7 +137,7 @@ static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, int16_t } } -static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) { +static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; int alpha = alpha_table[index_a]; @@ -155,7 +155,7 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta); } } -static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) { +static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; int alpha = alpha_table[index_a]; @@ -174,7 +174,7 @@ static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, in } } -static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) { +static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; @@ -193,7 +193,7 @@ static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, int16_t } } -static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) { +static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; @@ -247,9 +247,9 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, return; if( IS_INTRA(mb_type) ) { - int16_t bS4[4] = {4,4,4,4}; - int16_t bS3[4] = {3,3,3,3}; - int16_t *bSH = FIELD_PICTURE ? bS3 : bS4; + static const int16_t bS4[4] = {4,4,4,4}; + static const int16_t bS3[4] = {3,3,3,3}; + const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4; if(left_type) filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, h); if( IS_8x8DCT(mb_type) ) { From fe277b16f0861a327e1f6c00c0dbb8b00806d60d Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 5 Jul 2011 18:10:48 -0700 Subject: [PATCH 319/780] eval: fix memleak. --- libavutil/eval.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/eval.c b/libavutil/eval.c index 4d55f42664..9bc40c1edc 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -489,6 +489,7 @@ int av_expr_parse(AVExpr **expr, const char *s, if ((ret = parse_expr(&e, &p)) < 0) goto end; if (*p.s) { + av_expr_free(e); av_log(&p, AV_LOG_ERROR, "Invalid chars '%s' at the end of expression '%s'\n", p.s, s0); ret = AVERROR(EINVAL); goto end; From dfd8116986a30e312a27269fbac702e885e0e673 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 5 Jul 2011 18:11:32 -0700 Subject: [PATCH 320/780] eval: add missing comma to tests. --- libavutil/eval.c | 2 +- tests/ref/fate/eval | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libavutil/eval.c b/libavutil/eval.c index 9bc40c1edc..6d9b8e4208 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -559,7 +559,7 @@ int main(int argc, char **argv) "-PI", "+PI", "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", - "80G/80Gi" + "80G/80Gi", "1k", "1Gi", "1gi", diff --git a/tests/ref/fate/eval b/tests/ref/fate/eval index fb7a925b77..ad01891d9c 100644 --- a/tests/ref/fate/eval +++ b/tests/ref/fate/eval @@ -16,8 +16,11 @@ Evaluating '+PI' Evaluating '1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)' '1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)' -> 12.700000 -Evaluating '80G/80Gi1k' -'80G/80Gi1k' -> nan +Evaluating '80G/80Gi' +'80G/80Gi' -> 0.931323 + +Evaluating '1k' +'1k' -> 1000.000000 Evaluating '1Gi' '1Gi' -> 1073741824.000000 From f28aaae1c5e99eba51761d7c7cd0ae7e03232b54 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 5 Jul 2011 18:19:26 -0700 Subject: [PATCH 321/780] swscale: amend documentation to mention use of native depth for scaling. Signed-off-by: Diego Biurrun --- libswscale/swscale_internal.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 340227dc00..b3698a3d94 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -429,7 +429,10 @@ typedef struct SwsContext { * @param dstW width of destination image * @param src pointer to source data to be scaled. If scaling depth * is 8, this is 8bpp in 8bpp (uint8_t) width. If scaling - * depth is 16, this is 16bpp in 16bpp (uint16_t) depth. + * depth is 16, this is native depth in 16bbp (uint16_t) + * width. In other words, for 9-bit YUV input, this is + * 9bpp, for 10-bit YUV input, this is 10bpp, and for + * 16-bit RGB or YUV, this is 16bpp. * @param filter filter coefficients to be used per output pixel for * scaling. This contains 14bpp filtering coefficients. * Guaranteed to contain dstW * filterSize entries. From 923cff747a0f31b0e120e1899a4b807fb8137484 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 6 Jul 2011 10:04:02 +0200 Subject: [PATCH 322/780] Support extension jls for jpeg-ls. --- libavformat/img2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/img2.c b/libavformat/img2.c index b6082c68f8..ca391aa1bb 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -54,6 +54,7 @@ static const IdStrMap img_tags[] = { { CODEC_ID_MJPEG , "jpeg"}, { CODEC_ID_MJPEG , "jpg"}, { CODEC_ID_LJPEG , "ljpg"}, + { CODEC_ID_JPEGLS , "jls"}, { CODEC_ID_PNG , "png"}, { CODEC_ID_PNG , "mng"}, { CODEC_ID_PPM , "ppm"}, @@ -505,7 +506,7 @@ AVInputFormat ff_image2pipe_demuxer = { AVOutputFormat ff_image2_muxer = { .name = "image2", .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), - .extensions = "bmp,dpx,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png," + .extensions = "bmp,dpx,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png," "ppm,sgi,tga,tif,tiff,jp2", .priv_data_size = sizeof(VideoData), .video_codec = CODEC_ID_MJPEG, From 3950376b8baa6292f2f195dae43d7b00bcbf53e7 Mon Sep 17 00:00:00 2001 From: ami_stuff Date: Wed, 6 Jul 2011 10:05:08 +0200 Subject: [PATCH 323/780] Support fourcc YV24. Fixes ticket #306. --- libavcodec/raw.c | 1 + libavcodec/rawdec.c | 1 + libavformat/riff.c | 1 + 3 files changed, 3 insertions(+) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index d6867186ad..e87a9af2ba 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -137,6 +137,7 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { /* special */ { PIX_FMT_RGB565LE,MKTAG( 3 , 0 , 0 , 0 ) }, /* flipped RGB565LE */ + { PIX_FMT_YUV444P, MKTAG('Y', 'V', '2', '4') }, /* YUV444P, swapped UV */ { PIX_FMT_NONE, 0 }, }; diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index d48cbed3e7..177f08cb93 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -208,6 +208,7 @@ static int raw_decode(AVCodecContext *avctx, if ( avctx->codec_tag == MKTAG('Y', 'V', '1', '2') || avctx->codec_tag == MKTAG('Y', 'V', '1', '6') + || avctx->codec_tag == MKTAG('Y', 'V', '2', '4') || avctx->codec_tag == MKTAG('Y', 'V', 'U', '9')) FFSWAP(uint8_t *, picture->data[1], picture->data[2]); diff --git a/libavformat/riff.c b/libavformat/riff.c index 060eaa0728..2e00ae8963 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -173,6 +173,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_RAWVIDEO, MKTAG('P', '4', '2', '2') }, { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') }, { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '6') }, + { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '2', '4') }, { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') }, { CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') }, { CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') }, From cabc2938deef077a612bdf511580c2d9c810c322 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 00:21:43 +0200 Subject: [PATCH 324/780] flashsv: cosmetics: drop some unnecessary parentheses --- libavcodec/flashsv.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index a958bdaa53..13ae7f3f48 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -71,7 +71,7 @@ static void copy_region(uint8_t *sptr, uint8_t *dptr, int i; for (i = dx + h; i > dx; i--) { - memcpy(dptr + (i * stride) + dy * 3, sptr, w * 3); + memcpy(dptr + i * stride + dy * 3, sptr, w * 3); sptr += w * 3; } } @@ -86,7 +86,7 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx) s->zstream.zalloc = Z_NULL; s->zstream.zfree = Z_NULL; s->zstream.opaque = Z_NULL; - zret = inflateInit(&(s->zstream)); + zret = inflateInit(&s->zstream); if (zret != Z_OK) { av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); return 1; @@ -139,13 +139,13 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->block_size = s->block_width * s->block_height; /* init the image size once */ - if ((avctx->width == 0) && (avctx->height == 0)) { + if (avctx->width == 0 && avctx->height == 0) { avctx->width = s->image_width; avctx->height = s->image_height; } /* check for changes of image width and image height */ - if ((avctx->width != s->image_width) || (avctx->height != s->image_height)) { + if (avctx->width != s->image_width || avctx->height != s->image_height) { av_log(avctx, AV_LOG_ERROR, "Frame width or height differs from first frames!\n"); av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d vs ch = %d, cv = %d\n", avctx->height, avctx->width, s->image_height, s->image_width); @@ -187,23 +187,23 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* no change, don't do anything */ } else { /* decompress block */ - int ret = inflateReset(&(s->zstream)); + int ret = inflateReset(&s->zstream); if (ret != Z_OK) { av_log(avctx, AV_LOG_ERROR, "error in decompression (reset) of block %dx%d\n", i, j); /* return -1; */ } - s->zstream.next_in = buf + (get_bits_count(&gb) / 8); + s->zstream.next_in = buf + get_bits_count(&gb) / 8; s->zstream.avail_in = size; s->zstream.next_out = s->tmpblock; s->zstream.avail_out = s->block_size * 3; - ret = inflate(&(s->zstream), Z_FINISH); + ret = inflate(&s->zstream, Z_FINISH); if (ret == Z_DATA_ERROR) { av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n"); - inflateSync(&(s->zstream)); - ret = inflate(&(s->zstream), Z_FINISH); + inflateSync(&s->zstream); + ret = inflate(&s->zstream, Z_FINISH); } - if ((ret != Z_OK) && (ret != Z_STREAM_END)) { + if (ret != Z_OK && ret != Z_STREAM_END) { av_log(avctx, AV_LOG_ERROR, "error in decompression of block %dx%d: %d\n", i, j, ret); /* return -1; */ } @@ -229,7 +229,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, static av_cold int flashsv_decode_end(AVCodecContext *avctx) { FlashSVContext *s = avctx->priv_data; - inflateEnd(&(s->zstream)); + inflateEnd(&s->zstream); /* release the frame if needed */ if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); From 940230202a5cc80cef75a91cf9c063ae616e195d Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 00:25:35 +0200 Subject: [PATCH 325/780] flashsv: cosmetics: break some overly long lines --- libavcodec/flashsv.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 13ae7f3f48..8e17ac4535 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -146,18 +146,22 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* check for changes of image width and image height */ if (avctx->width != s->image_width || avctx->height != s->image_height) { - av_log(avctx, AV_LOG_ERROR, "Frame width or height differs from first frames!\n"); - av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d vs ch = %d, cv = %d\n", avctx->height, - avctx->width, s->image_height, s->image_width); + av_log(avctx, AV_LOG_ERROR, + "Frame width or height differs from first frames!\n"); + av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d vs ch = %d, cv = %d\n", + avctx->height, avctx->width, s->image_height, s->image_width); return -1; } - av_log(avctx, AV_LOG_DEBUG, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", + av_log(avctx, AV_LOG_DEBUG, + "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", s->image_width, s->image_height, s->block_width, s->block_height, h_blocks, v_blocks, h_part, v_part); s->frame.reference = 1; - s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; + s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | + FF_BUFFER_HINTS_PRESERVE | + FF_BUFFER_HINTS_REUSABLE; if (avctx->reget_buffer(avctx, &s->frame) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; @@ -189,7 +193,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* decompress block */ int ret = inflateReset(&s->zstream); if (ret != Z_OK) { - av_log(avctx, AV_LOG_ERROR, "error in decompression (reset) of block %dx%d\n", i, j); + av_log(avctx, AV_LOG_ERROR, + "error in decompression (reset) of block %dx%d\n", i, j); /* return -1; */ } s->zstream.next_in = buf + get_bits_count(&gb) / 8; @@ -204,10 +209,12 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, } if (ret != Z_OK && ret != Z_STREAM_END) { - av_log(avctx, AV_LOG_ERROR, "error in decompression of block %dx%d: %d\n", i, j, ret); + av_log(avctx, AV_LOG_ERROR, + "error in decompression of block %dx%d: %d\n", i, j, ret); /* return -1; */ } - copy_region(s->tmpblock, s->frame.data[0], s->image_height - (hp + hs + 1), + copy_region(s->tmpblock, s->frame.data[0], + s->image_height - (hp + hs + 1), wp, hs, ws, s->frame.linesize[0]); skip_bits_long(&gb, 8 * size); /* skip the consumed bits */ } From dbf5b95d35043ae3a24024d1db44d51bfa218704 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 00:28:08 +0200 Subject: [PATCH 326/780] flashsv: return more meaningful error values --- libavcodec/flashsv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 8e17ac4535..837a92243c 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -150,7 +150,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, "Frame width or height differs from first frames!\n"); av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d vs ch = %d, cv = %d\n", avctx->height, avctx->width, s->image_height, s->image_width); - return -1; + return AVERROR_INVALIDDATA; } av_log(avctx, AV_LOG_DEBUG, @@ -184,7 +184,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, if (8 * size > get_bits_left(&gb)) { avctx->release_buffer(avctx, &s->frame); s->frame.data[0] = NULL; - return -1; + return AVERROR_INVALIDDATA; } if (size == 0) { From 39884ab0356677c1673da1ebc3d906137cdeb8d2 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 01:00:30 +0200 Subject: [PATCH 327/780] flashsv: simplify condition --- libavcodec/flashsv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 837a92243c..37bff0a9ea 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -187,9 +187,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } - if (size == 0) { - /* no change, don't do anything */ - } else { + /* skip unchanged blocks, which have size 0 */ + if (size) { /* decompress block */ int ret = inflateReset(&s->zstream); if (ret != Z_OK) { From 9b576e4d124474272c2abeb322df3fd5602f00b8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 15:03:45 +0200 Subject: [PATCH 328/780] flashsv: convert a debug av_log into av_dlog --- libavcodec/flashsv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 37bff0a9ea..e3ddb74cee 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -153,10 +153,9 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } - av_log(avctx, AV_LOG_DEBUG, - "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", - s->image_width, s->image_height, s->block_width, s->block_height, - h_blocks, v_blocks, h_part, v_part); + av_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", + s->image_width, s->image_height, s->block_width, s->block_height, + h_blocks, v_blocks, h_part, v_part); s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | From bc35ab3f7d453e94df81c3145bdc77982f14ae9e Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 5 Jul 2011 19:25:10 +0200 Subject: [PATCH 329/780] flashsv: replace bitstream description by a link to the specification An official specification now exists and it is both more detailed and easier to understand than the incomplete notes available here. Also remove ideas on how to implement an encoder; these notes are already present in the encoder. --- libavcodec/flashsv.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index e3ddb74cee..4d8762c993 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -25,26 +25,10 @@ * Flash Screen Video decoder * @author Alex Beregszaszi * @author Benjamin Larsson - */ - -/* Bitstream description - * The picture is divided into blocks that are zlib compressed. * - * The decoder is fed complete frames, the frameheader contains: - * 4bits of block width - * 12bits of frame width - * 4bits of block height - * 12bits of frame height - * - * Directly after the header are the compressed blocks. The blocks - * have their compressed size represented with 16bits in the beginnig. - * If the size = 0 then the block is unchanged from the previous frame. - * All blocks are decompressed until the buffer is consumed. - * - * Encoding ideas, a basic encoder would just use a fixed block size. - * Block sizes can be multipels of 16, from 16 to 256. The blocks don't - * have to be quadratic. A brute force search with a set of diffrent - * block sizes should give a better result then to just use a fixed size. + * A description of the bitstream format for Flash Screen Video version 1/2 + * is part of the SWF File Format Specification (version 10), which can be + * downloaded from http://www.adobe.com/devnet/swf.html. */ #include From ecf026f1aa8ffe170b5b8c577cae56a405ebafc8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 15:07:36 +0200 Subject: [PATCH 330/780] flashsv: set reference frame type to full frame --- libavcodec/flashsv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 4d8762c993..e5c6a074f2 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -141,7 +141,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->image_width, s->image_height, s->block_width, s->block_height, h_blocks, v_blocks, h_part, v_part); - s->frame.reference = 1; + s->frame.reference = 3; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; From a082e68030d6515a418c86db9a2ec529a7ed3ec8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 20:45:22 +0200 Subject: [PATCH 331/780] flashsv: Eliminate redundant variable indirection. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As a positive side-effect, this gets rid of the following warning: libavcodec/flashsv.c:190:38: warning: assignment discards ‘const’ qualifier from pointer target type --- libavcodec/flashsv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index e5c6a074f2..8305378f94 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -85,7 +85,6 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx) static int flashsv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; FlashSVContext *s = avctx->priv_data; int h_blocks, v_blocks, h_part, v_part, i, j; @@ -97,7 +96,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, if (buf_size < 4) return -1; - init_get_bits(&gb, buf, buf_size * 8); + init_get_bits(&gb, avpkt->data, buf_size * 8); /* start to parse the bitstream */ s->block_width = 16 * (get_bits(&gb, 4) + 1); @@ -179,7 +178,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, "error in decompression (reset) of block %dx%d\n", i, j); /* return -1; */ } - s->zstream.next_in = buf + get_bits_count(&gb) / 8; + s->zstream.next_in = avpkt->data + get_bits_count(&gb) / 8; s->zstream.avail_in = size; s->zstream.next_out = s->tmpblock; s->zstream.avail_out = s->block_size * 3; From dc900310380ca77ad3398b93099cd211e3c53d65 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 15:05:24 +0200 Subject: [PATCH 332/780] flashsv: improve some comments and fix some wrong ones --- libavcodec/flashsv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 8305378f94..578e713157 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -104,7 +104,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->block_height = 16 * (get_bits(&gb, 4) + 1); s->image_height = get_bits(&gb, 12); - /* calculate amount of blocks and the size of the border blocks */ + /* calculate number of blocks and size of border (partial) blocks */ h_blocks = s->image_width / s->block_width; h_part = s->image_width % s->block_width; v_blocks = s->image_height / s->block_height; @@ -121,7 +121,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, } s->block_size = s->block_width * s->block_height; - /* init the image size once */ + /* initialize the image size once */ if (avctx->width == 0 && avctx->height == 0) { avctx->width = s->image_width; avctx->height = s->image_height; @@ -152,14 +152,14 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* loop over all block columns */ for (j = 0; j < v_blocks + (v_part ? 1 : 0); j++) { - int hp = j * s->block_height; // horiz position in frame - int hs = (j < v_blocks) ? s->block_height : v_part; // size of block + int hp = j * s->block_height; // vertical position in frame + int hs = (j < v_blocks) ? s->block_height : v_part; // block size /* loop over all block rows */ for (i = 0; i < h_blocks + (h_part ? 1 : 0); i++) { - int wp = i * s->block_width; // vert position in frame - int ws = (i < h_blocks) ? s->block_width : h_part; // size of block + int wp = i * s->block_width; // horizontal position in frame + int ws = (i < h_blocks) ? s->block_width : h_part; // block size /* get the size of the compressed zlib chunk */ int size = get_bits(&gb, 16); From 0fedf754b24331ae80a50816cd02ad0eba9beba4 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 26 Apr 2011 14:27:38 +0200 Subject: [PATCH 333/780] libpostproc: Remove disabled code. --- libpostproc/postprocess.c | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index dd50daf21e..ca6d85f4a0 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -246,7 +246,6 @@ static inline int isVertDC_C(uint8_t src[], int stride, PPContext *c) static inline int isHorizMinMaxOk_C(uint8_t src[], int stride, int QP) { int i; -#if 1 for(i=0; i<2; i++){ if((unsigned)(src[0] - src[5] + 2*QP) > 4*QP) return 0; src += stride; @@ -257,19 +256,11 @@ static inline int isHorizMinMaxOk_C(uint8_t src[], int stride, int QP) if((unsigned)(src[6] - src[3] + 2*QP) > 4*QP) return 0; src += stride; } -#else - for(i=0; i<8; i++){ - if((unsigned)(src[0] - src[7] + 2*QP) > 4*QP) return 0; - src += stride; - } -#endif return 1; } static inline int isVertMinMaxOk_C(uint8_t src[], int stride, int QP) { -#if 1 -#if 1 int x; src+= stride*4; for(x=0; x 4*QP) return 0; if((unsigned)(src[3+x + 6*stride] - src[3+x + 3*stride] + 2*QP) > 4*QP) return 0; } -#else - int x; - src+= stride*3; - for(x=0; x 4*QP) return 0; - } -#endif return 1; -#else - int x; - src+= stride*4; - for(x=0; xmax) max=v; - if(v 2*QP) return 0; - } - return 1; -#endif } static inline int horizClassify_C(uint8_t src[], int stride, PPContext *c) From df64da3b1ef0c7014135bce44e5f82becf81fe79 Mon Sep 17 00:00:00 2001 From: Kostya Date: Fri, 17 Jun 2011 07:28:58 +0000 Subject: [PATCH 334/780] bink: pass Bink version to audio decoder through extradata instead of codec_tag. This is needed because not all players (e.g. MPlayer) are able to distinguish two different Bink audio decoders when codec_tag is set. Signed-off-by: Anton Khirnov --- libavcodec/binkaudio.c | 2 +- libavformat/bink.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c index a05b0b56b2..9722bdff3e 100644 --- a/libavcodec/binkaudio.c +++ b/libavcodec/binkaudio.c @@ -90,7 +90,7 @@ static av_cold int decode_init(AVCodecContext *avctx) return -1; } - s->version_b = avctx->codec_tag == MKTAG('B','I','K','b'); + s->version_b = avctx->extradata && avctx->extradata[3] == 'b'; if (avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT) { // audio is already interleaved for the RDFT format variant diff --git a/libavformat/bink.c b/libavformat/bink.c index 76b457c21b..067673819a 100644 --- a/libavformat/bink.c +++ b/libavformat/bink.c @@ -134,13 +134,18 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; - ast->codec->codec_tag = vst->codec->codec_tag; + ast->codec->codec_tag = 0; ast->codec->sample_rate = avio_rl16(pb); av_set_pts_info(ast, 64, 1, ast->codec->sample_rate); flags = avio_rl16(pb); ast->codec->codec_id = flags & BINK_AUD_USEDCT ? CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT; ast->codec->channels = flags & BINK_AUD_STEREO ? 2 : 1; + ast->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE); + if (!ast->codec->extradata) + return AVERROR(ENOMEM); + ast->codec->extradata_size = 4; + AV_WL32(ast->codec->extradata, vst->codec->codec_tag); } for (i = 0; i < bink->num_audio_tracks; i++) From 5e8d2e337e432cad00daae7a6755c994b4853e70 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 20 Jun 2011 13:08:40 +0200 Subject: [PATCH 335/780] lavf: deprecate AVStream.quality. AVStream is no place for it and it's unused outside of ffmpeg anyway. --- ffmpeg.c | 15 ++++++++------- libavformat/avformat.h | 4 +++- libavformat/ffmdec.c | 1 - libavformat/ffmenc.c | 1 - libavformat/version.h | 3 +++ tests/ref/lavf/ffm | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 1a4d2a1204..29d9d17619 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1123,7 +1123,7 @@ static void do_video_out(AVFormatContext *s, AVOutputStream *ost, AVInputStream *ist, AVFrame *in_picture, - int *frame_size) + int *frame_size, float quality) { int nb_frames, i, ret, resample_changed; AVFrame *final_picture, *formatted_picture; @@ -1245,7 +1245,7 @@ static void do_video_out(AVFormatContext *s, /* handles sameq here. This is not correct because it may not be a global option */ - big_picture.quality = same_quality ? ist->st->quality : ost->st->quality; + big_picture.quality = quality; if(!me_threshold) big_picture.pict_type = 0; // big_picture.pts = AV_NOPTS_VALUE; @@ -1480,6 +1480,7 @@ static int output_packet(AVInputStream *ist, int ist_index, #if CONFIG_AVFILTER int frame_available; #endif + float quality; AVPacket avpkt; int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt); @@ -1560,7 +1561,7 @@ static int output_packet(AVInputStream *ist, int ist_index, ret = avcodec_decode_video2(ist->st->codec, &picture, &got_output, &avpkt); - ist->st->quality= picture.quality; + quality = same_quality ? picture.quality : 0; if (ret < 0) goto fail_decode; if (!got_output) { @@ -1685,7 +1686,8 @@ static int output_packet(AVInputStream *ist, int ist_index, if (ost->picref->video && !ost->frame_aspect_ratio) ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect; #endif - do_video_out(os, ost, ist, &picture, &frame_size); + do_video_out(os, ost, ist, &picture, &frame_size, + same_quality ? quality : ost->st->codec->global_quality); if (vstats_filename && frame_size) do_video_stats(os, ost, frame_size); break; @@ -3495,8 +3497,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) video_enc->gop_size = 0; if (video_qscale || same_quality) { video_enc->flags |= CODEC_FLAG_QSCALE; - video_enc->global_quality= - st->quality = FF_QP2LAMBDA * video_qscale; + video_enc->global_quality = FF_QP2LAMBDA * video_qscale; } if(intra_matrix) @@ -3614,7 +3615,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) if (audio_qscale > QSCALE_NONE) { audio_enc->flags |= CODEC_FLAG_QSCALE; - audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale; + audio_enc->global_quality = FF_QP2LAMBDA * audio_qscale; } if (audio_channels) audio_enc->channels = audio_channels; diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 12490c1209..9011099a21 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -523,12 +523,14 @@ typedef struct AVStream { int stream_copy; /**< If set, just copy stream. */ enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed. +#if FF_API_AVSTREAM_QUALITY //FIXME move stuff to a flags field? /** * Quality, as it has been removed from AVCodecContext and put in AVVideoFrame. * MN: dunno if that is the right place for it */ - float quality; + attribute_deprecated float quality; +#endif /** * Decoding: pts of the first frame of the stream, in stream time base. diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index 91ab2e4370..ed932703a2 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -301,7 +301,6 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) codec->codec_id = avio_rb32(pb); codec->codec_type = avio_r8(pb); /* codec_type */ codec->bit_rate = avio_rb32(pb); - st->quality = avio_rb32(pb); codec->flags = avio_rb32(pb); codec->flags2 = avio_rb32(pb); codec->debug = avio_rb32(pb); diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c index 9a3eb40ad7..a31ac8e1d0 100644 --- a/libavformat/ffmenc.c +++ b/libavformat/ffmenc.c @@ -114,7 +114,6 @@ static int ffm_write_header(AVFormatContext *s) avio_wb32(pb, codec->codec_id); avio_w8(pb, codec->codec_type); avio_wb32(pb, codec->bit_rate); - avio_wb32(pb, st->quality); avio_wb32(pb, codec->flags); avio_wb32(pb, codec->flags2); avio_wb32(pb, codec->debug); diff --git a/libavformat/version.h b/libavformat/version.h index 3cc1718f2b..0cf383fcc1 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -74,5 +74,8 @@ #ifndef FF_API_FLAG_RTP_HINT #define FF_API_FLAG_RTP_HINT (LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_AVSTREAM_QUALITY +#define FF_API_AVSTREAM_QUALITY (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif /* AVFORMAT_VERSION_H */ diff --git a/tests/ref/lavf/ffm b/tests/ref/lavf/ffm index b89af6e3e5..b20e132b45 100644 --- a/tests/ref/lavf/ffm +++ b/tests/ref/lavf/ffm @@ -1,3 +1,3 @@ -b6acf782a38d313153b68c4ca204fc90 *./tests/data/lavf/lavf.ffm +f9bee27ea1b6b83a06b5f9efb0a4ac1f *./tests/data/lavf/lavf.ffm 376832 ./tests/data/lavf/lavf.ffm ./tests/data/lavf/lavf.ffm CRC=0xf361ed74 From 4e59c8ecf1433b85b539c5e89bb68cfe8b839866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Tue, 5 Jul 2011 23:10:44 +0200 Subject: [PATCH 336/780] Fix av_open_input_stream with uninitialized context pointer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code would allocate a new context but forget to assign it to the pointer actually passed to avformat_open_input, potentially causing a crash. Even if it was initialized it would cause a memleak. This caused crashes with e.g. mpd, see also http://bugs.gentoo.org/show_bug.cgi?id=373423 Signed-off-by: Reimar Döffinger --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 989ddaca07..9a7d6b7a20 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -458,7 +458,7 @@ int av_open_input_stream(AVFormatContext **ic_ptr, opts = convert_format_parameters(ap); if(!ap->prealloced_context) - ic = avformat_alloc_context(); + *ic_ptr = ic = avformat_alloc_context(); else ic = *ic_ptr; if (!ic) { From b845af0115cbdf8f077ddabb2a3fc3f8fc0c09f0 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 3 Jul 2011 23:48:22 +0200 Subject: [PATCH 337/780] gitignore: Drop individual .d ignore; it is already covered by a wildcard. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8887980bc0..59a0860759 100644 --- a/.gitignore +++ b/.gitignore @@ -42,5 +42,4 @@ tools/pktdumper tools/probetest tools/qt-faststart tools/trasher -tools/trasher*.d version.h From fb2f23c6c9c95297d1c1c1ab44c27d2b1929f708 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 6 Jul 2011 20:46:06 +0200 Subject: [PATCH 338/780] Remove unused and outdated TODO file. --- doc/TODO | 82 -------------------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 doc/TODO diff --git a/doc/TODO b/doc/TODO deleted file mode 100644 index 8ff8a6b388..0000000000 --- a/doc/TODO +++ /dev/null @@ -1,82 +0,0 @@ -ffmpeg TODO list: ----------------- - -Fabrice's TODO list: (unordered) -------------------- -Short term: - -- use AVFMTCTX_DISCARD_PKT in ffplay so that DV has a chance to work -- add RTSP regression test (both client and server) -- make ffserver allocate AVFormatContext -- clean up (incompatible change, for 0.5.0): - * AVStream -> AVComponent - * AVFormatContext -> AVInputStream/AVOutputStream - * suppress rate_emu from AVCodecContext -- add new float/integer audio filterting and conversion : suppress - CODEC_ID_PCM_xxc and use CODEC_ID_RAWAUDIO. -- fix telecine and frame rate conversion - -Long term (ask me if you want to help): - -- commit new imgconvert API and new PIX_FMT_xxx alpha formats -- commit new LGPL'ed float and integer-only AC3 decoder -- add WMA integer-only decoder -- add new MPEG4-AAC audio decoder (both integer-only and float version) - -Michael's TODO list: (unordered) (if anyone wanna help with sth, just ask) -------------------- -- optimize H264 CABAC -- more optimizations -- simper rate control - -Philip'a TODO list: (alphabetically ordered) (please help) ------------------- -- Add a multi-ffm filetype so that feeds can be recorded into multiple files rather - than one big file. -- Authenticated users support -- where the authentication is in the URL -- Change ASF files so that the embedded timestamp in the frames is right rather - than being an offset from the start of the stream -- Make ffm files more resilient to changes in the codec structures so that you - can play old ffm files. - -Baptiste's TODO list: ------------------ -- mov edit list support (AVEditList) -- YUV 10 bit per component support "2vuy" -- mxf muxer -- mpeg2 non linear quantizer - -unassigned TODO: (unordered) ---------------- -- use AVFrame for audio codecs too -- rework aviobuf.c buffering strategy and fix url_fskip -- generate optimal huffman tables for mjpeg encoding -- fix ffserver regression tests -- support xvids motion estimation -- support x264s motion estimation -- support x264s rate control -- SNOW: non translational motion compensation -- SNOW: more optimal quantization -- SNOW: 4x4 block support -- SNOW: 1/8 pel motion compensation support -- SNOW: iterative motion estimation based on subsampled images -- SNOW: try B frames and MCTF and see how their PSNR/bitrate/complexity behaves -- SNOW: try to use the wavelet transformed MC-ed reference frame as context for the entropy coder -- SNOW: think about/analyize how to make snow use multiple cpus/threads -- SNOW: finish spec -- FLAC: lossy encoding (viterbi and naive scalar quantization) -- libavfilter -- JPEG2000 decoder & encoder -- MPEG4 GMC encoding support -- macroblock based pixel format (better cache locality, somewhat complex, one paper claimed it faster for high res) -- regression tests for codecs which do not have an encoder (I+P-frame bitstream in the 'master' branch) -- add support for using mplayers video filters to ffmpeg -- H264 encoder -- per MB ratecontrol (so VCD and such do work better) -- write a script which iteratively changes all functions between always_inline and noinline and benchmarks the result to find the best set of inlined functions -- convert all the non SIMD asm into small asm vs. C testcases and submit them to the gcc devels so they can improve gcc -- generic audio mixing API -- extract PES packetizer from PS muxer and use it for new TS muxer -- implement automatic AVBistreamFilter activation -- make cabac encoder use bytestream (see http://trac.videolan.org/x264/changeset/?format=diff&new=651) -- merge imdct and windowing, the current code does considerable amounts of redundant work From f02f745e4aa070e5fabf1156b75c340171304933 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 6 Jul 2011 22:13:10 +0200 Subject: [PATCH 339/780] ffserver: remove unused variable. Signed-off-by: Anton Khirnov --- ffserver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ffserver.c b/ffserver.c index f80ad972e5..b4deb8ffd0 100644 --- a/ffserver.c +++ b/ffserver.c @@ -2128,13 +2128,12 @@ static int open_input_stream(HTTPContext *c, const char *info) char buf[128]; char input_filename[1024]; AVFormatContext *s = NULL; - int buf_size, i, ret; + int i, ret; int64_t stream_pos; /* find file name */ if (c->stream->feed) { strcpy(input_filename, c->stream->feed->feed_filename); - buf_size = FFM_PACKET_SIZE; /* compute position (absolute time) */ if (av_find_info_tag(buf, sizeof(buf), "date", info)) { if ((ret = av_parse_time(&stream_pos, buf, 0)) < 0) @@ -2146,7 +2145,6 @@ static int open_input_stream(HTTPContext *c, const char *info) stream_pos = av_gettime() - c->stream->prebuffer * (int64_t)1000; } else { strcpy(input_filename, c->stream->feed_filename); - buf_size = 0; /* compute position (relative time) */ if (av_find_info_tag(buf, sizeof(buf), "date", info)) { if ((ret = av_parse_time(&stream_pos, buf, 1)) < 0) From df8c675f487bc2cda2b22541cd8e5a6d8090374d Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 1 Jul 2011 16:31:16 +0200 Subject: [PATCH 340/780] graphparser: fix logic for updating the open_inputs/outputs in avfilter_graph_parse() Create open_inputs and open_outputs structs if they are not provided by the user, and free them before exit. In particular, fix NULL pointer dereference and crash, in case the passed open_inputs/outputs is NULL and the parsing failed. --- libavfilter/graphparser.c | 54 ++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index 214729edb7..edba731897 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -333,38 +333,40 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, } int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, - AVFilterInOut **open_inputs, AVFilterInOut **open_outputs, + AVFilterInOut **open_inputs_ptr, AVFilterInOut **open_outputs_ptr, void *log_ctx) { - int index = 0, ret; + int index = 0, ret = 0; char chr = 0; AVFilterInOut *curr_inputs = NULL; + AVFilterInOut *open_inputs = open_inputs_ptr ? *open_inputs_ptr : NULL; + AVFilterInOut *open_outputs = open_outputs_ptr ? *open_outputs_ptr : NULL; do { AVFilterContext *filter; const char *filterchain = filters; filters += strspn(filters, WHITESPACES); - if ((ret = parse_inputs(&filters, &curr_inputs, open_outputs, log_ctx)) < 0) - goto fail; + if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0) + goto end; if ((ret = parse_filter(&filter, &filters, graph, index, log_ctx)) < 0) - goto fail; + goto end; if (filter->input_count == 1 && !curr_inputs && !index) { /* First input can be omitted if it is "[in]" */ const char *tmp = "[in]"; - if ((ret = parse_inputs(&tmp, &curr_inputs, open_outputs, log_ctx)) < 0) - goto fail; + if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0) + goto end; } - if ((ret = link_filter_inouts(filter, &curr_inputs, open_inputs, log_ctx)) < 0) - goto fail; + if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx)) < 0) + goto end; - if ((ret = parse_outputs(&filters, &curr_inputs, open_inputs, open_outputs, + if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs, log_ctx)) < 0) - goto fail; + goto end; filters += strspn(filters, WHITESPACES); chr = *filters++; @@ -374,7 +376,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, "Invalid filterchain containing an unlabelled output pad: \"%s\"\n", filterchain); ret = AVERROR(EINVAL); - goto fail; + goto end; } index++; } while (chr == ',' || chr == ';'); @@ -384,25 +386,29 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, "Unable to parse graph description substring: \"%s\"\n", filters - 1); ret = AVERROR(EINVAL); - goto fail; + goto end; } - if (open_inputs && *open_inputs && !strcmp((*open_inputs)->name, "out") && curr_inputs) { + if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) { /* Last output can be omitted if it is "[out]" */ const char *tmp = "[out]"; - if ((ret = parse_outputs(&tmp, &curr_inputs, open_inputs, open_outputs, + if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs, log_ctx)) < 0) - goto fail; + goto end; } - return 0; - - fail: - for (; graph->filter_count > 0; graph->filter_count--) - avfilter_free(graph->filters[graph->filter_count - 1]); - av_freep(&graph->filters); - avfilter_inout_free(open_inputs); - avfilter_inout_free(open_outputs); +end: + /* clear open_in/outputs only if not passed as parameters */ + if (open_inputs_ptr) *open_inputs_ptr = open_inputs; + else avfilter_inout_free(&open_inputs); + if (open_outputs_ptr) *open_outputs_ptr = open_outputs; + else avfilter_inout_free(&open_outputs); avfilter_inout_free(&curr_inputs); + + if (ret < 0) { + for (; graph->filter_count > 0; graph->filter_count--) + avfilter_free(graph->filters[graph->filter_count - 1]); + av_freep(&graph->filters); + } return ret; } From 6ce05bc73c782d9361a03ac83e41c44ed429f27b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 15:36:23 +0200 Subject: [PATCH 341/780] graphparser: clarify comments in avfilter_graph_parse() --- libavfilter/graphparser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index edba731897..111e5aa0db 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -355,7 +355,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, goto end; if (filter->input_count == 1 && !curr_inputs && !index) { - /* First input can be omitted if it is "[in]" */ + /* First input pad, assume it is "[in]" if not specified */ const char *tmp = "[in]"; if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0) goto end; @@ -390,7 +390,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, } if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) { - /* Last output can be omitted if it is "[out]" */ + /* Last output pad, assume it is "[out]" if not specified */ const char *tmp = "[out]"; if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs, log_ctx)) < 0) From ebd1edf36c81155e2817edaa056b0bc9eb21e8f5 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 16:09:55 +0200 Subject: [PATCH 342/780] avfiltergraph: clarify doxy for avfilter_graph_parse() open_inputs/outputs params Make it clear that open_inputs/open_outputs are updated only if non-NULL. --- libavfilter/avfiltergraph.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavfilter/avfiltergraph.h b/libavfilter/avfiltergraph.h index a975926fd1..f4c88bc796 100644 --- a/libavfilter/avfiltergraph.h +++ b/libavfilter/avfiltergraph.h @@ -124,12 +124,12 @@ void avfilter_inout_free(AVFilterInOut **inout); * * @param graph the filter graph where to link the parsed graph context * @param filters string to be parsed - * @param inputs linked list to the inputs of the graph, may be NULL. - * It is updated to contain the list of open inputs after the parsing, - * should be freed with avfilter_inout_free(). - * @param outputs linked list to the outputs of the graph, may be NULL. - * It is updated to contain the list of open outputs after the parsing, - * should be freed with avfilter_inout_free(). + * @param inputs pointer to a linked list to the inputs of the graph, may be NULL. + * If non-NULL, *inputs is updated to contain the list of open inputs + * after the parsing, should be freed with avfilter_inout_free(). + * @param outputs pointer to a linked list to the outputs of the graph, may be NULL. + * If non-NULL, *outputs is updated to contain the list of open outputs + * after the parsing, should be freed with avfilter_inout_free(). * @return zero on success, a negative AVERROR code on error */ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, From 7f01a4192cdf4565eadee457f76e6b5196e35e0b Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 29 Jun 2011 13:41:47 -0700 Subject: [PATCH 343/780] adts: Fix PCE copying. Parse the extension flag bit when reading the MPEG4 AudioSpecificConfig. This has nothing to do with SBR/PS contradictory to what was noted when it was removed. --- libavformat/adtsenc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c index e858a81d92..75649e24dc 100644 --- a/libavformat/adtsenc.c +++ b/libavformat/adtsenc.c @@ -59,6 +59,10 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf av_log(s, AV_LOG_ERROR, "Scalable configurations are not allowed in ADTS\n"); return -1; } + if (get_bits(&gb, 1)) { + av_log(s, AV_LOG_ERROR, "Extension flag is not allowed in ADTS\n"); + return -1; + } if (!adts->channel_conf) { init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE); From b0058bda78bcbb6a887e5099b85ac3bc2e23bb57 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 7 Jul 2011 01:31:00 +0200 Subject: [PATCH 344/780] libvo-amrwbenc: Add braces to shut up gcc warning. libavcodec/libvo-amrwbenc.c:37:5: warning: missing braces around initializer --- libavcodec/libvo-amrwbenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index b3615ede42..201a74ed26 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -34,7 +34,7 @@ typedef struct AMRWBContext { } AMRWBContext; static const AVOption options[] = { - { "dtx", "Allow DTX (generate comfort noise)", offsetof(AMRWBContext, allow_dtx), FF_OPT_TYPE_INT, 0, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, + { "dtx", "Allow DTX (generate comfort noise)", offsetof(AMRWBContext, allow_dtx), FF_OPT_TYPE_INT, { 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, { NULL } }; From 9d36139231bfcf155a1b94f61a420768f1771174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 7 Jul 2011 09:50:43 +0300 Subject: [PATCH 345/780] docs: Don't recommend adding --enable-memalign-hack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is enabled automatically when required nowadays. Signed-off-by: Martin Storsjö --- doc/general.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index 775bf5d03f..6e21ca899e 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -949,7 +949,7 @@ MSVC++-compatible import libraries. @item Build Libav with @example -./configure --enable-shared --enable-memalign-hack +./configure --enable-shared make make install @end example @@ -1071,12 +1071,12 @@ and add some special flags to your configure invocation. For a static build run @example -./configure --target-os=mingw32 --enable-memalign-hack --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin +./configure --target-os=mingw32 --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin @end example and for a build with shared libraries @example -./configure --target-os=mingw32 --enable-memalign-hack --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin +./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin @end example @bye From 6e4ca0749c2e6434e071dbd314076613fb3ef59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 7 Jul 2011 09:51:57 +0300 Subject: [PATCH 346/780] docs: Remove needless configure options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Specifying --enable-static --disable-shared isn't necessary, these are the defaults. Signed-off-by: Martin Storsjö --- doc/general.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index 6e21ca899e..93f563e1bf 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1024,7 +1024,7 @@ diffutils Then run @example -./configure --enable-static --disable-shared +./configure @end example to make a static build. @@ -1071,7 +1071,7 @@ and add some special flags to your configure invocation. For a static build run @example -./configure --target-os=mingw32 --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin +./configure --target-os=mingw32 --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin @end example and for a build with shared libraries From 357d0d8fc787ea5d6ca8ba0839f94493604208a3 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 7 Jul 2011 01:31:01 +0200 Subject: [PATCH 347/780] libgsm: Drop const qualifier to silence compiler warning. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libavcodec/libgsm.c:148: warning: passing argument 2 of ‘gsm_decode’ discards qualifiers from pointer target type /usr/include/gsm/gsm.h:68: note: expected ‘gsm_byte *’ but argument is of type ‘const uint8_t *’ --- libavcodec/libgsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c index 34f29573db..0573cb33d6 100644 --- a/libavcodec/libgsm.c +++ b/libavcodec/libgsm.c @@ -139,7 +139,7 @@ AVCodec ff_libgsm_ms_encoder = { static int libgsm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; + uint8_t *buf = avpkt->data; int buf_size = avpkt->size; *data_size = 0; /* In case of error */ if(buf_size < avctx->block_align) return -1; From 965fdda0159a5ce22a16d41f3cb197c5ab6651f0 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 7 Jul 2011 01:31:05 +0200 Subject: [PATCH 348/780] vf_drawtext: Remove some write-only variables. libavfilter/vf_drawtext.c:427:22: warning: variable 'dst_pixel' set but not used libavfilter/vf_drawtext.c:463:22: warning: variable 'dst_pixel' set but not used --- libavfilter/vf_drawtext.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index a3adaa7dfc..ed4b1003d8 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -424,15 +424,10 @@ static inline int draw_glyph_yuv(AVFilterBufferRef *picref, FT_Bitmap *bitmap, u { int r, c, alpha; unsigned int luma_pos, chroma_pos1, chroma_pos2; - uint8_t src_val, dst_pixel[4]; + uint8_t src_val; for (r = 0; r < bitmap->rows && r+y < height; r++) { for (c = 0; c < bitmap->width && c+x < width; c++) { - /* get pixel in the picref (destination) */ - dst_pixel[0] = picref->data[0][ c+x + (y+r) * picref->linesize[0]]; - dst_pixel[1] = picref->data[1][((c+x) >> hsub) + ((y+r) >> vsub) * picref->linesize[1]]; - dst_pixel[2] = picref->data[2][((c+x) >> hsub) + ((y+r) >> vsub) * picref->linesize[2]]; - /* get intensity value in the glyph bitmap (source) */ src_val = GET_BITMAP_VAL(r, c); if (!src_val) @@ -460,18 +455,10 @@ static inline int draw_glyph_rgb(AVFilterBufferRef *picref, FT_Bitmap *bitmap, { int r, c, alpha; uint8_t *p; - uint8_t src_val, dst_pixel[4]; + uint8_t src_val; for (r = 0; r < bitmap->rows && r+y < height; r++) { for (c = 0; c < bitmap->width && c+x < width; c++) { - /* get pixel in the picref (destination) */ - dst_pixel[0] = picref->data[0][(c+x + rgba_map[0]) * pixel_step + - (y+r) * picref->linesize[0]]; - dst_pixel[1] = picref->data[0][(c+x + rgba_map[1]) * pixel_step + - (y+r) * picref->linesize[0]]; - dst_pixel[2] = picref->data[0][(c+x + rgba_map[2]) * pixel_step + - (y+r) * picref->linesize[0]]; - /* get intensity value in the glyph bitmap (source) */ src_val = GET_BITMAP_VAL(r, c); if (!src_val) From 2f138f0b7c36fe50b51e0d74bc913d14aea00c5e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 7 Jul 2011 15:25:30 +0100 Subject: [PATCH 349/780] build: clean up library installation rules Signed-off-by: Mans Rullgard --- configure | 22 ++++++++++++---------- subdir.mak | 14 +++++++------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/configure b/configure index e77340f74a..f5b4a5c767 100755 --- a/configure +++ b/configure @@ -1657,6 +1657,8 @@ SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)' SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)' SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)' LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' +SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)' +SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)' AS_O='-o $@' CC_O='-o $@' @@ -2419,12 +2421,11 @@ case $target_os in SLIBSUF=".dll" SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)' SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' - SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)' - SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \ - install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \ - install -d "$(LIBDIR)"; \ - install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"' - SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"' + SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)' + SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)' + SLIB_INSTALL_LINKS= + SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)' + SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)' SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base' objformat="win32" dlltool="${cross_prefix}dlltool" @@ -2482,8 +2483,7 @@ case $target_os in emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def' SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \ emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;' - SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"' - SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib' + SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib' enable dos_paths ;; gnu/kfreebsd) @@ -3242,8 +3242,10 @@ SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION} SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR} SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD} SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD} -SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD} -SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD} +SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME} +SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS} +SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB} +SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB} SAMPLES:=${samples:-\$(FATE_SAMPLES)} EOF diff --git a/subdir.mak b/subdir.mak index e7c9eaafca..3a38dafe63 100644 --- a/subdir.mak +++ b/subdir.mak @@ -56,12 +56,11 @@ distclean:: clean install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME) $(Q)mkdir -p "$(SHLIBDIR)" - $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)" - $(Q)cd "$(SHLIBDIR)" && \ - $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR) - $(Q)cd "$(SHLIBDIR)" && \ - $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME) - $(SLIB_INSTALL_EXTRA_CMD) + $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)" + $(Q)$(foreach F,$(SLIB_INSTALL_LINKS),cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F);) + $(if $(SLIB_INSTALL_EXTRA_SHLIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_SHLIB:%=$(SUBDIR)%) "$(SHLIBDIR)") + $(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)") + $(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)") install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME) $(Q)mkdir -p "$(LIBDIR)" @@ -80,7 +79,8 @@ uninstall-libs:: -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \ "$(SHLIBDIR)/$(SLIBNAME)" \ "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)" - -$(SLIB_UNINSTALL_EXTRA_CMD) + -$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)"%) + -$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)"%) -$(RM) "$(LIBDIR)/$(LIBNAME)" uninstall-headers:: From bb83478d2c91db2c9150bb78568ccef25f0e975f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 5 Jul 2011 14:58:49 +0200 Subject: [PATCH 350/780] build: remove unused copy regression test script The copy regression test script is unused, bash-specific and did not even work properly when it was originally committed. --- tests/copy.regression.ref | 465 -------------------------------------- tests/copycooker.sh | 30 --- 2 files changed, 495 deletions(-) delete mode 100644 tests/copy.regression.ref delete mode 100755 tests/copycooker.sh diff --git a/tests/copy.regression.ref b/tests/copy.regression.ref deleted file mode 100644 index 0f62a7be75..0000000000 --- a/tests/copy.regression.ref +++ /dev/null @@ -1,465 +0,0 @@ ----------------- -./tests/data/a-ac3.rm -first.nut second.nut differ: char 34, line 1 -1dd5a62b7edb3a1bcf77626af0a85bc1 first.nut ----------------- -./tests/data/a-adpcm_ima.wav -first.nut second.nut differ: char 34, line 1 -c95390143078f08db8a3bfba5789c2da first.nut ----------------- -./tests/data/a-adpcm_ms.wav -first.nut second.nut differ: char 34, line 1 -05e4d8842f4001fed506423e1a8ef963 first.nut ----------------- -./tests/data/a-adpcm_qt.aiff -first.nut second.nut differ: char 34, line 1 -7455d87f626f05e20030f4c93ec91e69 first.nut ----------------- -./tests/data/a-adpcm_swf.flv -c0402ee010a483403a655f353e184df1 first.nut ----------------- -./tests/data/a-adpcm_yam.wav -first.nut second.nut differ: char 34, line 1 -f861047f6c6f75cdf3ce7bb78a4003ad first.nut ----------------- -./tests/data/a-alac.m4a -first.nut second.nut differ: char 34, line 1 -ab152b0b01e540e74b04a807e3882083 first.nut ----------------- -./tests/data/a-asv1.avi -636fc0dfef1830cc51cf2c182bd4a7b2 first.nut ----------------- -./tests/data/a-asv2.avi -bbfc299390378c7bdbd7463434d8fcbe first.nut ----------------- -./tests/data/a-dnxhd-1080i.mov -first.nut second.nut differ: char 113, line 1 -037e31900e6cdf7161c2a0df23d9dc9d first.nut ----------------- -./tests/data/a-dnxhd-720p-rd.dnxhd -first.nut second.nut differ: char 113, line 1 -1237abac554ea9adb2a926641eec0de0 first.nut ----------------- -./tests/data/a-dnxhd-720p.dnxhd -first.nut second.nut differ: char 113, line 1 -6694322cefa2f482bc3dac8be22eb5d5 first.nut ----------------- -./tests/data/a-dv.dv -1aa367a56d31bb45f98d820121820909 first.nut ----------------- -./tests/data/a-dv411.dv -7ef296512960e00d96850f2606b4b683 first.nut ----------------- -./tests/data/a-dv50.dv -6424dd39e22a1789a8182d7e8da224a9 first.nut ----------------- -./tests/data/a-error-mpeg4-adv.avi -715b262e3e7c9be2b59525ba0289f30e first.nut ----------------- -./tests/data/a-ffv1.avi -edada4da2170ffd3386636cff67a90f0 first.nut ----------------- -./tests/data/a-flac.flac -d5e0a6d87034c21627afb2a904412a21 first.nut ----------------- -./tests/data/a-flashsv.flv -985076a8a87df1f91b34cbb81ce96217 first.nut ----------------- -./tests/data/a-flv.flv -6d01a0eb07c15ec3d0a70bfad0615bec first.nut ----------------- -./tests/data/a-g726.wav -first.nut second.nut differ: char 34, line 1 -59540b44c97b8e1eafc53ebdaeaf3eb8 first.nut ----------------- -./tests/data/a-h261.avi -18d47cc50e05e5c855a8aec1a5d8d9ec first.nut ----------------- -./tests/data/a-h263.avi -91b67a478420a30cf10c3d872f7e799b first.nut ----------------- -./tests/data/a-h263p.avi -1e9f108181dca2dd3bb621bb45fc5834 first.nut ----------------- -./tests/data/a-huffyuv.avi -62dccc2a428b561c08497f8378ea1567 first.nut ----------------- -./tests/data/a-jpegls.avi -35f1bb0f9b14bf3eb29134784f278c4f first.nut ----------------- -./tests/data/a-ljpeg.avi -45ec1072d8e55d6cfa784cc732830f3c first.nut ----------------- -./tests/data/a-mjpeg.avi -4e6d42fdda880661de8308cfa45652ee first.nut ----------------- -./tests/data/a-mp2.mp2 -6c8d1a33dd994d63c68e5c9953b5cb8c first.nut ----------------- -./tests/data/a-mpeg1.mpg -first.nut second.nut differ: char 34, line 1 -9d444c67713ef70c06d35fd355200ed5 first.nut ----------------- -./tests/data/a-mpeg1b.mpg -first.nut second.nut differ: char 34, line 1 -9d444c67713ef70c06d35fd355200ed5 first.nut ----------------- -./tests/data/a-mpeg2.mpg -first.nut second.nut differ: char 34, line 1 -328f6a0069b76397c5ed0dcea8b69b50 first.nut ----------------- -./tests/data/a-mpeg2.mpg -first.nut second.nut differ: char 34, line 1 -328f6a0069b76397c5ed0dcea8b69b50 first.nut ----------------- -./tests/data/a-mpeg2_422.mpg -first.nut second.nut differ: char 34, line 1 -d27035bcf30801cd1bee6ac59e8f5e3e first.nut ----------------- -./tests/data/a-mpeg2i.mpg -first.nut second.nut differ: char 34, line 1 -c3351b79649825a6b9f62a2a1db633c1 first.nut ----------------- -./tests/data/a-mpeg2ivlc-qprd.mpg -first.nut second.nut differ: char 34, line 1 -d910da52fa10eb1deca10fa9443132d2 first.nut ----------------- -./tests/data/a-mpeg2reuse.mpg -first.nut second.nut differ: char 34, line 1 -c3351b79649825a6b9f62a2a1db633c1 first.nut ----------------- -./tests/data/a-mpeg2thread.mpg -first.nut second.nut differ: char 34, line 1 -c3351b79649825a6b9f62a2a1db633c1 first.nut ----------------- -./tests/data/a-mpeg2threadivlc.mpg -first.nut second.nut differ: char 34, line 1 -c3351b79649825a6b9f62a2a1db633c1 first.nut ----------------- -./tests/data/a-mpeg4-Q.avi -first.nut second.nut differ: char 34, line 1 -305bab90451e2c3b741e3aef51bc2a4c first.nut ----------------- -./tests/data/a-mpeg4-adap.avi -first.nut second.nut differ: char 34, line 1 -5d9315ec49c4122f6f23cf84cab5fc53 first.nut ----------------- -./tests/data/a-mpeg4-adv.avi -5d672bf4c2e879d6a20e349cb4dc09a6 first.nut ----------------- -./tests/data/a-mpeg4-nr.avi -0243b2e03115fe948f99da1ee10ae588 first.nut ----------------- -./tests/data/a-mpeg4-qprd.avi -first.nut second.nut differ: char 34, line 1 -5d9315ec49c4122f6f23cf84cab5fc53 first.nut ----------------- -./tests/data/a-mpeg4-rc.avi -first.nut second.nut differ: char 34, line 1 -5d9315ec49c4122f6f23cf84cab5fc53 first.nut ----------------- -./tests/data/a-mpeg4-thread.avi -first.nut second.nut differ: char 34, line 1 -6aa94d589e9e7626e51575d8a2aec6e7 first.nut ----------------- -./tests/data/a-msmpeg4.avi -836d432509ff22fd363237ef1dced5f3 first.nut ----------------- -./tests/data/a-msmpeg4v2.avi -37f253da3666fb057edecb86ed2dba39 first.nut ----------------- -./tests/data/a-odivx.mp4 -e3bd9d8a3417abc749c489e64119dbf3 first.nut ----------------- -./tests/data/a-pcm_alaw.wav -first.nut second.nut differ: char 34, line 1 -22853e7806b0f0162fd5e2573e34b03c first.nut ----------------- -./tests/data/a-pcm_f32be.au -first.nut second.nut differ: char 34, line 1 -94cb60c3107ec509af79191e86099a0e first.nut ----------------- -./tests/data/a-pcm_f32le.wav -first.nut second.nut differ: char 34, line 1 -8d887b27a8531390af5b682557631986 first.nut ----------------- -./tests/data/a-pcm_f64be.au -first.nut second.nut differ: char 34, line 1 -e0c7b64e13bb9398a57dac60806515fb first.nut ----------------- -./tests/data/a-pcm_f64le.wav -first.nut second.nut differ: char 34, line 1 -9dbb9bda0c990502e910e082a008433f first.nut ----------------- -./tests/data/a-pcm_mulaw.wav -first.nut second.nut differ: char 34, line 1 -78c4aae32fdddaba4f9caa5683018c94 first.nut ----------------- -./tests/data/a-pcm_s16be.mkv -first.nut second.nut differ: char 34, line 1 -279810a0c30a06c4ab7de154e3de140d first.nut ----------------- -./tests/data/a-pcm_s16be.mov -first.nut second.nut differ: char 42, line 1 -0a8ede3d121f17a98e9038771eb98e1a first.nut ----------------- -./tests/data/a-pcm_s16le.mkv -47942f5188f8d081bcbe7fb82550b135 first.nut ----------------- -./tests/data/a-pcm_s16le.wav -first.nut second.nut differ: char 34, line 1 -9f868acb99ba107750f165431f95c382 first.nut ----------------- -./tests/data/a-pcm_s24be.mov -first.nut second.nut differ: char 34, line 1 -9c96762f631851014dec14b506091cc1 first.nut ----------------- -./tests/data/a-pcm_s24daud.302 -60ecb7037b205e2013490fdadab9697b first.nut ----------------- -./tests/data/a-pcm_s24le.wav -first.nut second.nut differ: char 34, line 1 -5805a2e6e2eddede4757fd488d0d6adb first.nut ----------------- -./tests/data/a-pcm_s32be.mov -first.nut second.nut differ: char 34, line 1 -d6c868a1130be573bbe0cfc88913a60c first.nut ----------------- -./tests/data/a-pcm_s32le.wav -first.nut second.nut differ: char 34, line 1 -3e0a81669647739c490f12521f897527 first.nut ----------------- -./tests/data/a-pcm_s8.mov -first.nut second.nut differ: char 34, line 1 -a6fe0827966ee4515f27c7053d579229 first.nut ----------------- -./tests/data/a-pcm_u8.wav -first.nut second.nut differ: char 34, line 1 -f0d398fd651cdedfd7b4c5433c08fd79 first.nut ----------------- -./tests/data/a-pcm_zork.wav -first.nut second.nut differ: char 34, line 1 -69e40cc9266836a7101000677ee14a87 first.nut ----------------- -./tests/data/a-roqav.roq -first.nut second.nut differ: char 34, line 1 -0e7a57bb28054b7e319eac2ba0a4be23 first.nut ----------------- -./tests/data/a-rv10.rm -first.nut second.nut differ: char 34, line 1 -80f982c6bffea91ff45a9b320cb93c14 first.nut ----------------- -./tests/data/a-rv20.rm -first.nut second.nut differ: char 34, line 1 -5b02113c0941578ca6918215eed8a728 first.nut ----------------- -./tests/data/a-snow.avi -e73b88690aa491491ede5970641134ad first.nut ----------------- -./tests/data/a-snow53.avi -18a6b061252c8c74bd22b42a7d5b2bae first.nut ----------------- -./tests/data/a-svq1.mov -first.nut second.nut differ: char 197, line 1 -6bbe90d47c1763654e8388ce51ab911e first.nut ----------------- -./tests/data/a-wmav1.asf -first.nut second.nut differ: char 34, line 1 -c3f7bc239ff166d738b29252b47bd437 first.nut ----------------- -./tests/data/a-wmav2.asf -first.nut second.nut differ: char 34, line 1 -930f1824b9677f0b6b714f1c6ddcf825 first.nut ----------------- -./tests/data/a-wmv1.avi -206bd9985b575f61a8a580656af39beb first.nut ----------------- -./tests/data/a-wmv2.avi -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-bgr24.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-gray.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-monob.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-monow.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-rgb24.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-rgb32.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-rgb555.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-rgb565.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuv410p.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuv411p.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuv420p.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuv422p.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuv440p.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuv444p.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuvj420p.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuvj422p.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuvj440p.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuvj444p.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf-yuyv422.yuv -09178a3c2b99d4f7ad1f7a761a2b803a first.nut ----------------- -./tests/data/b-lavf.aif -first.nut second.nut differ: char 34, line 1 -3f1d3faae1671f1cf862ddb66a5c59d1 first.nut ----------------- -./tests/data/b-lavf.al -e6d4b977e74a535b039a6a1dfed2dbc1 first.nut ----------------- -./tests/data/b-lavf.asf -first.nut second.nut differ: char 34, line 1 -57727c41b3974697c0a79cfd08515ddd first.nut ----------------- -./tests/data/b-lavf.au -first.nut second.nut differ: char 34, line 1 -1da12f41bc5ea1fd851e8a48b222c204 first.nut ----------------- -./tests/data/b-lavf.avi -a88edf9fb8e02e658ba3cae9313a3cdc first.nut ----------------- -./tests/data/b-lavf.dv -first.nut second.nut differ: char 34, line 1 -819018a5d91c55312ffe784e8712ac4b first.nut ----------------- -./tests/data/b-lavf.ffm -first.nut second.nut differ: char 34, line 1 -17f8894a05c71adb51c9a0ff1b9040bb first.nut ----------------- -./tests/data/b-lavf.flv -d74edb56e74e0eea748863f3aeeafa61 first.nut ----------------- -./tests/data/b-lavf.gif -first.nut second.nut differ: char 34, line 1 -ef9ba6bf88f44d9d326049ef2872a4d3 first.nut ----------------- -./tests/data/b-lavf.gxf -first.nut second.nut differ: char 44, line 1 -522957f46ba46051fd03a0868c905e54 first.nut ----------------- -./tests/data/b-lavf.mkv -8c9427bb75c96210d6580d9b881d9e4d first.nut ----------------- -./tests/data/b-lavf.mmf -first.nut second.nut differ: char 42, line 1 -298136aef02389fc5b0844995fe6ac72 first.nut ----------------- -./tests/data/b-lavf.mov -ce895b33ff206fafbae89fd5a8f959d2 first.nut ----------------- -./tests/data/b-lavf.mpg -d279e3343993267241c2fac4f4563cdb first.nut ----------------- -./tests/data/b-lavf.mxf -first.nut second.nut differ: char 34, line 1 -3e98a90d40986b8ea4305be06175927a first.nut ----------------- -./tests/data/b-lavf.mxf_d10 -1ee69644165344a096ddfaaac951a0e9 first.nut ----------------- -./tests/data/b-lavf.nut -1426bca4c65796516a3e94b6bebc5a58 first.nut ----------------- -./tests/data/b-lavf.ogg -c986ce79045f2068ae1bedc2b8702884 first.nut ----------------- -./tests/data/b-lavf.rm -first.nut second.nut differ: char 34, line 1 -a3b2c9d3ec2c86b6d4c3bf0ed91391c3 first.nut ----------------- -./tests/data/b-lavf.swf -first.nut second.nut differ: char 34, line 1 -d4a5c5e6343dc17bed49397d889e0799 first.nut ----------------- -./tests/data/b-lavf.ts -40fd2ece0c8386d3a250943eab023795 first.nut ----------------- -./tests/data/b-lavf.ul -1c4c747e2e9c0fd195656359341eef76 first.nut ----------------- -./tests/data/b-lavf.voc -first.nut second.nut differ: char 42, line 1 -500ef42830c5bc2af849dbdcc4380f1b first.nut ----------------- -./tests/data/b-lavf.wav -first.nut second.nut differ: char 42, line 1 -8d4c6a79af442610ad912625c9b85d02 first.nut ----------------- -./tests/data/b-lavf.y4m -f42a6ff4488de306925b057ecee75b0e first.nut ----------------- -./tests/data/b-lavf02.bmp -first.nut second.nut differ: char 113, line 1 -02e3c782ef3a0c96e820201d4d4b8268 first.nut ----------------- -./tests/data/b-lavf02.jpg -61a19c3012a5aa056d8e9a589e29de2e first.nut ----------------- -./tests/data/b-lavf02.pcx -first.nut second.nut differ: char 113, line 1 -3c4e1b9c8d5dd2bedb8eebd1edc7a2f5 first.nut ----------------- -./tests/data/b-lavf02.pgm -first.nut second.nut differ: char 113, line 1 -cc36bdadd7aef501a6d5d588dec2188b first.nut ----------------- -./tests/data/b-lavf02.ppm -first.nut second.nut differ: char 113, line 1 -453ec690bea6c3668e2b65e0b7ad14c8 first.nut ----------------- -./tests/data/b-lavf02.sgi -first.nut second.nut differ: char 113, line 1 -6cdadd58aaa5ad196697352e96723e52 first.nut ----------------- -./tests/data/b-lavf02.tga -4144d2b4ee2948c1a16f7fc31b381be3 first.nut ----------------- -./tests/data/b-lavf02.tiff -first.nut second.nut differ: char 113, line 1 -237fa2da2d5f4930dae9825c9cf928a6 first.nut ----------------- -./tests/data/b-pbmpipe.pbm -first.nut second.nut differ: char 113, line 1 -2c65ef7188398da8a5f107b9dd5fb998 first.nut ----------------- -./tests/data/b-pgmpipe.pgm -first.nut second.nut differ: char 113, line 1 -b7e98248ada1e6f7170bc7fedee3825c first.nut ----------------- -./tests/data/b-ppmpipe.ppm -first.nut second.nut differ: char 113, line 1 -869fcefe430c35a9a8e46fd5f040b62e first.nut diff --git a/tests/copycooker.sh b/tests/copycooker.sh deleted file mode 100755 index 3118e3f842..0000000000 --- a/tests/copycooker.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -LC_ALL=C -export LC_ALL - -datadir="tests/data" - -logfile="$datadir/copy.regression" -reffile="$1" - -list=$(grep -oh ' ./tests/data/.*' tests/ref/{acodec,lavf,vsynth1}/*| sort) -rm -f $logfile -for i in $list ; do - echo ---------------- >> $logfile - echo $i >> $logfile - ./ffmpeg -flags +bitexact -i $i -acodec copy -vcodec copy -y first.nut - ./ffmpeg -flags +bitexact -i first.nut -acodec copy -vcodec copy -y second.nut - cmp first.nut second.nut >> $logfile - md5sum first.nut >> $logfile -done - -if diff -u -w "$reffile" "$logfile" ; then - echo - echo copy regression test: success - exit 0 -else - echo - echo copy regression test: error - exit 1 -fi From f9853c1b9c4b4a0b8599e4dbce292586e87100cc Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 26 Apr 2011 14:28:45 +0200 Subject: [PATCH 351/780] libavdevice: Remove disabled code. --- libavdevice/oss_audio.c | 7 ------- libavdevice/x11grab.c | 15 --------------- 2 files changed, 22 deletions(-) diff --git a/libavdevice/oss_audio.c b/libavdevice/oss_audio.c index fcbe26ba93..6e25288dba 100644 --- a/libavdevice/oss_audio.c +++ b/libavdevice/oss_audio.c @@ -80,13 +80,6 @@ static int audio_open(AVFormatContext *s1, int is_output, const char *audio_devi fcntl(audio_fd, F_SETFL, O_NONBLOCK); s->frame_size = AUDIO_BLOCK_SIZE; -#if 0 - tmp = (NB_FRAGMENTS << 16) | FRAGMENT_BITS; - err = ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &tmp); - if (err < 0) { - perror("SNDCTL_DSP_SETFRAGMENT"); - } -#endif /* select format : favour native format */ err = ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &tmp); diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 6e77a5c52a..62cb4f1a4f 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -217,21 +217,6 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) } break; case 32: -#if 0 - GetColorInfo (image, &c_info); - if ( c_info.alpha_mask == 0xff000000 && image->green_mask == 0x0000ff00) { - /* byte order is relevant here, not endianness - * endianness is handled by avcodec, but atm no such thing - * as having ABGR, instead of ARGB in a word. Since we - * need this for Solaris/SPARC, but need to do the conversion - * for every frame we do it outside of this loop, cf. below - * this matches both ARGB32 and ABGR32 */ - input_pixfmt = PIX_FMT_ARGB32; - } else { - av_log(s1, AV_LOG_ERROR,"image depth %i not supported ... aborting\n", image->bits_per_pixel); - return AVERROR(EIO); - } -#endif input_pixfmt = PIX_FMT_RGB32; break; default: From 8886d752636ab7b7fbe374061dbe24946ea95d18 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 7 Jul 2011 01:30:59 +0200 Subject: [PATCH 352/780] libschroedingerdec: Remove write-only variable. libavcodec/libschroedingerdec.c:211:23: warning: variable 'format' set but not used --- libavcodec/libschroedingerdec.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index ee29704d92..7e6846d5d1 100644 --- a/libavcodec/libschroedingerdec.c +++ b/libavcodec/libschroedingerdec.c @@ -208,7 +208,6 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; SchroDecoder *decoder = p_schro_params->decoder; - SchroVideoFormat *format; AVPicture *picture = data; SchroBuffer *enc_buf; SchroFrame* frame; @@ -240,7 +239,6 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, go = 1; } else outer = 0; - format = p_schro_params->format; while (go) { /* Parse data and process result. */ From 91fe776913d6525e2a7f582e4d5e21f517a09f0f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 01:00:10 +0200 Subject: [PATCH 353/780] flashsv: improve some variable names --- libavcodec/flashsv.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 578e713157..70c160ecd4 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -152,14 +152,13 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* loop over all block columns */ for (j = 0; j < v_blocks + (v_part ? 1 : 0); j++) { - int hp = j * s->block_height; // vertical position in frame - int hs = (j < v_blocks) ? s->block_height : v_part; // block size - + int y_pos = j * s->block_height; // vertical position in frame + int cur_blk_height = (j < v_blocks) ? s->block_height : v_part; /* loop over all block rows */ for (i = 0; i < h_blocks + (h_part ? 1 : 0); i++) { - int wp = i * s->block_width; // horizontal position in frame - int ws = (i < h_blocks) ? s->block_width : h_part; // block size + int x_pos = i * s->block_width; // horizontal position in frame + int cur_blk_width = (i < h_blocks) ? s->block_width : h_part; /* get the size of the compressed zlib chunk */ int size = get_bits(&gb, 16); @@ -195,8 +194,9 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* return -1; */ } copy_region(s->tmpblock, s->frame.data[0], - s->image_height - (hp + hs + 1), - wp, hs, ws, s->frame.linesize[0]); + s->image_height - (y_pos + cur_blk_height + 1), + x_pos, cur_blk_height, cur_blk_width, + s->frame.linesize[0]); skip_bits_long(&gb, 8 * size); /* skip the consumed bits */ } } From 4904995652dbbfc7cb37fef9656b9b86f53449f7 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 27 Jun 2011 00:46:29 +0200 Subject: [PATCH 354/780] avutil: Add missing test programs to Makefile. --- libavutil/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavutil/Makefile b/libavutil/Makefile index c07217b803..cfe7bae222 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -75,7 +75,8 @@ OBJS-$(ARCH_ARM) += arm/cpu.o OBJS-$(ARCH_PPC) += ppc/cpu.o OBJS-$(ARCH_X86) += x86/cpu.o -TESTPROGS = adler32 aes base64 cpu crc des eval lls md5 sha tree +TESTPROGS = adler32 aes avstring base64 cpu crc des eval file lfg lls \ + md5 opt parseutils rational sha tree TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo DIRS = arm bfin sh4 x86 From 51915cfa47e3fba1778673a0772070eaf2a9b742 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 30 Jun 2011 00:59:13 +0200 Subject: [PATCH 355/780] flashsv: inline copy_region() into flashsv_decode_frame() --- libavcodec/flashsv.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 70c160ecd4..e1033a84cc 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -49,18 +49,6 @@ typedef struct FlashSVContext { } FlashSVContext; -static void copy_region(uint8_t *sptr, uint8_t *dptr, - int dx, int dy, int h, int w, int stride) -{ - int i; - - for (i = dx + h; i > dx; i--) { - memcpy(dptr + i * stride + dy * 3, sptr, w * 3); - sptr += w * 3; - } -} - - static av_cold int flashsv_decode_init(AVCodecContext *avctx) { FlashSVContext *s = avctx->priv_data; @@ -171,6 +159,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* skip unchanged blocks, which have size 0 */ if (size) { /* decompress block */ + uint8_t *line = s->tmpblock; + int k; int ret = inflateReset(&s->zstream); if (ret != Z_OK) { av_log(avctx, AV_LOG_ERROR, @@ -193,10 +183,15 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, "error in decompression of block %dx%d: %d\n", i, j, ret); /* return -1; */ } - copy_region(s->tmpblock, s->frame.data[0], - s->image_height - (y_pos + cur_blk_height + 1), - x_pos, cur_blk_height, cur_blk_width, - s->frame.linesize[0]); + /* Flash Screen Video stores the image upside down, so copy + * lines to destination in reverse order. */ + for (k = 1; k <= cur_blk_height; k++) { + memcpy(s->frame.data[0] + x_pos * 3 + + (s->image_height - y_pos - k) * s->frame.linesize[0], + line, cur_blk_width * 3); + /* advance source pointer to next line */ + line += cur_blk_width * 3; + } skip_bits_long(&gb, 8 * size); /* skip the consumed bits */ } } From a953577b46fdaf4655d110c60925c2fc331f9c17 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 5 Jul 2011 17:22:56 +0200 Subject: [PATCH 356/780] examples: move metadata-example.c to doc/examples --- doc/examples/Makefile | 2 +- libavformat/metadata-example.c => doc/examples/metadata.c | 1 - libavformat/Makefile | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) rename libavformat/metadata-example.c => doc/examples/metadata.c (97%) diff --git a/doc/examples/Makefile b/doc/examples/Makefile index 4561b10bad..f8abdff4e3 100644 --- a/doc/examples/Makefile +++ b/doc/examples/Makefile @@ -3,7 +3,7 @@ FFMPEG_LIBS=libavdevice libavformat libavfilter libavcodec libswscale libavutil CFLAGS+=$(shell pkg-config --cflags $(FFMPEG_LIBS)) LDFLAGS+=$(shell pkg-config --libs $(FFMPEG_LIBS)) -EXAMPLES=encoding muxing +EXAMPLES=encoding metadata muxing OBJS=$(addsuffix .o,$(EXAMPLES)) diff --git a/libavformat/metadata-example.c b/doc/examples/metadata.c similarity index 97% rename from libavformat/metadata-example.c rename to doc/examples/metadata.c index 7bf77e7378..7d29be7049 100644 --- a/libavformat/metadata-example.c +++ b/doc/examples/metadata.c @@ -22,7 +22,6 @@ /** * @file - * @example libavformat/metadata-example.c * Shows how the metadata API can be used in application programs. */ diff --git a/libavformat/Makefile b/libavformat/Makefile index 27a6a9b08e..6d7a342c9e 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -341,7 +341,6 @@ OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o OBJS-$(CONFIG_ALSA_INDEV) += timefilter.o OBJS-$(CONFIG_JACK_INDEV) += timefilter.o -EXAMPLES = metadata TESTPROGS = timefilter include $(SRC_PATH)/subdir.mak From ecf86e1a97b8cbb1ae6e0ed12825187c5cc00de0 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 8 Jul 2011 13:58:15 +0100 Subject: [PATCH 357/780] dnxhd: prettify tables Signed-off-by: Mans Rullgard --- libavcodec/dnxhddata.c | 610 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 574 insertions(+), 36 deletions(-) diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c index 82d083c1e2..642b22fb5d 100644 --- a/libavcodec/dnxhddata.c +++ b/libavcodec/dnxhddata.c @@ -108,7 +108,7 @@ static const uint8_t dnxhd_1242_chroma_weight[] = { 48, 49, 51, 51, 52, 52, 54, 54, 49, 49, 52, 53, 54, 54, 53, 53, 55, 59, 63, 62, 60, 60, 60, 60, - }; +}; static const uint8_t dnxhd_1243_luma_weight[] = { 0, 32, 32, 33, 33, 35, 35, 35, @@ -184,35 +184,144 @@ static const uint8_t dnxhd_1237_dc_bits[12] = { }; static const uint16_t dnxhd_1237_ac_codes[257] = { - 0, 1, 4, 5, 12, 26, 27, 56, 57, 58, 59, 120, 121, 244, 245, 246, 247, 248, 498, 499, 500, 501, 502, 1006, 1007, 1008, 1009, 1010, 1011, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 4064, 4065, 4066, 4067, 4068, 4069, 4070, 4071, 4072, 4073, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 8157, 8158, 16318, 16319, 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 32668, 32669, 32670, 32671, 32672, 32673, 32674, 32675, 32676, 32677, 32678, 32679, 32680, 32681, 32682, 32683, 32684, 65370, 65371, 65372, 65373, 65374, 65375, 65376, 65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392, 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400, 65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535, + 0, 1, 4, 5, 12, 26, 27, 56, + 57, 58, 59, 120, 121, 244, 245, 246, + 247, 248, 498, 499, 500, 501, 502, 1006, + 1007, 1008, 1009, 1010, 1011, 2024, 2025, 2026, + 2027, 2028, 2029, 2030, 2031, 4064, 4065, 4066, + 4067, 4068, 4069, 4070, 4071, 4072, 4073, 8148, + 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, + 8157, 8158, 16318, 16319, 16320, 16321, 16322, 16323, + 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, + 16332, 16333, 32668, 32669, 32670, 32671, 32672, 32673, + 32674, 32675, 32676, 32677, 32678, 32679, 32680, 32681, + 32682, 32683, 32684, 65370, 65371, 65372, 65373, 65374, + 65375, 65376, 65377, 65378, 65379, 65380, 65381, 65382, + 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, + 65391, 65392, 65393, 65394, 65395, 65396, 65397, 65398, + 65399, 65400, 65401, 65402, 65403, 65404, 65405, 65406, + 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, + 65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422, + 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, + 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, + 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, + 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, + 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, + 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, + 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, + 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, + 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, + 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, + 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, + 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, + 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, + 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, + 65535, }; static const uint8_t dnxhd_1237_ac_bits[257] = { - 2, 2, 3, 3, 4, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 2, 2, 3, 3, 4, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, + 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, + 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, }; static const uint8_t dnxhd_1237_ac_level[257] = { - 1, 1, 2, 0, 3, 4, 2, 5, 6, 7, 3, 8, 9, 10, 11, 12, 4, 5, 13, 14, 15, 16, 6, 17, 18, 19, 20, 21, 7, 22, 23, 24, 25, 26, 27, 8, 9, 28, 29, 30, 31, 32, 33, 34, 10, 11, 12, 35, 36, 37, 38, 39, 40, 41, 13, 14, 15, 16, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 17, 18, 19, 20, 21, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 1, 22, 23, 24, 25, 26, 27, 62, 63, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 1, 1, 2, 0, 3, 4, 2, 5, 6, 7, 3, 8, 9, 10, 11, 12, + 4, 5, 13, 14, 15, 16, 6, 17, 18, 19, 20, 21, 7, 22, 23, 24, + 25, 26, 27, 8, 9, 28, 29, 30, 31, 32, 33, 34, 10, 11, 12, 35, + 36, 37, 38, 39, 40, 41, 13, 14, 15, 16, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 17, 18, 19, 20, 21, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 64, 1, 22, 23, 24, 25, 26, 27, 62, 63, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, }; static const uint8_t dnxhd_1237_ac_run_flag[257] = { - 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, }; static const uint8_t dnxhd_1237_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, }; static const uint16_t dnxhd_1237_run_codes[62] = { - 0, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 58, 118, 119, 240, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, + 0, 4, 10, 11, 24, 25, 26, 54, + 55, 56, 57, 58, 118, 119, 240, 482, + 483, 484, 485, 486, 487, 488, 489, 490, + 491, 492, 493, 494, 990, 991, 992, 993, + 994, 995, 996, 997, 998, 999, 1000, 1001, + 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, + 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, + 1018, 1019, 1020, 1021, 1022, 1023, }; static const uint8_t dnxhd_1237_run_bits[62] = { - 1, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 1, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 8, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, }; static const uint8_t dnxhd_1237_run[62] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 53, 57, 58, 59, 60, 61, 62, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 55, 56, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 53, 57, 58, 59, 60, 61, 62, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 55, 56, }; static const uint8_t dnxhd_1238_dc_codes[12] = { @@ -224,35 +333,144 @@ static const uint8_t dnxhd_1238_dc_bits[12] = { }; static const uint16_t dnxhd_1238_ac_codes[257] = { - 0, 1, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 116, 117, 118, 119, 240, 241, 242, 243, 244, 245, 492, 493, 494, 495, 496, 497, 498, 499, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 8140, 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 16314, 16315, 16316, 16317, 16318, 16319, 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, 16336, 16337, 16338, 32678, 32679, 32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693, 32694, 32695, 32696, 32697, 32698, 32699, 32700, 32701, 32702, 32703, 32704, 32705, 65412, 65413, 65414, 65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535, + 0, 1, 4, 10, 11, 24, 25, 26, + 54, 55, 56, 57, 116, 117, 118, 119, + 240, 241, 242, 243, 244, 245, 492, 493, + 494, 495, 496, 497, 498, 499, 1000, 1001, + 1002, 1003, 1004, 1005, 1006, 1007, 1008, 2018, + 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, + 2027, 4056, 4057, 4058, 4059, 4060, 4061, 4062, + 4063, 4064, 4065, 4066, 4067, 4068, 4069, 8140, + 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, + 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, + 16314, 16315, 16316, 16317, 16318, 16319, 16320, 16321, + 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, + 16330, 16331, 16332, 16333, 16334, 16335, 16336, 16337, + 16338, 32678, 32679, 32680, 32681, 32682, 32683, 32684, + 32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692, + 32693, 32694, 32695, 32696, 32697, 32698, 32699, 32700, + 32701, 32702, 32703, 32704, 32705, 65412, 65413, 65414, + 65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422, + 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, + 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, + 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, + 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, + 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, + 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, + 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, + 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, + 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, + 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, + 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, + 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, + 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, + 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, + 65535, }; static const uint8_t dnxhd_1238_ac_bits[257] = { - 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, }; static const uint8_t dnxhd_1238_ac_level[257] = { - 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 22, 6, 7, 23, 24, 25, 26, 27, 28, 29, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 10, 11, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 12, 13, 14, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 15, 16, 17, 18, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 40, 25, 26, 27, 28, 29, 30, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, + 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 22, 6, 7, 23, 24, + 25, 26, 27, 28, 29, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 10, + 11, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 12, 13, 14, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 15, 16, 17, 18, + 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 19, 20, 21, 22, 23, 24, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 40, 25, + 26, 27, 28, 29, 30, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, }; /* 0 is EOB */ static const uint8_t dnxhd_1238_ac_run_flag[257] = { - 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, }; static const uint8_t dnxhd_1238_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, }; static const uint16_t dnxhd_1238_run_codes[62] = { - 0, 4, 10, 11, 24, 25, 26, 27, 56, 57, 58, 59, 120, 242, 486, 487, 488, 489, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, + 0, 4, 10, 11, 24, 25, 26, 27, + 56, 57, 58, 59, 120, 242, 486, 487, + 488, 489, 980, 981, 982, 983, 984, 985, + 986, 987, 988, 989, 990, 991, 992, 993, + 994, 995, 996, 997, 998, 999, 1000, 1001, + 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, + 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, + 1018, 1019, 1020, 1021, 1022, 1023, }; static const uint8_t dnxhd_1238_run_bits[62] = { - 1, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 1, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 8, 9, 9, + 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, }; static const uint8_t dnxhd_1238_run[62] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 21, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 20, 21, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, }; static const uint8_t dnxhd_1241_dc_codes[14] = { @@ -262,81 +480,401 @@ static const uint8_t dnxhd_1241_dc_codes[14] = { static const uint8_t dnxhd_1241_dc_bits[14] = { 4, 6, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 7, 7, }; + static const uint16_t dnxhd_1241_ac_codes[257] = { - 0, 1, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 116, 117, 118, 119, 240, 241, 242, 243, 244, 245, 492, 493, 494, 495, 496, 497, 498, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 4054, 4055, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 8140, 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 8157, 16316, 16317, 16318, 16319, 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, 16336, 16337, 32676, 32677, 32678, 32679, 32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693, 32694, 32695, 32696, 32697, 32698, 32699, 32700, 32701, 32702, 32703, 32704, 32705, 32706, 32707, 32708, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535, + 0, 1, 4, 10, 11, 24, 25, 26, + 54, 55, 56, 57, 116, 117, 118, 119, + 240, 241, 242, 243, 244, 245, 492, 493, + 494, 495, 496, 497, 498, 998, 999, 1000, + 1001, 1002, 1003, 1004, 1005, 1006, 1007, 2016, + 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, + 2025, 2026, 4054, 4055, 4056, 4057, 4058, 4059, + 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, + 4068, 4069, 8140, 8141, 8142, 8143, 8144, 8145, + 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, + 8154, 8155, 8156, 8157, 16316, 16317, 16318, 16319, + 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, + 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, + 16336, 16337, 32676, 32677, 32678, 32679, 32680, 32681, + 32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689, + 32690, 32691, 32692, 32693, 32694, 32695, 32696, 32697, + 32698, 32699, 32700, 32701, 32702, 32703, 32704, 32705, + 32706, 32707, 32708, 65418, 65419, 65420, 65421, 65422, + 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, + 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, + 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, + 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, + 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, + 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, + 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, + 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, + 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, + 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, + 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, + 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, + 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, + 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, + 65535, }; static const uint8_t dnxhd_1241_ac_bits[257] = { - 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, }; static const uint8_t dnxhd_1241_ac_level[257] = { - 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 6, 7, 22, 23, 24, 25, 26, 27, 28, 29, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 38, 10, 11, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 12, 13, 14, 15, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 1, 16, 17, 18, 19, 64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 25, 26, 27, 28, 29, 30, 31, 32, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, + 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 6, 7, 22, 23, 24, + 25, 26, 27, 28, 29, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 10, 11, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 12, 13, + 14, 15, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 1, + 16, 17, 18, 19, 64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 25, 26, 27, 28, 29, 30, 31, 32, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, }; static const uint8_t dnxhd_1241_ac_run_flag[257] = { - 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, }; static const uint8_t dnxhd_1241_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, }; static const uint8_t dnxhd_1241_run[62] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 17, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 18, 20, 17, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, }; static const uint8_t dnxhd_1251_dc_codes[12] = { 0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63, }; + static const uint8_t dnxhd_1251_dc_bits[12] = { 3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6, }; + static const uint16_t dnxhd_1251_ac_codes[257] = { - 0, 1, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 116, 117, 118, 119, 240, 241, 242, 243, 244, 245, 492, 493, 494, 495, 496, 497, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 4052, 4053, 4054, 4055, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 8134, 8135, 8136, 8137, 8138, 8139, 8140, 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 16314, 16315, 16316, 16317, 16318, 16319, 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, 16336, 16337, 16338, 16339, 32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693, 32694, 32695, 32696, 32697, 32698, 32699, 32700, 32701, 32702, 32703, 32704, 32705, 32706, 32707, 32708, 32709, 32710, 32711, 32712, 32713, 32714, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535, + 0, 1, 4, 10, 11, 24, 25, 26, + 54, 55, 56, 57, 116, 117, 118, 119, + 240, 241, 242, 243, 244, 245, 492, 493, + 494, 495, 496, 497, 996, 997, 998, 999, + 1000, 1001, 1002, 1003, 1004, 1005, 2012, 2013, + 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, + 2022, 2023, 2024, 2025, 4052, 4053, 4054, 4055, + 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, + 4064, 4065, 4066, 8134, 8135, 8136, 8137, 8138, + 8139, 8140, 8141, 8142, 8143, 8144, 8145, 8146, + 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, + 8155, 8156, 16314, 16315, 16316, 16317, 16318, 16319, + 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, + 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, + 16336, 16337, 16338, 16339, 32680, 32681, 32682, 32683, + 32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691, + 32692, 32693, 32694, 32695, 32696, 32697, 32698, 32699, + 32700, 32701, 32702, 32703, 32704, 32705, 32706, 32707, + 32708, 32709, 32710, 32711, 32712, 32713, 32714, 65430, + 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, + 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, + 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, + 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, + 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, + 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, + 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, + 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, + 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, + 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, + 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, + 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, + 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, + 65535, }; + static const uint8_t dnxhd_1251_ac_bits[257] = { - 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, }; + static const uint8_t dnxhd_1251_ac_level[257] = { - 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 6, 22, 23, 24, 25, 26, 27, 28, 29, 7, 8, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 9, 10, 11, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 12, 13, 14, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, 17, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 18, 19, 20, 21, 22, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 23, 24, 25, 26, 27, 28, 59, 60, 61, 62, 63, 64, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, + 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 6, 22, 23, 24, 25, + 26, 27, 28, 29, 7, 8, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 9, 10, 11, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 12, 13, 14, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, + 2, 3, 4, 5, 6, 7, 8, 15, 16, 17, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 18, + 19, 20, 21, 22, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 23, 24, 25, 26, 27, 28, 59, 60, 61, 62, 63, 64, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, }; + static const uint8_t dnxhd_1251_ac_run_flag[257] = { - 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, }; + static const uint8_t dnxhd_1251_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, }; + static const uint16_t dnxhd_1251_run_codes[62] = { - 0, 4, 5, 12, 26, 27, 28, 58, 118, 119, 120, 242, 486, 487, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, + 0, 4, 5, 12, 26, 27, 28, 58, + 118, 119, 120, 242, 486, 487, 976, 977, + 978, 979, 980, 981, 982, 983, 984, 985, + 986, 987, 988, 989, 990, 991, 992, 993, + 994, 995, 996, 997, 998, 999, 1000, 1001, + 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, + 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, + 1018, 1019, 1020, 1021, 1022, 1023, }; + static const uint8_t dnxhd_1251_run_bits[62] = { - 1, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 1, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7, 8, 9, 9, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, }; + static const uint8_t dnxhd_1251_run[62] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, }; static const uint8_t dnxhd_1252_dc_codes[12] = { 0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63, }; + static const uint8_t dnxhd_1252_dc_bits[12] = { 3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6, }; + static const uint16_t dnxhd_1252_ac_codes[257] = { - 0, 1, 4, 10, 11, 12, 26, 27, 56, 57, 58, 118, 119, 120, 242, 243, 244, 245, 246, 247, 496, 497, 498, 499, 500, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 4070, 4071, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 8157, 8158, 16318, 16319, 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, 32672, 32673, 32674, 32675, 32676, 32677, 32678, 32679, 32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693, 32694, 65390, 65391, 65392, 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400, 65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535, + 0, 1, 4, 10, 11, 12, 26, 27, + 56, 57, 58, 118, 119, 120, 242, 243, + 244, 245, 246, 247, 496, 497, 498, 499, + 500, 1002, 1003, 1004, 1005, 1006, 1007, 1008, + 1009, 2020, 2021, 2022, 2023, 2024, 2025, 2026, + 2027, 2028, 2029, 4060, 4061, 4062, 4063, 4064, + 4065, 4066, 4067, 4068, 4069, 4070, 4071, 8144, + 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, + 8153, 8154, 8155, 8156, 8157, 8158, 16318, 16319, + 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, + 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, + 32672, 32673, 32674, 32675, 32676, 32677, 32678, 32679, + 32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687, + 32688, 32689, 32690, 32691, 32692, 32693, 32694, 65390, + 65391, 65392, 65393, 65394, 65395, 65396, 65397, 65398, + 65399, 65400, 65401, 65402, 65403, 65404, 65405, 65406, + 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, + 65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422, + 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, + 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, + 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, + 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, + 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, + 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, + 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, + 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, + 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, + 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, + 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, + 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, + 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, + 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, + 65535, }; + static const uint8_t dnxhd_1252_ac_bits[257] = { - 2, 2, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 2, 2, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, + 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, }; + static const uint8_t dnxhd_1252_ac_level[257] = { - 1, 1, 2, 3, 2, 0, 4, 5, 6, 7, 3, 8, 9, 10, 11, 12, 13, 14, 4, 5, 15, 16, 17, 18, 6, 19, 20, 21, 22, 23, 24, 7, 8, 25, 26, 27, 28, 29, 30, 31, 32, 9, 10, 33, 34, 35, 36, 37, 38, 39, 40, 41, 11, 12, 13, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 14, 15, 16, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 17, 18, 19, 20, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 1, 1, 2, 3, 2, 0, 4, 5, 6, 7, 3, 8, 9, 10, 11, 12, + 13, 14, 4, 5, 15, 16, 17, 18, 6, 19, 20, 21, 22, 23, 24, 7, + 8, 25, 26, 27, 28, 29, 30, 31, 32, 9, 10, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 11, 12, 13, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 14, 15, 16, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 1, 2, 3, 17, 18, 19, 20, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, }; + static const uint8_t dnxhd_1252_ac_run_flag[257] = { - 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, }; + static const uint8_t dnxhd_1252_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, }; const CIDEntry ff_dnxhd_cid_table[] = { From b369f327d5e6b01a4cae9e2726df7c73b2893eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 8 Jul 2011 11:00:01 +0300 Subject: [PATCH 358/780] docs: Mention the upstream bugzilla url about the dlltool vs MSVC issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- doc/general.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/general.texi b/doc/general.texi index 93f563e1bf..fbb36c9f6e 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -989,6 +989,8 @@ the linker optimization option to be set to "References: Keep Unreferenced Data (/OPT:NOREF)", otherwise the resulting binaries will fail during runtime. This isn't required when using import libraries generated by lib.exe. +This issue is reported upstream at +@url{http://sourceware.org/bugzilla/show_bug.cgi?id=12633}. @subsection Cross compilation for Windows with Linux From e4e3cdc6363b45213d79fd1467ff55dab3cd2bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 8 Jul 2011 11:14:14 +0300 Subject: [PATCH 359/780] docs: Remove old docs that mention setting up a build environment with lib.exe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The build system doesn't use lib.exe any longer, and therefore this can be simplified. Signed-off-by: Martin Storsjö --- doc/general.texi | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index fbb36c9f6e..95af68e9a9 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -923,30 +923,7 @@ Libav, so you must add this line before @code{#include}ing libav*: This is how to create DLL and LIB files that are compatible with MSVC++: -@enumerate - -@item Add a call to @file{vcvars32.bat} (which sets up the environment -variables for the Visual C++ tools) as the first line of @file{msys.bat}. -The standard location for @file{vcvars32.bat} is -@file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat}, -and the standard location for @file{msys.bat} is @file{C:\msys\1.0\msys.bat}. -If this corresponds to your setup, add the following line as the first line -of @file{msys.bat}: - -@example -call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" -@end example - -Alternatively, you may start the @file{Visual Studio 2005 Command Prompt}, -and run @file{c:\msys\1.0\msys.bat} from there. - -@item Within the MSYS shell, run @code{lib.exe}. If you get a help message -from @file{Microsoft (R) Library Manager}, this means your environment -variables are set up correctly, the @file{Microsoft (R) Library Manager} -is on the path and will be used by Libav to create -MSVC++-compatible import libraries. - -@item Build Libav with +Within the MSYS shell, build Libav with @example ./configure --enable-shared @@ -957,8 +934,6 @@ make install Your install path (@file{/usr/local/} by default) should now have the necessary DLL and LIB files under the @file{bin} directory. -@end enumerate - To use those files with MSVC++, do the same as you would do with the static libraries, as described above. But in Step 4, you should only need to add the directory where the LIB files are installed From b8272cc2cff052c953a0727e9ffc6d55a8d3037f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 8 Jul 2011 11:15:00 +0300 Subject: [PATCH 360/780] docs: Mention that libraries for MSVC can be built with a cross compiler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- doc/general.texi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/general.texi b/doc/general.texi index 95af68e9a9..c950fcb131 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -934,6 +934,9 @@ make install Your install path (@file{/usr/local/} by default) should now have the necessary DLL and LIB files under the @file{bin} directory. +Alternatively, build the libraries with a cross compiler, according to +the instructions below in @ref{Cross compilation for Windows with Linux}. + To use those files with MSVC++, do the same as you would do with the static libraries, as described above. But in Step 4, you should only need to add the directory where the LIB files are installed @@ -967,6 +970,7 @@ required when using import libraries generated by lib.exe. This issue is reported upstream at @url{http://sourceware.org/bugzilla/show_bug.cgi?id=12633}. +@anchor{Cross compilation for Windows with Linux} @subsection Cross compilation for Windows with Linux You must use the MinGW cross compilation tools available at From 37e6e6d3130ad0f93d3f5d040e41998d56bbf012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 8 Jul 2011 11:16:32 +0300 Subject: [PATCH 361/780] docs: Explain how to regenerate import libraries with MSVC tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- doc/general.texi | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/general.texi b/doc/general.texi index c950fcb131..814dc5f619 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -970,6 +970,34 @@ required when using import libraries generated by lib.exe. This issue is reported upstream at @url{http://sourceware.org/bugzilla/show_bug.cgi?id=12633}. +To create import libraries that work with the @code{/OPT:REF} option +(which is enabled by default in Release mode), follow these steps: + +@enumerate + +@item Open @file{Visual Studio 2005 Command Prompt}. + +Alternatively, in a normal command line prompt, call @file{vcvars32.bat} +which sets up the environment variables for the Visual C++ tools +(the standard location for this file is +@file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat}). + +@item Enter the @file{bin} directory where the created LIB and DLL files +are stored. + +@item Generate new import libraries with @file{lib.exe}: + +@example +lib /machine:i386 /def:..\lib\avcodec-53.def /out:avcodec.lib +lib /machine:i386 /def:..\lib\avdevice-53.def /out:avdevice.lib +lib /machine:i386 /def:..\lib\avfilter-2.def /out:avfilter.lib +lib /machine:i386 /def:..\lib\avformat-53.def /out:avformat.lib +lib /machine:i386 /def:..\lib\avutil-51.def /out:avutil.lib +lib /machine:i386 /def:..\lib\swscale-2.def /out:swscale.lib +@end example + +@end enumerate + @anchor{Cross compilation for Windows with Linux} @subsection Cross compilation for Windows with Linux From a0db0b302c98b7a1fe821771371685a744c23502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 8 Jul 2011 11:18:13 +0300 Subject: [PATCH 362/780] docs: Remove a remark that isn't relevant any longer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now the bin directory only contains those DLLs that are actually used. Signed-off-by: Martin Storsjö --- doc/general.texi | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index 814dc5f619..3459277dad 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -948,10 +948,7 @@ libraries (@file{libxxx.a} files) you should add the MSVC import libraries libraries (@file{libxxx.dll.a} files), as these will give you undefined reference errors. There should be no need for @file{libmingwex.a}, @file{libgcc.a}, and @file{wsock32.lib}, nor any other external library -statically linked into the DLLs. The @file{bin} directory contains a bunch -of DLL files, but the ones that are actually used to run your application -are the ones with a major version number in their filenames -(i.e. @file{avcodec-51.dll}). +statically linked into the DLLs. Libav headers do not declare global data for Windows DLLs through the usual dllexport/dllimport interface. Such data will be exported properly while From a3a94e1498685480800c22fc3ffa20d42ccfd527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 8 Jul 2011 13:37:54 +0300 Subject: [PATCH 363/780] docs: Use proper markup for a literal command line option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- doc/general.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/general.texi b/doc/general.texi index 3459277dad..c97a7575c8 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -961,7 +961,7 @@ extern __declspec(dllimport) const AVPixFmtDescriptor av_pix_fmt_descriptors[]; Note that using import libraries created by dlltool requires the linker optimization option to be set to -"References: Keep Unreferenced Data (/OPT:NOREF)", otherwise +"References: Keep Unreferenced Data (@code{/OPT:NOREF})", otherwise the resulting binaries will fail during runtime. This isn't required when using import libraries generated by lib.exe. This issue is reported upstream at From fdaf1d0640af0da11005a483de8533803a6ae42d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 8 Jul 2011 12:52:12 +0100 Subject: [PATCH 364/780] lls: whitespace cosmetics Signed-off-by: Mans Rullgard --- libavutil/lls.c | 127 +++++++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 56 deletions(-) diff --git a/libavutil/lls.c b/libavutil/lls.c index 679738530d..eba7375854 100644 --- a/libavutil/lls.c +++ b/libavutil/lls.c @@ -30,76 +30,88 @@ #include "lls.h" -void av_init_lls(LLSModel *m, int indep_count){ +void av_init_lls(LLSModel *m, int indep_count) +{ memset(m, 0, sizeof(LLSModel)); - - m->indep_count= indep_count; + m->indep_count = indep_count; } -void av_update_lls(LLSModel *m, double *var, double decay){ - int i,j; +void av_update_lls(LLSModel *m, double *var, double decay) +{ + int i, j; - for(i=0; i<=m->indep_count; i++){ - for(j=i; j<=m->indep_count; j++){ + for (i = 0; i <= m->indep_count; i++) { + for (j = i; j <= m->indep_count; j++) { m->covariance[i][j] *= decay; - m->covariance[i][j] += var[i]*var[j]; + m->covariance[i][j] += var[i] * var[j]; } } } -void av_solve_lls(LLSModel *m, double threshold, int min_order){ - int i,j,k; - double (*factor)[MAX_VARS+1]= (void*)&m->covariance[1][0]; - double (*covar )[MAX_VARS+1]= (void*)&m->covariance[1][1]; - double *covar_y = m->covariance[0]; - int count= m->indep_count; +void av_solve_lls(LLSModel *m, double threshold, int min_order) +{ + int i, j, k; + double (*factor)[MAX_VARS + 1] = (void *) &m->covariance[1][0]; + double (*covar) [MAX_VARS + 1] = (void *) &m->covariance[1][1]; + double *covar_y = m->covariance[0]; + int count = m->indep_count; - for(i=0; i=0; k--) - sum -= factor[i][k]*factor[j][k]; + for (k = i - 1; k >= 0; k--) + sum -= factor[i][k] * factor[j][k]; - if(i==j){ - if(sum < threshold) - sum= 1.0; - factor[i][i]= sqrt(sum); - }else - factor[j][i]= sum / factor[i][i]; + if (i == j) { + if (sum < threshold) + sum = 1.0; + factor[i][i] = sqrt(sum); + } else { + factor[j][i] = sum / factor[i][i]; + } } } - for(i=0; i=0; k--) - sum -= factor[i][k]*m->coeff[0][k]; - m->coeff[0][i]= sum / factor[i][i]; + + for (i = 0; i < count; i++) { + double sum = covar_y[i + 1]; + + for (k = i - 1; k >= 0; k--) + sum -= factor[i][k] * m->coeff[0][k]; + + m->coeff[0][i] = sum / factor[i][i]; } - for(j=count-1; j>=min_order; j--){ - for(i=j; i>=0; i--){ - double sum= m->coeff[0][i]; - for(k=i+1; k<=j; k++) - sum -= factor[k][i]*m->coeff[j][k]; - m->coeff[j][i]= sum / factor[i][i]; + for (j = count - 1; j >= min_order; j--) { + for (i = j; i >= 0; i--) { + double sum = m->coeff[0][i]; + + for (k = i + 1; k <= j; k++) + sum -= factor[k][i] * m->coeff[j][k]; + + m->coeff[j][i] = sum / factor[i][i]; } - m->variance[j]= covar_y[0]; - for(i=0; i<=j; i++){ - double sum= m->coeff[j][i]*covar[i][i] - 2*covar_y[i+1]; - for(k=0; kcoeff[j][k]*covar[k][i]; - m->variance[j] += m->coeff[j][i]*sum; + m->variance[j] = covar_y[0]; + + for (i = 0; i <= j; i++) { + double sum = m->coeff[j][i] * covar[i][i] - 2 * covar_y[i + 1]; + + for (k = 0; k < i; k++) + sum += 2 * m->coeff[j][k] * covar[k][i]; + + m->variance[j] += m->coeff[j][i] * sum; } } } -double av_evaluate_lls(LLSModel *m, double *param, int order){ +double av_evaluate_lls(LLSModel *m, double *param, int order) +{ int i; - double out= 0; + double out = 0; - for(i=0; i<=order; i++) - out+= param[i]*m->coeff[order][i]; + for (i = 0; i <= order; i++) + out += param[i] * m->coeff[order][i]; return out; } @@ -109,26 +121,29 @@ double av_evaluate_lls(LLSModel *m, double *param, int order){ #include #include -int main(void){ +int main(void) +{ LLSModel m; int i, order; av_init_lls(&m, 3); - for(i=0; i<100; i++){ + for (i = 0; i < 100; i++) { double var[4]; double eval; - var[0] = (rand() / (double)RAND_MAX - 0.5)*2; - var[1] = var[0] + rand() / (double)RAND_MAX - 0.5; - var[2] = var[1] + rand() / (double)RAND_MAX - 0.5; - var[3] = var[2] + rand() / (double)RAND_MAX - 0.5; + + var[0] = (rand() / (double) RAND_MAX - 0.5) * 2; + var[1] = var[0] + rand() / (double) RAND_MAX - 0.5; + var[2] = var[1] + rand() / (double) RAND_MAX - 0.5; + var[3] = var[2] + rand() / (double) RAND_MAX - 0.5; av_update_lls(&m, var, 0.99); av_solve_lls(&m, 0.001, 0); - for(order=0; order<3; order++){ - eval= av_evaluate_lls(&m, var+1, order); + for (order = 0; order < 3; order++) { + eval = av_evaluate_lls(&m, var + 1, order); printf("real:%9f order:%d pred:%9f var:%f coeffs:%f %9f %9f\n", - var[0], order, eval, sqrt(m.variance[order] / (i+1)), - m.coeff[order][0], m.coeff[order][1], m.coeff[order][2]); + var[0], order, eval, sqrt(m.variance[order] / (i + 1)), + m.coeff[order][0], m.coeff[order][1], + m.coeff[order][2]); } } return 0; From 8c28e01d3153edefec4469f379dd99722a4609c2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 8 Jul 2011 08:27:53 +0200 Subject: [PATCH 365/780] dict: extend documentation. --- libavutil/dict.h | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/libavutil/dict.h b/libavutil/dict.h index 397ce3852f..b0061c8475 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -25,10 +25,42 @@ #ifndef AVUTIL_DICT_H #define AVUTIL_DICT_H +/** + * @defgroup dict_api Public Dictionary API + * @{ + * Dictionaries are used for storing key:value pairs. To create + * an AVDictionary, simply pass an address of a NULL pointer to + * av_dict_set(). NULL can be used as an empty dictionary wherever + * a pointer to an AVDictionary is required. + * Use av_dict_get() to retrieve an entry or iterate over all + * entries and finally av_dict_free() to free the dictionary + * and all its contents. + * + * @code + * AVDictionary *d = NULL; // "create" an empty dictionary + * av_dict_set(&d, "foo", "bar", 0); // add an entry + * + * char *k = av_strdup("key"); // if your strings are already allocated, + * char *v = av_strdup("value"); // you can avoid copying them like this + * av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); + * + * AVDictionaryEntry *t = NULL; + * while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { + * <....> // iterate over all entries in d + * } + * + * av_dict_free(&d); + * @endcode + * + * @} + */ + #define AV_DICT_MATCH_CASE 1 #define AV_DICT_IGNORE_SUFFIX 2 -#define AV_DICT_DONT_STRDUP_KEY 4 -#define AV_DICT_DONT_STRDUP_VAL 8 +#define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been + allocated with av_malloc() and children. */ +#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been + allocated with av_malloc() and chilren. */ #define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries. #define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no delimiter is added, the strings are simply concatenated. */ @@ -74,7 +106,8 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags); /** - * Free all the memory allocated for an AVDictionary struct. + * Free all the memory allocated for an AVDictionary struct + * and all keys and values. */ void av_dict_free(AVDictionary **m); From ce558c8f590610fc68596ef0b4ac2a9d299fbcb2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 20 Jun 2011 12:42:36 +0200 Subject: [PATCH 366/780] x11grab: replace undocumented nomouse hackery with a private option. --- libavdevice/x11grab.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 62cb4f1a4f..80507abb05 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -70,7 +70,7 @@ struct x11_grab XImage *image; /**< X11 image holding the grab */ int use_shm; /**< !0 when using XShm extension */ XShmSegmentInfo shminfo; /**< When using XShm, keeps track of XShm infos */ - int nomouse; + int draw_mouse; /**< Set by a private option. */ char *framerate; /**< Set by a private option. */ }; @@ -104,7 +104,7 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) offset = strchr(param, '+'); if (offset) { sscanf(offset, "%d,%d", &x_off, &y_off); - x11grab->nomouse= strstr(offset, "nomouse"); + x11grab->draw_mouse = !strstr(offset, "nomouse"); *offset= 0; } @@ -410,7 +410,7 @@ x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt) } } - if(!s->nomouse){ + if (s->draw_mouse) { paint_mouse_pointer(image, s); } @@ -451,6 +451,7 @@ x11grab_read_close(AVFormatContext *s1) static const AVOption options[] = { { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC }, { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, + { "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), FF_OPT_TYPE_INT, { 1 }, 0, 1, DEC }, { NULL }, }; From a726d7fd4e0b112b276678ea9da9c9b3097e8b8f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 6 Jul 2011 19:56:58 +0200 Subject: [PATCH 367/780] AVOptions: in av_opt_find() don't return named constants unless unit is specified. That is, unless the caller explicitly asks for them. Prevents conflict between e.g. the 'loop' option in img2 demuxer and 'loop' flag in AVCodecContext. --- libavutil/opt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 65e02135d5..9c601a2cbb 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -573,8 +573,9 @@ const AVOption *av_opt_find(void *obj, const char *name, const char *unit, return o; while (o = av_next_option(obj, o)) { - if (!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) && - (o->flags & opt_flags) == opt_flags) + if (!strcmp(o->name, name) && (o->flags & opt_flags) == opt_flags && + ((!unit && o->type != FF_OPT_TYPE_CONST) || + (unit && o->unit && !strcmp(o->unit, unit)))) return o; } return NULL; From 6002fdef5eba7ecc623092583d5bb051c8a27318 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 18 Jun 2011 09:28:49 +0200 Subject: [PATCH 368/780] img2: add loop private option. Deprecate AVFormatContext.loop_input. --- libavformat/avformat.h | 7 ++++++- libavformat/img2.c | 9 ++++++++- libavformat/version.h | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 9011099a21..1be9f39646 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -742,7 +742,12 @@ typedef struct AVFormatContext { #endif #define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it. - int loop_input; +#if FF_API_LOOP_INPUT + /** + * @deprecated, use the 'loop' img2 demuxer private option. + */ + attribute_deprecated int loop_input; +#endif /** * decoding: size of data to probe; encoding: unused. diff --git a/libavformat/img2.c b/libavformat/img2.c index 4eef62371d..a4f39e7256 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -42,6 +42,7 @@ typedef struct { char *pixel_format; /**< Set by a private option. */ char *video_size; /**< Set by a private option. */ char *framerate; /**< Set by a private option. */ + int loop; } VideoData; typedef struct { @@ -243,6 +244,11 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap) framerate = (AVRational){ap->time_base.den, ap->time_base.num}; #endif +#if FF_API_LOOP_INPUT + if (s1->loop_input) + s->loop = s1->loop_input; +#endif + av_strlcpy(s->path, s1->filename, sizeof(s->path)); s->img_number = 0; s->img_count = 0; @@ -300,7 +306,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt) if (!s->is_pipe) { /* loop over input */ - if (s1->loop_input && s->img_number > s->img_last) { + if (s->loop && s->img_number > s->img_last) { s->img_number = s->img_first; } if (s->img_number > s->img_last) @@ -458,6 +464,7 @@ static const AVOption options[] = { { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "video_size", "", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { "loop", "", OFFSET(loop), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, DEC }, { NULL }, }; diff --git a/libavformat/version.h b/libavformat/version.h index 0cf383fcc1..957ce529dc 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -77,5 +77,8 @@ #ifndef FF_API_AVSTREAM_QUALITY #define FF_API_AVSTREAM_QUALITY (LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_LOOP_INPUT +#define FF_API_LOOP_INPUT (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif /* AVFORMAT_VERSION_H */ From d31e3f7ccc5d1e198b3a582f4413ce7342928d8c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 18 Jun 2011 09:47:46 +0200 Subject: [PATCH 369/780] gif: add loop private option. Deprecate AVFormatContext.loop_output. --- libavformat/avformat.h | 6 +++++- libavformat/gif.c | 29 ++++++++++++++++++++++++++--- libavformat/version.h | 3 +++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 1be9f39646..2cdf11be12 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -723,12 +723,16 @@ typedef struct AVFormatContext { int preload; int max_delay; +#if FF_API_LOOP_OUTPUT #define AVFMT_NOOUTPUTLOOP -1 #define AVFMT_INFINITEOUTPUTLOOP 0 /** * number of times to loop output in formats that support it + * + * @deprecated use the 'loop' private option in the gif muxer. */ - int loop_output; + attribute_deprecated int loop_output; +#endif int flags; #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames. diff --git a/libavformat/gif.c b/libavformat/gif.c index 55deb4d207..cf8785736b 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -40,6 +40,8 @@ */ #include "avformat.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" /* The GIF format uses reversed order for bitstreams... */ /* at least they don't use PDP_ENDIAN :) */ @@ -245,8 +247,10 @@ static int gif_image_write_image(AVIOContext *pb, } typedef struct { + AVClass *class; /** Class for private options. */ int64_t time, file_time; uint8_t buffer[100]; /* data chunks */ + int loop; } GIFContext; static int gif_write_header(AVFormatContext *s) @@ -254,7 +258,7 @@ static int gif_write_header(AVFormatContext *s) GIFContext *gif = s->priv_data; AVIOContext *pb = s->pb; AVCodecContext *enc, *video_enc; - int i, width, height, loop_count /*, rate*/; + int i, width, height /*, rate*/; /* XXX: do we reject audio streams or just ignore them ? if(s->nb_streams > 1) @@ -276,7 +280,6 @@ static int gif_write_header(AVFormatContext *s) } else { width = video_enc->width; height = video_enc->height; - loop_count = s->loop_output; // rate = video_enc->time_base.den; } @@ -285,7 +288,12 @@ static int gif_write_header(AVFormatContext *s) return AVERROR(EIO); } - gif_image_write_header(pb, width, height, loop_count, NULL); +#if FF_API_LOOP_OUTPUT + if (s->loop_output) + gif->loop = s->loop_output; +#endif + + gif_image_write_header(pb, width, height, gif->loop, NULL); avio_flush(s->pb); return 0; @@ -340,6 +348,20 @@ static int gif_write_trailer(AVFormatContext *s) return 0; } +#define OFFSET(x) offsetof(GIFContext, x) +#define ENC AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "loop", "Number of times to loop the output.", OFFSET(loop), FF_OPT_TYPE_INT, {0}, 0, 65535, ENC }, + { NULL }, +}; + +static const AVClass gif_muxer_class = { + .class_name = "GIF muxer", + .item_name = av_default_item_name, + .version = LIBAVUTIL_VERSION_INT, + .option = options, +}; + AVOutputFormat ff_gif_muxer = { "gif", NULL_IF_CONFIG_SMALL("GIF Animation"), @@ -351,4 +373,5 @@ AVOutputFormat ff_gif_muxer = { gif_write_header, gif_write_packet, gif_write_trailer, + .priv_class = &gif_muxer_class, }; diff --git a/libavformat/version.h b/libavformat/version.h index 957ce529dc..18331fc7d1 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -80,5 +80,8 @@ #ifndef FF_API_LOOP_INPUT #define FF_API_LOOP_INPUT (LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_LOOP_OUTPUT +#define FF_API_LOOP_OUTPUT (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif /* AVFORMAT_VERSION_H */ From f5302e5dcf6572e9424d51d152bffc570cd75ce6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 18 Jun 2011 09:49:24 +0200 Subject: [PATCH 370/780] ffmpeg: deprecate loop_input and loop_output options They were replaced by (de)muxer private options. --- doc/ffmpeg.texi | 2 ++ ffmpeg.c | 14 ++++++++++---- tests/ref/lavf/gif | 4 ++-- tests/ref/seek/lavf_gif | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index cabf395582..6e7fd1390d 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -731,9 +731,11 @@ Read input at native frame rate. Mainly used to simulate a grab device. @item -loop_input Loop over the input stream. Currently it works only for image streams. This option is used for automatic FFserver testing. +This option is deprecated, use -loop. @item -loop_output @var{number_of_times} Repeatedly loop output for formats that support looping such as animated GIF (0 will loop the output infinitely). +This option is deprecated, use -loop. @item -threads @var{count} Thread count. @item -vsync @var{parameter} diff --git a/ffmpeg.c b/ffmpeg.c index 29d9d17619..d55b0d854a 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3247,7 +3247,10 @@ static int opt_input_file(const char *opt, const char *filename) opt_programid=0; } - ic->loop_input = loop_input; + if (loop_input) { + av_log(NULL, AV_LOG_WARNING, "-loop_input is deprecated, use -loop 1\n"); + ic->loop_input = loop_input; + } /* Set AVCodecContext options so they will be seen by av_find_stream_info() */ for (i = 0; i < ic->nb_streams; i++) { @@ -3897,7 +3900,10 @@ static void opt_output_file(const char *filename) oc->preload= (int)(mux_preload*AV_TIME_BASE); oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE); - oc->loop_output = loop_output; + if (loop_output >= 0) { + av_log(NULL, AV_LOG_WARNING, "-loop_output is deprecated, use -loop\n"); + oc->loop_output = loop_output; + } oc->flags |= AVFMT_FLAG_NONBLOCK; frame_rate = (AVRational){0, 0}; @@ -4309,8 +4315,8 @@ static const OptionDef options[] = { { "hex", OPT_BOOL | OPT_EXPERT, {(void*)&do_hex_dump}, "when dumping packets, also dump the payload" }, { "re", OPT_BOOL | OPT_EXPERT, {(void*)&rate_emu}, "read input at native frame rate", "" }, - { "loop_input", OPT_BOOL | OPT_EXPERT, {(void*)&loop_input}, "loop (current only works with images)" }, - { "loop_output", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&loop_output}, "number of times to loop output in formats that support looping (0 loops forever)", "" }, + { "loop_input", OPT_BOOL | OPT_EXPERT, {(void*)&loop_input}, "deprecated, use -loop" }, + { "loop_output", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&loop_output}, "deprecated, use -loop", "" }, { "v", HAS_ARG, {(void*)opt_verbose}, "set ffmpeg verbosity level", "number" }, { "target", HAS_ARG, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" }, { "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" }, diff --git a/tests/ref/lavf/gif b/tests/ref/lavf/gif index fa55d0e66e..4a4ebfb9dc 100644 --- a/tests/ref/lavf/gif +++ b/tests/ref/lavf/gif @@ -1,3 +1,3 @@ -98968ceb210ab260a6a7af36767b94d3 *./tests/data/lavf/lavf.gif -2906382 ./tests/data/lavf/lavf.gif +e6089fd4ef3b9df44090ab3650bdd810 *./tests/data/lavf/lavf.gif +2906401 ./tests/data/lavf/lavf.gif ./tests/data/lavf/lavf.gif CRC=0xe5605ff6 diff --git a/tests/ref/seek/lavf_gif b/tests/ref/seek/lavf_gif index 5da803da42..883f18761e 100644 --- a/tests/ref/seek/lavf_gif +++ b/tests/ref/seek/lavf_gif @@ -1,4 +1,4 @@ -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:2906382 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:2906401 ret:-EINVAL st:-1 flags:0 ts:-1.000000 ret:-EINVAL st:-1 flags:1 ts: 1.894167 ret:-EINVAL st: 0 flags:0 ts: 0.800000 From 17c8cc550d823e796c7153e43374ece2f4b31cb9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 23 Jun 2011 19:14:08 +0200 Subject: [PATCH 371/780] ffmpeg: drop AV prefixes from struct names. Those are reserved for the libs. --- ffmpeg.c | 108 +++++++++++++++++++++++++++---------------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index d55b0d854a..5d6fa1ea02 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -78,26 +78,26 @@ const char program_name[] = "ffmpeg"; const int program_birth_year = 2000; /* select an input stream for an output stream */ -typedef struct AVStreamMap { +typedef struct StreamMap { int file_index; int stream_index; int sync_file_index; int sync_stream_index; -} AVStreamMap; +} StreamMap; /** * select an input file for an output file */ -typedef struct AVMetaDataMap { +typedef struct MetadataMap { int file; //< file index char type; //< type of metadata to copy -- (g)lobal, (s)tream, (c)hapter or (p)rogram int index; //< stream/chapter/program number -} AVMetaDataMap; +} MetadataMap; -typedef struct AVChapterMap { +typedef struct ChapterMap { int in_file; int out_file; -} AVChapterMap; +} ChapterMap; static const OptionDef options[]; @@ -117,17 +117,17 @@ static AVFormatContext *output_files[MAX_FILES]; static AVDictionary *output_opts[MAX_FILES]; static int nb_output_files = 0; -static AVStreamMap *stream_maps = NULL; +static StreamMap *stream_maps = NULL; static int nb_stream_maps; /* first item specifies output metadata, second is input */ -static AVMetaDataMap (*meta_data_maps)[2] = NULL; +static MetadataMap (*meta_data_maps)[2] = NULL; static int nb_meta_data_maps; static int metadata_global_autocopy = 1; static int metadata_streams_autocopy = 1; static int metadata_chapters_autocopy = 1; -static AVChapterMap *chapter_maps = NULL; +static ChapterMap *chapter_maps = NULL; static int nb_chapter_maps; /* indexed by output file stream index */ @@ -246,19 +246,19 @@ static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL; #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" -struct AVInputStream; +struct InputStream; -typedef struct AVOutputStream { +typedef struct OutputStream { int file_index; /* file index */ int index; /* stream index in the output file */ - int source_index; /* AVInputStream index */ + int source_index; /* InputStream index */ AVStream *st; /* stream in the output file */ int encoding_needed; /* true if encoding needed for this stream */ int frame_number; /* input pts and corresponding output pts for A/V sync */ //double sync_ipts; /* dts from the AVPacket of the demuxer in second units */ - struct AVInputStream *sync_ist; /* input stream to sync against */ + struct InputStream *sync_ist; /* input stream to sync against */ int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ //FIXME look at frame_number AVBitStreamFilterContext *bitstream_filters; AVCodec *enc; @@ -299,12 +299,12 @@ typedef struct AVOutputStream { #endif int sws_flags; -} AVOutputStream; +} OutputStream; -static AVOutputStream **output_streams_for_file[MAX_FILES] = { NULL }; +static OutputStream **output_streams_for_file[MAX_FILES] = { NULL }; static int nb_output_streams_for_file[MAX_FILES] = { 0 }; -typedef struct AVInputStream { +typedef struct InputStream { int file_index; AVStream *st; int discard; /* true if stream data should be discarded */ @@ -323,23 +323,23 @@ typedef struct AVInputStream { AVFrame *filter_frame; int has_filter_frame; #endif -} AVInputStream; +} InputStream; -typedef struct AVInputFile { +typedef struct InputFile { AVFormatContext *ctx; int eof_reached; /* true if eof reached */ int ist_index; /* index of first stream in ist_table */ int buffer_size; /* current total buffer size */ -} AVInputFile; +} InputFile; -static AVInputStream *input_streams = NULL; +static InputStream *input_streams = NULL; static int nb_input_streams = 0; -static AVInputFile *input_files = NULL; +static InputFile *input_files = NULL; static int nb_input_files = 0; #if CONFIG_AVFILTER -static int configure_video_filters(AVInputStream *ist, AVOutputStream *ost) +static int configure_video_filters(InputStream *ist, OutputStream *ost) { AVFilterContext *last_filter, *filter; /** filter graph containing all filters including input & output */ @@ -647,10 +647,10 @@ static void choose_pixel_fmt(AVStream *st, AVCodec *codec) } } -static AVOutputStream *new_output_stream(AVFormatContext *oc, int file_idx) +static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx) { int idx = oc->nb_streams - 1; - AVOutputStream *ost; + OutputStream *ost; output_streams_for_file[file_idx] = grow_array(output_streams_for_file[file_idx], @@ -658,7 +658,7 @@ static AVOutputStream *new_output_stream(AVFormatContext *oc, int file_idx) &nb_output_streams_for_file[file_idx], oc->nb_streams); ost = output_streams_for_file[file_idx][idx] = - av_mallocz(sizeof(AVOutputStream)); + av_mallocz(sizeof(OutputStream)); if (!ost) { fprintf(stderr, "Could not alloc output stream\n"); ffmpeg_exit(1); @@ -727,9 +727,9 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename) } static double -get_sync_ipts(const AVOutputStream *ost) +get_sync_ipts(const OutputStream *ost) { - const AVInputStream *ist = ost->sync_ist; + const InputStream *ist = ost->sync_ist; return (double)(ist->pts - start_time)/AV_TIME_BASE; } @@ -768,8 +768,8 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx #define MAX_AUDIO_PACKET_SIZE (128 * 1024) static void do_audio_out(AVFormatContext *s, - AVOutputStream *ost, - AVInputStream *ist, + OutputStream *ost, + InputStream *ist, unsigned char *buf, int size) { uint8_t *buftmp; @@ -1011,7 +1011,7 @@ need_realloc: } } -static void pre_process_video_frame(AVInputStream *ist, AVPicture *picture, void **bufp) +static void pre_process_video_frame(InputStream *ist, AVPicture *picture, void **bufp) { AVCodecContext *dec; AVPicture *picture2; @@ -1054,8 +1054,8 @@ static void pre_process_video_frame(AVInputStream *ist, AVPicture *picture, void #define AV_DELAY_MAX 0.100 static void do_subtitle_out(AVFormatContext *s, - AVOutputStream *ost, - AVInputStream *ist, + OutputStream *ost, + InputStream *ist, AVSubtitle *sub, int64_t pts) { @@ -1120,8 +1120,8 @@ static int bit_buffer_size= 1024*256; static uint8_t *bit_buffer= NULL; static void do_video_out(AVFormatContext *s, - AVOutputStream *ost, - AVInputStream *ist, + OutputStream *ost, + InputStream *ist, AVFrame *in_picture, int *frame_size, float quality) { @@ -1296,7 +1296,7 @@ static double psnr(double d){ return -10.0*log(d)/log(10.0); } -static void do_video_stats(AVFormatContext *os, AVOutputStream *ost, +static void do_video_stats(AVFormatContext *os, OutputStream *ost, int frame_size) { AVCodecContext *enc; @@ -1334,11 +1334,11 @@ static void do_video_stats(AVFormatContext *os, AVOutputStream *ost, } static void print_report(AVFormatContext **output_files, - AVOutputStream **ost_table, int nb_ostreams, + OutputStream **ost_table, int nb_ostreams, int is_last_report) { char buf[1024]; - AVOutputStream *ost; + OutputStream *ost; AVFormatContext *oc; int64_t total_size; AVCodecContext *enc; @@ -1464,12 +1464,12 @@ static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_ } /* pkt = NULL means EOF (needed to flush decoder buffers) */ -static int output_packet(AVInputStream *ist, int ist_index, - AVOutputStream **ost_table, int nb_ostreams, +static int output_packet(InputStream *ist, int ist_index, + OutputStream **ost_table, int nb_ostreams, const AVPacket *pkt) { AVFormatContext *os; - AVOutputStream *ost; + OutputStream *ost; int ret, i; int got_output; AVFrame picture; @@ -1916,7 +1916,7 @@ static int copy_chapters(int infile, int outfile) return 0; } -static void parse_forced_key_frames(char *kf, AVOutputStream *ost, +static void parse_forced_key_frames(char *kf, OutputStream *ost, AVCodecContext *avctx) { char *p; @@ -1944,15 +1944,15 @@ static void parse_forced_key_frames(char *kf, AVOutputStream *ost, */ static int transcode(AVFormatContext **output_files, int nb_output_files, - AVInputFile *input_files, + InputFile *input_files, int nb_input_files, - AVStreamMap *stream_maps, int nb_stream_maps) + StreamMap *stream_maps, int nb_stream_maps) { int ret = 0, i, j, k, n, nb_ostreams = 0; AVFormatContext *is, *os; AVCodecContext *codec, *icodec; - AVOutputStream *ost, **ost_table = NULL; - AVInputStream *ist; + OutputStream *ost, **ost_table = NULL; + InputStream *ist; char error[1024]; int want_sdp = 1; uint8_t no_packet[MAX_FILES]={0}; @@ -2001,7 +2001,7 @@ static int transcode(AVFormatContext **output_files, } } - ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams); + ost_table = av_mallocz(sizeof(OutputStream *) * nb_ostreams); if (!ost_table) goto fail; n = 0; @@ -2412,7 +2412,7 @@ static int transcode(AVFormatContext **output_files, files[1] = input_files[in_file_index].ctx; for (j = 0; j < 2; j++) { - AVMetaDataMap *map = &meta_data_maps[i][j]; + MetadataMap *map = &meta_data_maps[i][j]; switch (map->type) { case 'g': @@ -2984,7 +2984,7 @@ static int opt_codec_tag(const char *opt, const char *arg) static int opt_map(const char *opt, const char *arg) { - AVStreamMap *m; + StreamMap *m; char *p; stream_maps = grow_array(stream_maps, sizeof(*stream_maps), &nb_stream_maps, nb_stream_maps + 1); @@ -3031,7 +3031,7 @@ static void parse_meta_type(char *arg, char *type, int *index, char **endptr) static int opt_map_metadata(const char *opt, const char *arg) { - AVMetaDataMap *m, *m1; + MetadataMap *m, *m1; char *p; meta_data_maps = grow_array(meta_data_maps, sizeof(*meta_data_maps), @@ -3066,7 +3066,7 @@ static int opt_map_meta_data(const char *opt, const char *arg) static int opt_map_chapters(const char *opt, const char *arg) { - AVChapterMap *c; + ChapterMap *c; char *p; chapter_maps = grow_array(chapter_maps, sizeof(*chapter_maps), &nb_chapter_maps, @@ -3298,7 +3298,7 @@ static int opt_input_file(const char *opt, const char *filename) for(i=0;inb_streams;i++) { AVStream *st = ic->streams[i]; AVCodecContext *dec = st->codec; - AVInputStream *ist; + InputStream *ist; dec->thread_count = thread_count; input_codecs = grow_array(input_codecs, sizeof(*input_codecs), &nb_input_codecs, nb_input_codecs + 1); @@ -3430,7 +3430,7 @@ static void check_inputs(int *has_video_ptr, static void new_video_stream(AVFormatContext *oc, int file_idx) { AVStream *st; - AVOutputStream *ost; + OutputStream *ost; AVCodecContext *video_enc; enum CodecID codec_id = CODEC_ID_NONE; AVCodec *codec= NULL; @@ -3569,7 +3569,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) static void new_audio_stream(AVFormatContext *oc, int file_idx) { AVStream *st; - AVOutputStream *ost; + OutputStream *ost; AVCodec *codec= NULL; AVCodecContext *audio_enc; enum CodecID codec_id = CODEC_ID_NONE; @@ -3679,7 +3679,7 @@ static void new_data_stream(AVFormatContext *oc, int file_idx) static void new_subtitle_stream(AVFormatContext *oc, int file_idx) { AVStream *st; - AVOutputStream *ost; + OutputStream *ost; AVCodec *codec=NULL; AVCodecContext *subtitle_enc; enum CodecID codec_id = CODEC_ID_NONE; From 9e253c13d0f019359bdddc75aa5adba59e2a793d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 23 Jun 2011 19:22:19 +0200 Subject: [PATCH 372/780] ffmpeg: merge input_codecs into input_streams. There's no point in keeping them separate. --- ffmpeg.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 5d6fa1ea02..980a2858c3 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -109,8 +109,6 @@ static const OptionDef options[]; static const char *last_asked_format = NULL; static int64_t input_files_ts_offset[MAX_FILES]; static double *input_files_ts_scale[MAX_FILES] = {NULL}; -static AVCodec **input_codecs = NULL; -static int nb_input_codecs = 0; static int nb_input_files_ts_scale[MAX_FILES] = {0}; static AVFormatContext *output_files[MAX_FILES]; @@ -310,6 +308,7 @@ typedef struct InputStream { int discard; /* true if stream data should be discarded */ int decoding_needed; /* true if the packets must be decoded in 'raw_fifo' */ int64_t sample_index; /* current sample */ + AVCodec *dec; int64_t start; /* time when read started */ int64_t next_pts; /* synthetic pts for cases where pkt.pts @@ -479,7 +478,6 @@ static int ffmpeg_exit(int ret) av_free(vstats_filename); av_free(streamid_map); - av_free(input_codecs); av_free(stream_maps); av_free(meta_data_maps); @@ -2345,7 +2343,7 @@ static int transcode(AVFormatContext **output_files, for (i = 0; i < nb_input_streams; i++) { ist = &input_streams[i]; if (ist->decoding_needed) { - AVCodec *codec = i < nb_input_codecs ? input_codecs[i] : NULL; + AVCodec *codec = ist->dec; if (!codec) codec = avcodec_find_decoder(ist->st->codec->codec_id); if (!codec) { @@ -3301,7 +3299,6 @@ static int opt_input_file(const char *opt, const char *filename) InputStream *ist; dec->thread_count = thread_count; - input_codecs = grow_array(input_codecs, sizeof(*input_codecs), &nb_input_codecs, nb_input_codecs + 1); input_streams = grow_array(input_streams, sizeof(*input_streams), &nb_input_streams, nb_input_streams + 1); ist = &input_streams[nb_input_streams - 1]; @@ -3311,16 +3308,16 @@ static int opt_input_file(const char *opt, const char *filename) switch (dec->codec_type) { case AVMEDIA_TYPE_AUDIO: - input_codecs[nb_input_codecs-1] = avcodec_find_decoder_by_name(audio_codec_name); - set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, input_codecs[nb_input_codecs-1]); + ist->dec = avcodec_find_decoder_by_name(audio_codec_name); + set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, ist->dec); channel_layout = dec->channel_layout; audio_sample_fmt = dec->sample_fmt; if(audio_disable) st->discard= AVDISCARD_ALL; break; case AVMEDIA_TYPE_VIDEO: - input_codecs[nb_input_codecs-1] = avcodec_find_decoder_by_name(video_codec_name); - set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, input_codecs[nb_input_codecs-1]); + ist->dec = avcodec_find_decoder_by_name(video_codec_name); + set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, ist->dec); rfps = ic->streams[i]->r_frame_rate.num; rfps_base = ic->streams[i]->r_frame_rate.den; if (dec->lowres) { @@ -3348,7 +3345,7 @@ static int opt_input_file(const char *opt, const char *filename) case AVMEDIA_TYPE_DATA: break; case AVMEDIA_TYPE_SUBTITLE: - input_codecs[nb_input_codecs-1] = avcodec_find_decoder_by_name(subtitle_codec_name); + ist->dec = avcodec_find_decoder_by_name(subtitle_codec_name); if(subtitle_disable) st->discard = AVDISCARD_ALL; break; From 27e91f37f58d122f94d9d9b30c6355d2dd2b0e49 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 23 Jun 2011 19:30:15 +0200 Subject: [PATCH 373/780] ffmpeg: merge input_files_ts_offset into input_files. --- ffmpeg.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 980a2858c3..390785555a 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -107,7 +107,6 @@ static const OptionDef options[]; #define FFM_PACKET_SIZE 4096 //XXX a duplicate of the line in ffm.h static const char *last_asked_format = NULL; -static int64_t input_files_ts_offset[MAX_FILES]; static double *input_files_ts_scale[MAX_FILES] = {NULL}; static int nb_input_files_ts_scale[MAX_FILES] = {0}; @@ -329,6 +328,7 @@ typedef struct InputFile { int eof_reached; /* true if eof reached */ int ist_index; /* index of first stream in ist_table */ int buffer_size; /* current total buffer size */ + int64_t ts_offset; } InputFile; static InputStream *input_streams = NULL; @@ -1671,7 +1671,7 @@ static int output_packet(InputStream *ist, int ist_index, os = output_files[ost->file_index]; /* set the input output pts pairs */ - //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE; + //ost->sync_ipts = (double)(ist->pts + input_files[ist->file_index].ts_offset - start_time)/ AV_TIME_BASE; if (ost->encoding_needed) { av_assert0(ist->decoding_needed); @@ -1882,7 +1882,7 @@ static int copy_chapters(int infile, int outfile) for (i = 0; i < is->nb_chapters; i++) { AVChapter *in_ch = is->chapters[i], *out_ch; - int64_t ts_off = av_rescale_q(start_time - input_files_ts_offset[infile], + int64_t ts_off = av_rescale_q(start_time - input_files[infile].ts_offset, AV_TIME_BASE_Q, in_ch->time_base); int64_t rt = (recording_time == INT64_MAX) ? INT64_MAX : av_rescale_q(recording_time, AV_TIME_BASE_Q, in_ch->time_base); @@ -2613,9 +2613,9 @@ static int transcode(AVFormatContext **output_files, goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) - pkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base); + pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) - pkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base); + pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.stream_index < nb_input_files_ts_scale[file_index] && input_files_ts_scale[file_index][pkt.stream_index]){ @@ -2625,15 +2625,16 @@ static int transcode(AVFormatContext **output_files, pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index]; } -// fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type); +// fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files[ist->file_index].ts_offset, ist->st->codec->codec_type); if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE && (is->iformat->flags & AVFMT_TS_DISCONT)) { int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta= pkt_dts - ist->next_pts; if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1pts)&& !copy_ts){ - input_files_ts_offset[ist->file_index]-= delta; + input_files[ist->file_index].ts_offset -= delta; if (verbose > 2) - fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]); + fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", + delta, input_files[ist->file_index].ts_offset); pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); if(pkt.pts != AV_NOPTS_VALUE) pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); @@ -3357,7 +3358,6 @@ static int opt_input_file(const char *opt, const char *filename) } } - input_files_ts_offset[nb_input_files] = input_ts_offset - (copy_ts ? 0 : timestamp); /* dump the file content */ if (verbose >= 0) av_dump_format(ic, nb_input_files, filename, 0); @@ -3365,6 +3365,7 @@ static int opt_input_file(const char *opt, const char *filename) input_files = grow_array(input_files, sizeof(*input_files), &nb_input_files, nb_input_files + 1); input_files[nb_input_files - 1].ctx = ic; input_files[nb_input_files - 1].ist_index = nb_input_streams - ic->nb_streams; + input_files[nb_input_files - 1].ts_offset = input_ts_offset - (copy_ts ? 0 : timestamp); frame_rate = (AVRational){0, 0}; frame_pix_fmt = PIX_FMT_NONE; From 20f9f21fd49112c70c94dad015550f59ece5a0e9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 24 Jun 2011 08:54:52 +0200 Subject: [PATCH 374/780] ffmpeg: remove pointless if (nb_input_files) It's required to be non-zero since cc58300e30e7aea6acfecd72a04a3886b285cfd8 --- ffmpeg.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 390785555a..9ae197acec 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3821,23 +3821,20 @@ static void opt_output_file(const char *filename) use_subtitle = file_oformat->subtitle_codec != CODEC_ID_NONE || subtitle_stream_copy || subtitle_codec_name; use_data = data_stream_copy || data_codec_name; /* XXX once generic data codec will be available add a ->data_codec reference and use it here */ - /* disable if no corresponding type found and at least one - input file */ - if (nb_input_files > 0) { - check_inputs(&input_has_video, - &input_has_audio, - &input_has_subtitle, - &input_has_data); + /* disable if no corresponding type found */ + check_inputs(&input_has_video, + &input_has_audio, + &input_has_subtitle, + &input_has_data); - if (!input_has_video) - use_video = 0; - if (!input_has_audio) - use_audio = 0; - if (!input_has_subtitle) - use_subtitle = 0; - if (!input_has_data) - use_data = 0; - } + if (!input_has_video) + use_video = 0; + if (!input_has_audio) + use_audio = 0; + if (!input_has_subtitle) + use_subtitle = 0; + if (!input_has_data) + use_data = 0; /* manual disable */ if (audio_disable) use_audio = 0; From a58db9d283ced3eb443b3123e6e742dfd0614bc4 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 24 Jun 2011 11:22:15 +0200 Subject: [PATCH 375/780] doc: update ffmpeg -ar and -ac documentation to reflect reality. --- doc/ffmpeg.texi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 6e7fd1390d..5246b18640 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -551,19 +551,19 @@ The timestamps must be specified in ascending order. @item -aframes @var{number} Set the number of audio frames to record. @item -ar @var{freq} -Set the audio sampling frequency. For input streams it is set by -default to 44100 Hz, for output streams it is set by default to the -frequency of the input stream. If the input file has audio streams -with different frequencies, the behaviour is undefined. +Set the audio sampling frequency. For output streams it is set by +default to the frequency of the corresponding input stream. For input +streams this option only makes sense for audio grabbing devices and raw +demuxers and is mapped to the corresponding demuxer options. @item -ab @var{bitrate} Set the audio bitrate in bit/s (default = 64k). @item -aq @var{q} Set the audio quality (codec-specific, VBR). @item -ac @var{channels} -Set the number of audio channels. For input streams it is set by -default to 1, for output streams it is set by default to the same -number of audio channels in input. If the input file has audio streams -with different channel count, the behaviour is undefined. +Set the number of audio channels. For output streams it is set by +default to the number of input audio channels. For input streams +this option only makes sense for audio grabbing devices and raw demuxers +and is mapped to the corresponding demuxer options. @item -an Disable audio recording. @item -acodec @var{codec} From e98bc78ca168bbb615752ed8e3b97bcacafdf0b7 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 6 Jul 2011 08:35:07 +0200 Subject: [PATCH 376/780] ffmpeg: remove unused variables from InputStream. --- ffmpeg.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 9ae197acec..fe8b3446b8 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -306,7 +306,6 @@ typedef struct InputStream { AVStream *st; int discard; /* true if stream data should be discarded */ int decoding_needed; /* true if the packets must be decoded in 'raw_fifo' */ - int64_t sample_index; /* current sample */ AVCodec *dec; int64_t start; /* time when read started */ @@ -317,10 +316,6 @@ typedef struct InputStream { int is_start; /* is 1 at the start and after a discontinuity */ int showed_multi_packet_warning; int is_past_recording_time; -#if CONFIG_AVFILTER - AVFrame *filter_frame; - int has_filter_frame; -#endif } InputStream; typedef struct InputFile { From 1c6d2b7df061de2a9205ed711f4344926237bb5f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 16 Mar 2011 08:45:14 +0100 Subject: [PATCH 377/780] lavf: update AVStream.nb_frames when muxing. --- libavformat/matroskaenc.c | 2 +- libavformat/utils.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index d132b65f5b..169e8e44da 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -932,7 +932,7 @@ static int mkv_write_ass_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p size -= start - data; sscanf(data, "Dialogue: %d,", &layer); i = snprintf(buffer, sizeof(buffer), "%"PRId64",%d,", - s->streams[pkt->stream_index]->nb_frames++, layer); + s->streams[pkt->stream_index]->nb_frames, layer); size = FFMIN(i+size, sizeof(buffer)); memcpy(buffer+i, start, size-i); diff --git a/libavformat/utils.c b/libavformat/utils.c index 060e58e9b2..e38d9efa60 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3023,6 +3023,9 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt) return ret; ret= s->oformat->write_packet(s, pkt); + + if (ret >= 0) + s->streams[pkt->stream_index]->nb_frames++; return ret; } @@ -3143,6 +3146,8 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){ return ret; ret= s->oformat->write_packet(s, &opkt); + if (ret >= 0) + s->streams[opkt.stream_index]->nb_frames++; av_free_packet(&opkt); pkt= NULL; @@ -3165,6 +3170,8 @@ int av_write_trailer(AVFormatContext *s) break; ret= s->oformat->write_packet(s, &pkt); + if (ret >= 0) + s->streams[pkt.stream_index]->nb_frames++; av_free_packet(&pkt); From bda168d2b0210dda84f1a9d32c8aa4653d1674d5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Mar 2011 21:02:50 +0100 Subject: [PATCH 378/780] mp3enc: write a xing frame containing number of frames in the file --- libavcodec/Makefile | 1 + libavformat/mp3enc.c | 75 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b781ed7ef3..fb603f864d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -536,6 +536,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_MATROSKA_MUXER) += xiph.o mpeg4audio.o \ flacdec.o flacdata.o flac.o \ mpegaudiodata.o +OBJS-$(CONFIG_MP3_MUXER) += mpegaudiodata.o mpegaudiodecheader.o OBJS-$(CONFIG_MOV_DEMUXER) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_MOV_MUXER) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_MPEGTS_MUXER) += mpegvideo.o mpeg4audio.o diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 092d16ecc1..9d0ec5d929 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -21,10 +21,14 @@ #include #include "avformat.h" +#include "avio_internal.h" #include "id3v1.h" #include "id3v2.h" #include "rawenc.h" #include "libavutil/avstring.h" +#include "libavcodec/mpegaudio.h" +#include "libavcodec/mpegaudiodata.h" +#include "libavcodec/mpegaudiodecheader.h" #include "libavutil/intreadwrite.h" #include "libavutil/opt.h" #include "libavutil/dict.h" @@ -128,15 +132,31 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2 return len + ID3v2_HEADER_SIZE; } +typedef struct MP3Context { + const AVClass *class; + int id3v2_version; + int64_t nb_frames_offset; +} MP3Context; + static int mp3_write_trailer(struct AVFormatContext *s) { uint8_t buf[ID3v1_TAG_SIZE]; + MP3Context *mp3 = s->priv_data; /* write the id3v1 tag */ if (id3v1_create_tag(s, buf) > 0) { avio_write(s->pb, buf, ID3v1_TAG_SIZE); - avio_flush(s->pb); } + + /* write number of frames */ + if (mp3 && mp3->nb_frames_offset) { + avio_seek(s->pb, mp3->nb_frames_offset, SEEK_SET); + avio_wb32(s->pb, s->streams[0]->nb_frames); + avio_seek(s->pb, 0, SEEK_END); + } + + avio_flush(s->pb); + return 0; } @@ -156,10 +176,6 @@ AVOutputFormat ff_mp2_muxer = { #endif #if CONFIG_MP3_MUXER -typedef struct MP3Context { - const AVClass *class; - int id3v2_version; -} MP3Context; static const AVOption options[] = { { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.", @@ -189,6 +205,52 @@ static int id3v2_check_write_tag(AVFormatContext *s, AVDictionaryEntry *t, const return -1; } +/* insert a dummy frame containing number of frames */ +static void mp3_write_xing(AVFormatContext *s) +{ + AVCodecContext *codec = s->streams[0]->codec; + MP3Context *mp3 = s->priv_data; + int bitrate_idx = 1; // 32 kbps + int64_t xing_offset = (codec->channels == 2) ? 32 : 17; + int32_t header; + MPADecodeHeader mpah; + int srate_idx, i, channels; + + for (i = 0; i < FF_ARRAY_ELEMS(ff_mpa_freq_tab); i++) + if (ff_mpa_freq_tab[i] == codec->sample_rate) { + srate_idx = i; + break; + } + if (i == FF_ARRAY_ELEMS(ff_mpa_freq_tab)) { + av_log(s, AV_LOG_ERROR, "Unsupported sample rate.\n"); + return; + } + + switch (codec->channels) { + case 1: channels = MPA_MONO; break; + case 2: channels = MPA_STEREO; break; + default: av_log(s, AV_LOG_ERROR, "Unsupported number of channels.\n"); return; + } + + /* dummy MPEG audio header */ + header = 0xff << 24; // sync + header |= (0x7 << 5 | 0x3 << 3 | 0x1 << 1 | 0x1) << 16; // sync/mpeg-1/layer 3/no crc*/ + header |= (bitrate_idx << 4 | srate_idx << 2) << 8; + header |= channels << 6; + avio_wb32(s->pb, header); + + ff_mpegaudio_decode_header(&mpah, header); + + ffio_fill(s->pb, 0, xing_offset); + ffio_wfourcc(s->pb, "Xing"); + avio_wb32(s->pb, 0x1); // only number of frames + mp3->nb_frames_offset = avio_tell(s->pb); + avio_wb32(s->pb, 0); + + mpah.frame_size -= 4 + xing_offset + 4 + 4 + 4; + ffio_fill(s->pb, 0, mpah.frame_size); +} + /** * Write an ID3v2 header at beginning of stream */ @@ -237,6 +299,9 @@ static int mp3_write_header(struct AVFormatContext *s) id3v2_put_size(s, totlen); avio_seek(s->pb, cur_pos, SEEK_SET); + if (s->pb->seekable) + mp3_write_xing(s); + return 0; } From 42d622fab31dbcae91fd4b0810e0ac07027e2df1 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 8 Jul 2011 14:52:52 -0700 Subject: [PATCH 379/780] swscale: fix 16-bit scaling when output is 8-bits. We would use the second half of the U plane buffer, rather than the V plane buffer, to output the V plane pixels. --- libswscale/utils.c | 2 +- libswscale/x86/swscale_template.c | 24 ++++++++++++------------ tests/ref/lavfi/pixdesc | 4 ++-- tests/ref/lavfi/pixfmts_copy | 4 ++-- tests/ref/lavfi/pixfmts_crop | 4 ++-- tests/ref/lavfi/pixfmts_hflip | 4 ++-- tests/ref/lavfi/pixfmts_null | 4 ++-- tests/ref/lavfi/pixfmts_scale | 4 ++-- tests/ref/lavfi/pixfmts_vflip | 4 ++-- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 9f0bb7a8b9..fd10fa03fb 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1053,7 +1053,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) for (i=0; ivChrBufSize; i++) { FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i+c->vChrBufSize], dst_stride*2+1, fail); c->chrUPixBuf[i] = c->chrUPixBuf[i+c->vChrBufSize]; - c->chrVPixBuf[i] = c->chrVPixBuf[i+c->vChrBufSize] = c->chrUPixBuf[i] + dst_stride_px; + c->chrVPixBuf[i] = c->chrVPixBuf[i+c->vChrBufSize] = c->chrUPixBuf[i] + (dst_stride >> 1); } if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) for (i=0; ivLumBufSize; i++) { diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index f58ac520e1..26cd2742a3 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -81,7 +81,7 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; if (uDest) { - x86_reg uv_off = c->uv_off; + x86_reg uv_off = c->uv_offx2 >> 1; YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, vDest - uv_off, chrDstW + uv_off, uv_off) } @@ -164,7 +164,7 @@ static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; if (uDest) { - x86_reg uv_off = c->uv_off; + x86_reg uv_off = c->uv_offx2 >> 1; YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, vDest - uv_off, chrDstW + uv_off, uv_off) } @@ -473,7 +473,7 @@ static void RENAME(yuv2rgb32_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { YSCALEYUV2PACKEDX_ACCURATE @@ -506,7 +506,7 @@ static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { YSCALEYUV2PACKEDX @@ -563,7 +563,7 @@ static void RENAME(yuv2rgb565_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX @@ -587,7 +587,7 @@ static void RENAME(yuv2rgb565_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX YSCALEYUV2RGBX @@ -640,7 +640,7 @@ static void RENAME(yuv2rgb555_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX @@ -664,7 +664,7 @@ static void RENAME(yuv2rgb555_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX YSCALEYUV2RGBX @@ -797,7 +797,7 @@ static void RENAME(yuv2bgr24_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX @@ -821,7 +821,7 @@ static void RENAME(yuv2bgr24_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX YSCALEYUV2RGBX @@ -862,7 +862,7 @@ static void RENAME(yuv2yuyv422_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX_ACCURATE /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ @@ -883,7 +883,7 @@ static void RENAME(yuv2yuyv422_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc index 8695b1dea2..ee28c4b78f 100644 --- a/tests/ref/lavfi/pixdesc +++ b/tests/ref/lavfi/pixdesc @@ -42,8 +42,8 @@ yuv422p16be 86ad3447f97969ce095afeef81fa9abf yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be 95db370ae765dd3d10b7def14704ae73 -yuv444p16le 36b969179b5ad9d312a0d1e1cd6bc402 +yuv444p16be 12554ba5f143126dc5e886b9a8be37e9 +yuv444p16le 35872903aefd0f545255a4452ccc262e yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index 8695b1dea2..ee28c4b78f 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -42,8 +42,8 @@ yuv422p16be 86ad3447f97969ce095afeef81fa9abf yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be 95db370ae765dd3d10b7def14704ae73 -yuv444p16le 36b969179b5ad9d312a0d1e1cd6bc402 +yuv444p16be 12554ba5f143126dc5e886b9a8be37e9 +yuv444p16le 35872903aefd0f545255a4452ccc262e yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_crop b/tests/ref/lavfi/pixfmts_crop index c7b59527fb..fb5c838a4e 100644 --- a/tests/ref/lavfi/pixfmts_crop +++ b/tests/ref/lavfi/pixfmts_crop @@ -33,8 +33,8 @@ yuv422p16be 6647fe1c381c148f8207c988c0e22bf0 yuv422p16le e1548c9dc51202db38a9625c8954203f yuv440p 2472417d980e395ad6843cbb8b633b29 yuv444p 1f151980486848c96bc5585ced99003e -yuv444p16be ac3b159f8c858fcdf475a8c024ee79b6 -yuv444p16le 9a6863bfc5faee206065c11dc994bf0c +yuv444p16be 02d78b564a23df2f68cf6895d3bfe6bf +yuv444p16le cbea9591b954ea31d6a0cb25a9aed599 yuva420p 7536753dfbc7932560fb50c921369a0e yuvj420p 21f891093006d42d7683b0e1d773a657 yuvj422p 9a43d474c407590ad8f213880586b45e diff --git a/tests/ref/lavfi/pixfmts_hflip b/tests/ref/lavfi/pixfmts_hflip index 7f4342f35c..77102524b4 100644 --- a/tests/ref/lavfi/pixfmts_hflip +++ b/tests/ref/lavfi/pixfmts_hflip @@ -33,8 +33,8 @@ yuv422p16be 9dbe0af0eb877987611cf04bfa577202 yuv422p16le 2d8f37231110177cc5e1b61c8cb4b163 yuv440p a99e2b57ed601f39852715c9d675d0d3 yuv444p 947e47f7bb5fdccc659d19b7df2b6fc3 -yuv444p16be debc96a7ec4fec0a412f9d8995bc48a2 -yuv444p16le 5b5e1348a631fc2206bb7ff851a52687 +yuv444p16be cdc7bfb08b8286d05d6a639d1bfc0d26 +yuv444p16le 969caecaaca795477874420540d21e8b yuva420p d83ec0c01498189f179ec574918185f1 yuvj420p df3aaaec3bb157c3bde5f0365af30f4f yuvj422p d113871528d510a192797af59df9c05c diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index 8695b1dea2..ee28c4b78f 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -42,8 +42,8 @@ yuv422p16be 86ad3447f97969ce095afeef81fa9abf yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be 95db370ae765dd3d10b7def14704ae73 -yuv444p16le 36b969179b5ad9d312a0d1e1cd6bc402 +yuv444p16be 12554ba5f143126dc5e886b9a8be37e9 +yuv444p16le 35872903aefd0f545255a4452ccc262e yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index 8901fe9132..0cb27ef387 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -42,8 +42,8 @@ yuv422p16be 837945d3a771366a5a72a4ed095a4f53 yuv422p16le b8292ae9b52eb7afc3d8b93e8fd895b4 yuv440p 461503fdb9b90451020aa3b25ddf041c yuv444p 81b2eba962d12e8d64f003ac56f6faf2 -yuv444p16be cc7460f76477aa4b4c33442f67c06a89 -yuv444p16le 9a5ed60d68c0a4a5155f9d376174cdf7 +yuv444p16be fe2c4a3708c4f44a2d91f3c413f33caf +yuv444p16le 1b4fce808e546cd75ef01cdb91da26b5 yuva420p 8673a9131fb47de69788863f93a50eb7 yuvj420p 30427bd6caf5bda93a173dbebe759e09 yuvj422p fc8288f64fd149573f73cf8da05d8e6d diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index 89502d1745..acead3d990 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -42,8 +42,8 @@ yuv422p16be 8cdfbddf2dd4c44c3efef4ee00170eba yuv422p16le a2f421f6a1af950544081c1797de01ae yuv440p 876385e96165acf51271b20e5d85a416 yuv444p 9c3c667d1613b72d15bc6d851c5eb8f7 -yuv444p16be b092690d22f0b26360fbf5cfd739be17 -yuv444p16le 18768b4ddca92d06f9713fef467276a9 +yuv444p16be c73d2f57f90060d4126241aba04876d3 +yuv444p16le c9ab60ec1ae3ff50da524e83e3553add yuva420p c705d1cf061d8c6580ac690b55f92276 yuvj420p 41fd02b204da0ab62452cd14b595e2e4 yuvj422p 7f6ca9bc1812cde02036d7d29a7cce43 From f44d50a94c120135faeba6b4a1e5551b4397810f Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 8 Jul 2011 14:54:31 -0700 Subject: [PATCH 380/780] swscale: fix 16-bit horizontal scaling underflow. When using e.g. lanczos scaling, values can drop below 0, so they should never be unsigned. --- libswscale/swscale.c | 2 +- tests/ref/lavfi/pixdesc | 4 ++-- tests/ref/lavfi/pixfmts_copy | 4 ++-- tests/ref/lavfi/pixfmts_hflip | 4 ++-- tests/ref/lavfi/pixfmts_null | 4 ++-- tests/ref/lavfi/pixfmts_scale | 24 ++++++++++++------------ tests/ref/lavfi/pixfmts_vflip | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 14807fdc46..a302373b85 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1854,7 +1854,7 @@ static void hScale16_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_s for (i = 0; i < dstW; i++) { int j; int srcPos = filterPos[i]; - unsigned int val = 0; + int val = 0; for (j = 0; j < filterSize; j++) { val += src[srcPos + j] * filter[filterSize * i + j]; diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc index ee28c4b78f..76d845abb8 100644 --- a/tests/ref/lavfi/pixdesc +++ b/tests/ref/lavfi/pixdesc @@ -42,8 +42,8 @@ yuv422p16be 86ad3447f97969ce095afeef81fa9abf yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be 12554ba5f143126dc5e886b9a8be37e9 -yuv444p16le 35872903aefd0f545255a4452ccc262e +yuv444p16be 2a8e2bddfe4c208df4119aaa7dc5db28 +yuv444p16le f2117fc9cf66d3a832183e159ff71803 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index ee28c4b78f..76d845abb8 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -42,8 +42,8 @@ yuv422p16be 86ad3447f97969ce095afeef81fa9abf yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be 12554ba5f143126dc5e886b9a8be37e9 -yuv444p16le 35872903aefd0f545255a4452ccc262e +yuv444p16be 2a8e2bddfe4c208df4119aaa7dc5db28 +yuv444p16le f2117fc9cf66d3a832183e159ff71803 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_hflip b/tests/ref/lavfi/pixfmts_hflip index 77102524b4..4a32e35a1c 100644 --- a/tests/ref/lavfi/pixfmts_hflip +++ b/tests/ref/lavfi/pixfmts_hflip @@ -33,8 +33,8 @@ yuv422p16be 9dbe0af0eb877987611cf04bfa577202 yuv422p16le 2d8f37231110177cc5e1b61c8cb4b163 yuv440p a99e2b57ed601f39852715c9d675d0d3 yuv444p 947e47f7bb5fdccc659d19b7df2b6fc3 -yuv444p16be cdc7bfb08b8286d05d6a639d1bfc0d26 -yuv444p16le 969caecaaca795477874420540d21e8b +yuv444p16be 38cdb28061ebb8e7aa3797238615e77f +yuv444p16le 80d654986d6f3754e924310a045fdb24 yuva420p d83ec0c01498189f179ec574918185f1 yuvj420p df3aaaec3bb157c3bde5f0365af30f4f yuvj422p d113871528d510a192797af59df9c05c diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index ee28c4b78f..76d845abb8 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -42,8 +42,8 @@ yuv422p16be 86ad3447f97969ce095afeef81fa9abf yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be 12554ba5f143126dc5e886b9a8be37e9 -yuv444p16le 35872903aefd0f545255a4452ccc262e +yuv444p16be 2a8e2bddfe4c208df4119aaa7dc5db28 +yuv444p16le f2117fc9cf66d3a832183e159ff71803 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index 0cb27ef387..14c748ff10 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -11,8 +11,8 @@ bgr565le 3a514a298c6161a071ddf9963c06509d bgr8 7f007fa6c153a16e808a9c51605a4016 bgra a5e7040f9a80cccd65e5acf2ca09ace5 gray d7786a7d9d99ac74230cc045cab5632c -gray16be bba98532da29a31599df2feec3b08e3e -gray16le 30267f127d5734c4767f3944f1729a33 +gray16be b554d6c1cc8da23967445be4dd3e4a86 +gray16le 715a33aa1c19cb26b14f5cc000e7a3d1 monob 88c4c050758e64d120f50c7eff694381 monow d31772ebaa877fc2a78565937f7f9673 nv12 4676d59db43d657dc12841f6bc3ab452 @@ -31,19 +31,19 @@ uyvy422 314bd486277111a95d9369b944fa0400 yuv410p 7df8f6d69b56a8dcb6c7ee908e5018b5 yuv411p 1143e7c5cc28fe0922b051b17733bc4c yuv420p fdad2d8df8985e3d17e73c71f713cb14 -yuv420p10be 2343beaf83fccc2ab23a590b2049d38b -yuv420p10le 94d511d783d175f573e7be5cce75ba4d -yuv420p16be f6ef3ba90f238b467c7e72ade927083d -yuv420p16le faf6aab3b1c16e8afbe160686dd360e0 -yuv420p9be fdafb9ad473a559246c4cb0a1f416cd8 -yuv420p9le fccfd3c3941da635b13739f579819b5a +yuv420p10be aad747a7634ba4ed48f149cdfc78792e +yuv420p10le 46547f19a7f58638dff73657477b11b9 +yuv420p16be d7270efce54eb59c7b01c14157a1b890 +yuv420p16le e85abf00bad940a922b623c91c9026d7 +yuv420p9be a073b2d93b2a7dce2069ba252bc43175 +yuv420p9le b67233c3c7d93763d07d88f697c145e1 yuv422p 918e37701ee7377d16a8a6c119c56a40 -yuv422p16be 837945d3a771366a5a72a4ed095a4f53 -yuv422p16le b8292ae9b52eb7afc3d8b93e8fd895b4 +yuv422p16be 5cd8fe1da161d21b65bf75bf4cb50c75 +yuv422p16le 3b545317b1f5e627751525fb2958d88e yuv440p 461503fdb9b90451020aa3b25ddf041c yuv444p 81b2eba962d12e8d64f003ac56f6faf2 -yuv444p16be fe2c4a3708c4f44a2d91f3c413f33caf -yuv444p16le 1b4fce808e546cd75ef01cdb91da26b5 +yuv444p16be 2bd3e992d1533f8e0978a8e0c7008243 +yuv444p16le daee5a461ae3bc53295c392e423aa1d7 yuva420p 8673a9131fb47de69788863f93a50eb7 yuvj420p 30427bd6caf5bda93a173dbebe759e09 yuvj422p fc8288f64fd149573f73cf8da05d8e6d diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index acead3d990..b440efa26b 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -42,8 +42,8 @@ yuv422p16be 8cdfbddf2dd4c44c3efef4ee00170eba yuv422p16le a2f421f6a1af950544081c1797de01ae yuv440p 876385e96165acf51271b20e5d85a416 yuv444p 9c3c667d1613b72d15bc6d851c5eb8f7 -yuv444p16be c73d2f57f90060d4126241aba04876d3 -yuv444p16le c9ab60ec1ae3ff50da524e83e3553add +yuv444p16be bb86de32c67dd49469989ac184b89592 +yuv444p16le 64b899f52d820b14d05ff95954c15790 yuva420p c705d1cf061d8c6580ac690b55f92276 yuvj420p 41fd02b204da0ab62452cd14b595e2e4 yuvj422p 7f6ca9bc1812cde02036d7d29a7cce43 From bf2cba453244a74331238a472fe0e309f116f4d9 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 8 Jul 2011 12:28:28 -0700 Subject: [PATCH 381/780] swscale: fix crash in 8-bpc bilinear output without alpha. We accessed the alpha array even it wasn't used and didn't exist, hence leading to a NULL pointer segfault. --- libswscale/swscale.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index a302373b85..527dd80e0c 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1136,7 +1136,8 @@ yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2], const int16_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], *vbuf0 = vbuf[0], *vbuf1 = vbuf[1], - *abuf0 = abuf[0], *abuf1 = abuf[1]; + *abuf0 = hasAlpha ? abuf[0] : NULL, + *abuf1 = hasAlpha ? abuf[1] : NULL; int yalpha1 = 4095 - yalpha; int uvalpha1 = 4095 - uvalpha; int i; From 7d7bacf0f1f43f5cc112977fc3b8438e3e4a4a9b Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 8 Jul 2011 14:57:07 -0700 Subject: [PATCH 382/780] swscale: fix overflow in 16-bit vertical scaling. We operated on 31-bits, but with e.g. lanczos scaling, values can add up to beyond 0x80000000, thus leading to output of zeroes. Drop one bit of precision fixes this. --- libswscale/swscale.c | 18 +++++++++--------- tests/ref/lavfi/pixdesc | 8 ++++---- tests/ref/lavfi/pixfmts_copy | 8 ++++---- tests/ref/lavfi/pixfmts_crop | 8 ++++---- tests/ref/lavfi/pixfmts_hflip | 8 ++++---- tests/ref/lavfi/pixfmts_null | 8 ++++---- tests/ref/lavfi/pixfmts_scale | 16 ++++++++-------- tests/ref/lavfi/pixfmts_vflip | 8 ++++---- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 527dd80e0c..db4d231e13 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -195,7 +195,7 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, int i; uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; - int shift = 15 + 16 - output_bits; + int shift = 15 + 16 - output_bits - 1; #define output_pixel(pos, val) \ if (big_endian) { \ @@ -212,24 +212,24 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, } \ } for (i = 0; i < dstW; i++) { - int val = 1 << (30-output_bits); + int val = 1 << (30-output_bits - 1); int j; for (j = 0; j < lumFilterSize; j++) - val += lumSrc[j][i] * lumFilter[j]; + val += (lumSrc[j][i] * lumFilter[j]) >> 1; output_pixel(&yDest[i], val); } if (uDest) { for (i = 0; i < chrDstW; i++) { - int u = 1 << (30-output_bits); - int v = 1 << (30-output_bits); + int u = 1 << (30-output_bits - 1); + int v = 1 << (30-output_bits - 1); int j; for (j = 0; j < chrFilterSize; j++) { - u += chrUSrc[j][i] * chrFilter[j]; - v += chrVSrc[j][i] * chrFilter[j]; + u += (chrUSrc[j][i] * chrFilter[j]) >> 1; + v += (chrVSrc[j][i] * chrFilter[j]) >> 1; } output_pixel(&uDest[i], u); @@ -239,11 +239,11 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, if (CONFIG_SWSCALE_ALPHA && aDest) { for (i = 0; i < dstW; i++) { - int val = 1 << (30-output_bits); + int val = 1 << (30-output_bits - 1); int j; for (j = 0; j < lumFilterSize; j++) - val += alpSrc[j][i] * lumFilter[j]; + val += (alpSrc[j][i] * lumFilter[j]) >> 1; output_pixel(&aDest[i], val); } diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc index 76d845abb8..a82f8ed9b6 100644 --- a/tests/ref/lavfi/pixdesc +++ b/tests/ref/lavfi/pixdesc @@ -38,12 +38,12 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p16be 86ad3447f97969ce095afeef81fa9abf -yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 +yuv422p16be dc9886f2fccf87cc54b27e071a2c251e +yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be 2a8e2bddfe4c208df4119aaa7dc5db28 -yuv444p16le f2117fc9cf66d3a832183e159ff71803 +yuv444p16be af555dbaa401b142a995566864f47545 +yuv444p16le a803e8016997dad95c5b2a72f54c34d6 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index 76d845abb8..a82f8ed9b6 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -38,12 +38,12 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p16be 86ad3447f97969ce095afeef81fa9abf -yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 +yuv422p16be dc9886f2fccf87cc54b27e071a2c251e +yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be 2a8e2bddfe4c208df4119aaa7dc5db28 -yuv444p16le f2117fc9cf66d3a832183e159ff71803 +yuv444p16be af555dbaa401b142a995566864f47545 +yuv444p16le a803e8016997dad95c5b2a72f54c34d6 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_crop b/tests/ref/lavfi/pixfmts_crop index fb5c838a4e..e3bb88c101 100644 --- a/tests/ref/lavfi/pixfmts_crop +++ b/tests/ref/lavfi/pixfmts_crop @@ -29,12 +29,12 @@ yuv420p bfea0188ddd4889787c403caae119cc7 yuv420p16be 8365eff38b8c329aeb95fc605fa229bb yuv420p16le 5e8dd38d973d5854abe1ad4efad20cc1 yuv422p f2f930a91fe00d4252c4720b5ecd8961 -yuv422p16be 6647fe1c381c148f8207c988c0e22bf0 -yuv422p16le e1548c9dc51202db38a9625c8954203f +yuv422p16be 93f9b6f33f9529db6de6a9f0ddd70eb5 +yuv422p16le 2e66dcfec54ca6b57aa4bbd9ac234639 yuv440p 2472417d980e395ad6843cbb8b633b29 yuv444p 1f151980486848c96bc5585ced99003e -yuv444p16be 02d78b564a23df2f68cf6895d3bfe6bf -yuv444p16le cbea9591b954ea31d6a0cb25a9aed599 +yuv444p16be e7d1ecf0c11a41b5db192f761f55bd3c +yuv444p16le 3298a0043d982e7cf1a33a1292fa11f0 yuva420p 7536753dfbc7932560fb50c921369a0e yuvj420p 21f891093006d42d7683b0e1d773a657 yuvj422p 9a43d474c407590ad8f213880586b45e diff --git a/tests/ref/lavfi/pixfmts_hflip b/tests/ref/lavfi/pixfmts_hflip index 4a32e35a1c..2084d581e1 100644 --- a/tests/ref/lavfi/pixfmts_hflip +++ b/tests/ref/lavfi/pixfmts_hflip @@ -29,12 +29,12 @@ yuv420p 2d5c80f9ba2ddd85b2aeda3564cc7d64 yuv420p16be 758b0c1e2113b15e7afde48da4e4d024 yuv420p16le 480ccd951dcb806bc875d307e02e50a0 yuv422p 6e728f4eb9eae287c224f396d84be6ea -yuv422p16be 9dbe0af0eb877987611cf04bfa577202 -yuv422p16le 2d8f37231110177cc5e1b61c8cb4b163 +yuv422p16be 8657d2c8d443940300fdb4028d555631 +yuv422p16le 4ab27609981e50de5b1150125718ae76 yuv440p a99e2b57ed601f39852715c9d675d0d3 yuv444p 947e47f7bb5fdccc659d19b7df2b6fc3 -yuv444p16be 38cdb28061ebb8e7aa3797238615e77f -yuv444p16le 80d654986d6f3754e924310a045fdb24 +yuv444p16be a5154ce329db0d2caf0bd43f1347dba3 +yuv444p16le 1f703308b90feb048191b3bccc695671 yuva420p d83ec0c01498189f179ec574918185f1 yuvj420p df3aaaec3bb157c3bde5f0365af30f4f yuvj422p d113871528d510a192797af59df9c05c diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index 76d845abb8..a82f8ed9b6 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -38,12 +38,12 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p16be 86ad3447f97969ce095afeef81fa9abf -yuv422p16le a53a9b451f4a81eeae33362c1bbd07f8 +yuv422p16be dc9886f2fccf87cc54b27e071a2c251e +yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be 2a8e2bddfe4c208df4119aaa7dc5db28 -yuv444p16le f2117fc9cf66d3a832183e159ff71803 +yuv444p16be af555dbaa401b142a995566864f47545 +yuv444p16le a803e8016997dad95c5b2a72f54c34d6 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index 14c748ff10..094e52462f 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -31,19 +31,19 @@ uyvy422 314bd486277111a95d9369b944fa0400 yuv410p 7df8f6d69b56a8dcb6c7ee908e5018b5 yuv411p 1143e7c5cc28fe0922b051b17733bc4c yuv420p fdad2d8df8985e3d17e73c71f713cb14 -yuv420p10be aad747a7634ba4ed48f149cdfc78792e -yuv420p10le 46547f19a7f58638dff73657477b11b9 -yuv420p16be d7270efce54eb59c7b01c14157a1b890 -yuv420p16le e85abf00bad940a922b623c91c9026d7 +yuv420p10be af5429f27b9f95bf955e795921c65cdc +yuv420p10le d0b47e6a8a44e6b5ca0fe4349a4e393b +yuv420p16be 9688e33e03b8c8275ab2fb1df0f06bee +yuv420p16le cba8b390ad5e7b8678e419b8ce79c008 yuv420p9be a073b2d93b2a7dce2069ba252bc43175 yuv420p9le b67233c3c7d93763d07d88f697c145e1 yuv422p 918e37701ee7377d16a8a6c119c56a40 -yuv422p16be 5cd8fe1da161d21b65bf75bf4cb50c75 -yuv422p16le 3b545317b1f5e627751525fb2958d88e +yuv422p16be 2cf502d7d386db1f1b3b946679d897b1 +yuv422p16le 3002a4e47520731dcee5929aff49eb74 yuv440p 461503fdb9b90451020aa3b25ddf041c yuv444p 81b2eba962d12e8d64f003ac56f6faf2 -yuv444p16be 2bd3e992d1533f8e0978a8e0c7008243 -yuv444p16le daee5a461ae3bc53295c392e423aa1d7 +yuv444p16be b9f051ce7335923fe33efd162e48da1d +yuv444p16le fa47e317efac988b4a7fa55141c89126 yuva420p 8673a9131fb47de69788863f93a50eb7 yuvj420p 30427bd6caf5bda93a173dbebe759e09 yuvj422p fc8288f64fd149573f73cf8da05d8e6d diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index b440efa26b..8702eca796 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -38,12 +38,12 @@ yuv420p16le 0f609e588e5a258644ef85170d70e030 yuv420p9be be40ec975fb2873891643cbbbddbc3b0 yuv420p9le 7e606310d3f5ff12badf911e8f333471 yuv422p d7f5cb44d9b0210d66d6a8762640ab34 -yuv422p16be 8cdfbddf2dd4c44c3efef4ee00170eba -yuv422p16le a2f421f6a1af950544081c1797de01ae +yuv422p16be 51d9aa4e78d121c226d919ce97976fe4 +yuv422p16le 12965c54bda8932ca72da194419a9908 yuv440p 876385e96165acf51271b20e5d85a416 yuv444p 9c3c667d1613b72d15bc6d851c5eb8f7 -yuv444p16be bb86de32c67dd49469989ac184b89592 -yuv444p16le 64b899f52d820b14d05ff95954c15790 +yuv444p16be 6502abd75030d462c58d99a8673ec517 +yuv444p16le cd7e88b6d08425450a57555bc86ab210 yuva420p c705d1cf061d8c6580ac690b55f92276 yuvj420p 41fd02b204da0ab62452cd14b595e2e4 yuvj422p 7f6ca9bc1812cde02036d7d29a7cce43 From 4e3e333a79272944b40695166438359b376d7864 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 5 Jul 2011 12:49:11 -0700 Subject: [PATCH 383/780] swscale: error dithering for 16/9/10-bit to 8-bit. Based on a somewhat similar idea in FFmpeg's swscale copy. --- libswscale/swscale.c | 49 ++++++++--- libswscale/swscale_internal.h | 6 ++ libswscale/x86/swscale_template.c | 135 ++++++++++++++++++++++++++---- 3 files changed, 160 insertions(+), 30 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index db4d231e13..dd9f4a108f 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -182,6 +182,18 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={ { 77, 23, 60, 15, 72, 21, 56, 14, }, }; #endif +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_128)[8][8] = { +{ 36, 68, 60, 92, 34, 66, 58, 90,}, +{ 100, 4,124, 28, 98, 2,122, 26,}, +{ 52, 84, 44, 76, 50, 82, 42, 74,}, +{ 116, 20,108, 12,114, 18,106, 10,}, +{ 32, 64, 56, 88, 38, 70, 62, 94,}, +{ 96, 0,120, 24,102, 6,126, 30,}, +{ 48, 80, 40, 72, 54, 86, 46, 78,}, +{ 112, 16,104, 8,118, 22,110, 14,}, +}; +DECLARE_ALIGNED(8, const uint8_t, ff_sws_pb_64)[8] = +{ 64, 64, 64, 64, 64, 64, 64, 64 }; static av_always_inline void yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, @@ -285,10 +297,11 @@ static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; int i; + const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; //FIXME Optimize (just quickly written not optimized..) for (i=0; ilumDither8, *chrDither = c->chrDither8; for (i=0; i>7; + int val = (lumSrc[i]+ lumDither[i & 7]) >> 7; yDest[i]= av_clip_uint8(val); } if (uDest) for (i=0; i>7; - int v=(chrVSrc[i]+64)>>7; + int u = (chrUSrc[i] + chrDither[i & 7]) >> 7; + int v = (chrVSrc[i] + chrDither[(i + 3) & 7]) >> 7; uDest[i]= av_clip_uint8(u); vDest[i]= av_clip_uint8(v); } if (CONFIG_SWSCALE_ALPHA && aDest) for (i=0; i>7; + int val = (alpSrc[i] + lumDither[i & 7]) >> 7; aDest[i]= av_clip_uint8(val); } } @@ -359,11 +373,12 @@ static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, { uint8_t *yDest = dest[0], *uDest = dest[1]; enum PixelFormat dstFormat = c->dstFormat; + const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; //FIXME Optimize (just quickly written not optimized..) int i; for (i=0; iyuv2packed1; yuv2packed2_fn yuv2packed2 = c->yuv2packed2; yuv2packedX_fn yuv2packedX = c->yuv2packedX; + int should_dither = is9_OR_10BPS(c->srcFormat) || is16BPS(c->srcFormat); /* vars which will change and which we need to store back in the context */ int dstY= c->dstY; @@ -2401,6 +2417,9 @@ static int swScale(SwsContext *c, const uint8_t* src[], lastInChrBuf= -1; } + if (!should_dither) { + c->chrDither8 = c->lumDither8 = ff_sws_pb_64; + } lastDstY= dstY; for (;dstY < dstH; dstY++) { @@ -2490,6 +2509,10 @@ static int swScale(SwsContext *c, const uint8_t* src[], #if HAVE_MMX updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf); #endif + if (should_dither) { + c->chrDither8 = dither_8x8_128[chrDstY & 7]; + c->lumDither8 = dither_8x8_128[dstY & 7]; + } if (dstY >= dstH-2) { // hmm looks like we can't use MMX here without overwriting this array's tail find_c_packed_planar_out_funcs(c, &yuv2yuv1, &yuv2yuvX, diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index b3698a3d94..efb8aff088 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -321,6 +321,8 @@ typedef struct SwsContext { #define ALP_MMX_FILTER_OFFSET "11*8+4*4*256*2+48" #define UV_OFF "11*8+4*4*256*3+48" #define UV_OFFx2 "11*8+4*4*256*3+56" +#define DITHER16 "11*8+4*4*256*3+64" +#define DITHER32 "11*8+4*4*256*3+80" DECLARE_ALIGNED(8, uint64_t, redDither); DECLARE_ALIGNED(8, uint64_t, greenDither); @@ -345,6 +347,10 @@ typedef struct SwsContext { int32_t alpMmxFilter[4*MAX_FILTER_SIZE]; DECLARE_ALIGNED(8, ptrdiff_t, uv_off); ///< offset (in pixels) between u and v planes DECLARE_ALIGNED(8, ptrdiff_t, uv_offx2); ///< offset (in bytes) between u and v planes + uint16_t dither16[8]; + uint32_t dither32[8]; + + const uint8_t *chrDither8, *lumDither8; #if HAVE_ALTIVEC vector signed short CY; diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 26cd2742a3..fd6ec3a793 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -37,8 +37,8 @@ #define YSCALEYUV2YV12X(offset, dest, end, pos) \ __asm__ volatile(\ - "movq "VROUNDER_OFFSET"(%0), %%mm3 \n\t"\ - "movq %%mm3, %%mm4 \n\t"\ + "movq "DITHER16"+0(%0), %%mm3 \n\t"\ + "movq "DITHER16"+8(%0), %%mm4 \n\t"\ "lea " offset "(%0), %%"REG_d" \n\t"\ "mov (%%"REG_d"), %%"REG_S" \n\t"\ ".p2align 4 \n\t" /* FIXME Unroll? */\ @@ -60,8 +60,8 @@ MOVNTQ(%%mm3, (%1, %3))\ "add $8, %3 \n\t"\ "cmp %2, %3 \n\t"\ - "movq "VROUNDER_OFFSET"(%0), %%mm3 \n\t"\ - "movq %%mm3, %%mm4 \n\t"\ + "movq "DITHER16"+0(%0), %%mm3 \n\t"\ + "movq "DITHER16"+8(%0), %%mm4 \n\t"\ "lea " offset "(%0), %%"REG_d" \n\t"\ "mov (%%"REG_d"), %%"REG_S" \n\t"\ "jb 1b \n\t"\ @@ -70,6 +70,42 @@ : "%"REG_d, "%"REG_S\ ); +#if !COMPILE_TEMPLATE_MMX2 +static av_always_inline void +dither_8to16(SwsContext *c, const uint8_t *srcDither, int rot) +{ + if (rot) { + __asm__ volatile("pxor %%mm0, %%mm0\n\t" + "movq (%0), %%mm3\n\t" + "movq %%mm3, %%mm4\n\t" + "psrlq $24, %%mm3\n\t" + "psllq $40, %%mm4\n\t" + "por %%mm4, %%mm3\n\t" + "movq %%mm3, %%mm4\n\t" + "punpcklbw %%mm0, %%mm3\n\t" + "punpckhbw %%mm0, %%mm4\n\t" + "psraw $4, %%mm3\n\t" + "psraw $4, %%mm4\n\t" + "movq %%mm3, "DITHER16"+0(%1)\n\t" + "movq %%mm4, "DITHER16"+8(%1)\n\t" + :: "r"(srcDither), "r"(&c->redDither) + ); + } else { + __asm__ volatile("pxor %%mm0, %%mm0\n\t" + "movq (%0), %%mm3\n\t" + "movq %%mm3, %%mm4\n\t" + "punpcklbw %%mm0, %%mm3\n\t" + "punpckhbw %%mm0, %%mm4\n\t" + "psraw $4, %%mm3\n\t" + "psraw $4, %%mm4\n\t" + "movq %%mm3, "DITHER16"+0(%1)\n\t" + "movq %%mm4, "DITHER16"+8(%1)\n\t" + :: "r"(srcDither), "r"(&c->redDither) + ); + } +} +#endif + static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, @@ -79,12 +115,16 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, { uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; + const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; if (uDest) { x86_reg uv_off = c->uv_offx2 >> 1; + dither_8to16(c, chrDither, 0); YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) + dither_8to16(c, chrDither, 1); YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, vDest - uv_off, chrDstW + uv_off, uv_off) } + dither_8to16(c, lumDither, 0); if (CONFIG_SWSCALE_ALPHA && aDest) { YSCALEYUV2YV12X(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0) } @@ -95,10 +135,10 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, #define YSCALEYUV2YV12X_ACCURATE(offset, dest, end, pos) \ __asm__ volatile(\ "lea " offset "(%0), %%"REG_d" \n\t"\ - "pxor %%mm4, %%mm4 \n\t"\ - "pxor %%mm5, %%mm5 \n\t"\ - "pxor %%mm6, %%mm6 \n\t"\ - "pxor %%mm7, %%mm7 \n\t"\ + "movq "DITHER32"+0(%0), %%mm4 \n\t"\ + "movq "DITHER32"+8(%0), %%mm5 \n\t"\ + "movq "DITHER32"+16(%0), %%mm6 \n\t"\ + "movq "DITHER32"+24(%0), %%mm7 \n\t"\ "mov (%%"REG_d"), %%"REG_S" \n\t"\ ".p2align 4 \n\t"\ "1: \n\t"\ @@ -142,10 +182,10 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, "add $8, %3 \n\t"\ "cmp %2, %3 \n\t"\ "lea " offset "(%0), %%"REG_d" \n\t"\ - "pxor %%mm4, %%mm4 \n\t"\ - "pxor %%mm5, %%mm5 \n\t"\ - "pxor %%mm6, %%mm6 \n\t"\ - "pxor %%mm7, %%mm7 \n\t"\ + "movq "DITHER32"+0(%0), %%mm4 \n\t"\ + "movq "DITHER32"+8(%0), %%mm5 \n\t"\ + "movq "DITHER32"+16(%0), %%mm6 \n\t"\ + "movq "DITHER32"+24(%0), %%mm7 \n\t"\ "mov (%%"REG_d"), %%"REG_S" \n\t"\ "jb 1b \n\t"\ :: "r" (&c->redDither),\ @@ -153,6 +193,62 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, : "%"REG_a, "%"REG_d, "%"REG_S\ ); +#if !COMPILE_TEMPLATE_MMX2 +static av_always_inline void +dither_8to32(SwsContext *c, const uint8_t *srcDither, int rot) +{ + if (rot) { + __asm__ volatile("pxor %%mm0, %%mm0\n\t" + "movq (%0), %%mm4\n\t" + "movq %%mm4, %%mm5\n\t" + "psrlq $24, %%mm4\n\t" + "psllq $40, %%mm5\n\t" + "por %%mm5, %%mm4\n\t" + "movq %%mm4, %%mm6\n\t" + "punpcklbw %%mm0, %%mm4\n\t" + "punpckhbw %%mm0, %%mm6\n\t" + "movq %%mm4, %%mm5\n\t" + "movq %%mm6, %%mm7\n\t" + "punpcklwd %%mm0, %%mm4\n\t" + "punpckhwd %%mm0, %%mm5\n\t" + "punpcklwd %%mm0, %%mm6\n\t" + "punpckhwd %%mm0, %%mm7\n\t" + "psllw $12, %%mm4\n\t" + "psllw $12, %%mm5\n\t" + "psllw $12, %%mm6\n\t" + "psllw $12, %%mm7\n\t" + "movq %%mm3, "DITHER32"+0(%1)\n\t" + "movq %%mm4, "DITHER32"+8(%1)\n\t" + "movq %%mm4, "DITHER32"+16(%1)\n\t" + "movq %%mm4, "DITHER32"+24(%1)\n\t" + :: "r"(srcDither), "r"(&c->redDither) + ); + } else { + __asm__ volatile("pxor %%mm0, %%mm0\n\t" + "movq (%0), %%mm4\n\t" + "movq %%mm4, %%mm6\n\t" + "punpcklbw %%mm0, %%mm4\n\t" + "punpckhbw %%mm0, %%mm6\n\t" + "movq %%mm4, %%mm5\n\t" + "movq %%mm6, %%mm7\n\t" + "punpcklwd %%mm0, %%mm4\n\t" + "punpckhwd %%mm0, %%mm5\n\t" + "punpcklwd %%mm0, %%mm6\n\t" + "punpckhwd %%mm0, %%mm7\n\t" + "psllw $12, %%mm4\n\t" + "psllw $12, %%mm5\n\t" + "psllw $12, %%mm6\n\t" + "psllw $12, %%mm7\n\t" + "movq %%mm3, "DITHER32"+0(%1)\n\t" + "movq %%mm4, "DITHER32"+8(%1)\n\t" + "movq %%mm4, "DITHER32"+16(%1)\n\t" + "movq %%mm4, "DITHER32"+24(%1)\n\t" + :: "r"(srcDither), "r"(&c->redDither) + ); + } +} +#endif + static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, @@ -162,12 +258,16 @@ static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, { uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; + const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; if (uDest) { x86_reg uv_off = c->uv_offx2 >> 1; + dither_8to32(c, chrDither, 0); YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) + dither_8to32(c, chrDither, 1); YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, vDest - uv_off, chrDstW + uv_off, uv_off) } + dither_8to32(c, lumDither, 0); if (CONFIG_SWSCALE_ALPHA && aDest) { YSCALEYUV2YV12X_ACCURATE(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0) } @@ -220,19 +320,20 @@ static void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc, chrVSrc + chrDstW, alpSrc + dstW }; x86_reg counter[4]= { dstW, chrDstW, chrDstW, dstW }; + const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; while (p--) { if (dst[p]) { + dither_8to16(c, (p == 2 || p == 3) ? chrDither : lumDither, p == 2); __asm__ volatile( "mov %2, %%"REG_a" \n\t" - "pcmpeqw %%mm7, %%mm7 \n\t" - "psrlw $15, %%mm7 \n\t" - "psllw $6, %%mm7 \n\t" + "movq "DITHER16"+0(%3), %%mm6 \n\t" + "movq "DITHER16"+8(%3), %%mm7 \n\t" ".p2align 4 \n\t" /* FIXME Unroll? */ "1: \n\t" "movq (%0, %%"REG_a", 2), %%mm0 \n\t" "movq 8(%0, %%"REG_a", 2), %%mm1 \n\t" - "paddsw %%mm7, %%mm0 \n\t" + "paddsw %%mm6, %%mm0 \n\t" "paddsw %%mm7, %%mm1 \n\t" "psraw $7, %%mm0 \n\t" "psraw $7, %%mm1 \n\t" @@ -241,7 +342,7 @@ static void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc, "add $8, %%"REG_a" \n\t" "jnc 1b \n\t" :: "r" (src[p]), "r" (dst[p] + counter[p]), - "g" (-counter[p]) + "g" (-counter[p]), "r"(&c->redDither) : "%"REG_a ); } From 1ce724ee393a04a79cab9e7c28290fe7d82dadf2 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 5 Jul 2011 20:48:13 -0700 Subject: [PATCH 384/780] swscale: implement error dithering in planarCopyWrapper. Based on a somewhat similar idea in FFmpeg's swscale. --- libswscale/swscale_unscaled.c | 109 ++++++++++++++++++++++++++++------ 1 file changed, 90 insertions(+), 19 deletions(-) diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 87cd655a46..b8daa6b4e7 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -34,6 +34,48 @@ #include "libavutil/bswap.h" #include "libavutil/pixdesc.h" +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_1)[8][8] = { + { 0, 1, 0, 1, 0, 1, 0, 1,}, + { 1, 0, 1, 0, 1, 0, 1, 0,}, + { 0, 1, 0, 1, 0, 1, 0, 1,}, + { 1, 0, 1, 0, 1, 0, 1, 0,}, + { 0, 1, 0, 1, 0, 1, 0, 1,}, + { 1, 0, 1, 0, 1, 0, 1, 0,}, + { 0, 1, 0, 1, 0, 1, 0, 1,}, + { 1, 0, 1, 0, 1, 0, 1, 0,}, +}; +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_3)[8][8] = { + { 1, 2, 1, 2, 1, 2, 1, 2,}, + { 3, 0, 3, 0, 3, 0, 3, 0,}, + { 1, 2, 1, 2, 1, 2, 1, 2,}, + { 3, 0, 3, 0, 3, 0, 3, 0,}, + { 1, 2, 1, 2, 1, 2, 1, 2,}, + { 3, 0, 3, 0, 3, 0, 3, 0,}, + { 1, 2, 1, 2, 1, 2, 1, 2,}, + { 3, 0, 3, 0, 3, 0, 3, 0,}, +}; +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_64)[8][8] = { + { 18, 34, 30, 46, 17, 33, 29, 45,}, + { 50, 2, 62, 14, 49, 1, 61, 13,}, + { 26, 42, 22, 38, 25, 41, 21, 37,}, + { 58, 10, 54, 6, 57, 9, 53, 5,}, + { 16, 32, 28, 44, 19, 35, 31, 47,}, + { 48, 0, 60, 12, 51, 3, 63, 15,}, + { 24, 40, 20, 36, 27, 43, 23, 39,}, + { 56, 8, 52, 4, 59, 11, 55, 7,}, +}; +extern const uint8_t dither_8x8_128[8][8]; +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_256)[8][8] = { + { 72, 136, 120, 184, 68, 132, 116, 180,}, + { 200, 8, 248, 56, 196, 4, 244, 52,}, + { 104, 168, 88, 152, 100, 164, 84, 148,}, + { 232, 40, 216, 24, 228, 36, 212, 20,}, + { 64, 128, 102, 176, 76, 140, 124, 188,}, + { 192, 0, 240, 48, 204, 12, 252, 60,}, + { 96, 160, 80, 144, 108, 172, 92, 156,}, + { 224, 32, 208, 16, 236, 44, 220, 28,}, +}; + #define RGB2YUV_SHIFT 15 #define BY ( (int)(0.114*219/255*(1<> shift); \ + wfunc(&dst[j + 1], (rfunc(&src[j + 1]) + dither[1]) >> shift); \ + wfunc(&dst[j + 2], (rfunc(&src[j + 2]) + dither[2]) >> shift); \ + wfunc(&dst[j + 3], (rfunc(&src[j + 3]) + dither[3]) >> shift); \ + wfunc(&dst[j + 4], (rfunc(&src[j + 4]) + dither[4]) >> shift); \ + wfunc(&dst[j + 5], (rfunc(&src[j + 5]) + dither[5]) >> shift); \ + wfunc(&dst[j + 6], (rfunc(&src[j + 6]) + dither[6]) >> shift); \ + wfunc(&dst[j + 7], (rfunc(&src[j + 7]) + dither[7]) >> shift); \ + } \ + for (; j < length; j++) \ + wfunc(&dst[j], (rfunc(&src[j]) + dither[j & 7]) >> shift); \ + dst += dstStride; \ + src += srcStride; \ + } + static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]) { @@ -475,7 +536,9 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ COPY9_OR_10TO9_OR_10(int srcpx = rfunc(&srcPtr2[j]); \ wfunc(&dstPtr2[j], (srcpx << 1) | (srcpx >> 9))); \ } else if (dst_depth < src_depth) { \ - COPY9_OR_10TO9_OR_10(wfunc(&dstPtr2[j], rfunc(&srcPtr2[j]) >> 1)); \ + DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \ + srcPtr2, srcStride[plane]/2, rfunc, \ + dither_8x8_1, 1); \ } else { \ COPY9_OR_10TO9_OR_10(wfunc(&dstPtr2[j], rfunc(&srcPtr2[j]))); \ } @@ -493,14 +556,16 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ } } } else { - // FIXME Maybe dither instead. +#define W8(a, b) { *(a) = (b); } #define COPY9_OR_10TO8(rfunc) \ - for (i = 0; i < height; i++) { \ - for (j = 0; j < length; j++) { \ - dstPtr[j] = rfunc(&srcPtr2[j])>>(src_depth-8); \ - } \ - dstPtr += dstStride[plane]; \ - srcPtr2 += srcStride[plane]/2; \ + if (src_depth == 9) { \ + DITHER_COPY(dstPtr, dstStride[plane], W8, \ + srcPtr2, srcStride[plane]/2, rfunc, \ + dither_8x8_1, 1); \ + } else { \ + DITHER_COPY(dstPtr, dstStride[plane], W8, \ + srcPtr2, srcStride[plane]/2, rfunc, \ + dither_8x8_3, 2); \ } if (isBE(c->srcFormat)) { COPY9_OR_10TO8(AV_RB16); @@ -515,12 +580,14 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ if (is16BPS(c->srcFormat)) { const uint16_t *srcPtr2 = (const uint16_t*)srcPtr; #define COPY16TO9_OR_10(rfunc, wfunc) \ - for (i = 0; i < height; i++) { \ - for (j = 0; j < length; j++) { \ - wfunc(&dstPtr2[j], rfunc(&srcPtr2[j])>>(16-dst_depth)); \ - } \ - dstPtr2 += dstStride[plane]/2; \ - srcPtr2 += srcStride[plane]/2; \ + if (dst_depth == 9) { \ + DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \ + srcPtr2, srcStride[plane]/2, rfunc, \ + dither_8x8_128, 7); \ + } else { \ + DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \ + srcPtr2, srcStride[plane]/2, rfunc, \ + dither_8x8_64, 6); \ } if (isBE(c->dstFormat)) { if (isBE(c->srcFormat)) { @@ -552,11 +619,15 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ } } } else if(is16BPS(c->srcFormat) && !is16BPS(c->dstFormat)) { - if (!isBE(c->srcFormat)) srcPtr++; - for (i=0; isrcFormat)) { + COPY16TO8(AV_RB16); + } else { + COPY16TO8(AV_RL16); } } else if(!is16BPS(c->srcFormat) && is16BPS(c->dstFormat)) { for (i=0; i Date: Fri, 8 Jul 2011 14:39:04 -0700 Subject: [PATCH 385/780] swscale: rename uv_off/uv_off2 to uv_off_px/byte. --- libswscale/swscale_internal.h | 8 ++-- libswscale/utils.c | 4 +- libswscale/x86/swscale_template.c | 80 +++++++++++++++---------------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index efb8aff088..b602541044 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -319,8 +319,8 @@ typedef struct SwsContext { #define V_TEMP "11*8+4*4*256*2+32" #define Y_TEMP "11*8+4*4*256*2+40" #define ALP_MMX_FILTER_OFFSET "11*8+4*4*256*2+48" -#define UV_OFF "11*8+4*4*256*3+48" -#define UV_OFFx2 "11*8+4*4*256*3+56" +#define UV_OFF_PX "11*8+4*4*256*3+48" +#define UV_OFF_BYTE "11*8+4*4*256*3+56" #define DITHER16 "11*8+4*4*256*3+64" #define DITHER32 "11*8+4*4*256*3+80" @@ -345,8 +345,8 @@ typedef struct SwsContext { DECLARE_ALIGNED(8, uint64_t, v_temp); DECLARE_ALIGNED(8, uint64_t, y_temp); int32_t alpMmxFilter[4*MAX_FILTER_SIZE]; - DECLARE_ALIGNED(8, ptrdiff_t, uv_off); ///< offset (in pixels) between u and v planes - DECLARE_ALIGNED(8, ptrdiff_t, uv_offx2); ///< offset (in bytes) between u and v planes + DECLARE_ALIGNED(8, ptrdiff_t, uv_off_px); ///< offset (in pixels) between u and v planes + DECLARE_ALIGNED(8, ptrdiff_t, uv_off_byte); ///< offset (in bytes) between u and v planes uint16_t dither16[8]; uint32_t dither32[8]; diff --git a/libswscale/utils.c b/libswscale/utils.c index fd10fa03fb..296c84557d 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1048,8 +1048,8 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i+c->vLumBufSize], dst_stride+1, fail); c->lumPixBuf[i] = c->lumPixBuf[i+c->vLumBufSize]; } - c->uv_off = dst_stride_px; - c->uv_offx2 = dst_stride; + c->uv_off_px = dst_stride_px; + c->uv_off_byte = dst_stride; for (i=0; ivChrBufSize; i++) { FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i+c->vChrBufSize], dst_stride*2+1, fail); c->chrUPixBuf[i] = c->chrUPixBuf[i+c->vChrBufSize]; diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index fd6ec3a793..28ec4d2d9c 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -118,7 +118,7 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; if (uDest) { - x86_reg uv_off = c->uv_offx2 >> 1; + x86_reg uv_off = c->uv_off_byte >> 1; dither_8to16(c, chrDither, 0); YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) dither_8to16(c, chrDither, 1); @@ -213,14 +213,14 @@ dither_8to32(SwsContext *c, const uint8_t *srcDither, int rot) "punpckhwd %%mm0, %%mm5\n\t" "punpcklwd %%mm0, %%mm6\n\t" "punpckhwd %%mm0, %%mm7\n\t" - "psllw $12, %%mm4\n\t" - "psllw $12, %%mm5\n\t" - "psllw $12, %%mm6\n\t" - "psllw $12, %%mm7\n\t" - "movq %%mm3, "DITHER32"+0(%1)\n\t" - "movq %%mm4, "DITHER32"+8(%1)\n\t" - "movq %%mm4, "DITHER32"+16(%1)\n\t" - "movq %%mm4, "DITHER32"+24(%1)\n\t" + "pslld $12, %%mm4\n\t" + "pslld $12, %%mm5\n\t" + "pslld $12, %%mm6\n\t" + "pslld $12, %%mm7\n\t" + "movq %%mm4, "DITHER32"+0(%1)\n\t" + "movq %%mm5, "DITHER32"+8(%1)\n\t" + "movq %%mm6, "DITHER32"+16(%1)\n\t" + "movq %%mm7, "DITHER32"+24(%1)\n\t" :: "r"(srcDither), "r"(&c->redDither) ); } else { @@ -235,14 +235,14 @@ dither_8to32(SwsContext *c, const uint8_t *srcDither, int rot) "punpckhwd %%mm0, %%mm5\n\t" "punpcklwd %%mm0, %%mm6\n\t" "punpckhwd %%mm0, %%mm7\n\t" - "psllw $12, %%mm4\n\t" - "psllw $12, %%mm5\n\t" - "psllw $12, %%mm6\n\t" - "psllw $12, %%mm7\n\t" - "movq %%mm3, "DITHER32"+0(%1)\n\t" - "movq %%mm4, "DITHER32"+8(%1)\n\t" - "movq %%mm4, "DITHER32"+16(%1)\n\t" - "movq %%mm4, "DITHER32"+24(%1)\n\t" + "pslld $12, %%mm4\n\t" + "pslld $12, %%mm5\n\t" + "pslld $12, %%mm6\n\t" + "pslld $12, %%mm7\n\t" + "movq %%mm4, "DITHER32"+0(%1)\n\t" + "movq %%mm5, "DITHER32"+8(%1)\n\t" + "movq %%mm6, "DITHER32"+16(%1)\n\t" + "movq %%mm7, "DITHER32"+24(%1)\n\t" :: "r"(srcDither), "r"(&c->redDither) ); } @@ -261,7 +261,7 @@ static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; if (uDest) { - x86_reg uv_off = c->uv_offx2 >> 1; + x86_reg uv_off = c->uv_off_byte >> 1; dither_8to32(c, chrDither, 0); YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) dither_8to32(c, chrDither, 1); @@ -574,7 +574,7 @@ static void RENAME(yuv2rgb32_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_offx2; + x86_reg uv_off = c->uv_off_byte; if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { YSCALEYUV2PACKEDX_ACCURATE @@ -607,7 +607,7 @@ static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_offx2; + x86_reg uv_off = c->uv_off_byte; if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { YSCALEYUV2PACKEDX @@ -664,7 +664,7 @@ static void RENAME(yuv2rgb565_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_offx2; + x86_reg uv_off = c->uv_off_byte; YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX @@ -688,7 +688,7 @@ static void RENAME(yuv2rgb565_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_offx2; + x86_reg uv_off = c->uv_off_byte; YSCALEYUV2PACKEDX YSCALEYUV2RGBX @@ -741,7 +741,7 @@ static void RENAME(yuv2rgb555_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_offx2; + x86_reg uv_off = c->uv_off_byte; YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX @@ -765,7 +765,7 @@ static void RENAME(yuv2rgb555_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_offx2; + x86_reg uv_off = c->uv_off_byte; YSCALEYUV2PACKEDX YSCALEYUV2RGBX @@ -898,7 +898,7 @@ static void RENAME(yuv2bgr24_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_offx2; + x86_reg uv_off = c->uv_off_byte; YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX @@ -922,7 +922,7 @@ static void RENAME(yuv2bgr24_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_offx2; + x86_reg uv_off = c->uv_off_byte; YSCALEYUV2PACKEDX YSCALEYUV2RGBX @@ -963,7 +963,7 @@ static void RENAME(yuv2yuyv422_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_offx2; + x86_reg uv_off = c->uv_off_byte; YSCALEYUV2PACKEDX_ACCURATE /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ @@ -984,7 +984,7 @@ static void RENAME(yuv2yuyv422_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_offx2; + x86_reg uv_off = c->uv_off_byte; YSCALEYUV2PACKEDX /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ @@ -1002,10 +1002,10 @@ static void RENAME(yuv2yuyv422_X)(SwsContext *c, const int16_t *lumFilter, "1: \n\t"\ "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ - "add "UV_OFFx2"("#c"), "#index" \n\t" \ + "add "UV_OFF_PX"("#c"), "#index" \n\t" \ "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ - "sub "UV_OFFx2"("#c"), "#index" \n\t" \ + "sub "UV_OFF_PX"("#c"), "#index" \n\t" \ "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\ "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\ "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\ @@ -1233,10 +1233,10 @@ static void RENAME(yuv2rgb565_2)(SwsContext *c, const int16_t *buf[2], "1: \n\t"\ "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ - "add "UV_OFFx2"("#c"), "#index" \n\t" \ + "add "UV_OFF_PX"("#c"), "#index" \n\t" \ "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ - "sub "UV_OFFx2"("#c"), "#index" \n\t" \ + "sub "UV_OFF_PX"("#c"), "#index" \n\t" \ "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\ "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\ "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\ @@ -1288,9 +1288,9 @@ static void RENAME(yuv2yuyv422_2)(SwsContext *c, const int16_t *buf[2], ".p2align 4 \n\t"\ "1: \n\t"\ "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\ - "add "UV_OFFx2"("#c"), "#index" \n\t" \ + "add "UV_OFF_PX"("#c"), "#index" \n\t" \ "movq (%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ - "sub "UV_OFFx2"("#c"), "#index" \n\t" \ + "sub "UV_OFF_PX"("#c"), "#index" \n\t" \ "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\ "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\ @@ -1341,10 +1341,10 @@ static void RENAME(yuv2yuyv422_2)(SwsContext *c, const int16_t *buf[2], "1: \n\t"\ "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ - "add "UV_OFFx2"("#c"), "#index" \n\t" \ + "add "UV_OFF_PX"("#c"), "#index" \n\t" \ "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ - "sub "UV_OFFx2"("#c"), "#index" \n\t" \ + "sub "UV_OFF_PX"("#c"), "#index" \n\t" \ "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\ "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\ "psrlw $5, %%mm3 \n\t" /*FIXME might overflow*/\ @@ -1608,9 +1608,9 @@ static void RENAME(yuv2rgb565_1)(SwsContext *c, const int16_t *buf0, ".p2align 4 \n\t"\ "1: \n\t"\ "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\ - "add "UV_OFFx2"("#c"), "#index" \n\t" \ + "add "UV_OFF_PX"("#c"), "#index" \n\t" \ "movq (%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ - "sub "UV_OFFx2"("#c"), "#index" \n\t" \ + "sub "UV_OFF_PX"("#c"), "#index" \n\t" \ "psraw $7, %%mm3 \n\t" \ "psraw $7, %%mm4 \n\t" \ "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\ @@ -1626,10 +1626,10 @@ static void RENAME(yuv2rgb565_1)(SwsContext *c, const int16_t *buf0, "1: \n\t"\ "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ - "add "UV_OFFx2"("#c"), "#index" \n\t" \ + "add "UV_OFF_PX"("#c"), "#index" \n\t" \ "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ - "sub "UV_OFFx2"("#c"), "#index" \n\t" \ + "sub "UV_OFF_PX"("#c"), "#index" \n\t" \ "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\ "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\ "psrlw $8, %%mm3 \n\t" \ From 971c04066c601bdd38ed5e8eb585d2f5ba211fe2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 9 Jul 2011 00:28:16 +0200 Subject: [PATCH 386/780] make the RELEASE file say git and not 0.7 Signed-off-by: Michael Niedermayer --- RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE b/RELEASE index eb49d7c7fd..5664e303b5 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -0.7 +git From c0483d0c7a8f12564f615dcd73890bcc2f7c2796 Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Sun, 3 Jul 2011 14:56:09 -0400 Subject: [PATCH 387/780] H.264: Add x86 assembly for 10-bit H.264 predict functions Mainly ported from 8-bit H.264 predict. Some code ported from x264. LGPL ok by author. Signed-off-by: Ronald S. Bultje --- libavcodec/x86/dsputil_mmx.c | 2 +- libavcodec/x86/h264_intrapred_10bit.asm | 931 ++++++++++++++++++++++++ libavcodec/x86/h264_intrapred_init.c | 58 ++ libavcodec/x86/x86util.asm | 8 + 4 files changed, 998 insertions(+), 1 deletion(-) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 7842370fcd..b06a34ddce 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -42,7 +42,7 @@ DECLARE_ALIGNED(8, const uint64_t, ff_wtwo) = 0x0002000200020002ULL; DECLARE_ALIGNED(16, const uint64_t, ff_pdw_80000000)[2] = {0x8000000080000000ULL, 0x8000000080000000ULL}; -DECLARE_ALIGNED(8, const uint64_t, ff_pw_1 ) = 0x0001000100010001ULL; +DECLARE_ALIGNED(16, const xmm_reg, ff_pw_1 ) = {0x0001000100010001ULL, 0x0001000100010001ULL}; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_2 ) = {0x0002000200020002ULL, 0x0002000200020002ULL}; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_3 ) = {0x0003000300030003ULL, 0x0003000300030003ULL}; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_4 ) = {0x0004000400040004ULL, 0x0004000400040004ULL}; diff --git a/libavcodec/x86/h264_intrapred_10bit.asm b/libavcodec/x86/h264_intrapred_10bit.asm index 5cb593ac38..d57fc79754 100644 --- a/libavcodec/x86/h264_intrapred_10bit.asm +++ b/libavcodec/x86/h264_intrapred_10bit.asm @@ -29,9 +29,13 @@ SECTION_RODATA SECTION .text +cextern pw_8 cextern pw_4 +cextern pw_2 cextern pw_1 +; dest, left, right, src +; output: %1 = (t[n-1] + t[n]*2 + t[n+1] + 2) >> 2 %macro PRED4x4_LOWPASS 4 paddw %2, %3 psrlw %2, 1 @@ -335,3 +339,930 @@ cglobal pred8x8_horizontal_10_sse2, 2,3 dec r2 jg .loop REP_RET + +;----------------------------------------------------------------------------- +; void predict_8x8_dc(pixel *src, int stride) +;----------------------------------------------------------------------------- +%macro MOV8 2-3 +; sort of a hack, but it works +%if mmsize==8 + movq [%1+0], %2 + movq [%1+8], %3 +%else + movdqa [%1], %2 +%endif +%endmacro + +%macro PRED8x8_DC 2 +cglobal pred8x8_dc_10_%1, 2,4 +%ifdef ARCH_X86_64 +%define t0 r10 +%else +%define t0 r0m +%endif + sub r0, r1 + pxor m4, m4 + movq m0, [r0+0] + movq m1, [r0+8] + HADDW m0, m2 + mov t0, r0 + HADDW m1, m2 + + movzx r2d, word [r0+r1*1-2] + movzx r3d, word [r0+r1*2-2] + lea r0, [r0+r1*2] + add r2d, r3d + movzx r3d, word [r0+r1*1-2] + add r2d, r3d + movzx r3d, word [r0+r1*2-2] + add r2d, r3d + lea r0, [r0+r1*2] + movd m2, r2d ; s2 + + movzx r2d, word [r0+r1*1-2] + movzx r3d, word [r0+r1*2-2] + lea r0, [r0+r1*2] + add r2d, r3d + movzx r3d, word [r0+r1*1-2] + add r2d, r3d + movzx r3d, word [r0+r1*2-2] + add r2d, r3d + movd m3, r2d ; s3 + + punpcklwd m0, m1 + mov r0, t0 + punpcklwd m2, m3 + punpckldq m0, m2 ; s0, s1, s2, s3 + %2 m3, m0, 11110110b ; s2, s1, s3, s3 + lea r2, [r1+r1*2] + %2 m0, m0, 01110100b ; s0, s1, s3, s1 + paddw m0, m3 + lea r3, [r0+r1*4] + psrlw m0, 2 + pavgw m0, m4 ; s0+s2, s1, s3, s1+s3 +%ifidn %1, sse2 + punpcklwd m0, m0 + pshufd m3, m0, 11111010b + punpckldq m0, m0 + SWAP 0,1 +%else + pshufw m1, m0, 0x00 + pshufw m2, m0, 0x55 + pshufw m3, m0, 0xaa + pshufw m4, m0, 0xff +%endif + MOV8 r0+r1*1, m1, m2 + MOV8 r0+r1*2, m1, m2 + MOV8 r0+r2*1, m1, m2 + MOV8 r0+r1*4, m1, m2 + MOV8 r3+r1*1, m3, m4 + MOV8 r3+r1*2, m3, m4 + MOV8 r3+r2*1, m3, m4 + MOV8 r3+r1*4, m3, m4 + RET +%endmacro + +INIT_MMX +PRED8x8_DC mmxext, pshufw +INIT_XMM +PRED8x8_DC sse2 , pshuflw + +;----------------------------------------------------------------------------- +; void pred8x8_top_dc(pixel *src, int stride) +;----------------------------------------------------------------------------- +%macro PRED8x8_TOP_DC 2 +cglobal pred8x8_top_dc_10_%1, 2,4 + sub r0, r1 + movq m0, [r0+0] + movq m1, [r0+8] + HADDW m0, m2 + HADDW m1, m3 + lea r2, [r1+r1*2] + paddw m0, [pw_2] + paddw m1, [pw_2] + lea r3, [r0+r1*4] + psrlw m0, 2 + psrlw m1, 2 + %2 m0, m0, 0 + %2 m1, m1, 0 +%ifidn %1, sse2 + punpcklqdq m0, m1 +%endif + MOV8 r0+r1*1, m0, m1 + MOV8 r0+r1*2, m0, m1 + MOV8 r0+r2*1, m0, m1 + MOV8 r0+r1*4, m0, m1 + MOV8 r3+r1*1, m0, m1 + MOV8 r3+r1*2, m0, m1 + MOV8 r3+r2*1, m0, m1 + MOV8 r3+r1*4, m0, m1 + RET +%endmacro + +INIT_MMX +PRED8x8_TOP_DC mmxext, pshufw +INIT_XMM +PRED8x8_TOP_DC sse2 , pshuflw + + + +;----------------------------------------------------------------------------- +; void pred8x8l_top_dc(pixel *src, int has_topleft, int has_topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED8x8L_TOP_DC 1 +cglobal pred8x8l_top_dc_10_%1, 4,4,6 + sub r0, r3 + pxor m7, m7 + mova m0, [r0-16] + mova m3, [r0] + mova m1, [r0+16] + mova m2, m3 + mova m4, m3 + PALIGNR m2, m0, 14, m0 + PALIGNR m1, m4, 2, m4 + test r1, r1 ; top_left + jz .fix_lt_2 + test r2, r2 ; top_right + jz .fix_tr_1 + jmp .body +.fix_lt_2: + mova m5, m3 + pxor m5, m2 + pslldq m5, 14 + psrldq m5, 14 + pxor m2, m5 + test r2, r2 ; top_right + jnz .body +.fix_tr_1: + mova m5, m3 + pxor m5, m1 + psrldq m5, 14 + pslldq m5, 14 + pxor m1, m5 +.body + lea r1, [r3+r3*2] + lea r2, [r0+r3*4] + PRED4x4_LOWPASS m0, m2, m1, m3 + HADDW m0, m1 + paddw m0, [pw_4] + psrlw m0, 3 + SPLATW m0, m0, 0 + mova [r0+r3*1], m0 + mova [r0+r3*2], m0 + mova [r0+r1*1], m0 + mova [r0+r3*4], m0 + mova [r2+r3*1], m0 + mova [r2+r3*2], m0 + mova [r2+r1*1], m0 + mova [r2+r3*4], m0 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED8x8L_TOP_DC sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED8x8L_TOP_DC ssse3 + +;----------------------------------------------------------------------------- +;void pred8x8l_dc(pixel *src, int has_topleft, int has_topright, int stride) +;----------------------------------------------------------------------------- +;TODO: see if scalar is faster +%macro PRED8x8L_DC 1 +cglobal pred8x8l_dc_10_%1, 4,5,8 + sub r0, r3 + lea r4, [r0+r3*2] + mova m0, [r0+r3*1-16] + punpckhwd m0, [r0+r3*0-16] + mova m1, [r4+r3*1-16] + punpckhwd m1, [r0+r3*2-16] + mov r4, r0 + punpckhdq m1, m0 + lea r0, [r0+r3*4] + mova m2, [r0+r3*1-16] + punpckhwd m2, [r0+r3*0-16] + lea r0, [r0+r3*2] + mova m3, [r0+r3*1-16] + punpckhwd m3, [r0+r3*0-16] + punpckhdq m3, m2 + punpckhqdq m3, m1 + lea r0, [r0+r3*2] + mova m0, [r0+r3*0-16] + mova m1, [r4] + mov r0, r4 + mova m4, m3 + mova m2, m3 + PALIGNR m4, m0, 14, m0 + PALIGNR m1, m2, 2, m2 + test r1, r1 + jnz .do_left +.fix_lt_1: + mova m5, m3 + pxor m5, m4 + psrldq m5, 14 + pslldq m5, 12 + pxor m1, m5 + jmp .do_left +.fix_lt_2: + mova m5, m3 + pxor m5, m2 + pslldq m5, 14 + psrldq m5, 14 + pxor m2, m5 + test r2, r2 + jnz .body +.fix_tr_1: + mova m5, m3 + pxor m5, m1 + psrldq m5, 14 + pslldq m5, 14 + pxor m1, m5 + jmp .body +.do_left: + mova m0, m4 + PRED4x4_LOWPASS m2, m1, m4, m3 + mova m4, m0 + mova m7, m2 + PRED4x4_LOWPASS m1, m3, m0, m4 + pslldq m1, 14 + PALIGNR m7, m1, 14, m3 + mova m0, [r0-16] + mova m3, [r0] + mova m1, [r0+16] + mova m2, m3 + mova m4, m3 + PALIGNR m2, m0, 14, m0 + PALIGNR m1, m4, 2, m4 + test r1, r1 + jz .fix_lt_2 + test r2, r2 + jz .fix_tr_1 +.body + lea r1, [r3+r3*2] + PRED4x4_LOWPASS m6, m2, m1, m3 + HADDW m7, m0 + HADDW m6, m0 + lea r2, [r0+r3*4] + paddw m7, [pw_8] + paddw m7, m6 + psrlw m7, 4 + SPLATW m7, m7 + mova [r0+r3*1], m7 + mova [r0+r3*2], m7 + mova [r0+r1*1], m7 + mova [r0+r3*4], m7 + mova [r2+r3*1], m7 + mova [r2+r3*2], m7 + mova [r2+r1*1], m7 + mova [r2+r3*4], m7 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED8x8L_DC sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED8x8L_DC ssse3 + +;----------------------------------------------------------------------------- +; void pred8x8l_vertical(pixel *src, int has_topleft, int has_topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED8x8L_VERTICAL 1 +cglobal pred8x8l_vertical_10_%1, 4,4,6 + sub r0, r3 + mova m0, [r0-16] + mova m3, [r0] + mova m1, [r0+16] + mova m2, m3 + mova m4, m3 + PALIGNR m2, m0, 14, m0 + PALIGNR m1, m4, 2, m4 + test r1, r1 ; top_left + jz .fix_lt_2 + test r2, r2 ; top_right + jz .fix_tr_1 + jmp .body +.fix_lt_2: + mova m5, m3 + pxor m5, m2 + pslldq m5, 14 + psrldq m5, 14 + pxor m2, m5 + test r2, r2 ; top_right + jnz .body +.fix_tr_1: + mova m5, m3 + pxor m5, m1 + psrldq m5, 14 + pslldq m5, 14 + pxor m1, m5 +.body + lea r1, [r3+r3*2] + lea r2, [r0+r3*4] + PRED4x4_LOWPASS m0, m2, m1, m3 + mova [r0+r3*1], m0 + mova [r0+r3*2], m0 + mova [r0+r1*1], m0 + mova [r0+r3*4], m0 + mova [r2+r3*1], m0 + mova [r2+r3*2], m0 + mova [r2+r1*1], m0 + mova [r2+r3*4], m0 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED8x8L_VERTICAL sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED8x8L_VERTICAL ssse3 + +;----------------------------------------------------------------------------- +; void pred8x8l_horizontal(uint8_t *src, int has_topleft, int has_topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED8x8L_HORIZONTAL 1 +cglobal pred8x8l_horizontal_10_%1, 4,4,8 + sub r0, r3 + lea r2, [r0+r3*2] + mova m0, [r0+r3*1-16] + test r1, r1 + lea r1, [r0+r3] + cmovnz r1, r0 + punpckhwd m0, [r1+r3*0-16] + mova m1, [r2+r3*1-16] + punpckhwd m1, [r0+r3*2-16] + mov r2, r0 + punpckhdq m1, m0 + lea r0, [r0+r3*4] + mova m2, [r0+r3*1-16] + punpckhwd m2, [r0+r3*0-16] + lea r0, [r0+r3*2] + mova m3, [r0+r3*1-16] + punpckhwd m3, [r0+r3*0-16] + punpckhdq m3, m2 + punpckhqdq m3, m1 + lea r0, [r0+r3*2] + mova m0, [r0+r3*0-16] + mova m1, [r1+r3*0-16] + mov r0, r2 + mova m4, m3 + mova m2, m3 + PALIGNR m4, m0, 14, m0 + PALIGNR m1, m2, 2, m2 + mova m0, m4 + PRED4x4_LOWPASS m2, m1, m4, m3 + mova m4, m0 + mova m7, m2 + PRED4x4_LOWPASS m1, m3, m0, m4 + pslldq m1, 14 + PALIGNR m7, m1, 14, m3 + lea r1, [r3+r3*2] + punpckhwd m3, m7, m7 + punpcklwd m7, m7 + pshufd m0, m3, 0xff + pshufd m1, m3, 0xaa + lea r2, [r0+r3*4] + pshufd m2, m3, 0x55 + pshufd m3, m3, 0x00 + pshufd m4, m7, 0xff + pshufd m5, m7, 0xaa + pshufd m6, m7, 0x55 + pshufd m7, m7, 0x00 + mova [r0+r3*1], m0 + mova [r0+r3*2], m1 + mova [r0+r1*1], m2 + mova [r0+r3*4], m3 + mova [r2+r3*1], m4 + mova [r2+r3*2], m5 + mova [r2+r1*1], m6 + mova [r2+r3*4], m7 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED8x8L_HORIZONTAL sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED8x8L_HORIZONTAL ssse3 + +;----------------------------------------------------------------------------- +;void pred8x8l_down_left(pixel *src, int has_topleft, int has_topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED8x8L_DOWN_LEFT 1 +cglobal pred8x8l_down_left_10_%1, 4,4,8 + sub r0, r3 + mova m0, [r0-16] + mova m3, [r0] + mova m1, [r0+16] + mova m2, m3 + mova m4, m3 + PALIGNR m2, m0, 14, m0 + PALIGNR m1, m4, 2, m4 + test r1, r1 + jz .fix_lt_2 + test r2, r2 + jz .fix_tr_1 + jmp .do_top +.fix_lt_2: + mova m5, m3 + pxor m5, m2 + pslldq m5, 14 + psrldq m5, 14 + pxor m2, m5 + test r2, r2 + jnz .do_top +.fix_tr_1: + mova m5, m3 + pxor m5, m1 + psrldq m5, 14 + pslldq m5, 14 + pxor m1, m5 + jmp .do_top +.fix_tr_2: + punpckhwd m3, m3 + pshufd m1, m3, 0xFF + jmp .do_topright +.do_top: + PRED4x4_LOWPASS m4, m2, m1, m3 + mova m7, m4 + test r2, r2 + jz .fix_tr_2 + mova m0, [r0+16] + mova m5, m0 + mova m2, m0 + mova m4, m0 + psrldq m5, 14 + PALIGNR m2, m3, 14, m3 + PALIGNR m5, m4, 2, m4 + PRED4x4_LOWPASS m1, m2, m5, m0 +.do_topright: + lea r1, [r3+r3*2] + mova m6, m1 + psrldq m1, 14 + mova m4, m1 + lea r2, [r0+r3*4] + mova m2, m6 + PALIGNR m2, m7, 2, m0 + mova m3, m6 + PALIGNR m3, m7, 14, m0 + PALIGNR m4, m6, 2, m0 + mova m5, m7 + mova m1, m7 + mova m7, m6 + pslldq m1, 2 + PRED4x4_LOWPASS m0, m1, m2, m5 + PRED4x4_LOWPASS m1, m3, m4, m7 + mova [r2+r3*4], m1 + mova m2, m0 + pslldq m1, 2 + psrldq m2, 14 + pslldq m0, 2 + por m1, m2 + mova [r2+r1*1], m1 + mova m2, m0 + pslldq m1, 2 + psrldq m2, 14 + pslldq m0, 2 + por m1, m2 + mova [r2+r3*2], m1 + mova m2, m0 + pslldq m1, 2 + psrldq m2, 14 + pslldq m0, 2 + por m1, m2 + mova [r2+r3*1], m1 + mova m2, m0 + pslldq m1, 2 + psrldq m2, 14 + pslldq m0, 2 + por m1, m2 + mova [r0+r3*4], m1 + mova m2, m0 + pslldq m1, 2 + psrldq m2, 14 + pslldq m0, 2 + por m1, m2 + mova [r0+r1*1], m1 + mova m2, m0 + pslldq m1, 2 + psrldq m2, 14 + pslldq m0, 2 + por m1, m2 + mova [r0+r3*2], m1 + pslldq m1, 2 + psrldq m0, 14 + por m1, m0 + mova [r0+r3*1], m1 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED8x8L_DOWN_LEFT sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED8x8L_DOWN_LEFT ssse3 + +;----------------------------------------------------------------------------- +;void pred8x8l_down_right_mxext(pixel *src, int has_topleft, int has_topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED8x8L_DOWN_RIGHT 1 +cglobal pred8x8l_down_right_10_%1, 4,5,8 + sub r0, r3 + lea r4, [r0+r3*2] + mova m0, [r0+r3*1-16] + punpckhwd m0, [r0+r3*0-16] + mova m1, [r4+r3*1-16] + punpckhwd m1, [r0+r3*2-16] + mov r4, r0 + punpckhdq m1, m0 + lea r0, [r0+r3*4] + mova m2, [r0+r3*1-16] + punpckhwd m2, [r0+r3*0-16] + lea r0, [r0+r3*2] + mova m3, [r0+r3*1-16] + punpckhwd m3, [r0+r3*0-16] + punpckhdq m3, m2 + punpckhqdq m3, m1 + lea r0, [r0+r3*2] + mova m0, [r0+r3*0-16] + mova m1, [r4] + mov r0, r4 + mova m4, m3 + mova m2, m3 + PALIGNR m4, m0, 14, m0 + PALIGNR m1, m2, 2, m2 + test r1, r1 ; top_left + jz .fix_lt_1 +.do_left: + mova m0, m4 + PRED4x4_LOWPASS m2, m1, m4, m3 + mova m4, m0 + mova m7, m2 + mova m6, m2 + PRED4x4_LOWPASS m1, m3, m0, m4 + pslldq m1, 14 + PALIGNR m7, m1, 14, m3 + mova m0, [r0-16] + mova m3, [r0] + mova m1, [r0+16] + mova m2, m3 + mova m4, m3 + PALIGNR m2, m0, 14, m0 + PALIGNR m1, m4, 2, m4 + test r1, r1 ; top_left + jz .fix_lt_2 + test r2, r2 ; top_right + jz .fix_tr_1 +.do_top: + PRED4x4_LOWPASS m4, m2, m1, m3 + mova m5, m4 + jmp .body +.fix_lt_1: + mova m5, m3 + pxor m5, m4 + psrldq m5, 14 + pslldq m5, 12 + pxor m1, m5 + jmp .do_left +.fix_lt_2: + mova m5, m3 + pxor m5, m2 + pslldq m5, 14 + psrldq m5, 14 + pxor m2, m5 + test r2, r2 ; top_right + jnz .do_top +.fix_tr_1: + mova m5, m3 + pxor m5, m1 + psrldq m5, 14 + pslldq m5, 14 + pxor m1, m5 + jmp .do_top +.body + lea r1, [r3+r3*2] + mova m1, m7 + mova m7, m5 + mova m5, m6 + mova m2, m7 + lea r2, [r0+r3*4] + PALIGNR m2, m6, 2, m0 + mova m3, m7 + PALIGNR m3, m6, 14, m0 + mova m4, m7 + psrldq m4, 2 + PRED4x4_LOWPASS m0, m1, m2, m5 + PRED4x4_LOWPASS m1, m3, m4, m7 + mova [r2+r3*4], m0 + mova m2, m1 + psrldq m0, 2 + pslldq m2, 14 + psrldq m1, 2 + por m0, m2 + mova [r2+r1*1], m0 + mova m2, m1 + psrldq m0, 2 + pslldq m2, 14 + psrldq m1, 2 + por m0, m2 + mova [r2+r3*2], m0 + mova m2, m1 + psrldq m0, 2 + pslldq m2, 14 + psrldq m1, 2 + por m0, m2 + mova [r2+r3*1], m0 + mova m2, m1 + psrldq m0, 2 + pslldq m2, 14 + psrldq m1, 2 + por m0, m2 + mova [r0+r3*4], m0 + mova m2, m1 + psrldq m0, 2 + pslldq m2, 14 + psrldq m1, 2 + por m0, m2 + mova [r0+r1*1], m0 + mova m2, m1 + psrldq m0, 2 + pslldq m2, 14 + psrldq m1, 2 + por m0, m2 + mova [r0+r3*2], m0 + psrldq m0, 2 + pslldq m1, 14 + por m0, m1 + mova [r0+r3*1], m0 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED8x8L_DOWN_RIGHT sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED8x8L_DOWN_RIGHT ssse3 + +;----------------------------------------------------------------------------- +; void pred8x8l_vertical_right(pixel *src, int has_topleft, int has_topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED8x8L_VERTICAL_RIGHT 1 +cglobal pred8x8l_vertical_right_10_%1, 4,5,8 + sub r0, r3 + lea r4, [r0+r3*2] + mova m0, [r0+r3*1-16] + punpckhwd m0, [r0+r3*0-16] + mova m1, [r4+r3*1-16] + punpckhwd m1, [r0+r3*2-16] + mov r4, r0 + punpckhdq m1, m0 + lea r0, [r0+r3*4] + mova m2, [r0+r3*1-16] + punpckhwd m2, [r0+r3*0-16] + lea r0, [r0+r3*2] + mova m3, [r0+r3*1-16] + punpckhwd m3, [r0+r3*0-16] + punpckhdq m3, m2 + punpckhqdq m3, m1 + lea r0, [r0+r3*2] + mova m0, [r0+r3*0-16] + mova m1, [r4] + mov r0, r4 + mova m4, m3 + mova m2, m3 + PALIGNR m4, m0, 14, m0 + PALIGNR m1, m2, 2, m2 + test r1, r1 + jz .fix_lt_1 + jmp .do_left +.fix_lt_1: + mova m5, m3 + pxor m5, m4 + psrldq m5, 14 + pslldq m5, 12 + pxor m1, m5 + jmp .do_left +.fix_lt_2: + mova m5, m3 + pxor m5, m2 + pslldq m5, 14 + psrldq m5, 14 + pxor m2, m5 + test r2, r2 + jnz .do_top +.fix_tr_1: + mova m5, m3 + pxor m5, m1 + psrldq m5, 14 + pslldq m5, 14 + pxor m1, m5 + jmp .do_top +.do_left: + mova m0, m4 + PRED4x4_LOWPASS m2, m1, m4, m3 + mova m7, m2 + mova m0, [r0-16] + mova m3, [r0] + mova m1, [r0+16] + mova m2, m3 + mova m4, m3 + PALIGNR m2, m0, 14, m0 + PALIGNR m1, m4, 2, m4 + test r1, r1 + jz .fix_lt_2 + test r2, r2 + jz .fix_tr_1 +.do_top + PRED4x4_LOWPASS m6, m2, m1, m3 + lea r1, [r3+r3*2] + mova m2, m6 + mova m3, m6 + PALIGNR m3, m7, 14, m0 + PALIGNR m6, m7, 12, m1 + mova m4, m3 + pavgw m3, m2 + lea r2, [r0+r3*4] + PRED4x4_LOWPASS m0, m6, m2, m4 + mova [r0+r3*1], m3 + mova [r0+r3*2], m0 + mova m5, m0 + mova m6, m3 + mova m1, m7 + mova m2, m1 + pslldq m2, 2 + mova m3, m1 + pslldq m3, 4 + PRED4x4_LOWPASS m0, m1, m3, m2 + PALIGNR m6, m0, 14, m2 + mova [r0+r1*1], m6 + pslldq m0, 2 + PALIGNR m5, m0, 14, m1 + mova [r0+r3*4], m5 + pslldq m0, 2 + PALIGNR m6, m0, 14, m2 + mova [r2+r3*1], m6 + pslldq m0, 2 + PALIGNR m5, m0, 14, m1 + mova [r2+r3*2], m5 + pslldq m0, 2 + PALIGNR m6, m0, 14, m2 + mova [r2+r1*1], m6 + pslldq m0, 2 + PALIGNR m5, m0, 14, m1 + mova [r2+r3*4], m5 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED8x8L_VERTICAL_RIGHT sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED8x8L_VERTICAL_RIGHT ssse3 + +;----------------------------------------------------------------------------- +; void pred8x8l_horizontal_up(pixel *src, int has_topleft, int has_topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED8x8L_HORIZONTAL_UP 1 +cglobal pred8x8l_horizontal_up_10_%1, 4,4,8 + sub r0, r3 + lea r2, [r0+r3*2] + mova m0, [r0+r3*1-16] + test r1, r1 + lea r1, [r0+r3] + cmovnz r1, r0 + punpckhwd m0, [r1+r3*0-16] + mova m1, [r2+r3*1-16] + punpckhwd m1, [r0+r3*2-16] + mov r2, r0 + punpckhdq m1, m0 + lea r0, [r0+r3*4] + mova m2, [r0+r3*1-16] + punpckhwd m2, [r0+r3*0-16] + lea r0, [r0+r3*2] + mova m3, [r0+r3*1-16] + punpckhwd m3, [r0+r3*0-16] + punpckhdq m3, m2 + punpckhqdq m3, m1 + lea r0, [r0+r3*2] + mova m0, [r0+r3*0-16] + mova m1, [r1+r3*0-16] + mov r0, r2 + mova m4, m3 + mova m2, m3 + PALIGNR m4, m0, 14, m0 + PALIGNR m1, m2, 2, m2 + mova m0, m4 + PRED4x4_LOWPASS m2, m1, m4, m3 + mova m4, m0 + mova m7, m2 + PRED4x4_LOWPASS m1, m3, m0, m4 + pslldq m1, 14 + PALIGNR m7, m1, 14, m3 + lea r1, [r3+r3*2] + pshufd m0, m7, 00011011b ; l6 l7 l4 l5 l2 l3 l0 l1 + pslldq m7, 14 ; l7 .. .. .. .. .. .. .. + mova m2, m0 + pslld m0, 16 + psrld m2, 16 + por m2, m0 ; l7 l6 l5 l4 l3 l2 l1 l0 + mova m3, m2 + mova m4, m2 + mova m5, m2 + psrldq m2, 2 + psrldq m3, 4 + lea r2, [r0+r3*4] + por m2, m7 ; l7 l7 l6 l5 l4 l3 l2 l1 + punpckhwd m7, m7 + por m3, m7 ; l7 l7 l7 l6 l5 l4 l3 l2 + pavgw m4, m2 + PRED4x4_LOWPASS m1, m3, m5, m2 + mova m5, m4 + punpcklwd m4, m1 ; p4 p3 p2 p1 + punpckhwd m5, m1 ; p8 p7 p6 p5 + mova m6, m5 + mova m7, m5 + mova m0, m5 + PALIGNR m5, m4, 4, m1 + pshufd m1, m6, 11111001b + PALIGNR m6, m4, 8, m2 + pshufd m2, m7, 11111110b + PALIGNR m7, m4, 12, m3 + pshufd m3, m0, 11111111b + mova [r0+r3*1], m4 + mova [r0+r3*2], m5 + mova [r0+r1*1], m6 + mova [r0+r3*4], m7 + mova [r2+r3*1], m0 + mova [r2+r3*2], m1 + mova [r2+r1*1], m2 + mova [r2+r3*4], m3 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED8x8L_HORIZONTAL_UP sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED8x8L_HORIZONTAL_UP ssse3 + + + +;----------------------------------------------------------------------------- +; void pred16x16_vertical(pixel *src, int stride) +;----------------------------------------------------------------------------- +%macro MOV16 3-5 + mova [%1+ 0], %2 + mova [%1+mmsize], %3 +%if mmsize==8 + mova [%1+ 16], %4 + mova [%1+ 24], %5 +%endif +%endmacro + +%macro PRED16x16_VERTICAL 1 +cglobal pred16x16_vertical_10_%1, 2,3 + sub r0, r1 + mov r2, 8 + mova m0, [r0+ 0] + mova m1, [r0+mmsize] +%if mmsize==8 + mova m2, [r0+16] + mova m3, [r0+24] +%endif +.loop: + MOV16 r0+r1*1, m0, m1, m2, m3 + MOV16 r0+r1*2, m0, m1, m2, m3 + lea r0, [r0+r1*2] + dec r2 + jg .loop + REP_RET +%endmacro + +INIT_MMX +PRED16x16_VERTICAL mmxext +INIT_XMM +PRED16x16_VERTICAL sse2 + +;----------------------------------------------------------------------------- +; void pred16x16_horizontal(pixel *src, int stride) +;----------------------------------------------------------------------------- +%macro PRED16x16_HORIZONTAL 1 +cglobal pred16x16_horizontal_10_%1, 2,3 + mov r2, 8 +.vloop: + movd m0, [r0+r1*0-4] + movd m1, [r0+r1*1-4] + SPLATW m0, m0, 1 + SPLATW m1, m1, 1 + MOV16 r0+r1*0, m0, m0, m0, m0 + MOV16 r0+r1*1, m1, m1, m1, m1 + lea r0, [r0+r1*2] + dec r2 + jge .vloop + REP_RET +%endmacro + +INIT_MMX +PRED16x16_HORIZONTAL mmxext +INIT_XMM +PRED16x16_HORIZONTAL sse2 diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c index 9d6726c31c..a0c5164db1 100644 --- a/libavcodec/x86/h264_intrapred_init.c +++ b/libavcodec/x86/h264_intrapred_init.c @@ -43,9 +43,41 @@ PRED4x4(horizontal_down, 10, avx) #define PRED8x8(TYPE, DEPTH, OPT) \ void ff_pred8x8_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, int stride); +PRED8x8(dc, 10, mmxext) +PRED8x8(dc, 10, sse2) +PRED8x8(top_dc, 10, mmxext) +PRED8x8(top_dc, 10, sse2) PRED8x8(vertical, 10, sse2) PRED8x8(horizontal, 10, sse2) +#define PRED8x8L(TYPE, DEPTH, OPT)\ +void ff_pred8x8l_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, int has_topleft, int has_topright, int stride); + +PRED8x8L(dc, 10, sse2) +PRED8x8L(dc, 10, ssse3) +PRED8x8L(top_dc, 10, sse2) +PRED8x8L(top_dc, 10, ssse3) +PRED8x8L(vertical, 10, sse2) +PRED8x8L(vertical, 10, ssse3) +PRED8x8L(horizontal, 10, sse2) +PRED8x8L(horizontal, 10, ssse3) +PRED8x8L(down_left, 10, sse2) +PRED8x8L(down_left, 10, ssse3) +PRED8x8L(down_right, 10, sse2) +PRED8x8L(down_right, 10, ssse3) +PRED8x8L(vertical_right, 10, sse2) +PRED8x8L(vertical_right, 10, ssse3) +PRED8x8L(horizontal_up, 10, sse2) +PRED8x8L(horizontal_up, 10, ssse3) + +#define PRED16x16(TYPE, DEPTH, OPT)\ +void ff_pred16x16_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, int stride); + +PRED16x16(vertical, 10, mmxext) +PRED16x16(vertical, 10, sse2) +PRED16x16(horizontal, 10, mmxext) +PRED16x16(horizontal, 10, sse2) + void ff_pred16x16_vertical_mmx (uint8_t *src, int stride); void ff_pred16x16_vertical_sse (uint8_t *src, int stride); void ff_pred16x16_horizontal_mmx (uint8_t *src, int stride); @@ -253,6 +285,12 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth if (mm_flags & AV_CPU_FLAG_MMX2) { h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; + + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_mmxext; + h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_mmxext; + + h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_10_mmxext; + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_10_mmxext; } if (mm_flags & AV_CPU_FLAG_SSE2) { h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_sse2; @@ -261,13 +299,33 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_sse2; h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_sse2; + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_sse2; + h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_sse2; h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vertical_10_sse2; h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_10_sse2; + + h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_sse2; + h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_sse2; + h->pred8x8l[DC_PRED ] = ff_pred8x8l_dc_10_sse2; + h->pred8x8l[TOP_DC_PRED ] = ff_pred8x8l_top_dc_10_sse2; + h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_sse2; + h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_sse2; + h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_sse2; + h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_sse2; + + h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_10_sse2; + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_10_sse2; } if (mm_flags & AV_CPU_FLAG_SSSE3) { h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_ssse3; h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_ssse3; h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3; + + h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_ssse3; + h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_ssse3; + h->pred8x8l[DC_PRED ] = ff_pred8x8l_dc_10_ssse3; + h->pred8x8l[TOP_DC_PRED ] = ff_pred8x8l_top_dc_10_ssse3; + h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_ssse3; } #if HAVE_AVX if (mm_flags & AV_CPU_FLAG_AVX) { diff --git a/libavcodec/x86/x86util.asm b/libavcodec/x86/x86util.asm index 141e96000c..45196625fe 100644 --- a/libavcodec/x86/x86util.asm +++ b/libavcodec/x86/x86util.asm @@ -528,6 +528,14 @@ %endif %endmacro +%macro SPLATD 2-3 0 +%if mmsize == 16 + pshufd %1, %2, (%3)*0x55 +%else + pshufw %1, %2, (%3)*0x11 + ((%3)+1)*0x44 +%endif +%endmacro + %macro CLIPW 3 ;(dst, min, max) pmaxsw %1, %2 pminsw %1, %3 From bbdd52ed343cb594d4af07f9b369df6a00117774 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Tue, 5 Jul 2011 18:08:22 -0700 Subject: [PATCH 388/780] H.264: av_always_inline some more functions These weren't getting inlined all the time in all gcc versions. --- libavcodec/h264.c | 4 ++-- libavcodec/h264.h | 4 ++-- libavcodec/h264_mvpred.h | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index dbac4fda95..f7c0345daf 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1443,7 +1443,7 @@ static void decode_postinit(H264Context *h, int setup_finished){ ff_thread_finish_setup(s->avctx); } -static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int chroma444, int simple){ +static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int chroma444, int simple){ MpegEncContext * const s = &h->s; uint8_t *top_border; int top_idx = 1; @@ -1518,7 +1518,7 @@ static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src } } -static inline void xchg_mb_border(H264Context *h, uint8_t *src_y, +static av_always_inline void xchg_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int xchg, int chroma444, diff --git a/libavcodec/h264.h b/libavcodec/h264.h index dad06e2007..a2abab9d9b 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -766,11 +766,11 @@ static av_always_inline uint16_t pack8to16(int a, int b){ /** * gets the chroma qp. */ -static inline int get_chroma_qp(H264Context *h, int t, int qscale){ +static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){ return h->pps.chroma_qp_table[t][qscale]; } -static inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my); +static av_always_inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my); static void fill_decode_neighbors(H264Context *h, int mb_type){ MpegEncContext * const s = &h->s; diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h index f603e7ff38..c4e65b5847 100644 --- a/libavcodec/h264_mvpred.h +++ b/libavcodec/h264_mvpred.h @@ -35,7 +35,7 @@ //#undef NDEBUG #include -static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, int list, int part_width){ +static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, int list, int part_width){ const int topright_ref= h->ref_cache[list][ i - 8 + part_width ]; MpegEncContext *s = &h->s; @@ -92,7 +92,7 @@ static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, in * @param mx the x component of the predicted motion vector * @param my the y component of the predicted motion vector */ -static inline void pred_motion(H264Context * const h, int n, int part_width, int list, int ref, int * const mx, int * const my){ +static av_always_inline void pred_motion(H264Context * const h, int n, int part_width, int list, int ref, int * const mx, int * const my){ const int index8= scan8[n]; const int top_ref= h->ref_cache[list][ index8 - 8 ]; const int left_ref= h->ref_cache[list][ index8 - 1 ]; @@ -147,7 +147,7 @@ static inline void pred_motion(H264Context * const h, int n, int part_width, int * @param mx the x component of the predicted motion vector * @param my the y component of the predicted motion vector */ -static inline void pred_16x8_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ +static av_always_inline void pred_16x8_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ if(n==0){ const int top_ref= h->ref_cache[list][ scan8[0] - 8 ]; const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ]; @@ -182,7 +182,7 @@ static inline void pred_16x8_motion(H264Context * const h, int n, int list, int * @param mx the x component of the predicted motion vector * @param my the y component of the predicted motion vector */ -static inline void pred_8x16_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ +static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ if(n==0){ const int left_ref= h->ref_cache[list][ scan8[0] - 1 ]; const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ]; From 5136ba7c690f50ebe12bba6e3320a18e1d4fd936 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Tue, 5 Jul 2011 17:55:14 -0700 Subject: [PATCH 389/780] H.264: faster P-SKIP decoding Inline the relevant parts of fill_decode_caches into P-SKIP mv prediction to avoid calling the whole thing. --- libavcodec/h264.h | 1 - libavcodec/h264_mvpred.h | 111 +++++++++++++++++++++++++++++++++++---- 2 files changed, 102 insertions(+), 10 deletions(-) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index a2abab9d9b..d34e6db573 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -1331,7 +1331,6 @@ static void av_unused decode_mb_skip(H264Context *h){ mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP; fill_decode_neighbors(h, mb_type); - fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ... pred_pskip_motion(h, &mx, &my); fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1); fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4); diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h index c4e65b5847..8159f8a0dc 100644 --- a/libavcodec/h264_mvpred.h +++ b/libavcodec/h264_mvpred.h @@ -213,21 +213,114 @@ static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int pred_motion(h, n, 2, list, ref, mx, my); } -static inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my){ - const int top_ref = h->ref_cache[0][ scan8[0] - 8 ]; - const int left_ref= h->ref_cache[0][ scan8[0] - 1 ]; +#define FIX_MV_MBAFF(type, refn, mvn, idx)\ + if(FRAME_MBAFF){\ + if(MB_FIELD){\ + if(!IS_INTERLACED(type)){\ + refn <<= 1;\ + AV_COPY32(mvbuf[idx], mvn);\ + mvbuf[idx][1] /= 2;\ + mvn = mvbuf[idx];\ + }\ + }else{\ + if(IS_INTERLACED(type)){\ + refn >>= 1;\ + AV_COPY32(mvbuf[idx], mvn);\ + mvbuf[idx][1] <<= 1;\ + mvn = mvbuf[idx];\ + }\ + }\ + } - tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y); - - if(top_ref == PART_NOT_AVAILABLE || left_ref == PART_NOT_AVAILABLE - || !( top_ref | AV_RN32A(h->mv_cache[0][ scan8[0] - 8 ])) - || !(left_ref | AV_RN32A(h->mv_cache[0][ scan8[0] - 1 ]))){ +static av_always_inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my){ + DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = {0}; + DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2]; + MpegEncContext * const s = &h->s; + int8_t *ref = s->current_picture.ref_index[0]; + int16_t (*mv)[2] = s->current_picture.motion_val[0]; + int top_ref, left_ref, diagonal_ref, match_count; + const int16_t *A, *B, *C; + int b_stride = h->b_stride; + /* To avoid doing an entire fill_decode_caches, we inline the relevant parts here. + * FIXME: this is a partial duplicate of the logic in fill_decode_caches, but it's + * faster this way. Is there a way to avoid this duplication? + */ + if(USES_LIST(h->left_type[LTOP], 0)){ + left_ref = ref[4*h->left_mb_xy[LTOP] + 1 + (h->left_block[0]&~1)]; + A = mv[h->mb2b_xy[h->left_mb_xy[LTOP]] + 3 + b_stride*h->left_block[0]]; + FIX_MV_MBAFF(h->left_type[LTOP], left_ref, A, 0); + if(!(left_ref | AV_RN32A(A))){ + *mx = *my = 0; + return; + } + }else if(h->left_type[LTOP]){ + left_ref = LIST_NOT_USED; + A = zeromv; + }else{ *mx = *my = 0; return; } - pred_motion(h, 0, 4, 0, 0, mx, my); + if(USES_LIST(h->top_type, 0)){ + top_ref = ref[4*h->top_mb_xy + 2]; + B = mv[h->mb2b_xy[h->top_mb_xy] + 3*b_stride]; + FIX_MV_MBAFF(h->top_type, top_ref, B, 1); + if(!(top_ref | AV_RN32A(B))){ + *mx = *my = 0; + return; + } + }else if(h->top_type){ + top_ref = LIST_NOT_USED; + B = zeromv; + }else{ + *mx = *my = 0; + return; + } + + tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y); + + if(USES_LIST(h->topright_type, 0)){ + diagonal_ref = ref[4*h->topright_mb_xy + 2]; + C = mv[h->mb2b_xy[h->topright_mb_xy] + 3*b_stride]; + FIX_MV_MBAFF(h->topright_type, diagonal_ref, C, 2); + }else if(h->topright_type){ + diagonal_ref = LIST_NOT_USED; + C = zeromv; + }else{ + if(USES_LIST(h->topleft_type, 0)){ + diagonal_ref = ref[4*h->topleft_mb_xy + 1 + (h->topleft_partition & 2)]; + C = mv[h->mb2b_xy[h->topleft_mb_xy] + 3 + b_stride + (h->topleft_partition & 2*b_stride)]; + FIX_MV_MBAFF(h->topleft_type, diagonal_ref, C, 2); + }else if(h->topleft_type){ + diagonal_ref = LIST_NOT_USED; + C = zeromv; + }else{ + diagonal_ref = PART_NOT_AVAILABLE; + C = zeromv; + } + } + + match_count= !diagonal_ref + !top_ref + !left_ref; + tprintf(h->s.avctx, "pred_pskip_motion match_count=%d\n", match_count); + if(match_count > 1){ + *mx= mid_pred(A[0], B[0], C[0]); + *my= mid_pred(A[1], B[1], C[1]); + }else if(match_count==1){ + if(!left_ref){ + *mx= A[0]; + *my= A[1]; + }else if(!top_ref){ + *mx= B[0]; + *my= B[1]; + }else{ + *mx= C[0]; + *my= C[1]; + } + }else{ + *mx= mid_pred(A[0], B[0], C[0]); + *my= mid_pred(A[1], B[1], C[1]); + } return; } From ef0c5948018216aadae18e5626ed0b1b95668f4f Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 6 Jul 2011 07:58:50 -0700 Subject: [PATCH 390/780] H.264: merge fill_rectangle into P-SKIP MV prediction, to match B-SKIP --- libavcodec/h264.h | 7 ++----- libavcodec/h264_mvpred.h | 42 +++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index d34e6db573..e88005aa3e 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -770,7 +770,7 @@ static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){ return h->pps.chroma_qp_table[t][qscale]; } -static av_always_inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my); +static av_always_inline void pred_pskip_motion(H264Context * const h); static void fill_decode_neighbors(H264Context *h, int mb_type){ MpegEncContext * const s = &h->s; @@ -1327,13 +1327,10 @@ static void av_unused decode_mb_skip(H264Context *h){ } else { - int mx, my; mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP; fill_decode_neighbors(h, mb_type); - pred_pskip_motion(h, &mx, &my); - fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1); - fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4); + pred_pskip_motion(h); } write_back_motion(h, mb_type); diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h index 8159f8a0dc..6dceee3c90 100644 --- a/libavcodec/h264_mvpred.h +++ b/libavcodec/h264_mvpred.h @@ -232,16 +232,18 @@ static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int }\ } -static av_always_inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my){ +static av_always_inline void pred_pskip_motion(H264Context * const h){ DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = {0}; DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2]; MpegEncContext * const s = &h->s; int8_t *ref = s->current_picture.ref_index[0]; int16_t (*mv)[2] = s->current_picture.motion_val[0]; - int top_ref, left_ref, diagonal_ref, match_count; + int top_ref, left_ref, diagonal_ref, match_count, mx, my; const int16_t *A, *B, *C; int b_stride = h->b_stride; + fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1); + /* To avoid doing an entire fill_decode_caches, we inline the relevant parts here. * FIXME: this is a partial duplicate of the logic in fill_decode_caches, but it's * faster this way. Is there a way to avoid this duplication? @@ -251,15 +253,13 @@ static av_always_inline void pred_pskip_motion(H264Context * const h, int * cons A = mv[h->mb2b_xy[h->left_mb_xy[LTOP]] + 3 + b_stride*h->left_block[0]]; FIX_MV_MBAFF(h->left_type[LTOP], left_ref, A, 0); if(!(left_ref | AV_RN32A(A))){ - *mx = *my = 0; - return; + goto zeromv; } }else if(h->left_type[LTOP]){ left_ref = LIST_NOT_USED; A = zeromv; }else{ - *mx = *my = 0; - return; + goto zeromv; } if(USES_LIST(h->top_type, 0)){ @@ -267,15 +267,13 @@ static av_always_inline void pred_pskip_motion(H264Context * const h, int * cons B = mv[h->mb2b_xy[h->top_mb_xy] + 3*b_stride]; FIX_MV_MBAFF(h->top_type, top_ref, B, 1); if(!(top_ref | AV_RN32A(B))){ - *mx = *my = 0; - return; + goto zeromv; } }else if(h->top_type){ top_ref = LIST_NOT_USED; B = zeromv; }else{ - *mx = *my = 0; - return; + goto zeromv; } tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y); @@ -304,24 +302,28 @@ static av_always_inline void pred_pskip_motion(H264Context * const h, int * cons match_count= !diagonal_ref + !top_ref + !left_ref; tprintf(h->s.avctx, "pred_pskip_motion match_count=%d\n", match_count); if(match_count > 1){ - *mx= mid_pred(A[0], B[0], C[0]); - *my= mid_pred(A[1], B[1], C[1]); + mx = mid_pred(A[0], B[0], C[0]); + my = mid_pred(A[1], B[1], C[1]); }else if(match_count==1){ if(!left_ref){ - *mx= A[0]; - *my= A[1]; + mx = A[0]; + my = A[1]; }else if(!top_ref){ - *mx= B[0]; - *my= B[1]; + mx = B[0]; + my = B[1]; }else{ - *mx= C[0]; - *my= C[1]; + mx = C[0]; + my = C[1]; } }else{ - *mx= mid_pred(A[0], B[0], C[0]); - *my= mid_pred(A[1], B[1], C[1]); + mx = mid_pred(A[0], B[0], C[0]); + my = mid_pred(A[1], B[1], C[1]); } + fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4); + return; +zeromv: + fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4); return; } From 298e52c99caabebba63bb2b7074d8c4b5c2c0f92 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 6 Jul 2011 12:26:04 -0700 Subject: [PATCH 391/780] H.264: Remove redundant hl_motion_16/8 code --- libavcodec/h264.c | 52 +++++++++-------------------------------------- 1 file changed, 10 insertions(+), 42 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index f7c0345daf..f79f4d1d35 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -778,24 +778,6 @@ static av_always_inline void hl_motion(H264Context *h, uint8_t *dest_y, uint8_t prefetch_motion(h, 1, pixel_shift, chroma444); } -#define hl_motion_fn(sh, bits) \ -static av_always_inline void hl_motion_ ## bits(H264Context *h, \ - uint8_t *dest_y, \ - uint8_t *dest_cb, uint8_t *dest_cr, \ - qpel_mc_func (*qpix_put)[16], \ - h264_chroma_mc_func (*chroma_put), \ - qpel_mc_func (*qpix_avg)[16], \ - h264_chroma_mc_func (*chroma_avg), \ - h264_weight_func *weight_op, \ - h264_biweight_func *weight_avg, \ - int chroma444) \ -{ \ - hl_motion(h, dest_y, dest_cb, dest_cr, qpix_put, chroma_put, \ - qpix_avg, chroma_avg, weight_op, weight_avg, sh, chroma444); \ -} -hl_motion_fn(0, 8); -hl_motion_fn(1, 16); - static void free_tables(H264Context *h, int free_rbsp){ int i; H264Context *hx; @@ -1876,18 +1858,11 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i if(h->deblocking_filter) xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, 0, simple, pixel_shift); }else if(is_h264){ - if (pixel_shift) { - hl_motion_16(h, dest_y, dest_cb, dest_cr, - s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, - s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, - h->h264dsp.weight_h264_pixels_tab, - h->h264dsp.biweight_h264_pixels_tab, 0); - } else - hl_motion_8(h, dest_y, dest_cb, dest_cr, - s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, - s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, - h->h264dsp.weight_h264_pixels_tab, - h->h264dsp.biweight_h264_pixels_tab, 0); + hl_motion(h, dest_y, dest_cb, dest_cr, + s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, + s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, + h->h264dsp.weight_h264_pixels_tab, + h->h264dsp.biweight_h264_pixels_tab, pixel_shift, 0); } hl_decode_mb_idct_luma(h, mb_type, is_h264, simple, transform_bypass, pixel_shift, block_offset, linesize, dest_y, 0); @@ -2017,18 +1992,11 @@ static av_always_inline void hl_decode_mb_444_internal(H264Context *h, int simpl if(h->deblocking_filter) xchg_mb_border(h, dest[0], dest[1], dest[2], linesize, linesize, 0, 1, simple, pixel_shift); }else{ - if (pixel_shift) { - hl_motion_16(h, dest[0], dest[1], dest[2], - s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, - s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, - h->h264dsp.weight_h264_pixels_tab, - h->h264dsp.biweight_h264_pixels_tab, 1); - } else - hl_motion_8(h, dest[0], dest[1], dest[2], - s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, - s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, - h->h264dsp.weight_h264_pixels_tab, - h->h264dsp.biweight_h264_pixels_tab, 1); + hl_motion(h, dest[0], dest[1], dest[2], + s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, + s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, + h->h264dsp.weight_h264_pixels_tab, + h->h264dsp.biweight_h264_pixels_tab, pixel_shift, 1); } for (p = 0; p < plane_count; p++) From 99b6d2c065c3823e77e23cadaf9077ca954b36ff Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 6 Jul 2011 13:25:13 -0700 Subject: [PATCH 392/780] H.264: use fill_rectangle in CABAC decoding --- libavcodec/h264_cabac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 6dacf7a336..390a7b6587 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1818,8 +1818,7 @@ static av_always_inline void decode_cabac_luma_residual( H264Context *h, const u } } } else { - uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8+16*p] ]; - nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0; + fill_rectangle(&h->non_zero_count_cache[scan8[4*i8x8+16*p]], 2, 2, 8, 0, 1); } } } From 6a2176aac05e1edbcdf8fb9c26d572d092a00c3c Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 6 Jul 2011 14:08:30 -0700 Subject: [PATCH 393/780] H.264: improve qp_thresh check Eliminate redundant check in filter_mb_fast, consider bit depth in calculating qp_thresh. --- libavcodec/h264.c | 4 +++- libavcodec/h264_loopfilter.c | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index f79f4d1d35..33c9527946 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2931,7 +2931,9 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ } } } - h->qp_thresh= 15 + 52 - FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) - FFMAX3(0, h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1]); + h->qp_thresh = 15 + 52 - FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) + - FFMAX3(0, h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1]) + + 6 * (h->sps.bit_depth_luma - 8); #if 0 //FMO if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index c7163472d3..5de9f784d9 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -216,7 +216,7 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, MpegEncContext * const s = &h->s; int mb_xy; int mb_type, left_type, top_type; - int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh; + int qp, qp0, qp1, qpc, qpc0, qpc1; int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)); int chroma444 = CHROMA444; @@ -241,10 +241,6 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, qp1 = (qp + qp1 + 1) >> 1; qpc0 = (qpc + qpc0 + 1) >> 1; qpc1 = (qpc + qpc1 + 1) >> 1; - qp_thresh = 15+52 - h->slice_alpha_c0_offset; - if(qp <= qp_thresh && qp0 <= qp_thresh && qp1 <= qp_thresh && - qpc <= qp_thresh && qpc0 <= qp_thresh && qpc1 <= qp_thresh) - return; if( IS_INTRA(mb_type) ) { static const int16_t bS4[4] = {4,4,4,4}; From d8dbe20241558a1b4439ac33120caa4dafebf418 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 7 Jul 2011 01:31:04 +0200 Subject: [PATCH 394/780] libxvid: Add const qualifier to silence compiler warning. libavcodec/libxvidff.c:752: warning: initialization discards qualifiers from pointer target type --- libavcodec/libxvidff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c index fd0aea58fa..3ca4d1b2ec 100644 --- a/libavcodec/libxvidff.c +++ b/libavcodec/libxvidff.c @@ -749,7 +749,7 @@ static int xvid_ff_2pass_before(struct xvid_context *ref, static int xvid_ff_2pass_after(struct xvid_context *ref, xvid_plg_data_t *param) { char *log = ref->twopassbuffer; - char *frame_types = " ipbs"; + const char *frame_types = " ipbs"; char frame_type; /* Quick bounds check */ From 99fecc64b064a013559d3d61f7d9790e3c95c80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 23 Jun 2011 15:59:33 +0200 Subject: [PATCH 395/780] gxf: Fix 25 fps DV material in GXF being misdetected as 50 fps Set DV packet durations using fields_per_frame. This requires turning gxf_stream_info into the demuxer's context for access to the value in gxf_packet(). Since MPEG-2 seems to work fine this done only for DV. Signed-off-by: Anton Khirnov --- libavformat/gxf.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/libavformat/gxf.c b/libavformat/gxf.c index 54fdadfc32..062a147a0c 100644 --- a/libavformat/gxf.c +++ b/libavformat/gxf.c @@ -264,7 +264,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { int map_len; int len; AVRational main_timebase = {0, 0}; - struct gxf_stream_info si; + struct gxf_stream_info *si = s->priv_data; int i; if (!parse_packet_header(pb, &pkt_type, &map_len) || pkt_type != PKT_MAP) { av_log(s, AV_LOG_ERROR, "map packet not found\n"); @@ -282,7 +282,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { return 0; } map_len -= len; - gxf_material_tags(pb, &len, &si); + gxf_material_tags(pb, &len, si); avio_skip(pb, len); map_len -= 2; len = avio_rb16(pb); // length of track description @@ -300,7 +300,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { track_id = avio_r8(pb); track_len = avio_rb16(pb); len -= track_len; - gxf_track_tags(pb, &track_len, &si); + gxf_track_tags(pb, &track_len, si); avio_skip(pb, track_len); if (!(track_type & 0x80)) { av_log(s, AV_LOG_ERROR, "invalid track type %x\n", track_type); @@ -316,12 +316,12 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { if (idx < 0) continue; st = s->streams[idx]; if (!main_timebase.num || !main_timebase.den) { - main_timebase.num = si.frames_per_second.den; - main_timebase.den = si.frames_per_second.num * 2; + main_timebase.num = si->frames_per_second.den; + main_timebase.den = si->frames_per_second.num * 2; } - st->start_time = si.first_field; - if (si.first_field != AV_NOPTS_VALUE && si.last_field != AV_NOPTS_VALUE) - st->duration = si.last_field - si.first_field; + st->start_time = si->first_field; + if (si->first_field != AV_NOPTS_VALUE && si->last_field != AV_NOPTS_VALUE) + st->duration = si->last_field - si->first_field; } if (len < 0) av_log(s, AV_LOG_ERROR, "invalid track description length specified\n"); @@ -422,6 +422,8 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) { AVIOContext *pb = s->pb; GXFPktType pkt_type; int pkt_len; + struct gxf_stream_info *si = s->priv_data; + while (!pb->eof_reached) { AVStream *st; int track_type, track_id, ret; @@ -473,6 +475,11 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) { avio_skip(pb, skip); pkt->stream_index = stream_index; pkt->dts = field_nr; + + //set duration manually for DV or else lavf misdetects the frame rate + if (st->codec->codec_id == CODEC_ID_DVVIDEO) + pkt->duration = si->fields_per_frame; + return ret; } return AVERROR(EIO); @@ -518,7 +525,7 @@ static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index, AVInputFormat ff_gxf_demuxer = { "gxf", NULL_IF_CONFIG_SMALL("GXF format"), - 0, + sizeof(struct gxf_stream_info), gxf_probe, gxf_header, gxf_packet, From 26f373988d61fbdf140b6d34125e195ec95bcb58 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 8 Jul 2011 10:05:06 +0200 Subject: [PATCH 396/780] examples/muxing.c: set sample format for encoding This is required, or avcodec_open() will abort because of invalid sample format. --- doc/examples/encoding.c | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/examples/encoding.c b/doc/examples/encoding.c index afe7e4f277..8588d724a5 100644 --- a/doc/examples/encoding.c +++ b/doc/examples/encoding.c @@ -71,6 +71,7 @@ static void audio_encode_example(const char *filename) c->bit_rate = 64000; c->sample_rate = 44100; c->channels = 2; + c->sample_fmt = AV_SAMPLE_FMT_S16; /* open it */ if (avcodec_open(c, codec) < 0) { From ffe3856de7a5f18aba36b56a314aee48d7b7ac78 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Jul 2011 15:39:16 +0200 Subject: [PATCH 397/780] examples/encoding.c: remove reference to unexisting file --- doc/examples/encoding.c | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/examples/encoding.c b/doc/examples/encoding.c index 8588d724a5..d201baeac4 100644 --- a/doc/examples/encoding.c +++ b/doc/examples/encoding.c @@ -22,7 +22,6 @@ * @file * libavcodec API use example. * - * @example libavcodec/api-example.c * Note that this library only handles codecs (mpeg, mpeg4, etc...), * not file formats (avi, vob, etc...). See library 'libavformat' for the * format handling From a7aabda267d6e2277ac8e234a603ebee3ede2fca Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Jul 2011 15:40:01 +0200 Subject: [PATCH 398/780] examples/encoding.c: replace "this library" with "libavcodec" in doxy So it is more clear the context of the sentence. --- doc/examples/encoding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/encoding.c b/doc/examples/encoding.c index d201baeac4..ff6fd2b4df 100644 --- a/doc/examples/encoding.c +++ b/doc/examples/encoding.c @@ -22,7 +22,7 @@ * @file * libavcodec API use example. * - * Note that this library only handles codecs (mpeg, mpeg4, etc...), + * Note that libavcodec only handles codecs (mpeg, mpeg4, etc...), * not file formats (avi, vob, etc...). See library 'libavformat' for the * format handling */ From 84d098d943bacbc4a3c71c3abeef229d3791b6f7 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 5 Jul 2011 12:21:22 -0400 Subject: [PATCH 399/780] segafilm: add support for videos with cri adx adpcm Signed-off-by: Ronald S. Bultje --- libavformat/segafilm.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c index 0ad5fbbe0b..0886825523 100644 --- a/libavformat/segafilm.c +++ b/libavformat/segafilm.c @@ -111,7 +111,9 @@ static int film_read_header(AVFormatContext *s, film->audio_samplerate = AV_RB16(&scratch[24]); film->audio_channels = scratch[21]; film->audio_bits = scratch[22]; - if (film->audio_bits == 8) + if (scratch[23] == 2) + film->audio_type = CODEC_ID_ADPCM_ADX; + else if (film->audio_bits == 8) film->audio_type = CODEC_ID_PCM_S8; else if (film->audio_bits == 16) film->audio_type = CODEC_ID_PCM_S16BE; @@ -149,12 +151,19 @@ static int film_read_header(AVFormatContext *s, st->codec->codec_id = film->audio_type; st->codec->codec_tag = 1; st->codec->channels = film->audio_channels; - st->codec->bits_per_coded_sample = film->audio_bits; st->codec->sample_rate = film->audio_samplerate; + + if (film->audio_type == CODEC_ID_ADPCM_ADX) { + st->codec->bits_per_coded_sample = 18 * 8 / 32; + st->codec->block_align = st->codec->channels * 18; + } else { + st->codec->bits_per_coded_sample = film->audio_bits; + st->codec->block_align = st->codec->channels * + st->codec->bits_per_coded_sample / 8; + } + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * st->codec->bits_per_coded_sample; - st->codec->block_align = st->codec->channels * - st->codec->bits_per_coded_sample / 8; } /* load the sample table */ @@ -187,8 +196,12 @@ static int film_read_header(AVFormatContext *s, film->sample_table[i].pts *= film->base_clock; film->sample_table[i].pts /= film->audio_samplerate; - audio_frame_counter += (film->sample_table[i].sample_size / - (film->audio_channels * film->audio_bits / 8)); + if (film->audio_type == CODEC_ID_ADPCM_ADX) + audio_frame_counter += (film->sample_table[i].sample_size * 32 / + (18 * film->audio_channels)); + else + audio_frame_counter += (film->sample_table[i].sample_size / + (film->audio_channels * film->audio_bits / 8)); } else { film->sample_table[i].stream = film->video_stream_index; film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF; @@ -227,7 +240,8 @@ static int film_read_packet(AVFormatContext *s, return AVERROR(ENOMEM); avio_read(pb, pkt->data, sample->sample_size); } else if ((sample->stream == film->audio_stream_index) && - (film->audio_channels == 2)) { + (film->audio_channels == 2) && + (film->audio_type != CODEC_ID_ADPCM_ADX)) { /* stereo PCM needs to be interleaved */ if (av_new_packet(pkt, sample->sample_size)) From 43e96d0466094e3780260fa896046b1ecbb8ff06 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 9 Jul 2011 17:13:13 +0200 Subject: [PATCH 400/780] Support gsm_ms in caf files. --- libavformat/caf.c | 1 + libavformat/cafenc.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/libavformat/caf.c b/libavformat/caf.c index 907562a082..d49cc0b9f3 100644 --- a/libavformat/caf.c +++ b/libavformat/caf.c @@ -41,6 +41,7 @@ const AVCodecTag ff_codec_caf_tags[] = { { CODEC_ID_ADPCM_IMA_QT, MKBETAG('i','m','a','4') }, { CODEC_ID_AMR_NB, MKBETAG('s','a','m','r') }, { CODEC_ID_GSM, MKBETAG('a','g','s','m') }, + { CODEC_ID_GSM_MS, MKBETAG('m','s', 0, '1') }, { CODEC_ID_MACE3, MKBETAG('M','A','C','3') }, { CODEC_ID_MACE6, MKBETAG('M','A','C','6') }, { CODEC_ID_MP3, MKBETAG('.','m','p','3') }, diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c index 4156c49f7a..7cb4777bc6 100644 --- a/libavformat/cafenc.c +++ b/libavformat/cafenc.c @@ -72,6 +72,8 @@ static uint32_t samples_per_packet(enum CodecID codec_id) { case CODEC_ID_GSM: case CODEC_ID_QCELP: return 160; + case CODEC_ID_GSM_MS: + return 320; case CODEC_ID_MP1: return 384; case CODEC_ID_MP2: From 6dabe0f74a967fd6f4af7cab3da65b08f06cb088 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Tue, 5 Jul 2011 00:18:32 +0200 Subject: [PATCH 401/780] Added ability to enable workaround for dxva2 decoding using older ATI cards The workaround need to be enabled per pci id which can not be detected inside ffmpeg. So this adds a flag that enabled the alternate behavior. --- libavcodec/dxva2.h | 2 ++ libavcodec/dxva2_h264.c | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/libavcodec/dxva2.h b/libavcodec/dxva2.h index 5c5fe21e2f..6eb494b9fe 100644 --- a/libavcodec/dxva2.h +++ b/libavcodec/dxva2.h @@ -27,6 +27,8 @@ #include +#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards + /** * This structure is used to provides the necessary configurations and data * to the DXVA2 FFmpeg HWAccel implementation. diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c index bc80e982fb..21157bfe1e 100644 --- a/libavcodec/dxva2_h264.c +++ b/libavcodec/dxva2_h264.c @@ -113,6 +113,9 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context pp->bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8; pp->bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8; + if (ctx->workaround & FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG) + pp->Reserved16Bits = 0; + else pp->Reserved16Bits = 3; /* FIXME is there a way to detect the right mode ? */ pp->StatusReportFeedbackNumber = 1 + ctx->report_id++; pp->CurrFieldOrderCnt[0] = 0; @@ -150,10 +153,19 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context //pp->SliceGroupMap[810]; /* XXX not implemented by FFmpeg */ } -static void fill_scaling_lists(const H264Context *h, DXVA_Qmatrix_H264 *qm) +static void fill_scaling_lists(struct dxva_context *ctx, const H264Context *h, DXVA_Qmatrix_H264 *qm) { unsigned i, j; memset(qm, 0, sizeof(*qm)); + if (ctx->workaround & FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG) { + for (i = 0; i < 6; i++) + for (j = 0; j < 16; j++) + qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][j]; + + for (i = 0; i < 2; i++) + for (j = 0; j < 64; j++) + qm->bScalingLists8x8[i][j] = h->pps.scaling_matrix8[i][j]; + } else { for (i = 0; i < 6; i++) for (j = 0; j < 16; j++) qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][zigzag_scan[j]]; @@ -161,6 +173,7 @@ static void fill_scaling_lists(const H264Context *h, DXVA_Qmatrix_H264 *qm) for (i = 0; i < 2; i++) for (j = 0; j < 64; j++) qm->bScalingLists8x8[i][j] = h->pps.scaling_matrix8[i][ff_zigzag_direct[j]]; + } } static int is_slice_short(struct dxva_context *ctx) @@ -370,7 +383,7 @@ static int start_frame(AVCodecContext *avctx, fill_picture_parameters(ctx, h, &ctx_pic->pp); /* Fill up DXVA_Qmatrix_H264 */ - fill_scaling_lists(h, &ctx_pic->qm); + fill_scaling_lists(ctx, h, &ctx_pic->qm); ctx_pic->slice_count = 0; ctx_pic->bitstream_size = 0; From a7d3a51dd1efa3073cc9d419a73f709f784ce267 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Sat, 9 Jul 2011 17:30:25 +0200 Subject: [PATCH 402/780] cosmetic: reindent of dxva2 zigzag workaround --- libavcodec/dxva2_h264.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c index 21157bfe1e..2d2e475044 100644 --- a/libavcodec/dxva2_h264.c +++ b/libavcodec/dxva2_h264.c @@ -116,7 +116,7 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context if (ctx->workaround & FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG) pp->Reserved16Bits = 0; else - pp->Reserved16Bits = 3; /* FIXME is there a way to detect the right mode ? */ + pp->Reserved16Bits = 3; /* FIXME is there a way to detect the right mode ? */ pp->StatusReportFeedbackNumber = 1 + ctx->report_id++; pp->CurrFieldOrderCnt[0] = 0; if ((s->picture_structure & PICT_TOP_FIELD) && @@ -166,13 +166,13 @@ static void fill_scaling_lists(struct dxva_context *ctx, const H264Context *h, D for (j = 0; j < 64; j++) qm->bScalingLists8x8[i][j] = h->pps.scaling_matrix8[i][j]; } else { - for (i = 0; i < 6; i++) - for (j = 0; j < 16; j++) - qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][zigzag_scan[j]]; + for (i = 0; i < 6; i++) + for (j = 0; j < 16; j++) + qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][zigzag_scan[j]]; - for (i = 0; i < 2; i++) - for (j = 0; j < 64; j++) - qm->bScalingLists8x8[i][j] = h->pps.scaling_matrix8[i][ff_zigzag_direct[j]]; + for (i = 0; i < 2; i++) + for (j = 0; j < 64; j++) + qm->bScalingLists8x8[i][j] = h->pps.scaling_matrix8[i][ff_zigzag_direct[j]]; } } From f98c9fb27de84dc4f6123537b754eb2fe1a80c02 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Wed, 29 Jun 2011 14:13:18 -0700 Subject: [PATCH 403/780] mpeg1video: don't abort if thread_count is too high. Instead, just decrease it to a valid value and use that. Signed-off-by: Ronald S. Bultje --- libavcodec/mpegvideo.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index ceed41f230..aec75b541e 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -575,7 +575,11 @@ void MPV_decode_defaults(MpegEncContext *s){ */ av_cold int MPV_common_init(MpegEncContext *s) { - int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y, threads; + int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y, + threads = (s->encoding || + (HAVE_THREADS && + s->avctx->active_thread_type & FF_THREAD_SLICE)) ? + s->avctx->thread_count : 1; if(s->codec_id == CODEC_ID_MPEG2VIDEO && !s->progressive_sequence) s->mb_height = (s->height + 31) / 32 * 2; @@ -589,8 +593,10 @@ av_cold int MPV_common_init(MpegEncContext *s) if((s->encoding || (s->avctx->active_thread_type & FF_THREAD_SLICE)) && (s->avctx->thread_count > MAX_THREADS || (s->avctx->thread_count > s->mb_height && s->mb_height))){ - av_log(s->avctx, AV_LOG_ERROR, "too many threads\n"); - return -1; + int max_threads = FFMIN(MAX_THREADS, s->mb_height); + av_log(s->avctx, AV_LOG_WARNING, "too many threads (%d), reducing to %d\n", + s->avctx->thread_count, max_threads); + threads = max_threads; } if((s->width || s->height) && av_image_check_size(s->width, s->height, 0, s->avctx)) @@ -752,8 +758,6 @@ av_cold int MPV_common_init(MpegEncContext *s) if (s->width && s->height) { if (s->encoding || (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_SLICE)) { - threads = s->avctx->thread_count; - for(i=1; ithread_context[i]= av_malloc(sizeof(MpegEncContext)); memcpy(s->thread_context[i], s, sizeof(MpegEncContext)); From 4c98976124f611b1a475bccb1b5177ff536be79c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 8 Jul 2011 15:34:56 +0200 Subject: [PATCH 404/780] doc: replace @pxref by @ref where appropriate --- doc/developer.texi | 4 ++-- doc/filters.texi | 8 +++----- doc/muxers.texi | 4 ++-- doc/texi2pod.pl | 1 + 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index 37b9f3e889..cae4f3df5e 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -224,7 +224,7 @@ Note, some rules were borrowed from the MPlayer project. @section Submitting patches -First, read the (@pxref{Coding Rules}) above if you did not yet, in particular +First, read the @ref{Coding Rules} above if you did not yet, in particular the rules regarding patch submission. As stated already, please do not submit a patch which contains several @@ -238,7 +238,7 @@ for us and greatly increases your chances of getting your patch applied. Use the patcheck tool of Libav to check your patch. The tool is located in the tools directory. -Run the @pxref{Regression Tests} before submitting a patch in order to verify +Run the @ref{Regression Tests} before submitting a patch in order to verify it does not cause unexpected problems. Patches should be posted as base64 encoded attachments (or any other diff --git a/doc/filters.texi b/doc/filters.texi index 9666f582f2..a8076b2bf5 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -796,8 +796,7 @@ Erode an image by using a specific structuring element. This filter corresponds to the libopencv function @code{cvErode}. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations}, -with the same meaning and use of those of the dilate filter -(@pxref{dilate}). +with the same syntax and semantics as the @ref{dilate} filter. @subsection smooth @@ -1093,7 +1092,7 @@ setdar=16:9 setdar=1.77777 @end example -See also the "setsar" filter documentation (@pxref{setsar}). +See also the @ref{setsar} filter documentation. @section setpts @@ -1547,8 +1546,7 @@ form @var{width}x@var{height} or a frame size abbreviation. the form @var{num}/@var{den} or a frame rate abbreviation. @var{src_name} is the name to the frei0r source to load. For more information regarding frei0r and how to set the parameters read the -section "frei0r" (@pxref{frei0r}) in the description of the video -filters. +section @ref{frei0r} in the description of the video filters. Some examples follow: @example diff --git a/doc/muxers.texi b/doc/muxers.texi index 74c014bc70..bcba77cb2c 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -51,7 +51,7 @@ and the input video converted to MPEG-2 video, use the command: ffmpeg -i INPUT -acodec pcm_u8 -vcodec mpeg2video -f crc - @end example -See also the @code{framecrc} muxer (@pxref{framecrc}). +See also the @ref{framecrc} muxer. @anchor{framecrc} @section framecrc @@ -88,7 +88,7 @@ MPEG-2 video, use the command: ffmpeg -i INPUT -acodec pcm_u8 -vcodec mpeg2video -f framecrc - @end example -See also the @code{crc} muxer (@pxref{crc}). +See also the @ref{crc} muxer. @section image2 diff --git a/doc/texi2pod.pl b/doc/texi2pod.pl index 84c36ff1e1..0eb5e8d9fe 100755 --- a/doc/texi2pod.pl +++ b/doc/texi2pod.pl @@ -352,6 +352,7 @@ sub postprocess s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g; s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g; s/;\s+\@pxref\{(?:[^\}]*)\}//g; + s/\@ref\{([^\}]*)\}/$1/g; s/\@noindent\s*//g; s/\@refill//g; s/\@gol//g; From 8bfd7f6a475225a0595bf657f8b99a8fffb461e4 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 22 Jun 2011 15:33:56 -0400 Subject: [PATCH 405/780] alsa: fallback to buffer_size/4 for period_size. buffer_size/4 is the value used by aplay. This fixes output to null devices, e.g. writing ALSA output to a file. --- libavdevice/alsa-audio-common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index 4cfc6e9864..1e945fc389 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -269,6 +269,8 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, } snd_pcm_hw_params_get_period_size_min(hw_params, &period_size, NULL); + if (!period_size) + period_size = buffer_size / 4; res = snd_pcm_hw_params_set_period_size_near(h, hw_params, &period_size, NULL); if (res < 0) { av_log(ctx, AV_LOG_ERROR, "cannot set ALSA period size (%s)\n", From e35c674d13a7f180412cfe058530a2e7f1d49a90 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 22 Jun 2011 16:38:20 -0400 Subject: [PATCH 406/780] alsa: limit buffer_size to 32768 frames. In testing, the file output plugin gave a max buffer size of about 20 million frames, which is way more than what is really needed and causes a memory allocation error on my system. --- libavdevice/alsa-audio-common.c | 1 + libavdevice/alsa-audio.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index 1e945fc389..126695f754 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -260,6 +260,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, } snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size); + buffer_size = FFMIN(buffer_size, ALSA_BUFFER_SIZE_MAX); /* TODO: maybe use ctx->max_picture_buffer somehow */ res = snd_pcm_hw_params_set_buffer_size_near(h, hw_params, &buffer_size); if (res < 0) { diff --git a/libavdevice/alsa-audio.h b/libavdevice/alsa-audio.h index 1e0be1cac7..ee43463696 100644 --- a/libavdevice/alsa-audio.h +++ b/libavdevice/alsa-audio.h @@ -40,6 +40,8 @@ other formats */ #define DEFAULT_CODEC_ID AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE) +#define ALSA_BUFFER_SIZE_MAX 32768 + typedef struct { AVClass *class; snd_pcm_t *h; From 7f7dc4fb55904e7b51b78ebca746c6755fc9770c Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Sat, 9 Jul 2011 11:03:26 -0700 Subject: [PATCH 407/780] H.264: fix filter_mb_fast with 4:4:4 + 8x8dct --- libavcodec/h264_loopfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 5de9f784d9..6eba8dcd02 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -317,7 +317,7 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, } else { LOCAL_ALIGNED_8(int16_t, bS, [2], [4][4]); int edges; - if( IS_8x8DCT(mb_type) && (h->cbp&7) == 7 ) { + if( IS_8x8DCT(mb_type) && (h->cbp&7) == 7 && !chroma444 ) { edges = 4; AV_WN64A(bS[0][0], 0x0002000200020002ULL); AV_WN64A(bS[0][2], 0x0002000200020002ULL); From 0b950fe240936fa48fd41204bcfd04f35bbf39c3 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 22 May 2011 14:10:49 +0200 Subject: [PATCH 408/780] lavc: introduce avcodec_open2() as a replacement for avcodec_open(). Adds support for decoder-private options and makes setting other options simpler. --- ffprobe.c | 2 +- ffserver.c | 2 +- libavcodec/avcodec.h | 39 ++++++++++++++++++++++++++++++++++++++ libavcodec/mpegvideo_enc.c | 2 +- libavcodec/utils.c | 24 ++++++++++++++++++++++- libavcodec/version.h | 3 +++ libavfilter/vsrc_movie.c | 2 +- 7 files changed, 69 insertions(+), 5 deletions(-) diff --git a/ffprobe.c b/ffprobe.c index edda454cde..cb4a4c3106 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -291,7 +291,7 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) { fprintf(stderr, "Unsupported codec with id %d for input stream %d\n", stream->codec->codec_id, stream->index); - } else if (avcodec_open(stream->codec, codec) < 0) { + } else if (avcodec_open2(stream->codec, codec, NULL) < 0) { fprintf(stderr, "Error while opening codec for input stream %d\n", stream->index); } diff --git a/ffserver.c b/ffserver.c index b4deb8ffd0..a12d7082b6 100644 --- a/ffserver.c +++ b/ffserver.c @@ -2117,7 +2117,7 @@ static void open_parser(AVFormatContext *s, int i) codec = avcodec_find_decoder(st->codec->codec_id); if (codec && (codec->capabilities & CODEC_CAP_PARSE_ONLY)) { st->codec->parse_only = 1; - if (avcodec_open(st->codec, codec) < 0) + if (avcodec_open2(st->codec, codec, NULL) < 0) st->codec->parse_only = 0; } } diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index b26bac7bef..ba0c636292 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -30,6 +30,7 @@ #include "libavutil/samplefmt.h" #include "libavutil/avutil.h" #include "libavutil/cpu.h" +#include "libavutil/dict.h" #include "libavutil/log.h" #include "libavutil/pixfmt.h" #include "libavutil/rational.h" @@ -3619,6 +3620,7 @@ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, v int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); //FIXME func typedef +#if FF_API_AVCODEC_OPEN /** * Initialize the AVCodecContext to use the given AVCodec. Prior to using this * function the context has to be allocated. @@ -3645,8 +3647,45 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, * @param codec The codec to use within the context. * @return zero on success, a negative value on error * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder, avcodec_close + * + * @deprecated use avcodec_open2 */ +attribute_deprecated int avcodec_open(AVCodecContext *avctx, AVCodec *codec); +#endif + +/** + * Initialize the AVCodecContext to use the given AVCodec. Prior to using this + * function the context has to be allocated with avcodec_alloc_context(). + * + * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), + * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for + * retrieving a codec. + * + * @warning This function is not thread safe! + * + * @code + * avcodec_register_all(); + * av_dict_set(&opts, "b", "2.5M", 0); + * codec = avcodec_find_decoder(CODEC_ID_H264); + * if (!codec) + * exit(1); + * + * context = avcodec_alloc_context(); + * + * if (avcodec_open(context, codec, opts) < 0) + * exit(1); + * @endcode + * + * @param avctx The context to initialize. + * @param options A dictionary filled with AVCodecContext and codec-private options. + * On return this object will be filled with options that were not found. + * + * @return zero on success, a negative value on error + * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(), + * av_dict_set(), av_opt_find(). + */ +int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options); /** * Decode the audio frame of size avpkt->size from avpkt->data into samples. diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 73bcc5b229..f298993c0c 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -973,7 +973,7 @@ static int estimate_best_b_count(MpegEncContext *s){ c->time_base= s->avctx->time_base; c->max_b_frames= s->max_b_frames; - if (avcodec_open(c, codec) < 0) + if (avcodec_open2(c, codec, NULL) < 0) return -1; for(i=0; imax_b_frames+2; i++){ diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 722f758231..5ad0c51d02 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -32,6 +32,7 @@ #include "libavutil/audioconvert.h" #include "libavutil/imgutils.h" #include "libavutil/samplefmt.h" +#include "libavutil/dict.h" #include "avcodec.h" #include "dsputil.h" #include "libavutil/opt.h" @@ -467,9 +468,20 @@ AVFrame *avcodec_alloc_frame(void){ return pic; } +#if FF_API_AVCODEC_OPEN int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) +{ + return avcodec_open2(avctx, codec, NULL); +} +#endif + +int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) { int ret = 0; + AVDictionary *tmp = NULL; + + if (options) + av_dict_copy(&tmp, *options, 0); /* If there is a user-supplied mutex locking routine, call it. */ if (ff_lockmgr_cb) { @@ -496,14 +508,18 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) ret = AVERROR(ENOMEM); goto end; } - if(codec->priv_class){ //this can be droped once all user apps use avcodec_get_context_defaults3() + if (codec->priv_class) { *(AVClass**)avctx->priv_data= codec->priv_class; av_opt_set_defaults(avctx->priv_data); } } + if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp) < 0)) + goto free_and_end; } else { avctx->priv_data = NULL; } + if ((ret = av_opt_set_dict(avctx, &tmp)) < 0) + goto free_and_end; if(avctx->coded_width && avctx->coded_height) avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height); @@ -615,8 +631,14 @@ end: if (ff_lockmgr_cb) { (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); } + if (options) { + av_dict_free(options); + *options = tmp; + } + return ret; free_and_end: + av_dict_free(&tmp); av_freep(&avctx->priv_data); avctx->codec= NULL; goto end; diff --git a/libavcodec/version.h b/libavcodec/version.h index aded68e83e..f4a0ecd868 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -68,5 +68,8 @@ #ifndef FF_API_GET_PIX_FMT_NAME #define FF_API_GET_PIX_FMT_NAME (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_AVCODEC_OPEN +#define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c index 7556fa2e9e..bd74f95545 100644 --- a/libavfilter/vsrc_movie.c +++ b/libavfilter/vsrc_movie.c @@ -139,7 +139,7 @@ static int movie_init(AVFilterContext *ctx) return AVERROR(EINVAL); } - if ((ret = avcodec_open(movie->codec_ctx, codec)) < 0) { + if ((ret = avcodec_open2(movie->codec_ctx, codec, NULL)) < 0) { av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n"); return ret; } From a67c061e0f3b55ffcc96f336fc0998e44b86c8e4 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 22 May 2011 19:24:59 +0200 Subject: [PATCH 409/780] lavf: add avformat_find_stream_info() It supports passing options to codecs. --- libavfilter/vsrc_movie.c | 2 +- libavformat/avformat.h | 27 +++++++++++++++++++++++++++ libavformat/utils.c | 18 +++++++++++++----- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c index bd74f95545..b018ba7418 100644 --- a/libavfilter/vsrc_movie.c +++ b/libavfilter/vsrc_movie.c @@ -96,7 +96,7 @@ static int movie_init(AVFilterContext *ctx) "Failed to avformat_open_input '%s'\n", movie->file_name); return ret; } - if ((ret = av_find_stream_info(movie->format_ctx)) < 0) + if ((ret = avformat_find_stream_info(movie->format_ctx, NULL)) < 0) av_log(ctx, AV_LOG_WARNING, "Failed to find stream info\n"); // if seeking requested, we execute it diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 2cdf11be12..6e861de262 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1093,6 +1093,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma */ AVFormatContext *avformat_alloc_context(void); +#if FF_API_FORMAT_PARAMETERS /** * Read packets of a media file to get stream information. This * is useful for file formats with no headers such as MPEG. This @@ -1105,8 +1106,34 @@ AVFormatContext *avformat_alloc_context(void); * @return >=0 if OK, AVERROR_xxx on error * @todo Let the user decide somehow what information is needed so that * we do not waste time getting stuff the user does not need. + * + * @deprecated use avformat_find_stream_info. */ int av_find_stream_info(AVFormatContext *ic); +#endif + +/** + * Read packets of a media file to get stream information. This + * is useful for file formats with no headers such as MPEG. This + * function also computes the real framerate in case of MPEG-2 repeat + * frame mode. + * The logical file position is not changed by this function; + * examined packets may be buffered for later processing. + * + * @param ic media file handle + * @param options If non-NULL, an ic.nb_streams long array of pointers to + * dictionaries, where i-th member contains options for + * codec corresponding to i-th stream. + * On return each dictionary will be filled with options that were not found. + * @return >=0 if OK, AVERROR_xxx on error + * + * @note this function isn't guaranteed to open all the codecs, so + * options being non-empty at return is a perfectly normal behavior. + * + * @todo Let the user decide somehow what information is needed so that + * we do not waste time getting stuff the user does not need. + */ +int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options); /** * Find the "best" stream in the file. diff --git a/libavformat/utils.c b/libavformat/utils.c index e38d9efa60..a3825a0c93 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2074,7 +2074,7 @@ static int has_decode_delay_been_guessed(AVStream *st) st->codec_info_nb_frames >= 6 + st->codec->has_b_frames; } -static int try_decode_frame(AVStream *st, AVPacket *avpkt) +static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options) { int16_t *samples; AVCodec *codec; @@ -2085,7 +2085,7 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt) codec = avcodec_find_decoder(st->codec->codec_id); if (!codec) return -1; - ret = avcodec_open(st->codec, codec); + ret = avcodec_open2(st->codec, codec, options); if (ret < 0) return ret; } @@ -2204,12 +2204,20 @@ static int tb_unreliable(AVCodecContext *c){ return 0; } +#if FF_API_FORMAT_PARAMETERS int av_find_stream_info(AVFormatContext *ic) +{ + return avformat_find_stream_info(ic, NULL); +} +#endif + +int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) { int i, count, ret, read_size, j; AVStream *st; AVPacket pkt1, *pkt; int64_t old_offset = avio_tell(ic->pb); + int orig_nb_streams = ic->nb_streams; // new streams might appear, no options for those for(i=0;inb_streams;i++) { AVCodec *codec; @@ -2235,12 +2243,12 @@ int av_find_stream_info(AVFormatContext *ic) /* Ensure that subtitle_header is properly set. */ if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE && codec && !st->codec->codec) - avcodec_open(st->codec, codec); + avcodec_open2(st->codec, codec, options ? &options[i] : NULL); //try to just open decoders, in case this is enough to get parameters if(!has_codec_parameters(st->codec)){ if (codec && !st->codec->codec) - avcodec_open(st->codec, codec); + avcodec_open2(st->codec, codec, options ? &options[i] : NULL); } } @@ -2383,7 +2391,7 @@ int av_find_stream_info(AVFormatContext *ic) !has_decode_delay_been_guessed(st) || (st->codec->codec && st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF)) - try_decode_frame(st, pkt); + try_decode_frame(st, pkt, (options && i <= orig_nb_streams )? &options[i] : NULL); st->codec_info_nb_frames++; count++; From 9b83919f44eb1c87dc9431112944f0cccf6a599f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 20 May 2011 22:37:59 +0200 Subject: [PATCH 410/780] ac3dec: add a drc_scale private option Deprecate corresponding AVCodecContext option. This is the first test of decoder private options. --- libavcodec/ac3dec.c | 17 +++++++++++++++++ libavcodec/ac3dec.h | 2 ++ libavcodec/avcodec.h | 5 ++++- libavcodec/options.c | 2 ++ libavcodec/version.h | 3 +++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 42b62ef701..663acc0ac9 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -30,6 +30,7 @@ #include #include "libavutil/crc.h" +#include "libavutil/opt.h" #include "internal.h" #include "aac_ac3_parser.h" #include "ac3_parser.h" @@ -1440,6 +1441,20 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx) return 0; } +#define OFFSET(x) offsetof(AC3DecodeContext, x) +#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM) +static const AVOption options[] = { + { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, {1.0}, 0.0, 1.0, PAR }, + { NULL}, +}; + +static const AVClass ac3_decoder_class = { + .class_name = "(E-)AC3 decoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_ac3_decoder = { .name = "ac3", .type = AVMEDIA_TYPE_AUDIO, @@ -1452,6 +1467,7 @@ AVCodec ff_ac3_decoder = { .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .priv_class = &ac3_decoder_class, }; #if CONFIG_EAC3_DECODER @@ -1467,5 +1483,6 @@ AVCodec ff_eac3_decoder = { .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .priv_class = &ac3_decoder_class, }; #endif diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h index aed87432f5..a7cebafbe9 100644 --- a/libavcodec/ac3dec.h +++ b/libavcodec/ac3dec.h @@ -63,6 +63,7 @@ #define SPX_MAX_BANDS 17 typedef struct { + AVClass *class; ///< class for AVOptions AVCodecContext *avctx; ///< parent context GetBitContext gbc; ///< bitstream reader uint8_t *input_buffer; ///< temp buffer to prevent overread @@ -141,6 +142,7 @@ typedef struct { ///@name Dynamic range float dynamic_range[2]; ///< dynamic range + float drc_scale; ///< percentage of dynamic range compression to be applied ///@} ///@name Bandwidth diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ba0c636292..7c7a0c6a97 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2544,13 +2544,16 @@ typedef struct AVCodecContext { int request_channels; #endif +#if FF_API_DRC_SCALE /** * Percentage of dynamic range compression to be applied by the decoder. * The default value is 1.0, corresponding to full compression. * - encoding: unused * - decoding: Set by user. + * @deprecated use AC3 decoder private option instead. */ - float drc_scale; + attribute_deprecated float drc_scale; +#endif /** * opaque 64bit number (generally a PTS) that will be reordered and diff --git a/libavcodec/options.c b/libavcodec/options.c index ae9e0c902d..545887a7c1 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -413,7 +413,9 @@ static const AVOption options[]={ #if FF_API_REQUEST_CHANNELS {"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|D}, #endif +#if FF_API_DRC_SCALE {"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, {.dbl = 1.0 }, 0.0, 1.0, A|D}, +#endif {"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BIT_RESERVOIR }, INT_MIN, INT_MAX, A|E, "flags2"}, {"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MBTREE }, INT_MIN, INT_MAX, V|E, "flags2"}, {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, diff --git a/libavcodec/version.h b/libavcodec/version.h index f4a0ecd868..7e4c02d91e 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -71,5 +71,8 @@ #ifndef FF_API_AVCODEC_OPEN #define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_DRC_SCALE +#define FF_API_DRC_SCALE (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ From 18c007ba37b2c7dee5bd2f1a3eb3bfee9b6b3d26 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 6 Jun 2011 18:37:46 +0200 Subject: [PATCH 411/780] lavc: remove a half-working attempt at different defaults for audio/video codecs. It should be replaced with proper per-codec defaults. --- libavcodec/options.c | 2 +- tests/lavf-regression.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/options.c b/libavcodec/options.c index 545887a7c1..a876ce0404 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -69,7 +69,7 @@ static const AVOption *opt_find(void *obj, const char *name, const char *unit, i static const AVOption options[]={ {"b", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE }, INT_MIN, INT_MAX, V|E}, -{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = 64*1000 }, INT_MIN, INT_MAX, A|E}, +{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE }, INT_MIN, INT_MAX, A|E}, {"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE*20 }, 1, INT_MAX, V|E}, {"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, V|A|E|D, "flags"}, {"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"}, diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh index d7e684032c..6d2d6d8162 100755 --- a/tests/lavf-regression.sh +++ b/tests/lavf-regression.sh @@ -14,7 +14,7 @@ eval do_$test=y do_lavf() { file=${outfile}lavf.$1 - do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $2 + do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -ab 64k -t 1 -qscale 10 $2 do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file $3 } @@ -53,7 +53,7 @@ fi if [ -n "$do_rm" ] ; then file=${outfile}lavf.rm -do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed +do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed -ab 64k # broken #do_ffmpeg_crc $file -i $target_path/$file fi From 71a861cf4010ab835fab383a250f27903eb61a34 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 18 Jun 2011 13:40:48 +0200 Subject: [PATCH 412/780] lavc: make avcodec_alloc_context3 officially public. Deprecate avcodec_alloc_context/2. --- cmdutils.c | 2 +- ffserver.c | 4 ++-- libavcodec/api-example.c | 8 ++++---- libavcodec/avcodec.h | 27 ++++++++++++++++++++++----- libavcodec/motion-test.c | 2 +- libavcodec/mpegvideo_enc.c | 2 +- libavcodec/options.c | 4 ++++ libavcodec/version.h | 3 +++ libavformat/movenc.c | 2 +- libavformat/movenchint.c | 2 +- libavformat/utils.c | 2 +- 11 files changed, 41 insertions(+), 17 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 943a77c82c..2124ca1439 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -63,7 +63,7 @@ void init_opts(void) { int i; for (i = 0; i < AVMEDIA_TYPE_NB; i++) - avcodec_opts[i] = avcodec_alloc_context2(i); + avcodec_opts[i] = avcodec_alloc_context3(NULL); avformat_opts = avformat_alloc_context(); #if CONFIG_SWSCALE sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, NULL, NULL, NULL); diff --git a/ffserver.c b/ffserver.c index a12d7082b6..1dc8a17f2f 100644 --- a/ffserver.c +++ b/ffserver.c @@ -3468,7 +3468,7 @@ static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec, int cop if (!fst) return NULL; if (copy) { - fst->codec= avcodec_alloc_context(); + fst->codec = avcodec_alloc_context3(NULL); memcpy(fst->codec, codec, sizeof(AVCodecContext)); if (codec->extradata_size) { fst->codec->extradata = av_malloc(codec->extradata_size); @@ -3885,7 +3885,7 @@ static void add_codec(FFStream *stream, AVCodecContext *av) st = av_mallocz(sizeof(AVStream)); if (!st) return; - st->codec = avcodec_alloc_context(); + st->codec = avcodec_alloc_context3(NULL); stream->streams[stream->nb_streams++] = st; memcpy(st->codec, av, sizeof(AVCodecContext)); } diff --git a/libavcodec/api-example.c b/libavcodec/api-example.c index 1792d60d77..ec71b0d031 100644 --- a/libavcodec/api-example.c +++ b/libavcodec/api-example.c @@ -65,7 +65,7 @@ static void audio_encode_example(const char *filename) exit(1); } - c= avcodec_alloc_context(); + c = avcodec_alloc_context3(codec); /* put sample parameters */ c->bit_rate = 64000; @@ -135,7 +135,7 @@ static void audio_decode_example(const char *outfilename, const char *filename) exit(1); } - c= avcodec_alloc_context(); + c = avcodec_alloc_context3(codec); /* open it */ if (avcodec_open(c, codec) < 0) { @@ -216,7 +216,7 @@ static void video_encode_example(const char *filename) exit(1); } - c= avcodec_alloc_context(); + c = avcodec_alloc_context3(codec); picture= avcodec_alloc_frame(); /* put sample parameters */ @@ -347,7 +347,7 @@ static void video_decode_example(const char *outfilename, const char *filename) exit(1); } - c= avcodec_alloc_context(); + c = avcodec_alloc_context3(codec); picture= avcodec_alloc_frame(); if(codec->capabilities&CODEC_CAP_TRUNCATED) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7c7a0c6a97..3f016807ab 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3529,21 +3529,38 @@ void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType); * we WILL change its arguments and name a few times! */ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec); +#if FF_API_ALLOC_CONTEXT /** * Allocate an AVCodecContext and set its fields to default values. The * resulting struct can be deallocated by simply calling av_free(). * * @return An AVCodecContext filled with default values or NULL on failure. * @see avcodec_get_context_defaults + * + * @deprecated use avcodec_alloc_context3() */ +attribute_deprecated AVCodecContext *avcodec_alloc_context(void); /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! * we WILL change its arguments and name a few times! */ +attribute_deprecated AVCodecContext *avcodec_alloc_context2(enum AVMediaType); +#endif -/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! - * we WILL change its arguments and name a few times! */ +/** + * Allocate an AVCodecContext and set its fields to default values. The + * resulting struct can be deallocated by simply calling av_free(). + * + * @param codec if non-NULL, allocate private data and initialize defaults + * for the given codec. It is illegal to then call avcodec_open() + * with a different codec. + * + * @return An AVCodecContext filled with default values or NULL on failure. + * @see avcodec_get_context_defaults + * + * @deprecated use avcodec_alloc_context3() + */ AVCodecContext *avcodec_alloc_context3(AVCodec *codec); /** @@ -3553,7 +3570,7 @@ AVCodecContext *avcodec_alloc_context3(AVCodec *codec); * can use this AVCodecContext to decode/encode video/audio data. * * @param dest target codec context, should be initialized with - * avcodec_alloc_context(), but otherwise uninitialized + * avcodec_alloc_context3(), but otherwise uninitialized * @param src source codec context * @return AVERROR() on error (e.g. memory allocation error), 0 on success */ @@ -3640,7 +3657,7 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, * if (!codec) * exit(1); * - * context = avcodec_alloc_context(); + * context = avcodec_alloc_context3(codec); * * if (avcodec_open(context, codec) < 0) * exit(1); @@ -3649,7 +3666,7 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, * @param avctx The context which will be set up to use the given codec. * @param codec The codec to use within the context. * @return zero on success, a negative value on error - * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder, avcodec_close + * @see avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close * * @deprecated use avcodec_open2 */ diff --git a/libavcodec/motion-test.c b/libavcodec/motion-test.c index b88917c988..7ac5cc7d4a 100644 --- a/libavcodec/motion-test.c +++ b/libavcodec/motion-test.c @@ -144,7 +144,7 @@ int main(int argc, char **argv) printf("ffmpeg motion test\n"); - ctx = avcodec_alloc_context(); + ctx = avcodec_alloc_context3(NULL); ctx->dsp_mask = AV_CPU_FLAG_FORCE; dsputil_init(&cctx, ctx); for (c = 0; c < flags_size; c++) { diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index f298993c0c..68bd080960 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -944,7 +944,7 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref){ static int estimate_best_b_count(MpegEncContext *s){ AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id); - AVCodecContext *c= avcodec_alloc_context(); + AVCodecContext *c = avcodec_alloc_context3(NULL); AVFrame input[FF_MAX_B_FRAMES+2]; const int scale= s->avctx->brd_scale; int i, j, out_size, p_lambda, b_lambda, lambda2; diff --git a/libavcodec/options.c b/libavcodec/options.c index a876ce0404..1e7fe522ea 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -540,6 +540,7 @@ AVCodecContext *avcodec_alloc_context3(AVCodec *codec){ return avctx; } +#if FF_API_ALLOC_CONTEXT AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){ AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext)); @@ -549,14 +550,17 @@ AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){ return avctx; } +#endif void avcodec_get_context_defaults(AVCodecContext *s){ avcodec_get_context_defaults2(s, AVMEDIA_TYPE_UNKNOWN); } +#if FF_API_ALLOC_CONTEXT AVCodecContext *avcodec_alloc_context(void){ return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN); } +#endif int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) { diff --git a/libavcodec/version.h b/libavcodec/version.h index 7e4c02d91e..32b2bb314c 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -68,6 +68,9 @@ #ifndef FF_API_GET_PIX_FMT_NAME #define FF_API_GET_PIX_FMT_NAME (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_ALLOC_CONTEXT +#define FF_API_ALLOC_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #ifndef FF_API_AVCODEC_OPEN #define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 54) #endif diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 0de7c4d44d..ae6f603e86 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2102,7 +2102,7 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum) track->mode = mov->mode; track->tag = MKTAG('t','e','x','t'); track->timescale = MOV_TIMESCALE; - track->enc = avcodec_alloc_context(); + track->enc = avcodec_alloc_context3(NULL); track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE; for (i = 0; i < s->nb_chapters; i++) { diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c index 615714627c..683d58b7c5 100644 --- a/libavformat/movenchint.c +++ b/libavformat/movenchint.c @@ -36,7 +36,7 @@ int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index) track->tag = MKTAG('r','t','p',' '); track->src_track = src_index; - track->enc = avcodec_alloc_context(); + track->enc = avcodec_alloc_context3(NULL); if (!track->enc) goto fail; track->enc->codec_type = AVMEDIA_TYPE_DATA; diff --git a/libavformat/utils.c b/libavformat/utils.c index a3825a0c93..bbd1b2d07b 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2668,7 +2668,7 @@ AVStream *av_new_stream(AVFormatContext *s, int id) return NULL; } - st->codec= avcodec_alloc_context(); + st->codec = avcodec_alloc_context3(NULL); if (s->iformat) { /* no default bitrate if decoding */ st->codec->bit_rate = 0; From 84626b364babc27c5a3db454ebf6a02aeaa186fe Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 8 Jun 2011 08:27:53 +0200 Subject: [PATCH 413/780] lavc: add support for codec-specific defaults. --- libavcodec/avcodec.h | 7 +++++++ libavcodec/internal.h | 5 +++++ libavcodec/options.c | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 3f016807ab..ba6342a09e 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2860,6 +2860,8 @@ typedef struct AVProfile { const char *name; ///< short name for the profile } AVProfile; +typedef struct AVCodecDefault AVCodecDefault; + /** * AVCodec. */ @@ -2922,6 +2924,11 @@ typedef struct AVCodec { */ int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src); /** @} */ + + /** + * Private codec-specific defaults. + */ + const AVCodecDefault *defaults; } AVCodec; /** diff --git a/libavcodec/internal.h b/libavcodec/internal.h index fe853ab87e..9a444fcae7 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -27,6 +27,11 @@ #include #include "avcodec.h" +struct AVCodecDefault { + const uint8_t *key; + const uint8_t *value; +}; + /** * Determine whether pix_fmt is a hardware accelerated format. */ diff --git a/libavcodec/options.c b/libavcodec/options.c index 1e7fe522ea..4869046665 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -25,6 +25,8 @@ */ #include "avcodec.h" +#include "internal.h" +#include "libavutil/avassert.h" #include "libavutil/opt.h" #include /* FLT_MIN, FLT_MAX */ @@ -524,6 +526,15 @@ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ av_opt_set_defaults(s->priv_data); } } + if (codec && codec->defaults) { + int ret; + AVCodecDefault *d = codec->defaults; + while (d->key) { + ret = av_set_string3(s, d->key, d->value, 0, NULL); + av_assert0(ret >= 0); + d++; + } + } return 0; } From 2420763638bef385c8116a44ff5c0d2c15589494 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Jul 2011 15:37:32 +0200 Subject: [PATCH 414/780] graphparser: simplify condition in avfilter_graph_parse() Since avfilter_graph_parse() creates the "[in]" inout for the first unlabelled input pad, it is expected that it will create an "[out]" inout for last unlabelled output pad, even in the case where it cannot find any open input pad with that name. This change removes the check on the existence of an open input pad named "out", so it simplifies the checked condition while implementing a more intuitive behavior. --- libavfilter/avfilter.h | 2 +- libavfilter/graphparser.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 226d7beacb..362bbfe2e5 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 24 -#define LIBAVFILTER_VERSION_MICRO 3 +#define LIBAVFILTER_VERSION_MICRO 4 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index 111e5aa0db..9db7a4df94 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -389,7 +389,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, goto end; } - if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) { + if (curr_inputs) { /* Last output pad, assume it is "[out]" if not specified */ const char *tmp = "[out]"; if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs, From 2e5a9e580cef8a30a8d724cc8ff93897f4903d06 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 8 Jul 2011 09:52:07 +0200 Subject: [PATCH 415/780] examples/encoding.c: use av_image_alloc() for allocating an image buffer Simplify. --- doc/examples/encoding.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/doc/examples/encoding.c b/doc/examples/encoding.c index ff6fd2b4df..1fb82c290c 100644 --- a/doc/examples/encoding.c +++ b/doc/examples/encoding.c @@ -205,7 +205,7 @@ static void video_encode_example(const char *filename) int i, out_size, size, x, y, outbuf_size; FILE *f; AVFrame *picture; - uint8_t *outbuf, *picture_buf; + uint8_t *outbuf; printf("Video encoding\n"); @@ -245,15 +245,11 @@ static void video_encode_example(const char *filename) /* alloc image and output buffer */ outbuf_size = 100000; outbuf = malloc(outbuf_size); - size = c->width * c->height; - picture_buf = malloc((size * 3) / 2); /* size for YUV 420 */ - picture->data[0] = picture_buf; - picture->data[1] = picture->data[0] + size; - picture->data[2] = picture->data[1] + size / 4; - picture->linesize[0] = c->width; - picture->linesize[1] = c->width / 2; - picture->linesize[2] = c->width / 2; + /* the image can be allocated by any means and av_image_alloc() is + * just the most convenient way if av_malloc() is to be used */ + av_image_alloc(picture->data, picture->linesize, + c->width, c->height, c->pix_fmt, 1); /* encode 1 second of video */ for(i=0;i<25;i++) { @@ -296,11 +292,11 @@ static void video_encode_example(const char *filename) outbuf[3] = 0xb7; fwrite(outbuf, 1, 4, f); fclose(f); - free(picture_buf); free(outbuf); avcodec_close(c); av_free(c); + av_free(picture->data[0]); av_free(picture); printf("\n"); } From c762f9fa2d9adde5c7119b2a06f41206c003507e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Jul 2011 15:24:54 +0200 Subject: [PATCH 416/780] examples/encoding.c: remove unnecessary includes Simplify. --- doc/examples/encoding.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/doc/examples/encoding.c b/doc/examples/encoding.c index 1fb82c290c..2d06cf6d94 100644 --- a/doc/examples/encoding.c +++ b/doc/examples/encoding.c @@ -27,14 +27,6 @@ * format handling */ -#include -#include -#include - -#ifdef HAVE_AV_CONFIG_H -#undef HAVE_AV_CONFIG_H -#endif - #include "libavcodec/avcodec.h" #include "libavutil/mathematics.h" From fcc7d869d98838356e3e778afe2196a12bfcd2b1 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 21 Jun 2011 00:33:37 +0200 Subject: [PATCH 417/780] doc/examples: add decoding/filtering example program --- doc/examples/Makefile | 2 +- doc/examples/filtering.c | 230 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 doc/examples/filtering.c diff --git a/doc/examples/Makefile b/doc/examples/Makefile index f8abdff4e3..fde2256fca 100644 --- a/doc/examples/Makefile +++ b/doc/examples/Makefile @@ -3,7 +3,7 @@ FFMPEG_LIBS=libavdevice libavformat libavfilter libavcodec libswscale libavutil CFLAGS+=$(shell pkg-config --cflags $(FFMPEG_LIBS)) LDFLAGS+=$(shell pkg-config --libs $(FFMPEG_LIBS)) -EXAMPLES=encoding metadata muxing +EXAMPLES=encoding filtering metadata muxing OBJS=$(addsuffix .o,$(EXAMPLES)) diff --git a/doc/examples/filtering.c b/doc/examples/filtering.c new file mode 100644 index 0000000000..369cc03e80 --- /dev/null +++ b/doc/examples/filtering.c @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2010 Nicolas George + * Copyright (c) 2011 Stefano Sabatini + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * @file + * API example for decoding and filtering + */ + +#define _XOPEN_SOURCE 600 /* for usleep */ + +#include +#include +#include +#include +#include + +const char *filter_descr = "scale=78:24"; + +static AVFormatContext *fmt_ctx; +static AVCodecContext *dec_ctx; +AVFilterContext *buffersink_ctx; +AVFilterContext *buffersrc_ctx; +AVFilterGraph *filter_graph; +static int video_stream_index = -1; +static int64_t last_pts = AV_NOPTS_VALUE; + +static int open_input_file(const char *filename) +{ + int ret, i; + AVCodec *dec; + + if ((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)) < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n"); + return ret; + } + + if ((ret = av_find_stream_info(fmt_ctx)) < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n"); + return ret; + } + + /* select the video stream */ + ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &dec, 0); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot find a video stream in the input file\n"); + return ret; + } + video_stream_index = ret; + dec_ctx = fmt_ctx->streams[video_stream_index]->codec; + + /* init the video decoder */ + if ((ret = avcodec_open(dec_ctx, dec)) < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot open video decoder\n"); + return ret; + } + + return 0; +} + +static int init_filters(const char *filters_descr) +{ + char args[512]; + int ret; + AVFilter *buffersrc = avfilter_get_by_name("buffer"); + AVFilter *buffersink = avfilter_get_by_name("buffersink"); + AVFilterInOut *outputs = avfilter_inout_alloc(); + AVFilterInOut *inputs = avfilter_inout_alloc(); + enum PixelFormat pix_fmts[] = { PIX_FMT_GRAY8, PIX_FMT_NONE }; + filter_graph = avfilter_graph_alloc(); + + /* buffer video source: the decoded frames from the decoder will be inserted here. */ + snprintf(args, sizeof(args), "%d:%d:%d:%d:%d:%d:%d", + dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt, + dec_ctx->time_base.num, dec_ctx->time_base.den, + dec_ctx->sample_aspect_ratio.num, dec_ctx->sample_aspect_ratio.den); + ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in", + args, NULL, filter_graph); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot create buffer source\n"); + return ret; + } + + /* buffer video sink: to terminate the filter chain. */ + ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out", + NULL, pix_fmts, filter_graph); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n"); + return ret; + } + + /* Endpoints for the filter graph. */ + outputs->name = av_strdup("in"); + outputs->filter_ctx = buffersrc_ctx; + outputs->pad_idx = 0; + outputs->next = NULL; + + inputs->name = av_strdup("out"); + inputs->filter_ctx = buffersink_ctx; + inputs->pad_idx = 0; + inputs->next = NULL; + + if ((ret = avfilter_graph_parse(filter_graph, filter_descr, + &inputs, &outputs, NULL)) < 0) + return ret; + + if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0) + return ret; +} + +static void display_picref(AVFilterBufferRef *picref, AVRational time_base) +{ + int x, y; + uint8_t *p0, *p; + int64_t delay; + + if (picref->pts != AV_NOPTS_VALUE) { + if (last_pts != AV_NOPTS_VALUE) { + /* sleep roughly the right amount of time; + * usleep is in microseconds, just like AV_TIME_BASE. */ + delay = av_rescale_q(picref->pts - last_pts, + time_base, AV_TIME_BASE_Q); + if (delay > 0 && delay < 1000000) + usleep(delay); + } + last_pts = picref->pts; + } + + /* Trivial ASCII grayscale display. */ + p0 = picref->data[0]; + puts("\033c"); + for (y = 0; y < picref->video->h; y++) { + p = p0; + for (x = 0; x < picref->video->w; x++) + putchar(" .-+#"[*(p++) / 52]); + putchar('\n'); + p0 += picref->linesize[0]; + } + fflush(stdout); +} + +int main(int argc, char **argv) +{ + int ret; + AVPacket packet; + AVFrame frame; + int got_frame; + + if (argc != 2) { + fprintf(stderr, "Usage: %s file\n", argv[0]); + exit(1); + } + + avcodec_register_all(); + av_register_all(); + avfilter_register_all(); + + if ((ret = open_input_file(argv[1]) < 0)) + goto end; + if ((ret = init_filters(filter_descr)) < 0) + goto end; + + /* read all packets */ + while (1) { + AVFilterBufferRef *picref; + if ((ret = av_read_frame(fmt_ctx, &packet)) < 0) + break; + + if (packet.stream_index == video_stream_index) { + avcodec_get_frame_defaults(&frame); + got_frame = 0; + ret = avcodec_decode_video2(dec_ctx, &frame, &got_frame, &packet); + av_free_packet(&packet); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error decoding video\n"); + break; + } + + if (got_frame) { + if (frame.pts == AV_NOPTS_VALUE) + frame.pts = frame.pkt_dts == AV_NOPTS_VALUE ? + frame.pkt_dts : frame.pkt_pts; + /* push the decoded frame into the filtergraph */ + av_vsrc_buffer_add_frame(buffersrc_ctx, &frame); + + /* pull filtered pictures from the filtergraph */ + while (avfilter_poll_frame(buffersink_ctx->inputs[0])) { + av_vsink_buffer_get_video_buffer_ref(buffersink_ctx, &picref, 0); + if (picref) { + display_picref(picref, buffersink_ctx->inputs[0]->time_base); + avfilter_unref_buffer(picref); + } + } + } + } + } +end: + avfilter_graph_free(&filter_graph); + if (dec_ctx) + avcodec_close(dec_ctx); + av_close_input_file(fmt_ctx); + + if (ret < 0 && ret != AVERROR_EOF) { + char buf[1024]; + av_strerror(ret, buf, sizeof(buf)); + fprintf(stderr, "Error occurred: %s\n", buf); + exit(1); + } + + exit(0); +} From 58174293d815c76a4fafe290c78a955c52a47981 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 10 Jul 2011 17:58:35 +0200 Subject: [PATCH 418/780] examples/muxing.c: remove doxy reference to unexisting file --- doc/examples/muxing.c | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c index 42c9ced022..9f94a7808c 100644 --- a/doc/examples/muxing.c +++ b/doc/examples/muxing.c @@ -24,7 +24,6 @@ * @file * libavformat API example. * - * @example libavformat/output-example.c * Output a media file in any supported libavformat format. * The default codecs are used. */ From 31ad14c21e0735387ba8082c6e3436241f7ccfc8 Mon Sep 17 00:00:00 2001 From: Aaron Colwell Date: Sat, 9 Jul 2011 07:48:43 +0200 Subject: [PATCH 419/780] matroskadec: defer parsing of cues element until we seek. This decreases startup latency. Signed-off-by: Ronald S. Bultje Signed-off-by: Anton Khirnov --- libavformat/matroskadec.c | 131 +++++++++++++++++++++++++------------- 1 file changed, 86 insertions(+), 45 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index a1e827f093..37ce3342b1 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -244,6 +244,9 @@ typedef struct { /* What to skip before effectively reading a packet. */ int skip_to_keyframe; uint64_t skip_to_timecode; + + /* File has a CUES element, but we defer parsing until it is needed. */ + int cues_parsing_deferred; } MatroskaDemuxContext; typedef struct { @@ -1110,7 +1113,7 @@ static void matroska_convert_tags(AVFormatContext *s) } } -static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) +static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, int idx) { EbmlList *seekhead_list = &matroska->seekhead; MatroskaSeekhead *seekhead = seekhead_list->elem; @@ -1118,34 +1121,25 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) int64_t before_pos = avio_tell(matroska->ctx->pb); uint32_t saved_id = matroska->current_id; MatroskaLevel level; - int i; + int64_t offset; + int ret = 0; - // we should not do any seeking in the streaming case - if (!matroska->ctx->pb->seekable || - (matroska->ctx->flags & AVFMT_FLAG_IGNIDX)) - return; - - for (i=0; inb_elem; i++) { - int64_t offset = seekhead[i].pos + matroska->segment_start; - - if (seekhead[i].pos <= before_pos - || seekhead[i].id == MATROSKA_ID_SEEKHEAD - || seekhead[i].id == MATROSKA_ID_CLUSTER) - continue; + if (idx >= seekhead_list->nb_elem + || seekhead[idx].id == MATROSKA_ID_SEEKHEAD + || seekhead[idx].id == MATROSKA_ID_CLUSTER) + return 0; /* seek */ - if (avio_seek(matroska->ctx->pb, offset, SEEK_SET) != offset) - continue; - + offset = seekhead[idx].pos + matroska->segment_start; + if (avio_seek(matroska->ctx->pb, offset, SEEK_SET) == offset) { /* We don't want to lose our seekhead level, so we add * a dummy. This is a crude hack. */ if (matroska->num_levels == EBML_MAX_DEPTH) { av_log(matroska->ctx, AV_LOG_INFO, "Max EBML element depth (%d) reached, " "cannot parse further.\n", EBML_MAX_DEPTH); - break; - } - + ret = AVERROR_INVALIDDATA; + } else { level.start = 0; level.length = (uint64_t)-1; matroska->levels[matroska->num_levels] = level; @@ -1161,11 +1155,76 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) break; } } - + } /* seek back */ avio_seek(matroska->ctx->pb, before_pos, SEEK_SET); matroska->level_up = level_up; matroska->current_id = saved_id; + + return ret; +} + +static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) +{ + EbmlList *seekhead_list = &matroska->seekhead; + MatroskaSeekhead *seekhead = seekhead_list->elem; + int64_t before_pos = avio_tell(matroska->ctx->pb); + int i; + + // we should not do any seeking in the streaming case + if (!matroska->ctx->pb->seekable || + (matroska->ctx->flags & AVFMT_FLAG_IGNIDX)) + return; + + for (i = 0; i < seekhead_list->nb_elem; i++) { + if (seekhead[i].pos <= before_pos) + continue; + + // defer cues parsing until we actually need cue data. + if (seekhead[i].id == MATROSKA_ID_CUES) { + matroska->cues_parsing_deferred = 1; + continue; + } + + if (matroska_parse_seekhead_entry(matroska, i) < 0) + break; + } +} + +static void matroska_parse_cues(MatroskaDemuxContext *matroska) { + EbmlList *seekhead_list = &matroska->seekhead; + MatroskaSeekhead *seekhead = seekhead_list->elem; + EbmlList *index_list; + MatroskaIndex *index; + int index_scale = 1; + int i, j; + + for (i = 0; i < seekhead_list->nb_elem; i++) + if (seekhead[i].id != MATROSKA_ID_CUES) + break; + assert(i <= seekhead_list->nb_elem); + + matroska_parse_seekhead_entry(matroska, i); + + index_list = &matroska->index; + index = index_list->elem; + if (index_list->nb_elem + && index[0].time > 1E14/matroska->time_scale) { + av_log(matroska->ctx, AV_LOG_WARNING, "Working around broken index.\n"); + index_scale = matroska->time_scale; + } + for (i = 0; i < index_list->nb_elem; i++) { + EbmlList *pos_list = &index[i].pos; + MatroskaIndexPos *pos = pos_list->elem; + for (j = 0; j < pos_list->nb_elem; j++) { + MatroskaTrack *track = matroska_find_track_by_num(matroska, pos[j].track); + if (track && track->stream) + av_add_index_entry(track->stream, + pos[j].pos + matroska->segment_start, + index[i].time/index_scale, 0, 0, + AVINDEX_KEYFRAME); + } + } } static int matroska_aac_profile(char *codec_id) @@ -1197,9 +1256,6 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) EbmlList *chapters_list = &matroska->chapters; MatroskaChapter *chapters; MatroskaTrack *tracks; - EbmlList *index_list; - MatroskaIndex *index; - int index_scale = 1; uint64_t max_start = 0; Ebml ebml = { 0 }; AVStream *st; @@ -1529,27 +1585,6 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) max_start = chapters[i].start; } - index_list = &matroska->index; - index = index_list->elem; - if (index_list->nb_elem - && index[0].time > 100000000000000/matroska->time_scale) { - av_log(matroska->ctx, AV_LOG_WARNING, "Working around broken index.\n"); - index_scale = matroska->time_scale; - } - for (i=0; inb_elem; i++) { - EbmlList *pos_list = &index[i].pos; - MatroskaIndexPos *pos = pos_list->elem; - for (j=0; jnb_elem; j++) { - MatroskaTrack *track = matroska_find_track_by_num(matroska, - pos[j].track); - if (track && track->stream) - av_add_index_entry(track->stream, - pos[j].pos + matroska->segment_start, - index[i].time/index_scale, 0, 0, - AVINDEX_KEYFRAME); - } - } - matroska_convert_tags(s); return 0; @@ -1898,6 +1933,12 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, AVStream *st = s->streams[stream_index]; int i, index, index_sub, index_min; + /* Parse the CUES now since we need the index data to seek. */ + if (matroska->cues_parsing_deferred) { + matroska_parse_cues(matroska); + matroska->cues_parsing_deferred = 0; + } + if (!st->nb_index_entries) return 0; timestamp = FFMAX(timestamp, st->index_entries[0].timestamp); From f47ac3c6ca966d72b2966495958184b524d001f7 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Jul 2011 08:11:30 +0200 Subject: [PATCH 420/780] matroskadec: reindent --- libavformat/matroskadec.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 37ce3342b1..e1e555df80 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1129,7 +1129,7 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, int idx || seekhead[idx].id == MATROSKA_ID_CLUSTER) return 0; - /* seek */ + /* seek */ offset = seekhead[idx].pos + matroska->segment_start; if (avio_seek(matroska->ctx->pb, offset, SEEK_SET) == offset) { /* We don't want to lose our seekhead level, so we add @@ -1140,22 +1140,22 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, int idx "cannot parse further.\n", EBML_MAX_DEPTH); ret = AVERROR_INVALIDDATA; } else { - level.start = 0; - level.length = (uint64_t)-1; - matroska->levels[matroska->num_levels] = level; - matroska->num_levels++; - matroska->current_id = 0; + level.start = 0; + level.length = (uint64_t)-1; + matroska->levels[matroska->num_levels] = level; + matroska->num_levels++; + matroska->current_id = 0; - ebml_parse(matroska, matroska_segment, matroska); + ebml_parse(matroska, matroska_segment, matroska); - /* remove dummy level */ - while (matroska->num_levels) { - uint64_t length = matroska->levels[--matroska->num_levels].length; - if (length == (uint64_t)-1) - break; + /* remove dummy level */ + while (matroska->num_levels) { + uint64_t length = matroska->levels[--matroska->num_levels].length; + if (length == (uint64_t)-1) + break; + } } } - } /* seek back */ avio_seek(matroska->ctx->pb, before_pos, SEEK_SET); matroska->level_up = level_up; From 0f6fc8660e32a69c406cba44cf31df6f7a7543d2 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 9 Jul 2011 11:03:01 +0100 Subject: [PATCH 421/780] 9/10-bit: simplify clipping macros Signed-off-by: Mans Rullgard --- libavcodec/bit_depth_template.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/libavcodec/bit_depth_template.c b/libavcodec/bit_depth_template.c index c0a6eafe89..4da0a6e0c9 100644 --- a/libavcodec/bit_depth_template.c +++ b/libavcodec/bit_depth_template.c @@ -43,15 +43,6 @@ # undef PIXEL_SPLAT_X4 #else # define AVCODEC_H264_HIGH_DEPTH_H -# define CLIP_PIXEL(depth)\ - static inline uint16_t av_clip_pixel_ ## depth (int p)\ - {\ - const int pixel_max = (1 << depth)-1;\ - return (p & ~pixel_max) ? (-p)>>31 & pixel_max : p;\ - } - -CLIP_PIXEL( 9) -CLIP_PIXEL(10) #endif #if BIT_DEPTH > 8 @@ -70,6 +61,9 @@ CLIP_PIXEL(10) # define AV_WN4P AV_WN64 # define AV_WN4PA AV_WN64A # define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL) + +# define av_clip_pixel(a) av_clip_uintp2(a, BIT_DEPTH) +# define CLIP(a) av_clip_uintp2(a, BIT_DEPTH) #else # define pixel uint8_t # define pixel2 uint16_t @@ -86,21 +80,18 @@ CLIP_PIXEL(10) # define AV_WN4P AV_WN32 # define AV_WN4PA AV_WN32A # define PIXEL_SPLAT_X4(x) ((x)*0x01010101U) + +# define av_clip_pixel(a) av_clip_uint8(a) +# define CLIP(a) cm[a] #endif #if BIT_DEPTH == 8 -# define av_clip_pixel(a) av_clip_uint8(a) -# define CLIP(a) cm[a] # define FUNC(a) a ## _8 # define FUNCC(a) a ## _8_c #elif BIT_DEPTH == 9 -# define av_clip_pixel(a) av_clip_pixel_9(a) -# define CLIP(a) av_clip_pixel_9(a) # define FUNC(a) a ## _9 # define FUNCC(a) a ## _9_c #elif BIT_DEPTH == 10 -# define av_clip_pixel(a) av_clip_pixel_10(a) -# define CLIP(a) av_clip_pixel_10(a) # define FUNC(a) a ## _10 # define FUNCC(a) a ## _10_c #endif From 710b8df949248b29446e5ee8b081b611a83951fa Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 9 Jul 2011 11:38:39 +0100 Subject: [PATCH 422/780] dsputil: remove ff_emulated_edge_mc macro used in one place This macro can cause problems in conjunction with the bitdepth template expansion. It was presumably added to keep source compatibility when high bitdepth support was added. However, emulated_edge_mc is a dsputil pointer and should not be called directly, so there is little reason to keep such a macro. Signed-off-by: Mans Rullgard --- libavcodec/dsputil.h | 2 -- libavcodec/x86/dsputil_mmx.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index ef2956eecb..5a97b442ad 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -211,8 +211,6 @@ EMULATED_EDGE(8) EMULATED_EDGE(9) EMULATED_EDGE(10) -#define ff_emulated_edge_mc ff_emulated_edge_mc_8 - void ff_add_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize); void ff_put_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize); void ff_put_signed_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize); diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index b06a34ddce..4e84f63378 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -1879,7 +1879,7 @@ static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int o int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height) { gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r, - width, height, &ff_emulated_edge_mc); + width, height, &ff_emulated_edge_mc_8); } #endif From 39c2a6bf44b25534fdbc9b6ac3844dab28ba5b0e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 9 Jul 2011 11:44:07 +0100 Subject: [PATCH 423/780] bitdepth: simplify FUNC/FUNCC macros Signed-off-by: Mans Rullgard --- libavcodec/bit_depth_template.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libavcodec/bit_depth_template.c b/libavcodec/bit_depth_template.c index 4da0a6e0c9..9071ec2a35 100644 --- a/libavcodec/bit_depth_template.c +++ b/libavcodec/bit_depth_template.c @@ -85,13 +85,7 @@ # define CLIP(a) cm[a] #endif -#if BIT_DEPTH == 8 -# define FUNC(a) a ## _8 -# define FUNCC(a) a ## _8_c -#elif BIT_DEPTH == 9 -# define FUNC(a) a ## _9 -# define FUNCC(a) a ## _9_c -#elif BIT_DEPTH == 10 -# define FUNC(a) a ## _10 -# define FUNCC(a) a ## _10_c -#endif +#define FUNC3(a, b, c) a ## _ ## b ## c +#define FUNC2(a, b, c) FUNC3(a, b, c) +#define FUNC(a) FUNC2(a, BIT_DEPTH,) +#define FUNCC(a) FUNC2(a, BIT_DEPTH, _c) From 11043d80f60ca37330f5f1afb8ee956665a71290 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 9 Jul 2011 12:37:08 +0100 Subject: [PATCH 424/780] ARM: use const macro to define constant data in asm Signed-off-by: Mans Rullgard --- libavcodec/arm/fft_neon.S | 16 +++++++++------- libavcodec/arm/h264idct_neon.S | 5 +++-- libavcodec/arm/h264pred_neon.S | 7 ++----- libavcodec/arm/simple_idct_neon.S | 5 ++--- libavcodec/arm/vp3dsp_neon.S | 8 ++------ libavcodec/arm/vp8_armv6.S | 4 ++-- 6 files changed, 20 insertions(+), 25 deletions(-) diff --git a/libavcodec/arm/fft_neon.S b/libavcodec/arm/fft_neon.S index 887621834e..b79a2dc265 100644 --- a/libavcodec/arm/fft_neon.S +++ b/libavcodec/arm/fft_neon.S @@ -349,9 +349,7 @@ function ff_fft_permute_neon, export=1 pop {r4,pc} endfunc - .section .rodata - .align 4 -fft_tab_neon: +const fft_tab_neon .word fft4_neon .word fft8_neon .word fft16_neon @@ -367,8 +365,12 @@ fft_tab_neon: .word fft16384_neon .word fft32768_neon .word fft65536_neon -ELF .size fft_tab_neon, . - fft_tab_neon +endconst - .align 4 -pmmp: .float +1.0, -1.0, -1.0, +1.0 -mppm: .float -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2 +const pmmp, align=4 + .float +1.0, -1.0, -1.0, +1.0 +endconst + +const mppm, align=4 + .float -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2 +endconst diff --git a/libavcodec/arm/h264idct_neon.S b/libavcodec/arm/h264idct_neon.S index eadf2e711d..6c62e0f7cb 100644 --- a/libavcodec/arm/h264idct_neon.S +++ b/libavcodec/arm/h264idct_neon.S @@ -383,8 +383,8 @@ function ff_h264_idct8_add4_neon, export=1 pop {r4-r8,pc} endfunc - .section .rodata -scan8: .byte 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8 +const scan8 + .byte 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8 .byte 6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8 .byte 4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8 .byte 6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8 @@ -396,3 +396,4 @@ scan8: .byte 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8 .byte 6+11*8, 7+11*8, 6+12*8, 7+12*8 .byte 4+13*8, 5+13*8, 4+14*8, 5+14*8 .byte 6+13*8, 7+13*8, 6+14*8, 7+14*8 +endconst diff --git a/libavcodec/arm/h264pred_neon.S b/libavcodec/arm/h264pred_neon.S index fe8a369a90..815b67b81f 100644 --- a/libavcodec/arm/h264pred_neon.S +++ b/libavcodec/arm/h264pred_neon.S @@ -166,12 +166,9 @@ function ff_pred16x16_plane_neon, export=1 bx lr endfunc - .section .rodata - .align 4 -p16weight: +const p16weight, align=4 .short 1,2,3,4,5,6,7,8 - - .text +endconst function ff_pred8x8_hor_neon, export=1 sub r2, r0, #1 diff --git a/libavcodec/arm/simple_idct_neon.S b/libavcodec/arm/simple_idct_neon.S index cbed9eefe4..0c4e05d869 100644 --- a/libavcodec/arm/simple_idct_neon.S +++ b/libavcodec/arm/simple_idct_neon.S @@ -243,10 +243,9 @@ function idct_col4_st8_neon bx lr endfunc - .section .rodata - .align 4 -idct_coeff_neon: +const idct_coeff_neon, align=4 .short W1, W2, W3, W4, W5, W6, W7, W4c +endconst .macro idct_start data push {r4-r7, lr} diff --git a/libavcodec/arm/vp3dsp_neon.S b/libavcodec/arm/vp3dsp_neon.S index c1a55cad2f..279b13225b 100644 --- a/libavcodec/arm/vp3dsp_neon.S +++ b/libavcodec/arm/vp3dsp_neon.S @@ -20,11 +20,9 @@ #include "asm.S" -.section .rodata -.align 4 - -vp3_idct_constants: +const vp3_idct_constants, align=4 .short 64277, 60547, 54491, 46341, 36410, 25080, 12785 +endconst #define xC1S7 d0[0] #define xC2S6 d0[1] @@ -34,8 +32,6 @@ vp3_idct_constants: #define xC6S2 d1[1] #define xC7S1 d1[2] -.text - .macro vp3_loop_filter vsubl.u8 q3, d18, d17 vsubl.u8 q2, d16, d19 diff --git a/libavcodec/arm/vp8_armv6.S b/libavcodec/arm/vp8_armv6.S index 1d89c68909..594046d709 100644 --- a/libavcodec/arm/vp8_armv6.S +++ b/libavcodec/arm/vp8_armv6.S @@ -240,9 +240,9 @@ A orrcs r8, r8, r10, lsl r6 b 5b endfunc - .section .rodata -zigzag_scan: +const zigzag_scan .byte 0, 2, 8, 16 .byte 10, 4, 6, 12 .byte 18, 24, 26, 20 .byte 14, 22, 28, 30 +endconst From b695256eddf2b3608e6f8da4663d31dcf96612af Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 10 Jul 2011 16:17:55 +0100 Subject: [PATCH 425/780] configure: fix --cpu=host with gcc 4.6 The output from -v with gcc 4.6 has changed such that the search pattern matches too soon without making it more strict. Signed-off-by: Mans Rullgard --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index f5b4a5c767..02bcd0989c 100755 --- a/configure +++ b/configure @@ -2103,7 +2103,7 @@ if test "$cpu" = host; then gcc|llvm_gcc) check_native(){ $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return - sed -n "/$1=/{ + sed -n "/cc1.*$1=/{ s/.*$1=\\([^ ]*\\).*/\\1/ p q From fb464fca4486e77d689851d22abe5d08825f7c1d Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 10 Jul 2011 21:09:55 +0200 Subject: [PATCH 426/780] Match VA-API / VDPAU with zlib / bzlib build system documentation. --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 58b6abd65d..202fffa233 100755 --- a/configure +++ b/configure @@ -106,8 +106,8 @@ Configuration options: --disable-lpc disable LPC code --disable-mdct disable MDCT code --disable-rdft disable RDFT code - --enable-vaapi enable VAAPI code - --enable-vdpau enable VDPAU code + --enable-vaapi enable VAAPI code [autodetect] + --enable-vdpau enable VDPAU code [autodetect] --disable-dxva2 disable DXVA2 code --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary) --enable-hardcoded-tables use hardcoded tables instead of runtime generation From 3743ea1fe3761ddbf8bfaae31c6acbf59a8cdc0a Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 10 Jul 2011 21:11:37 +0200 Subject: [PATCH 427/780] Hint why SDL_Init() may have failed. --- ffplay.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ffplay.c b/ffplay.c index a8be6bea2d..40e0cc1ef4 100644 --- a/ffplay.c +++ b/ffplay.c @@ -3027,6 +3027,7 @@ int main(int argc, char **argv) #endif if (SDL_Init (flags)) { fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError()); + fprintf(stderr, "(Did you set the DISPLAY variable?)\n"); exit(1); } From 28e1c97916b026c8785f54ec591718379b251bbb Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 10 Jul 2011 20:26:25 +0100 Subject: [PATCH 428/780] build: rework rules for things in the tools dir Declaring tools associated with each library in their respective makefiles allows these tools to easily depend on the correct prerequisites and link against the libs they need. Signed-off-by: Mans Rullgard --- Makefile | 21 ++++++++------------- common.mak | 6 ++++++ libavfilter/Makefile | 2 ++ libavformat/Makefile | 1 + subdir.mak | 4 ++-- tests/Makefile | 3 --- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 9f7b4361d4..720936a604 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,8 @@ PROGS := $(PROGS-yes:%=%$(EXESUF)) OBJS = $(PROGS-yes:%=%.o) cmdutils.o TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64 HOSTPROGS := $(TESTTOOLS:%=tests/%) +TOOLS = qt-faststart trasher +TOOLS-$(CONFIG_ZLIB) += cws2fws BASENAMES = ffmpeg ffplay ffprobe ffserver ALLPROGS = $(BASENAMES:%=%$(EXESUF)) @@ -86,6 +88,11 @@ FF_DEP_LIBS := $(DEP_LIBS) all: $(FF_DEP_LIBS) $(PROGS) +$(TOOLS): %$(EXESUF): %.o + $(LD) $(LDFLAGS) -o $@ $< $(ELIBS) + +tools/cws2fws$(EXESUF): ELIBS = -lz + config.h: .config .config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) @-tput bold 2>/dev/null @@ -94,7 +101,7 @@ config.h: .config SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \ ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \ - HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS + HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS TOOLS define RESET $(1) := @@ -116,18 +123,6 @@ ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS) $(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS) $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS) -TOOLS = cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher -TOOLOBJS := $(TOOLS:%=tools/%.o) -TOOLS := $(TOOLS:%=tools/%$(EXESUF)) - -alltools: $(TOOLS) - -tools/%$(EXESUF): tools/%.o - $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) - -$(TOOLOBJS): %.o: %.c | tools - $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $< - OBJDIRS += tools -include $(wildcard tools/*.d) diff --git a/common.mak b/common.mak index bd210462b9..da51495a16 100644 --- a/common.mak +++ b/common.mak @@ -20,6 +20,9 @@ TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o) TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF)) HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o) HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF)) +TOOLS += $(TOOLS-yes) +TOOLOBJS := $(TOOLS:%=tools/%.o) +TOOLS := $(TOOLS:%=tools/%$(EXESUF)) DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME)) @@ -28,6 +31,8 @@ SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-) SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%) checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho)) +alltools: $(TOOLS) + $(HOSTOBJS): %.o: %.c $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $< @@ -37,6 +42,7 @@ $(HOSTPROGS): %$(HOSTEXESUF): %.o $(OBJS): | $(dir $(OBJS)) $(HOSTOBJS): | $(dir $(HOSTOBJS)) $(TESTOBJS): | $(dir $(TESTOBJS)) +$(TOOLOBJS): | tools OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS)) diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 02016076bf..1a6fd9b68f 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -62,4 +62,6 @@ OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o DIRS = x86 +TOOLS = graph2dot lavfi-showfiltfmts + include $(SRC_PATH)/subdir.mak diff --git a/libavformat/Makefile b/libavformat/Makefile index a20db26b03..ca337e0167 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -335,6 +335,7 @@ OBJS-$(CONFIG_JACK_INDEV) += timefilter.o EXAMPLES = metadata output TESTPROGS = timefilter +TOOLS = pktdumper probetest include $(SRC_PATH)/subdir.mak diff --git a/subdir.mak b/subdir.mak index 3a38dafe63..a88955bdfb 100644 --- a/subdir.mak +++ b/subdir.mak @@ -34,7 +34,7 @@ install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared define RULES -$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o +$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $$(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS) $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR) @@ -91,7 +91,7 @@ endef $(eval $(RULES)) -$(EXAMPLES) $(TESTPROGS): $(THIS_LIB) $(DEP_LIBS) +$(EXAMPLES) $(TESTPROGS) $(TOOLS): $(THIS_LIB) $(DEP_LIBS) examples: $(EXAMPLES) testprogs: $(TESTPROGS) diff --git a/tests/Makefile b/tests/Makefile index 431a404219..501a72f879 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -31,9 +31,6 @@ tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS) $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) -tools/lavfi-showfiltfmts$(EXESUF): tools/lavfi-showfiltfmts.o $(FF_DEP_LIBS) - $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) - include $(SRC_PATH)/tests/fate.mak include $(SRC_PATH)/tests/fate2.mak From 3e5cce81e77fae6af91fcf8de11dafe9c8b1744d Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 10 Jul 2011 21:05:45 +0200 Subject: [PATCH 429/780] build: remove duplicates from order-only directory prerequisite list This reduces startup latency for make invocations, which is especially noticeable on systems that are slow or have slow I/O, like Windows. --- common.mak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common.mak b/common.mak index da51495a16..8a2aa7cf0d 100644 --- a/common.mak +++ b/common.mak @@ -39,9 +39,9 @@ $(HOSTOBJS): %.o: %.c $(HOSTPROGS): %$(HOSTEXESUF): %.o $(HOSTCC) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS) -$(OBJS): | $(dir $(OBJS)) -$(HOSTOBJS): | $(dir $(HOSTOBJS)) -$(TESTOBJS): | $(dir $(TESTOBJS)) +$(OBJS): | $(sort $(dir $(OBJS))) +$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS))) +$(TESTOBJS): | $(sort $(dir $(TESTOBJS))) $(TOOLOBJS): | tools OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS)) From fdb94444beb9c32beb8cfc70656f5115d9eec58b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 10 Jul 2011 20:48:23 +0100 Subject: [PATCH 430/780] matroskadec: fix stupid typo (!= -> ==) Signed-off-by: Mans Rullgard --- libavformat/matroskadec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index e1e555df80..70bb765ab4 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1200,7 +1200,7 @@ static void matroska_parse_cues(MatroskaDemuxContext *matroska) { int i, j; for (i = 0; i < seekhead_list->nb_elem; i++) - if (seekhead[i].id != MATROSKA_ID_CUES) + if (seekhead[i].id == MATROSKA_ID_CUES) break; assert(i <= seekhead_list->nb_elem); From 142e76f1055de5dde44696e71a5f63f2cb11dedf Mon Sep 17 00:00:00 2001 From: Anton Mitrofanov Date: Sun, 10 Jul 2011 20:07:43 +0400 Subject: [PATCH 431/780] swscale: fix crash with dithering due incorrect offset calculation. ptrdiff_t can be 4 bytes, which leads to the next element being 4-byte aligned and thus at a different offset than intended. Forcing 8-byte alignment forces equal offset of dither16/32 on x86-32 and x86-64. Signed-off-by: Ronald S. Bultje --- libswscale/swscale_internal.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index b602541044..9492303301 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -345,10 +345,13 @@ typedef struct SwsContext { DECLARE_ALIGNED(8, uint64_t, v_temp); DECLARE_ALIGNED(8, uint64_t, y_temp); int32_t alpMmxFilter[4*MAX_FILTER_SIZE]; + // alignment of these values is not necessary, but merely here + // to maintain the same offset across x8632 and x86-64. Once we + // use proper offset macros in the asm, they can be removed. DECLARE_ALIGNED(8, ptrdiff_t, uv_off_px); ///< offset (in pixels) between u and v planes DECLARE_ALIGNED(8, ptrdiff_t, uv_off_byte); ///< offset (in bytes) between u and v planes - uint16_t dither16[8]; - uint32_t dither32[8]; + DECLARE_ALIGNED(8, uint16_t, dither16)[8]; + DECLARE_ALIGNED(8, uint32_t, dither32)[8]; const uint8_t *chrDither8, *lumDither8; From 657ccb5ac75ce34e62bd67f228d9bd36db72189e Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 6 Jul 2011 20:08:30 +0200 Subject: [PATCH 432/780] Eliminate FF_COMMON_FRAME macro. FF_COMMON_FRAME holds the contents of the AVFrame structure and is also copied to struct Picture. Replace by an embedded AVFrame structure in struct Picture. --- libavcodec/avcodec.h | 527 +++++++++++++++++----------------- libavcodec/cavs.c | 24 +- libavcodec/cavsdec.c | 16 +- libavcodec/error_resilience.c | 176 ++++++------ libavcodec/h261dec.c | 14 +- libavcodec/h263.c | 48 ++-- libavcodec/h263dec.c | 6 +- libavcodec/h264.c | 184 ++++++------ libavcodec/h264.h | 37 +-- libavcodec/h264_cabac.c | 22 +- libavcodec/h264_cavlc.c | 8 +- libavcodec/h264_direct.c | 50 ++-- libavcodec/h264_loopfilter.c | 34 +-- libavcodec/h264_mvpred.h | 10 +- libavcodec/h264_refs.c | 52 ++-- libavcodec/intrax8.c | 24 +- libavcodec/ituh263dec.c | 28 +- libavcodec/ituh263enc.c | 6 +- libavcodec/motion_est.c | 149 +++++----- libavcodec/mpeg12.c | 50 ++-- libavcodec/mpeg12enc.c | 8 +- libavcodec/mpeg4video.c | 8 +- libavcodec/mpeg4videodec.c | 83 +++--- libavcodec/mpeg4videoenc.c | 25 +- libavcodec/mpegvideo.c | 211 +++++++------- libavcodec/mpegvideo.h | 3 +- libavcodec/mpegvideo_common.h | 32 +-- libavcodec/mpegvideo_enc.c | 172 +++++------ libavcodec/msmpeg4.c | 6 +- libavcodec/ratecontrol.c | 10 +- libavcodec/rv30.c | 18 +- libavcodec/rv34.c | 132 ++++----- libavcodec/rv40.c | 10 +- libavcodec/snow.c | 22 +- libavcodec/svq1dec.c | 6 +- libavcodec/svq1enc.c | 14 +- libavcodec/svq3.c | 44 +-- libavcodec/vc1dec.c | 224 +++++++-------- libavcodec/wmv2dec.c | 12 +- 39 files changed, 1257 insertions(+), 1248 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ba6342a09e..2d4515519a 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -741,266 +741,6 @@ typedef struct AVPanScan{ int16_t position[3][2]; }AVPanScan; -#define FF_COMMON_FRAME \ - /**\ - * pointer to the picture planes.\ - * This might be different from the first allocated byte\ - * - encoding: \ - * - decoding: \ - */\ - uint8_t *data[4];\ - int linesize[4];\ - /**\ - * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\ - * This isn't used by libavcodec unless the default get/release_buffer() is used.\ - * - encoding: \ - * - decoding: \ - */\ - uint8_t *base[4];\ - /**\ - * 1 -> keyframe, 0-> not\ - * - encoding: Set by libavcodec.\ - * - decoding: Set by libavcodec.\ - */\ - int key_frame;\ -\ - /**\ - * Picture type of the frame, see ?_TYPE below.\ - * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\ - * - decoding: Set by libavcodec.\ - */\ - enum AVPictureType pict_type;\ -\ - /**\ - * presentation timestamp in time_base units (time when frame should be shown to user)\ - * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.\ - * - encoding: MUST be set by user.\ - * - decoding: Set by libavcodec.\ - */\ - int64_t pts;\ -\ - /**\ - * picture number in bitstream order\ - * - encoding: set by\ - * - decoding: Set by libavcodec.\ - */\ - int coded_picture_number;\ - /**\ - * picture number in display order\ - * - encoding: set by\ - * - decoding: Set by libavcodec.\ - */\ - int display_picture_number;\ -\ - /**\ - * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \ - * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\ - * - decoding: Set by libavcodec.\ - */\ - int quality; \ -\ - /**\ - * buffer age (1->was last buffer and dint change, 2->..., ...).\ - * Set to INT_MAX if the buffer has not been used yet.\ - * - encoding: unused\ - * - decoding: MUST be set by get_buffer().\ - */\ - int age;\ -\ - /**\ - * is this picture used as reference\ - * The values for this are the same as the MpegEncContext.picture_structure\ - * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.\ - * Set to 4 for delayed, non-reference frames.\ - * - encoding: unused\ - * - decoding: Set by libavcodec. (before get_buffer() call)).\ - */\ - int reference;\ -\ - /**\ - * QP table\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - int8_t *qscale_table;\ - /**\ - * QP store stride\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - int qstride;\ -\ - /**\ - * mbskip_table[mb]>=1 if MB didn't change\ - * stride= mb_width = (width+15)>>4\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - uint8_t *mbskip_table;\ -\ - /**\ - * motion vector table\ - * @code\ - * example:\ - * int mv_sample_log2= 4 - motion_subsample_log2;\ - * int mb_width= (width+15)>>4;\ - * int mv_stride= (mb_width << mv_sample_log2) + 1;\ - * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\ - * @endcode\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec.\ - */\ - int16_t (*motion_val[2])[2];\ -\ - /**\ - * macroblock type table\ - * mb_type_base + mb_width + 2\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec.\ - */\ - uint32_t *mb_type;\ -\ - /**\ - * log2 of the size of the block which a single vector in motion_val represents: \ - * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - uint8_t motion_subsample_log2;\ -\ - /**\ - * for some private data of the user\ - * - encoding: unused\ - * - decoding: Set by user.\ - */\ - void *opaque;\ -\ - /**\ - * error\ - * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.\ - * - decoding: unused\ - */\ - uint64_t error[4];\ -\ - /**\ - * type of the buffer (to keep track of who has to deallocate data[*])\ - * - encoding: Set by the one who allocates it.\ - * - decoding: Set by the one who allocates it.\ - * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.\ - */\ - int type;\ - \ - /**\ - * When decoding, this signals how much the picture must be delayed.\ - * extra_delay = repeat_pict / (2*fps)\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - int repeat_pict;\ - \ - /**\ - * \ - */\ - int qscale_type;\ - \ - /**\ - * The content of the picture is interlaced.\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec. (default 0)\ - */\ - int interlaced_frame;\ - \ - /**\ - * If the content is interlaced, is top field displayed first.\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec.\ - */\ - int top_field_first;\ - \ - /**\ - * Pan scan.\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec.\ - */\ - AVPanScan *pan_scan;\ - \ - /**\ - * Tell user application that palette has changed from previous frame.\ - * - encoding: ??? (no palette-enabled encoder yet)\ - * - decoding: Set by libavcodec. (default 0).\ - */\ - int palette_has_changed;\ - \ - /**\ - * codec suggestion on buffer type if != 0\ - * - encoding: unused\ - * - decoding: Set by libavcodec. (before get_buffer() call)).\ - */\ - int buffer_hints;\ -\ - /**\ - * DCT coefficients\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - short *dct_coeff;\ -\ - /**\ - * motion reference frame index\ - * the order in which these are stored can depend on the codec.\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec.\ - */\ - int8_t *ref_index[2];\ -\ - /**\ - * reordered opaque 64bit (generally an integer or a double precision float\ - * PTS but can be anything). \ - * The user sets AVCodecContext.reordered_opaque to represent the input at\ - * that time,\ - * the decoder reorders values as needed and sets AVFrame.reordered_opaque\ - * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque \ - * @deprecated in favor of pkt_pts\ - * - encoding: unused\ - * - decoding: Read by user.\ - */\ - int64_t reordered_opaque;\ -\ - /**\ - * hardware accelerator private data (Libav-allocated)\ - * - encoding: unused\ - * - decoding: Set by libavcodec\ - */\ - void *hwaccel_picture_private;\ -\ - /**\ - * reordered pts from the last AVPacket that has been input into the decoder\ - * - encoding: unused\ - * - decoding: Read by user.\ - */\ - int64_t pkt_pts;\ -\ - /**\ - * dts from the last AVPacket that has been input into the decoder\ - * - encoding: unused\ - * - decoding: Read by user.\ - */\ - int64_t pkt_dts;\ -\ - /**\ - * the AVCodecContext which ff_thread_get_buffer() was last called on\ - * - encoding: Set by libavcodec.\ - * - decoding: Set by libavcodec.\ - */\ - struct AVCodecContext *owner;\ -\ - /**\ - * used by multithreading to store frame-specific info\ - * - encoding: Set by libavcodec.\ - * - decoding: Set by libavcodec.\ - */\ - void *thread_opaque;\ - #define FF_QSCALE_TYPE_MPEG1 0 #define FF_QSCALE_TYPE_MPEG2 1 #define FF_QSCALE_TYPE_H264 2 @@ -1095,15 +835,270 @@ typedef struct AVPacket { /** * Audio Video Frame. - * New fields can be added to the end of FF_COMMON_FRAME with minor version - * bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. No fields should be added into AVFrame before or after - * FF_COMMON_FRAME! + * New fields can be added to the end of AVFRAME with minor version + * bumps. Removal, reordering and changes to existing fields require + * a major version bump. * sizeof(AVFrame) must not be used outside libav*. */ typedef struct AVFrame { - FF_COMMON_FRAME + /** + * pointer to the picture planes. + * This might be different from the first allocated byte + * - encoding: + * - decoding: + */ + uint8_t *data[4]; + int linesize[4]; + /** + * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer. + * This isn't used by libavcodec unless the default get/release_buffer() is used. + * - encoding: + * - decoding: + */ + uint8_t *base[4]; + /** + * 1 -> keyframe, 0-> not + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int key_frame; + + /** + * Picture type of the frame, see ?_TYPE below. + * - encoding: Set by libavcodec. for coded_picture (and set by user for input). + * - decoding: Set by libavcodec. + */ + enum AVPictureType pict_type; + + /** + * presentation timestamp in time_base units (time when frame should be shown to user) + * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + */ + int64_t pts; + + /** + * picture number in bitstream order + * - encoding: set by + * - decoding: Set by libavcodec. + */ + int coded_picture_number; + /** + * picture number in display order + * - encoding: set by + * - decoding: Set by libavcodec. + */ + int display_picture_number; + + /** + * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) + * - encoding: Set by libavcodec. for coded_picture (and set by user for input). + * - decoding: Set by libavcodec. + */ + int quality; + + /** + * buffer age (1->was last buffer and dint change, 2->..., ...). + * Set to INT_MAX if the buffer has not been used yet. + * - encoding: unused + * - decoding: MUST be set by get_buffer(). + */ + int age; + + /** + * is this picture used as reference + * The values for this are the same as the MpegEncContext.picture_structure + * variable, that is 1->top field, 2->bottom field, 3->frame/both fields. + * Set to 4 for delayed, non-reference frames. + * - encoding: unused + * - decoding: Set by libavcodec. (before get_buffer() call)). + */ + int reference; + + /** + * QP table + * - encoding: unused + * - decoding: Set by libavcodec. + */ + int8_t *qscale_table; + /** + * QP store stride + * - encoding: unused + * - decoding: Set by libavcodec. + */ + int qstride; + + /** + * mbskip_table[mb]>=1 if MB didn't change + * stride= mb_width = (width+15)>>4 + * - encoding: unused + * - decoding: Set by libavcodec. + */ + uint8_t *mbskip_table; + + /** + * motion vector table + * @code + * example: + * int mv_sample_log2= 4 - motion_subsample_log2; + * int mb_width= (width+15)>>4; + * int mv_stride= (mb_width << mv_sample_log2) + 1; + * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y]; + * @endcode + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int16_t (*motion_val[2])[2]; + + /** + * macroblock type table + * mb_type_base + mb_width + 2 + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + uint32_t *mb_type; + + /** + * log2 of the size of the block which a single vector in motion_val represents: + * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2) + * - encoding: unused + * - decoding: Set by libavcodec. + */ + uint8_t motion_subsample_log2; + + /** + * for some private data of the user + * - encoding: unused + * - decoding: Set by user. + */ + void *opaque; + + /** + * error + * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR. + * - decoding: unused + */ + uint64_t error[4]; + + /** + * type of the buffer (to keep track of who has to deallocate data[*]) + * - encoding: Set by the one who allocates it. + * - decoding: Set by the one who allocates it. + * Note: User allocated (direct rendering) & internal buffers cannot coexist currently. + */ + int type; + + /** + * When decoding, this signals how much the picture must be delayed. + * extra_delay = repeat_pict / (2*fps) + * - encoding: unused + * - decoding: Set by libavcodec. + */ + int repeat_pict; + + /** + * + */ + int qscale_type; + + /** + * The content of the picture is interlaced. + * - encoding: Set by user. + * - decoding: Set by libavcodec. (default 0) + */ + int interlaced_frame; + + /** + * If the content is interlaced, is top field displayed first. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int top_field_first; + + /** + * Pan scan. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + AVPanScan *pan_scan; + + /** + * Tell user application that palette has changed from previous frame. + * - encoding: ??? (no palette-enabled encoder yet) + * - decoding: Set by libavcodec. (default 0). + */ + int palette_has_changed; + + /** + * codec suggestion on buffer type if != 0 + * - encoding: unused + * - decoding: Set by libavcodec. (before get_buffer() call)). + */ + int buffer_hints; + + /** + * DCT coefficients + * - encoding: unused + * - decoding: Set by libavcodec. + */ + short *dct_coeff; + + /** + * motion reference frame index + * the order in which these are stored can depend on the codec. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int8_t *ref_index[2]; + + /** + * reordered opaque 64bit (generally an integer or a double precision float + * PTS but can be anything). + * The user sets AVCodecContext.reordered_opaque to represent the input at + * that time, + * the decoder reorders values as needed and sets AVFrame.reordered_opaque + * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque + * @deprecated in favor of pkt_pts + * - encoding: unused + * - decoding: Read by user. + */ + int64_t reordered_opaque; + + /** + * hardware accelerator private data (Libav-allocated) + * - encoding: unused + * - decoding: Set by libavcodec + */ + void *hwaccel_picture_private; + + /** + * reordered pts from the last AVPacket that has been input into the decoder + * - encoding: unused + * - decoding: Read by user. + */ + int64_t pkt_pts; + + /** + * dts from the last AVPacket that has been input into the decoder + * - encoding: unused + * - decoding: Read by user. + */ + int64_t pkt_dts; + + /** + * the AVCodecContext which ff_thread_get_buffer() was last called on + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + struct AVCodecContext *owner; + + /** + * used by multithreading to store frame-specific info + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + void *thread_opaque; } AVFrame; /** diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index 9a73e2a54b..6f63c23628 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -333,9 +333,9 @@ static inline void mc_dir_part(AVSContext *h,Picture *pic,int square, const int mx= mv->x + src_x_offset*8; const int my= mv->y + src_y_offset*8; const int luma_xy= (mx&3) + ((my&3)<<2); - uint8_t * src_y = pic->data[0] + (mx>>2) + (my>>2)*h->l_stride; - uint8_t * src_cb= pic->data[1] + (mx>>3) + (my>>3)*h->c_stride; - uint8_t * src_cr= pic->data[2] + (mx>>3) + (my>>3)*h->c_stride; + uint8_t * src_y = pic->f.data[0] + (mx >> 2) + (my >> 2) * h->l_stride; + uint8_t * src_cb = pic->f.data[1] + (mx >> 3) + (my >> 3) * h->c_stride; + uint8_t * src_cr = pic->f.data[2] + (mx >> 3) + (my >> 3) * h->c_stride; int extra_width= 0; //(s->flags&CODEC_FLAG_EMU_EDGE) ? 0 : 16; int extra_height= extra_width; int emu=0; @@ -344,7 +344,7 @@ static inline void mc_dir_part(AVSContext *h,Picture *pic,int square, const int pic_width = 16*h->mb_width; const int pic_height = 16*h->mb_height; - if(!pic->data[0]) + if(!pic->f.data[0]) return; if(mx&7) extra_width -= 3; if(my&7) extra_height -= 3; @@ -602,9 +602,9 @@ int ff_cavs_next_mb(AVSContext *h) { h->mbx = 0; h->mby++; /* re-calculate sample pointers */ - h->cy = h->picture.data[0] + h->mby*16*h->l_stride; - h->cu = h->picture.data[1] + h->mby*8*h->c_stride; - h->cv = h->picture.data[2] + h->mby*8*h->c_stride; + h->cy = h->picture.f.data[0] + h->mby * 16 * h->l_stride; + h->cu = h->picture.f.data[1] + h->mby * 8 * h->c_stride; + h->cv = h->picture.f.data[2] + h->mby * 8 * h->c_stride; if(h->mby == h->mb_height) { //frame end return 0; } @@ -629,11 +629,11 @@ void ff_cavs_init_pic(AVSContext *h) { h->mv[MV_FWD_X0] = ff_cavs_dir_mv; set_mvs(&h->mv[MV_FWD_X0], BLK_16X16); h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL; - h->cy = h->picture.data[0]; - h->cu = h->picture.data[1]; - h->cv = h->picture.data[2]; - h->l_stride = h->picture.linesize[0]; - h->c_stride = h->picture.linesize[1]; + h->cy = h->picture.f.data[0]; + h->cu = h->picture.f.data[1]; + h->cv = h->picture.f.data[2]; + h->l_stride = h->picture.f.linesize[0]; + h->c_stride = h->picture.f.linesize[1]; h->luma_scan[2] = 8*h->l_stride; h->luma_scan[3] = 8*h->l_stride+8; h->mbx = h->mby = h->mbidx = 0; diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index a9e4d37c2a..b2e221d627 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -476,8 +476,8 @@ static int decode_pic(AVSContext *h) { return -1; } /* make sure we have the reference frames we need */ - if(!h->DPB[0].data[0] || - (!h->DPB[1].data[0] && h->pic_type == AV_PICTURE_TYPE_B)) + if(!h->DPB[0].f.data[0] || + (!h->DPB[1].f.data[0] && h->pic_type == AV_PICTURE_TYPE_B)) return -1; } else { h->pic_type = AV_PICTURE_TYPE_I; @@ -494,7 +494,7 @@ static int decode_pic(AVSContext *h) { skip_bits(&s->gb,1); //marker_bit } /* release last B frame */ - if(h->picture.data[0]) + if(h->picture.f.data[0]) s->avctx->release_buffer(s->avctx, (AVFrame *)&h->picture); s->avctx->get_buffer(s->avctx, (AVFrame *)&h->picture); @@ -585,7 +585,7 @@ static int decode_pic(AVSContext *h) { } while(ff_cavs_next_mb(h)); } if(h->pic_type != AV_PICTURE_TYPE_B) { - if(h->DPB[1].data[0]) + if(h->DPB[1].f.data[0]) s->avctx->release_buffer(s->avctx, (AVFrame *)&h->DPB[1]); h->DPB[1] = h->DPB[0]; h->DPB[0] = h->picture; @@ -648,7 +648,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size, s->avctx = avctx; if (buf_size == 0) { - if(!s->low_delay && h->DPB[0].data[0]) { + if (!s->low_delay && h->DPB[0].f.data[0]) { *data_size = sizeof(AVPicture); *picture = *(AVFrame *) &h->DPB[0]; } @@ -669,9 +669,9 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size, break; case PIC_I_START_CODE: if(!h->got_keyframe) { - if(h->DPB[0].data[0]) + if(h->DPB[0].f.data[0]) avctx->release_buffer(avctx, (AVFrame *)&h->DPB[0]); - if(h->DPB[1].data[0]) + if(h->DPB[1].f.data[0]) avctx->release_buffer(avctx, (AVFrame *)&h->DPB[1]); h->got_keyframe = 1; } @@ -685,7 +685,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size, break; *data_size = sizeof(AVPicture); if(h->pic_type != AV_PICTURE_TYPE_B) { - if(h->DPB[1].data[0]) { + if(h->DPB[1].f.data[0]) { *picture = *(AVFrame *) &h->DPB[1]; } else { *data_size = 0; diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index 8906b49c80..11e2636242 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -41,9 +41,9 @@ #undef mb_intra static void decode_mb(MpegEncContext *s, int ref){ - s->dest[0] = s->current_picture.data[0] + (s->mb_y * 16* s->linesize ) + s->mb_x * 16; - s->dest[1] = s->current_picture.data[1] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift); - s->dest[2] = s->current_picture.data[2] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift); + s->dest[0] = s->current_picture.f.data[0] + (s->mb_y * 16 * s->linesize) + s->mb_x * 16; + s->dest[1] = s->current_picture.f.data[1] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift); + s->dest[2] = s->current_picture.f.data[2] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift); if(CONFIG_H264_DECODER && s->codec_id == CODEC_ID_H264){ H264Context *h= (void*)s; @@ -52,7 +52,7 @@ static void decode_mb(MpegEncContext *s, int ref){ assert(ref>=0); if(ref >= h->ref_count[0]) //FIXME it is posible albeit uncommon that slice references differ between slices, we take the easy approuch and ignore it for now. If this turns out to have any relevance in practice then correct remapping should be added ref=0; - fill_rectangle(&s->current_picture.ref_index[0][4*h->mb_xy], 2, 2, 2, ref, 1); + fill_rectangle(&s->current_picture.f.ref_index[0][4*h->mb_xy], 2, 2, 2, ref, 1); fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1); fill_rectangle(h->mv_cache[0][ scan8[0] ], 4, 4, 8, pack16to32(s->mv[0][0][0],s->mv[0][0][1]), 4); assert(!FRAME_MBAFF); @@ -166,14 +166,14 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i error= s->error_status_table[mb_index]; - if(IS_INTER(s->current_picture.mb_type[mb_index])) continue; //inter + if(IS_INTER(s->current_picture.f.mb_type[mb_index])) continue; //inter if(!(error&DC_ERROR)) continue; //dc-ok /* right block */ for(j=b_x+1; j>is_luma) + (b_y>>is_luma)*s->mb_stride; int error_j= s->error_status_table[mb_index_j]; - int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]); + int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); if(intra_j==0 || !(error_j&DC_ERROR)){ color[0]= dc[j + b_y*stride]; distance[0]= j-b_x; @@ -185,7 +185,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i for(j=b_x-1; j>=0; j--){ int mb_index_j= (j>>is_luma) + (b_y>>is_luma)*s->mb_stride; int error_j= s->error_status_table[mb_index_j]; - int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]); + int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); if(intra_j==0 || !(error_j&DC_ERROR)){ color[1]= dc[j + b_y*stride]; distance[1]= b_x-j; @@ -197,7 +197,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i for(j=b_y+1; j>is_luma) + (j>>is_luma)*s->mb_stride; int error_j= s->error_status_table[mb_index_j]; - int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]); + int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); if(intra_j==0 || !(error_j&DC_ERROR)){ color[2]= dc[b_x + j*stride]; distance[2]= j-b_y; @@ -209,7 +209,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i for(j=b_y-1; j>=0; j--){ int mb_index_j= (b_x>>is_luma) + (j>>is_luma)*s->mb_stride; int error_j= s->error_status_table[mb_index_j]; - int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]); + int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); if(intra_j==0 || !(error_j&DC_ERROR)){ color[3]= dc[b_x + j*stride]; distance[3]= b_y-j; @@ -248,13 +248,13 @@ static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int st int y; int left_status = s->error_status_table[( b_x >>is_luma) + (b_y>>is_luma)*s->mb_stride]; int right_status= s->error_status_table[((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride]; - int left_intra= IS_INTRA(s->current_picture.mb_type [( b_x >>is_luma) + (b_y>>is_luma)*s->mb_stride]); - int right_intra= IS_INTRA(s->current_picture.mb_type [((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride]); + int left_intra = IS_INTRA(s->current_picture.f.mb_type[( b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride]); + int right_intra = IS_INTRA(s->current_picture.f.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride]); int left_damage = left_status&(DC_ERROR|AC_ERROR|MV_ERROR); int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR); int offset= b_x*8 + b_y*stride*8; - int16_t *left_mv= s->current_picture.motion_val[0][mvy_stride*b_y + mvx_stride* b_x ]; - int16_t *right_mv= s->current_picture.motion_val[0][mvy_stride*b_y + mvx_stride*(b_x+1)]; + int16_t *left_mv= s->current_picture.f.motion_val[0][mvy_stride*b_y + mvx_stride* b_x ]; + int16_t *right_mv= s->current_picture.f.motion_val[0][mvy_stride*b_y + mvx_stride*(b_x+1)]; if(!(left_damage||right_damage)) continue; // both undamaged @@ -311,13 +311,13 @@ static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int st int x; int top_status = s->error_status_table[(b_x>>is_luma) + ( b_y >>is_luma)*s->mb_stride]; int bottom_status= s->error_status_table[(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride]; - int top_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ( b_y >>is_luma)*s->mb_stride]); - int bottom_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride]); + int top_intra = IS_INTRA(s->current_picture.f.mb_type[(b_x >> is_luma) + ( b_y >> is_luma) * s->mb_stride]); + int bottom_intra = IS_INTRA(s->current_picture.f.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]); int top_damage = top_status&(DC_ERROR|AC_ERROR|MV_ERROR); int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR); int offset= b_x*8 + b_y*stride*8; - int16_t *top_mv= s->current_picture.motion_val[0][mvy_stride* b_y + mvx_stride*b_x]; - int16_t *bottom_mv= s->current_picture.motion_val[0][mvy_stride*(b_y+1) + mvx_stride*b_x]; + int16_t *top_mv = s->current_picture.f.motion_val[0][mvy_stride * b_y + mvx_stride * b_x]; + int16_t *bottom_mv = s->current_picture.f.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x]; if(!(top_damage||bottom_damage)) continue; // both undamaged @@ -376,7 +376,7 @@ static void guess_mv(MpegEncContext *s){ int f=0; int error= s->error_status_table[mb_xy]; - if(IS_INTRA(s->current_picture.mb_type[mb_xy])) f=MV_FROZEN; //intra //FIXME check + if(IS_INTRA(s->current_picture.f.mb_type[mb_xy])) f=MV_FROZEN; //intra //FIXME check if(!(error&MV_ERROR)) f=MV_FROZEN; //inter with undamaged MV fixed[mb_xy]= f; @@ -389,10 +389,10 @@ static void guess_mv(MpegEncContext *s){ for(mb_x=0; mb_xmb_width; mb_x++){ const int mb_xy= mb_x + mb_y*s->mb_stride; - if(IS_INTRA(s->current_picture.mb_type[mb_xy])) continue; + if(IS_INTRA(s->current_picture.f.mb_type[mb_xy])) continue; if(!(s->error_status_table[mb_xy]&MV_ERROR)) continue; - s->mv_dir = s->last_picture.data[0] ? MV_DIR_FORWARD : MV_DIR_BACKWARD; + s->mv_dir = s->last_picture.f.data[0] ? MV_DIR_FORWARD : MV_DIR_BACKWARD; s->mb_intra=0; s->mv_type = MV_TYPE_16X16; s->mb_skipped=0; @@ -434,8 +434,8 @@ int score_sum=0; if((mb_x^mb_y^pass)&1) continue; if(fixed[mb_xy]==MV_FROZEN) continue; - assert(!IS_INTRA(s->current_picture.mb_type[mb_xy])); - assert(s->last_picture_ptr && s->last_picture_ptr->data[0]); + assert(!IS_INTRA(s->current_picture.f.mb_type[mb_xy])); + assert(s->last_picture_ptr && s->last_picture_ptr->f.data[0]); j=0; if(mb_x>0 && fixed[mb_xy-1 ]==MV_FROZEN) j=1; @@ -454,27 +454,27 @@ int score_sum=0; none_left=0; if(mb_x>0 && fixed[mb_xy-1]){ - mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_step][0]; - mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_step][1]; - ref [pred_count] = s->current_picture.ref_index[0][4*(mb_xy-1)]; + mv_predictor[pred_count][0]= s->current_picture.f.motion_val[0][mot_index - mot_step][0]; + mv_predictor[pred_count][1]= s->current_picture.f.motion_val[0][mot_index - mot_step][1]; + ref [pred_count] = s->current_picture.f.ref_index[0][4*(mb_xy-1)]; pred_count++; } if(mb_x+1current_picture.motion_val[0][mot_index + mot_step][0]; - mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_step][1]; - ref [pred_count] = s->current_picture.ref_index[0][4*(mb_xy+1)]; + mv_predictor[pred_count][0]= s->current_picture.f.motion_val[0][mot_index + mot_step][0]; + mv_predictor[pred_count][1]= s->current_picture.f.motion_val[0][mot_index + mot_step][1]; + ref [pred_count] = s->current_picture.f.ref_index[0][4*(mb_xy+1)]; pred_count++; } if(mb_y>0 && fixed[mb_xy-mb_stride]){ - mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_stride*mot_step][0]; - mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_stride*mot_step][1]; - ref [pred_count] = s->current_picture.ref_index[0][4*(mb_xy-s->mb_stride)]; + mv_predictor[pred_count][0]= s->current_picture.f.motion_val[0][mot_index - mot_stride*mot_step][0]; + mv_predictor[pred_count][1]= s->current_picture.f.motion_val[0][mot_index - mot_stride*mot_step][1]; + ref [pred_count] = s->current_picture.f.ref_index[0][4*(mb_xy-s->mb_stride)]; pred_count++; } if(mb_y+1current_picture.motion_val[0][mot_index + mot_stride*mot_step][0]; - mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_stride*mot_step][1]; - ref [pred_count] = s->current_picture.ref_index[0][4*(mb_xy+s->mb_stride)]; + mv_predictor[pred_count][0]= s->current_picture.f.motion_val[0][mot_index + mot_stride*mot_step][0]; + mv_predictor[pred_count][1]= s->current_picture.f.motion_val[0][mot_index + mot_stride*mot_step][1]; + ref [pred_count] = s->current_picture.f.ref_index[0][4*(mb_xy+s->mb_stride)]; pred_count++; } if(pred_count==0) continue; @@ -534,16 +534,16 @@ skip_mean_and_median: ff_thread_await_progress((AVFrame *) s->last_picture_ptr, mb_y, 0); } - if (!s->last_picture.motion_val[0] || - !s->last_picture.ref_index[0]) + if (!s->last_picture.f.motion_val[0] || + !s->last_picture.f.ref_index[0]) goto skip_last_mv; - prev_x = s->last_picture.motion_val[0][mot_index][0]; - prev_y = s->last_picture.motion_val[0][mot_index][1]; - prev_ref = s->last_picture.ref_index[0][4*mb_xy]; + prev_x = s->last_picture.f.motion_val[0][mot_index][0]; + prev_y = s->last_picture.f.motion_val[0][mot_index][1]; + prev_ref = s->last_picture.f.ref_index[0][4*mb_xy]; } else { - prev_x = s->current_picture.motion_val[0][mot_index][0]; - prev_y = s->current_picture.motion_val[0][mot_index][1]; - prev_ref = s->current_picture.ref_index[0][4*mb_xy]; + prev_x = s->current_picture.f.motion_val[0][mot_index][0]; + prev_y = s->current_picture.f.motion_val[0][mot_index][1]; + prev_ref = s->current_picture.f.ref_index[0][4*mb_xy]; } /* last MV */ @@ -565,10 +565,10 @@ skip_mean_and_median: for(j=0; jcurrent_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; + uint8_t *src = s->current_picture.f.data[0] + mb_x*16 + mb_y*16*s->linesize; - s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0]; - s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1]; + s->current_picture.f.motion_val[0][mot_index][0] = s->mv[0][0][0] = mv_predictor[j][0]; + s->current_picture.f.motion_val[0][mot_index][1] = s->mv[0][0][1] = mv_predictor[j][1]; if(ref[j]<0) //predictor intra or otherwise not available continue; @@ -607,8 +607,8 @@ score_sum+= best_score; for(i=0; icurrent_picture.motion_val[0][mot_index+i+j*mot_stride][0]= s->mv[0][0][0]; - s->current_picture.motion_val[0][mot_index+i+j*mot_stride][1]= s->mv[0][0][1]; + s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0]; + s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1]; } decode_mb(s, ref[best_pred]); @@ -640,7 +640,7 @@ score_sum+= best_score; static int is_intra_more_likely(MpegEncContext *s){ int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y; - if(!s->last_picture_ptr || !s->last_picture_ptr->data[0]) return 1; //no previous frame available -> use spatial prediction + if (!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) return 1; //no previous frame available -> use spatial prediction undamaged_count=0; for(i=0; imb_num; i++){ @@ -652,7 +652,7 @@ static int is_intra_more_likely(MpegEncContext *s){ if(s->codec_id == CODEC_ID_H264){ H264Context *h= (void*)s; - if(h->ref_count[0] <= 0 || !h->ref_list[0][0].data[0]) + if (h->ref_count[0] <= 0 || !h->ref_list[0][0].f.data[0]) return 1; } @@ -679,8 +679,8 @@ static int is_intra_more_likely(MpegEncContext *s){ if((j%skip_amount) != 0) continue; //skip a few to speed things up if(s->pict_type==AV_PICTURE_TYPE_I){ - uint8_t *mb_ptr = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; - uint8_t *last_mb_ptr= s->last_picture.data [0] + mb_x*16 + mb_y*16*s->linesize; + uint8_t *mb_ptr = s->current_picture.f.data[0] + mb_x*16 + mb_y*16*s->linesize; + uint8_t *last_mb_ptr= s->last_picture.f.data [0] + mb_x*16 + mb_y*16*s->linesize; if (s->avctx->codec_id == CODEC_ID_H264) { // FIXME @@ -691,7 +691,7 @@ static int is_intra_more_likely(MpegEncContext *s){ is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16); is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16); }else{ - if(IS_INTRA(s->current_picture.mb_type[mb_xy])) + if (IS_INTRA(s->current_picture.f.mb_type[mb_xy])) is_intra_likely++; else is_intra_likely--; @@ -793,15 +793,15 @@ void ff_er_frame_end(MpegEncContext *s){ s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return; - if(s->current_picture.motion_val[0] == NULL){ + if (s->current_picture.f.motion_val[0] == NULL) { av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n"); for(i=0; i<2; i++){ - pic->ref_index[i]= av_mallocz(s->mb_stride * s->mb_height * 4 * sizeof(uint8_t)); + pic->f.ref_index[i] = av_mallocz(s->mb_stride * s->mb_height * 4 * sizeof(uint8_t)); pic->motion_val_base[i]= av_mallocz((size+4) * 2 * sizeof(uint16_t)); - pic->motion_val[i]= pic->motion_val_base[i]+4; + pic->f.motion_val[i] = pic->motion_val_base[i] + 4; } - pic->motion_subsample_log2= 3; + pic->f.motion_subsample_log2 = 3; s->current_picture= *s->current_picture_ptr; } @@ -951,25 +951,25 @@ void ff_er_frame_end(MpegEncContext *s){ continue; if(is_intra_likely) - s->current_picture.mb_type[mb_xy]= MB_TYPE_INTRA4x4; + s->current_picture.f.mb_type[mb_xy] = MB_TYPE_INTRA4x4; else - s->current_picture.mb_type[mb_xy]= MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0; } // change inter to intra blocks if no reference frames are available - if (!s->last_picture.data[0] && !s->next_picture.data[0]) + if (!s->last_picture.f.data[0] && !s->next_picture.f.data[0]) for(i=0; imb_num; i++){ const int mb_xy= s->mb_index2xy[i]; - if(!IS_INTRA(s->current_picture.mb_type[mb_xy])) - s->current_picture.mb_type[mb_xy]= MB_TYPE_INTRA4x4; + if (!IS_INTRA(s->current_picture.f.mb_type[mb_xy])) + s->current_picture.f.mb_type[mb_xy] = MB_TYPE_INTRA4x4; } /* handle inter blocks with damaged AC */ for(mb_y=0; mb_ymb_height; mb_y++){ for(mb_x=0; mb_xmb_width; mb_x++){ const int mb_xy= mb_x + mb_y * s->mb_stride; - const int mb_type= s->current_picture.mb_type[mb_xy]; - int dir = !s->last_picture.data[0]; + const int mb_type= s->current_picture.f.mb_type[mb_xy]; + int dir = !s->last_picture.f.data[0]; error= s->error_status_table[mb_xy]; if(IS_INTRA(mb_type)) continue; //intra @@ -984,13 +984,13 @@ void ff_er_frame_end(MpegEncContext *s){ int j; s->mv_type = MV_TYPE_8X8; for(j=0; j<4; j++){ - s->mv[0][j][0] = s->current_picture.motion_val[dir][ mb_index + (j&1) + (j>>1)*s->b8_stride ][0]; - s->mv[0][j][1] = s->current_picture.motion_val[dir][ mb_index + (j&1) + (j>>1)*s->b8_stride ][1]; + s->mv[0][j][0] = s->current_picture.f.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0]; + s->mv[0][j][1] = s->current_picture.f.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1]; } }else{ s->mv_type = MV_TYPE_16X16; - s->mv[0][0][0] = s->current_picture.motion_val[dir][ mb_x*2 + mb_y*2*s->b8_stride ][0]; - s->mv[0][0][1] = s->current_picture.motion_val[dir][ mb_x*2 + mb_y*2*s->b8_stride ][1]; + s->mv[0][0][0] = s->current_picture.f.motion_val[dir][ mb_x*2 + mb_y*2*s->b8_stride ][0]; + s->mv[0][0][1] = s->current_picture.f.motion_val[dir][ mb_x*2 + mb_y*2*s->b8_stride ][1]; } s->dsp.clear_blocks(s->block[0]); @@ -1007,7 +1007,7 @@ void ff_er_frame_end(MpegEncContext *s){ for(mb_x=0; mb_xmb_width; mb_x++){ int xy= mb_x*2 + mb_y*2*s->b8_stride; const int mb_xy= mb_x + mb_y * s->mb_stride; - const int mb_type= s->current_picture.mb_type[mb_xy]; + const int mb_type= s->current_picture.f.mb_type[mb_xy]; error= s->error_status_table[mb_xy]; if(IS_INTRA(mb_type)) continue; @@ -1015,8 +1015,8 @@ void ff_er_frame_end(MpegEncContext *s){ if(!(error&AC_ERROR)) continue; //undamaged inter s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD; - if(!s->last_picture.data[0]) s->mv_dir &= ~MV_DIR_FORWARD; - if(!s->next_picture.data[0]) s->mv_dir &= ~MV_DIR_BACKWARD; + if(!s->last_picture.f.data[0]) s->mv_dir &= ~MV_DIR_FORWARD; + if(!s->next_picture.f.data[0]) s->mv_dir &= ~MV_DIR_BACKWARD; s->mb_intra=0; s->mv_type = MV_TYPE_16X16; s->mb_skipped=0; @@ -1031,10 +1031,10 @@ void ff_er_frame_end(MpegEncContext *s){ ff_thread_await_progress((AVFrame *) s->next_picture_ptr, mb_y, 0); } - s->mv[0][0][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp; - s->mv[0][0][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp; - s->mv[1][0][0] = s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp; - s->mv[1][0][1] = s->next_picture.motion_val[0][xy][1]*(time_pb - time_pp)/time_pp; + s->mv[0][0][0] = s->next_picture.f.motion_val[0][xy][0] * time_pb / time_pp; + s->mv[0][0][1] = s->next_picture.f.motion_val[0][xy][1] * time_pb / time_pp; + s->mv[1][0][0] = s->next_picture.f.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp; + s->mv[1][0][1] = s->next_picture.f.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp; }else{ s->mv[0][0][0]= 0; s->mv[0][0][1]= 0; @@ -1061,16 +1061,16 @@ void ff_er_frame_end(MpegEncContext *s){ int16_t *dc_ptr; uint8_t *dest_y, *dest_cb, *dest_cr; const int mb_xy= mb_x + mb_y * s->mb_stride; - const int mb_type= s->current_picture.mb_type[mb_xy]; + const int mb_type = s->current_picture.f.mb_type[mb_xy]; error= s->error_status_table[mb_xy]; if(IS_INTRA(mb_type) && s->partitioned_frame) continue; // if(error&MV_ERROR) continue; //inter data damaged FIXME is this good? - dest_y = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; - dest_cb= s->current_picture.data[1] + mb_x*8 + mb_y*8 *s->uvlinesize; - dest_cr= s->current_picture.data[2] + mb_x*8 + mb_y*8 *s->uvlinesize; + dest_y = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize; + dest_cb = s->current_picture.f.data[1] + mb_x * 8 + mb_y * 8 * s->uvlinesize; + dest_cr = s->current_picture.f.data[2] + mb_x * 8 + mb_y * 8 * s->uvlinesize; dc_ptr= &s->dc_val[0][mb_x*2 + mb_y*2*s->b8_stride]; for(n=0; n<4; n++){ @@ -1110,16 +1110,16 @@ void ff_er_frame_end(MpegEncContext *s){ for(mb_x=0; mb_xmb_width; mb_x++){ uint8_t *dest_y, *dest_cb, *dest_cr; const int mb_xy= mb_x + mb_y * s->mb_stride; - const int mb_type= s->current_picture.mb_type[mb_xy]; + const int mb_type = s->current_picture.f.mb_type[mb_xy]; error= s->error_status_table[mb_xy]; if(IS_INTER(mb_type)) continue; if(!(error&AC_ERROR)) continue; //undamaged - dest_y = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; - dest_cb= s->current_picture.data[1] + mb_x*8 + mb_y*8 *s->uvlinesize; - dest_cr= s->current_picture.data[2] + mb_x*8 + mb_y*8 *s->uvlinesize; + dest_y = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize; + dest_cb = s->current_picture.f.data[1] + mb_x * 8 + mb_y * 8 * s->uvlinesize; + dest_cr = s->current_picture.f.data[2] + mb_x * 8 + mb_y * 8 * s->uvlinesize; put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y); } @@ -1127,14 +1127,14 @@ void ff_er_frame_end(MpegEncContext *s){ if(s->avctx->error_concealment&FF_EC_DEBLOCK){ /* filter horizontal block boundaries */ - h_block_filter(s, s->current_picture.data[0], s->mb_width*2, s->mb_height*2, s->linesize , 1); - h_block_filter(s, s->current_picture.data[1], s->mb_width , s->mb_height , s->uvlinesize, 0); - h_block_filter(s, s->current_picture.data[2], s->mb_width , s->mb_height , s->uvlinesize, 0); + h_block_filter(s, s->current_picture.f.data[0], s->mb_width*2, s->mb_height*2, s->linesize , 1); + h_block_filter(s, s->current_picture.f.data[1], s->mb_width , s->mb_height , s->uvlinesize, 0); + h_block_filter(s, s->current_picture.f.data[2], s->mb_width , s->mb_height , s->uvlinesize, 0); /* filter vertical block boundaries */ - v_block_filter(s, s->current_picture.data[0], s->mb_width*2, s->mb_height*2, s->linesize , 1); - v_block_filter(s, s->current_picture.data[1], s->mb_width , s->mb_height , s->uvlinesize, 0); - v_block_filter(s, s->current_picture.data[2], s->mb_width , s->mb_height , s->uvlinesize, 0); + v_block_filter(s, s->current_picture.f.data[0], s->mb_width*2, s->mb_height*2, s->linesize , 1); + v_block_filter(s, s->current_picture.f.data[1], s->mb_width , s->mb_height , s->uvlinesize, 0); + v_block_filter(s, s->current_picture.f.data[2], s->mb_width , s->mb_height , s->uvlinesize, 0); } ec_clean: diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index a335d68ff1..e6f5cdb7cf 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -215,7 +215,7 @@ static int h261_decode_mb_skipped(H261Context *h, int mba1, int mba2 ) s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; - s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mb_skipped = 1; @@ -323,14 +323,14 @@ static int h261_decode_mb(H261Context *h){ } if(s->mb_intra){ - s->current_picture.mb_type[xy]= MB_TYPE_INTRA; + s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA; goto intra; } //set motion vectors s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; - s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0; s->mv[0][0][0] = h->current_mv_x * 2;//gets divided by 2 in motion compensation s->mv[0][0][1] = h->current_mv_y * 2; @@ -464,7 +464,7 @@ static int h261_decode_picture_header(H261Context *h){ s->picture_number = (s->picture_number&~31) + i; s->avctx->time_base= (AVRational){1001, 30000}; - s->current_picture.pts= s->picture_number; + s->current_picture.f.pts = s->picture_number; /* PTYPE starts here */ @@ -570,7 +570,7 @@ retry: } //we need to set current_picture_ptr before reading the header, otherwise we cannot store anyting im there - if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ + if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) { int i= ff_find_unused_picture(s, 0); s->current_picture_ptr= &s->picture[i]; } @@ -596,8 +596,8 @@ retry: } // for skipping the frame - s->current_picture.pict_type= s->pict_type; - s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I; + s->current_picture.f.pict_type = s->pict_type; + s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B) ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I) diff --git a/libavcodec/h263.c b/libavcodec/h263.c index 5c25df2272..b3c93027ee 100644 --- a/libavcodec/h263.c +++ b/libavcodec/h263.c @@ -52,7 +52,7 @@ void ff_h263_update_motion_val(MpegEncContext * s){ const int wrap = s->b8_stride; const int xy = s->block_index[0]; - s->current_picture.mbskip_table[mb_xy]= s->mb_skipped; + s->current_picture.f.mbskip_table[mb_xy] = s->mb_skipped; if(s->mv_type != MV_TYPE_8X8){ int motion_x, motion_y; @@ -71,30 +71,30 @@ void ff_h263_update_motion_val(MpegEncContext * s){ s->p_field_mv_table[i][0][mb_xy][0]= s->mv[0][i][0]; s->p_field_mv_table[i][0][mb_xy][1]= s->mv[0][i][1]; } - s->current_picture.ref_index[0][4*mb_xy ]= - s->current_picture.ref_index[0][4*mb_xy + 1]= s->field_select[0][0]; - s->current_picture.ref_index[0][4*mb_xy + 2]= - s->current_picture.ref_index[0][4*mb_xy + 3]= s->field_select[0][1]; + s->current_picture.f.ref_index[0][4*mb_xy ] = + s->current_picture.f.ref_index[0][4*mb_xy + 1] = s->field_select[0][0]; + s->current_picture.f.ref_index[0][4*mb_xy + 2] = + s->current_picture.f.ref_index[0][4*mb_xy + 3] = s->field_select[0][1]; } /* no update if 8X8 because it has been done during parsing */ - s->current_picture.motion_val[0][xy][0] = motion_x; - s->current_picture.motion_val[0][xy][1] = motion_y; - s->current_picture.motion_val[0][xy + 1][0] = motion_x; - s->current_picture.motion_val[0][xy + 1][1] = motion_y; - s->current_picture.motion_val[0][xy + wrap][0] = motion_x; - s->current_picture.motion_val[0][xy + wrap][1] = motion_y; - s->current_picture.motion_val[0][xy + 1 + wrap][0] = motion_x; - s->current_picture.motion_val[0][xy + 1 + wrap][1] = motion_y; + s->current_picture.f.motion_val[0][xy][0] = motion_x; + s->current_picture.f.motion_val[0][xy][1] = motion_y; + s->current_picture.f.motion_val[0][xy + 1][0] = motion_x; + s->current_picture.f.motion_val[0][xy + 1][1] = motion_y; + s->current_picture.f.motion_val[0][xy + wrap][0] = motion_x; + s->current_picture.f.motion_val[0][xy + wrap][1] = motion_y; + s->current_picture.f.motion_val[0][xy + 1 + wrap][0] = motion_x; + s->current_picture.f.motion_val[0][xy + 1 + wrap][1] = motion_y; } if(s->encoding){ //FIXME encoding MUST be cleaned up if (s->mv_type == MV_TYPE_8X8) - s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_8x8; + s->current_picture.f.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_8x8; else if(s->mb_intra) - s->current_picture.mb_type[mb_xy]= MB_TYPE_INTRA; + s->current_picture.f.mb_type[mb_xy] = MB_TYPE_INTRA; else - s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_16x16; + s->current_picture.f.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_16x16; } } @@ -154,7 +154,7 @@ void ff_h263_loop_filter(MpegEncContext * s){ Diag Top Left Center */ - if(!IS_SKIP(s->current_picture.mb_type[xy])){ + if (!IS_SKIP(s->current_picture.f.mb_type[xy])) { qp_c= s->qscale; s->dsp.h263_v_loop_filter(dest_y+8*linesize , linesize, qp_c); s->dsp.h263_v_loop_filter(dest_y+8*linesize+8, linesize, qp_c); @@ -164,10 +164,10 @@ void ff_h263_loop_filter(MpegEncContext * s){ if(s->mb_y){ int qp_dt, qp_tt, qp_tc; - if(IS_SKIP(s->current_picture.mb_type[xy-s->mb_stride])) + if (IS_SKIP(s->current_picture.f.mb_type[xy - s->mb_stride])) qp_tt=0; else - qp_tt= s->current_picture.qscale_table[xy-s->mb_stride]; + qp_tt = s->current_picture.f.qscale_table[xy - s->mb_stride]; if(qp_c) qp_tc= qp_c; @@ -187,10 +187,10 @@ void ff_h263_loop_filter(MpegEncContext * s){ s->dsp.h263_h_loop_filter(dest_y-8*linesize+8 , linesize, qp_tt); if(s->mb_x){ - if(qp_tt || IS_SKIP(s->current_picture.mb_type[xy-1-s->mb_stride])) + if (qp_tt || IS_SKIP(s->current_picture.f.mb_type[xy - 1 - s->mb_stride])) qp_dt= qp_tt; else - qp_dt= s->current_picture.qscale_table[xy-1-s->mb_stride]; + qp_dt = s->current_picture.f.qscale_table[xy - 1 - s->mb_stride]; if(qp_dt){ const int chroma_qp= s->chroma_qscale_table[qp_dt]; @@ -209,10 +209,10 @@ void ff_h263_loop_filter(MpegEncContext * s){ if(s->mb_x){ int qp_lc; - if(qp_c || IS_SKIP(s->current_picture.mb_type[xy-1])) + if (qp_c || IS_SKIP(s->current_picture.f.mb_type[xy - 1])) qp_lc= qp_c; else - qp_lc= s->current_picture.qscale_table[xy-1]; + qp_lc = s->current_picture.f.qscale_table[xy - 1]; if(qp_lc){ s->dsp.h263_h_loop_filter(dest_y, linesize, qp_lc); @@ -321,7 +321,7 @@ int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir, static const int off[4]= {2, 1, 1, -1}; wrap = s->b8_stride; - mot_val = s->current_picture.motion_val[dir] + s->block_index[block]; + mot_val = s->current_picture.f.motion_val[dir] + s->block_index[block]; A = mot_val[ - 1]; /* special case for first (slice) line */ diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index bc6d613be4..6eea8def11 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -394,7 +394,7 @@ retry: /* We need to set current_picture_ptr before reading the header, * otherwise we cannot store anyting in there */ - if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ + if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) { int i= ff_find_unused_picture(s, 0); s->current_picture_ptr= &s->picture[i]; } @@ -581,8 +581,8 @@ retry: s->gob_index = ff_h263_get_gob_height(s); // for skipping the frame - s->current_picture.pict_type= s->pict_type; - s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I; + s->current_picture.f.pict_type = s->pict_type; + s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; /* skip B-frames if we don't have reference frames */ if(s->last_picture_ptr==NULL && (s->pict_type==AV_PICTURE_TYPE_B || s->dropable)) return get_consumed_bytes(s, buf_size); diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 33c9527946..cbeeb07425 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -261,8 +261,8 @@ static inline void get_lowest_part_y(H264Context *h, int refs[2][48], int n, int // Error resilience puts the current picture in the ref list. // Don't try to wait on these as it will cause a deadlock. // Fields can wait on each other, though. - if(ref->thread_opaque != s->current_picture.thread_opaque || - (ref->reference&3) != s->picture_structure) { + if (ref->f.thread_opaque != s->current_picture.f.thread_opaque || + (ref->f.reference & 3) != s->picture_structure) { my = get_lowest_part_list_y(h, ref, n, height, y_offset, 0); if (refs[0][ref_n] < 0) nrefs[0] += 1; refs[0][ref_n] = FFMAX(refs[0][ref_n], my); @@ -273,8 +273,8 @@ static inline void get_lowest_part_y(H264Context *h, int refs[2][48], int n, int int ref_n = h->ref_cache[1][ scan8[n] ]; Picture *ref= &h->ref_list[1][ref_n]; - if(ref->thread_opaque != s->current_picture.thread_opaque || - (ref->reference&3) != s->picture_structure) { + if (ref->f.thread_opaque != s->current_picture.f.thread_opaque || + (ref->f.reference & 3) != s->picture_structure) { my = get_lowest_part_list_y(h, ref, n, height, y_offset, 1); if (refs[1][ref_n] < 0) nrefs[1] += 1; refs[1][ref_n] = FFMAX(refs[1][ref_n], my); @@ -290,7 +290,7 @@ static inline void get_lowest_part_y(H264Context *h, int refs[2][48], int n, int static void await_references(H264Context *h){ MpegEncContext * const s = &h->s; const int mb_xy= h->mb_xy; - const int mb_type= s->current_picture.mb_type[mb_xy]; + const int mb_type = s->current_picture.f.mb_type[mb_xy]; int refs[2][48]; int nrefs[2] = {0}; int ref, list; @@ -350,7 +350,7 @@ static void await_references(H264Context *h){ int row = refs[list][ref]; if(row >= 0){ Picture *ref_pic = &h->ref_list[list][ref]; - int ref_field = ref_pic->reference - 1; + int ref_field = ref_pic->f.reference - 1; int ref_field_picture = ref_pic->field_picture; int pic_height = 16*s->mb_height >> ref_field_picture; @@ -448,7 +448,7 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int my= h->mv_cache[list][ scan8[n] ][1] + src_y_offset*8; const int luma_xy= (mx&3) + ((my&3)<<2); int offset = ((mx>>2) << pixel_shift) + (my>>2)*h->mb_linesize; - uint8_t * src_y = pic->data[0] + offset; + uint8_t * src_y = pic->f.data[0] + offset; uint8_t * src_cb, * src_cr; int extra_width= h->emu_edge_width; int extra_height= h->emu_edge_height; @@ -478,7 +478,7 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, if(CONFIG_GRAY && s->flags&CODEC_FLAG_GRAY) return; if(chroma444){ - src_cb = pic->data[1] + offset; + src_cb = pic->f.data[1] + offset; if(emu){ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb - (2 << pixel_shift) - 2*h->mb_linesize, h->mb_linesize, 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height); @@ -489,7 +489,7 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, qpix_op[luma_xy](dest_cb + delta, src_cb + delta, h->mb_linesize); } - src_cr = pic->data[2] + offset; + src_cr = pic->f.data[2] + offset; if(emu){ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cr - (2 << pixel_shift) - 2*h->mb_linesize, h->mb_linesize, 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height); @@ -504,11 +504,11 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, if(MB_FIELD){ // chroma offset when predicting from a field of opposite parity - my += 2 * ((s->mb_y & 1) - (pic->reference - 1)); + my += 2 * ((s->mb_y & 1) - (pic->f.reference - 1)); emu |= (my>>3) < 0 || (my>>3) + 8 >= (pic_height>>1); } - src_cb= pic->data[1] + ((mx>>3) << pixel_shift) + (my>>3)*h->mb_uvlinesize; - src_cr= pic->data[2] + ((mx>>3) << pixel_shift) + (my>>3)*h->mb_uvlinesize; + src_cb = pic->f.data[1] + ((mx >> 3) << pixel_shift) + (my >> 3) * h->mb_uvlinesize; + src_cr = pic->f.data[2] + ((mx >> 3) << pixel_shift) + (my >> 3) * h->mb_uvlinesize; if(emu){ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb, h->mb_uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); @@ -664,7 +664,7 @@ static inline void prefetch_motion(H264Context *h, int list, int pixel_shift, in if(refn >= 0){ const int mx= (h->mv_cache[list][scan8[0]][0]>>2) + 16*s->mb_x + 8; const int my= (h->mv_cache[list][scan8[0]][1]>>2) + 16*s->mb_y; - uint8_t **src= h->ref_list[list][refn].data; + uint8_t **src = h->ref_list[list][refn].f.data; int off= (mx << pixel_shift) + (my + (s->mb_x&3)*4)*h->mb_linesize + (64 << pixel_shift); s->dsp.prefetch(src[0]+off, s->linesize, 4); if(chroma444){ @@ -684,7 +684,7 @@ static av_always_inline void hl_motion(H264Context *h, uint8_t *dest_y, uint8_t int pixel_shift, int chroma444){ MpegEncContext * const s = &h->s; const int mb_xy= h->mb_xy; - const int mb_type= s->current_picture.mb_type[mb_xy]; + const int mb_type = s->current_picture.f.mb_type[mb_xy]; assert(IS_INTER(mb_type)); @@ -1220,7 +1220,7 @@ int ff_h264_frame_start(H264Context *h){ * Zero here; IDR markings per slice in frame or fields are ORed in later. * See decode_nal_units(). */ - s->current_picture_ptr->key_frame= 0; + s->current_picture_ptr->f.key_frame = 0; s->current_picture_ptr->mmco_reset= 0; assert(s->linesize && s->uvlinesize); @@ -1245,7 +1245,7 @@ int ff_h264_frame_start(H264Context *h){ /* some macroblocks can be accessed before they're available in case of lost slices, mbaff or threading*/ memset(h->slice_table, -1, (s->mb_height*s->mb_stride-1) * sizeof(*h->slice_table)); -// s->decode= (s->flags&CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.reference /*|| h->contains_intra*/ || 1; +// s->decode = (s->flags & CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.f.reference /*|| h->contains_intra*/ || 1; // We mark the current picture as non-reference after allocating it, so // that if we break out due to an error it can be released automatically @@ -1254,7 +1254,7 @@ int ff_h264_frame_start(H264Context *h){ // get released even with set reference, besides SVQ3 and others do not // mark frames as reference later "naturally". if(s->codec_id != CODEC_ID_SVQ3) - s->current_picture_ptr->reference= 0; + s->current_picture_ptr->f.reference = 0; s->current_picture_ptr->field_poc[0]= s->current_picture_ptr->field_poc[1]= INT_MAX; @@ -1280,8 +1280,8 @@ static void decode_postinit(H264Context *h, int setup_finished){ Picture *cur = s->current_picture_ptr; int i, pics, out_of_order, out_idx; - s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264; - s->current_picture_ptr->pict_type= s->pict_type; + s->current_picture_ptr->f.qscale_type = FF_QSCALE_TYPE_H264; + s->current_picture_ptr->f.pict_type = s->pict_type; if (h->next_output_pic) return; @@ -1294,8 +1294,8 @@ static void decode_postinit(H264Context *h, int setup_finished){ return; } - cur->interlaced_frame = 0; - cur->repeat_pict = 0; + cur->f.interlaced_frame = 0; + cur->f.repeat_pict = 0; /* Signal interlacing information externally. */ /* Prioritize picture timing SEI information over used decoding process if it exists. */ @@ -1307,53 +1307,53 @@ static void decode_postinit(H264Context *h, int setup_finished){ break; case SEI_PIC_STRUCT_TOP_FIELD: case SEI_PIC_STRUCT_BOTTOM_FIELD: - cur->interlaced_frame = 1; + cur->f.interlaced_frame = 1; break; case SEI_PIC_STRUCT_TOP_BOTTOM: case SEI_PIC_STRUCT_BOTTOM_TOP: if (FIELD_OR_MBAFF_PICTURE) - cur->interlaced_frame = 1; + cur->f.interlaced_frame = 1; else // try to flag soft telecine progressive - cur->interlaced_frame = h->prev_interlaced_frame; + cur->f.interlaced_frame = h->prev_interlaced_frame; break; case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: // Signal the possibility of telecined film externally (pic_struct 5,6) // From these hints, let the applications decide if they apply deinterlacing. - cur->repeat_pict = 1; + cur->f.repeat_pict = 1; break; case SEI_PIC_STRUCT_FRAME_DOUBLING: // Force progressive here, as doubling interlaced frame is a bad idea. - cur->repeat_pict = 2; + cur->f.repeat_pict = 2; break; case SEI_PIC_STRUCT_FRAME_TRIPLING: - cur->repeat_pict = 4; + cur->f.repeat_pict = 4; break; } if ((h->sei_ct_type & 3) && h->sei_pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP) - cur->interlaced_frame = (h->sei_ct_type & (1<<1)) != 0; + cur->f.interlaced_frame = (h->sei_ct_type & (1 << 1)) != 0; }else{ /* Derive interlacing flag from used decoding process. */ - cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE; + cur->f.interlaced_frame = FIELD_OR_MBAFF_PICTURE; } - h->prev_interlaced_frame = cur->interlaced_frame; + h->prev_interlaced_frame = cur->f.interlaced_frame; if (cur->field_poc[0] != cur->field_poc[1]){ /* Derive top_field_first from field pocs. */ - cur->top_field_first = cur->field_poc[0] < cur->field_poc[1]; + cur->f.top_field_first = cur->field_poc[0] < cur->field_poc[1]; }else{ - if(cur->interlaced_frame || h->sps.pic_struct_present_flag){ + if (cur->f.interlaced_frame || h->sps.pic_struct_present_flag) { /* Use picture timing SEI information. Even if it is a information of a past frame, better than nothing. */ if(h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM || h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) - cur->top_field_first = 1; + cur->f.top_field_first = 1; else - cur->top_field_first = 0; + cur->f.top_field_first = 0; }else{ /* Most likely progressive */ - cur->top_field_first = 0; + cur->f.top_field_first = 0; } } @@ -1379,17 +1379,17 @@ static void decode_postinit(H264Context *h, int setup_finished){ assert(pics <= MAX_DELAYED_PIC_COUNT); h->delayed_pic[pics++] = cur; - if(cur->reference == 0) - cur->reference = DELAYED_PIC_REF; + if (cur->f.reference == 0) + cur->f.reference = DELAYED_PIC_REF; out = h->delayed_pic[0]; out_idx = 0; - for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && !h->delayed_pic[i]->mmco_reset; i++) + for (i = 1; h->delayed_pic[i] && !h->delayed_pic[i]->f.key_frame && !h->delayed_pic[i]->mmco_reset; i++) if(h->delayed_pic[i]->poc < out->poc){ out = h->delayed_pic[i]; out_idx = i; } - if(s->avctx->has_b_frames == 0 && (h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset)) + if (s->avctx->has_b_frames == 0 && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) h->next_outputed_poc= INT_MIN; out_of_order = out->poc < h->next_outputed_poc; @@ -1398,14 +1398,14 @@ static void decode_postinit(H264Context *h, int setup_finished){ else if((out_of_order && pics-1 == s->avctx->has_b_frames && s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) || (s->low_delay && ((h->next_outputed_poc != INT_MIN && out->poc > h->next_outputed_poc + 2) - || cur->pict_type == AV_PICTURE_TYPE_B))) + || cur->f.pict_type == AV_PICTURE_TYPE_B))) { s->low_delay = 0; s->avctx->has_b_frames++; } if(out_of_order || pics > s->avctx->has_b_frames){ - out->reference &= ~DELAYED_PIC_REF; + out->f.reference &= ~DELAYED_PIC_REF; out->owner2 = s; // for frame threading, the owner must be the second field's thread // or else the first thread can release the picture and reuse it unsafely for(i=out_idx; h->delayed_pic[i]; i++) @@ -1413,7 +1413,7 @@ static void decode_postinit(H264Context *h, int setup_finished){ } if(!out_of_order && pics > s->avctx->has_b_frames){ h->next_output_pic = out; - if(out_idx==0 && h->delayed_pic[0] && (h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset)) { + if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) { h->next_outputed_poc = INT_MIN; } else h->next_outputed_poc = out->poc; @@ -1757,7 +1757,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i const int mb_x= s->mb_x; const int mb_y= s->mb_y; const int mb_xy= h->mb_xy; - const int mb_type= s->current_picture.mb_type[mb_xy]; + const int mb_type = s->current_picture.f.mb_type[mb_xy]; uint8_t *dest_y, *dest_cb, *dest_cr; int linesize, uvlinesize /*dct_offset*/; int i, j; @@ -1767,9 +1767,9 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i const int is_h264 = !CONFIG_SVQ3_DECODER || simple || s->codec_id == CODEC_ID_H264; void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride); - dest_y = s->current_picture.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; - dest_cb = s->current_picture.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8; - dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8; + dest_y = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; + dest_cb = s->current_picture.f.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8; + dest_cr = s->current_picture.f.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8; s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + (64 << pixel_shift), s->linesize, 4); s->dsp.prefetch(dest_cb + (s->mb_x&7)*s->uvlinesize + (64 << pixel_shift), dest_cr - dest_cb, 2); @@ -1918,7 +1918,7 @@ static av_always_inline void hl_decode_mb_444_internal(H264Context *h, int simpl const int mb_x= s->mb_x; const int mb_y= s->mb_y; const int mb_xy= h->mb_xy; - const int mb_type= s->current_picture.mb_type[mb_xy]; + const int mb_type = s->current_picture.f.mb_type[mb_xy]; uint8_t *dest[3]; int linesize; int i, j, p; @@ -1928,7 +1928,7 @@ static av_always_inline void hl_decode_mb_444_internal(H264Context *h, int simpl for (p = 0; p < plane_count; p++) { - dest[p] = s->current_picture.data[p] + ((mb_x << pixel_shift) + mb_y * s->linesize) * 16; + dest[p] = s->current_picture.f.data[p] + ((mb_x << pixel_shift) + mb_y * s->linesize) * 16; s->dsp.prefetch(dest[p] + (s->mb_x&3)*4*s->linesize + (64 << pixel_shift), s->linesize, 4); } @@ -2037,7 +2037,7 @@ static void av_noinline hl_decode_mb_444_simple(H264Context *h){ void ff_h264_hl_decode_mb(H264Context *h){ MpegEncContext * const s = &h->s; const int mb_xy= h->mb_xy; - const int mb_type= s->current_picture.mb_type[mb_xy]; + const int mb_type = s->current_picture.f.mb_type[mb_xy]; int is_complex = CONFIG_SMALL || h->is_complex || IS_INTRA_PCM(mb_type) || s->qscale == 0; if (CHROMA444) { @@ -2191,14 +2191,14 @@ static void flush_dpb(AVCodecContext *avctx){ int i; for(i=0; idelayed_pic[i]) - h->delayed_pic[i]->reference= 0; + h->delayed_pic[i]->f.reference = 0; h->delayed_pic[i]= NULL; } h->outputed_poc=h->next_outputed_poc= INT_MIN; h->prev_interlaced_frame = 1; idr(h); if(h->s.current_picture_ptr) - h->s.current_picture_ptr->reference= 0; + h->s.current_picture_ptr->f.reference = 0; h->s.first_field= 0; ff_h264_reset_sei(h); ff_mpeg_flush(avctx); @@ -2677,8 +2677,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ * be fixed. */ if (h->short_ref_count) { if (prev) { - av_image_copy(h->short_ref[0]->data, h->short_ref[0]->linesize, - (const uint8_t**)prev->data, prev->linesize, + av_image_copy(h->short_ref[0]->f.data, h->short_ref[0]->f.linesize, + (const uint8_t**)prev->f.data, prev->f.linesize, s->avctx->pix_fmt, s->mb_width*16, s->mb_height*16); h->short_ref[0]->poc = prev->poc+2; } @@ -2689,7 +2689,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ /* See if we have a decoded first field looking for a pair... */ if (s0->first_field) { assert(s0->current_picture_ptr); - assert(s0->current_picture_ptr->data[0]); + assert(s0->current_picture_ptr->f.data[0]); assert(s0->current_picture_ptr->reference != DELAYED_PIC_REF); /* figure out if we have a complementary field pair */ @@ -2703,7 +2703,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ } else { if (h->nal_ref_idc && - s0->current_picture_ptr->reference && + s0->current_picture_ptr->f.reference && s0->current_picture_ptr->frame_num != h->frame_num) { /* * This and previous field were reference, but had @@ -2951,16 +2951,16 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ int *ref2frm= h->ref2frm[h->slice_num&(MAX_SLICES-1)][j]; for(i=0; i<16; i++){ id_list[i]= 60; - if(h->ref_list[j][i].data[0]){ + if (h->ref_list[j][i].f.data[0]) { int k; - uint8_t *base= h->ref_list[j][i].base[0]; + uint8_t *base = h->ref_list[j][i].f.base[0]; for(k=0; kshort_ref_count; k++) - if(h->short_ref[k]->base[0] == base){ + if (h->short_ref[k]->f.base[0] == base) { id_list[i]= k; break; } for(k=0; klong_ref_count; k++) - if(h->long_ref[k] && h->long_ref[k]->base[0] == base){ + if (h->long_ref[k] && h->long_ref[k]->f.base[0] == base) { id_list[i]= h->short_ref_count + k; break; } @@ -2971,12 +2971,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ ref2frm[1]= -1; for(i=0; i<16; i++) ref2frm[i+2]= 4*id_list[i] - +(h->ref_list[j][i].reference&3); + + (h->ref_list[j][i].f.reference & 3); ref2frm[18+0]= ref2frm[18+1]= -1; for(i=16; i<48; i++) ref2frm[i+4]= 4*id_list[(i-16)>>1] - +(h->ref_list[j][i].reference&3); + + (h->ref_list[j][i].f.reference & 3); } //FIXME: fix draw_edges+PAFF+frame threads @@ -3026,11 +3026,11 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride; const int b8_xy= 4*top_xy + 2; int (*ref2frm)[64] = h->ref2frm[ h->slice_table[top_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); - AV_COPY128(mv_dst - 1*8, s->current_picture.motion_val[list][b_xy + 0]); + AV_COPY128(mv_dst - 1*8, s->current_picture.f.motion_val[list][b_xy + 0]); ref_cache[0 - 1*8]= - ref_cache[1 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 0]]; + ref_cache[1 - 1*8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 0]]; ref_cache[2 - 1*8]= - ref_cache[3 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 1]]; + ref_cache[3 - 1*8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 1]]; }else{ AV_ZERO128(mv_dst - 1*8); AV_WN32A(&ref_cache[0 - 1*8], ((LIST_NOT_USED)&0xFF)*0x01010101u); @@ -3041,14 +3041,14 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3; const int b8_xy= 4*left_xy[LTOP] + 1; int (*ref2frm)[64] = h->ref2frm[ h->slice_table[left_xy[LTOP]]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); - AV_COPY32(mv_dst - 1 + 0, s->current_picture.motion_val[list][b_xy + b_stride*0]); - AV_COPY32(mv_dst - 1 + 8, s->current_picture.motion_val[list][b_xy + b_stride*1]); - AV_COPY32(mv_dst - 1 +16, s->current_picture.motion_val[list][b_xy + b_stride*2]); - AV_COPY32(mv_dst - 1 +24, s->current_picture.motion_val[list][b_xy + b_stride*3]); + AV_COPY32(mv_dst - 1 + 0, s->current_picture.f.motion_val[list][b_xy + b_stride*0]); + AV_COPY32(mv_dst - 1 + 8, s->current_picture.f.motion_val[list][b_xy + b_stride*1]); + AV_COPY32(mv_dst - 1 + 16, s->current_picture.f.motion_val[list][b_xy + b_stride*2]); + AV_COPY32(mv_dst - 1 + 24, s->current_picture.f.motion_val[list][b_xy + b_stride*3]); ref_cache[-1 + 0]= - ref_cache[-1 + 8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 2*0]]; + ref_cache[-1 + 8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 2*0]]; ref_cache[-1 + 16]= - ref_cache[-1 + 24]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 2*1]]; + ref_cache[-1 + 24]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 2*1]]; }else{ AV_ZERO32(mv_dst - 1 + 0); AV_ZERO32(mv_dst - 1 + 8); @@ -3072,7 +3072,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon } { - int8_t *ref = &s->current_picture.ref_index[list][4*mb_xy]; + int8_t *ref = &s->current_picture.f.ref_index[list][4*mb_xy]; int (*ref2frm)[64] = h->ref2frm[ h->slice_num&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101; uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]],ref2frm[list][ref[3]])&0x00FF00FF)*0x0101; @@ -3083,7 +3083,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncCon } { - int16_t (*mv_src)[2] = &s->current_picture.motion_val[list][4*s->mb_x + 4*s->mb_y*b_stride]; + int16_t (*mv_src)[2] = &s->current_picture.f.motion_val[list][4*s->mb_x + 4*s->mb_y*b_stride]; AV_COPY128(mv_dst + 8*0, mv_src + 0*b_stride); AV_COPY128(mv_dst + 8*1, mv_src + 1*b_stride); AV_COPY128(mv_dst + 8*2, mv_src + 2*b_stride); @@ -3110,7 +3110,7 @@ static int fill_filter_caches(H264Context *h, int mb_type){ left_xy[LBOT] = left_xy[LTOP] = mb_xy-1; if(FRAME_MBAFF){ - const int left_mb_field_flag = IS_INTERLACED(s->current_picture.mb_type[mb_xy-1]); + const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]); const int curr_mb_field_flag = IS_INTERLACED(mb_type); if(s->mb_y&1){ if (left_mb_field_flag != curr_mb_field_flag) { @@ -3118,7 +3118,7 @@ static int fill_filter_caches(H264Context *h, int mb_type){ } }else{ if(curr_mb_field_flag){ - top_xy += s->mb_stride & (((s->current_picture.mb_type[top_xy ]>>7)&1)-1); + top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy] >> 7) & 1) - 1); } if (left_mb_field_flag != curr_mb_field_flag) { left_xy[LBOT] += s->mb_stride; @@ -3133,21 +3133,21 @@ static int fill_filter_caches(H264Context *h, int mb_type){ //for sufficiently low qp, filtering wouldn't do anything //this is a conservative estimate: could also check beta_offset and more accurate chroma_qp int qp_thresh = h->qp_thresh; //FIXME strictly we should store qp_thresh for each mb of a slice - int qp = s->current_picture.qscale_table[mb_xy]; + int qp = s->current_picture.f.qscale_table[mb_xy]; if(qp <= qp_thresh - && (left_xy[LTOP]<0 || ((qp + s->current_picture.qscale_table[left_xy[LTOP]] + 1)>>1) <= qp_thresh) - && (top_xy <0 || ((qp + s->current_picture.qscale_table[top_xy ] + 1)>>1) <= qp_thresh)){ + && (left_xy[LTOP] < 0 || ((qp + s->current_picture.f.qscale_table[left_xy[LTOP]] + 1) >> 1) <= qp_thresh) + && (top_xy < 0 || ((qp + s->current_picture.f.qscale_table[top_xy ] + 1) >> 1) <= qp_thresh)) { if(!FRAME_MBAFF) return 1; - if( (left_xy[LTOP]< 0 || ((qp + s->current_picture.qscale_table[left_xy[LBOT] ] + 1)>>1) <= qp_thresh) - && (top_xy < s->mb_stride || ((qp + s->current_picture.qscale_table[top_xy -s->mb_stride] + 1)>>1) <= qp_thresh)) + if ((left_xy[LTOP] < 0 || ((qp + s->current_picture.f.qscale_table[left_xy[LBOT] ] + 1) >> 1) <= qp_thresh) && + (top_xy < s->mb_stride || ((qp + s->current_picture.f.qscale_table[top_xy - s->mb_stride] + 1) >> 1) <= qp_thresh)) return 1; } } - top_type = s->current_picture.mb_type[top_xy]; - left_type[LTOP] = s->current_picture.mb_type[left_xy[LTOP]]; - left_type[LBOT] = s->current_picture.mb_type[left_xy[LBOT]]; + top_type = s->current_picture.f.mb_type[top_xy]; + left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]]; + left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]]; if(h->deblocking_filter == 2){ if(h->slice_table[top_xy ] != h->slice_num) top_type= 0; if(h->slice_table[left_xy[LBOT]] != h->slice_num) left_type[LTOP]= left_type[LBOT]= 0; @@ -3236,7 +3236,7 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ int mb_xy, mb_type; mb_xy = h->mb_xy = mb_x + mb_y*s->mb_stride; h->slice_num= h->slice_table[mb_xy]; - mb_type= s->current_picture.mb_type[mb_xy]; + mb_type = s->current_picture.f.mb_type[mb_xy]; h->list_count= h->list_counts[mb_xy]; if(FRAME_MBAFF) @@ -3244,9 +3244,9 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ s->mb_x= mb_x; s->mb_y= mb_y; - dest_y = s->current_picture.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; - dest_cb = s->current_picture.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444); - dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444); + dest_y = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; + dest_cb = s->current_picture.f.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444); + dest_cr = s->current_picture.f.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444); //FIXME simplify above if (MB_FIELD) { @@ -3264,8 +3264,8 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, CHROMA444, 0); if(fill_filter_caches(h, mb_type)) continue; - h->chroma_qp[0] = get_chroma_qp(h, 0, s->current_picture.qscale_table[mb_xy]); - h->chroma_qp[1] = get_chroma_qp(h, 1, s->current_picture.qscale_table[mb_xy]); + h->chroma_qp[0] = get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mb_xy]); + h->chroma_qp[1] = get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mb_xy]); if (FRAME_MBAFF) { ff_h264_filter_mb (h, mb_x, mb_y, dest_y, dest_cb, dest_cr, linesize, uvlinesize); @@ -3286,9 +3286,9 @@ static void predict_field_decoding_flag(H264Context *h){ MpegEncContext * const s = &h->s; const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; int mb_type = (h->slice_table[mb_xy-1] == h->slice_num) - ? s->current_picture.mb_type[mb_xy-1] + ? s->current_picture.f.mb_type[mb_xy - 1] : (h->slice_table[mb_xy-s->mb_stride] == h->slice_num) - ? s->current_picture.mb_type[mb_xy-s->mb_stride] + ? s->current_picture.f.mb_type[mb_xy - s->mb_stride] : 0; h->mb_mbaff = h->mb_field_decoding_flag = IS_INTERLACED(mb_type) ? 1 : 0; } @@ -3667,7 +3667,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ if((err = decode_slice_header(hx, h))) break; - s->current_picture_ptr->key_frame |= + s->current_picture_ptr->f.key_frame |= (hx->nal_unit_type == NAL_IDR_SLICE) || (h->sei_recovery_frame_cnt >= 0); @@ -3831,7 +3831,7 @@ static int decode_frame(AVCodecContext *avctx, //FIXME factorize this with the output code below out = h->delayed_pic[0]; out_idx = 0; - for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && !h->delayed_pic[i]->mmco_reset; i++) + for (i = 1; h->delayed_pic[i] && !h->delayed_pic[i]->f.key_frame && !h->delayed_pic[i]->mmco_reset; i++) if(h->delayed_pic[i]->poc < out->poc){ out = h->delayed_pic[i]; out_idx = i; diff --git a/libavcodec/h264.h b/libavcodec/h264.h index e88005aa3e..f5bdb667b9 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -795,8 +795,8 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ left_xy[LBOT] = left_xy[LTOP] = mb_xy-1; h->left_block = left_block_options[0]; if(FRAME_MBAFF){ - const int left_mb_field_flag = IS_INTERLACED(s->current_picture.mb_type[mb_xy-1]); - const int curr_mb_field_flag = IS_INTERLACED(mb_type); + const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]); + const int curr_mb_field_flag = IS_INTERLACED(mb_type); if(s->mb_y&1){ if (left_mb_field_flag != curr_mb_field_flag) { left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1; @@ -812,9 +812,9 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ } }else{ if(curr_mb_field_flag){ - topleft_xy += s->mb_stride & (((s->current_picture.mb_type[top_xy - 1]>>7)&1)-1); - topright_xy += s->mb_stride & (((s->current_picture.mb_type[top_xy + 1]>>7)&1)-1); - top_xy += s->mb_stride & (((s->current_picture.mb_type[top_xy ]>>7)&1)-1); + topleft_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1); + topright_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy + 1] >> 7) & 1) - 1); + top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy ] >> 7) & 1) - 1); } if (left_mb_field_flag != curr_mb_field_flag) { if (curr_mb_field_flag) { @@ -834,11 +834,11 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ h->left_mb_xy[LBOT] = left_xy[LBOT]; //FIXME do we need all in the context? - h->topleft_type = s->current_picture.mb_type[topleft_xy] ; - h->top_type = s->current_picture.mb_type[top_xy] ; - h->topright_type= s->current_picture.mb_type[topright_xy]; - h->left_type[LTOP] = s->current_picture.mb_type[left_xy[LTOP]] ; - h->left_type[LBOT] = s->current_picture.mb_type[left_xy[LBOT]] ; + h->topleft_type = s->current_picture.f.mb_type[topleft_xy]; + h->top_type = s->current_picture.f.mb_type[top_xy]; + h->topright_type = s->current_picture.f.mb_type[topright_xy]; + h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]]; + h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]]; if(FMO){ if(h->slice_table[topleft_xy ] != h->slice_num) h->topleft_type = 0; @@ -898,7 +898,7 @@ static void fill_decode_caches(H264Context *h, int mb_type){ h->left_samples_available&= 0xFF5F; } }else{ - int left_typei = s->current_picture.mb_type[left_xy[LTOP] + s->mb_stride]; + int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride]; assert(left_xy[LTOP] == left_xy[LBOT]); if(!((left_typei & type_mask) && (left_type[LTOP] & type_mask))){ @@ -1016,9 +1016,9 @@ static void fill_decode_caches(H264Context *h, int mb_type){ int b_stride = h->b_stride; for(list=0; listlist_count; list++){ int8_t *ref_cache = &h->ref_cache[list][scan8[0]]; - int8_t *ref = s->current_picture.ref_index[list]; + int8_t *ref = s->current_picture.f.ref_index[list]; int16_t (*mv_cache)[2] = &h->mv_cache[list][scan8[0]]; - int16_t (*mv)[2] = s->current_picture.motion_val[list]; + int16_t (*mv)[2] = s->current_picture.f.motion_val[list]; if(!USES_LIST(mb_type, list)){ continue; } @@ -1240,7 +1240,7 @@ static av_always_inline void write_back_non_zero_count(H264Context *h){ static av_always_inline void write_back_motion_list(H264Context *h, MpegEncContext * const s, int b_stride, int b_xy, int b8_xy, int mb_type, int list ) { - int16_t (*mv_dst)[2] = &s->current_picture.motion_val[list][b_xy]; + int16_t (*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy]; int16_t (*mv_src)[2] = &h->mv_cache[list][scan8[0]]; AV_COPY128(mv_dst + 0*b_stride, mv_src + 8*0); AV_COPY128(mv_dst + 1*b_stride, mv_src + 8*1); @@ -1260,7 +1260,7 @@ static av_always_inline void write_back_motion_list(H264Context *h, MpegEncConte } { - int8_t *ref_index = &s->current_picture.ref_index[list][b8_xy]; + int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy]; int8_t *ref_cache = h->ref_cache[list]; ref_index[0+0*2]= ref_cache[scan8[0]]; ref_index[1+0*2]= ref_cache[scan8[4]]; @@ -1278,7 +1278,8 @@ static av_always_inline void write_back_motion(H264Context *h, int mb_type){ if(USES_LIST(mb_type, 0)){ write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0); }else{ - fill_rectangle(&s->current_picture.ref_index[0][b8_xy], 2, 2, 2, (uint8_t)LIST_NOT_USED, 1); + fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy], + 2, 2, 2, (uint8_t)LIST_NOT_USED, 1); } if(USES_LIST(mb_type, 1)){ write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1); @@ -1334,8 +1335,8 @@ static void av_unused decode_mb_skip(H264Context *h){ } write_back_motion(h, mb_type); - s->current_picture.mb_type[mb_xy]= mb_type; - s->current_picture.qscale_table[mb_xy]= s->qscale; + s->current_picture.f.mb_type[mb_xy] = mb_type; + s->current_picture.f.qscale_table[mb_xy] = s->qscale; h->slice_table[ mb_xy ]= h->slice_num; h->prev_mb_skipped= 1; } diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 390a7b6587..f7cec5d03e 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1284,8 +1284,8 @@ static int decode_cabac_field_decoding_flag(H264Context *h) { unsigned long ctx = 0; - ctx += h->mb_field_decoding_flag & !!s->mb_x; //for FMO:(s->current_picture.mb_type[mba_xy]>>7)&(h->slice_table[mba_xy] == h->slice_num); - ctx += (s->current_picture.mb_type[mbb_xy]>>7)&(h->slice_table[mbb_xy] == h->slice_num); + ctx += h->mb_field_decoding_flag & !!s->mb_x; //for FMO:(s->current_picture.f.mb_type[mba_xy] >> 7) & (h->slice_table[mba_xy] == h->slice_num); + ctx += (s->current_picture.f.mb_type[mbb_xy] >> 7) & (h->slice_table[mbb_xy] == h->slice_num); return get_cabac_noinline( &h->cabac, &(h->cabac_state+70)[ctx] ); } @@ -1330,13 +1330,13 @@ static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { mba_xy = mb_xy - 1; if( (mb_y&1) && h->slice_table[mba_xy] == h->slice_num - && MB_FIELD == !!IS_INTERLACED( s->current_picture.mb_type[mba_xy] ) ) + && MB_FIELD == !!IS_INTERLACED( s->current_picture.f.mb_type[mba_xy] ) ) mba_xy += s->mb_stride; if( MB_FIELD ){ mbb_xy = mb_xy - s->mb_stride; if( !(mb_y&1) && h->slice_table[mbb_xy] == h->slice_num - && IS_INTERLACED( s->current_picture.mb_type[mbb_xy] ) ) + && IS_INTERLACED( s->current_picture.f.mb_type[mbb_xy] ) ) mbb_xy -= s->mb_stride; }else mbb_xy = mb_x + (mb_y-1)*s->mb_stride; @@ -1346,9 +1346,9 @@ static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { mbb_xy = mb_xy - (s->mb_stride << FIELD_PICTURE); } - if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] )) + if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.f.mb_type[mba_xy] )) ctx++; - if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] )) + if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.f.mb_type[mbb_xy] )) ctx++; if( h->slice_type_nos == AV_PICTURE_TYPE_B ) @@ -1849,7 +1849,7 @@ int ff_h264_decode_mb_cabac(H264Context *h) { /* read skip flags */ if( skip ) { if( FRAME_MBAFF && (s->mb_y&1)==0 ){ - s->current_picture.mb_type[mb_xy] = MB_TYPE_SKIP; + s->current_picture.f.mb_type[mb_xy] = MB_TYPE_SKIP; h->next_mb_skipped = decode_cabac_mb_skip( h, s->mb_x, s->mb_y+1 ); if(!h->next_mb_skipped) h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h); @@ -1965,10 +1965,10 @@ decode_intra_mb: h->cbp_table[mb_xy] = 0xf7ef; h->chroma_pred_mode_table[mb_xy] = 0; // In deblocking, the quantizer is 0 - s->current_picture.qscale_table[mb_xy]= 0; + s->current_picture.f.qscale_table[mb_xy] = 0; // All coeffs are present memset(h->non_zero_count[mb_xy], 16, 48); - s->current_picture.mb_type[mb_xy]= mb_type; + s->current_picture.f.mb_type[mb_xy] = mb_type; h->last_qscale_diff = 0; return 0; } @@ -2265,7 +2265,7 @@ decode_intra_mb: AV_WN32A(&nnz_cache[4+8*10], top_empty); } } - s->current_picture.mb_type[mb_xy]= mb_type; + s->current_picture.f.mb_type[mb_xy] = mb_type; if( cbp || IS_INTRA16x16( mb_type ) ) { const uint8_t *scan, *scan8x8; @@ -2344,7 +2344,7 @@ decode_intra_mb: h->last_qscale_diff = 0; } - s->current_picture.qscale_table[mb_xy]= s->qscale; + s->current_picture.f.qscale_table[mb_xy] = s->qscale; write_back_non_zero_count(h); if(MB_MBAFF){ diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index 90c411002e..9e7c182f18 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -689,11 +689,11 @@ decode_intra_mb: } // In deblocking, the quantizer is 0 - s->current_picture.qscale_table[mb_xy]= 0; + s->current_picture.f.qscale_table[mb_xy] = 0; // All coeffs are present memset(h->non_zero_count[mb_xy], 16, 48); - s->current_picture.mb_type[mb_xy]= mb_type; + s->current_picture.f.mb_type[mb_xy] = mb_type; return 0; } @@ -990,7 +990,7 @@ decode_intra_mb: } h->cbp= h->cbp_table[mb_xy]= cbp; - s->current_picture.mb_type[mb_xy]= mb_type; + s->current_picture.f.mb_type[mb_xy] = mb_type; if(cbp || IS_INTRA16x16(mb_type)){ int i4x4, chroma_idx; @@ -1063,7 +1063,7 @@ decode_intra_mb: fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); } - s->current_picture.qscale_table[mb_xy]= s->qscale; + s->current_picture.f.qscale_table[mb_xy] = s->qscale; write_back_non_zero_count(h); if(MB_MBAFF){ diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c index a7e6853b5c..c73aab3d01 100644 --- a/libavcodec/h264_direct.c +++ b/libavcodec/h264_direct.c @@ -87,7 +87,7 @@ static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field, poc= (poc&~3) + rfield + 1; for(j=start; jref_list[0][j].frame_num + (h->ref_list[0][j].reference&3) == poc){ + if (4 * h->ref_list[0][j].frame_num + (h->ref_list[0][j].f.reference & 3) == poc) { int cur_ref= mbafi ? (j-16)^field : j; map[list][2*old_ref + (rfield^field) + 16] = cur_ref; if(rfield == field || !interl) @@ -105,12 +105,12 @@ void ff_h264_direct_ref_list_init(H264Context * const h){ Picture * const cur = s->current_picture_ptr; int list, j, field; int sidx= (s->picture_structure&1)^1; - int ref1sidx= (ref1->reference&1)^1; + int ref1sidx = (ref1->f.reference&1)^1; for(list=0; list<2; list++){ cur->ref_count[sidx][list] = h->ref_count[list]; for(j=0; jref_count[list]; j++) - cur->ref_poc[sidx][list][j] = 4*h->ref_list[list][j].frame_num + (h->ref_list[list][j].reference&3); + cur->ref_poc[sidx][list][j] = 4 * h->ref_list[list][j].frame_num + (h->ref_list[list][j].f.reference & 3); } if(s->picture_structure == PICT_FRAME){ @@ -126,11 +126,11 @@ void ff_h264_direct_ref_list_init(H264Context * const h){ int *col_poc = h->ref_list[1]->field_poc; h->col_parity= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc)); ref1sidx=sidx= h->col_parity; - }else if(!(s->picture_structure & h->ref_list[1][0].reference) && !h->ref_list[1][0].mbaff){ // FL -> FL & differ parity - h->col_fieldoff= 2*(h->ref_list[1][0].reference) - 3; + } else if (!(s->picture_structure & h->ref_list[1][0].f.reference) && !h->ref_list[1][0].mbaff) { // FL -> FL & differ parity + h->col_fieldoff = 2 * h->ref_list[1][0].f.reference - 3; } - if(cur->pict_type != AV_PICTURE_TYPE_B || h->direct_spatial_mv_pred) + if (cur->f.pict_type != AV_PICTURE_TYPE_B || h->direct_spatial_mv_pred) return; for(list=0; list<2; list++){ @@ -143,7 +143,7 @@ void ff_h264_direct_ref_list_init(H264Context * const h){ static void await_reference_mb_row(H264Context * const h, Picture *ref, int mb_y) { - int ref_field = ref->reference - 1; + int ref_field = ref->f.reference - 1; int ref_field_picture = ref->field_picture; int ref_height = 16*h->s.mb_height >> ref_field_picture; @@ -234,8 +234,8 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ return; } - if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL - if(!IS_INTERLACED(*mb_type)){ // AFR/FR -> AFL/FL + if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL + if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL mb_y = (s->mb_y&~1) + h->col_parity; mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride; b8_stride = 0; @@ -248,8 +248,8 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR mb_y = s->mb_y&~1; mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; - mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; - mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride]; + mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy]; + mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride]; b8_stride = 2+4*s->mb_stride; b4_stride *= 6; @@ -264,7 +264,7 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ }else{ // AFR/FR -> AFR/FR single_col: mb_type_col[0] = - mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy]; + mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy]; sub_mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){ @@ -284,10 +284,10 @@ single_col: await_reference_mb_row(h, &h->ref_list[1][0], mb_y); - l1mv0 = &h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]]; - l1mv1 = &h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]]; - l1ref0 = &h->ref_list[1][0].ref_index [0][4*mb_xy]; - l1ref1 = &h->ref_list[1][0].ref_index [1][4*mb_xy]; + l1mv0 = &h->ref_list[1][0].f.motion_val[0][h->mb2b_xy [mb_xy]]; + l1mv1 = &h->ref_list[1][0].f.motion_val[1][h->mb2b_xy [mb_xy]]; + l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy]; + l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy]; if(!b8_stride){ if(s->mb_y&1){ l1ref0 += 2; @@ -420,8 +420,8 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){ await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type)); - if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL - if(!IS_INTERLACED(*mb_type)){ // AFR/FR -> AFL/FL + if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL + if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL mb_y = (s->mb_y&~1) + h->col_parity; mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride; b8_stride = 0; @@ -434,8 +434,8 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){ if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR mb_y = s->mb_y&~1; mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; - mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; - mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride]; + mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy]; + mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride]; b8_stride = 2+4*s->mb_stride; b4_stride *= 6; @@ -451,7 +451,7 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){ }else{ // AFR/FR -> AFR/FR single_col: mb_type_col[0] = - mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy]; + mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy]; sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){ @@ -471,10 +471,10 @@ single_col: await_reference_mb_row(h, &h->ref_list[1][0], mb_y); - l1mv0 = &h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]]; - l1mv1 = &h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]]; - l1ref0 = &h->ref_list[1][0].ref_index [0][4*mb_xy]; - l1ref1 = &h->ref_list[1][0].ref_index [1][4*mb_xy]; + l1mv0 = &h->ref_list[1][0].f.motion_val[0][h->mb2b_xy [mb_xy]]; + l1mv1 = &h->ref_list[1][0].f.motion_val[1][h->mb2b_xy [mb_xy]]; + l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy]; + l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy]; if(!b8_stride){ if(s->mb_y&1){ l1ref0 += 2; diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 6eba8dcd02..2e94459b6c 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -230,10 +230,10 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, left_type= h->left_type[LTOP]; top_type= h->top_type; - mb_type = s->current_picture.mb_type[mb_xy]; - qp = s->current_picture.qscale_table[mb_xy]; - qp0 = s->current_picture.qscale_table[mb_xy-1]; - qp1 = s->current_picture.qscale_table[h->top_mb_xy]; + mb_type = s->current_picture.f.mb_type[mb_xy]; + qp = s->current_picture.f.qscale_table[mb_xy]; + qp0 = s->current_picture.f.qscale_table[mb_xy - 1]; + qp1 = s->current_picture.f.qscale_table[h->top_mb_xy]; qpc = get_chroma_qp( h, 0, qp ); qpc0 = get_chroma_qp( h, 0, qp0 ); qpc1 = get_chroma_qp( h, 0, qp1 ); @@ -435,10 +435,10 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u for(j=0; j<2; j++, mbn_xy += s->mb_stride){ DECLARE_ALIGNED(8, int16_t, bS)[4]; int qp; - if( IS_INTRA(mb_type|s->current_picture.mb_type[mbn_xy]) ) { + if (IS_INTRA(mb_type | s->current_picture.f.mb_type[mbn_xy])) { AV_WN64A(bS, 0x0003000300030003ULL); } else { - if(!CABAC && IS_8x8DCT(s->current_picture.mb_type[mbn_xy])){ + if (!CABAC && IS_8x8DCT(s->current_picture.f.mb_type[mbn_xy])) { bS[0]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+0]); bS[1]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+1]); bS[2]= 1+((h->cbp_table[mbn_xy] & 0x8000)||h->non_zero_count_cache[scan8[0]+2]); @@ -453,12 +453,12 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u } // Do not use s->qscale as luma quantizer because it has not the same // value in IPCM macroblocks. - qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; + qp = (s->current_picture.f.qscale_table[mb_xy] + s->current_picture.f.qscale_table[mbn_xy] + 1) >> 1; tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize); { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, h ); - chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1; - chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1; + chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1; + chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1; if (chroma) { if (chroma444) { filter_mb_edgeh (&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], h); @@ -518,12 +518,12 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u // Do not use s->qscale as luma quantizer because it has not the same // value in IPCM macroblocks. if(bS[0]+bS[1]+bS[2]+bS[3]){ - qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbm_xy] + 1 ) >> 1; + qp = (s->current_picture.f.qscale_table[mb_xy] + s->current_picture.f.qscale_table[mbm_xy] + 1) >> 1; //tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp[0], s->current_picture.qscale_table[mbn_xy]); tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize); //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } - chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbm_xy] ) + 1 ) >> 1; - chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbm_xy] ) + 1 ) >> 1; + chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1; + chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1; if( dir == 0 ) { filter_mb_edgev( &img_y[0], linesize, bS, qp, h ); if (chroma) { @@ -602,7 +602,7 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u /* Filter edge */ // Do not use s->qscale as luma quantizer because it has not the same // value in IPCM macroblocks. - qp = s->current_picture.qscale_table[mb_xy]; + qp = s->current_picture.f.qscale_table[mb_xy]; //tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp[0], s->current_picture.qscale_table[mbn_xy]); tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize); //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } @@ -635,7 +635,7 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { MpegEncContext * const s = &h->s; const int mb_xy= mb_x + mb_y*s->mb_stride; - const int mb_type = s->current_picture.mb_type[mb_xy]; + const int mb_type = s->current_picture.f.mb_type[mb_xy]; const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4; int first_vertical_edge_done = 0; av_unused int dir; @@ -688,9 +688,9 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint } } - mb_qp = s->current_picture.qscale_table[mb_xy]; - mbn0_qp = s->current_picture.qscale_table[h->left_mb_xy[0]]; - mbn1_qp = s->current_picture.qscale_table[h->left_mb_xy[1]]; + mb_qp = s->current_picture.f.qscale_table[mb_xy]; + mbn0_qp = s->current_picture.f.qscale_table[h->left_mb_xy[0]]; + mbn1_qp = s->current_picture.f.qscale_table[h->left_mb_xy[1]]; qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1; bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) + get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1; diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h index 6dceee3c90..1d40c0a2c5 100644 --- a/libavcodec/h264_mvpred.h +++ b/libavcodec/h264_mvpred.h @@ -48,15 +48,15 @@ static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, const int mb_type = mb_types[xy+(y4>>2)*s->mb_stride];\ if(!USES_LIST(mb_type,list))\ return LIST_NOT_USED;\ - mv = s->current_picture_ptr->motion_val[list][h->mb2b_xy[xy]+3 + y4*h->b_stride];\ + mv = s->current_picture_ptr->f.motion_val[list][h->mb2b_xy[xy] + 3 + y4*h->b_stride];\ h->mv_cache[list][scan8[0]-2][0] = mv[0];\ h->mv_cache[list][scan8[0]-2][1] = mv[1] MV_OP;\ - return s->current_picture_ptr->ref_index[list][4*xy+1 + (y4&~1)] REF_OP; + return s->current_picture_ptr->f.ref_index[list][4*xy + 1 + (y4 & ~1)] REF_OP; if(topright_ref == PART_NOT_AVAILABLE && i >= scan8[0]+8 && (i&7)==4 && h->ref_cache[list][scan8[0]-1] != PART_NOT_AVAILABLE){ - const uint32_t *mb_types = s->current_picture_ptr->mb_type; + const uint32_t *mb_types = s->current_picture_ptr->f.mb_type; const int16_t *mv; AV_ZERO32(h->mv_cache[list][scan8[0]-2]); *C = h->mv_cache[list][scan8[0]-2]; @@ -236,8 +236,8 @@ static av_always_inline void pred_pskip_motion(H264Context * const h){ DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = {0}; DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2]; MpegEncContext * const s = &h->s; - int8_t *ref = s->current_picture.ref_index[0]; - int16_t (*mv)[2] = s->current_picture.motion_val[0]; + int8_t *ref = s->current_picture.f.ref_index[0]; + int16_t (*mv)[2] = s->current_picture.f.motion_val[0]; int top_ref, left_ref, diagonal_ref, match_count, mx, my; const int16_t *A, *B, *C; int b_stride = h->b_stride; diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index a025f7d352..1c72b22d2c 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -39,16 +39,16 @@ static void pic_as_field(Picture *pic, const int parity){ int i; for (i = 0; i < 4; ++i) { if (parity == PICT_BOTTOM_FIELD) - pic->data[i] += pic->linesize[i]; - pic->reference = parity; - pic->linesize[i] *= 2; + pic->f.data[i] += pic->f.linesize[i]; + pic->f.reference = parity; + pic->f.linesize[i] *= 2; } pic->poc= pic->field_poc[parity == PICT_BOTTOM_FIELD]; } static int split_field_copy(Picture *dest, Picture *src, int parity, int id_add){ - int match = !!(src->reference & parity); + int match = !!(src->f.reference & parity); if (match) { *dest = *src; @@ -67,9 +67,9 @@ static int build_def_list(Picture *def, Picture **in, int len, int is_long, int int index=0; while(i[0]reference & sel))) + while (i[0] < len && !(in[ i[0] ] && (in[ i[0] ]->f.reference & sel))) i[0]++; - while(i[1]reference & (sel^3)))) + while (i[1] < len && !(in[ i[1] ] && (in[ i[1] ]->f.reference & (sel^3)))) i[1]++; if(i[0] < len){ in[ i[0] ]->pic_id= is_long ? i[0] : in[ i[0] ]->frame_num; @@ -133,7 +133,7 @@ int ff_h264_fill_default_ref_list(H264Context *h){ } if(lens[0] == lens[1] && lens[1] > 1){ - for(i=0; h->default_ref_list[0][i].data[0] == h->default_ref_list[1][i].data[0] && idefault_ref_list[0][i].f.data[0] == h->default_ref_list[1][i].f.data[0] && i < lens[0]; i++); if(i == lens[0]) FFSWAP(Picture, h->default_ref_list[1][0], h->default_ref_list[1][1]); } @@ -229,11 +229,11 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){ for(i= h->short_ref_count-1; i>=0; i--){ ref = h->short_ref[i]; - assert(ref->reference); + assert(ref->f.reference); assert(!ref->long_ref); if( ref->frame_num == frame_num && - (ref->reference & pic_structure) + (ref->f.reference & pic_structure) ) break; } @@ -250,8 +250,8 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){ return -1; } ref = h->long_ref[long_idx]; - assert(!(ref && !ref->reference)); - if(ref && (ref->reference & pic_structure)){ + assert(!(ref && !ref->f.reference)); + if (ref && (ref->f.reference & pic_structure)) { ref->pic_id= pic_id; assert(ref->long_ref); i=0; @@ -285,9 +285,9 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){ } for(list=0; listlist_count; list++){ for(index= 0; index < h->ref_count[list]; index++){ - if(!h->ref_list[list][index].data[0]){ + if (!h->ref_list[list][index].f.data[0]) { av_log(h->s.avctx, AV_LOG_ERROR, "Missing reference picture\n"); - if(h->default_ref_list[list][0].data[0]) + if (h->default_ref_list[list][0].f.data[0]) h->ref_list[list][index]= h->default_ref_list[list][0]; else return -1; @@ -306,13 +306,13 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h){ Picture *field = &h->ref_list[list][16+2*i]; field[0] = *frame; for(j=0; j<3; j++) - field[0].linesize[j] <<= 1; - field[0].reference = PICT_TOP_FIELD; + field[0].f.linesize[j] <<= 1; + field[0].f.reference = PICT_TOP_FIELD; field[0].poc= field[0].field_poc[0]; field[1] = field[0]; for(j=0; j<3; j++) - field[1].data[j] += frame->linesize[j]; - field[1].reference = PICT_BOTTOM_FIELD; + field[1].f.data[j] += frame->f.linesize[j]; + field[1].f.reference = PICT_BOTTOM_FIELD; field[1].poc= field[1].field_poc[1]; h->luma_weight[16+2*i][list][0] = h->luma_weight[16+2*i+1][list][0] = h->luma_weight[i][list][0]; @@ -338,12 +338,12 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h){ */ static inline int unreference_pic(H264Context *h, Picture *pic, int refmask){ int i; - if (pic->reference &= refmask) { + if (pic->f.reference &= refmask) { return 0; } else { for(i = 0; h->delayed_pic[i]; i++) if(pic == h->delayed_pic[i]){ - pic->reference=DELAYED_PIC_REF; + pic->f.reference = DELAYED_PIC_REF; break; } return 1; @@ -453,7 +453,8 @@ static void print_short_term(H264Context *h) { av_log(h->s.avctx, AV_LOG_DEBUG, "short term list:\n"); for(i=0; ishort_ref_count; i++){ Picture *pic= h->short_ref[i]; - av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n", i, pic->frame_num, pic->poc, pic->data[0]); + av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n", + i, pic->frame_num, pic->poc, pic->f.data[0]); } } } @@ -468,7 +469,8 @@ static void print_long_term(H264Context *h) { for(i = 0; i < 16; i++){ Picture *pic= h->long_ref[i]; if (pic) { - av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n", i, pic->frame_num, pic->poc, pic->data[0]); + av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n", + i, pic->frame_num, pic->poc, pic->f.data[0]); } } } @@ -480,7 +482,7 @@ void ff_generate_sliding_window_mmcos(H264Context *h) { h->mmco_index= 0; if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count && - !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->reference)) { + !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->f.reference)) { h->mmco[0].opcode= MMCO_SHORT2UNUSED; h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num; h->mmco_index= 1; @@ -561,7 +563,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ h->long_ref_count++; } - s->current_picture_ptr->reference |= s->picture_structure; + s->current_picture_ptr->f.reference |= s->picture_structure; current_ref_assigned=1; break; case MMCO_SET_MAX_LONG: @@ -600,7 +602,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ */ if (h->short_ref_count && h->short_ref[0] == s->current_picture_ptr) { /* Just mark the second field valid */ - s->current_picture_ptr->reference = PICT_FRAME; + s->current_picture_ptr->f.reference = PICT_FRAME; } else if (s->current_picture_ptr->long_ref) { av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term reference " "assignment for second field " @@ -617,7 +619,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ h->short_ref[0]= s->current_picture_ptr; h->short_ref_count++; - s->current_picture_ptr->reference |= s->picture_structure; + s->current_picture_ptr->f.reference |= s->picture_structure; } } diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c index 69f940a162..6b869b7aa5 100644 --- a/libavcodec/intrax8.c +++ b/libavcodec/intrax8.c @@ -304,7 +304,7 @@ static int x8_setup_spatial_predictor(IntraX8Context * const w, const int chroma int quant; s->dsp.x8_setup_spatial_compensation(s->dest[chroma], s->edge_emu_buffer, - s->current_picture.linesize[chroma>0], + s->current_picture.f.linesize[chroma>0], &range, &sum, w->edges); if(chroma){ w->orient=w->chroma_orient; @@ -613,7 +613,7 @@ static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){ dc_level+= (w->predicted_dc*divide_quant + (1<<12) )>>13; dsp_x8_put_solidcolor( av_clip_uint8((dc_level*dc_quant+4)>>3), - s->dest[chroma], s->current_picture.linesize[!!chroma]); + s->dest[chroma], s->current_picture.f.linesize[!!chroma]); goto block_placed; } @@ -637,15 +637,15 @@ static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){ } if(w->flat_dc){ - dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma], s->current_picture.linesize[!!chroma]); + dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma], s->current_picture.f.linesize[!!chroma]); }else{ s->dsp.x8_spatial_compensation[w->orient]( s->edge_emu_buffer, s->dest[chroma], - s->current_picture.linesize[!!chroma] ); + s->current_picture.f.linesize[!!chroma] ); } if(!zeros_only) s->dsp.idct_add ( s->dest[chroma], - s->current_picture.linesize[!!chroma], + s->current_picture.f.linesize[!!chroma], s->block[0] ); block_placed: @@ -656,7 +656,7 @@ block_placed: if(s->loop_filter){ uint8_t* ptr = s->dest[chroma]; - int linesize = s->current_picture.linesize[!!chroma]; + int linesize = s->current_picture.f.linesize[!!chroma]; if(!( (w->edges&2) || ( zeros_only && (w->orient|4)==4 ) )){ s->dsp.x8_h_loop_filter(ptr, linesize, w->quant); @@ -671,12 +671,12 @@ block_placed: static void x8_init_block_index(MpegEncContext *s){ //FIXME maybe merge with ff_* //not s->linesize as this would be wrong for field pics //not that IntraX8 has interlacing support ;) - const int linesize = s->current_picture.linesize[0]; - const int uvlinesize= s->current_picture.linesize[1]; + const int linesize = s->current_picture.f.linesize[0]; + const int uvlinesize = s->current_picture.f.linesize[1]; - s->dest[0] = s->current_picture.data[0]; - s->dest[1] = s->current_picture.data[1]; - s->dest[2] = s->current_picture.data[2]; + s->dest[0] = s->current_picture.f.data[0]; + s->dest[1] = s->current_picture.f.data[1]; + s->dest[2] = s->current_picture.f.data[2]; s->dest[0] += s->mb_y * linesize << 3; s->dest[1] += ( s->mb_y&(~1) ) * uvlinesize << 2;//chroma blocks are on add rows @@ -771,7 +771,7 @@ int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_of /*emulate MB info in the relevant tables*/ s->mbskip_table [mb_xy]=0; s->mbintra_table[mb_xy]=1; - s->current_picture.qscale_table[mb_xy]=w->quant; + s->current_picture.f.qscale_table[mb_xy] = w->quant; mb_xy++; } s->dest[0]+= 8; diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 7071b845fc..a54d7c1728 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -353,20 +353,20 @@ static void preview_obmc(MpegEncContext *s){ do{ if (get_bits1(&s->gb)) { /* skip mb */ - mot_val = s->current_picture.motion_val[0][ s->block_index[0] ]; + mot_val = s->current_picture.f.motion_val[0][s->block_index[0]]; mot_val[0 ]= mot_val[2 ]= mot_val[0+stride]= mot_val[2+stride]= 0; mot_val[1 ]= mot_val[3 ]= mot_val[1+stride]= mot_val[3+stride]= 0; - s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; goto end; } cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); }while(cbpc == 20); if(cbpc & 4){ - s->current_picture.mb_type[xy]= MB_TYPE_INTRA; + s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA; }else{ get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); if (cbpc & 8) { @@ -378,7 +378,7 @@ static void preview_obmc(MpegEncContext *s){ } if ((cbpc & 16) == 0) { - s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0; /* 16x16 motion prediction */ mot_val= h263_pred_motion(s, 0, 0, &pred_x, &pred_y); if (s->umvplus) @@ -396,7 +396,7 @@ static void preview_obmc(MpegEncContext *s){ mot_val[1 ]= mot_val[3 ]= mot_val[1+stride]= mot_val[3+stride]= my; } else { - s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0; for(i=0;i<4;i++) { mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y); if (s->umvplus) @@ -618,7 +618,7 @@ int ff_h263_decode_mb(MpegEncContext *s, s->block_last_index[i] = -1; s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; - s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mb_skipped = !(s->obmc | s->loop_filter); @@ -651,7 +651,7 @@ int ff_h263_decode_mb(MpegEncContext *s, s->mv_dir = MV_DIR_FORWARD; if ((cbpc & 16) == 0) { - s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0; /* 16x16 motion prediction */ s->mv_type = MV_TYPE_16X16; h263_pred_motion(s, 0, 0, &pred_x, &pred_y); @@ -676,7 +676,7 @@ int ff_h263_decode_mb(MpegEncContext *s, if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1) skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */ } else { - s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0; s->mv_type = MV_TYPE_8X8; for(i=0;i<4;i++) { mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y); @@ -704,8 +704,8 @@ int ff_h263_decode_mb(MpegEncContext *s, } else if(s->pict_type==AV_PICTURE_TYPE_B) { int mb_type; const int stride= s->b8_stride; - int16_t *mot_val0 = s->current_picture.motion_val[0][ 2*(s->mb_x + s->mb_y*stride) ]; - int16_t *mot_val1 = s->current_picture.motion_val[1][ 2*(s->mb_x + s->mb_y*stride) ]; + int16_t *mot_val0 = s->current_picture.f.motion_val[0][2 * (s->mb_x + s->mb_y * stride)]; + int16_t *mot_val1 = s->current_picture.f.motion_val[1][2 * (s->mb_x + s->mb_y * stride)]; // const int mv_xy= s->mb_x + 1 + s->mb_y * s->mb_stride; //FIXME ugly @@ -788,7 +788,7 @@ int ff_h263_decode_mb(MpegEncContext *s, } } - s->current_picture.mb_type[xy]= mb_type; + s->current_picture.f.mb_type[xy] = mb_type; } else { /* I-Frame */ do{ cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2); @@ -803,11 +803,11 @@ int ff_h263_decode_mb(MpegEncContext *s, dquant = cbpc & 4; s->mb_intra = 1; intra: - s->current_picture.mb_type[xy]= MB_TYPE_INTRA; + s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA; if (s->h263_aic) { s->ac_pred = get_bits1(&s->gb); if(s->ac_pred){ - s->current_picture.mb_type[xy]= MB_TYPE_INTRA | MB_TYPE_ACPRED; + s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED; s->h263_aic_dir = get_bits1(&s->gb); } @@ -889,7 +889,7 @@ int h263_decode_picture_header(MpegEncContext *s) i = get_bits(&s->gb, 8); /* picture timestamp */ if( (s->picture_number&~0xFF)+i < s->picture_number) i+= 256; - s->current_picture_ptr->pts= + s->current_picture_ptr->f.pts = s->picture_number= (s->picture_number&~0xFF) + i; /* PTYPE starts here */ diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index cadf389866..383a81b0e1 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -275,7 +275,7 @@ void h263_encode_gob_header(MpegEncContext * s, int mb_line) */ void ff_clean_h263_qscales(MpegEncContext *s){ int i; - int8_t * const qscale_table= s->current_picture.qscale_table; + int8_t * const qscale_table = s->current_picture.f.qscale_table; ff_init_qscale_tab(s); @@ -529,8 +529,8 @@ void h263_encode_mb(MpegEncContext * s, /* motion vectors: 8x8 mode*/ h263_pred_motion(s, i, 0, &pred_x, &pred_y); - motion_x= s->current_picture.motion_val[0][ s->block_index[i] ][0]; - motion_y= s->current_picture.motion_val[0][ s->block_index[i] ][1]; + motion_x = s->current_picture.f.motion_val[0][s->block_index[i]][0]; + motion_y = s->current_picture.f.motion_val[0][s->block_index[i]][1]; if (!s->umvplus) { ff_h263_encode_motion_vector(s, motion_x - pred_x, motion_y - pred_y, 1); diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 48e8ea9ffa..86b357d9f2 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -533,16 +533,16 @@ static inline void set_p_mv_tables(MpegEncContext * s, int mx, int my, int mv4) if(mv4){ int mot_xy= s->block_index[0]; - s->current_picture.motion_val[0][mot_xy ][0]= mx; - s->current_picture.motion_val[0][mot_xy ][1]= my; - s->current_picture.motion_val[0][mot_xy+1][0]= mx; - s->current_picture.motion_val[0][mot_xy+1][1]= my; + s->current_picture.f.motion_val[0][mot_xy ][0] = mx; + s->current_picture.f.motion_val[0][mot_xy ][1] = my; + s->current_picture.f.motion_val[0][mot_xy + 1][0] = mx; + s->current_picture.f.motion_val[0][mot_xy + 1][1] = my; mot_xy += s->b8_stride; - s->current_picture.motion_val[0][mot_xy ][0]= mx; - s->current_picture.motion_val[0][mot_xy ][1]= my; - s->current_picture.motion_val[0][mot_xy+1][0]= mx; - s->current_picture.motion_val[0][mot_xy+1][1]= my; + s->current_picture.f.motion_val[0][mot_xy ][0] = mx; + s->current_picture.f.motion_val[0][mot_xy ][1] = my; + s->current_picture.f.motion_val[0][mot_xy + 1][0] = mx; + s->current_picture.f.motion_val[0][mot_xy + 1][1] = my; } } @@ -615,8 +615,8 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) const int mot_stride = s->b8_stride; const int mot_xy = s->block_index[block]; - P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0]; - P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1]; + P_LEFT[0] = s->current_picture.f.motion_val[0][mot_xy - 1][0]; + P_LEFT[1] = s->current_picture.f.motion_val[0][mot_xy - 1][1]; if(P_LEFT[0] > (c->xmax<xmax<pred_x= pred_x4= P_LEFT[0]; c->pred_y= pred_y4= P_LEFT[1]; } else { - P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0]; - P_TOP[1] = s->current_picture.motion_val[0][mot_xy - mot_stride ][1]; - P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + off[block]][0]; - P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + off[block]][1]; + P_TOP[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride ][0]; + P_TOP[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride ][1]; + P_TOPRIGHT[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + off[block]][0]; + P_TOPRIGHT[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + off[block]][1]; if(P_TOP[1] > (c->ymax<ymax<xmin<xmin< (c->xmax<xmax<current_picture.motion_val[0][ s->block_index[block] ][0]= mx4; - s->current_picture.motion_val[0][ s->block_index[block] ][1]= my4; + s->current_picture.f.motion_val[0][s->block_index[block]][0] = mx4; + s->current_picture.f.motion_val[0][s->block_index[block]][1] = my4; if(mx4 != mx || my4 != my) same=0; } @@ -690,7 +690,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) return INT_MAX; if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){ - dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16); + dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16); } if(c->avctx->mb_cmp&FF_CMP_CHROMA){ @@ -705,15 +705,15 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) offset= (s->mb_x*8 + (mx>>1)) + (s->mb_y*8 + (my>>1))*s->uvlinesize; if(s->no_rounding){ - s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad , s->last_picture.data[1] + offset, s->uvlinesize, 8); - s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad+8 , s->last_picture.data[2] + offset, s->uvlinesize, 8); + s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad , s->last_picture.f.data[1] + offset, s->uvlinesize, 8); + s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, s->last_picture.f.data[2] + offset, s->uvlinesize, 8); }else{ - s->dsp.put_pixels_tab [1][dxy](c->scratchpad , s->last_picture.data[1] + offset, s->uvlinesize, 8); - s->dsp.put_pixels_tab [1][dxy](c->scratchpad+8 , s->last_picture.data[2] + offset, s->uvlinesize, 8); + s->dsp.put_pixels_tab [1][dxy](c->scratchpad , s->last_picture.f.data[1] + offset, s->uvlinesize, 8); + s->dsp.put_pixels_tab [1][dxy](c->scratchpad + 8, s->last_picture.f.data[2] + offset, s->uvlinesize, 8); } - dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad , s->uvlinesize, 8); - dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8); + dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad , s->uvlinesize, 8); + dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8); } c->pred_x= mx; @@ -879,7 +879,7 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int Picture *p= s->current_picture_ptr; int mb_xy= mb_x + mb_y*s->mb_stride; int xy= 2*mb_x + 2*mb_y*s->b8_stride; - int mb_type= s->current_picture.mb_type[mb_xy]; + int mb_type= s->current_picture.f.mb_type[mb_xy]; int flags= c->flags; int shift= (flags&FLAG_QPEL) + 1; int mask= (1<block_index[i]; - clip_input_mv(s, p->motion_val[0][xy], !!IS_INTERLACED(mb_type)); - clip_input_mv(s, p->motion_val[1][xy], !!IS_INTERLACED(mb_type)); + clip_input_mv(s, p->f.motion_val[0][xy], !!IS_INTERLACED(mb_type)); + clip_input_mv(s, p->f.motion_val[1][xy], !!IS_INTERLACED(mb_type)); } if(IS_INTERLACED(mb_type)){ @@ -912,8 +912,8 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int } if(USES_LIST(mb_type, 0)){ - int field_select0= p->ref_index[0][4*mb_xy ]; - int field_select1= p->ref_index[0][4*mb_xy+2]; + int field_select0= p->f.ref_index[0][4*mb_xy ]; + int field_select1= p->f.ref_index[0][4*mb_xy+2]; assert(field_select0==0 ||field_select0==1); assert(field_select1==0 ||field_select1==1); init_interlaced_ref(s, 0); @@ -921,46 +921,46 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int if(p_type){ s->p_field_select_table[0][mb_xy]= field_select0; s->p_field_select_table[1][mb_xy]= field_select1; - *(uint32_t*)s->p_field_mv_table[0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ]; - *(uint32_t*)s->p_field_mv_table[1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2]; + *(uint32_t*)s->p_field_mv_table[0][field_select0][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy ]; + *(uint32_t*)s->p_field_mv_table[1][field_select1][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy2]; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER_I; }else{ s->b_field_select_table[0][0][mb_xy]= field_select0; s->b_field_select_table[0][1][mb_xy]= field_select1; - *(uint32_t*)s->b_field_mv_table[0][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ]; - *(uint32_t*)s->b_field_mv_table[0][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2]; + *(uint32_t*)s->b_field_mv_table[0][0][field_select0][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy ]; + *(uint32_t*)s->b_field_mv_table[0][1][field_select1][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy2]; s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_FORWARD_I; } - x= p->motion_val[0][xy ][0]; - y= p->motion_val[0][xy ][1]; + x = p->f.motion_val[0][xy ][0]; + y = p->f.motion_val[0][xy ][1]; d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0, 0, cmpf, chroma_cmpf, flags); - x= p->motion_val[0][xy2][0]; - y= p->motion_val[0][xy2][1]; + x = p->f.motion_val[0][xy2][0]; + y = p->f.motion_val[0][xy2][1]; d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1, 1, cmpf, chroma_cmpf, flags); } if(USES_LIST(mb_type, 1)){ - int field_select0= p->ref_index[1][4*mb_xy ]; - int field_select1= p->ref_index[1][4*mb_xy+2]; + int field_select0 = p->f.ref_index[1][4 * mb_xy ]; + int field_select1 = p->f.ref_index[1][4 * mb_xy + 2]; assert(field_select0==0 ||field_select0==1); assert(field_select1==0 ||field_select1==1); init_interlaced_ref(s, 2); s->b_field_select_table[1][0][mb_xy]= field_select0; s->b_field_select_table[1][1][mb_xy]= field_select1; - *(uint32_t*)s->b_field_mv_table[1][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[1][xy ]; - *(uint32_t*)s->b_field_mv_table[1][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[1][xy2]; + *(uint32_t*)s->b_field_mv_table[1][0][field_select0][mb_xy] = *(uint32_t*)p->f.motion_val[1][xy ]; + *(uint32_t*)s->b_field_mv_table[1][1][field_select1][mb_xy] = *(uint32_t*)p->f.motion_val[1][xy2]; if(USES_LIST(mb_type, 0)){ s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BIDIR_I; }else{ s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BACKWARD_I; } - x= p->motion_val[1][xy ][0]; - y= p->motion_val[1][xy ][1]; + x = p->f.motion_val[1][xy ][0]; + y = p->f.motion_val[1][xy ][1]; d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0+2, 0, cmpf, chroma_cmpf, flags); - x= p->motion_val[1][xy2][0]; - y= p->motion_val[1][xy2][1]; + x = p->f.motion_val[1][xy2][0]; + y = p->f.motion_val[1][xy2][1]; d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1+2, 1, cmpf, chroma_cmpf, flags); //FIXME bidir scores } @@ -976,33 +976,33 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int init_mv4_ref(c); for(i=0; i<4; i++){ xy= s->block_index[i]; - x= p->motion_val[0][xy][0]; - y= p->motion_val[0][xy][1]; + x= p->f.motion_val[0][xy][0]; + y= p->f.motion_val[0][xy][1]; d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 1, 8, i, i, cmpf, chroma_cmpf, flags); } s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER4V; }else{ if(USES_LIST(mb_type, 0)){ if(p_type){ - *(uint32_t*)s->p_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy]; + *(uint32_t*)s->p_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[0][xy]; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER; }else if(USES_LIST(mb_type, 1)){ - *(uint32_t*)s->b_bidir_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy]; - *(uint32_t*)s->b_bidir_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy]; + *(uint32_t*)s->b_bidir_forw_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[0][xy]; + *(uint32_t*)s->b_bidir_back_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[1][xy]; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BIDIR; }else{ - *(uint32_t*)s->b_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy]; + *(uint32_t*)s->b_forw_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[0][xy]; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_FORWARD; } - x= p->motion_val[0][xy][0]; - y= p->motion_val[0][xy][1]; + x = p->f.motion_val[0][xy][0]; + y = p->f.motion_val[0][xy][1]; d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 0, 0, cmpf, chroma_cmpf, flags); }else if(USES_LIST(mb_type, 1)){ - *(uint32_t*)s->b_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy]; + *(uint32_t*)s->b_back_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[1][xy]; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BACKWARD; - x= p->motion_val[1][xy][0]; - y= p->motion_val[1][xy][1]; + x = p->f.motion_val[1][xy][0]; + y = p->f.motion_val[1][xy][1]; d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 2, 0, cmpf, chroma_cmpf, flags); }else s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA; @@ -1023,7 +1023,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, int mb_type=0; Picture * const pic= &s->current_picture; - init_ref(c, s->new_picture.data, s->last_picture.data, NULL, 16*mb_x, 16*mb_y, 0); + init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0); assert(s->quarter_sample==0 || s->quarter_sample==1); assert(s->linesize == c->stride); @@ -1075,16 +1075,16 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, const int mot_stride = s->b8_stride; const int mot_xy = s->block_index[0]; - P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0]; - P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1]; + P_LEFT[0] = s->current_picture.f.motion_val[0][mot_xy - 1][0]; + P_LEFT[1] = s->current_picture.f.motion_val[0][mot_xy - 1][1]; if(P_LEFT[0] > (c->xmax<xmax<first_slice_line) { - P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0]; - P_TOP[1] = s->current_picture.motion_val[0][mot_xy - mot_stride ][1]; - P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0]; - P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1]; + P_TOP[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride ][0]; + P_TOP[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride ][1]; + P_TOPRIGHT[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + 2][0]; + P_TOPRIGHT[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + 2][1]; if(P_TOP[1] > (c->ymax<ymax<xmin<xmin< (c->ymax<ymax<last_dc[i] + 4)>>3; } - dest_c = s->new_picture.data[i] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; + dest_c = s->new_picture.f.data[i] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; mean*= 0x01010101; for(i=0; i<8; i++){ @@ -1242,9 +1242,9 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, if(intra_score < dmin){ mb_type= CANDIDATE_MB_TYPE_INTRA; - s->current_picture.mb_type[mb_y*s->mb_stride + mb_x]= CANDIDATE_MB_TYPE_INTRA; //FIXME cleanup + s->current_picture.f.mb_type[mb_y*s->mb_stride + mb_x] = CANDIDATE_MB_TYPE_INTRA; //FIXME cleanup }else - s->current_picture.mb_type[mb_y*s->mb_stride + mb_x]= 0; + s->current_picture.f.mb_type[mb_y*s->mb_stride + mb_x] = 0; { int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100); @@ -1264,7 +1264,7 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s, int P[10][2]; const int shift= 1+s->quarter_sample; const int xy= mb_x + mb_y*s->mb_stride; - init_ref(c, s->new_picture.data, s->last_picture.data, NULL, 16*mb_x, 16*mb_y, 0); + init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0); assert(s->quarter_sample==0 || s->quarter_sample==1); @@ -1615,7 +1615,7 @@ static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y) ymin= xmin=(-32)>>shift; ymax= xmax= 31>>shift; - if(IS_8X8(s->next_picture.mb_type[mot_xy])){ + if (IS_8X8(s->next_picture.f.mb_type[mot_xy])) { s->mv_type= MV_TYPE_8X8; }else{ s->mv_type= MV_TYPE_16X16; @@ -1625,8 +1625,8 @@ static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y) int index= s->block_index[i]; int min, max; - c->co_located_mv[i][0]= s->next_picture.motion_val[0][index][0]; - c->co_located_mv[i][1]= s->next_picture.motion_val[0][index][1]; + c->co_located_mv[i][0] = s->next_picture.f.motion_val[0][index][0]; + c->co_located_mv[i][1] = s->next_picture.f.motion_val[0][index][1]; c->direct_basis_mv[i][0]= c->co_located_mv[i][0]*time_pb/time_pp + ((i& 1)<<(shift+3)); c->direct_basis_mv[i][1]= c->co_located_mv[i][1]*time_pb/time_pp + ((i>>1)<<(shift+3)); // c->direct_basis_mv[1][i][0]= c->co_located_mv[i][0]*(time_pb - time_pp)/time_pp + ((i &1)<<(shift+3); @@ -1708,13 +1708,14 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, int fmin, bmin, dmin, fbmin, bimin, fimin; int type=0; const int xy = mb_y*s->mb_stride + mb_x; - init_ref(c, s->new_picture.data, s->last_picture.data, s->next_picture.data, 16*mb_x, 16*mb_y, 2); + init_ref(c, s->new_picture.f.data, s->last_picture.f.data, + s->next_picture.f.data, 16 * mb_x, 16 * mb_y, 2); get_limits(s, 16*mb_x, 16*mb_y); c->skip=0; - if(s->codec_id == CODEC_ID_MPEG4 && s->next_picture.mbskip_table[xy]){ + if (s->codec_id == CODEC_ID_MPEG4 && s->next_picture.f.mbskip_table[xy]) { int score= direct_search(s, mb_x, mb_y); //FIXME just check 0,0 score= ((unsigned)(score*score + 128*256))>>16; @@ -1947,14 +1948,14 @@ void ff_fix_long_p_mvs(MpegEncContext * s) int block; for(block=0; block<4; block++){ int off= (block& 1) + (block>>1)*wrap; - int mx= s->current_picture.motion_val[0][ xy + off ][0]; - int my= s->current_picture.motion_val[0][ xy + off ][1]; + int mx = s->current_picture.f.motion_val[0][ xy + off ][0]; + int my = s->current_picture.f.motion_val[0][ xy + off ][1]; if( mx >=range || mx <-range || my >=range || my <-range){ s->mb_type[i] &= ~CANDIDATE_MB_TYPE_INTER4V; s->mb_type[i] |= CANDIDATE_MB_TYPE_INTRA; - s->current_picture.mb_type[i]= CANDIDATE_MB_TYPE_INTRA; + s->current_picture.f.mb_type[i] = CANDIDATE_MB_TYPE_INTRA; } } } diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 986cad5fd2..4cbfa8d636 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -221,20 +221,20 @@ static int mpeg_decode_mb(MpegEncContext *s, if (s->mb_skip_run-- != 0) { if (s->pict_type == AV_PICTURE_TYPE_P) { s->mb_skipped = 1; - s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16; + s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride] = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16; } else { int mb_type; if(s->mb_x) - mb_type= s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]; + mb_type = s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1]; else - mb_type= s->current_picture.mb_type[ s->mb_width + (s->mb_y-1)*s->mb_stride - 1]; // FIXME not sure if this is allowed in MPEG at all + mb_type = s->current_picture.f.mb_type[s->mb_width + (s->mb_y - 1) * s->mb_stride - 1]; // FIXME not sure if this is allowed in MPEG at all if(IS_INTRA(mb_type)) return -1; - s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= + s->current_picture.f.mb_type[s->mb_x + s->mb_y*s->mb_stride] = mb_type | MB_TYPE_SKIP; -// assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8)); +// assert(s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8)); if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0) s->mb_skipped = 1; @@ -577,7 +577,7 @@ static int mpeg_decode_mb(MpegEncContext *s, } } - s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= mb_type; + s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride] = mb_type; return 0; } @@ -1385,8 +1385,8 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, s->mpeg_f_code[1][0] = f_code; s->mpeg_f_code[1][1] = f_code; } - s->current_picture.pict_type= s->pict_type; - s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I; + s->current_picture.f.pict_type = s->pict_type; + s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; if(avctx->debug & FF_DEBUG_PICT_INFO) av_log(avctx, AV_LOG_DEBUG, "vbv_delay %d, ref %d type:%d\n", vbv_delay, ref, s->pict_type); @@ -1539,8 +1539,8 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1) s->pict_type= AV_PICTURE_TYPE_P; }else s->pict_type= AV_PICTURE_TYPE_B; - s->current_picture.pict_type= s->pict_type; - s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I; + s->current_picture.f.pict_type = s->pict_type; + s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; } s->intra_dc_precision = get_bits(&s->gb, 2); s->picture_structure = get_bits(&s->gb, 2); @@ -1618,19 +1618,19 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) ff_er_frame_start(s); /* first check if we must repeat the frame */ - s->current_picture_ptr->repeat_pict = 0; + s->current_picture_ptr->f.repeat_pict = 0; if (s->repeat_first_field) { if (s->progressive_sequence) { if (s->top_field_first) - s->current_picture_ptr->repeat_pict = 4; + s->current_picture_ptr->f.repeat_pict = 4; else - s->current_picture_ptr->repeat_pict = 2; + s->current_picture_ptr->f.repeat_pict = 2; } else if (s->progressive_frame) { - s->current_picture_ptr->repeat_pict = 1; + s->current_picture_ptr->f.repeat_pict = 1; } } - *s->current_picture_ptr->pan_scan= s1->pan_scan; + *s->current_picture_ptr->f.pan_scan = s1->pan_scan; if (HAVE_PTHREADS && (avctx->active_thread_type & FF_THREAD_FRAME)) ff_thread_finish_setup(avctx); @@ -1643,9 +1643,9 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) } for(i=0; i<4; i++){ - s->current_picture.data[i] = s->current_picture_ptr->data[i]; + s->current_picture.f.data[i] = s->current_picture_ptr->f.data[i]; if(s->picture_structure == PICT_BOTTOM_FIELD){ - s->current_picture.data[i] += s->current_picture_ptr->linesize[i]; + s->current_picture.f.data[i] += s->current_picture_ptr->f.linesize[i]; } } } @@ -1767,7 +1767,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, if(mpeg_decode_mb(s, s->block) < 0) return -1; - if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs + if (s->current_picture.f.motion_val[0] && !s->encoding) { //note motion_val is normally NULL unless we want to extract the MVs const int wrap = s->b8_stride; int xy = s->mb_x*2 + s->mb_y*2*wrap; int b8_xy= 4*(s->mb_x + s->mb_y*s->mb_stride); @@ -1785,12 +1785,12 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, motion_y = s->mv[dir][i][1]; } - s->current_picture.motion_val[dir][xy ][0] = motion_x; - s->current_picture.motion_val[dir][xy ][1] = motion_y; - s->current_picture.motion_val[dir][xy + 1][0] = motion_x; - s->current_picture.motion_val[dir][xy + 1][1] = motion_y; - s->current_picture.ref_index [dir][b8_xy ]= - s->current_picture.ref_index [dir][b8_xy + 1]= s->field_select[dir][i]; + s->current_picture.f.motion_val[dir][xy ][0] = motion_x; + s->current_picture.f.motion_val[dir][xy ][1] = motion_y; + s->current_picture.f.motion_val[dir][xy + 1][0] = motion_x; + s->current_picture.f.motion_val[dir][xy + 1][1] = motion_y; + s->current_picture.f.ref_index [dir][b8_xy ] = + s->current_picture.f.ref_index [dir][b8_xy + 1] = s->field_select[dir][i]; assert(s->field_select[dir][i]==0 || s->field_select[dir][i]==1); } xy += wrap; @@ -1954,7 +1954,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict) if (/*s->mb_y<mb_height &&*/ !s->first_field) { /* end of image */ - s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG2; + s->current_picture_ptr->f.qscale_type = FF_QSCALE_TYPE_MPEG2; ff_er_frame_end(s); diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index eb07ecfc5e..31ac515efe 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -200,7 +200,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) if(aspect_ratio==0.0) aspect_ratio= 1.0; //pixel aspect 1:1 (VGA) - if (s->current_picture.key_frame) { + if (s->current_picture.f.key_frame) { AVRational framerate= ff_frame_rate_tab[s->frame_rate_index]; /* mpeg1 header repeated every gop */ @@ -287,9 +287,9 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) /* time code : we must convert from the real frame rate to a fake mpeg frame rate in case of low frame rate */ fps = (framerate.num + framerate.den/2)/ framerate.den; - time_code = s->current_picture_ptr->coded_picture_number + s->avctx->timecode_frame_start; + time_code = s->current_picture_ptr->f.coded_picture_number + s->avctx->timecode_frame_start; - s->gop_picture_number = s->current_picture_ptr->coded_picture_number; + s->gop_picture_number = s->current_picture_ptr->f.coded_picture_number; if (s->avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE) { /* only works for NTSC 29.97 */ int d = time_code / 17982; @@ -396,7 +396,7 @@ void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number) if (s->progressive_sequence) { put_bits(&s->pb, 1, 0); /* no repeat */ } else { - put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first); + put_bits(&s->pb, 1, s->current_picture_ptr->f.top_field_first); } /* XXX: optimize the generation of this flag with entropy measures */ diff --git a/libavcodec/mpeg4video.c b/libavcodec/mpeg4video.c index a4dc80a420..130e9b2050 100644 --- a/libavcodec/mpeg4video.c +++ b/libavcodec/mpeg4video.c @@ -89,7 +89,7 @@ static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, int my, uint16_t time_pb= s->pb_time; int p_mx, p_my; - p_mx= s->next_picture.motion_val[0][xy][0]; + p_mx = s->next_picture.f.motion_val[0][xy][0]; if((unsigned)(p_mx + tab_bias) < tab_size){ s->mv[0][i][0] = s->direct_scale_mv[0][p_mx + tab_bias] + mx; s->mv[1][i][0] = mx ? s->mv[0][i][0] - p_mx @@ -99,7 +99,7 @@ static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, int my, s->mv[1][i][0] = mx ? s->mv[0][i][0] - p_mx : p_mx*(time_pb - time_pp)/time_pp; } - p_my= s->next_picture.motion_val[0][xy][1]; + p_my = s->next_picture.f.motion_val[0][xy][1]; if((unsigned)(p_my + tab_bias) < tab_size){ s->mv[0][i][1] = s->direct_scale_mv[0][p_my + tab_bias] + my; s->mv[1][i][1] = my ? s->mv[0][i][1] - p_my @@ -120,7 +120,7 @@ static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, int my, */ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){ const int mb_index= s->mb_x + s->mb_y*s->mb_stride; - const int colocated_mb_type= s->next_picture.mb_type[mb_index]; + const int colocated_mb_type = s->next_picture.f.mb_type[mb_index]; uint16_t time_pp; uint16_t time_pb; int i; @@ -137,7 +137,7 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){ } else if(IS_INTERLACED(colocated_mb_type)){ s->mv_type = MV_TYPE_FIELD; for(i=0; i<2; i++){ - int field_select= s->next_picture.ref_index[0][4*mb_index + 2*i]; + int field_select = s->next_picture.f.ref_index[0][4 * mb_index + 2 * i]; s->field_select[0][i]= field_select; s->field_select[1][i]= i; if(s->top_field_first){ diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 22d7ace789..df0191dc9f 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -55,7 +55,7 @@ void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n, { int i; int16_t *ac_val, *ac_val1; - int8_t * const qscale_table= s->current_picture.qscale_table; + int8_t * const qscale_table = s->current_picture.f.qscale_table; /* find prediction */ ac_val = s->ac_val[0][0] + s->block_index[n] * 16; @@ -376,7 +376,7 @@ int mpeg4_decode_video_packet_header(MpegEncContext *s) if(s->pict_type == AV_PICTURE_TYPE_B){ int mb_x = 0, mb_y = 0; - while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) { + while (s->next_picture.f.mbskip_table[s->mb_index2xy[mb_num]]) { if (!mb_x) ff_thread_await_progress((AVFrame*)s->next_picture_ptr, mb_y++, 0); mb_num++; if (++mb_x == s->mb_width) mb_x = 0; @@ -570,13 +570,13 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){ }while(cbpc == 8); s->cbp_table[xy]= cbpc & 3; - s->current_picture.mb_type[xy]= MB_TYPE_INTRA; + s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA; s->mb_intra = 1; if(cbpc & 4) { ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]); } - s->current_picture.qscale_table[xy]= s->qscale; + s->current_picture.f.qscale_table[xy]= s->qscale; s->mbintra_table[xy]= 1; for(i=0; i<6; i++){ @@ -592,7 +592,7 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){ s->pred_dir_table[xy]= dir; }else{ /* P/S_TYPE */ int mx, my, pred_x, pred_y, bits; - int16_t * const mot_val= s->current_picture.motion_val[0][s->block_index[0]]; + int16_t * const mot_val = s->current_picture.f.motion_val[0][s->block_index[0]]; const int stride= s->b8_stride*2; try_again: @@ -604,11 +604,11 @@ try_again: if(bits&0x10000){ /* skip mb */ if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){ - s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0; mx= get_amv(s, 0); my= get_amv(s, 1); }else{ - s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; mx=my=0; } mot_val[0 ]= mot_val[2 ]= @@ -634,7 +634,7 @@ try_again: s->mb_intra = ((cbpc & 4) != 0); if(s->mb_intra){ - s->current_picture.mb_type[xy]= MB_TYPE_INTRA; + s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA; s->mbintra_table[xy]= 1; mot_val[0 ]= mot_val[2 ]= mot_val[0+stride]= mot_val[2+stride]= 0; @@ -660,11 +660,11 @@ try_again: my = h263_decode_motion(s, pred_y, s->f_code); if (my >= 0xffff) return -1; - s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0; } else { mx = get_amv(s, 0); my = get_amv(s, 1); - s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0; } mot_val[0 ]= mot_val[2 ] = @@ -673,7 +673,7 @@ try_again: mot_val[1+stride]= mot_val[3+stride]= my; } else { int i; - s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0; for(i=0;i<4;i++) { int16_t *mot_val= h263_pred_motion(s, i, 0, &pred_x, &pred_y); mx = h263_decode_motion(s, pred_x, s->f_code); @@ -725,9 +725,9 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){ } s->cbp_table[xy]|= cbpy<<2; - s->current_picture.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED; + s->current_picture.f.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED; }else{ /* P || S_TYPE */ - if(IS_INTRA(s->current_picture.mb_type[xy])){ + if (IS_INTRA(s->current_picture.f.mb_type[xy])) { int dir=0,i; int ac_pred = get_bits1(&s->gb); int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); @@ -740,7 +740,7 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){ if(s->cbp_table[xy] & 8) { ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]); } - s->current_picture.qscale_table[xy]= s->qscale; + s->current_picture.f.qscale_table[xy] = s->qscale; for(i=0; i<6; i++){ int dc_pred_dir; @@ -754,10 +754,10 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){ } s->cbp_table[xy]&= 3; //remove dquant s->cbp_table[xy]|= cbpy<<2; - s->current_picture.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED; + s->current_picture.f.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED; s->pred_dir_table[xy]= dir; - }else if(IS_SKIP(s->current_picture.mb_type[xy])){ - s->current_picture.qscale_table[xy]= s->qscale; + } else if (IS_SKIP(s->current_picture.f.mb_type[xy])) { + s->current_picture.f.qscale_table[xy] = s->qscale; s->cbp_table[xy]= 0; }else{ int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); @@ -770,7 +770,7 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){ if(s->cbp_table[xy] & 8) { ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]); } - s->current_picture.qscale_table[xy]= s->qscale; + s->current_picture.f.qscale_table[xy] = s->qscale; s->cbp_table[xy]&= 3; //remove dquant s->cbp_table[xy]|= (cbpy^0xf)<<2; @@ -1091,20 +1091,20 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64]) int cbp, mb_type; const int xy= s->mb_x + s->mb_y*s->mb_stride; - mb_type= s->current_picture.mb_type[xy]; + mb_type = s->current_picture.f.mb_type[xy]; cbp = s->cbp_table[xy]; s->use_intra_dc_vlc= s->qscale < s->intra_dc_threshold; - if(s->current_picture.qscale_table[xy] != s->qscale){ - ff_set_qscale(s, s->current_picture.qscale_table[xy] ); + if (s->current_picture.f.qscale_table[xy] != s->qscale) { + ff_set_qscale(s, s->current_picture.f.qscale_table[xy]); } if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) { int i; for(i=0; i<4; i++){ - s->mv[0][i][0] = s->current_picture.motion_val[0][ s->block_index[i] ][0]; - s->mv[0][i][1] = s->current_picture.motion_val[0][ s->block_index[i] ][1]; + s->mv[0][i][0] = s->current_picture.f.motion_val[0][s->block_index[i]][0]; + s->mv[0][i][1] = s->current_picture.f.motion_val[0][s->block_index[i]][1]; } s->mb_intra = IS_INTRA(mb_type); @@ -1122,7 +1122,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64]) s->mb_skipped = 1; } }else if(s->mb_intra){ - s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]); + s->ac_pred = IS_ACPRED(s->current_picture.f.mb_type[xy]); }else if(!s->mb_intra){ // s->mcsel= 0; //FIXME do we need to init that @@ -1135,7 +1135,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64]) } } else { /* I-Frame */ s->mb_intra = 1; - s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]); + s->ac_pred = IS_ACPRED(s->current_picture.f.mb_type[xy]); } if (!IS_SKIP(mb_type)) { @@ -1188,14 +1188,14 @@ static int mpeg4_decode_mb(MpegEncContext *s, s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){ - s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0; s->mcsel=1; s->mv[0][0][0]= get_amv(s, 0); s->mv[0][0][1]= get_amv(s, 1); s->mb_skipped = 0; }else{ - s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; s->mcsel=0; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; @@ -1230,7 +1230,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, s->mv_dir = MV_DIR_FORWARD; if ((cbpc & 16) == 0) { if(s->mcsel){ - s->current_picture.mb_type[xy]= MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0; /* 16x16 global motion prediction */ s->mv_type = MV_TYPE_16X16; mx= get_amv(s, 0); @@ -1238,7 +1238,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, s->mv[0][0][0] = mx; s->mv[0][0][1] = my; }else if((!s->progressive_sequence) && get_bits1(&s->gb)){ - s->current_picture.mb_type[xy]= MB_TYPE_16x8 | MB_TYPE_L0 | MB_TYPE_INTERLACED; + s->current_picture.f.mb_type[xy] = MB_TYPE_16x8 | MB_TYPE_L0 | MB_TYPE_INTERLACED; /* 16x8 field motion prediction */ s->mv_type= MV_TYPE_FIELD; @@ -1260,7 +1260,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, s->mv[0][i][1] = my; } }else{ - s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0; /* 16x16 motion prediction */ s->mv_type = MV_TYPE_16X16; h263_pred_motion(s, 0, 0, &pred_x, &pred_y); @@ -1277,7 +1277,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, s->mv[0][0][1] = my; } } else { - s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0; s->mv_type = MV_TYPE_8X8; for(i=0;i<4;i++) { mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y); @@ -1314,7 +1314,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, } /* if we skipped it in the future P Frame than skip it now too */ - s->mb_skipped= s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC + s->mb_skipped = s->next_picture.f.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC if(s->mb_skipped){ /* skip mb */ @@ -1327,7 +1327,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, s->mv[0][0][1] = 0; s->mv[1][0][0] = 0; s->mv[1][0][1] = 0; - s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; + s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; goto end; } @@ -1433,7 +1433,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; mb_type |= ff_mpeg4_set_direct_mv(s, mx, my); } - s->current_picture.mb_type[xy]= mb_type; + s->current_picture.f.mb_type[xy] = mb_type; } else { /* I-Frame */ do{ cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2); @@ -1448,9 +1448,9 @@ static int mpeg4_decode_mb(MpegEncContext *s, intra: s->ac_pred = get_bits1(&s->gb); if(s->ac_pred) - s->current_picture.mb_type[xy]= MB_TYPE_INTRA | MB_TYPE_ACPRED; + s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED; else - s->current_picture.mb_type[xy]= MB_TYPE_INTRA; + s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA; cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); if(cbpy<0){ @@ -1491,12 +1491,12 @@ end: if(mpeg4_is_resync(s)){ const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1; - if(s->pict_type==AV_PICTURE_TYPE_B && s->next_picture.mbskip_table[xy + delta]){ + if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture.f.mbskip_table[xy + delta]) { ff_thread_await_progress((AVFrame*)s->next_picture_ptr, (s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y, 0); } - if(s->pict_type==AV_PICTURE_TYPE_B && s->next_picture.mbskip_table[xy + delta]) + if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture.f.mbskip_table[xy + delta]) return SLICE_OK; return SLICE_END; } @@ -1961,11 +1961,12 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){ } if(s->avctx->time_base.num) - s->current_picture_ptr->pts= (s->time + s->avctx->time_base.num/2) / s->avctx->time_base.num; + s->current_picture_ptr->f.pts = (s->time + s->avctx->time_base.num / 2) / s->avctx->time_base.num; else - s->current_picture_ptr->pts= AV_NOPTS_VALUE; + s->current_picture_ptr->f.pts = AV_NOPTS_VALUE; if(s->avctx->debug&FF_DEBUG_PTS) - av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %"PRId64"\n", s->current_picture_ptr->pts); + av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %"PRId64"\n", + s->current_picture_ptr->f.pts); check_marker(gb, "before vop_coded"); diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 8a044d6d23..741c5971fb 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -124,7 +124,7 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], const { int score= 0; int i, n; - int8_t * const qscale_table= s->current_picture.qscale_table; + int8_t * const qscale_table = s->current_picture.f.qscale_table; memcpy(zigzag_last_index, s->block_last_index, sizeof(int)*6); @@ -201,7 +201,7 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], const */ void ff_clean_mpeg4_qscales(MpegEncContext *s){ int i; - int8_t * const qscale_table= s->current_picture.qscale_table; + int8_t * const qscale_table = s->current_picture.f.qscale_table; ff_clean_h263_qscales(s); @@ -457,7 +457,7 @@ void mpeg4_encode_mb(MpegEncContext * s, assert(mb_type>=0); /* nothing to do if this MB was skipped in the next P Frame */ - if(s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]){ //FIXME avoid DCT & ... + if (s->next_picture.f.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]) { //FIXME avoid DCT & ... s->skip_count++; s->mv[0][0][0]= s->mv[0][0][1]= @@ -589,7 +589,7 @@ void mpeg4_encode_mb(MpegEncContext * s, if(y+16 > s->height) y= s->height-16; offset= x + y*s->linesize; - p_pic= s->new_picture.data[0] + offset; + p_pic = s->new_picture.f.data[0] + offset; s->mb_skipped=1; for(i=0; imax_b_frames; i++){ @@ -597,10 +597,11 @@ void mpeg4_encode_mb(MpegEncContext * s, int diff; Picture *pic= s->reordered_input_picture[i+1]; - if(pic==NULL || pic->pict_type!=AV_PICTURE_TYPE_B) break; + if (pic == NULL || pic->f.pict_type != AV_PICTURE_TYPE_B) + break; - b_pic= pic->data[0] + offset; - if(pic->type != FF_BUFFER_TYPE_SHARED) + b_pic = pic->f.data[0] + offset; + if (pic->f.type != FF_BUFFER_TYPE_SHARED) b_pic+= INPLACE_OFFSET; diff= s->dsp.sad[0](NULL, p_pic, b_pic, s->linesize, 16); if(diff>s->qscale*70){ //FIXME check that 70 is optimal @@ -704,8 +705,8 @@ void mpeg4_encode_mb(MpegEncContext * s, /* motion vectors: 8x8 mode*/ h263_pred_motion(s, i, 0, &pred_x, &pred_y); - ff_h263_encode_motion_vector(s, s->current_picture.motion_val[0][ s->block_index[i] ][0] - pred_x, - s->current_picture.motion_val[0][ s->block_index[i] ][1] - pred_y, s->f_code); + ff_h263_encode_motion_vector(s, s->current_picture.f.motion_val[0][ s->block_index[i] ][0] - pred_x, + s->current_picture.f.motion_val[0][ s->block_index[i] ][1] - pred_y, s->f_code); } } @@ -814,9 +815,9 @@ static void mpeg4_encode_gop_header(MpegEncContext * s){ put_bits(&s->pb, 16, 0); put_bits(&s->pb, 16, GOP_STARTCODE); - time= s->current_picture_ptr->pts; + time = s->current_picture_ptr->f.pts; if(s->reordered_input_picture[1]) - time= FFMIN(time, s->reordered_input_picture[1]->pts); + time = FFMIN(time, s->reordered_input_picture[1]->f.pts); time= time*s->avctx->time_base.num; seconds= time/s->avctx->time_base.den; @@ -1026,7 +1027,7 @@ void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number) } put_bits(&s->pb, 3, 0); /* intra dc VLC threshold */ if(!s->progressive_sequence){ - put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first); + put_bits(&s->pb, 1, s->current_picture_ptr->f.top_field_first); put_bits(&s->pb, 1, s->alternate_scan); } //FIXME sprite stuff diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index aec75b541e..27dcd74a5a 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -198,7 +198,7 @@ av_cold int ff_dct_common_init(MpegEncContext *s) void ff_copy_picture(Picture *dst, Picture *src){ *dst = *src; - dst->type= FF_BUFFER_TYPE_COPY; + dst->f.type= FF_BUFFER_TYPE_COPY; } /** @@ -207,7 +207,7 @@ void ff_copy_picture(Picture *dst, Picture *src){ static void free_frame_buffer(MpegEncContext *s, Picture *pic) { ff_thread_release_buffer(s->avctx, (AVFrame*)pic); - av_freep(&pic->hwaccel_picture_private); + av_freep(&pic->f.hwaccel_picture_private); } /** @@ -220,8 +220,8 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) if (s->avctx->hwaccel) { assert(!pic->hwaccel_picture_private); if (s->avctx->hwaccel->priv_data_size) { - pic->hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size); - if (!pic->hwaccel_picture_private) { + pic->f.hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size); + if (!pic->f.hwaccel_picture_private) { av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n"); return -1; } @@ -230,19 +230,20 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) r = ff_thread_get_buffer(s->avctx, (AVFrame*)pic); - if (r<0 || !pic->age || !pic->type || !pic->data[0]) { - av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]); - av_freep(&pic->hwaccel_picture_private); + if (r < 0 || !pic->f.age || !pic->f.type || !pic->f.data[0]) { + av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", + r, pic->f.age, pic->f.type, pic->f.data[0]); + av_freep(&pic->f.hwaccel_picture_private); return -1; } - if (s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])) { + if (s->linesize && (s->linesize != pic->f.linesize[0] || s->uvlinesize != pic->f.linesize[1])) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n"); free_frame_buffer(s, pic); return -1; } - if (pic->linesize[1] != pic->linesize[2]) { + if (pic->f.linesize[1] != pic->f.linesize[2]) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n"); free_frame_buffer(s, pic); return -1; @@ -264,59 +265,59 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){ int r= -1; if(shared){ - assert(pic->data[0]); + assert(pic->f.data[0]); assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED); - pic->type= FF_BUFFER_TYPE_SHARED; + pic->f.type = FF_BUFFER_TYPE_SHARED; }else{ - assert(!pic->data[0]); + assert(!pic->f.data[0]); if (alloc_frame_buffer(s, pic) < 0) return -1; - s->linesize = pic->linesize[0]; - s->uvlinesize= pic->linesize[1]; + s->linesize = pic->f.linesize[0]; + s->uvlinesize = pic->f.linesize[1]; } - if(pic->qscale_table==NULL){ + if (pic->f.qscale_table == NULL) { if (s->encoding) { FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_var , mb_array_size * sizeof(int16_t) , fail) FF_ALLOCZ_OR_GOTO(s->avctx, pic->mc_mb_var, mb_array_size * sizeof(int16_t) , fail) FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_mean , mb_array_size * sizeof(int8_t ) , fail) } - FF_ALLOCZ_OR_GOTO(s->avctx, pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2, fail) //the +2 is for the slice end check + FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.mbskip_table, mb_array_size * sizeof(uint8_t) + 2, fail) //the +2 is for the slice end check FF_ALLOCZ_OR_GOTO(s->avctx, pic->qscale_table_base , (big_mb_num + s->mb_stride) * sizeof(uint8_t) , fail) FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_type_base , (big_mb_num + s->mb_stride) * sizeof(uint32_t), fail) - pic->mb_type= pic->mb_type_base + 2*s->mb_stride+1; - pic->qscale_table = pic->qscale_table_base + 2*s->mb_stride + 1; + pic->f.mb_type = pic->mb_type_base + 2*s->mb_stride + 1; + pic->f.qscale_table = pic->qscale_table_base + 2*s->mb_stride + 1; if(s->out_format == FMT_H264){ for(i=0; i<2; i++){ FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b4_array_size+4) * sizeof(int16_t), fail) - pic->motion_val[i]= pic->motion_val_base[i]+4; - FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail) + pic->f.motion_val[i] = pic->motion_val_base[i] + 4; + FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail) } - pic->motion_subsample_log2= 2; + pic->f.motion_subsample_log2 = 2; }else if(s->out_format == FMT_H263 || s->encoding || (s->avctx->debug&FF_DEBUG_MV) || (s->avctx->debug_mv)){ for(i=0; i<2; i++){ FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b8_array_size+4) * sizeof(int16_t), fail) - pic->motion_val[i]= pic->motion_val_base[i]+4; - FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail) + pic->f.motion_val[i] = pic->motion_val_base[i] + 4; + FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail) } - pic->motion_subsample_log2= 3; + pic->f.motion_subsample_log2 = 3; } if(s->avctx->debug&FF_DEBUG_DCT_COEFF) { - FF_ALLOCZ_OR_GOTO(s->avctx, pic->dct_coeff, 64 * mb_array_size * sizeof(DCTELEM)*6, fail) + FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.dct_coeff, 64 * mb_array_size * sizeof(DCTELEM) * 6, fail) } - pic->qstride= s->mb_stride; - FF_ALLOCZ_OR_GOTO(s->avctx, pic->pan_scan , 1 * sizeof(AVPanScan), fail) + pic->f.qstride = s->mb_stride; + FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.pan_scan , 1 * sizeof(AVPanScan), fail) } /* It might be nicer if the application would keep track of these * but it would require an API change. */ memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1); s->prev_pict_types[0]= s->dropable ? AV_PICTURE_TYPE_B : s->pict_type; - if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == AV_PICTURE_TYPE_B) - pic->age= INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway. + if (pic->f.age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->f.age] == AV_PICTURE_TYPE_B) + pic->f.age = INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway. pic->owner2 = NULL; return 0; @@ -332,30 +333,30 @@ fail: //for the FF_ALLOCZ_OR_GOTO macro static void free_picture(MpegEncContext *s, Picture *pic){ int i; - if(pic->data[0] && pic->type!=FF_BUFFER_TYPE_SHARED){ + if (pic->f.data[0] && pic->f.type != FF_BUFFER_TYPE_SHARED) { free_frame_buffer(s, pic); } av_freep(&pic->mb_var); av_freep(&pic->mc_mb_var); av_freep(&pic->mb_mean); - av_freep(&pic->mbskip_table); + av_freep(&pic->f.mbskip_table); av_freep(&pic->qscale_table_base); av_freep(&pic->mb_type_base); - av_freep(&pic->dct_coeff); - av_freep(&pic->pan_scan); - pic->mb_type= NULL; + av_freep(&pic->f.dct_coeff); + av_freep(&pic->f.pan_scan); + pic->f.mb_type = NULL; for(i=0; i<2; i++){ av_freep(&pic->motion_val_base[i]); - av_freep(&pic->ref_index[i]); + av_freep(&pic->f.ref_index[i]); } - if(pic->type == FF_BUFFER_TYPE_SHARED){ + if (pic->f.type == FF_BUFFER_TYPE_SHARED) { for(i=0; i<4; i++){ - pic->base[i]= - pic->data[i]= NULL; + pic->f.base[i] = + pic->f.data[i] = NULL; } - pic->type= 0; + pic->f.type = 0; } } @@ -526,7 +527,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src if(!s1->first_field){ s->last_pict_type= s1->pict_type; - if (s1->current_picture_ptr) s->last_lambda_for[s1->pict_type] = s1->current_picture_ptr->quality; + if (s1->current_picture_ptr) s->last_lambda_for[s1->pict_type] = s1->current_picture_ptr->f.quality; if(s1->pict_type!=FF_B_TYPE){ s->last_non_b_pict_type= s1->pict_type; @@ -965,7 +966,7 @@ void ff_release_unused_pictures(MpegEncContext *s, int remove_current) /* release non reference frames */ for(i=0; ipicture_count; i++){ - if(s->picture[i].data[0] && !s->picture[i].reference + if (s->picture[i].f.data[0] && !s->picture[i].f.reference && (!s->picture[i].owner2 || s->picture[i].owner2 == s) && (remove_current || &s->picture[i] != s->current_picture_ptr) /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){ @@ -979,14 +980,17 @@ int ff_find_unused_picture(MpegEncContext *s, int shared){ if(shared){ for(i=s->picture_range_start; ipicture_range_end; i++){ - if(s->picture[i].data[0]==NULL && s->picture[i].type==0) return i; + if (s->picture[i].f.data[0] == NULL && s->picture[i].f.type == 0) + return i; } }else{ for(i=s->picture_range_start; ipicture_range_end; i++){ - if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) return i; //FIXME + if (s->picture[i].f.data[0] == NULL && s->picture[i].f.type != 0) + return i; //FIXME } for(i=s->picture_range_start; ipicture_range_end; i++){ - if(s->picture[i].data[0]==NULL) return i; + if (s->picture[i].f.data[0] == NULL) + return i; } } @@ -1035,7 +1039,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3); /* mark&release old frames */ - if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) { + if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->f.data[0]) { if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){ free_frame_buffer(s, s->last_picture_ptr); @@ -1043,7 +1047,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) /* if(mpeg124/h263) */ if(!s->encoding){ for(i=0; ipicture_count; i++){ - if(s->picture[i].data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].reference){ + if (s->picture[i].f.data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].f.reference) { av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n"); free_frame_buffer(s, &s->picture[i]); } @@ -1055,41 +1059,41 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) if(!s->encoding){ ff_release_unused_pictures(s, 1); - if(s->current_picture_ptr && s->current_picture_ptr->data[0]==NULL) + if (s->current_picture_ptr && s->current_picture_ptr->f.data[0] == NULL) pic= s->current_picture_ptr; //we already have a unused image (maybe it was set before reading the header) else{ i= ff_find_unused_picture(s, 0); pic= &s->picture[i]; } - pic->reference= 0; + pic->f.reference = 0; if (!s->dropable){ if (s->codec_id == CODEC_ID_H264) - pic->reference = s->picture_structure; + pic->f.reference = s->picture_structure; else if (s->pict_type != AV_PICTURE_TYPE_B) - pic->reference = 3; + pic->f.reference = 3; } - pic->coded_picture_number= s->coded_picture_number++; + pic->f.coded_picture_number = s->coded_picture_number++; if(ff_alloc_picture(s, pic, 0) < 0) return -1; s->current_picture_ptr= pic; //FIXME use only the vars from current_pic - s->current_picture_ptr->top_field_first= s->top_field_first; + s->current_picture_ptr->f.top_field_first = s->top_field_first; if(s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO) { if(s->picture_structure != PICT_FRAME) - s->current_picture_ptr->top_field_first= (s->picture_structure == PICT_TOP_FIELD) == s->first_field; + s->current_picture_ptr->f.top_field_first = (s->picture_structure == PICT_TOP_FIELD) == s->first_field; } - s->current_picture_ptr->interlaced_frame= !s->progressive_frame && !s->progressive_sequence; - s->current_picture_ptr->field_picture= s->picture_structure != PICT_FRAME; + s->current_picture_ptr->f.interlaced_frame = !s->progressive_frame && !s->progressive_sequence; + s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME; } - s->current_picture_ptr->pict_type= s->pict_type; + s->current_picture_ptr->f.pict_type = s->pict_type; // if(s->flags && CODEC_FLAG_QSCALE) // s->current_picture_ptr->quality= s->new_picture_ptr->quality; - s->current_picture_ptr->key_frame= s->pict_type == AV_PICTURE_TYPE_I; + s->current_picture_ptr->f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; ff_copy_picture(&s->current_picture, s->current_picture_ptr); @@ -1099,13 +1103,13 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) s->next_picture_ptr= s->current_picture_ptr; } /* av_log(s->avctx, AV_LOG_DEBUG, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n", s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr, - s->last_picture_ptr ? s->last_picture_ptr->data[0] : NULL, - s->next_picture_ptr ? s->next_picture_ptr->data[0] : NULL, - s->current_picture_ptr ? s->current_picture_ptr->data[0] : NULL, + s->last_picture_ptr ? s->last_picture_ptr->f.data[0] : NULL, + s->next_picture_ptr ? s->next_picture_ptr->f.data[0] : NULL, + s->current_picture_ptr ? s->current_picture_ptr->f.data[0] : NULL, s->pict_type, s->dropable);*/ if(s->codec_id != CODEC_ID_H264){ - if((s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && + if ((s->last_picture_ptr == NULL || s->last_picture_ptr->f.data[0] == NULL) && (s->pict_type!=AV_PICTURE_TYPE_I || s->picture_structure != PICT_FRAME)){ if (s->pict_type != AV_PICTURE_TYPE_I) av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n"); @@ -1120,7 +1124,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 0); ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 1); } - if((s->next_picture_ptr==NULL || s->next_picture_ptr->data[0]==NULL) && s->pict_type==AV_PICTURE_TYPE_B){ + if ((s->next_picture_ptr == NULL || s->next_picture_ptr->f.data[0] == NULL) && s->pict_type == AV_PICTURE_TYPE_B) { /* Allocate a dummy frame */ i= ff_find_unused_picture(s, 0); s->next_picture_ptr= &s->picture[i]; @@ -1134,17 +1138,17 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) if(s->last_picture_ptr) ff_copy_picture(&s->last_picture, s->last_picture_ptr); if(s->next_picture_ptr) ff_copy_picture(&s->next_picture, s->next_picture_ptr); - assert(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr && s->last_picture_ptr->data[0])); + assert(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr && s->last_picture_ptr->f.data[0])); if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){ int i; for(i=0; i<4; i++){ if(s->picture_structure == PICT_BOTTOM_FIELD){ - s->current_picture.data[i] += s->current_picture.linesize[i]; + s->current_picture.f.data[i] += s->current_picture.f.linesize[i]; } - s->current_picture.linesize[i] *= 2; - s->last_picture.linesize[i] *=2; - s->next_picture.linesize[i] *=2; + s->current_picture.f.linesize[i] *= 2; + s->last_picture.f.linesize[i] *= 2; + s->next_picture.f.linesize[i] *= 2; } } @@ -1187,18 +1191,18 @@ void MPV_frame_end(MpegEncContext *s) && !s->avctx->hwaccel && !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) && s->unrestricted_mv - && s->current_picture.reference + && s->current_picture.f.reference && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) { int hshift = av_pix_fmt_descriptors[s->avctx->pix_fmt].log2_chroma_w; int vshift = av_pix_fmt_descriptors[s->avctx->pix_fmt].log2_chroma_h; - s->dsp.draw_edges(s->current_picture.data[0], s->linesize , + s->dsp.draw_edges(s->current_picture.f.data[0], s->linesize, s->h_edge_pos , s->v_edge_pos, EDGE_WIDTH , EDGE_WIDTH , EDGE_TOP | EDGE_BOTTOM); - s->dsp.draw_edges(s->current_picture.data[1], s->uvlinesize, + s->dsp.draw_edges(s->current_picture.f.data[1], s->uvlinesize, s->h_edge_pos>>hshift, s->v_edge_pos>>vshift, EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, EDGE_TOP | EDGE_BOTTOM); - s->dsp.draw_edges(s->current_picture.data[2], s->uvlinesize, + s->dsp.draw_edges(s->current_picture.f.data[2], s->uvlinesize, s->h_edge_pos>>hshift, s->v_edge_pos>>vshift, EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, EDGE_TOP | EDGE_BOTTOM); } @@ -1206,14 +1210,14 @@ void MPV_frame_end(MpegEncContext *s) emms_c(); s->last_pict_type = s->pict_type; - s->last_lambda_for[s->pict_type]= s->current_picture_ptr->quality; + s->last_lambda_for[s->pict_type] = s->current_picture_ptr->f.quality; if(s->pict_type!=AV_PICTURE_TYPE_B){ s->last_non_b_pict_type= s->pict_type; } #if 0 /* copy back current_picture variables */ for(i=0; ipicture[i].data[0] == s->current_picture.data[0]){ + if(s->picture[i].f.data[0] == s->current_picture.f.data[0]){ s->picture[i]= s->current_picture; break; } @@ -1224,7 +1228,7 @@ void MPV_frame_end(MpegEncContext *s) if(s->encoding){ /* release non-reference frames */ for(i=0; ipicture_count; i++){ - if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){ + if (s->picture[i].f.data[0] && !s->picture[i].f.reference /*&& s->picture[i].type != FF_BUFFER_TYPE_SHARED*/) { free_frame_buffer(s, &s->picture[i]); } } @@ -1237,7 +1241,7 @@ void MPV_frame_end(MpegEncContext *s) #endif s->avctx->coded_frame= (AVFrame*)s->current_picture_ptr; - if (s->codec_id != CODEC_ID_H264 && s->current_picture.reference) { + if (s->codec_id != CODEC_ID_H264 && s->current_picture.f.reference) { ff_thread_report_progress((AVFrame*)s->current_picture_ptr, s->mb_height-1, 0); } } @@ -1644,8 +1648,8 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, const int s_mask= (2<h_edge_pos >> lowres; const int v_edge_pos = s->v_edge_pos >> lowres; - linesize = s->current_picture.linesize[0] << field_based; - uvlinesize = s->current_picture.linesize[1] << field_based; + linesize = s->current_picture.f.linesize[0] << field_based; + uvlinesize = s->current_picture.f.linesize[1] << field_based; if(s->quarter_sample){ //FIXME obviously not perfect but qpel will not work in lowres anyway motion_x/=2; @@ -1702,7 +1706,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, } } - if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.data + if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.f.data dest_y += s->linesize; dest_cb+= s->uvlinesize; dest_cr+= s->uvlinesize; @@ -1842,7 +1846,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s, s->mv[dir][1][0], s->mv[dir][1][1], block_s, mb_y); } else { if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field){ - ref_picture= s->current_picture_ptr->data; + ref_picture = s->current_picture_ptr->f.data; } mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, @@ -1858,7 +1862,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s, if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == AV_PICTURE_TYPE_B || s->first_field){ ref2picture= ref_picture; }else{ - ref2picture= s->current_picture_ptr->data; + ref2picture = s->current_picture_ptr->f.data; } mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, @@ -1895,7 +1899,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s, //opposite parity is always in the same frame if this is second field if(!s->first_field){ - ref_picture = s->current_picture_ptr->data; + ref_picture = s->current_picture_ptr->f.data; } } } @@ -2024,7 +2028,7 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], if(s->avctx->debug&FF_DEBUG_DCT_COEFF) { /* save DCT coefficients */ int i,j; - DCTELEM *dct = &s->current_picture.dct_coeff[mb_xy*64*6]; + DCTELEM *dct = &s->current_picture.f.dct_coeff[mb_xy * 64 * 6]; av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y); for(i=0; i<6; i++){ for(j=0; j<64; j++){ @@ -2035,7 +2039,7 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], } } - s->current_picture.qscale_table[mb_xy]= s->qscale; + s->current_picture.f.qscale_table[mb_xy] = s->qscale; /* update DC predictors for P macroblocks */ if (!s->mb_intra) { @@ -2056,8 +2060,8 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], int dct_linesize, dct_offset; op_pixels_func (*op_pix)[4]; qpel_mc_func (*op_qpix)[16]; - const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics - const int uvlinesize= s->current_picture.linesize[1]; + const int linesize = s->current_picture.f.linesize[0]; //not s->linesize as this would be wrong for field pics + const int uvlinesize = s->current_picture.f.linesize[1]; const int readable= s->pict_type != AV_PICTURE_TYPE_B || s->encoding || s->avctx->draw_horiz_band || lowres_flag; const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8; @@ -2065,7 +2069,7 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], /* skip only during decoding as we might trash the buffers during encoding a bit */ if(!s->encoding){ uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy]; - const int age= s->current_picture.age; + const int age = s->current_picture.f.age; assert(age); @@ -2077,10 +2081,10 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], if(*mbskip_ptr >99) *mbskip_ptr= 99; /* if previous was skipped too, then nothing to do ! */ - if (*mbskip_ptr >= age && s->current_picture.reference){ + if (*mbskip_ptr >= age && s->current_picture.f.reference){ return; } - } else if(!s->current_picture.reference){ + } else if(!s->current_picture.f.reference) { (*mbskip_ptr) ++; /* increase counter so the age can be compared cleanly */ if(*mbskip_ptr >99) *mbskip_ptr= 99; } else{ @@ -2119,11 +2123,11 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], h264_chroma_mc_func *op_pix = s->dsp.put_h264_chroma_pixels_tab; if (s->mv_dir & MV_DIR_FORWARD) { - MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix); + MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix); op_pix = s->dsp.avg_h264_chroma_pixels_tab; } if (s->mv_dir & MV_DIR_BACKWARD) { - MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix); + MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix); } }else{ op_qpix= s->me.qpel_put; @@ -2133,12 +2137,12 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], op_pix = s->dsp.put_no_rnd_pixels_tab; } if (s->mv_dir & MV_DIR_FORWARD) { - MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix); + MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix, op_qpix); op_pix = s->dsp.avg_pixels_tab; op_qpix= s->me.qpel_avg; } if (s->mv_dir & MV_DIR_BACKWARD) { - MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix); + MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix, op_qpix); } } } @@ -2287,7 +2291,7 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){ if (!s->avctx->hwaccel && !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) && s->unrestricted_mv - && s->current_picture.reference + && s->current_picture.f.reference && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) { int sides = 0, edge_h; @@ -2298,11 +2302,11 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){ edge_h= FFMIN(h, s->v_edge_pos - y); - s->dsp.draw_edges(s->current_picture_ptr->data[0] + y *s->linesize , s->linesize, + s->dsp.draw_edges(s->current_picture_ptr->f.data[0] + y *s->linesize , s->linesize, s->h_edge_pos , edge_h , EDGE_WIDTH , EDGE_WIDTH , sides); - s->dsp.draw_edges(s->current_picture_ptr->data[1] + (y>>vshift)*s->uvlinesize, s->uvlinesize, + s->dsp.draw_edges(s->current_picture_ptr->f.data[1] + (y>>vshift)*s->uvlinesize, s->uvlinesize, s->h_edge_pos>>hshift, edge_h>>hshift, EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides); - s->dsp.draw_edges(s->current_picture_ptr->data[2] + (y>>vshift)*s->uvlinesize, s->uvlinesize, + s->dsp.draw_edges(s->current_picture_ptr->f.data[2] + (y>>vshift)*s->uvlinesize, s->uvlinesize, s->h_edge_pos>>hshift, edge_h>>hshift, EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides); } @@ -2341,8 +2345,8 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){ } void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename - const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics - const int uvlinesize= s->current_picture.linesize[1]; + const int linesize = s->current_picture.f.linesize[0]; //not s->linesize as this would be wrong for field pics + const int uvlinesize = s->current_picture.f.linesize[1]; const int mb_size= 4 - s->avctx->lowres; s->block_index[0]= s->b8_stride*(s->mb_y*2 ) - 2 + s->mb_x*2; @@ -2353,9 +2357,9 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x - 1; //block_index is not used by mpeg2, so it is not affected by chroma_format - s->dest[0] = s->current_picture.data[0] + ((s->mb_x - 1) << mb_size); - s->dest[1] = s->current_picture.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift)); - s->dest[2] = s->current_picture.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift)); + s->dest[0] = s->current_picture.f.data[0] + ((s->mb_x - 1) << mb_size); + s->dest[1] = s->current_picture.f.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift)); + s->dest[2] = s->current_picture.f.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift)); if(!(s->pict_type==AV_PICTURE_TYPE_B && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME)) { @@ -2380,8 +2384,9 @@ void ff_mpeg_flush(AVCodecContext *avctx){ return; for(i=0; ipicture_count; i++){ - if(s->picture[i].data[0] && ( s->picture[i].type == FF_BUFFER_TYPE_INTERNAL - || s->picture[i].type == FF_BUFFER_TYPE_USER)) + if (s->picture[i].f.data[0] && + (s->picture[i].f.type == FF_BUFFER_TYPE_INTERNAL || + s->picture[i].f.type == FF_BUFFER_TYPE_USER)) free_frame_buffer(s, &s->picture[i]); } s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index d309fcb83b..315f319a80 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -28,6 +28,7 @@ #ifndef AVCODEC_MPEGVIDEO_H #define AVCODEC_MPEGVIDEO_H +#include "avcodec.h" #include "dsputil.h" #include "get_bits.h" #include "put_bits.h" @@ -82,7 +83,7 @@ struct MpegEncContext; * Picture. */ typedef struct Picture{ - FF_COMMON_FRAME + struct AVFrame f; /** * halfpel luma planes. diff --git a/libavcodec/mpegvideo_common.h b/libavcodec/mpegvideo_common.h index d0093ce8d2..96155d0f9a 100644 --- a/libavcodec/mpegvideo_common.h +++ b/libavcodec/mpegvideo_common.h @@ -255,8 +255,8 @@ if(s->quarter_sample) #endif v_edge_pos = s->v_edge_pos >> field_based; - linesize = s->current_picture.linesize[0] << field_based; - uvlinesize = s->current_picture.linesize[1] << field_based; + linesize = s->current_picture.f.linesize[0] << field_based; + uvlinesize = s->current_picture.f.linesize[1] << field_based; dxy = ((motion_y & 1) << 1) | (motion_x & 1); src_x = s->mb_x* 16 + (motion_x >> 1); @@ -657,30 +657,30 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, assert(!s->mb_skipped); - memcpy(mv_cache[1][1], s->current_picture.motion_val[0][mot_xy ], sizeof(int16_t)*4); - memcpy(mv_cache[2][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4); - memcpy(mv_cache[3][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4); + memcpy(mv_cache[1][1], s->current_picture.f.motion_val[0][mot_xy ], sizeof(int16_t) * 4); + memcpy(mv_cache[2][1], s->current_picture.f.motion_val[0][mot_xy + mot_stride], sizeof(int16_t) * 4); + memcpy(mv_cache[3][1], s->current_picture.f.motion_val[0][mot_xy + mot_stride], sizeof(int16_t) * 4); - if(mb_y==0 || IS_INTRA(s->current_picture.mb_type[xy-s->mb_stride])){ + if (mb_y == 0 || IS_INTRA(s->current_picture.f.mb_type[xy - s->mb_stride])) { memcpy(mv_cache[0][1], mv_cache[1][1], sizeof(int16_t)*4); }else{ - memcpy(mv_cache[0][1], s->current_picture.motion_val[0][mot_xy-mot_stride], sizeof(int16_t)*4); + memcpy(mv_cache[0][1], s->current_picture.f.motion_val[0][mot_xy - mot_stride], sizeof(int16_t) * 4); } - if(mb_x==0 || IS_INTRA(s->current_picture.mb_type[xy-1])){ + if (mb_x == 0 || IS_INTRA(s->current_picture.f.mb_type[xy - 1])) { AV_COPY32(mv_cache[1][0], mv_cache[1][1]); AV_COPY32(mv_cache[2][0], mv_cache[2][1]); }else{ - AV_COPY32(mv_cache[1][0], s->current_picture.motion_val[0][mot_xy-1]); - AV_COPY32(mv_cache[2][0], s->current_picture.motion_val[0][mot_xy-1+mot_stride]); + AV_COPY32(mv_cache[1][0], s->current_picture.f.motion_val[0][mot_xy - 1]); + AV_COPY32(mv_cache[2][0], s->current_picture.f.motion_val[0][mot_xy - 1 + mot_stride]); } - if(mb_x+1>=s->mb_width || IS_INTRA(s->current_picture.mb_type[xy+1])){ + if (mb_x + 1 >= s->mb_width || IS_INTRA(s->current_picture.f.mb_type[xy + 1])) { AV_COPY32(mv_cache[1][3], mv_cache[1][2]); AV_COPY32(mv_cache[2][3], mv_cache[2][2]); }else{ - AV_COPY32(mv_cache[1][3], s->current_picture.motion_val[0][mot_xy+2]); - AV_COPY32(mv_cache[2][3], s->current_picture.motion_val[0][mot_xy+2+mot_stride]); + AV_COPY32(mv_cache[1][3], s->current_picture.f.motion_val[0][mot_xy + 2]); + AV_COPY32(mv_cache[2][3], s->current_picture.f.motion_val[0][mot_xy + 2 + mot_stride]); } mx = 0; @@ -817,7 +817,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, } } else { if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field){ - ref_picture= s->current_picture_ptr->data; + ref_picture = s->current_picture_ptr->f.data; } mpeg_motion(s, dest_y, dest_cb, dest_cr, @@ -834,7 +834,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, || s->pict_type == AV_PICTURE_TYPE_B || s->first_field){ ref2picture= ref_picture; }else{ - ref2picture= s->current_picture_ptr->data; + ref2picture = s->current_picture_ptr->f.data; } mpeg_motion(s, dest_y, dest_cb, dest_cr, @@ -871,7 +871,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, //opposite parity is always in the same frame if this is second field if(!s->first_field){ - ref_picture = s->current_picture_ptr->data; + ref_picture = s->current_picture_ptr->f.data; } } } diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 68bd080960..4b4636b32b 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -158,7 +158,7 @@ void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix){ * init s->current_picture.qscale_table from s->lambda_table */ void ff_init_qscale_tab(MpegEncContext *s){ - int8_t * const qscale_table= s->current_picture.qscale_table; + int8_t * const qscale_table = s->current_picture.f.qscale_table; int i; for(i=0; imb_num; i++){ @@ -915,12 +915,12 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref){ int64_t score64=0; for(plane=0; plane<3; plane++){ - const int stride= p->linesize[plane]; + const int stride = p->f.linesize[plane]; const int bw= plane ? 1 : 2; for(y=0; ymb_height*bw; y++){ for(x=0; xmb_width*bw; x++){ - int off= p->type == FF_BUFFER_TYPE_SHARED ? 0: 16; - int v= s->dsp.frame_skip_cmp[1](s, p->data[plane] + 8*(x + y*stride)+off, ref->data[plane] + 8*(x + y*stride), stride, 8); + int off = p->f.type == FF_BUFFER_TYPE_SHARED ? 0: 16; + int v = s->dsp.frame_skip_cmp[1](s, p->f.data[plane] + 8*(x + y*stride)+off, ref->f.data[plane] + 8*(x + y*stride), stride, 8); switch(s->avctx->frame_skip_exp){ case 0: score= FFMAX(score, v); break; @@ -992,15 +992,15 @@ static int estimate_best_b_count(MpegEncContext *s){ if(pre_input_ptr && (!i || s->input_picture[i-1])) { pre_input= *pre_input_ptr; - if(pre_input.type != FF_BUFFER_TYPE_SHARED && i) { - pre_input.data[0]+=INPLACE_OFFSET; - pre_input.data[1]+=INPLACE_OFFSET; - pre_input.data[2]+=INPLACE_OFFSET; + if (pre_input.f.type != FF_BUFFER_TYPE_SHARED && i) { + pre_input.f.data[0] += INPLACE_OFFSET; + pre_input.f.data[1] += INPLACE_OFFSET; + pre_input.f.data[2] += INPLACE_OFFSET; } - s->dsp.shrink[scale](input[i].data[0], input[i].linesize[0], pre_input.data[0], pre_input.linesize[0], c->width, c->height); - s->dsp.shrink[scale](input[i].data[1], input[i].linesize[1], pre_input.data[1], pre_input.linesize[1], c->width>>1, c->height>>1); - s->dsp.shrink[scale](input[i].data[2], input[i].linesize[2], pre_input.data[2], pre_input.linesize[2], c->width>>1, c->height>>1); + s->dsp.shrink[scale](input[i].data[0], input[i].linesize[0], pre_input.f.data[0], pre_input.f.linesize[0], c->width, c->height); + s->dsp.shrink[scale](input[i].data[1], input[i].linesize[1], pre_input.f.data[1], pre_input.f.linesize[1], c->width >> 1, c->height >> 1); + s->dsp.shrink[scale](input[i].data[2], input[i].linesize[2], pre_input.f.data[2], pre_input.f.linesize[2], c->width >> 1, c->height >> 1); } } @@ -1062,20 +1062,20 @@ static int select_input_picture(MpegEncContext *s){ if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){ if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){ s->reordered_input_picture[0]= s->input_picture[0]; - s->reordered_input_picture[0]->pict_type= AV_PICTURE_TYPE_I; - s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; + s->reordered_input_picture[0]->f.pict_type = AV_PICTURE_TYPE_I; + s->reordered_input_picture[0]->f.coded_picture_number = s->coded_picture_number++; }else{ int b_frames; if(s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor){ if(s->picture_in_gop_number < s->gop_size && skip_check(s, s->input_picture[0], s->next_picture_ptr)){ //FIXME check that te gop check above is +-1 correct -//av_log(NULL, AV_LOG_DEBUG, "skip %p %"PRId64"\n", s->input_picture[0]->data[0], s->input_picture[0]->pts); +//av_log(NULL, AV_LOG_DEBUG, "skip %p %"PRId64"\n", s->input_picture[0]->f.data[0], s->input_picture[0]->pts); - if(s->input_picture[0]->type == FF_BUFFER_TYPE_SHARED){ + if (s->input_picture[0]->f.type == FF_BUFFER_TYPE_SHARED) { for(i=0; i<4; i++) - s->input_picture[0]->data[i]= NULL; - s->input_picture[0]->type= 0; + s->input_picture[0]->f.data[i] = NULL; + s->input_picture[0]->f.type = 0; }else{ assert( s->input_picture[0]->type==FF_BUFFER_TYPE_USER || s->input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL); @@ -1092,7 +1092,7 @@ static int select_input_picture(MpegEncContext *s){ if(s->flags&CODEC_FLAG_PASS2){ for(i=0; imax_b_frames+1; i++){ - int pict_num= s->input_picture[0]->display_picture_number + i; + int pict_num = s->input_picture[0]->f.display_picture_number + i; if(pict_num >= s->rc_context.num_entries) break; @@ -1101,7 +1101,7 @@ static int select_input_picture(MpegEncContext *s){ break; } - s->input_picture[i]->pict_type= + s->input_picture[i]->f.pict_type = s->rc_context.entry[pict_num].new_pict_type; } } @@ -1113,8 +1113,8 @@ static int select_input_picture(MpegEncContext *s){ for(i=1; imax_b_frames+1; i++){ if(s->input_picture[i] && s->input_picture[i]->b_frame_score==0){ s->input_picture[i]->b_frame_score= - get_intra_count(s, s->input_picture[i ]->data[0], - s->input_picture[i-1]->data[0], s->linesize) + 1; + get_intra_count(s, s->input_picture[i ]->f.data[0], + s->input_picture[i-1]->f.data[0], s->linesize) + 1; } } for(i=0; imax_b_frames+1; i++){ @@ -1140,11 +1140,11 @@ static int select_input_picture(MpegEncContext *s){ //av_log(s->avctx, AV_LOG_DEBUG, "b_frames: %d\n", b_count); for(i= b_frames - 1; i>=0; i--){ - int type= s->input_picture[i]->pict_type; + int type = s->input_picture[i]->f.pict_type; if(type && type != AV_PICTURE_TYPE_B) b_frames= i; } - if(s->input_picture[b_frames]->pict_type == AV_PICTURE_TYPE_B && b_frames == s->max_b_frames){ + if (s->input_picture[b_frames]->f.pict_type == AV_PICTURE_TYPE_B && b_frames == s->max_b_frames){ av_log(s->avctx, AV_LOG_ERROR, "warning, too many b frames in a row\n"); } @@ -1154,49 +1154,49 @@ static int select_input_picture(MpegEncContext *s){ }else{ if(s->flags & CODEC_FLAG_CLOSED_GOP) b_frames=0; - s->input_picture[b_frames]->pict_type= AV_PICTURE_TYPE_I; + s->input_picture[b_frames]->f.pict_type = AV_PICTURE_TYPE_I; } } if( (s->flags & CODEC_FLAG_CLOSED_GOP) && b_frames - && s->input_picture[b_frames]->pict_type== AV_PICTURE_TYPE_I) + && s->input_picture[b_frames]->f.pict_type== AV_PICTURE_TYPE_I) b_frames--; s->reordered_input_picture[0]= s->input_picture[b_frames]; - if(s->reordered_input_picture[0]->pict_type != AV_PICTURE_TYPE_I) - s->reordered_input_picture[0]->pict_type= AV_PICTURE_TYPE_P; - s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; + if (s->reordered_input_picture[0]->f.pict_type != AV_PICTURE_TYPE_I) + s->reordered_input_picture[0]->f.pict_type = AV_PICTURE_TYPE_P; + s->reordered_input_picture[0]->f.coded_picture_number = s->coded_picture_number++; for(i=0; ireordered_input_picture[i+1]= s->input_picture[i]; - s->reordered_input_picture[i+1]->pict_type= AV_PICTURE_TYPE_B; - s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++; + s->reordered_input_picture[i + 1] = s->input_picture[i]; + s->reordered_input_picture[i + 1]->f.pict_type = AV_PICTURE_TYPE_B; + s->reordered_input_picture[i + 1]->f.coded_picture_number = s->coded_picture_number++; } } } no_output_pic: if(s->reordered_input_picture[0]){ - s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=AV_PICTURE_TYPE_B ? 3 : 0; + s->reordered_input_picture[0]->f.reference = s->reordered_input_picture[0]->f.pict_type!=AV_PICTURE_TYPE_B ? 3 : 0; ff_copy_picture(&s->new_picture, s->reordered_input_picture[0]); - if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED || s->avctx->rc_buffer_size){ + if (s->reordered_input_picture[0]->f.type == FF_BUFFER_TYPE_SHARED || s->avctx->rc_buffer_size) { // input is a shared pix, so we can't modifiy it -> alloc a new one & ensure that the shared one is reuseable int i= ff_find_unused_picture(s, 0); Picture *pic= &s->picture[i]; - pic->reference = s->reordered_input_picture[0]->reference; + pic->f.reference = s->reordered_input_picture[0]->f.reference; if(ff_alloc_picture(s, pic, 0) < 0){ return -1; } /* mark us unused / free shared pic */ - if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_INTERNAL) + if (s->reordered_input_picture[0]->f.type == FF_BUFFER_TYPE_INTERNAL) s->avctx->release_buffer(s->avctx, (AVFrame*)s->reordered_input_picture[0]); for(i=0; i<4; i++) - s->reordered_input_picture[0]->data[i]= NULL; - s->reordered_input_picture[0]->type= 0; + s->reordered_input_picture[0]->f.data[i] = NULL; + s->reordered_input_picture[0]->f.type = 0; copy_picture_attributes(s, (AVFrame*)pic, (AVFrame*)s->reordered_input_picture[0]); @@ -1209,12 +1209,12 @@ no_output_pic: s->current_picture_ptr= s->reordered_input_picture[0]; for(i=0; i<4; i++){ - s->new_picture.data[i]+= INPLACE_OFFSET; + s->new_picture.f.data[i] += INPLACE_OFFSET; } } ff_copy_picture(&s->current_picture, s->current_picture_ptr); - s->picture_number= s->new_picture.display_picture_number; + s->picture_number = s->new_picture.f.display_picture_number; //printf("dpn:%d\n", s->picture_number); }else{ memset(&s->new_picture, 0, sizeof(Picture)); @@ -1249,8 +1249,8 @@ int MPV_encode_picture(AVCodecContext *avctx, } /* output? */ - if(s->new_picture.data[0]){ - s->pict_type= s->new_picture.pict_type; + if (s->new_picture.f.data[0]) { + s->pict_type = s->new_picture.f.pict_type; //emms_c(); //printf("qs:%f %f %d\n", s->new_picture.quality, s->current_picture.quality, s->qscale); MPV_frame_start(s, avctx); @@ -1307,8 +1307,8 @@ vbv_retry: ff_write_pass1_stats(s); for(i=0; i<4; i++){ - s->current_picture_ptr->error[i]= s->current_picture.error[i]; - avctx->error[i] += s->current_picture_ptr->error[i]; + s->current_picture_ptr->f.error[i] = s->current_picture.f.error[i]; + avctx->error[i] += s->current_picture_ptr->f.error[i]; } if(s->flags&CODEC_FLAG_PASS1) @@ -1508,7 +1508,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, update_qscale(s); if(!(s->flags&CODEC_FLAG_QP_RD)){ - s->qscale= s->current_picture_ptr->qscale_table[mb_xy]; + s->qscale = s->current_picture_ptr->f.qscale_table[mb_xy]; s->dquant= s->qscale - last_qp; if(s->out_format==FMT_H263){ @@ -1532,9 +1532,9 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, wrap_y = s->linesize; wrap_c = s->uvlinesize; - ptr_y = s->new_picture.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16; - ptr_cb = s->new_picture.data[1] + (mb_y * mb_block_height * wrap_c) + mb_x * 8; - ptr_cr = s->new_picture.data[2] + (mb_y * mb_block_height * wrap_c) + mb_x * 8; + ptr_y = s->new_picture.f.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16; + ptr_cb = s->new_picture.f.data[1] + (mb_y * mb_block_height * wrap_c) + mb_x * 8; + ptr_cr = s->new_picture.f.data[2] + (mb_y * mb_block_height * wrap_c) + mb_x * 8; if(mb_x*16+16 > s->width || mb_y*16+16 > s->height){ uint8_t *ebuf= s->edge_emu_buffer + 32; @@ -1602,12 +1602,12 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, } if (s->mv_dir & MV_DIR_FORWARD) { - MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix); + MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix, op_qpix); op_pix = s->dsp.avg_pixels_tab; op_qpix= s->dsp.avg_qpel_pixels_tab; } if (s->mv_dir & MV_DIR_BACKWARD) { - MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix); + MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix, op_qpix); } if(s->flags&CODEC_FLAG_INTERLACED_DCT){ @@ -1933,18 +1933,18 @@ static int sse_mb(MpegEncContext *s){ if(w==16 && h==16) if(s->avctx->mb_cmp == FF_CMP_NSSE){ - return s->dsp.nsse[0](s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16) - +s->dsp.nsse[1](s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8) - +s->dsp.nsse[1](s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8); + return s->dsp.nsse[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16) + +s->dsp.nsse[1](s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8) + +s->dsp.nsse[1](s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8); }else{ - return s->dsp.sse[0](NULL, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16) - +s->dsp.sse[1](NULL, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8) - +s->dsp.sse[1](NULL, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8); + return s->dsp.sse[0](NULL, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16) + +s->dsp.sse[1](NULL, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8) + +s->dsp.sse[1](NULL, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8); } else - return sse(s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize) - +sse(s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize) - +sse(s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize); + return sse(s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize) + +sse(s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize) + +sse(s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize); } static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){ @@ -2003,7 +2003,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){ for(mb_x=0; mb_x < s->mb_width; mb_x++) { int xx = mb_x * 16; int yy = mb_y * 16; - uint8_t *pix = s->new_picture.data[0] + (yy * s->linesize) + xx; + uint8_t *pix = s->new_picture.f.data[0] + (yy * s->linesize) + xx; int varc; int sum = s->dsp.pix_sum(pix, s->linesize); @@ -2070,7 +2070,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ /* note: quant matrix value (8) is implied here */ s->last_dc[i] = 128 << s->intra_dc_precision; - s->current_picture.error[i] = 0; + s->current_picture.f.error[i] = 0; } s->mb_skip_run = 0; memset(s->last_mv, 0, sizeof(s->last_mv)); @@ -2271,8 +2271,8 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv_type = MV_TYPE_8X8; s->mb_intra= 0; for(i=0; i<4; i++){ - s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0]; - s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1]; + s->mv[0][i][0] = s->current_picture.f.motion_val[0][s->block_index[i]][0]; + s->mv[0][i][1] = s->current_picture.f.motion_val[0][s->block_index[i]][1]; } encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); @@ -2458,7 +2458,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ } } - s->current_picture.qscale_table[xy]= best_s.qscale; + s->current_picture.f.qscale_table[xy] = best_s.qscale; copy_context_after_encode(s, &best_s, -1); @@ -2525,8 +2525,8 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv_type = MV_TYPE_8X8; s->mb_intra= 0; for(i=0; i<4; i++){ - s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0]; - s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1]; + s->mv[0][i][0] = s->current_picture.f.motion_val[0][s->block_index[i]][0]; + s->mv[0][i][1] = s->current_picture.f.motion_val[0][s->block_index[i]][1]; } break; case CANDIDATE_MB_TYPE_DIRECT: @@ -2627,14 +2627,14 @@ static int encode_thread(AVCodecContext *c, void *arg){ if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16; if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16; - s->current_picture.error[0] += sse( - s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, + s->current_picture.f.error[0] += sse( + s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize); - s->current_picture.error[1] += sse( - s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h, + s->current_picture.f.error[1] += sse( + s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h, s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize); - s->current_picture.error[2] += sse( - s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h, + s->current_picture.f.error[2] += sse( + s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h, s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize); } if(s->loop_filter){ @@ -2685,9 +2685,9 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src) MERGE(misc_bits); MERGE(error_count); MERGE(padding_bug_score); - MERGE(current_picture.error[0]); - MERGE(current_picture.error[1]); - MERGE(current_picture.error[2]); + MERGE(current_picture.f.error[0]); + MERGE(current_picture.f.error[1]); + MERGE(current_picture.f.error[2]); if(dst->avctx->noise_reduction){ for(i=0; i<64; i++){ @@ -2704,13 +2704,13 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src) static int estimate_qp(MpegEncContext *s, int dry_run){ if (s->next_lambda){ - s->current_picture_ptr->quality= - s->current_picture.quality = s->next_lambda; + s->current_picture_ptr->f.quality = + s->current_picture.f.quality = s->next_lambda; if(!dry_run) s->next_lambda= 0; } else if (!s->fixed_qscale) { - s->current_picture_ptr->quality= - s->current_picture.quality = ff_rate_estimate_qscale(s, dry_run); - if (s->current_picture.quality < 0) + s->current_picture_ptr->f.quality = + s->current_picture.f.quality = ff_rate_estimate_qscale(s, dry_run); + if (s->current_picture.f.quality < 0) return -1; } @@ -2733,7 +2733,7 @@ static int estimate_qp(MpegEncContext *s, int dry_run){ s->lambda= s->lambda_table[0]; //FIXME broken }else - s->lambda= s->current_picture.quality; + s->lambda = s->current_picture.f.quality; //printf("%d %d\n", s->avctx->global_quality, s->current_picture.quality); update_qscale(s); return 0; @@ -2742,7 +2742,7 @@ static int estimate_qp(MpegEncContext *s, int dry_run){ /* must be called before writing the header */ static void set_frame_distances(MpegEncContext * s){ assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE); - s->time= s->current_picture_ptr->pts*s->avctx->time_base.num; + s->time = s->current_picture_ptr->f.pts * s->avctx->time_base.num; if(s->pict_type==AV_PICTURE_TYPE_B){ s->pb_time= s->pp_time - (s->last_non_b_time - s->time); @@ -2916,12 +2916,12 @@ static int encode_picture(MpegEncContext *s, int picture_number) } //FIXME var duplication - s->current_picture_ptr->key_frame= - s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I; //FIXME pic_ptr - s->current_picture_ptr->pict_type= - s->current_picture.pict_type= s->pict_type; + s->current_picture_ptr->f.key_frame = + s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; //FIXME pic_ptr + s->current_picture_ptr->f.pict_type = + s->current_picture.f.pict_type = s->pict_type; - if(s->current_picture.key_frame) + if (s->current_picture.f.key_frame) s->picture_in_gop_number=0; s->last_bits= put_bits_count(&s->pb); diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index c740cfa0bd..ee34a8917c 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -780,10 +780,10 @@ static inline int msmpeg4_pred_dc(MpegEncContext * s, int n, }else{ if(n<4){ wrap= s->linesize; - dest= s->current_picture.data[0] + (((n>>1) + 2*s->mb_y) * 8* wrap ) + ((n&1) + 2*s->mb_x) * 8; + dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8* wrap ) + ((n & 1) + 2*s->mb_x) * 8; }else{ wrap= s->uvlinesize; - dest= s->current_picture.data[n-3] + (s->mb_y * 8 * wrap) + s->mb_x * 8; + dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8; } if(s->mb_x==0) a= (1024 + (scale>>1))/scale; else a= get_dc(dest-8, wrap, scale*8); @@ -1172,7 +1172,7 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) { int cbp, code, i; uint8_t *coded_val; - uint32_t * const mb_type_ptr= &s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]; + uint32_t * const mb_type_ptr = &s->current_picture.f.mb_type[s->mb_x + s->mb_y*s->mb_stride]; if (s->pict_type == AV_PICTURE_TYPE_P) { if (s->use_skip_mb_code) { diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 0d7b995476..dc5c063f02 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -44,9 +44,9 @@ static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_f void ff_write_pass1_stats(MpegEncContext *s){ snprintf(s->avctx->stats_out, 256, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d;\n", - s->current_picture_ptr->display_picture_number, s->current_picture_ptr->coded_picture_number, s->pict_type, - s->current_picture.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits, - s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count, s->skip_count, s->header_bits); + s->current_picture_ptr->f.display_picture_number, s->current_picture_ptr->f.coded_picture_number, s->pict_type, + s->current_picture.f.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits, + s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count, s->skip_count, s->header_bits); } static inline double qp2bits(RateControlEntry *rce, double qp){ @@ -707,10 +707,10 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run) //if(dts_pic) // av_log(NULL, AV_LOG_ERROR, "%Ld %Ld %Ld %d\n", s->current_picture_ptr->pts, s->user_specified_pts, dts_pic->pts, picture_number); - if(!dts_pic || dts_pic->pts == AV_NOPTS_VALUE) + if (!dts_pic || dts_pic->f.pts == AV_NOPTS_VALUE) wanted_bits= (uint64_t)(s->bit_rate*(double)picture_number/fps); else - wanted_bits= (uint64_t)(s->bit_rate*(double)dts_pic->pts/fps); + wanted_bits = (uint64_t)(s->bit_rate*(double)dts_pic->f.pts / fps); } diff= s->total_bits - wanted_bits; diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 62177dda78..5d7109f961 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -142,7 +142,7 @@ static void rv30_loop_filter(RV34DecContext *r, int row) mb_pos = row * s->mb_stride; for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){ - int mbtype = s->current_picture_ptr->mb_type[mb_pos]; + int mbtype = s->current_picture_ptr->f.mb_type[mb_pos]; if(IS_INTRA(mbtype) || IS_SEPARATE_DC(mbtype)) r->deblock_coefs[mb_pos] = 0xFFFF; if(IS_INTRA(mbtype)) @@ -154,11 +154,11 @@ static void rv30_loop_filter(RV34DecContext *r, int row) */ mb_pos = row * s->mb_stride; for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){ - cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos]]; + cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.qscale_table[mb_pos]]; if(mb_x) - left_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos - 1]]; + left_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.qscale_table[mb_pos - 1]]; for(j = 0; j < 16; j += 4){ - Y = s->current_picture_ptr->data[0] + mb_x*16 + (row*16 + j) * s->linesize + 4 * !mb_x; + Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize + 4 * !mb_x; for(i = !mb_x; i < 4; i++, Y += 4){ int ij = i + j; loc_lim = 0; @@ -178,7 +178,7 @@ static void rv30_loop_filter(RV34DecContext *r, int row) if(mb_x) left_cbp = (r->cbp_chroma[mb_pos - 1] >> (k*4)) & 0xF; for(j = 0; j < 8; j += 4){ - C = s->current_picture_ptr->data[k+1] + mb_x*8 + (row*8 + j) * s->uvlinesize + 4 * !mb_x; + C = s->current_picture_ptr->f.data[k + 1] + mb_x*8 + (row*8 + j) * s->uvlinesize + 4 * !mb_x; for(i = !mb_x; i < 2; i++, C += 4){ int ij = i + (j >> 1); loc_lim = 0; @@ -196,11 +196,11 @@ static void rv30_loop_filter(RV34DecContext *r, int row) } mb_pos = row * s->mb_stride; for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){ - cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos]]; + cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.qscale_table[mb_pos]]; if(row) - top_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos - s->mb_stride]]; + top_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.qscale_table[mb_pos - s->mb_stride]]; for(j = 4*!row; j < 16; j += 4){ - Y = s->current_picture_ptr->data[0] + mb_x*16 + (row*16 + j) * s->linesize; + Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize; for(i = 0; i < 4; i++, Y += 4){ int ij = i + j; loc_lim = 0; @@ -220,7 +220,7 @@ static void rv30_loop_filter(RV34DecContext *r, int row) if(row) top_cbp = (r->cbp_chroma[mb_pos - s->mb_stride] >> (k*4)) & 0xF; for(j = 4*!row; j < 8; j += 4){ - C = s->current_picture_ptr->data[k+1] + mb_x*8 + (row*8 + j) * s->uvlinesize; + C = s->current_picture_ptr->f.data[k+1] + mb_x*8 + (row*8 + j) * s->uvlinesize; for(i = 0; i < 2; i++, C += 4){ int ij = i + (j >> 1); loc_lim = 0; diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 98607ea7ff..9162da5194 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -439,13 +439,13 @@ static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types) if(!get_bits1(gb)) av_log(s->avctx, AV_LOG_ERROR, "Need DQUANT\n"); } - s->current_picture_ptr->mb_type[mb_pos] = r->is16 ? MB_TYPE_INTRA16x16 : MB_TYPE_INTRA; + s->current_picture_ptr->f.mb_type[mb_pos] = r->is16 ? MB_TYPE_INTRA16x16 : MB_TYPE_INTRA; r->block_type = r->is16 ? RV34_MB_TYPE_INTRA16x16 : RV34_MB_TYPE_INTRA; }else{ r->block_type = r->decode_mb_info(r); if(r->block_type == -1) return -1; - s->current_picture_ptr->mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type]; + s->current_picture_ptr->f.mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type]; r->mb_type[mb_pos] = r->block_type; if(r->block_type == RV34_MB_SKIP){ if(s->pict_type == AV_PICTURE_TYPE_P) @@ -453,7 +453,7 @@ static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types) if(s->pict_type == AV_PICTURE_TYPE_B) r->mb_type[mb_pos] = RV34_MB_B_DIRECT; } - r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->mb_type[mb_pos]); + r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->f.mb_type[mb_pos]); rv34_decode_mv(r, r->block_type); if(r->block_type == RV34_MB_SKIP){ fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0])); @@ -462,7 +462,7 @@ static int rv34_decode_mb_header(RV34DecContext *r, int8_t *intra_types) r->chroma_vlc = 1; r->luma_vlc = 0; } - if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])){ + if(IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos])){ if(r->is16){ t = get_bits(gb, 2); fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0])); @@ -527,27 +527,27 @@ static void rv34_pred_mv(RV34DecContext *r, int block_type, int subblock_no, int c_off = -1; if(r->avail_cache[avail_index - 1]){ - A[0] = s->current_picture_ptr->motion_val[0][mv_pos-1][0]; - A[1] = s->current_picture_ptr->motion_val[0][mv_pos-1][1]; + A[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-1][0]; + A[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-1][1]; } if(r->avail_cache[avail_index - 4]){ - B[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][0]; - B[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][1]; + B[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride][0]; + B[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride][1]; }else{ B[0] = A[0]; B[1] = A[1]; } if(!r->avail_cache[avail_index - 4 + c_off]){ if(r->avail_cache[avail_index - 4] && (r->avail_cache[avail_index - 1] || r->rv30)){ - C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][0]; - C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][1]; + C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride-1][0]; + C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride-1][1]; }else{ C[0] = A[0]; C[1] = A[1]; } }else{ - C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+c_off][0]; - C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+c_off][1]; + C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride+c_off][0]; + C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride+c_off][1]; } mx = mid_pred(A[0], B[0], C[0]); my = mid_pred(A[1], B[1], C[1]); @@ -555,8 +555,8 @@ static void rv34_pred_mv(RV34DecContext *r, int block_type, int subblock_no, int my += r->dmv[dmv_no][1]; for(j = 0; j < part_sizes_h[block_type]; j++){ for(i = 0; i < part_sizes_w[block_type]; i++){ - s->current_picture_ptr->motion_val[0][mv_pos + i + j*s->b8_stride][0] = mx; - s->current_picture_ptr->motion_val[0][mv_pos + i + j*s->b8_stride][1] = my; + s->current_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][0] = mx; + s->current_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][1] = my; } } } @@ -611,28 +611,28 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir) int i, j; Picture *cur_pic = s->current_picture_ptr; const int mask = dir ? MB_TYPE_L1 : MB_TYPE_L0; - int type = cur_pic->mb_type[mb_pos]; + int type = cur_pic->f.mb_type[mb_pos]; memset(A, 0, sizeof(A)); memset(B, 0, sizeof(B)); memset(C, 0, sizeof(C)); if((r->avail_cache[6-1] & type) & mask){ - A[0] = cur_pic->motion_val[dir][mv_pos - 1][0]; - A[1] = cur_pic->motion_val[dir][mv_pos - 1][1]; + A[0] = cur_pic->f.motion_val[dir][mv_pos - 1][0]; + A[1] = cur_pic->f.motion_val[dir][mv_pos - 1][1]; has_A = 1; } if((r->avail_cache[6-4] & type) & mask){ - B[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][0]; - B[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][1]; + B[0] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride][0]; + B[1] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride][1]; has_B = 1; } if(r->avail_cache[6-4] && (r->avail_cache[6-2] & type) & mask){ - C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][0]; - C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][1]; + C[0] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride + 2][0]; + C[1] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride + 2][1]; has_C = 1; }else if((s->mb_x+1) == s->mb_width && (r->avail_cache[6-5] & type) & mask){ - C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride - 1][0]; - C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride - 1][1]; + C[0] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride - 1][0]; + C[1] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride - 1][1]; has_C = 1; } @@ -643,12 +643,12 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir) for(j = 0; j < 2; j++){ for(i = 0; i < 2; i++){ - cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][0] = mx; - cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][1] = my; + cur_pic->f.motion_val[dir][mv_pos + i + j*s->b8_stride][0] = mx; + cur_pic->f.motion_val[dir][mv_pos + i + j*s->b8_stride][1] = my; } } if(block_type == RV34_MB_B_BACKWARD || block_type == RV34_MB_B_FORWARD){ - ZERO8x2(cur_pic->motion_val[!dir][mv_pos], s->b8_stride); + ZERO8x2(cur_pic->f.motion_val[!dir][mv_pos], s->b8_stride); } } @@ -665,27 +665,27 @@ static void rv34_pred_mv_rv3(RV34DecContext *r, int block_type, int dir) int avail_index = avail_indexes[0]; if(r->avail_cache[avail_index - 1]){ - A[0] = s->current_picture_ptr->motion_val[0][mv_pos-1][0]; - A[1] = s->current_picture_ptr->motion_val[0][mv_pos-1][1]; + A[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - 1][0]; + A[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - 1][1]; } if(r->avail_cache[avail_index - 4]){ - B[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][0]; - B[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride][1]; + B[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride][0]; + B[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride][1]; }else{ B[0] = A[0]; B[1] = A[1]; } if(!r->avail_cache[avail_index - 4 + 2]){ if(r->avail_cache[avail_index - 4] && (r->avail_cache[avail_index - 1])){ - C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][0]; - C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride-1][1]; + C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride - 1][0]; + C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride - 1][1]; }else{ C[0] = A[0]; C[1] = A[1]; } }else{ - C[0] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+2][0]; - C[1] = s->current_picture_ptr->motion_val[0][mv_pos-s->b8_stride+2][1]; + C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride + 2][0]; + C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride + 2][1]; } mx = mid_pred(A[0], B[0], C[0]); my = mid_pred(A[1], B[1], C[1]); @@ -694,8 +694,8 @@ static void rv34_pred_mv_rv3(RV34DecContext *r, int block_type, int dir) for(j = 0; j < 2; j++){ for(i = 0; i < 2; i++){ for(k = 0; k < 2; k++){ - s->current_picture_ptr->motion_val[k][mv_pos + i + j*s->b8_stride][0] = mx; - s->current_picture_ptr->motion_val[k][mv_pos + i + j*s->b8_stride][1] = my; + s->current_picture_ptr->f.motion_val[k][mv_pos + i + j*s->b8_stride][0] = mx; + s->current_picture_ptr->f.motion_val[k][mv_pos + i + j*s->b8_stride][1] = my; } } } @@ -733,24 +733,24 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type, if(thirdpel){ int chroma_mx, chroma_my; - mx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + (3 << 24)) / 3 - (1 << 24); - my = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + (3 << 24)) / 3 - (1 << 24); - lx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + (3 << 24)) % 3; - ly = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + (3 << 24)) % 3; - chroma_mx = (s->current_picture_ptr->motion_val[dir][mv_pos][0] + 1) >> 1; - chroma_my = (s->current_picture_ptr->motion_val[dir][mv_pos][1] + 1) >> 1; + mx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + (3 << 24)) / 3 - (1 << 24); + my = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + (3 << 24)) / 3 - (1 << 24); + lx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + (3 << 24)) % 3; + ly = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + (3 << 24)) % 3; + chroma_mx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + 1) >> 1; + chroma_my = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + 1) >> 1; umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24); umy = (chroma_my + (3 << 24)) / 3 - (1 << 24); uvmx = chroma_coeffs[(chroma_mx + (3 << 24)) % 3]; uvmy = chroma_coeffs[(chroma_my + (3 << 24)) % 3]; }else{ int cx, cy; - mx = s->current_picture_ptr->motion_val[dir][mv_pos][0] >> 2; - my = s->current_picture_ptr->motion_val[dir][mv_pos][1] >> 2; - lx = s->current_picture_ptr->motion_val[dir][mv_pos][0] & 3; - ly = s->current_picture_ptr->motion_val[dir][mv_pos][1] & 3; - cx = s->current_picture_ptr->motion_val[dir][mv_pos][0] / 2; - cy = s->current_picture_ptr->motion_val[dir][mv_pos][1] / 2; + mx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] >> 2; + my = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] >> 2; + lx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] & 3; + ly = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] & 3; + cx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] / 2; + cy = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] / 2; umx = cx >> 2; umy = cy >> 2; uvmx = (cx & 3) << 1; @@ -760,9 +760,9 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type, uvmx = uvmy = 4; } dxy = ly*4 + lx; - srcY = dir ? s->next_picture_ptr->data[0] : s->last_picture_ptr->data[0]; - srcU = dir ? s->next_picture_ptr->data[1] : s->last_picture_ptr->data[1]; - srcV = dir ? s->next_picture_ptr->data[2] : s->last_picture_ptr->data[2]; + srcY = dir ? s->next_picture_ptr->f.data[0] : s->last_picture_ptr->f.data[0]; + srcU = dir ? s->next_picture_ptr->f.data[1] : s->last_picture_ptr->f.data[1]; + srcV = dir ? s->next_picture_ptr->f.data[2] : s->last_picture_ptr->f.data[2]; src_x = s->mb_x * 16 + xoff + mx; src_y = s->mb_y * 16 + yoff + my; uvsrc_x = s->mb_x * 8 + (xoff >> 1) + umx; @@ -870,31 +870,31 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type) switch(block_type){ case RV34_MB_TYPE_INTRA: case RV34_MB_TYPE_INTRA16x16: - ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); + ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); return 0; case RV34_MB_SKIP: if(s->pict_type == AV_PICTURE_TYPE_P){ - ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); + ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0); break; } case RV34_MB_B_DIRECT: //surprisingly, it uses motion scheme from next reference frame - next_bt = s->next_picture_ptr->mb_type[s->mb_x + s->mb_y * s->mb_stride]; + next_bt = s->next_picture_ptr->f.mb_type[s->mb_x + s->mb_y * s->mb_stride]; if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){ - ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); - ZERO8x2(s->current_picture_ptr->motion_val[1][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); + ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); + ZERO8x2(s->current_picture_ptr->f.motion_val[1][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); }else for(j = 0; j < 2; j++) for(i = 0; i < 2; i++) for(k = 0; k < 2; k++) for(l = 0; l < 2; l++) - s->current_picture_ptr->motion_val[l][mv_pos + i + j*s->b8_stride][k] = calc_add_mv(r, l, s->next_picture_ptr->motion_val[0][mv_pos + i + j*s->b8_stride][k]); + s->current_picture_ptr->f.motion_val[l][mv_pos + i + j*s->b8_stride][k] = calc_add_mv(r, l, s->next_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][k]); if(!(IS_16X8(next_bt) || IS_8X16(next_bt) || IS_8X8(next_bt))) //we can use whole macroblock MC rv34_mc_2mv(r, block_type); else rv34_mc_2mv_skip(r); - ZERO8x2(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); + ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); break; case RV34_MB_P_16x16: case RV34_MB_P_MIX16x16: @@ -1128,7 +1128,7 @@ static int rv34_set_deblock_coef(RV34DecContext *r) MpegEncContext *s = &r->s; int hmvmask = 0, vmvmask = 0, i, j; int midx = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; - int16_t (*motion_val)[2] = &s->current_picture_ptr->motion_val[0][midx]; + int16_t (*motion_val)[2] = &s->current_picture_ptr->f.motion_val[0][midx]; for(j = 0; j < 16; j += 8){ for(i = 0; i < 2; i++){ if(is_mv_diff_gt_3(motion_val + i, 1)) @@ -1170,14 +1170,14 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types) dist = (s->mb_x - s->resync_mb_x) + (s->mb_y - s->resync_mb_y) * s->mb_width; if(s->mb_x && dist) r->avail_cache[5] = - r->avail_cache[9] = s->current_picture_ptr->mb_type[mb_pos - 1]; + r->avail_cache[9] = s->current_picture_ptr->f.mb_type[mb_pos - 1]; if(dist >= s->mb_width) r->avail_cache[2] = - r->avail_cache[3] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride]; + r->avail_cache[3] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride]; if(((s->mb_x+1) < s->mb_width) && dist >= s->mb_width - 1) - r->avail_cache[4] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride + 1]; + r->avail_cache[4] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride + 1]; if(s->mb_x && dist > s->mb_width) - r->avail_cache[1] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride - 1]; + r->avail_cache[1] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride - 1]; s->qscale = r->si.quant; cbp = cbp2 = rv34_decode_mb_header(r, intra_types); @@ -1187,7 +1187,7 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types) r->deblock_coefs[mb_pos] = 0xFFFF; else r->deblock_coefs[mb_pos] = rv34_set_deblock_coef(r) | r->cbp_luma[mb_pos]; - s->current_picture_ptr->qscale_table[mb_pos] = s->qscale; + s->current_picture_ptr->f.qscale_table[mb_pos] = s->qscale; if(cbp == -1) return -1; @@ -1221,7 +1221,7 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types) rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]],rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]); rv34_inv_transform(s->block[blknum] + blkoff); } - if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])) + if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos])) rv34_output_macroblock(r, intra_types, cbp2, r->is16); else rv34_apply_differences(r, cbp2); @@ -1429,7 +1429,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n"); return -1; } - if((!s->last_picture_ptr || !s->last_picture_ptr->data[0]) && si.type == AV_PICTURE_TYPE_B) + if ((!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) && si.type == AV_PICTURE_TYPE_B) return -1; if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I) diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 46e77bc240..df97c3a4e5 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -475,7 +475,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row) mb_pos = row * s->mb_stride; for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){ - int mbtype = s->current_picture_ptr->mb_type[mb_pos]; + int mbtype = s->current_picture_ptr->f.mb_type[mb_pos]; if(IS_INTRA(mbtype) || IS_SEPARATE_DC(mbtype)) r->cbp_luma [mb_pos] = r->deblock_coefs[mb_pos] = 0xFFFF; if(IS_INTRA(mbtype)) @@ -489,7 +489,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row) int avail[4]; int y_to_deblock, c_to_deblock[2]; - q = s->current_picture_ptr->qscale_table[mb_pos]; + q = s->current_picture_ptr->f.qscale_table[mb_pos]; alpha = rv40_alpha_tab[q]; beta = rv40_beta_tab [q]; betaY = betaC = beta * 3; @@ -504,7 +504,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row) if(avail[i]){ int pos = mb_pos + neighbour_offs_x[i] + neighbour_offs_y[i]*s->mb_stride; mvmasks[i] = r->deblock_coefs[pos]; - mbtype [i] = s->current_picture_ptr->mb_type[pos]; + mbtype [i] = s->current_picture_ptr->f.mb_type[pos]; cbp [i] = r->cbp_luma[pos]; uvcbp[i][0] = r->cbp_chroma[pos] & 0xF; uvcbp[i][1] = r->cbp_chroma[pos] >> 4; @@ -563,7 +563,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row) } for(j = 0; j < 16; j += 4){ - Y = s->current_picture_ptr->data[0] + mb_x*16 + (row*16 + j) * s->linesize; + Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize; for(i = 0; i < 4; i++, Y += 4){ int ij = i + j; int clip_cur = y_to_deblock & (MASK_CUR << ij) ? clip[POS_CUR] : 0; @@ -607,7 +607,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row) } for(k = 0; k < 2; k++){ for(j = 0; j < 2; j++){ - C = s->current_picture_ptr->data[k+1] + mb_x*8 + (row*8 + j*4) * s->uvlinesize; + C = s->current_picture_ptr->f.data[k + 1] + mb_x*8 + (row*8 + j*4) * s->uvlinesize; for(i = 0; i < 2; i++, C += 4){ int ij = i + j*2; int clip_cur = c_to_deblock[k] & (MASK_CUR << ij) ? clip[POS_CUR] : 0; diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 6a63da7aa8..e1f6c57352 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -3441,8 +3441,8 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, frame_start(s); s->m.current_picture_ptr= &s->m.current_picture; - s->m.last_picture.pts= s->m.current_picture.pts; - s->m.current_picture.pts= pict->pts; + s->m.last_picture.f.pts = s->m.current_picture.f.pts; + s->m.current_picture.f.pts = pict->pts; if(pict->pict_type == AV_PICTURE_TYPE_P){ int block_width = (width +15)>>4; int block_height= (height+15)>>4; @@ -3452,14 +3452,14 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, assert(s->last_picture[0].data[0]); s->m.avctx= s->avctx; - s->m.current_picture.data[0]= s->current_picture.data[0]; - s->m. last_picture.data[0]= s->last_picture[0].data[0]; - s->m. new_picture.data[0]= s-> input_picture.data[0]; + s->m.current_picture.f.data[0] = s->current_picture.data[0]; + s->m. last_picture.f.data[0] = s->last_picture[0].data[0]; + s->m. new_picture.f.data[0] = s-> input_picture.data[0]; s->m. last_picture_ptr= &s->m. last_picture; s->m.linesize= - s->m. last_picture.linesize[0]= - s->m. new_picture.linesize[0]= - s->m.current_picture.linesize[0]= stride; + s->m. last_picture.f.linesize[0] = + s->m. new_picture.f.linesize[0] = + s->m.current_picture.f.linesize[0] = stride; s->m.uvlinesize= s->current_picture.linesize[1]; s->m.width = width; s->m.height= height; @@ -3646,9 +3646,9 @@ redo_frame: s->current_picture.quality = pict->quality; s->m.frame_bits = 8*(s->c.bytestream - s->c.bytestream_start); s->m.p_tex_bits = s->m.frame_bits - s->m.misc_bits - s->m.mv_bits; - s->m.current_picture.display_picture_number = - s->m.current_picture.coded_picture_number = avctx->frame_number; - s->m.current_picture.quality = pict->quality; + s->m.current_picture.f.display_picture_number = + s->m.current_picture.f.coded_picture_number = avctx->frame_number; + s->m.current_picture.f.quality = pict->quality; s->m.total_bits += 8*(s->c.bytestream - s->c.bytestream_start); if(s->pass1_rc) if (ff_rate_estimate_qscale(&s->m, 0) < 0) diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index 2a80374569..e949b5596d 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -689,12 +689,12 @@ static int svq1_decode_frame(AVCodecContext *avctx, linesize= s->uvlinesize; } - current = s->current_picture.data[i]; + current = s->current_picture.f.data[i]; if(s->pict_type==AV_PICTURE_TYPE_B){ - previous = s->next_picture.data[i]; + previous = s->next_picture.f.data[i]; }else{ - previous = s->last_picture.data[i]; + previous = s->last_picture.f.data[i]; } if (s->pict_type == AV_PICTURE_TYPE_I) { diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index fbeca803f0..4fdfefa664 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -284,11 +284,11 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane s->m.avctx= s->avctx; s->m.current_picture_ptr= &s->m.current_picture; s->m.last_picture_ptr = &s->m.last_picture; - s->m.last_picture.data[0]= ref_plane; + s->m.last_picture.f.data[0] = ref_plane; s->m.linesize= - s->m.last_picture.linesize[0]= - s->m.new_picture.linesize[0]= - s->m.current_picture.linesize[0]= stride; + s->m.last_picture.f.linesize[0] = + s->m.new_picture.f.linesize[0] = + s->m.current_picture.f.linesize[0] = stride; s->m.width= width; s->m.height= height; s->m.mb_width= block_width; @@ -318,9 +318,9 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane s->m.current_picture.mb_mean= (uint8_t *)s->dummy; s->m.current_picture.mb_var= (uint16_t*)s->dummy; s->m.current_picture.mc_mb_var= (uint16_t*)s->dummy; - s->m.current_picture.mb_type= s->dummy; + s->m.current_picture.f.mb_type = s->dummy; - s->m.current_picture.motion_val[0]= s->motion_val8[plane] + 2; + s->m.current_picture.f.motion_val[0] = s->motion_val8[plane] + 2; s->m.p_mv_table= s->motion_val16[plane] + s->m.mb_stride + 1; s->m.dsp= s->dsp; //move ff_init_me(&s->m); @@ -328,7 +328,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane s->m.me.dia_size= s->avctx->dia_size; s->m.first_slice_line=1; for (y = 0; y < block_height; y++) { - s->m.new_picture.data[0]= src - y*16*stride; //ugly + s->m.new_picture.f.data[0] = src - y*16*stride; //ugly s->m.mb_y= y; for(i=0; i<16 && i + 16*ycurrent_picture.data[0] + x + y*s->linesize; - src = pic->data[0] + mx + my*s->linesize; + dest = s->current_picture.f.data[0] + x + y*s->linesize; + src = pic->f.data[0] + mx + my*s->linesize; if (emu) { s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, (width + 1), (height + 1), @@ -309,8 +309,8 @@ static inline void svq3_mc_dir_part(MpegEncContext *s, blocksize++; for (i = 1; i < 3; i++) { - dest = s->current_picture.data[i] + (x >> 1) + (y >> 1)*s->uvlinesize; - src = pic->data[i] + mx + my*s->uvlinesize; + dest = s->current_picture.f.data[i] + (x >> 1) + (y >> 1) * s->uvlinesize; + src = pic->f.data[i] + mx + my * s->uvlinesize; if (emu) { s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->uvlinesize, (width + 1), (height + 1), @@ -347,8 +347,8 @@ static inline int svq3_mc_dir(H264Context *h, int size, int mode, int dir, if (mode != PREDICT_MODE) { pred_motion(h, k, (part_width >> 2), dir, 1, &mx, &my); } else { - mx = s->next_picture.motion_val[0][b_xy][0]<<1; - my = s->next_picture.motion_val[0][b_xy][1]<<1; + mx = s->next_picture.f.motion_val[0][b_xy][0] << 1; + my = s->next_picture.f.motion_val[0][b_xy][1] << 1; if (dir == 0) { mx = ((mx * h->frame_num_offset) / h->prev_frame_num_offset + 1) >> 1; @@ -425,7 +425,9 @@ static inline int svq3_mc_dir(H264Context *h, int size, int mode, int dir, } /* write back motion vectors */ - fill_rectangle(s->current_picture.motion_val[dir][b_xy], part_width>>2, part_height>>2, h->b_stride, pack16to32(mx,my), 4); + fill_rectangle(s->current_picture.f.motion_val[dir][b_xy], + part_width >> 2, part_height >> 2, h->b_stride, + pack16to32(mx, my), 4); } } @@ -448,7 +450,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) h->topright_samples_available = 0xFFFF; if (mb_type == 0) { /* SKIP */ - if (s->pict_type == AV_PICTURE_TYPE_P || s->next_picture.mb_type[mb_xy] == -1) { + if (s->pict_type == AV_PICTURE_TYPE_P || s->next_picture.f.mb_type[mb_xy] == -1) { svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 0, 0); if (s->pict_type == AV_PICTURE_TYPE_B) { @@ -457,7 +459,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) mb_type = MB_TYPE_SKIP; } else { - mb_type = FFMIN(s->next_picture.mb_type[mb_xy], 6); + mb_type = FFMIN(s->next_picture.f.mb_type[mb_xy], 6); if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 0, 0) < 0) return -1; if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 1, 1) < 0) @@ -486,7 +488,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) for (m = 0; m < 2; m++) { if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) { for (i = 0; i < 4; i++) { - *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - 1 + i*h->b_stride]; + *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - 1 + i*h->b_stride]; } } else { for (i = 0; i < 4; i++) { @@ -494,18 +496,18 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) } } if (s->mb_y > 0) { - memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t)); + memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.f.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t)); memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4); if (s->mb_x < (s->mb_width - 1)) { - *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride + 4]; + *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride + 4]; h->ref_cache[m][scan8[0] + 4 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 || h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride ] ] == -1) ? PART_NOT_AVAILABLE : 1; }else h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE; if (s->mb_x > 0) { - *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride - 1]; + *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride - 1]; h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] == -1) ? PART_NOT_AVAILABLE : 1; }else h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE; @@ -526,7 +528,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) return -1; } else { for (i = 0; i < 4; i++) { - memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); + memset(s->current_picture.f.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } } if (mb_type != 1) { @@ -534,7 +536,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) return -1; } else { for (i = 0; i < 4; i++) { - memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); + memset(s->current_picture.f.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } } } @@ -621,11 +623,11 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) if (!IS_INTER(mb_type) && s->pict_type != AV_PICTURE_TYPE_I) { for (i = 0; i < 4; i++) { - memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); + memset(s->current_picture.f.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } if (s->pict_type == AV_PICTURE_TYPE_B) { for (i = 0; i < 4; i++) { - memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); + memset(s->current_picture.f.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t)); } } } @@ -706,7 +708,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) } h->cbp= cbp; - s->current_picture.mb_type[mb_xy] = mb_type; + s->current_picture.f.mb_type[mb_xy] = mb_type; if (IS_INTRA(mb_type)) { h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8); @@ -966,8 +968,8 @@ static int svq3_decode_frame(AVCodecContext *avctx, } /* for skipping the frame */ - s->current_picture.pict_type = s->pict_type; - s->current_picture.key_frame = (s->pict_type == AV_PICTURE_TYPE_I); + s->current_picture.f.pict_type = s->pict_type; + s->current_picture.f.key_frame = (s->pict_type == AV_PICTURE_TYPE_I); /* Skip B-frames if we do not have reference frames. */ if (s->last_picture_ptr == NULL && s->pict_type == AV_PICTURE_TYPE_B) @@ -1051,7 +1053,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, } if (s->pict_type != AV_PICTURE_TYPE_B && !s->low_delay) { - s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] = + s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride] = (s->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1; } } diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index cf828dd1f0..d20fc893d3 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -407,15 +407,15 @@ static void vc1_mc_1mv(VC1Context *v, int dir) uint8_t *srcY, *srcU, *srcV; int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; - if(!v->s.last_picture.data[0])return; + if(!v->s.last_picture.f.data[0])return; mx = s->mv[dir][0][0]; my = s->mv[dir][0][1]; // store motion vectors for further use in B frames if(s->pict_type == AV_PICTURE_TYPE_P) { - s->current_picture.motion_val[1][s->block_index[0]][0] = mx; - s->current_picture.motion_val[1][s->block_index[0]][1] = my; + s->current_picture.f.motion_val[1][s->block_index[0]][0] = mx; + s->current_picture.f.motion_val[1][s->block_index[0]][1] = my; } uvmx = (mx + ((mx & 3) == 3)) >> 1; uvmy = (my + ((my & 3) == 3)) >> 1; @@ -426,13 +426,13 @@ static void vc1_mc_1mv(VC1Context *v, int dir) uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1)); } if(!dir) { - srcY = s->last_picture.data[0]; - srcU = s->last_picture.data[1]; - srcV = s->last_picture.data[2]; + srcY = s->last_picture.f.data[0]; + srcU = s->last_picture.f.data[1]; + srcV = s->last_picture.f.data[2]; } else { - srcY = s->next_picture.data[0]; - srcU = s->next_picture.data[1]; - srcV = s->next_picture.data[2]; + srcY = s->next_picture.f.data[0]; + srcU = s->next_picture.f.data[1]; + srcV = s->next_picture.f.data[2]; } src_x = s->mb_x * 16 + (mx >> 2); @@ -559,10 +559,10 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n) int dxy, mx, my, src_x, src_y; int off; - if(!v->s.last_picture.data[0])return; + if(!v->s.last_picture.f.data[0])return; mx = s->mv[0][n][0]; my = s->mv[0][n][1]; - srcY = s->last_picture.data[0]; + srcY = s->last_picture.f.data[0]; off = s->linesize * 4 * (n&2) + (n&1) * 8; @@ -647,7 +647,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v) int mvx[4], mvy[4], intra[4]; static const int count[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; - if(!v->s.last_picture.data[0])return; + if(!v->s.last_picture.f.data[0])return; if(s->flags & CODEC_FLAG_GRAY) return; for(i = 0; i < 4; i++) { @@ -687,14 +687,14 @@ static void vc1_mc_4mv_chroma(VC1Context *v) tx = (mvx[t1] + mvx[t2]) / 2; ty = (mvy[t1] + mvy[t2]) / 2; } else { - s->current_picture.motion_val[1][s->block_index[0]][0] = 0; - s->current_picture.motion_val[1][s->block_index[0]][1] = 0; + s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; + s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; return; //no need to do MC for inter blocks } - s->current_picture.motion_val[1][s->block_index[0]][0] = tx; - s->current_picture.motion_val[1][s->block_index[0]][1] = ty; + s->current_picture.f.motion_val[1][s->block_index[0]][0] = tx; + s->current_picture.f.motion_val[1][s->block_index[0]][1] = ty; uvmx = (tx + ((tx&3) == 3)) >> 1; uvmy = (ty + ((ty&3) == 3)) >> 1; v->luma_mv[s->mb_x][0] = uvmx; @@ -715,8 +715,8 @@ static void vc1_mc_4mv_chroma(VC1Context *v) uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); } - srcU = s->last_picture.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; - srcV = s->last_picture.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; + srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; + srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9 || (unsigned)uvsrc_y > (s->v_edge_pos >> 1) - 9){ @@ -883,30 +883,30 @@ static inline void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int m xy = s->block_index[n]; if(s->mb_intra){ - s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = 0; - s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = 0; - s->current_picture.motion_val[1][xy][0] = 0; - s->current_picture.motion_val[1][xy][1] = 0; + s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = 0; + s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = 0; + s->current_picture.f.motion_val[1][xy][0] = 0; + s->current_picture.f.motion_val[1][xy][1] = 0; if(mv1) { /* duplicate motion data for 1-MV block */ - s->current_picture.motion_val[0][xy + 1][0] = 0; - s->current_picture.motion_val[0][xy + 1][1] = 0; - s->current_picture.motion_val[0][xy + wrap][0] = 0; - s->current_picture.motion_val[0][xy + wrap][1] = 0; - s->current_picture.motion_val[0][xy + wrap + 1][0] = 0; - s->current_picture.motion_val[0][xy + wrap + 1][1] = 0; + s->current_picture.f.motion_val[0][xy + 1][0] = 0; + s->current_picture.f.motion_val[0][xy + 1][1] = 0; + s->current_picture.f.motion_val[0][xy + wrap][0] = 0; + s->current_picture.f.motion_val[0][xy + wrap][1] = 0; + s->current_picture.f.motion_val[0][xy + wrap + 1][0] = 0; + s->current_picture.f.motion_val[0][xy + wrap + 1][1] = 0; v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; - s->current_picture.motion_val[1][xy + 1][0] = 0; - s->current_picture.motion_val[1][xy + 1][1] = 0; - s->current_picture.motion_val[1][xy + wrap][0] = 0; - s->current_picture.motion_val[1][xy + wrap][1] = 0; - s->current_picture.motion_val[1][xy + wrap + 1][0] = 0; - s->current_picture.motion_val[1][xy + wrap + 1][1] = 0; + s->current_picture.f.motion_val[1][xy + 1][0] = 0; + s->current_picture.f.motion_val[1][xy + 1][1] = 0; + s->current_picture.f.motion_val[1][xy + wrap][0] = 0; + s->current_picture.f.motion_val[1][xy + wrap][1] = 0; + s->current_picture.f.motion_val[1][xy + wrap + 1][0] = 0; + s->current_picture.f.motion_val[1][xy + wrap + 1][1] = 0; } return; } - C = s->current_picture.motion_val[0][xy - 1]; - A = s->current_picture.motion_val[0][xy - wrap]; + C = s->current_picture.f.motion_val[0][xy - 1]; + A = s->current_picture.f.motion_val[0][xy - wrap]; if(mv1) off = (s->mb_x == (s->mb_width - 1)) ? -1 : 2; else { @@ -925,7 +925,7 @@ static inline void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int m off = -1; } } - B = s->current_picture.motion_val[0][xy - wrap + off]; + B = s->current_picture.f.motion_val[0][xy - wrap + off]; if(!s->first_slice_line || (n==2 || n==3)) { // predictor A is not out of bounds if(s->mb_width == 1) { @@ -989,15 +989,15 @@ static inline void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int m } } /* store MV using signed modulus of MV range defined in 4.11 */ - s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x; - s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y; + s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x; + s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y; if(mv1) { /* duplicate motion data for 1-MV block */ - s->current_picture.motion_val[0][xy + 1][0] = s->current_picture.motion_val[0][xy][0]; - s->current_picture.motion_val[0][xy + 1][1] = s->current_picture.motion_val[0][xy][1]; - s->current_picture.motion_val[0][xy + wrap][0] = s->current_picture.motion_val[0][xy][0]; - s->current_picture.motion_val[0][xy + wrap][1] = s->current_picture.motion_val[0][xy][1]; - s->current_picture.motion_val[0][xy + wrap + 1][0] = s->current_picture.motion_val[0][xy][0]; - s->current_picture.motion_val[0][xy + wrap + 1][1] = s->current_picture.motion_val[0][xy][1]; + s->current_picture.f.motion_val[0][xy + 1][0] = s->current_picture.f.motion_val[0][xy][0]; + s->current_picture.f.motion_val[0][xy + 1][1] = s->current_picture.f.motion_val[0][xy][1]; + s->current_picture.f.motion_val[0][xy + wrap][0] = s->current_picture.f.motion_val[0][xy][0]; + s->current_picture.f.motion_val[0][xy + wrap][1] = s->current_picture.f.motion_val[0][xy][1]; + s->current_picture.f.motion_val[0][xy + wrap + 1][0] = s->current_picture.f.motion_val[0][xy][0]; + s->current_picture.f.motion_val[0][xy + wrap + 1][1] = s->current_picture.f.motion_val[0][xy][1]; } } @@ -1010,7 +1010,7 @@ static void vc1_interp_mc(VC1Context *v) uint8_t *srcY, *srcU, *srcV; int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; - if(!v->s.next_picture.data[0])return; + if(!v->s.next_picture.f.data[0])return; mx = s->mv[1][0][0]; my = s->mv[1][0][1]; @@ -1020,9 +1020,9 @@ static void vc1_interp_mc(VC1Context *v) uvmx = uvmx + ((uvmx<0)?-(uvmx&1):(uvmx&1)); uvmy = uvmy + ((uvmy<0)?-(uvmy&1):(uvmy&1)); } - srcY = s->next_picture.data[0]; - srcU = s->next_picture.data[1]; - srcV = s->next_picture.data[2]; + srcY = s->next_picture.f.data[0]; + srcU = s->next_picture.f.data[1]; + srcV = s->next_picture.f.data[2]; src_x = s->mb_x * 16 + (mx >> 2); src_y = s->mb_y * 16 + (my >> 2); @@ -1185,16 +1185,16 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int xy = s->block_index[0]; if(s->mb_intra) { - s->current_picture.motion_val[0][xy][0] = - s->current_picture.motion_val[0][xy][1] = - s->current_picture.motion_val[1][xy][0] = - s->current_picture.motion_val[1][xy][1] = 0; + s->current_picture.f.motion_val[0][xy][0] = + s->current_picture.f.motion_val[0][xy][1] = + s->current_picture.f.motion_val[1][xy][0] = + s->current_picture.f.motion_val[1][xy][1] = 0; return; } - s->mv[0][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample); - s->mv[0][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample); - s->mv[1][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample); - s->mv[1][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 1, s->quarter_sample); + s->mv[0][0][0] = scale_mv(s->next_picture.f.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample); + s->mv[0][0][1] = scale_mv(s->next_picture.f.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample); + s->mv[1][0][0] = scale_mv(s->next_picture.f.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample); + s->mv[1][0][1] = scale_mv(s->next_picture.f.motion_val[1][xy][1], v->bfraction, 1, s->quarter_sample); /* Pullback predicted motion vectors as specified in 8.4.5.4 */ s->mv[0][0][0] = av_clip(s->mv[0][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); @@ -1202,18 +1202,18 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int s->mv[1][0][0] = av_clip(s->mv[1][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); s->mv[1][0][1] = av_clip(s->mv[1][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); if(direct) { - s->current_picture.motion_val[0][xy][0] = s->mv[0][0][0]; - s->current_picture.motion_val[0][xy][1] = s->mv[0][0][1]; - s->current_picture.motion_val[1][xy][0] = s->mv[1][0][0]; - s->current_picture.motion_val[1][xy][1] = s->mv[1][0][1]; + s->current_picture.f.motion_val[0][xy][0] = s->mv[0][0][0]; + s->current_picture.f.motion_val[0][xy][1] = s->mv[0][0][1]; + s->current_picture.f.motion_val[1][xy][0] = s->mv[1][0][0]; + s->current_picture.f.motion_val[1][xy][1] = s->mv[1][0][1]; return; } if((mvtype == BMV_TYPE_FORWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { - C = s->current_picture.motion_val[0][xy - 2]; - A = s->current_picture.motion_val[0][xy - wrap*2]; + C = s->current_picture.f.motion_val[0][xy - 2]; + A = s->current_picture.f.motion_val[0][xy - wrap*2]; off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; - B = s->current_picture.motion_val[0][xy - wrap*2 + off]; + B = s->current_picture.f.motion_val[0][xy - wrap*2 + off]; if(!s->mb_x) C[0] = C[1] = 0; if(!s->first_slice_line) { // predictor A is not out of bounds @@ -1288,10 +1288,10 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int s->mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y; } if((mvtype == BMV_TYPE_BACKWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { - C = s->current_picture.motion_val[1][xy - 2]; - A = s->current_picture.motion_val[1][xy - wrap*2]; + C = s->current_picture.f.motion_val[1][xy - 2]; + A = s->current_picture.f.motion_val[1][xy - wrap*2]; off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; - B = s->current_picture.motion_val[1][xy - wrap*2 + off]; + B = s->current_picture.f.motion_val[1][xy - wrap*2 + off]; if(!s->mb_x) C[0] = C[1] = 0; if(!s->first_slice_line) { // predictor A is not out of bounds @@ -1366,10 +1366,10 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int s->mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x; s->mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y; } - s->current_picture.motion_val[0][xy][0] = s->mv[0][0][0]; - s->current_picture.motion_val[0][xy][1] = s->mv[0][0][1]; - s->current_picture.motion_val[1][xy][0] = s->mv[1][0][0]; - s->current_picture.motion_val[1][xy][1] = s->mv[1][0][1]; + s->current_picture.f.motion_val[0][xy][0] = s->mv[0][0][0]; + s->current_picture.f.motion_val[0][xy][1] = s->mv[0][0][1]; + s->current_picture.f.motion_val[1][xy][0] = s->mv[1][0][0]; + s->current_picture.f.motion_val[1][xy][1] = s->mv[1][0][1]; } /** Get predicted DC value for I-frames only @@ -1464,14 +1464,14 @@ static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, b = dc_val[ - 1 - wrap]; a = dc_val[ - wrap]; /* scale predictors if needed */ - q1 = s->current_picture.qscale_table[mb_pos]; + q1 = s->current_picture.f.qscale_table[mb_pos]; if(c_avail && (n!= 1 && n!=3)) { - q2 = s->current_picture.qscale_table[mb_pos - 1]; + q2 = s->current_picture.f.qscale_table[mb_pos - 1]; if(q2 && q2 != q1) c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; } if(a_avail && (n!= 2 && n!=3)) { - q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride]; + q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride]; if(q2 && q2 != q1) a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; } @@ -1479,7 +1479,7 @@ static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, int off = mb_pos; if(n != 1) off--; if(n != 2) off -= s->mb_stride; - q2 = s->current_picture.qscale_table[off]; + q2 = s->current_picture.f.qscale_table[off]; if(q2 && q2 != q1) b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; } @@ -1853,9 +1853,9 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c else //top ac_val -= 16 * s->block_wrap[n]; - q1 = s->current_picture.qscale_table[mb_pos]; - if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.qscale_table[mb_pos - 1]; - if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride]; + q1 = s->current_picture.f.qscale_table[mb_pos]; + if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.f.qscale_table[mb_pos - 1]; + if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride]; if(dc_pred_dir && n==1) q2 = q1; if(!dc_pred_dir && n==2) q2 = q1; if(n==3) q2 = q1; @@ -2060,9 +2060,9 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c else //top ac_val -= 16 * s->block_wrap[n]; - q1 = s->current_picture.qscale_table[mb_pos]; - if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.qscale_table[mb_pos - 1]; - if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride]; + q1 = s->current_picture.f.qscale_table[mb_pos]; + if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.f.qscale_table[mb_pos - 1]; + if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride]; if(dc_pred_dir && n==1) q2 = q1; if(!dc_pred_dir && n==2) q2 = q1; if(n==3) q2 = q1; @@ -2344,7 +2344,7 @@ static av_always_inline void vc1_apply_p_v_loop_filter(VC1Context *v, int block_ bottom_is_intra = (block_num < 2) ? (mb_is_intra >> ((block_num + 2) * 4)) : (v->is_intra[s->mb_x] >> ((block_num - 2) * 4)); mv_stride = s->b8_stride; - mv = &s->current_picture.motion_val[0][s->block_index[block_num] - 2 * mv_stride]; + mv = &s->current_picture.f.motion_val[0][s->block_index[block_num] - 2 * mv_stride]; } if (bottom_is_intra & 1 || block_is_intra & 1 || @@ -2406,7 +2406,7 @@ static av_always_inline void vc1_apply_p_h_loop_filter(VC1Context *v, int block_ (mb_cbp >> ((block_num + 1) * 4)); right_is_intra = (block_num & 1) ? (v->is_intra[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4)) : (mb_is_intra >> ((block_num + 1) * 4)); - mv = &s->current_picture.motion_val[0][s->block_index[block_num] - s->b8_stride * 2 - 2]; + mv = &s->current_picture.f.motion_val[0][s->block_index[block_num] - s->b8_stride * 2 - 2]; } if (block_is_intra & 1 || right_is_intra & 1 || mv[0][0] != mv[1][0] || mv[0][1] != mv[1][1]) { v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq); @@ -2502,10 +2502,10 @@ static int vc1_decode_p_mb(VC1Context *v) GET_MVDATA(dmv_x, dmv_y); if (s->mb_intra) { - s->current_picture.motion_val[1][s->block_index[0]][0] = 0; - s->current_picture.motion_val[1][s->block_index[0]][1] = 0; + s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; + s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; } - s->current_picture.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16; + s->current_picture.f.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16; vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]); /* FIXME Set DC val for inter block ? */ @@ -2526,7 +2526,7 @@ static int vc1_decode_p_mb(VC1Context *v) mquant = v->pq; cbp = 0; } - s->current_picture.qscale_table[mb_pos] = mquant; + s->current_picture.f.qscale_table[mb_pos] = mquant; if (!v->ttmbf && !s->mb_intra && mb_has_coeffs) ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, @@ -2576,8 +2576,8 @@ static int vc1_decode_p_mb(VC1Context *v) v->mb_type[0][s->block_index[i]] = 0; s->dc_val[0][s->block_index[i]] = 0; } - s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP; - s->current_picture.qscale_table[mb_pos] = 0; + s->current_picture.f.mb_type[mb_pos] = MB_TYPE_SKIP; + s->current_picture.f.qscale_table[mb_pos] = 0; vc1_pred_mv(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]); vc1_mc_1mv(v, 0); } @@ -2621,7 +2621,7 @@ static int vc1_decode_p_mb(VC1Context *v) if(!intra_count && !coded_inter) goto end; GET_MQUANT(); - s->current_picture.qscale_table[mb_pos] = mquant; + s->current_picture.f.qscale_table[mb_pos] = mquant; /* test if block is intra and has pred */ { int intrapred = 0; @@ -2675,7 +2675,7 @@ static int vc1_decode_p_mb(VC1Context *v) else //Skipped MB { s->mb_intra = 0; - s->current_picture.qscale_table[mb_pos] = 0; + s->current_picture.f.qscale_table[mb_pos] = 0; for (i=0; i<6; i++) { v->mb_type[0][s->block_index[i]] = 0; s->dc_val[0][s->block_index[i]] = 0; @@ -2686,7 +2686,7 @@ static int vc1_decode_p_mb(VC1Context *v) vc1_mc_4mv_luma(v, i); } vc1_mc_4mv_chroma(v); - s->current_picture.qscale_table[mb_pos] = 0; + s->current_picture.f.qscale_table[mb_pos] = 0; } } end: @@ -2734,7 +2734,7 @@ static void vc1_decode_b_mb(VC1Context *v) v->mb_type[0][s->block_index[i]] = 0; s->dc_val[0][s->block_index[i]] = 0; } - s->current_picture.qscale_table[mb_pos] = 0; + s->current_picture.f.qscale_table[mb_pos] = 0; if (!direct) { if (!skipped) { @@ -2770,7 +2770,7 @@ static void vc1_decode_b_mb(VC1Context *v) cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); GET_MQUANT(); s->mb_intra = 0; - s->current_picture.qscale_table[mb_pos] = mquant; + s->current_picture.f.qscale_table[mb_pos] = mquant; if(!v->ttmbf) ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0; @@ -2785,7 +2785,7 @@ static void vc1_decode_b_mb(VC1Context *v) } if(s->mb_intra && !mb_has_coeffs) { GET_MQUANT(); - s->current_picture.qscale_table[mb_pos] = mquant; + s->current_picture.f.qscale_table[mb_pos] = mquant; s->ac_pred = get_bits1(gb); cbp = 0; vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); @@ -2807,7 +2807,7 @@ static void vc1_decode_b_mb(VC1Context *v) s->ac_pred = get_bits1(gb); cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); GET_MQUANT(); - s->current_picture.qscale_table[mb_pos] = mquant; + s->current_picture.f.qscale_table[mb_pos] = mquant; if(!v->ttmbf && !s->mb_intra && mb_has_coeffs) ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); } @@ -2898,10 +2898,10 @@ static void vc1_decode_i_blocks(VC1Context *v) dst[5] = s->dest[2]; s->dsp.clear_blocks(s->block[0]); mb_pos = s->mb_x + s->mb_y * s->mb_width; - s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA; - s->current_picture.qscale_table[mb_pos] = v->pq; - s->current_picture.motion_val[1][s->block_index[0]][0] = 0; - s->current_picture.motion_val[1][s->block_index[0]][1] = 0; + s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA; + s->current_picture.f.qscale_table[mb_pos] = v->pq; + s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; + s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; // do actual MB decoding and displaying cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); @@ -3029,9 +3029,9 @@ static void vc1_decode_i_blocks_adv(VC1Context *v) ff_update_block_index(s); s->dsp.clear_blocks(block[0]); mb_pos = s->mb_x + s->mb_y * s->mb_stride; - s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA; - s->current_picture.motion_val[1][s->block_index[0]][0] = 0; - s->current_picture.motion_val[1][s->block_index[0]][1] = 0; + s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA; + s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; + s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; // do actual MB decoding and displaying cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); @@ -3045,7 +3045,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v) GET_MQUANT(); - s->current_picture.qscale_table[mb_pos] = mquant; + s->current_picture.f.qscale_table[mb_pos] = mquant; /* Set DC scale - y and c use the same */ s->y_dc_scale = s->y_dc_scale_table[mquant]; s->c_dc_scale = s->c_dc_scale_table[mquant]; @@ -3232,9 +3232,9 @@ static void vc1_decode_skip_blocks(VC1Context *v) s->mb_x = 0; ff_init_block_index(s); ff_update_block_index(s); - memcpy(s->dest[0], s->last_picture.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16); - memcpy(s->dest[1], s->last_picture.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); - memcpy(s->dest[2], s->last_picture.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); + memcpy(s->dest[0], s->last_picture.f.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16); + memcpy(s->dest[1], s->last_picture.f.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); + memcpy(s->dest[2], s->last_picture.f.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); ff_draw_horiz_band(s, s->mb_y * 16, 16); s->first_slice_line = 0; } @@ -3601,7 +3601,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, /* We need to set current_picture_ptr before reading the header, * otherwise we cannot store anything in there. */ - if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ + if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) { int i= ff_find_unused_picture(s, 0); s->current_picture_ptr= &s->picture[i]; } @@ -3699,8 +3699,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, } // for skipping the frame - s->current_picture.pict_type= s->pict_type; - s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I; + s->current_picture.f.pict_type = s->pict_type; + s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; /* skip B-frames if we don't have reference frames */ if(s->last_picture_ptr==NULL && (s->pict_type==AV_PICTURE_TYPE_B || s->dropable)){ @@ -3756,8 +3756,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, MPV_frame_end(s); -assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); -assert(s->current_picture.pict_type == s->pict_type); +assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type); +assert(s->current_picture.f.pict_type == s->pict_type); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { *pict= *(AVFrame*)s->current_picture_ptr; } else if (s->last_picture_ptr != NULL) { diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index ede5236559..20ffbb736e 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -32,7 +32,7 @@ static void parse_mb_skip(Wmv2Context * w){ int mb_x, mb_y; MpegEncContext * const s= &w->s; - uint32_t * const mb_type= s->current_picture_ptr->mb_type; + uint32_t * const mb_type = s->current_picture_ptr->f.mb_type; w->skip_type= get_bits(&s->gb, 2); switch(w->skip_type){ @@ -257,11 +257,11 @@ static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py){ wrap = s->b8_stride; xy = s->block_index[0]; - mot_val = s->current_picture.motion_val[0][xy]; + mot_val = s->current_picture.f.motion_val[0][xy]; - A = s->current_picture.motion_val[0][xy - 1]; - B = s->current_picture.motion_val[0][xy - wrap]; - C = s->current_picture.motion_val[0][xy + 2 - wrap]; + A = s->current_picture.f.motion_val[0][xy - 1]; + B = s->current_picture.f.motion_val[0][xy - wrap]; + C = s->current_picture.f.motion_val[0][xy + 2 - wrap]; if(s->mb_x && !s->first_slice_line && !s->mspel && w->top_left_mv_flag) diff= FFMAX(FFABS(A[0] - B[0]), FFABS(A[1] - B[1])); @@ -343,7 +343,7 @@ int ff_wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) if(w->j_type) return 0; if (s->pict_type == AV_PICTURE_TYPE_P) { - if(IS_SKIP(s->current_picture.mb_type[s->mb_y * s->mb_stride + s->mb_x])){ + if (IS_SKIP(s->current_picture.f.mb_type[s->mb_y * s->mb_stride + s->mb_x])) { /* skip mb */ s->mb_intra = 0; for(i=0;i<6;i++) From 1765aacb17fd1df0cd794a9ddc95e22d272434cb Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 10 Jul 2011 23:55:06 +0100 Subject: [PATCH 433/780] hwaccel: unbreak build Signed-off-by: Mans Rullgard --- libavcodec/mpegvideo_xvmc.c | 14 ++++++------- libavcodec/vaapi_h264.c | 10 +++++----- libavcodec/vaapi_internal.h | 2 +- libavcodec/vaapi_mpeg4.c | 2 +- libavcodec/vdpau.c | 40 ++++++++++++++++++------------------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/libavcodec/mpegvideo_xvmc.c b/libavcodec/mpegvideo_xvmc.c index 29d8bbbde6..159fe21b58 100644 --- a/libavcodec/mpegvideo_xvmc.c +++ b/libavcodec/mpegvideo_xvmc.c @@ -41,7 +41,7 @@ */ void ff_xvmc_init_block(MpegEncContext *s) { - struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.data[2]; + struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2]; assert(render && render->xvmc_id == AV_XVMC_ID); s->block = (DCTELEM (*)[64])(render->data_blocks + render->next_free_data_block_num * 64); @@ -73,7 +73,7 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) */ int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx) { - struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.data[2]; + struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2]; const int mb_block_count = 4 + (1 << s->chroma_format); assert(avctx); @@ -113,7 +113,7 @@ int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx) case AV_PICTURE_TYPE_I: return 0; // no prediction from other frames case AV_PICTURE_TYPE_B: - next = (struct xvmc_pix_fmt*)s->next_picture.data[2]; + next = (struct xvmc_pix_fmt*)s->next_picture.f.data[2]; if (!next) return -1; if (next->xvmc_id != AV_XVMC_ID) @@ -121,7 +121,7 @@ int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx) render->p_future_surface = next->p_surface; // no return here, going to set forward prediction case AV_PICTURE_TYPE_P: - last = (struct xvmc_pix_fmt*)s->last_picture.data[2]; + last = (struct xvmc_pix_fmt*)s->last_picture.f.data[2]; if (!last) last = render; // predict second field from the first if (last->xvmc_id != AV_XVMC_ID) @@ -141,7 +141,7 @@ return -1; */ void ff_xvmc_field_end(MpegEncContext *s) { - struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.data[2]; + struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2]; assert(render); if (render->filled_mv_blocks_num > 0) @@ -179,10 +179,10 @@ void ff_xvmc_decode_mb(MpegEncContext *s) // Do I need to export quant when I could not perform postprocessing? // Anyway, it doesn't hurt. - s->current_picture.qscale_table[mb_xy] = s->qscale; + s->current_picture.f.qscale_table[mb_xy] = s->qscale; // start of XVMC-specific code - render = (struct xvmc_pix_fmt*)s->current_picture.data[2]; + render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2]; assert(render); assert(render->xvmc_id == AV_XVMC_ID); assert(render->mv_blocks); diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c index 83bf2907de..f6d1a6d48e 100644 --- a/libavcodec/vaapi_h264.c +++ b/libavcodec/vaapi_h264.c @@ -54,7 +54,7 @@ static void fill_vaapi_pic(VAPictureH264 *va_pic, int pic_structure) { if (pic_structure == 0) - pic_structure = pic->reference; + pic_structure = pic->f.reference; pic_structure &= PICT_FRAME; /* PICT_TOP_FIELD|PICT_BOTTOM_FIELD */ va_pic->picture_id = ff_vaapi_get_surface_id(pic); @@ -63,7 +63,7 @@ static void fill_vaapi_pic(VAPictureH264 *va_pic, va_pic->flags = 0; if (pic_structure != PICT_FRAME) va_pic->flags |= (pic_structure & PICT_TOP_FIELD) ? VA_PICTURE_H264_TOP_FIELD : VA_PICTURE_H264_BOTTOM_FIELD; - if (pic->reference) + if (pic->f.reference) va_pic->flags |= pic->long_ref ? VA_PICTURE_H264_LONG_TERM_REFERENCE : VA_PICTURE_H264_SHORT_TERM_REFERENCE; va_pic->TopFieldOrderCnt = 0; @@ -133,13 +133,13 @@ static int fill_vaapi_ReferenceFrames(VAPictureParameterBufferH264 *pic_param, for (i = 0; i < h->short_ref_count; i++) { Picture * const pic = h->short_ref[i]; - if (pic && pic->reference && dpb_add(&dpb, pic) < 0) + if (pic && pic->f.reference && dpb_add(&dpb, pic) < 0) return -1; } for (i = 0; i < 16; i++) { Picture * const pic = h->long_ref[i]; - if (pic && pic->reference && dpb_add(&dpb, pic) < 0) + if (pic && pic->f.reference && dpb_add(&dpb, pic) < 0) return -1; } return 0; @@ -159,7 +159,7 @@ static void fill_vaapi_RefPicList(VAPictureH264 RefPicList[32], { unsigned int i, n = 0; for (i = 0; i < ref_count; i++) - if (ref_list[i].reference) + if (ref_list[i].f.reference) fill_vaapi_pic(&RefPicList[n++], &ref_list[i], 0); for (; n < 32; n++) diff --git a/libavcodec/vaapi_internal.h b/libavcodec/vaapi_internal.h index 38432e1bc0..c6d5d6e42a 100644 --- a/libavcodec/vaapi_internal.h +++ b/libavcodec/vaapi_internal.h @@ -38,7 +38,7 @@ /** Extract VASurfaceID from a Picture */ static inline VASurfaceID ff_vaapi_get_surface_id(Picture *pic) { - return (uintptr_t)pic->data[3]; + return (uintptr_t)pic->f.data[3]; } /** Common AVHWAccel.end_frame() implementation */ diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index fcd429086e..1a756cbaf4 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -79,7 +79,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ pic_param->quant_precision = s->quant_precision; pic_param->vop_fields.value = 0; /* reset all bits */ pic_param->vop_fields.bits.vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I; - pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == AV_PICTURE_TYPE_B ? s->next_picture.pict_type - AV_PICTURE_TYPE_I : 0; + pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == AV_PICTURE_TYPE_B ? s->next_picture.f.pict_type - AV_PICTURE_TYPE_I : 0; pic_param->vop_fields.bits.vop_rounding_type = s->no_rounding; pic_param->vop_fields.bits.intra_dc_vlc_thr = mpeg4_get_intra_dc_vlc_thr(s); pic_param->vop_fields.bits.top_field_first = s->top_field_first; diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index bdc596ce24..df04ca01fc 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -46,7 +46,7 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s) Picture *pic; int i, list, pic_frame_idx; - render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; + render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0]; assert(render); rf = &render->info.h264.referenceFrames[0]; @@ -58,11 +58,11 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s) for (i = 0; i < ls; ++i) { pic = lp[i]; - if (!pic || !pic->reference) + if (!pic || !pic->f.reference) continue; pic_frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num; - render_ref = (struct vdpau_render_state *)pic->data[0]; + render_ref = (struct vdpau_render_state *)pic->f.data[0]; assert(render_ref); rf2 = &render->info.h264.referenceFrames[0]; @@ -76,8 +76,8 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s) ++rf2; } if (rf2 != rf) { - rf2->top_is_reference |= (pic->reference & PICT_TOP_FIELD) ? VDP_TRUE : VDP_FALSE; - rf2->bottom_is_reference |= (pic->reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE; + rf2->top_is_reference |= (pic->f.reference & PICT_TOP_FIELD) ? VDP_TRUE : VDP_FALSE; + rf2->bottom_is_reference |= (pic->f.reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE; continue; } @@ -86,8 +86,8 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s) rf->surface = render_ref->surface; rf->is_long_term = pic->long_ref; - rf->top_is_reference = (pic->reference & PICT_TOP_FIELD) ? VDP_TRUE : VDP_FALSE; - rf->bottom_is_reference = (pic->reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE; + rf->top_is_reference = (pic->f.reference & PICT_TOP_FIELD) ? VDP_TRUE : VDP_FALSE; + rf->bottom_is_reference = (pic->f.reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE; rf->field_order_cnt[0] = pic->field_poc[0]; rf->field_order_cnt[1] = pic->field_poc[1]; rf->frame_idx = pic_frame_idx; @@ -112,7 +112,7 @@ void ff_vdpau_add_data_chunk(MpegEncContext *s, { struct vdpau_render_state *render; - render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; + render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0]; assert(render); render->bitstream_buffers= av_fast_realloc( @@ -133,7 +133,7 @@ void ff_vdpau_h264_picture_start(MpegEncContext *s) struct vdpau_render_state *render; int i; - render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; + render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0]; assert(render); for (i = 0; i < 2; ++i) { @@ -151,14 +151,14 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s) H264Context *h = s->avctx->priv_data; struct vdpau_render_state *render; - render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; + render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0]; assert(render); render->info.h264.slice_count = h->slice_num; if (render->info.h264.slice_count < 1) return; - render->info.h264.is_reference = (s->current_picture_ptr->reference & 3) ? VDP_TRUE : VDP_FALSE; + render->info.h264.is_reference = (s->current_picture_ptr->f.reference & 3) ? VDP_TRUE : VDP_FALSE; render->info.h264.field_pic_flag = s->picture_structure != PICT_FRAME; render->info.h264.bottom_field_flag = s->picture_structure == PICT_BOTTOM_FIELD; render->info.h264.num_ref_frames = h->sps.ref_frame_count; @@ -198,7 +198,7 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, if (!s->current_picture_ptr) return; - render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; + render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0]; assert(render); /* fill VdpPictureInfoMPEG1Or2 struct */ @@ -227,12 +227,12 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, switch(s->pict_type){ case AV_PICTURE_TYPE_B: - next = (struct vdpau_render_state *)s->next_picture.data[0]; + next = (struct vdpau_render_state *)s->next_picture.f.data[0]; assert(next); render->info.mpeg.backward_reference = next->surface; // no return here, going to set forward prediction case AV_PICTURE_TYPE_P: - last = (struct vdpau_render_state *)s->last_picture.data[0]; + last = (struct vdpau_render_state *)s->last_picture.f.data[0]; if (!last) // FIXME: Does this test make sense? last = render; // predict second field from the first render->info.mpeg.forward_reference = last->surface; @@ -253,7 +253,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, VC1Context *v = s->avctx->priv_data; struct vdpau_render_state *render, *last, *next; - render = (struct vdpau_render_state *)s->current_picture.data[0]; + render = (struct vdpau_render_state *)s->current_picture.f.data[0]; assert(render); /* fill LvPictureInfoVC1 struct */ @@ -297,12 +297,12 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, switch(s->pict_type){ case AV_PICTURE_TYPE_B: - next = (struct vdpau_render_state *)s->next_picture.data[0]; + next = (struct vdpau_render_state *)s->next_picture.f.data[0]; assert(next); render->info.vc1.backward_reference = next->surface; // no break here, going to set forward prediction case AV_PICTURE_TYPE_P: - last = (struct vdpau_render_state *)s->last_picture.data[0]; + last = (struct vdpau_render_state *)s->last_picture.f.data[0]; if (!last) // FIXME: Does this test make sense? last = render; // predict second field from the first render->info.vc1.forward_reference = last->surface; @@ -324,7 +324,7 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, if (!s->current_picture_ptr) return; - render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; + render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0]; assert(render); /* fill VdpPictureInfoMPEG4Part2 struct */ @@ -353,13 +353,13 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, switch (s->pict_type) { case AV_PICTURE_TYPE_B: - next = (struct vdpau_render_state *)s->next_picture.data[0]; + next = (struct vdpau_render_state *)s->next_picture.f.data[0]; assert(next); render->info.mpeg4.backward_reference = next->surface; render->info.mpeg4.vop_coding_type = 2; // no break here, going to set forward prediction case AV_PICTURE_TYPE_P: - last = (struct vdpau_render_state *)s->last_picture.data[0]; + last = (struct vdpau_render_state *)s->last_picture.f.data[0]; assert(last); render->info.mpeg4.forward_reference = last->surface; } From 58ef4ecff834f47f5a4c2a6bd4385b1999a30930 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Mon, 11 Jul 2011 01:13:20 +0200 Subject: [PATCH 434/780] DxVA2: unbreak build after [657ccb5ac75ce34e62bd67f228d9bd36db72189e] Signed-off-by: Ronald S. Bultje --- libavcodec/dxva2.c | 2 +- libavcodec/dxva2_h264.c | 18 +++++++++--------- libavcodec/dxva2_mpeg2.c | 8 ++++---- libavcodec/dxva2_vc1.c | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 25b021ae11..e56a64594e 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -24,7 +24,7 @@ void *ff_dxva2_get_surface(const Picture *picture) { - return picture->data[3]; + return picture->f.data[3]; } unsigned ff_dxva2_get_surface_index(const struct dxva_context *ctx, diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c index 8de4c51082..690d4ad9bd 100644 --- a/libavcodec/dxva2_h264.c +++ b/libavcodec/dxva2_h264.c @@ -70,15 +70,15 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context ff_dxva2_get_surface_index(ctx, r), r->long_ref != 0); - if ((r->reference & PICT_TOP_FIELD) && r->field_poc[0] != INT_MAX) + if ((r->f.reference & PICT_TOP_FIELD) && r->field_poc[0] != INT_MAX) pp->FieldOrderCntList[i][0] = r->field_poc[0]; - if ((r->reference & PICT_BOTTOM_FIELD) && r->field_poc[1] != INT_MAX) + if ((r->f.reference & PICT_BOTTOM_FIELD) && r->field_poc[1] != INT_MAX) pp->FieldOrderCntList[i][1] = r->field_poc[1]; pp->FrameNumList[i] = r->long_ref ? r->pic_id : r->frame_num; - if (r->reference & PICT_TOP_FIELD) + if (r->f.reference & PICT_TOP_FIELD) pp->UsedForReferenceFlags |= 1 << (2*i + 0); - if (r->reference & PICT_BOTTOM_FIELD) + if (r->f.reference & PICT_BOTTOM_FIELD) pp->UsedForReferenceFlags |= 1 << (2*i + 1); } else { pp->RefFrameList[i].bPicEntry = 0xff; @@ -216,7 +216,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, unsigned plane; fill_picture_entry(&slice->RefPicList[list][i], ff_dxva2_get_surface_index(ctx, r), - r->reference == PICT_BOTTOM_FIELD); + r->f.reference == PICT_BOTTOM_FIELD); for (plane = 0; plane < 3; plane++) { int w, o; if (plane == 0 && h->luma_weight_flag[list]) { @@ -265,7 +265,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const unsigned mb_count = s->mb_width * s->mb_height; struct dxva_context *ctx = avctx->hwaccel_context; const Picture *current_picture = h->s.current_picture_ptr; - struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = current_picture->f.hwaccel_picture_private; DXVA_Slice_H264_Short *slice = NULL; uint8_t *dxva_data, *current, *end; unsigned dxva_size; @@ -360,7 +360,7 @@ static int start_frame(AVCodecContext *avctx, { const H264Context *h = avctx->priv_data; struct dxva_context *ctx = avctx->hwaccel_context; - struct dxva2_picture_context *ctx_pic = h->s.current_picture_ptr->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = h->s.current_picture_ptr->f.hwaccel_picture_private; if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0) return -1; @@ -384,7 +384,7 @@ static int decode_slice(AVCodecContext *avctx, const H264Context *h = avctx->priv_data; struct dxva_context *ctx = avctx->hwaccel_context; const Picture *current_picture = h->s.current_picture_ptr; - struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = current_picture->f.hwaccel_picture_private; unsigned position; if (ctx_pic->slice_count >= MAX_SLICES) @@ -413,7 +413,7 @@ static int end_frame(AVCodecContext *avctx) H264Context *h = avctx->priv_data; MpegEncContext *s = &h->s; struct dxva2_picture_context *ctx_pic = - h->s.current_picture_ptr->hwaccel_picture_private; + h->s.current_picture_ptr->f.hwaccel_picture_private; if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) return -1; diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index f14aabd540..092123bff5 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -151,7 +151,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const struct MpegEncContext *s = avctx->priv_data; struct dxva_context *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = - s->current_picture_ptr->hwaccel_picture_private; + s->current_picture_ptr->f.hwaccel_picture_private; const int is_field = s->picture_structure != PICT_FRAME; const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); uint8_t *dxva_data, *current, *end; @@ -210,7 +210,7 @@ static int start_frame(AVCodecContext *avctx, const struct MpegEncContext *s = avctx->priv_data; struct dxva_context *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = - s->current_picture_ptr->hwaccel_picture_private; + s->current_picture_ptr->f.hwaccel_picture_private; if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0) return -1; @@ -230,7 +230,7 @@ static int decode_slice(AVCodecContext *avctx, { const struct MpegEncContext *s = avctx->priv_data; struct dxva2_picture_context *ctx_pic = - s->current_picture_ptr->hwaccel_picture_private; + s->current_picture_ptr->f.hwaccel_picture_private; unsigned position; if (ctx_pic->slice_count >= MAX_SLICES) @@ -250,7 +250,7 @@ static int end_frame(AVCodecContext *avctx) { struct MpegEncContext *s = avctx->priv_data; struct dxva2_picture_context *ctx_pic = - s->current_picture_ptr->hwaccel_picture_private; + s->current_picture_ptr->f.hwaccel_picture_private; if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) return -1; diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index 112d7df785..ba6416b719 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -161,7 +161,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const VC1Context *v = avctx->priv_data; struct dxva_context *ctx = avctx->hwaccel_context; const MpegEncContext *s = &v->s; - struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->f.hwaccel_picture_private; DXVA_SliceInfo *slice = &ctx_pic->si; @@ -213,7 +213,7 @@ static int start_frame(AVCodecContext *avctx, { const VC1Context *v = avctx->priv_data; struct dxva_context *ctx = avctx->hwaccel_context; - struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->f.hwaccel_picture_private; if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0) return -1; @@ -231,7 +231,7 @@ static int decode_slice(AVCodecContext *avctx, { const VC1Context *v = avctx->priv_data; const Picture *current_picture = v->s.current_picture_ptr; - struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = current_picture->f.hwaccel_picture_private; if (ctx_pic->bitstream_size > 0) return -1; @@ -252,7 +252,7 @@ static int decode_slice(AVCodecContext *avctx, static int end_frame(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; - struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; + struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->f.hwaccel_picture_private; if (ctx_pic->bitstream_size <= 0) return -1; From 948ccdadf4b9c4b15e2777d25517ef1343675785 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 30 Jun 2011 17:35:13 -0700 Subject: [PATCH 435/780] swscale: for >8bit scaling, read in native bit-depth. For 9/10bit, it means we don't have to upscale to 16bit before actual scaling or pixel format conversion, and thus a performance gain. --- libswscale/ppc/swscale_altivec.c | 2 +- libswscale/swscale.c | 67 ++++--------------------------- libswscale/swscale_internal.h | 2 +- libswscale/utils.c | 1 - libswscale/x86/swscale_template.c | 2 +- 5 files changed, 11 insertions(+), 63 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index b71e0fd949..8bc0ddd9d8 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -220,7 +220,7 @@ yuv2yuvX_altivec_real(SwsContext *c, } } -static void hScale_altivec_real(int16_t *dst, int dstW, +static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize) { diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 0004db1206..475175b589 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1882,59 +1882,6 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV, #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos)) -// FIXME Maybe dither instead. -static av_always_inline void -yuv9_OR_10ToUV_c_template(uint16_t *dstU, uint16_t *dstV, - const uint16_t *srcU, const uint16_t *srcV, - int width, enum PixelFormat origin, int depth) -{ - int i; - - for (i = 0; i < width; i++) { - int upx = input_pixel(&srcU[i]); - int vpx = input_pixel(&srcV[i]); - dstU[i] = (upx << (16 - depth)) | (upx >> (2 * depth - 16)); - dstV[i] = (vpx << (16 - depth)) | (vpx >> (2 * depth - 16)); - } -} - -static av_always_inline void -yuv9_or_10ToY_c_template(uint16_t *dstY, const uint16_t *srcY, - int width, enum PixelFormat origin, int depth) -{ - int i; - - for (i = 0; i < width; i++) { - int px = input_pixel(&srcY[i]); - dstY[i] = (px << (16 - depth)) | (px >> (2 * depth - 16)); - } -} - -#undef input_pixel - -#define YUV_NBPS(depth, BE_LE, origin) \ -static void BE_LE ## depth ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ - const uint8_t *_srcU, const uint8_t *_srcV, \ - int width, uint32_t *unused) \ -{ \ - uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ - const uint16_t *srcU = (const uint16_t *) _srcU, \ - *srcV = (const uint16_t *) _srcV; \ - yuv9_OR_10ToUV_c_template(dstU, dstV, srcU, srcV, width, origin, depth); \ -} \ -static void BE_LE ## depth ## ToY_c(uint8_t *_dstY, const uint8_t *_srcY, \ - int width, uint32_t *unused) \ -{ \ - uint16_t *dstY = (uint16_t *) _dstY; \ - const uint16_t *srcY = (const uint16_t *) _srcY; \ - yuv9_or_10ToY_c_template(dstY, srcY, width, origin, depth); \ -} - -YUV_NBPS( 9, LE, PIX_FMT_YUV420P9LE); -YUV_NBPS( 9, BE, PIX_FMT_YUV420P9BE); -YUV_NBPS(10, LE, PIX_FMT_YUV420P10LE); -YUV_NBPS(10, BE, PIX_FMT_YUV420P10BE); - static void bgr24ToY_c(int16_t *dst, const uint8_t *src, int width, uint32_t *unused) { @@ -2021,13 +1968,15 @@ static void rgb24ToUV_half_c(int16_t *dstU, int16_t *dstV, const uint8_t *src1, } } -static void hScale16_c(int16_t *_dst, int dstW, const uint8_t *_src, +static void hScale16_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int16_t *filterPos, int filterSize) { int i; int32_t *dst = (int32_t *) _dst; const uint16_t *src = (const uint16_t *) _src; + int bits = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; + int sh = (bits <= 7) ? 11 : (bits - 4); for (i = 0; i < dstW; i++) { int j; @@ -2038,12 +1987,12 @@ static void hScale16_c(int16_t *_dst, int dstW, const uint8_t *_src, val += src[srcPos + j] * filter[filterSize * i + j]; } // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit - dst[i] = FFMIN(val >> 11, (1 << 19) - 1); + dst[i] = FFMIN(val >> sh, (1 << 19) - 1); } } // bilinear / bicubic scaling -static void hScale_c(int16_t *dst, int dstW, const uint8_t *src, +static void hScale_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize) { @@ -2213,7 +2162,7 @@ static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, int shift= isAnyRGB(c->srcFormat) || c->srcFormat==PIX_FMT_PAL8 ? 13 : av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; c->hScale16(dst, dstWidth, (const uint16_t*)src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize, shift); } else if (!c->hyscale_fast) { - c->hScale(dst, dstWidth, src, hLumFilter, hLumFilterPos, hLumFilterSize); + c->hScale(c, dst, dstWidth, src, hLumFilter, hLumFilterPos, hLumFilterSize); } else { // fast bilinear upscale / crap downscale c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc); } @@ -2271,8 +2220,8 @@ static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2 c->hScale16(dst1, dstWidth, (const uint16_t*)src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize, shift); c->hScale16(dst2, dstWidth, (const uint16_t*)src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize, shift); } else if (!c->hcscale_fast) { - c->hScale(dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize); - c->hScale(dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize); + c->hScale(c, dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize); + c->hScale(c, dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize); } else { // fast bilinear upscale / crap downscale c->hcscale_fast(c, dst1, dst2, dstWidth, src1, src2, srcW, xInc); } diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 232d9adcb2..e19956c079 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -447,7 +447,7 @@ typedef struct SwsContext { * (and input coefficients thus padded with zeroes) * to simplify creating SIMD code. */ - void (*hScale)(int16_t *dst, int dstW, const uint8_t *src, + void (*hScale)(struct SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize); diff --git a/libswscale/utils.c b/libswscale/utils.c index 18793198fa..15d594c582 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -883,7 +883,6 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) } } - // FIXME it's even nicer if bpp isn't 16, but max({src,dst}formatbpp) c->scalingBpp = FFMAX(av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1, av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1) >= 15 ? 16 : 8; diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 73df06cf40..7603f1a415 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -1868,7 +1868,7 @@ static void RENAME(rgb24ToUV)(int16_t *dstU, int16_t *dstV, #if !COMPILE_TEMPLATE_MMX2 // bilinear / bicubic scaling -static void RENAME(hScale)(int16_t *dst, int dstW, +static void RENAME(hScale)(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize) { From ae05dd87311b4a3f77409c86d51f967ca750fa5a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 2 Jul 2011 02:25:02 +0200 Subject: [PATCH 436/780] sws: fix 16/32 bug from merge --- libswscale/swscale.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 475175b589..17a46504b4 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -299,9 +299,10 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, { //FIXME Optimize (just quickly written not optimized..) int i; + int dword= output_bits == 16; uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; - int shift = 15 + 16 - output_bits; + int shift = 11 + 4*dword + 16 - output_bits; #define output_pixel(pos, val) \ if (big_endian) { \ @@ -318,24 +319,24 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, } \ } for (i = 0; i < dstW; i++) { - int val = 1 << (30-output_bits); + int val = 1 << (26-output_bits + 4*dword); int j; for (j = 0; j < lumFilterSize; j++) - val += lumSrc[j][i] * lumFilter[j]; + val += (dword ? lumSrc[j][i] : ((int16_t**)lumSrc)[j][i]) * lumFilter[j]; output_pixel(&yDest[i], val); } if (uDest) { for (i = 0; i < chrDstW; i++) { - int u = 1 << (30-output_bits); - int v = 1 << (30-output_bits); + int u = 1 << (26-output_bits + 4*dword); + int v = 1 << (26-output_bits + 4*dword); int j; for (j = 0; j < chrFilterSize; j++) { - u += chrUSrc[j][i] * chrFilter[j]; - v += chrVSrc[j][i] * chrFilter[j]; + u += (dword ? chrUSrc[j][i] : ((int16_t**)chrUSrc)[j][i]) * chrFilter[j]; + v += (dword ? chrVSrc[j][i] : ((int16_t**)chrVSrc)[j][i]) * chrFilter[j]; } output_pixel(&uDest[i], u); @@ -345,11 +346,11 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, if (CONFIG_SWSCALE_ALPHA && aDest) { for (i = 0; i < dstW; i++) { - int val = 1 << (30-output_bits); + int val = 1 << (26-output_bits + 4*dword); int j; for (j = 0; j < lumFilterSize; j++) - val += alpSrc[j][i] * lumFilter[j]; + val += (dword ? alpSrc[j][i] : ((int16_t**)alpSrc)[j][i]) * lumFilter[j]; output_pixel(&aDest[i], val); } @@ -2170,7 +2171,7 @@ static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, if (convertRange) convertRange(dst, dstWidth); - if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 15 && c->scalingBpp == 16) { c->scale19To15Fw(dst, (int32_t *) dst, dstWidth); } } @@ -2229,7 +2230,7 @@ static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2 if (c->chrConvertRange) c->chrConvertRange(dst1, dst2, dstWidth); - if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 15 && c->scalingBpp == 16) { c->scale19To15Fw(dst1, (int32_t *) dst1, dstWidth); c->scale19To15Fw(dst2, (int32_t *) dst2, dstWidth); } From 947020541400bbef27a6a2858e725d234758c384 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 2 Jul 2011 23:30:14 +0200 Subject: [PATCH 437/780] sws:ix yuv2rgb48_1_c_template() --- libswscale/swscale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 17a46504b4..471526facb 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1027,8 +1027,8 @@ yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0, for (i = 0; i < (dstW >> 1); i++) { int Y1 = (buf0[i * 2] ) >> 2; int Y2 = (buf0[i * 2 + 1]) >> 2; - int U = (ubuf0[i] + ubuf1[i] + (-128 << 11)) >> 3; - int V = (vbuf0[i] + vbuf1[i] + (-128 << 11)) >> 3; + int U = (ubuf0[i] + ubuf1[i] + (-128 << 12)) >> 3; + int V = (vbuf0[i] + vbuf1[i] + (-128 << 12)) >> 3; int R, G, B; Y1 -= c->yuv2rgb_y_offset; From d2c910b9a4ff6cd8bff0da1b6dd9098c70c01189 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 Jul 2011 00:33:23 +0200 Subject: [PATCH 438/780] sws: fix gray16_1 --- libswscale/swscale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 471526facb..d1cb37185c 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -578,8 +578,8 @@ yuv2gray16_1_c_template(SwsContext *c, const int32_t *buf0, int i; for (i = 0; i < (dstW >> 1); i++) { - int Y1 = buf0[i * 2 ] << 1; - int Y2 = buf0[i * 2 + 1] << 1; + int Y1 = (buf0[i * 2 ]+4)>>3; + int Y2 = (buf0[i * 2 + 1]+4)>>3; output_pixel(&dest[i * 2 + 0], Y1); output_pixel(&dest[i * 2 + 1], Y2); From b5ff61695f2c0493036b463666c5936ee10da344 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 Jul 2011 01:04:51 +0200 Subject: [PATCH 439/780] sws: fix uv overwrite in 32bt --- libswscale/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 15d594c582..3e1662716b 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -786,7 +786,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) int srcH= c->srcH; int dstW= c->dstW; int dstH= c->dstH; - int dst_stride = FFALIGN(dstW * sizeof(int16_t)+66, 16), dst_stride_px = dst_stride >> 1; + int dst_stride = FFALIGN(dstW * sizeof(int16_t)+66, 16); int flags, cpu_flags; enum PixelFormat srcFormat= c->srcFormat; enum PixelFormat dstFormat= c->dstFormat; @@ -1047,12 +1047,12 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i+c->vLumBufSize], dst_stride+1, fail); c->lumPixBuf[i] = c->lumPixBuf[i+c->vLumBufSize]; } - c->uv_off = dst_stride_px; + c->uv_off = dst_stride>>1; c->uv_offx2 = dst_stride; for (i=0; ivChrBufSize; i++) { FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i+c->vChrBufSize], dst_stride*2+1, fail); c->chrUPixBuf[i] = c->chrUPixBuf[i+c->vChrBufSize]; - c->chrVPixBuf[i] = c->chrVPixBuf[i+c->vChrBufSize] = c->chrUPixBuf[i] + dst_stride_px; + c->chrVPixBuf[i] = c->chrVPixBuf[i+c->vChrBufSize] = c->chrUPixBuf[i] + (dst_stride>>1); } if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) for (i=0; ivLumBufSize; i++) { From 987e4c1787f18d97a39a5bce17b9c1f19a0996c9 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 Jul 2011 02:08:45 +0200 Subject: [PATCH 440/780] sws: fix rgb -> 16bit --- libswscale/swscale.c | 11 +++++++---- libswscale/x86/swscale_template.c | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index d1cb37185c..c39f1b6f93 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1979,6 +1979,9 @@ static void hScale16_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_s int bits = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; int sh = (bits <= 7) ? 11 : (bits - 4); + if((isAnyRGB(c->srcFormat) || c->srcFormat==PIX_FMT_PAL8) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15) + sh= 9; + for (i = 0; i < dstW; i++) { int j; int srcPos = filterPos[i]; @@ -2154,7 +2157,7 @@ static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, src= formatConvBuffer; } - if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16 && !isAnyRGB(c->srcFormat)) { c->scale8To16Rv((uint16_t *) formatConvBuffer, src, srcW); src = formatConvBuffer; } @@ -2208,7 +2211,7 @@ static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2 src2= buf2; } - if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16 && !isAnyRGB(c->srcFormat)) { uint8_t *buf2 = (formatConvBuffer + FFALIGN(srcW * 2+78, 16)); c->scale8To16Rv((uint16_t *) formatConvBuffer, src1, srcW); c->scale8To16Rv((uint16_t *) buf2, src2, srcW); @@ -2878,8 +2881,8 @@ static av_cold void sws_init_swScale_c(SwsContext *c) } } - if((isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15) - || c->srcFormat == PIX_FMT_PAL8) + if(((isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15) + || c->srcFormat == PIX_FMT_PAL8) && c->scalingBpp == 8) c->hScale16= hScale16N_c; if (c->scalingBpp == 8) { diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 7603f1a415..8ab5556c61 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -2438,6 +2438,6 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) } } #endif /* !COMPILE_TEMPLATE_MMX2 */ - if(isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15) + if(isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15 && c->scalingBpp == 8) c->hScale16= RENAME(hScale16); } From ca78fa24b75906538156392a449efacedd234247 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 Jul 2011 02:34:00 +0200 Subject: [PATCH 441/780] sws: disable scale16 when int32 is used --- libswscale/swscale.c | 5 +++-- libswscale/x86/swscale_template.c | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index c39f1b6f93..cbb172f9e8 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2881,8 +2881,8 @@ static av_cold void sws_init_swScale_c(SwsContext *c) } } - if(((isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15) - || c->srcFormat == PIX_FMT_PAL8) && c->scalingBpp == 8) + if((isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15) + || c->srcFormat == PIX_FMT_PAL8) c->hScale16= hScale16N_c; if (c->scalingBpp == 8) { @@ -2902,6 +2902,7 @@ static av_cold void sws_init_swScale_c(SwsContext *c) } } } else { + c->hScale16 = NULL; c->hScale = hScale16_c; c->scale19To15Fw = scale19To15Fw_c; c->scale8To16Rv = scale8To16Rv_c; diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 8ab5556c61..84b8deae33 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -2438,6 +2438,8 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c) } } #endif /* !COMPILE_TEMPLATE_MMX2 */ - if(isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15 && c->scalingBpp == 8) + if(isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15) c->hScale16= RENAME(hScale16); + if(c->scalingBpp != 8) + c->hScale16 = NULL; } From 08b57574c6a1bde51576f42546b7b9f8c03f9297 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 Jul 2011 02:46:54 +0200 Subject: [PATCH 442/780] sws: fix non native endian 9-15 bit input with 16bit out --- libswscale/swscale.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index cbb172f9e8..15db8367de 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2902,6 +2902,10 @@ static av_cold void sws_init_swScale_c(SwsContext *c) } } } else { + if(c->hScale16 == hScale16NX_c && !isAnyRGB(c->srcFormat)){ + c->chrToYV12 = bswap16UV_c; + c->lumToYV12 = bswap16Y_c; + } c->hScale16 = NULL; c->hScale = hScale16_c; c->scale19To15Fw = scale19To15Fw_c; From ac9ac45aca7d3114dc790f794b49f066b4178827 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 8 Jul 2011 14:52:52 -0700 Subject: [PATCH 443/780] swscale: fix 16-bit scaling when output is 8-bits. We would use the second half of the U plane buffer, rather than the V plane buffer, to output the V plane pixels. --- libswscale/utils.c | 2 +- libswscale/x86/swscale_template.c | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 3e1662716b..00bd89f78b 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1052,7 +1052,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) for (i=0; ivChrBufSize; i++) { FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i+c->vChrBufSize], dst_stride*2+1, fail); c->chrUPixBuf[i] = c->chrUPixBuf[i+c->vChrBufSize]; - c->chrVPixBuf[i] = c->chrVPixBuf[i+c->vChrBufSize] = c->chrUPixBuf[i] + (dst_stride>>1); + c->chrVPixBuf[i] = c->chrVPixBuf[i+c->vChrBufSize] = c->chrUPixBuf[i] + (dst_stride >> 1); } if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) for (i=0; ivLumBufSize; i++) { diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 84b8deae33..23bc5148c7 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -83,7 +83,7 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; if (uDest) { - x86_reg uv_off = c->uv_off; + x86_reg uv_off = c->uv_offx2 >> 1; for(i=0; i<8; i++) c->dither16[i] = chrDither[i]>>4; YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) for(i=0; i<8; i++) c->dither16[i] = chrDither[(i+3)&7]>>4; @@ -170,7 +170,7 @@ static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; if (uDest) { - x86_reg uv_off = c->uv_off; + x86_reg uv_off = c->uv_offx2 >> 1; for(i=0; i<8; i++) c->dither32[i] = chrDither[i]<<12; YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) for(i=0; i<8; i++) c->dither32[i] = chrDither[(i+3)&7]<<12; @@ -485,7 +485,7 @@ static void RENAME(yuv2rgb32_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { YSCALEYUV2PACKEDX_ACCURATE @@ -518,7 +518,7 @@ static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { YSCALEYUV2PACKEDX @@ -575,7 +575,7 @@ static void RENAME(yuv2rgb565_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX @@ -599,7 +599,7 @@ static void RENAME(yuv2rgb565_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX YSCALEYUV2RGBX @@ -652,7 +652,7 @@ static void RENAME(yuv2rgb555_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX @@ -676,7 +676,7 @@ static void RENAME(yuv2rgb555_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX YSCALEYUV2RGBX @@ -809,7 +809,7 @@ static void RENAME(yuv2bgr24_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX @@ -833,7 +833,7 @@ static void RENAME(yuv2bgr24_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX YSCALEYUV2RGBX @@ -874,7 +874,7 @@ static void RENAME(yuv2yuyv422_X_ar)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX_ACCURATE /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ @@ -895,7 +895,7 @@ static void RENAME(yuv2yuyv422_X)(SwsContext *c, const int16_t *lumFilter, { x86_reg dummy=0; x86_reg dstW_reg = dstW; - x86_reg uv_off = c->uv_off << 1; + x86_reg uv_off = c->uv_offx2; YSCALEYUV2PACKEDX /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ From 71a04bc19dfb990d3f7cce82b5516e88d2c371f4 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 8 Jul 2011 12:28:28 -0700 Subject: [PATCH 444/780] swscale: fix crash in 8-bpc bilinear output without alpha. We accessed the alpha array even it wasn't used and didn't exist, hence leading to a NULL pointer segfault. (cherry picked from commit bf2cba453244a74331238a472fe0e309f116f4d9) --- libswscale/swscale.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 15db8367de..b9c619c727 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1247,7 +1247,8 @@ yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2], const int16_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], *vbuf0 = vbuf[0], *vbuf1 = vbuf[1], - *abuf0 = abuf[0], *abuf1 = abuf[1]; + *abuf0 = hasAlpha ? abuf[0] : NULL, + *abuf1 = hasAlpha ? abuf[1] : NULL; int yalpha1 = 4095 - yalpha; int uvalpha1 = 4095 - uvalpha; int i; From 93a10dd56121862fab13aa6676227673c534cc12 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 8 Jul 2011 14:57:07 -0700 Subject: [PATCH 445/780] swscale: fix overflow in 16-bit vertical scaling. We operated on 31-bits, but with e.g. lanczos scaling, values can add up to beyond 0x80000000, thus leading to output of zeroes. Drop one bit of precision fixes this. --- libswscale/swscale.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index b9c619c727..b6455bb5e7 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -302,7 +302,7 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, int dword= output_bits == 16; uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; - int shift = 11 + 4*dword + 16 - output_bits; + int shift = 11 + 4*dword + 16 - output_bits - 1; #define output_pixel(pos, val) \ if (big_endian) { \ @@ -319,24 +319,24 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, } \ } for (i = 0; i < dstW; i++) { - int val = 1 << (26-output_bits + 4*dword); + int val = 1 << (26-output_bits + 4*dword - 1); int j; for (j = 0; j < lumFilterSize; j++) - val += (dword ? lumSrc[j][i] : ((int16_t**)lumSrc)[j][i]) * lumFilter[j]; + val += ((dword ? lumSrc[j][i] : ((int16_t**)lumSrc)[j][i]) * lumFilter[j])>>1; output_pixel(&yDest[i], val); } if (uDest) { for (i = 0; i < chrDstW; i++) { - int u = 1 << (26-output_bits + 4*dword); - int v = 1 << (26-output_bits + 4*dword); + int u = 1 << (26-output_bits + 4*dword - 1); + int v = 1 << (26-output_bits + 4*dword - 1); int j; for (j = 0; j < chrFilterSize; j++) { - u += (dword ? chrUSrc[j][i] : ((int16_t**)chrUSrc)[j][i]) * chrFilter[j]; - v += (dword ? chrVSrc[j][i] : ((int16_t**)chrVSrc)[j][i]) * chrFilter[j]; + u += ((dword ? chrUSrc[j][i] : ((int16_t**)chrUSrc)[j][i]) * chrFilter[j]) >> 1; + v += ((dword ? chrVSrc[j][i] : ((int16_t**)chrVSrc)[j][i]) * chrFilter[j]) >> 1; } output_pixel(&uDest[i], u); @@ -346,11 +346,11 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, if (CONFIG_SWSCALE_ALPHA && aDest) { for (i = 0; i < dstW; i++) { - int val = 1 << (26-output_bits + 4*dword); + int val = 1 << (26-output_bits + 4*dword - 1); int j; for (j = 0; j < lumFilterSize; j++) - val += (dword ? alpSrc[j][i] : ((int16_t**)alpSrc)[j][i]) * lumFilter[j]; + val += ((dword ? alpSrc[j][i] : ((int16_t**)alpSrc)[j][i]) * lumFilter[j]) >> 1; output_pixel(&aDest[i], val); } From c59f9a68e2eda847538df367b5b9e7256247ef78 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 5 Jul 2011 12:49:11 -0700 Subject: [PATCH 446/780] swscale: error dithering for 16/9/10-bit to 8-bit. Based on a somewhat similar idea in FFmpeg's swscale copy. --- libswscale/swscale.c | 64 +++++++++----- libswscale/swscale_internal.h | 9 +- libswscale/x86/swscale_template.c | 136 +++++++++++++++++++++++++----- 3 files changed, 160 insertions(+), 49 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index b6455bb5e7..45098ef4c2 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -193,6 +193,18 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={ { 77, 23, 60, 15, 72, 21, 56, 14, }, }; #endif +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_128)[8][8] = { +{ 36, 68, 60, 92, 34, 66, 58, 90,}, +{ 100, 4,124, 28, 98, 2,122, 26,}, +{ 52, 84, 44, 76, 50, 82, 42, 74,}, +{ 116, 20,108, 12,114, 18,106, 10,}, +{ 32, 64, 56, 88, 38, 70, 62, 94,}, +{ 96, 0,120, 24,102, 6,126, 30,}, +{ 48, 80, 40, 72, 54, 86, 46, 78,}, +{ 112, 16,104, 8,118, 22,110, 14,}, +}; +DECLARE_ALIGNED(8, const uint8_t, ff_sws_pb_64)[8] = +{ 64, 64, 64, 64, 64, 64, 64, 64 }; DECLARE_ALIGNED(8, const uint8_t, dithers)[8][8][8]={ { @@ -387,16 +399,16 @@ static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest[4], int dstW, int chrDstW, - const uint8_t *lumDither, const uint8_t *chrDither) + uint8_t *dest[4], int dstW, int chrDstW) { uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; int i; + const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; //FIXME Optimize (just quickly written not optimized..) for (i=0; ilumDither8, *chrDither = c->chrDither8; for (i=0; i>7; + int val = (lumSrc[i]+ lumDither[i & 7]) >> 7; yDest[i]= av_clip_uint8(val); } if (uDest) for (i=0; i>7; - int v=(chrVSrc[i]+chrDither[(i+3)&7])>>7; + int u = (chrUSrc[i] + chrDither[i & 7]) >> 7; + int v = (chrVSrc[i] + chrDither[(i + 3) & 7]) >> 7; uDest[i]= av_clip_uint8(u); vDest[i]= av_clip_uint8(v); } if (CONFIG_SWSCALE_ALPHA && aDest) for (i=0; i>7; + int val = (alpSrc[i] + lumDither[i & 7]) >> 7; aDest[i]= av_clip_uint8(val); } } @@ -464,16 +476,16 @@ static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest[4], - int dstW, int chrDstW, - const uint8_t *lumDither, const uint8_t *chrDither) + int dstW, int chrDstW) { uint8_t *yDest = dest[0], *uDest = dest[1]; enum PixelFormat dstFormat = c->dstFormat; + const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; //FIXME Optimize (just quickly written not optimized..) int i; for (i=0; i> c->chrSrcVSubSample); int lastDstY; uint32_t *pal=c->pal_yuv; + int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat); yuv2planar1_fn yuv2yuv1 = c->yuv2yuv1; yuv2planarX_fn yuv2yuvX = c->yuv2yuvX; @@ -2578,6 +2591,9 @@ static int swScale(SwsContext *c, const uint8_t* src[], lastInChrBuf= -1; } + if (!should_dither) { + c->chrDither8 = c->lumDither8 = ff_sws_pb_64; + } lastDstY= dstY; for (;dstY < dstH; dstY++) { @@ -2588,8 +2604,6 @@ static int swScale(SwsContext *c, const uint8_t* src[], dst[2] + dstStride[2] * chrDstY, (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL, }; - const uint8_t *lumDither= should_dither ? dithers[7][dstY &7] : flat64; - const uint8_t *chrDither= should_dither ? dithers[7][chrDstY&7] : flat64; const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<chrDstVSubSample) - 1), dstH-1)]; @@ -2669,6 +2683,10 @@ static int swScale(SwsContext *c, const uint8_t* src[], #if HAVE_MMX updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf); #endif + if (should_dither) { + c->chrDither8 = dither_8x8_128[chrDstY & 7]; + c->lumDither8 = dither_8x8_128[dstY & 7]; + } if (dstY >= dstH-2) { // hmm looks like we can't use MMX here without overwriting this array's tail find_c_packed_planar_out_funcs(c, &yuv2yuv1, &yuv2yuvX, @@ -2689,13 +2707,13 @@ static int swScale(SwsContext *c, const uint8_t* src[], if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12 const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL; yuv2yuv1(c, lumSrcPtr[0], chrUSrcPtr[0], chrVSrcPtr[0], alpBuf, - dest, dstW, chrDstW, lumDither, chrDither); + dest, dstW, chrDstW); } else { //General YV12 yuv2yuvX(c, vLumFilter + dstY * vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter + chrDstY * vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, dstW, chrDstW, lumDither, chrDither); + alpSrcPtr, dest, dstW, chrDstW); } } else { assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index e19956c079..09e6ad4b01 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -75,8 +75,7 @@ typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[], typedef void (*yuv2planar1_fn) (struct SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, - uint8_t *dest[4], int dstW, int chrDstW, - const uint8_t *lumDither, const uint8_t *chrDither); + uint8_t *dest[4], int dstW, int chrDstW); /** * Write one line of horizontally scaled Y/U/V/A to planar output * with multi-point vertical scaling between input pixels. @@ -99,7 +98,7 @@ typedef void (*yuv2planarX_fn) (struct SwsContext *c, const int16_t *lumFilter, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest[4], - int dstW, int chrDstW, const uint8_t *lumDither, const uint8_t *chrDither); + int dstW, int chrDstW); /** * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB * output without any additional vertical scaling (or point-scaling). Note @@ -323,7 +322,7 @@ typedef struct SwsContext { #define UV_OFF "11*8+4*4*256*3+48" #define UV_OFFx2 "11*8+4*4*256*3+56" #define DITHER16 "11*8+4*4*256*3+64" -#define DITHER32 "11*8+4*4*256*3+64+16" +#define DITHER32 "11*8+4*4*256*3+80" DECLARE_ALIGNED(8, uint64_t, redDither); DECLARE_ALIGNED(8, uint64_t, greenDither); @@ -351,6 +350,8 @@ typedef struct SwsContext { uint16_t dither16[8]; uint32_t dither32[8]; + const uint8_t *chrDither8, *lumDither8; + #if HAVE_ALTIVEC vector signed short CY; vector signed short CRV; diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 23bc5148c7..87248e76fa 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -70,26 +70,62 @@ : "%"REG_d, "%"REG_S\ ); +#if !COMPILE_TEMPLATE_MMX2 +static av_always_inline void +dither_8to16(SwsContext *c, const uint8_t *srcDither, int rot) +{ + if (rot) { + __asm__ volatile("pxor %%mm0, %%mm0\n\t" + "movq (%0), %%mm3\n\t" + "movq %%mm3, %%mm4\n\t" + "psrlq $24, %%mm3\n\t" + "psllq $40, %%mm4\n\t" + "por %%mm4, %%mm3\n\t" + "movq %%mm3, %%mm4\n\t" + "punpcklbw %%mm0, %%mm3\n\t" + "punpckhbw %%mm0, %%mm4\n\t" + "psraw $4, %%mm3\n\t" + "psraw $4, %%mm4\n\t" + "movq %%mm3, "DITHER16"+0(%1)\n\t" + "movq %%mm4, "DITHER16"+8(%1)\n\t" + :: "r"(srcDither), "r"(&c->redDither) + ); + } else { + __asm__ volatile("pxor %%mm0, %%mm0\n\t" + "movq (%0), %%mm3\n\t" + "movq %%mm3, %%mm4\n\t" + "punpcklbw %%mm0, %%mm3\n\t" + "punpckhbw %%mm0, %%mm4\n\t" + "psraw $4, %%mm3\n\t" + "psraw $4, %%mm4\n\t" + "movq %%mm3, "DITHER16"+0(%1)\n\t" + "movq %%mm4, "DITHER16"+8(%1)\n\t" + :: "r"(srcDither), "r"(&c->redDither) + ); + } +} +#endif + static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest[4], int dstW, int chrDstW, - const uint8_t *lumDither, const uint8_t *chrDither) + uint8_t *dest[4], int dstW, int chrDstW) { int i; uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; + const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; if (uDest) { x86_reg uv_off = c->uv_offx2 >> 1; - for(i=0; i<8; i++) c->dither16[i] = chrDither[i]>>4; + dither_8to16(c, chrDither, 0); YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) - for(i=0; i<8; i++) c->dither16[i] = chrDither[(i+3)&7]>>4; + dither_8to16(c, chrDither, 1); YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, vDest - uv_off, chrDstW + uv_off, uv_off) } - for(i=0; i<8; i++) c->dither16[i] = lumDither[i]>>4; + dither_8to16(c, lumDither, 0); if (CONFIG_SWSCALE_ALPHA && aDest) { YSCALEYUV2YV12X(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0) } @@ -104,10 +140,6 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, "movq "DITHER32"+8(%0), %%mm5 \n\t"\ "movq "DITHER32"+16(%0), %%mm6 \n\t"\ "movq "DITHER32"+24(%0), %%mm7 \n\t"\ - "pxor %%mm4, %%mm4 \n\t"\ - "pxor %%mm5, %%mm5 \n\t"\ - "pxor %%mm6, %%mm6 \n\t"\ - "pxor %%mm7, %%mm7 \n\t"\ "mov (%%"REG_d"), %%"REG_S" \n\t"\ ".p2align 4 \n\t"\ "1: \n\t"\ @@ -157,26 +189,87 @@ static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, : "%"REG_a, "%"REG_d, "%"REG_S\ ); +#if !COMPILE_TEMPLATE_MMX2 +static av_always_inline void +dither_8to32(SwsContext *c, const uint8_t *srcDither, int rot) +{ +int i; +if(rot) for(i=0; i<8; i++) c->dither32[i] = srcDither[(i+3)&7]<<12; +else for(i=0; i<8; i++) c->dither32[i] = srcDither[i&7]<<12; +return; + + if (rot) { + __asm__ volatile("pxor %%mm0, %%mm0\n\t" + "movq (%0), %%mm4\n\t" + "movq %%mm4, %%mm5\n\t" + "psrlq $24, %%mm4\n\t" + "psllq $40, %%mm5\n\t" + "por %%mm5, %%mm4\n\t" + "movq %%mm4, %%mm6\n\t" + "punpcklbw %%mm0, %%mm4\n\t" + "punpckhbw %%mm0, %%mm6\n\t" + "movq %%mm4, %%mm5\n\t" + "movq %%mm6, %%mm7\n\t" + "punpcklwd %%mm0, %%mm4\n\t" + "punpckhwd %%mm0, %%mm5\n\t" + "punpcklwd %%mm0, %%mm6\n\t" + "punpckhwd %%mm0, %%mm7\n\t" + "psllw $12, %%mm4\n\t" + "psllw $12, %%mm5\n\t" + "psllw $12, %%mm6\n\t" + "psllw $12, %%mm7\n\t" + "movq %%mm4, "DITHER32"+0(%1)\n\t" + "movq %%mm5, "DITHER32"+8(%1)\n\t" + "movq %%mm6, "DITHER32"+16(%1)\n\t" + "movq %%mm7, "DITHER32"+24(%1)\n\t" + :: "r"(srcDither), "r"(&c->redDither) + ); + } else { + __asm__ volatile("pxor %%mm0, %%mm0\n\t" + "movq (%0), %%mm4\n\t" + "movq %%mm4, %%mm6\n\t" + "punpcklbw %%mm0, %%mm4\n\t" + "punpckhbw %%mm0, %%mm6\n\t" + "movq %%mm4, %%mm5\n\t" + "movq %%mm6, %%mm7\n\t" + "punpcklwd %%mm0, %%mm4\n\t" + "punpckhwd %%mm0, %%mm5\n\t" + "punpcklwd %%mm0, %%mm6\n\t" + "punpckhwd %%mm0, %%mm7\n\t" + "psllw $12, %%mm4\n\t" + "psllw $12, %%mm5\n\t" + "psllw $12, %%mm6\n\t" + "psllw $12, %%mm7\n\t" + "movq %%mm4, "DITHER32"+0(%1)\n\t" + "movq %%mm5, "DITHER32"+8(%1)\n\t" + "movq %%mm6, "DITHER32"+16(%1)\n\t" + "movq %%mm7, "DITHER32"+24(%1)\n\t" + :: "r"(srcDither), "r"(&c->redDither) + ); + } +} +#endif + static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest[4], int dstW, int chrDstW, - const uint8_t *lumDither, const uint8_t *chrDither) + uint8_t *dest[4], int dstW, int chrDstW) { int i; uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; + const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; if (uDest) { x86_reg uv_off = c->uv_offx2 >> 1; - for(i=0; i<8; i++) c->dither32[i] = chrDither[i]<<12; + dither_8to32(c, chrDither, 0); YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) - for(i=0; i<8; i++) c->dither32[i] = chrDither[(i+3)&7]<<12; + dither_8to32(c, chrDither, 1); YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, vDest - uv_off, chrDstW + uv_off, uv_off) } - for(i=0; i<8; i++) c->dither32[i] = lumDither[i]<<12; + dither_8to32(c, lumDither, 0); if (CONFIG_SWSCALE_ALPHA && aDest) { YSCALEYUV2YV12X_ACCURATE(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0) } @@ -187,8 +280,7 @@ static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, static void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, - uint8_t *dst[4], int dstW, int chrDstW, - const uint8_t *lumDither, const uint8_t *chrDither) + uint8_t *dst[4], int dstW, int chrDstW) { int p= 4; const int16_t *src[4]= { @@ -222,8 +314,7 @@ static void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc, static void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, - uint8_t *dst[4], int dstW, int chrDstW, - const uint8_t *lumDither, const uint8_t *chrDither) + uint8_t *dst[4], int dstW, int chrDstW) { int p= 4; const int16_t *src[4]= { @@ -231,15 +322,16 @@ static void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc, chrVSrc + chrDstW, alpSrc + dstW }; x86_reg counter[4]= { dstW, chrDstW, chrDstW, dstW }; + const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; while (p--) { if (dst[p]) { int i; - for(i=0; i<8; i++) c->dither16[i] = i<2 ? lumDither[i] : chrDither[i]; + for(i=0; i<8; i++) c->dither16[i] = (p == 2 || p == 3) ? lumDither[i] : chrDither[i]; __asm__ volatile( "mov %2, %%"REG_a" \n\t" - "movq 0(%3), %%mm6 \n\t" - "movq 8(%3), %%mm7 \n\t" + "movq "DITHER16"+0(%3), %%mm6 \n\t" + "movq "DITHER16"+8(%3), %%mm7 \n\t" ".p2align 4 \n\t" /* FIXME Unroll? */ "1: \n\t" "movq (%0, %%"REG_a", 2), %%mm0 \n\t" @@ -253,7 +345,7 @@ static void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc, "add $8, %%"REG_a" \n\t" "jnc 1b \n\t" :: "r" (src[p]), "r" (dst[p] + counter[p]), - "g" (-counter[p]), "r"(c->dither16) + "g" (-counter[p]), "r"(&c->redDither) : "%"REG_a ); } From 29fb1b5a06752d2baf10dd363ece1f1b3c964833 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 10 Jul 2011 15:58:24 +0200 Subject: [PATCH 447/780] sws: Fix chroma init for 32bit buffers. Signed-off-by: Michael Niedermayer --- libswscale/utils.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 00bd89f78b..9d373cc038 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -778,7 +778,7 @@ SwsContext *sws_alloc_context(void) int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) { - int i; + int i, j; int usesVFilter, usesHFilter; int unscaled; SwsFilter dummyFilter= {NULL, NULL, NULL, NULL}; @@ -1062,7 +1062,13 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) //try to avoid drawing green stuff between the right end and the stride end for (i=0; ivChrBufSize; i++) - memset(c->chrUPixBuf[i], 64, dst_stride*2+1); + if(av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 == 15){ + av_assert0(c->scalingBpp == 16); + for(j=0; jchrUPixBuf[i]))[j] = 1<<18; + } else + for(j=0; jchrUPixBuf[i]))[j] = 1<<14; assert(c->chrDstH <= dstH); From e1d9cee13dda335dcb8e46115512cca7d1f2b5a1 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 11 Jul 2011 01:44:23 +0200 Subject: [PATCH 448/780] sws: dont mess with XInc when the code needing it isnt used Signed-off-by: Michael Niedermayer --- libswscale/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 9d373cc038..62839ee8e5 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -916,7 +916,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) c->chrXInc+= 20; } //we don't use the x86 asm scaler if MMX is available - else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) { + else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX && c->scalingBpp == 8) { c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20; c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20; } From 46b32b51979af94f645f8780c78bb12944d04790 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 11 Jul 2011 03:54:30 +0200 Subject: [PATCH 449/780] regtests/sws: update checksums for recent changes Signed-off-by: Michael Niedermayer --- tests/ref/lavf/pixfmt | 4 ++-- tests/ref/lavfi/pixdesc | 16 ++++++++-------- tests/ref/lavfi/pixfmts_copy | 16 ++++++++-------- tests/ref/lavfi/pixfmts_crop | 16 ++++++++-------- tests/ref/lavfi/pixfmts_hflip | 16 ++++++++-------- tests/ref/lavfi/pixfmts_null | 16 ++++++++-------- tests/ref/lavfi/pixfmts_scale | 36 +++++++++++++++++------------------ tests/ref/lavfi/pixfmts_vflip | 16 ++++++++-------- 8 files changed, 68 insertions(+), 68 deletions(-) diff --git a/tests/ref/lavf/pixfmt b/tests/ref/lavf/pixfmt index a6618390e4..bf62d9059b 100644 --- a/tests/ref/lavf/pixfmt +++ b/tests/ref/lavf/pixfmt @@ -28,9 +28,9 @@ efa7c0337cc00c796c6df615223716f1 *./tests/data/pixfmt/rgb565.yuv 304128 ./tests/data/pixfmt/rgb555.yuv 6be306b0cce5f8e6c271ea17fef9745b *./tests/data/pixfmt/gray.yuv 304128 ./tests/data/pixfmt/gray.yuv -31398104d2349dd48328a6862bc6711f *./tests/data/pixfmt/monow.yuv +6c719671e39f1bcf67b47eab98fa529b *./tests/data/pixfmt/monow.yuv 304128 ./tests/data/pixfmt/monow.yuv -31398104d2349dd48328a6862bc6711f *./tests/data/pixfmt/monob.yuv +6c719671e39f1bcf67b47eab98fa529b *./tests/data/pixfmt/monob.yuv 304128 ./tests/data/pixfmt/monob.yuv 00b85790df5740bab95e2559d81603a7 *./tests/data/pixfmt/yuv440p.yuv 304128 ./tests/data/pixfmt/yuv440p.yuv diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc index 3efc45bf4b..35e08a6ac7 100644 --- a/tests/ref/lavfi/pixdesc +++ b/tests/ref/lavfi/pixdesc @@ -1,8 +1,8 @@ abgr 037bf9df6a765520ad6d490066bf4b89 argb c442a8261c2265a07212ef0f72e35f5a bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b -bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f -bgr48le d022bfdd6a07d5dcc693799322a386b4 +bgr48be 74dedaaacae8fd1ef46e05f78cf29d62 +bgr48le 0eb7d30801eac6058814bddd330b3c76 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b @@ -18,8 +18,8 @@ monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f rgb24 b41eba9651e1b5fe386289b506188105 -rgb48be 460b6de89b156290a12d3941db8bd731 -rgb48le cd93cb34d15996987367dabda3a10128 +rgb48be e3bc84c9af376fb6d0f0293cc7b713a6 +rgb48le f51c0e71638a822458329abb2f4052c7 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c @@ -40,12 +40,12 @@ yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a yuv422p10be bdc13b630fd668b34c6fe1aae28dfc71 yuv422p10le d0607c260a45c973e6639f4e449730ad -yuv422p16be 5499502e1c29534a158a1fe60e889f60 -yuv422p16le e3d61fde6978591596bc36b914386623 +yuv422p16be dc9886f2fccf87cc54b27e071a2c251e +yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be ea602a24b8e6969679265078bd8607b6 -yuv444p16le 1262a0dc57ee147967fc896d04206313 +yuv444p16be af555dbaa401b142a995566864f47545 +yuv444p16le a803e8016997dad95c5b2a72f54c34d6 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index 3efc45bf4b..35e08a6ac7 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -1,8 +1,8 @@ abgr 037bf9df6a765520ad6d490066bf4b89 argb c442a8261c2265a07212ef0f72e35f5a bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b -bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f -bgr48le d022bfdd6a07d5dcc693799322a386b4 +bgr48be 74dedaaacae8fd1ef46e05f78cf29d62 +bgr48le 0eb7d30801eac6058814bddd330b3c76 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b @@ -18,8 +18,8 @@ monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f rgb24 b41eba9651e1b5fe386289b506188105 -rgb48be 460b6de89b156290a12d3941db8bd731 -rgb48le cd93cb34d15996987367dabda3a10128 +rgb48be e3bc84c9af376fb6d0f0293cc7b713a6 +rgb48le f51c0e71638a822458329abb2f4052c7 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c @@ -40,12 +40,12 @@ yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a yuv422p10be bdc13b630fd668b34c6fe1aae28dfc71 yuv422p10le d0607c260a45c973e6639f4e449730ad -yuv422p16be 5499502e1c29534a158a1fe60e889f60 -yuv422p16le e3d61fde6978591596bc36b914386623 +yuv422p16be dc9886f2fccf87cc54b27e071a2c251e +yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be ea602a24b8e6969679265078bd8607b6 -yuv444p16le 1262a0dc57ee147967fc896d04206313 +yuv444p16be af555dbaa401b142a995566864f47545 +yuv444p16le a803e8016997dad95c5b2a72f54c34d6 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_crop b/tests/ref/lavfi/pixfmts_crop index af42cd3c4a..e3bb88c101 100644 --- a/tests/ref/lavfi/pixfmts_crop +++ b/tests/ref/lavfi/pixfmts_crop @@ -1,8 +1,8 @@ abgr cd761690872843d1b7ab0c695393c751 argb 2ec6ef18769bcd651c2e8904d5a3ee67 bgr24 3450fd00cf1493d1ded75544d82ba3ec -bgr48be 90cb5d373a1123432d63c6a10c101afa -bgr48le 9371f54ceda9010f1199e86f4930ac3f +bgr48be a9a7d177cef0914d3f1d266f00dff676 +bgr48le b475d1b529ed80c728ddbacd22d35281 bgr4_byte 2f6ac3cdd4676ab4e2982bdf0664945b bgr555be d3a7c273604723adeb7e5f5dd1c4272b bgr555le d22442fc13b464f9ba455b08df4e981f @@ -14,8 +14,8 @@ gray 8c4850e66562a587a292dc728a65ea4a gray16be daa5a6b98fb4a280c57c57bff1a2ab5a gray16le 84f5ea7259073edcb893113b42213c8e rgb24 3b90ed64b687d3dc186c6ef521dc71a8 -rgb48be a808128041a1962deaa8620c7448feba -rgb48le ce92d02cc322608d5be377cb1940677b +rgb48be b8f9fd6aaa24d75275ee2f8b8a7b9e55 +rgb48le 3e52e831a040f086c3ae983241172cce rgb4_byte 6958029f73c6cdfed4f71020d816f027 rgb555be 41a7d1836837bc90f2cae19a9c9df3b3 rgb555le eeb78f8ce6186fba55c941469e60ba67 @@ -29,12 +29,12 @@ yuv420p bfea0188ddd4889787c403caae119cc7 yuv420p16be 8365eff38b8c329aeb95fc605fa229bb yuv420p16le 5e8dd38d973d5854abe1ad4efad20cc1 yuv422p f2f930a91fe00d4252c4720b5ecd8961 -yuv422p16be 167e4338811a7d272925a4c6417d60da -yuv422p16le 3359395d5875d581fa1e975013d30114 +yuv422p16be 93f9b6f33f9529db6de6a9f0ddd70eb5 +yuv422p16le 2e66dcfec54ca6b57aa4bbd9ac234639 yuv440p 2472417d980e395ad6843cbb8b633b29 yuv444p 1f151980486848c96bc5585ced99003e -yuv444p16be d69280c2856865d2ea94bd5292aac1c6 -yuv444p16le 33f43e030bedf9723be4f63c3e9fc80e +yuv444p16be e7d1ecf0c11a41b5db192f761f55bd3c +yuv444p16le 3298a0043d982e7cf1a33a1292fa11f0 yuva420p 7536753dfbc7932560fb50c921369a0e yuvj420p 21f891093006d42d7683b0e1d773a657 yuvj422p 9a43d474c407590ad8f213880586b45e diff --git a/tests/ref/lavfi/pixfmts_hflip b/tests/ref/lavfi/pixfmts_hflip index 3a3dbf0014..2084d581e1 100644 --- a/tests/ref/lavfi/pixfmts_hflip +++ b/tests/ref/lavfi/pixfmts_hflip @@ -1,8 +1,8 @@ abgr 49468c6c9ceee5d52b08b1270a909323 argb 50ba9f16c6475530602f2983278b82d0 bgr24 cc53d2011d097972db0d22756c3699e3 -bgr48be 11641cf0f4516a9aed98f7872720f801 -bgr48le b5440734eed128554dd9f83b34ba582f +bgr48be 90374bc92471f1bd4931d71ef8b73f50 +bgr48le 696f628d0dd32121e60a0d61ac47d6e6 bgr4_byte aac987e7d1a6a96477cfc0b48a4285de bgr555be bc07265898440116772200390d70c092 bgr555le ccee08679bac84a1f960c6c9070c5538 @@ -14,8 +14,8 @@ gray 03efcb4ab52a24c0af0e03cfd26c9377 gray16be 9bcbca979601ddc4869f846f08f3d1dd gray16le c1b8965adcc7f847ee343149ff507073 rgb24 754f1722fc738590cc407ac65749bfe8 -rgb48be 10743e1577dc3198dbbc7c0b3b8f429e -rgb48le dd945a44f39119221407bf7a04f1bc49 +rgb48be 2397b9d3c296ac15f8a2325a703f81c7 +rgb48le 527043c72546d8b4bb1ce2dea4b294c3 rgb4_byte c8a3f995fcf3e0919239ea2c413ddc29 rgb555be 045ce8607d3910586f4d97481dda8632 rgb555le 8778ee0cf58ce9ad1d99a1eca9f95e87 @@ -29,12 +29,12 @@ yuv420p 2d5c80f9ba2ddd85b2aeda3564cc7d64 yuv420p16be 758b0c1e2113b15e7afde48da4e4d024 yuv420p16le 480ccd951dcb806bc875d307e02e50a0 yuv422p 6e728f4eb9eae287c224f396d84be6ea -yuv422p16be a05d43cd62b790087bd37083174557de -yuv422p16le 6954abebcbc62d81068d58d0c62bdd5b +yuv422p16be 8657d2c8d443940300fdb4028d555631 +yuv422p16le 4ab27609981e50de5b1150125718ae76 yuv440p a99e2b57ed601f39852715c9d675d0d3 yuv444p 947e47f7bb5fdccc659d19b7df2b6fc3 -yuv444p16be e5ef45bc3d2f5b0b2542d5151340c382 -yuv444p16le 70793e3d66d0c23a0cdedabe9c24c2a7 +yuv444p16be a5154ce329db0d2caf0bd43f1347dba3 +yuv444p16le 1f703308b90feb048191b3bccc695671 yuva420p d83ec0c01498189f179ec574918185f1 yuvj420p df3aaaec3bb157c3bde5f0365af30f4f yuvj422p d113871528d510a192797af59df9c05c diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index 3efc45bf4b..35e08a6ac7 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -1,8 +1,8 @@ abgr 037bf9df6a765520ad6d490066bf4b89 argb c442a8261c2265a07212ef0f72e35f5a bgr24 0d0cb38ab3fa0b2ec0865c14f78b217b -bgr48be 4ba0ff7fc9e011ea264610ad1585bb1f -bgr48le d022bfdd6a07d5dcc693799322a386b4 +bgr48be 74dedaaacae8fd1ef46e05f78cf29d62 +bgr48le 0eb7d30801eac6058814bddd330b3c76 bgr4_byte 50d23cc82d9dcef2fd12adb81fb9b806 bgr555be 49f01b1f1f0c84fd9e776dd34cc3c280 bgr555le 378d6ac4223651a1adcbf94a3d0d807b @@ -18,8 +18,8 @@ monow 9251497f3b0634f1165d12d5a289d943 nv12 e0af357888584d36eec5aa0f673793ef nv21 9a3297f3b34baa038b1f37cb202b512f rgb24 b41eba9651e1b5fe386289b506188105 -rgb48be 460b6de89b156290a12d3941db8bd731 -rgb48le cd93cb34d15996987367dabda3a10128 +rgb48be e3bc84c9af376fb6d0f0293cc7b713a6 +rgb48le f51c0e71638a822458329abb2f4052c7 rgb4_byte c93ba89b74c504e7f5ae9d9ab1546c73 rgb555be 912a62c5e53bfcbac2a0340e10973cf2 rgb555le a937a0fc764fb57dc1b3af87cba0273c @@ -40,12 +40,12 @@ yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a yuv422p10be bdc13b630fd668b34c6fe1aae28dfc71 yuv422p10le d0607c260a45c973e6639f4e449730ad -yuv422p16be 5499502e1c29534a158a1fe60e889f60 -yuv422p16le e3d61fde6978591596bc36b914386623 +yuv422p16be dc9886f2fccf87cc54b27e071a2c251e +yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf yuv444p 0a98447b78fd476aa39686da6a74fa2e -yuv444p16be ea602a24b8e6969679265078bd8607b6 -yuv444p16le 1262a0dc57ee147967fc896d04206313 +yuv444p16be af555dbaa401b142a995566864f47545 +yuv444p16le a803e8016997dad95c5b2a72f54c34d6 yuva420p a29884f3f3dfe1e00b961bc17bef3d47 yuvj420p 32eec78ba51857b16ce9b813a49b7189 yuvj422p 0dfa0ed434f73be51428758c69e082cb diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index b3351c8631..15f63b3c4f 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -1,8 +1,8 @@ abgr cff82561a074874027ac1cc896fd2730 argb 756dd1eaa5baca2238ce23dbdc452684 bgr24 e44192347a45586c6c157e3059610cd1 -bgr48be 6d01b6ccd2ccf18c12985bcb2fde2218 -bgr48le 4caa6914091ad03b8f67c02d6b050bc0 +bgr48be 07f7a0cc34feb3646434d47c0cec8cee +bgr48le 9abd2c3a66088e6c9078232064eba61e bgr4_byte ee1d35a7baf8e9016891929a2f565c0b bgr555be 6a2d335856db12e3ea72173d71610e21 bgr555le 41e3e0961478dc634bf68a7bbd670cc9 @@ -11,15 +11,15 @@ bgr565le 614897eaeb422bd9a972f8ee51909be5 bgr8 7f007fa6c153a16e808a9c51605a4016 bgra 01cfdda1f72fcabb6c46424e27f8c519 gray d7786a7d9d99ac74230cc045cab5632c -gray16be 5ba22d4802b40ec27e62abb22ad1d1cc -gray16le 2d5e83aa875a4c3baa6fecf55e3223bf +gray16be b554d6c1cc8da23967445be4dd3e4a86 +gray16le 715a33aa1c19cb26b14f5cc000e7a3d1 monob cb62f31b701c6e987b574974d1b31e32 monow fd5d417ab7728acddffc06870661df61 nv12 4676d59db43d657dc12841f6bc3ab452 nv21 69c699510ff1fb777b118ebee1002f14 rgb24 13ff53ebeab74dc05492836f1cfbd2c1 -rgb48be f82e99f13d5ede2a53cf3bf7178ca350 -rgb48le 3a09d89e4b27ea1a98f762e662e306a7 +rgb48be f18841c19fc6d9c817a3095f557b9bc5 +rgb48le 819e7b8acd8965ba57ba46198a5cc9bf rgb4_byte d81ffd3add95842a618eec81024f0b5c rgb555be 491dc49ff83258ffe415289bdcfb50b2 rgb555le bd698d86c03170c4a16607c0fd1f750f @@ -31,21 +31,21 @@ uyvy422 314bd486277111a95d9369b944fa0400 yuv410p 7df8f6d69b56a8dcb6c7ee908e5018b5 yuv411p 1143e7c5cc28fe0922b051b17733bc4c yuv420p fdad2d8df8985e3d17e73c71f713cb14 -yuv420p10be c143e77e97d2f7d62c3b518857ba9f9b -yuv420p10le 72d90eccf5c34691ff057dafb7447aa2 -yuv420p16be 01da53e7f4f9882d5189ec1b1165ee05 -yuv420p16le 165f9aaf5332e5d088f44534d8ed2bc9 -yuv420p9be bb87fddca65d1742412c8d2b1caf96c6 -yuv420p9le 828eec50014a41258a5423c1fe56ac97 +yuv420p10be d7695b9117d5b52819c569459e42669b +yuv420p10le 0ac6d448db2df5f3d1346aa81f2b5f50 +yuv420p16be 9688e33e03b8c8275ab2fb1df0f06bee +yuv420p16le cba8b390ad5e7b8678e419b8ce79c008 +yuv420p9be 8fa6e007b1a40f34eaa3e2beb73ea8af +yuv420p9le a7b131a7dd06906a5aef2e36d117b972 yuv422p 918e37701ee7377d16a8a6c119c56a40 -yuv422p10be cea7ca6b0e66d6f29539885896c88603 -yuv422p10le a10c4a5837547716f13cd61918b145f9 -yuv422p16be 961860aa4f229e09f1249910c687081c -yuv422p16le 7695ee42c0581279bbe68de81deb7aee +yuv422p10be 35206fcd7e00ee582a8c366b37d57d1d +yuv422p10le 396f930e2da02f149ab9dd5b781cbe8d +yuv422p16be 2cf502d7d386db1f1b3b946679d897b1 +yuv422p16le 3002a4e47520731dcee5929aff49eb74 yuv440p 461503fdb9b90451020aa3b25ddf041c yuv444p 81b2eba962d12e8d64f003ac56f6faf2 -yuv444p16be 5f924c2b385826106300cecc4ef4d2df -yuv444p16le 40a55a85858508138b7661c83d95223e +yuv444p16be b9f051ce7335923fe33efd162e48da1d +yuv444p16le fa47e317efac988b4a7fa55141c89126 yuva420p 8673a9131fb47de69788863f93a50eb7 yuvj420p 30427bd6caf5bda93a173dbebe759e09 yuvj422p fc8288f64fd149573f73cf8da05d8e6d diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index 16471417ab..44f1c131db 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -1,8 +1,8 @@ abgr 25e72e9dbd01ab00727c976d577f7be5 argb 19869bf1a5ac0b6af4d8bbe2c104533c bgr24 89108a4ba00201f79b75b9305c42352d -bgr48be ed82382da09b64a8e04728fcf76e6814 -bgr48le 0f1f135608c2ff24d26d03e939fc2112 +bgr48be 908b4edb525fd154a95a3744c4ab5420 +bgr48le 796c2072d6fa13a091f5c5b175417ed5 bgr4_byte 407fcf564ed764c38e1d748f700ab921 bgr555be f739d2519f7e9d494359bf67a3821537 bgr555le bd7b3ec4d684dfad075d89a606cb8b74 @@ -18,8 +18,8 @@ monow ff9869d067ecb94eb9d90c9750c31fea nv12 046f00f598ce14d9854a3534a5c99114 nv21 01ea369dd2d0d3ed7451dc5c8d61497f rgb24 eaefabc168d0b14576bab45bc1e56e1e -rgb48be 4e0c384163ebab06a08e74637beb02bc -rgb48le a77bfeefcd96750cf0e1917a2e2bf1e7 +rgb48be 8e347deca2902e7dc1ece261322577d8 +rgb48le 2034e485f946e4064b5fb9be09865e55 rgb4_byte 8c6ff02df0b06dd2d574836c3741b2a2 rgb555be 40dc33cfb5cf56aac1c5a290ac486c36 rgb555le 4f8eaad29a17e0f8e9d8ab743e76b999 @@ -40,12 +40,12 @@ yuv420p9le 7e606310d3f5ff12badf911e8f333471 yuv422p d7f5cb44d9b0210d66d6a8762640ab34 yuv422p10be 588fe319b96513c32e21d3e32b45447f yuv422p10le 11b57f2bd9661024153f3973b9090cdb -yuv422p16be 9bd8f8c961822b586fa4cf992be54acc -yuv422p16le 9c4a1239605c7952b736ac3130163f14 +yuv422p16be 51d9aa4e78d121c226d919ce97976fe4 +yuv422p16le 12965c54bda8932ca72da194419a9908 yuv440p 876385e96165acf51271b20e5d85a416 yuv444p 9c3c667d1613b72d15bc6d851c5eb8f7 -yuv444p16be 0f4afa4a4aacf4bb6b87641abde71ea9 -yuv444p16le 8f31557bc52adfe00ae8b40a9b8c23f8 +yuv444p16be 6502abd75030d462c58d99a8673ec517 +yuv444p16le cd7e88b6d08425450a57555bc86ab210 yuva420p c705d1cf061d8c6580ac690b55f92276 yuvj420p 41fd02b204da0ab62452cd14b595e2e4 yuvj422p 7f6ca9bc1812cde02036d7d29a7cce43 From a8c2ff2c3cc5f28c36692031c342692cac742280 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 11 Jul 2011 05:46:51 +0200 Subject: [PATCH 450/780] Revert "lavc: remove a half-working attempt at different defaults for audio/video codecs." This reverts commit 18c007ba37b2c7dee5bd2f1a3eb3bfee9b6b3d26. --- libavcodec/options.c | 2 +- tests/lavf-regression.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/options.c b/libavcodec/options.c index 74e60fb67f..be60b96fe4 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -71,7 +71,7 @@ static const AVOption *opt_find(void *obj, const char *name, const char *unit, i static const AVOption options[]={ {"b", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE }, INT_MIN, INT_MAX, V|E}, -{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE }, INT_MIN, INT_MAX, A|E}, +{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = 64*1000 }, INT_MIN, INT_MAX, A|E}, {"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE*20 }, 1, INT_MAX, V|E}, {"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, V|A|E|D, "flags"}, {"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"}, diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh index 6d2d6d8162..d7e684032c 100755 --- a/tests/lavf-regression.sh +++ b/tests/lavf-regression.sh @@ -14,7 +14,7 @@ eval do_$test=y do_lavf() { file=${outfile}lavf.$1 - do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -ab 64k -t 1 -qscale 10 $2 + do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $2 do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file $3 } @@ -53,7 +53,7 @@ fi if [ -n "$do_rm" ] ; then file=${outfile}lavf.rm -do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed -ab 64k +do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed # broken #do_ffmpeg_crc $file -i $target_path/$file fi From 5eafc8b46644764f8aef1b7b2ecae53ee8034822 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 10 Jul 2011 17:28:28 -0700 Subject: [PATCH 451/780] mt: proper locking around release_buffer calls. This fixes a crash when seeking in some webm files with many threads (e.g. 8). --- libavcodec/pthread.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 08ef4ba0c2..77e072d96a 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -408,9 +408,10 @@ static void release_delayed_buffers(PerThreadContext *p) FrameThreadContext *fctx = p->parent; while (p->num_released_buffers > 0) { - AVFrame *f = &p->released_buffers[--p->num_released_buffers]; + AVFrame *f; pthread_mutex_lock(&fctx->buffer_mutex); + f = &p->released_buffers[--p->num_released_buffers]; free_progress(f); f->thread_opaque = NULL; @@ -836,6 +837,7 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f) void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f) { PerThreadContext *p = avctx->thread_opaque; + FrameThreadContext *fctx; if (!(avctx->active_thread_type&FF_THREAD_FRAME)) { avctx->release_buffer(avctx, f); @@ -851,7 +853,10 @@ void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f) av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p, %d buffers used\n", f, f->owner->internal_buffer_count); + fctx = p->parent; + pthread_mutex_lock(&fctx->buffer_mutex); p->released_buffers[p->num_released_buffers++] = *f; + pthread_mutex_unlock(&fctx->buffer_mutex); memset(f->data, 0, sizeof(f->data)); } From d1cf45911935cc4fed9afd3a37d99616d31eb9da Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 10 Jul 2011 21:23:09 -0700 Subject: [PATCH 452/780] vp8/mt: flush worker thread, not application thread context, on seek. This prevents a crash when seeking. --- libavcodec/pthread.c | 9 ++++++--- libavcodec/utils.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 77e072d96a..e546c21ddd 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -747,9 +747,12 @@ void ff_thread_flush(AVCodecContext *avctx) if (!avctx->thread_opaque) return; park_frame_worker_threads(fctx, avctx->thread_count); - - if (fctx->prev_thread) - update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0); + if (fctx->prev_thread) { + if (fctx->prev_thread != &fctx->threads[0]) + update_context_from_thread(fctx->threads[0].avctx, fctx->prev_thread->avctx, 0); + if (avctx->codec->flush) + avctx->codec->flush(fctx->threads[0].avctx); + } fctx->next_decoding = fctx->next_finished = 0; fctx->delaying = 1; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 5ad0c51d02..32e52514e5 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1080,7 +1080,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) { if(HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME) ff_thread_flush(avctx); - if(avctx->codec->flush) + else if(avctx->codec->flush) avctx->codec->flush(avctx); } From ca9036155d28ed9f5a1406356316c3fd41e5a400 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 10 Jul 2011 22:01:41 +0100 Subject: [PATCH 453/780] build: remove unnecessary FFLDFLAGS variable This variable is set to the same value for all directories. Adding the -L flags directly to LDFLAGS is simpler and achieves the same thing. Signed-off-by: Mans Rullgard --- Makefile | 6 +++--- common.mak | 1 - subdir.mak | 4 ++-- tests/Makefile | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 720936a604..87451e04d0 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ CFLAGS += $(ECFLAGS) CCFLAGS = $(CFLAGS) YASMFLAGS += $(IFLAGS) -Pconfig.asm HOSTCFLAGS += $(IFLAGS) +LDFLAGS += $(ALLFFLIBS:%=-Llib%) define COMPILE $($(1)DEP) @@ -82,7 +83,6 @@ SKIPHEADERS = cmdutils_common_opts.h include $(SRC_PATH)/common.mak -FF_LDFLAGS := $(FFLDFLAGS) FF_EXTRALIBS := $(FFEXTRALIBS) FF_DEP_LIBS := $(DEP_LIBS) @@ -118,10 +118,10 @@ $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D)))) ffplay.o: CFLAGS += $(SDL_CFLAGS) ffplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS) -ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS) +ffserver$(EXESUF): LDFLAGS += $(FFSERVERLDFLAGS) $(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS) - $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS) + $(LD) $(LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS) OBJDIRS += tools diff --git a/common.mak b/common.mak index 8a2aa7cf0d..d781ced09e 100644 --- a/common.mak +++ b/common.mak @@ -12,7 +12,6 @@ FFLIBS := $(FFLIBS-yes) $(FFLIBS) TESTPROGS += $(TESTPROGS-yes) FFEXTRALIBS := $(FFLIBS:%=-l%$(BUILDSUF)) $(EXTRALIBS) -FFLDFLAGS := $(ALLFFLIBS:%=-Llib%) $(LDFLAGS) EXAMPLES := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF)) OBJS := $(sort $(OBJS:%=$(SUBDIR)%)) diff --git a/subdir.mak b/subdir.mak index a88955bdfb..e6d52953b5 100644 --- a/subdir.mak +++ b/subdir.mak @@ -35,14 +35,14 @@ install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared define RULES $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o - $$(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS) + $$(LD) $(LDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS) $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR) $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME) $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(DEP_LIBS) $(SLIB_CREATE_DEF_CMD) - $$(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS) + $$(LD) $(SHFLAGS) $(LDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS) $(SLIB_EXTRA_CMD) clean:: diff --git a/tests/Makefile b/tests/Makefile index 501a72f879..35e803d102 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -29,7 +29,7 @@ tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF) tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS) - $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) + $(LD) $(LDFLAGS) -o $@ $< $(FF_EXTRALIBS) include $(SRC_PATH)/tests/fate.mak include $(SRC_PATH)/tests/fate2.mak From 8923cfa328e8eb565aebcfe8672b276fd1c19bf7 Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Thu, 30 Jun 2011 09:03:15 +0000 Subject: [PATCH 454/780] mpegts: fix Continuity Counter error detection According to MPEG-TS specs, the continuity_counter shall not be incremented when the adaptation_field_control of the packet equals '00' or '10'. Signed-off-by: Jindrich Makovicka Signed-off-by: Anton Khirnov --- libavformat/mpegts.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 43cd1fbd6f..228f48b424 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1248,7 +1248,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) { AVFormatContext *s = ts->stream; MpegTSFilter *tss; - int len, pid, cc, cc_ok, afc, is_start; + int len, pid, cc, expected_cc, cc_ok, afc, is_start; const uint8_t *p, *p_end; int64_t pos; @@ -1266,7 +1266,8 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) /* continuity check (currently not used) */ cc = (packet[3] & 0xf); - cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc)); + expected_cc = (packet[3] & 0x10) ? (tss->last_cc + 1) & 0x0f : tss->last_cc; + cc_ok = (tss->last_cc < 0) || (expected_cc == cc); tss->last_cc = cc; /* skip adaptation field */ From a4f6be86d67ae30d494fbe8a470bc32b715d75a9 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Sun, 10 Jul 2011 01:28:50 -0700 Subject: [PATCH 455/780] H.264: optimize intra/inter loopfilter decision --- libavcodec/h264_loopfilter.c | 233 ++++++++++++++++++----------------- 1 file changed, 117 insertions(+), 116 deletions(-) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 2e94459b6c..c9b94ce860 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -100,14 +100,15 @@ static const uint8_t tc0_table[52*3][4] = { {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, }; -static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h) { +/* intra: 0 if this loopfilter call is guaranteed to be inter (bS < 4), 1 if it might be intra (bS == 4) */ +static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h, int intra ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; - if( bS[0] < 4 ) { + if( bS[0] < 4 || !intra ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0]]; tc[1] = tc0_table[index_a][bS[1]]; @@ -118,14 +119,14 @@ static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const in h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta); } } -static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) { +static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h, int intra ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; - if( bS[0] < 4 ) { + if( bS[0] < 4 || !intra ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0]]+1; tc[1] = tc0_table[index_a][bS[1]]+1; @@ -137,14 +138,14 @@ static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const i } } -static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) { +static void av_always_inline filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int intra ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; int alpha = alpha_table[index_a]; int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; - if( bS[0] < 4 ) { + if( bS[0] < 4 || !intra ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0*bsi]]; tc[1] = tc0_table[index_a][bS[1*bsi]]; @@ -155,14 +156,14 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, con h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta); } } -static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) { +static void av_always_inline filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int intra ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; int alpha = alpha_table[index_a]; int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; - if( bS[0] < 4 ) { + if( bS[0] < 4 || !intra ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0*bsi]] + 1; tc[1] = tc0_table[index_a][bS[1*bsi]] + 1; @@ -174,14 +175,14 @@ static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, co } } -static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) { +static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h, int intra ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; - if( bS[0] < 4 ) { + if( bS[0] < 4 || !intra ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0]]; tc[1] = tc0_table[index_a][bS[1]]; @@ -193,14 +194,14 @@ static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const in } } -static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) { +static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h, int intra ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; - if( bS[0] < 4 ) { + if( bS[0] < 4 || !intra ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0]]+1; tc[1] = tc0_table[index_a][bS[1]]+1; @@ -247,70 +248,70 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, static const int16_t bS3[4] = {3,3,3,3}; const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4; if(left_type) - filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, h); + filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, h, 1); if( IS_8x8DCT(mb_type) ) { - filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h); + filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h, 0); if(top_type){ - filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h); + filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h, 1); } - filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h); + filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h, 0); } else { - filter_mb_edgev( &img_y[4*1], linesize, bS3, qp, h); - filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h); - filter_mb_edgev( &img_y[4*3], linesize, bS3, qp, h); + filter_mb_edgev( &img_y[4*1], linesize, bS3, qp, h, 0); + filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h, 0); + filter_mb_edgev( &img_y[4*3], linesize, bS3, qp, h, 0); if(top_type){ - filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h); + filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h, 1); } - filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, h); - filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h); - filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, h); + filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, h, 0); + filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h, 0); + filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, h, 0); } if(chroma){ if(chroma444){ if(left_type){ - filter_mb_edgev( &img_cb[4*0], linesize, bS4, qpc0, h); - filter_mb_edgev( &img_cr[4*0], linesize, bS4, qpc0, h); + filter_mb_edgev( &img_cb[4*0], linesize, bS4, qpc0, h, 1); + filter_mb_edgev( &img_cr[4*0], linesize, bS4, qpc0, h, 1); } if( IS_8x8DCT(mb_type) ) { - filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h); - filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h); + filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h, 0); + filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h, 0); if(top_type){ - filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h); - filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h); + filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h,1 ); + filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h,1 ); } - filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h); - filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h); + filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h, 0); + filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h, 0); } else { - filter_mb_edgev( &img_cb[4*1], linesize, bS3, qpc, h); - filter_mb_edgev( &img_cr[4*1], linesize, bS3, qpc, h); - filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h); - filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h); - filter_mb_edgev( &img_cb[4*3], linesize, bS3, qpc, h); - filter_mb_edgev( &img_cr[4*3], linesize, bS3, qpc, h); + filter_mb_edgev( &img_cb[4*1], linesize, bS3, qpc, h, 0); + filter_mb_edgev( &img_cr[4*1], linesize, bS3, qpc, h, 0); + filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h, 0); + filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h, 0); + filter_mb_edgev( &img_cb[4*3], linesize, bS3, qpc, h, 0); + filter_mb_edgev( &img_cr[4*3], linesize, bS3, qpc, h, 0); if(top_type){ - filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h); - filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h); + filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h, 1); + filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h, 1); } - filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, h); - filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, h); - filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h); - filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h); - filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, h); - filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, h); + filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, h, 0); + filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, h, 0); + filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h, 0); + filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h, 0); + filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, h, 0); + filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, h, 0); } }else{ if(left_type){ - filter_mb_edgecv( &img_cb[2*0], uvlinesize, bS4, qpc0, h); - filter_mb_edgecv( &img_cr[2*0], uvlinesize, bS4, qpc0, h); + filter_mb_edgecv( &img_cb[2*0], uvlinesize, bS4, qpc0, h, 1); + filter_mb_edgecv( &img_cr[2*0], uvlinesize, bS4, qpc0, h, 1); } - filter_mb_edgecv( &img_cb[2*2], uvlinesize, bS3, qpc, h); - filter_mb_edgecv( &img_cr[2*2], uvlinesize, bS3, qpc, h); + filter_mb_edgecv( &img_cb[2*2], uvlinesize, bS3, qpc, h, 0); + filter_mb_edgecv( &img_cr[2*2], uvlinesize, bS3, qpc, h, 0); if(top_type){ - filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h); - filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h); + filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h, 1); + filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h, 1); } - filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, h); - filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, h); + filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, h, 0); + filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, h, 0); } } return; @@ -336,38 +337,38 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, if( IS_INTRA(top_type) ) AV_WN64A(bS[1][0], FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL); -#define FILTER(hv,dir,edge)\ +#define FILTER(hv,dir,edge,intra)\ if(AV_RN64A(bS[dir][edge])) { \ - filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qp : qp##dir, h );\ + filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qp : qp##dir, h, intra );\ if(chroma){\ if(chroma444){\ - filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\ - filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\ + filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h, intra );\ + filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h, intra );\ } else if(!(edge&1)) {\ - filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\ - filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h );\ + filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h, intra );\ + filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h, intra );\ }\ }\ } if(left_type) - FILTER(v,0,0); + FILTER(v,0,0,1); if( edges == 1 ) { if(top_type) - FILTER(h,1,0); + FILTER(h,1,0,1); } else if( IS_8x8DCT(mb_type) ) { - FILTER(v,0,2); + FILTER(v,0,2,0); if(top_type) - FILTER(h,1,0); - FILTER(h,1,2); + FILTER(h,1,0,1); + FILTER(h,1,2,0); } else { - FILTER(v,0,1); - FILTER(v,0,2); - FILTER(v,0,3); + FILTER(v,0,1,0); + FILTER(v,0,2,0); + FILTER(v,0,3,0); if(top_type) - FILTER(h,1,0); - FILTER(h,1,1); - FILTER(h,1,2); - FILTER(h,1,3); + FILTER(h,1,0,1); + FILTER(h,1,1,0); + FILTER(h,1,2,0); + FILTER(h,1,3,0); } #undef FILTER } @@ -456,16 +457,16 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u qp = (s->current_picture.f.qscale_table[mb_xy] + s->current_picture.f.qscale_table[mbn_xy] + 1) >> 1; tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize); { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } - filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, h ); + filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, h, 0 ); chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1; chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1; if (chroma) { if (chroma444) { - filter_mb_edgeh (&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], h); - filter_mb_edgeh (&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], h); + filter_mb_edgeh (&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], h, 0); + filter_mb_edgeh (&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], h, 0); } else { - filter_mb_edgech(&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], h); - filter_mb_edgech(&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], h); + filter_mb_edgech(&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], h, 0); + filter_mb_edgech(&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], h, 0); } } } @@ -525,25 +526,25 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1; chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1; if( dir == 0 ) { - filter_mb_edgev( &img_y[0], linesize, bS, qp, h ); + filter_mb_edgev( &img_y[0], linesize, bS, qp, h, 1 ); if (chroma) { if (chroma444) { - filter_mb_edgev ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h); - filter_mb_edgev ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h); + filter_mb_edgev ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h, 1); + filter_mb_edgev ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h, 1); } else { - filter_mb_edgecv( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h); - filter_mb_edgecv( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h); + filter_mb_edgecv( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h, 1); + filter_mb_edgecv( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h, 1); } } } else { - filter_mb_edgeh( &img_y[0], linesize, bS, qp, h ); + filter_mb_edgeh( &img_y[0], linesize, bS, qp, h, 1 ); if (chroma) { if (chroma444) { - filter_mb_edgeh ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h); - filter_mb_edgeh ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h); + filter_mb_edgeh ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h, 1); + filter_mb_edgeh ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h, 1); } else { - filter_mb_edgech( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h); - filter_mb_edgech( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h); + filter_mb_edgech( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h, 1); + filter_mb_edgech( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h, 1); } } } @@ -607,25 +608,25 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize); //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } if( dir == 0 ) { - filter_mb_edgev( &img_y[4*edge << h->pixel_shift], linesize, bS, qp, h ); + filter_mb_edgev( &img_y[4*edge << h->pixel_shift], linesize, bS, qp, h, 0 ); if (chroma) { if (chroma444) { - filter_mb_edgev ( &img_cb[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h); - filter_mb_edgev ( &img_cr[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h); + filter_mb_edgev ( &img_cb[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h, 0); + filter_mb_edgev ( &img_cr[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h, 0); } else if( (edge&1) == 0 ) { - filter_mb_edgecv( &img_cb[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h); - filter_mb_edgecv( &img_cr[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h); + filter_mb_edgecv( &img_cb[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h, 0); + filter_mb_edgecv( &img_cr[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h, 0); } } } else { - filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, h ); + filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, h, 0 ); if (chroma) { if (chroma444) { - filter_mb_edgeh ( &img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], h); - filter_mb_edgeh ( &img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], h); + filter_mb_edgeh ( &img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], h, 0); + filter_mb_edgeh ( &img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], h, 0); } else if( (edge&1) == 0 ) { - filter_mb_edgech( &img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], h); - filter_mb_edgech( &img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], h); + filter_mb_edgech( &img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], h, 0); + filter_mb_edgech( &img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], h, 0); } } } @@ -706,35 +707,35 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize); { int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } if(MB_FIELD){ - filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0] ); - filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1] ); + filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], 1 ); + filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], 1 ); if (chroma){ if (CHROMA444) { - filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0] ); - filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1] ); - filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0] ); - filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1] ); + filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], 1 ); + filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], 1 ); + filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], 1 ); + filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], 1 ); }else{ - filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0] ); - filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1] ); - filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0] ); - filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1] ); + filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], 1 ); + filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], 1 ); + filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], 1 ); + filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], 1 ); } } }else{ - filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0] ); - filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1] ); + filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], 1 ); + filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], 1 ); if (chroma){ if (CHROMA444) { - filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0] ); - filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1] ); - filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0] ); - filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1] ); + filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], 1 ); + filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], 1 ); + filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], 1 ); + filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], 1 ); }else{ - filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0] ); - filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1] ); - filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0] ); - filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1] ); + filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], 1 ); + filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], 1 ); + filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], 1 ); + filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], 1 ); } } } From f6b7f72461673e4d398b1edf9ed2a7fe70d99c47 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Sun, 10 Jul 2011 02:25:53 -0700 Subject: [PATCH 456/780] H.264: avoid redundant alpha/beta calculations in loopfilter --- libavcodec/h264_loopfilter.c | 243 ++++++++++++++++++----------------- 1 file changed, 122 insertions(+), 121 deletions(-) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index c9b94ce860..f94e13aef0 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -101,11 +101,10 @@ static const uint8_t tc0_table[52*3][4] = { }; /* intra: 0 if this loopfilter call is guaranteed to be inter (bS < 4), 1 if it might be intra (bS == 4) */ -static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h, int intra ) { - const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); - const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; +static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) { + const unsigned int index_a = qp + a; const int alpha = alpha_table[index_a]; - const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; + const int beta = beta_table[qp + b]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 || !intra ) { @@ -119,11 +118,10 @@ static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const in h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta); } } -static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h, int intra ) { - const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); - const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; +static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) { + const unsigned int index_a = qp + a; const int alpha = alpha_table[index_a]; - const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; + const int beta = beta_table[qp + b]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 || !intra ) { @@ -138,11 +136,10 @@ static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const i } } -static void av_always_inline filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int intra ) { - const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); - int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; - int alpha = alpha_table[index_a]; - int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; +static void av_always_inline filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int a, int b, int intra ) { + const unsigned int index_a = qp + a; + const int alpha = alpha_table[index_a]; + const int beta = beta_table[qp + b]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 || !intra ) { @@ -156,11 +153,10 @@ static void av_always_inline filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta); } } -static void av_always_inline filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int intra ) { - const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); - int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; - int alpha = alpha_table[index_a]; - int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; +static void av_always_inline filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int a, int b, int intra ) { + const unsigned int index_a = qp + a; + const int alpha = alpha_table[index_a]; + const int beta = beta_table[qp + b]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 || !intra ) { @@ -175,11 +171,10 @@ static void av_always_inline filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pi } } -static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h, int intra ) { - const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); - const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; +static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) { + const unsigned int index_a = qp + a; const int alpha = alpha_table[index_a]; - const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; + const int beta = beta_table[qp + b]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 || !intra ) { @@ -194,11 +189,10 @@ static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, const in } } -static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h, int intra ) { - const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); - const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; +static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, int a, int b, H264Context *h, int intra ) { + const unsigned int index_a = qp + a; const int alpha = alpha_table[index_a]; - const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; + const int beta = beta_table[qp + b]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 || !intra ) { @@ -220,6 +214,7 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, int qp, qp0, qp1, qpc, qpc0, qpc1; int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)); int chroma444 = CHROMA444; + int qp_bd_offset, a, b; mb_xy = h->mb_xy; @@ -242,76 +237,79 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, qp1 = (qp + qp1 + 1) >> 1; qpc0 = (qpc + qpc0 + 1) >> 1; qpc1 = (qpc + qpc1 + 1) >> 1; + qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); + a = h->slice_alpha_c0_offset - qp_bd_offset; + b = h->slice_beta_offset - qp_bd_offset; if( IS_INTRA(mb_type) ) { static const int16_t bS4[4] = {4,4,4,4}; static const int16_t bS3[4] = {3,3,3,3}; const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4; if(left_type) - filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, h, 1); + filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, a, b, h, 1); if( IS_8x8DCT(mb_type) ) { - filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h, 0); + filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, a, b, h, 0); if(top_type){ - filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h, 1); + filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1); } - filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h, 0); + filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0); } else { - filter_mb_edgev( &img_y[4*1], linesize, bS3, qp, h, 0); - filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h, 0); - filter_mb_edgev( &img_y[4*3], linesize, bS3, qp, h, 0); + filter_mb_edgev( &img_y[4*1], linesize, bS3, qp, a, b, h, 0); + filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, a, b, h, 0); + filter_mb_edgev( &img_y[4*3], linesize, bS3, qp, a, b, h, 0); if(top_type){ - filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h, 1); + filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1); } - filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, h, 0); - filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h, 0); - filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, h, 0); + filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, a, b, h, 0); + filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0); + filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, a, b, h, 0); } if(chroma){ if(chroma444){ if(left_type){ - filter_mb_edgev( &img_cb[4*0], linesize, bS4, qpc0, h, 1); - filter_mb_edgev( &img_cr[4*0], linesize, bS4, qpc0, h, 1); + filter_mb_edgev( &img_cb[4*0], linesize, bS4, qpc0, a, b, h, 1); + filter_mb_edgev( &img_cr[4*0], linesize, bS4, qpc0, a, b, h, 1); } if( IS_8x8DCT(mb_type) ) { - filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h, 0); - filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h, 0); + filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, a, b, h, 0); if(top_type){ - filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h,1 ); - filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h,1 ); + filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 ); + filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 ); } - filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h, 0); - filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h, 0); + filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0); } else { - filter_mb_edgev( &img_cb[4*1], linesize, bS3, qpc, h, 0); - filter_mb_edgev( &img_cr[4*1], linesize, bS3, qpc, h, 0); - filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h, 0); - filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h, 0); - filter_mb_edgev( &img_cb[4*3], linesize, bS3, qpc, h, 0); - filter_mb_edgev( &img_cr[4*3], linesize, bS3, qpc, h, 0); + filter_mb_edgev( &img_cb[4*1], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgev( &img_cr[4*1], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgev( &img_cb[4*3], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgev( &img_cr[4*3], linesize, bS3, qpc, a, b, h, 0); if(top_type){ - filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h, 1); - filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h, 1); + filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1); + filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1); } - filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, h, 0); - filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, h, 0); - filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h, 0); - filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h, 0); - filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, h, 0); - filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, h, 0); + filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, a, b, h, 0); + filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, a, b, h, 0); } }else{ if(left_type){ - filter_mb_edgecv( &img_cb[2*0], uvlinesize, bS4, qpc0, h, 1); - filter_mb_edgecv( &img_cr[2*0], uvlinesize, bS4, qpc0, h, 1); + filter_mb_edgecv( &img_cb[2*0], uvlinesize, bS4, qpc0, a, b, h, 1); + filter_mb_edgecv( &img_cr[2*0], uvlinesize, bS4, qpc0, a, b, h, 1); } - filter_mb_edgecv( &img_cb[2*2], uvlinesize, bS3, qpc, h, 0); - filter_mb_edgecv( &img_cr[2*2], uvlinesize, bS3, qpc, h, 0); + filter_mb_edgecv( &img_cb[2*2], uvlinesize, bS3, qpc, a, b, h, 0); + filter_mb_edgecv( &img_cr[2*2], uvlinesize, bS3, qpc, a, b, h, 0); if(top_type){ - filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h, 1); - filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h, 1); + filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1); + filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1); } - filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, h, 0); - filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, h, 0); + filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); + filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); } } return; @@ -339,14 +337,14 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, #define FILTER(hv,dir,edge,intra)\ if(AV_RN64A(bS[dir][edge])) { \ - filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qp : qp##dir, h, intra );\ + filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qp : qp##dir, a, b, h, intra );\ if(chroma){\ if(chroma444){\ - filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h, intra );\ - filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, h, intra );\ + filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\ + filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\ } else if(!(edge&1)) {\ - filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h, intra );\ - filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, h, intra );\ + filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\ + filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\ }\ }\ } @@ -403,7 +401,7 @@ static int check_mv(H264Context *h, long b_idx, long bn_idx, int mvy_limit){ return v; } -static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int mb_xy, int mb_type, int mvy_limit, int first_vertical_edge_done, int chroma, int chroma444, int dir) { +static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int mb_xy, int mb_type, int mvy_limit, int first_vertical_edge_done, int a, int b, int chroma, int chroma444, int dir) { MpegEncContext * const s = &h->s; int edge; int chroma_qp_avg[2]; @@ -457,16 +455,16 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u qp = (s->current_picture.f.qscale_table[mb_xy] + s->current_picture.f.qscale_table[mbn_xy] + 1) >> 1; tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize); { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } - filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, h, 0 ); + filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, a, b, h, 0 ); chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1; chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1; if (chroma) { if (chroma444) { - filter_mb_edgeh (&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], h, 0); - filter_mb_edgeh (&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], h, 0); + filter_mb_edgeh (&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], a, b, h, 0); + filter_mb_edgeh (&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], a, b, h, 0); } else { - filter_mb_edgech(&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], h, 0); - filter_mb_edgech(&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], h, 0); + filter_mb_edgech(&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], a, b, h, 0); + filter_mb_edgech(&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], a, b, h, 0); } } } @@ -526,25 +524,25 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1; chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1; if( dir == 0 ) { - filter_mb_edgev( &img_y[0], linesize, bS, qp, h, 1 ); + filter_mb_edgev( &img_y[0], linesize, bS, qp, a, b, h, 1 ); if (chroma) { if (chroma444) { - filter_mb_edgev ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h, 1); - filter_mb_edgev ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h, 1); + filter_mb_edgev ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1); + filter_mb_edgev ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1); } else { - filter_mb_edgecv( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h, 1); - filter_mb_edgecv( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h, 1); + filter_mb_edgecv( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1); + filter_mb_edgecv( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1); } } } else { - filter_mb_edgeh( &img_y[0], linesize, bS, qp, h, 1 ); + filter_mb_edgeh( &img_y[0], linesize, bS, qp, a, b, h, 1 ); if (chroma) { if (chroma444) { - filter_mb_edgeh ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h, 1); - filter_mb_edgeh ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h, 1); + filter_mb_edgeh ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1); + filter_mb_edgeh ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1); } else { - filter_mb_edgech( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], h, 1); - filter_mb_edgech( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], h, 1); + filter_mb_edgech( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1); + filter_mb_edgech( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1); } } } @@ -608,25 +606,25 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize); //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } if( dir == 0 ) { - filter_mb_edgev( &img_y[4*edge << h->pixel_shift], linesize, bS, qp, h, 0 ); + filter_mb_edgev( &img_y[4*edge << h->pixel_shift], linesize, bS, qp, a, b, h, 0 ); if (chroma) { if (chroma444) { - filter_mb_edgev ( &img_cb[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h, 0); - filter_mb_edgev ( &img_cr[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h, 0); + filter_mb_edgev ( &img_cb[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); + filter_mb_edgev ( &img_cr[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); } else if( (edge&1) == 0 ) { - filter_mb_edgecv( &img_cb[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h, 0); - filter_mb_edgecv( &img_cr[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h, 0); + filter_mb_edgecv( &img_cb[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); + filter_mb_edgecv( &img_cr[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); } } } else { - filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, h, 0 ); + filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0 ); if (chroma) { if (chroma444) { - filter_mb_edgeh ( &img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], h, 0); - filter_mb_edgeh ( &img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], h, 0); + filter_mb_edgeh ( &img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); + filter_mb_edgeh ( &img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); } else if( (edge&1) == 0 ) { - filter_mb_edgech( &img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], h, 0); - filter_mb_edgech( &img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], h, 0); + filter_mb_edgech( &img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); + filter_mb_edgech( &img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); } } } @@ -641,6 +639,9 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint int first_vertical_edge_done = 0; av_unused int dir; int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)); + int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); + int a = h->slice_alpha_c0_offset - qp_bd_offset; + int b = h->slice_beta_offset - qp_bd_offset; if (FRAME_MBAFF // and current and left pair do not have the same interlaced type @@ -707,35 +708,35 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize); { int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } if(MB_FIELD){ - filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], 1 ); - filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], 1 ); + filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], a, b, 1 ); + filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], a, b, 1 ); if (chroma){ if (CHROMA444) { - filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], 1 ); - filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], 1 ); - filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], 1 ); - filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], 1 ); + filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 ); + filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 ); + filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 ); + filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 ); }else{ - filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], 1 ); - filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], 1 ); - filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], 1 ); - filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], 1 ); + filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 ); + filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 ); + filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 ); + filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 ); } } }else{ - filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], 1 ); - filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], 1 ); + filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], a, b, 1 ); + filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], a, b, 1 ); if (chroma){ if (CHROMA444) { - filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], 1 ); - filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], 1 ); - filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], 1 ); - filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], 1 ); + filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 ); + filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 ); + filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 ); + filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 ); }else{ - filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], 1 ); - filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], 1 ); - filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], 1 ); - filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], 1 ); + filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 ); + filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 ); + filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 ); + filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 ); } } } @@ -743,9 +744,9 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint #if CONFIG_SMALL for( dir = 0; dir < 2; dir++ ) - filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, chroma, CHROMA444, dir); + filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, a, b, chroma, CHROMA444, dir); #else - filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, chroma, CHROMA444, 0); - filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, chroma, CHROMA444, 1); + filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, CHROMA444, 0); + filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, CHROMA444, 1); #endif } From 1fef92fd7390cda7e5a2655c1c7cfc0851c9a66e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 11 Jul 2011 20:53:15 +0100 Subject: [PATCH 457/780] build: remove unnecessary dependency on libs from 'all' target The libs are added to the all target elsewhere, no need to do it again here. Signed-off-by: Mans Rullgard --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 87451e04d0..a27fe28934 100644 --- a/Makefile +++ b/Makefile @@ -86,7 +86,7 @@ include $(SRC_PATH)/common.mak FF_EXTRALIBS := $(FFEXTRALIBS) FF_DEP_LIBS := $(DEP_LIBS) -all: $(FF_DEP_LIBS) $(PROGS) +all: $(PROGS) $(TOOLS): %$(EXESUF): %.o $(LD) $(LDFLAGS) -o $@ $< $(ELIBS) From 7ce914fb5a4ae974985368ce98db4031c034d513 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 8 Jul 2011 15:01:05 +0100 Subject: [PATCH 458/780] lls: use av_lfg instead of rand() in test program Signed-off-by: Mans Rullgard --- libavutil/lls.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavutil/lls.c b/libavutil/lls.c index eba7375854..b29fc968da 100644 --- a/libavutil/lls.c +++ b/libavutil/lls.c @@ -118,24 +118,27 @@ double av_evaluate_lls(LLSModel *m, double *param, int order) #ifdef TEST -#include #include +#include +#include "lfg.h" int main(void) { LLSModel m; int i, order; + AVLFG lfg; + av_lfg_init(&lfg, 1); av_init_lls(&m, 3); for (i = 0; i < 100; i++) { double var[4]; double eval; - var[0] = (rand() / (double) RAND_MAX - 0.5) * 2; - var[1] = var[0] + rand() / (double) RAND_MAX - 0.5; - var[2] = var[1] + rand() / (double) RAND_MAX - 0.5; - var[3] = var[2] + rand() / (double) RAND_MAX - 0.5; + var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2; + var[1] = var[0] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5; + var[2] = var[1] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5; + var[3] = var[2] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5; av_update_lls(&m, var, 0.99); av_solve_lls(&m, 0.001, 0); for (order = 0; order < 3; order++) { From 5ccbf80963c1cc54aed97b1c81b1657ab91baf6a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 9 Jul 2011 20:15:29 +0200 Subject: [PATCH 459/780] doc: Remove outdated comments about gcc 2.95 and gcc 3.3 support. --- doc/developer.texi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index cae4f3df5e..597ce957d1 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -60,10 +60,8 @@ These features are supported by all compilers we care about, so we will not accept patches to remove their use unless they absolutely do not impair clarity and performance. -All code must compile with GCC 2.95 and GCC 3.3. Currently, Libav also -compiles with several other compilers, such as the Compaq ccc compiler -or Sun Studio 9, and we would like to keep it that way unless it would -be exceedingly involved. To ensure compatibility, please do not use any +All code must compile with recent versions of GCC and a number of other +currently supported compilers. To ensure compatibility, please do not use additional C99 features or GCC extensions. Especially watch out for: @itemize @bullet @item From b5bbc84fe2ae07d98764361d93d40ee2781467ab Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Mon, 11 Jul 2011 14:46:37 -0700 Subject: [PATCH 460/780] H.264: add filter_mb_fast support for >8-bit decoding Much faster high bit depth deblocking. --- libavcodec/h264_loopfilter.c | 104 +++++++++++++++++++---------------- libavcodec/x86/h264dsp_mmx.c | 3 +- 2 files changed, 59 insertions(+), 48 deletions(-) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index f94e13aef0..377968fcd2 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -207,56 +207,48 @@ static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, const i } } -void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { +static void av_always_inline h264_filter_mb_fast_internal( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, + unsigned int linesize, unsigned int uvlinesize, int pixel_shift) { MpegEncContext * const s = &h->s; - int mb_xy; - int mb_type, left_type, top_type; - int qp, qp0, qp1, qpc, qpc0, qpc1; int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)); int chroma444 = CHROMA444; - int qp_bd_offset, a, b; - mb_xy = h->mb_xy; + int mb_xy = h->mb_xy; + int left_type= h->left_type[LTOP]; + int top_type= h->top_type; - if(!h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) { - ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize); - return; - } - assert(!FRAME_MBAFF); - left_type= h->left_type[LTOP]; - top_type= h->top_type; + int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); + int a = h->slice_alpha_c0_offset - qp_bd_offset; + int b = h->slice_beta_offset - qp_bd_offset; - mb_type = s->current_picture.f.mb_type[mb_xy]; - qp = s->current_picture.f.qscale_table[mb_xy]; - qp0 = s->current_picture.f.qscale_table[mb_xy - 1]; - qp1 = s->current_picture.f.qscale_table[h->top_mb_xy]; - qpc = get_chroma_qp( h, 0, qp ); - qpc0 = get_chroma_qp( h, 0, qp0 ); - qpc1 = get_chroma_qp( h, 0, qp1 ); + int mb_type = s->current_picture.f.mb_type[mb_xy]; + int qp = s->current_picture.f.qscale_table[mb_xy]; + int qp0 = s->current_picture.f.qscale_table[mb_xy - 1]; + int qp1 = s->current_picture.f.qscale_table[h->top_mb_xy]; + int qpc = get_chroma_qp( h, 0, qp ); + int qpc0 = get_chroma_qp( h, 0, qp0 ); + int qpc1 = get_chroma_qp( h, 0, qp1 ); qp0 = (qp + qp0 + 1) >> 1; qp1 = (qp + qp1 + 1) >> 1; qpc0 = (qpc + qpc0 + 1) >> 1; qpc1 = (qpc + qpc1 + 1) >> 1; - qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); - a = h->slice_alpha_c0_offset - qp_bd_offset; - b = h->slice_beta_offset - qp_bd_offset; if( IS_INTRA(mb_type) ) { static const int16_t bS4[4] = {4,4,4,4}; static const int16_t bS3[4] = {3,3,3,3}; const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4; if(left_type) - filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, a, b, h, 1); + filter_mb_edgev( &img_y[4*0<h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) { + ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize); + return; + } + +#if CONFIG_SMALL + h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, h->pixel_shift); +#else + if(h->pixel_shift){ + h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 1); + }else{ + h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 0); + } +#endif +} + static int check_mv(H264Context *h, long b_idx, long bn_idx, int mvy_limit){ int v; diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c index 1042552948..35ec267b42 100644 --- a/libavcodec/x86/h264dsp_mmx.c +++ b/libavcodec/x86/h264dsp_mmx.c @@ -354,10 +354,11 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) { int mm_flags = av_get_cpu_flags(); - if (bit_depth == 8) { if (mm_flags & AV_CPU_FLAG_MMX2) { c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2; } + + if (bit_depth == 8) { #if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { c->h264_idct_dc_add = From b047941d7da470ba0dcedb1fd0aa828075265ffc Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 9 Jul 2011 17:43:53 +0200 Subject: [PATCH 461/780] changelog: misc typo and wording fixes --- Changelog | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Changelog b/Changelog index b785197083..943d710836 100644 --- a/Changelog +++ b/Changelog @@ -6,23 +6,23 @@ version 0.7: - E-AC-3 audio encoder - ac3enc: add channel coupling support -- floating-point sample format support to the ac3, eac3, dca, aac, and vorbis decoders. -- H264/MPEG frame-level multi-threading -- All av_metadata_* functions renamed to av_dict_* and moved to libavutil +- floating-point sample format support for (E-)AC-3, DCA, AAC, Vorbis decoders +- H.264/MPEG frame-level multithreading +- av_metadata_* functions renamed to av_dict_* and moved to libavutil - 4:4:4 H.264 decoding support - 10-bit H.264 optimizations for x86 -- Bump libswscale for recently reported ABI break +- bump libswscale for recently reported ABI break version 0.7_beta2: -- VP8 frame-multithreading +- VP8 frame-level multithreading - NEON optimizations for VP8 -- Lots of deprecated API cruft removed -- fft and imdct optimizations for AVX (Sandy Bridge) processors +- removed a lot of deprecated API cruft +- FFT and IMDCT optimizations for AVX (Sandy Bridge) processors - DPX image encoder - SMPTE 302M AES3 audio decoder -- Remove support for quitting ffmpeg with 'q', ctrl+c should be used. +- ffmpeg no longer quits after the 'q' key is pressed; use 'ctrl+c' instead - 9bit and 10bit per sample support in the H.264 decoder @@ -75,10 +75,10 @@ version 0.7_beta1: - demuxer for receiving raw rtp:// URLs without an SDP description - single stream LATM/LOAS decoder - setpts filter added -- Win64 support for optimized asm functions +- Win64 support for optimized x86 assembly functions - MJPEG/AVI1 to JPEG/JFIF bitstream filter - ASS subtitle encoder and decoder -- IEC 61937 encapsulation for E-AC3, TrueHD, DTS-HD (for HDMI passthrough) +- IEC 61937 encapsulation for E-AC-3, TrueHD, DTS-HD (for HDMI passthrough) - overlay filter added - rename aspect filter to setdar, and pixelaspect to setsar - IEC 61937 demuxer From 4cc3467e7abfea7e8d03b6af511f7719038a5a98 Mon Sep 17 00:00:00 2001 From: Chris Evans Date: Wed, 29 Jun 2011 15:44:40 -0700 Subject: [PATCH 462/780] oggdec: prevent heap corruption. Specifically crafted samples can reinit ogg->streams[] while reading samples, and thus we should not cache old pointers since these may no longer be valid. Signed-off-by: Ronald S. Bultje --- libavformat/oggdec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index e33de7d978..3d03a5f974 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -592,15 +592,15 @@ static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos_arg, int64_t pos_limit) { struct ogg *ogg = s->priv_data; - struct ogg_stream *os = ogg->streams + stream_index; AVIOContext *bc = s->pb; int64_t pts = AV_NOPTS_VALUE; - int i; + int i = -1; avio_seek(bc, *pos_arg, SEEK_SET); ogg_reset(ogg); while (avio_tell(bc) < pos_limit && !ogg_packet(s, &i, NULL, NULL, pos_arg)) { if (i == stream_index) { + struct ogg_stream *os = ogg->streams + stream_index; pts = ogg_calc_pts(s, i, NULL); if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY)) pts = AV_NOPTS_VALUE; @@ -626,6 +626,7 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index, os->keyframe_seek = 1; ret = av_seek_frame_binary(s, stream_index, timestamp, flags); + os = ogg->streams + stream_index; if (ret < 0) os->keyframe_seek = 0; return ret; From 8ced6f52ddd38491ca964557115b105c95851705 Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Mon, 11 Jul 2011 20:33:45 +0200 Subject: [PATCH 463/780] RELEASE: We are git after 0.8 release --- RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE b/RELEASE index 5664e303b5..648fc13ac7 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -git +0.8.git From 93ade976c8e0af5cfe4a0d2f5a32875efe73e2d9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 24 Jun 2011 21:34:42 +0200 Subject: [PATCH 464/780] matroskaenc: make SSA default subtitle codec. It's a better format and we have an encoder for it, so it doesn't fail like CODEC_ID_TEXT. --- libavformat/matroskaenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 169e8e44da..d0e3c171eb 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1205,7 +1205,7 @@ AVOutputFormat ff_matroska_muxer = { mkv_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, .codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0}, - .subtitle_codec = CODEC_ID_TEXT, + .subtitle_codec = CODEC_ID_SSA, }; #endif From 1cede1d0112b5b26e6d023846729662b7cf1853f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 25 Jun 2011 07:43:49 +0200 Subject: [PATCH 465/780] ffmpeg: factor common code from new_a/v/s/d_stream to new_output_stream() --- ffmpeg.c | 80 ++++++++++++++++++++------------------------------------ 1 file changed, 28 insertions(+), 52 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index fe8b3446b8..91cfb80b14 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -640,10 +640,16 @@ static void choose_pixel_fmt(AVStream *st, AVCodec *codec) } } -static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx) +static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx, AVCodec *codec) { - int idx = oc->nb_streams - 1; OutputStream *ost; + AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); + int idx = oc->nb_streams - 1; + + if (!st) { + av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n"); + ffmpeg_exit(1); + } output_streams_for_file[file_idx] = grow_array(output_streams_for_file[file_idx], @@ -658,6 +664,10 @@ static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx) } ost->file_index = file_idx; ost->index = idx; + ost->st = st; + ost->enc = codec; + + avcodec_get_context_defaults3(st->codec, codec); ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); return ost; @@ -673,27 +683,20 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename) if (err < 0) return err; /* copy stream format */ - s->nb_streams = 0; - s->streams = av_mallocz(sizeof(AVStream *) * ic->nb_streams); for(i=0;inb_streams;i++) { AVStream *st; + OutputStream *ost; AVCodec *codec; - s->nb_streams++; + codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id); + ost = new_output_stream(s, nb_output_files, codec); + st = ost->st; // FIXME: a more elegant solution is needed - st = av_mallocz(sizeof(AVStream)); memcpy(st, ic->streams[i], sizeof(AVStream)); st->info = NULL; - st->codec = avcodec_alloc_context(); - if (!st->codec) { - print_error(filename, AVERROR(ENOMEM)); - ffmpeg_exit(1); - } avcodec_copy_context(st->codec, ic->streams[i]->codec); - s->streams[i] = st; - codec = avcodec_find_encoder(st->codec->codec_id); if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if (audio_stream_copy) { st->stream_copy = 1; @@ -708,8 +711,6 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename) if(st->codec->flags & CODEC_FLAG_BITEXACT) nopts = 1; - - new_output_stream(s, nb_output_files); } if (!nopts) @@ -2003,7 +2004,6 @@ static int transcode(AVFormatContext **output_files, for(i=0;inb_streams;i++,n++) { int found; ost = ost_table[n] = output_streams_for_file[k][i]; - ost->st = os->streams[i]; if (nb_stream_maps > 0) { ost->source_index = input_files[stream_maps[n].file_index].ist_index + stream_maps[n].stream_index; @@ -3428,24 +3428,20 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) enum CodecID codec_id = CODEC_ID_NONE; AVCodec *codec= NULL; - st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); - if (!st) { - fprintf(stderr, "Could not alloc stream\n"); - ffmpeg_exit(1); - } - ost = new_output_stream(oc, file_idx); - if(!video_stream_copy){ if (video_codec_name) { codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1, avcodec_opts[AVMEDIA_TYPE_VIDEO]->strict_std_compliance); codec = avcodec_find_encoder_by_name(video_codec_name); - ost->enc = codec; } else { codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO); codec = avcodec_find_encoder(codec_id); } + } + ost = new_output_stream(oc, file_idx, codec); + st = ost->st; + if (!video_stream_copy) { ost->frame_aspect_ratio = frame_aspect_ratio; frame_aspect_ratio = 0; #if CONFIG_AVFILTER @@ -3454,7 +3450,6 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) #endif } - avcodec_get_context_defaults3(st->codec, codec); ost->bitstream_filters = video_bitstream_filters; video_bitstream_filters= NULL; @@ -3567,26 +3562,18 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) AVCodecContext *audio_enc; enum CodecID codec_id = CODEC_ID_NONE; - st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); - if (!st) { - fprintf(stderr, "Could not alloc stream\n"); - ffmpeg_exit(1); - } - ost = new_output_stream(oc, file_idx); - if(!audio_stream_copy){ if (audio_codec_name) { codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1, avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance); codec = avcodec_find_encoder_by_name(audio_codec_name); - ost->enc = codec; } else { codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO); codec = avcodec_find_encoder(codec_id); } } - - avcodec_get_context_defaults3(st->codec, codec); + ost = new_output_stream(oc, file_idx, codec); + st = ost->st; ost->bitstream_filters = audio_bitstream_filters; audio_bitstream_filters= NULL; @@ -3635,21 +3622,16 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) static void new_data_stream(AVFormatContext *oc, int file_idx) { AVStream *st; - AVCodec *codec=NULL; + OutputStream *ost; AVCodecContext *data_enc; - st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); - if (!st) { - fprintf(stderr, "Could not alloc stream\n"); - ffmpeg_exit(1); - } - new_output_stream(oc, file_idx); + ost = new_output_stream(oc, file_idx, NULL); + st = ost->st; data_enc = st->codec; if (!data_stream_copy) { fprintf(stderr, "Data stream encoding not supported yet (only streamcopy)\n"); ffmpeg_exit(1); } - avcodec_get_context_defaults3(st->codec, codec); data_enc->codec_type = AVMEDIA_TYPE_DATA; @@ -3677,25 +3659,19 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) AVCodecContext *subtitle_enc; enum CodecID codec_id = CODEC_ID_NONE; - st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); - if (!st) { - fprintf(stderr, "Could not alloc stream\n"); - ffmpeg_exit(1); - } - ost = new_output_stream(oc, file_idx); - subtitle_enc = st->codec; if(!subtitle_stream_copy){ if (subtitle_codec_name) { codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); codec = avcodec_find_encoder_by_name(subtitle_codec_name); - ost->enc = codec; } else { codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE); codec = avcodec_find_encoder(codec_id); } } - avcodec_get_context_defaults3(st->codec, codec); + ost = new_output_stream(oc, file_idx, codec); + st = ost->st; + subtitle_enc = st->codec; ost->bitstream_filters = subtitle_bitstream_filters; subtitle_bitstream_filters= NULL; From 87c739a395ff2951058d719687cd06b0e89420bd Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 15 Jun 2011 08:00:03 +0200 Subject: [PATCH 466/780] ffmpeg: don't abuse a global for passing channel layout from input to output It's broken with multiple files or audio streams. --- ffmpeg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 91cfb80b14..8035848e07 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -161,7 +161,6 @@ static char *vfilters = NULL; static int intra_only = 0; static int audio_sample_rate = 0; -static int64_t channel_layout = 0; #define QSCALE_NONE -99999 static float audio_qscale = QSCALE_NONE; static int audio_disable = 0; @@ -2183,6 +2182,7 @@ static int transcode(AVFormatContext **output_files, codec->time_base = (AVRational){1, codec->sample_rate}; if (!codec->channels) codec->channels = icodec->channels; + codec->channel_layout = icodec->channel_layout; if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) codec->channel_layout = 0; ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; @@ -3306,7 +3306,6 @@ static int opt_input_file(const char *opt, const char *filename) case AVMEDIA_TYPE_AUDIO: ist->dec = avcodec_find_decoder_by_name(audio_codec_name); set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, ist->dec); - channel_layout = dec->channel_layout; audio_sample_fmt = dec->sample_fmt; if(audio_disable) st->discard= AVDISCARD_ALL; @@ -3605,7 +3604,6 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) audio_enc->sample_fmt = audio_sample_fmt; if (audio_sample_rate) audio_enc->sample_rate = audio_sample_rate; - audio_enc->channel_layout = channel_layout; choose_sample_fmt(st, codec); } if (audio_language) { From 6fbf2485ad5b1d52f55b229acbf2a7de2b752283 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 15 Jun 2011 08:00:03 +0200 Subject: [PATCH 467/780] ffmpeg: don't abuse a global for passing sample format from input to output It's broken with multiple files or audio streams. --- ffmpeg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 8035848e07..b140b0d395 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2180,6 +2180,9 @@ static int transcode(AVFormatContext **output_files, } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; + if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) + codec->sample_fmt = icodec->sample_fmt; + choose_sample_fmt(ost->st, ost->enc); if (!codec->channels) codec->channels = icodec->channels; codec->channel_layout = icodec->channel_layout; @@ -3306,7 +3309,6 @@ static int opt_input_file(const char *opt, const char *filename) case AVMEDIA_TYPE_AUDIO: ist->dec = avcodec_find_decoder_by_name(audio_codec_name); set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, ist->dec); - audio_sample_fmt = dec->sample_fmt; if(audio_disable) st->discard= AVDISCARD_ALL; break; @@ -3367,6 +3369,7 @@ static int opt_input_file(const char *opt, const char *filename) frame_width = 0; audio_sample_rate = 0; audio_channels = 0; + audio_sample_fmt = AV_SAMPLE_FMT_NONE; av_freep(&video_codec_name); av_freep(&audio_codec_name); @@ -3601,10 +3604,10 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) } if (audio_channels) audio_enc->channels = audio_channels; - audio_enc->sample_fmt = audio_sample_fmt; + if (audio_sample_fmt != AV_SAMPLE_FMT_NONE) + audio_enc->sample_fmt = audio_sample_fmt; if (audio_sample_rate) audio_enc->sample_rate = audio_sample_rate; - choose_sample_fmt(st, codec); } if (audio_language) { av_dict_set(&st->metadata, "language", audio_language, 0); @@ -3875,6 +3878,7 @@ static void opt_output_file(const char *filename) frame_height = 0; audio_sample_rate = 0; audio_channels = 0; + audio_sample_fmt = AV_SAMPLE_FMT_NONE; av_freep(&forced_key_frames); uninit_opts(); From b12c2592525c3d8e12265a3d923a945d6f699a5b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 7 Jul 2011 08:54:07 +0200 Subject: [PATCH 468/780] ffmpeg: merge input_files_ts_scale into InputStream. --- ffmpeg.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index b140b0d395..1af1d0bdd1 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -107,8 +107,8 @@ static const OptionDef options[]; #define FFM_PACKET_SIZE 4096 //XXX a duplicate of the line in ffm.h static const char *last_asked_format = NULL; -static double *input_files_ts_scale[MAX_FILES] = {NULL}; -static int nb_input_files_ts_scale[MAX_FILES] = {0}; +static double *ts_scale; +static int nb_ts_scale; static AVFormatContext *output_files[MAX_FILES]; static AVDictionary *output_opts[MAX_FILES]; @@ -312,6 +312,7 @@ typedef struct InputStream { is not defined */ int64_t pts; /* current pts */ PtsCorrectionContext pts_ctx; + double ts_scale; int is_start; /* is 1 at the start and after a discontinuity */ int showed_multi_packet_warning; int is_past_recording_time; @@ -461,7 +462,6 @@ static int ffmpeg_exit(int ret) } for(i=0;ifile_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); - if (pkt.stream_index < nb_input_files_ts_scale[file_index] - && input_files_ts_scale[file_index][pkt.stream_index]){ + if (ist->ts_scale) { if(pkt.pts != AV_NOPTS_VALUE) - pkt.pts *= input_files_ts_scale[file_index][pkt.stream_index]; + pkt.pts *= ist->ts_scale; if(pkt.dts != AV_NOPTS_VALUE) - pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index]; + pkt.dts *= ist->ts_scale; } // fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files[ist->file_index].ts_offset, ist->st->codec->codec_type); @@ -3091,8 +3090,8 @@ static int opt_input_ts_scale(const char *opt, const char *arg) if(stream >= MAX_STREAMS) ffmpeg_exit(1); - input_files_ts_scale[nb_input_files] = grow_array(input_files_ts_scale[nb_input_files], sizeof(*input_files_ts_scale[nb_input_files]), &nb_input_files_ts_scale[nb_input_files], stream + 1); - input_files_ts_scale[nb_input_files][stream]= scale; + ts_scale = grow_array(ts_scale, sizeof(*ts_scale), &nb_ts_scale, stream + 1); + ts_scale[stream] = scale; return 0; } @@ -3305,6 +3304,9 @@ static int opt_input_file(const char *opt, const char *filename) ist->file_index = nb_input_files; ist->discard = 1; + if (i < nb_ts_scale) + ist->ts_scale = ts_scale[i]; + switch (dec->codec_type) { case AVMEDIA_TYPE_AUDIO: ist->dec = avcodec_find_decoder_by_name(audio_codec_name); @@ -3370,6 +3372,8 @@ static int opt_input_file(const char *opt, const char *filename) audio_sample_rate = 0; audio_channels = 0; audio_sample_fmt = AV_SAMPLE_FMT_NONE; + av_freep(&ts_scale); + nb_ts_scale = 0; av_freep(&video_codec_name); av_freep(&audio_codec_name); From 5f847bf61dca1fd1a2f65a2f56c9a99d1cb716ab Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 7 Jul 2011 11:25:03 +0200 Subject: [PATCH 469/780] lavf: deprecate AVFormatContext.timestamp It's replaced by 'creation_time' metadata tag. --- ffmpeg.c | 15 ++++++++------- libavformat/avformat.h | 7 ++++++- libavformat/dvenc.c | 14 ++++++++++++-- libavformat/gxfenc.c | 18 ++++++++++++++++-- libavformat/movenc.c | 14 +++++++++++++- libavformat/mxfenc.c | 14 +++++++++++++- libavformat/version.h | 3 +++ 7 files changed, 71 insertions(+), 14 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 1af1d0bdd1..a0f6abc87d 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -183,7 +183,6 @@ static float mux_max_delay= 0.7; static int64_t recording_time = INT64_MAX; static int64_t start_time = 0; -static int64_t recording_timestamp = 0; static int64_t input_ts_offset = 0; static int file_overwrite = 0; static AVDictionary *metadata; @@ -712,9 +711,6 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename) nopts = 1; } - if (!nopts) - s->timestamp = av_gettime(); - av_close_input_file(ic); return 0; } @@ -3109,7 +3105,14 @@ static int opt_start_time(const char *opt, const char *arg) static int opt_recording_timestamp(const char *opt, const char *arg) { - recording_timestamp = parse_time_or_die(opt, arg, 0) / 1000000; + char buf[128]; + int64_t recording_timestamp = parse_time_or_die(opt, arg, 0) / 1E6; + struct tm time = *gmtime((time_t*)&recording_timestamp); + strftime(buf, sizeof(buf), "creation_time=%FT%T%z", &time); + opt_metadata("metadata", buf); + + av_log(NULL, AV_LOG_WARNING, "%s is deprecated, set the 'creation_time' metadata " + "tag instead.\n", opt); return 0; } @@ -3823,8 +3826,6 @@ static void opt_output_file(const char *filename) if (use_subtitle) new_subtitle_stream(oc, nb_output_files); if (use_data) new_data_stream(oc, nb_output_files); - oc->timestamp = recording_timestamp; - av_dict_copy(&oc->metadata, metadata, 0); av_dict_free(&metadata); } diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6e861de262..38bb86592e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -674,7 +674,12 @@ typedef struct AVFormatContext { AVStream **streams; char filename[1024]; /**< input or output filename */ /* stream info */ - int64_t timestamp; +#if FF_API_TIMESTAMP + /** + * @deprecated use 'creation_time' metadata tag instead + */ + attribute_deprecated int64_t timestamp; +#endif int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ /* private data for pts handling (do not modify directly). */ diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 504e3ee26f..1e59bd9cc7 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -43,7 +43,7 @@ struct DVMuxContext { AVStream *ast[2]; /* stereo audio streams */ AVFifoBuffer *audio_data[2]; /* FIFO for storing excessive amounts of PCM */ int frames; /* current frame number */ - time_t start_time; /* recording start time */ + int64_t start_time; /* recording start time */ int has_audio; /* frame under contruction has audio */ int has_video; /* frame under contruction has video */ uint8_t frame_buf[DV_MAX_FRAME_SIZE]; /* frame under contruction */ @@ -290,6 +290,7 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) { DVMuxContext *c = s->priv_data; AVStream *vst = NULL; + AVDictionaryEntry *t; int i; /* we support at most 1 video and 2 audio streams */ @@ -337,7 +338,16 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) c->frames = 0; c->has_audio = 0; c->has_video = 0; - c->start_time = (time_t)s->timestamp; +#if FF_API_TIMESTAMP + if (s->timestamp) + c->start_time = s->timestamp; + else +#endif + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { + struct tm time = {0}; + strptime(t->value, "%Y - %m - %dT%T", &time); + c->start_time = mktime(&time); + } for (i=0; i < c->n_ast; i++) { if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc(100*AVCODEC_MAX_AUDIO_FRAME_SIZE))) { diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 5a3ff39ab2..2d4136ab86 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -394,6 +394,20 @@ static int gxf_write_umf_material_description(AVFormatContext *s) GXFContext *gxf = s->priv_data; AVIOContext *pb = s->pb; int timecode_base = gxf->time_base.den == 60000 ? 60 : 50; + int64_t timestamp = 0; + AVDictionaryEntry *t; + +#if FF_API_TIMESTAMP + if (s->timestamp) + timestamp = s->timestamp; + else +#endif + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { + struct tm time = {0}; + strptime(t->value, "%Y - %m - %dT%T", &time); + timestamp = mktime(&time); + } + // XXX drop frame uint32_t timecode = @@ -409,8 +423,8 @@ static int gxf_write_umf_material_description(AVFormatContext *s) avio_wl32(pb, gxf->nb_fields); /* mark out */ avio_wl32(pb, 0); /* timecode mark in */ avio_wl32(pb, timecode); /* timecode mark out */ - avio_wl64(pb, s->timestamp); /* modification time */ - avio_wl64(pb, s->timestamp); /* creation time */ + avio_wl64(pb, timestamp); /* modification time */ + avio_wl64(pb, timestamp); /* creation time */ avio_wl16(pb, 0); /* reserved */ avio_wl16(pb, 0); /* reserved */ avio_wl16(pb, gxf->audio_tracks); diff --git a/libavformat/movenc.c b/libavformat/movenc.c index ae6f603e86..78e5db7444 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2129,6 +2129,7 @@ static int mov_write_header(AVFormatContext *s) { AVIOContext *pb = s->pb; MOVMuxContext *mov = s->priv_data; + AVDictionaryEntry *t; int i, hint_track = 0; if (!s->pb->seekable) { @@ -2259,7 +2260,18 @@ static int mov_write_header(AVFormatContext *s) } mov_write_mdat_tag(pb, mov); - mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based + +#if FF_API_TIMESTAMP + if (s->timestamp) + mov->time = s->timestamp; + else +#endif + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { + struct tm time = {0}; + strptime(t->value, "%Y - %m - %dT%T", &time); + mov->time = mktime(&time); + } + mov->time += 0x7C25B080; //1970 based -> 1904 based if (mov->chapter_track) mov_create_chapter_track(s, mov->chapter_track); diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 16fa0dadd1..d7cc5c1c67 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1407,6 +1407,8 @@ static int mxf_write_header(AVFormatContext *s) int i; uint8_t present[FF_ARRAY_ELEMS(mxf_essence_container_uls)] = {0}; const int *samples_per_frame = NULL; + AVDictionaryEntry *t; + int64_t timestamp = 0; if (!s->nb_streams) return -1; @@ -1512,8 +1514,18 @@ static int mxf_write_header(AVFormatContext *s) sc->order = AV_RB32(sc->track_essence_element_key+12); } +#if FF_API_TIMESTAMP if (s->timestamp) - mxf->timestamp = mxf_parse_timestamp(s->timestamp); + timestamp = s->timestamp; + else +#endif + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { + struct tm time = {0}; + strptime(t->value, "%Y - %m - %dT%T", &time); + timestamp = mktime(&time); + } + if (timestamp) + mxf->timestamp = mxf_parse_timestamp(timestamp); mxf->duration = -1; mxf->timecode_track = av_mallocz(sizeof(*mxf->timecode_track)); diff --git a/libavformat/version.h b/libavformat/version.h index 18331fc7d1..cae0339f62 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -83,5 +83,8 @@ #ifndef FF_API_LOOP_OUTPUT #define FF_API_LOOP_OUTPUT (LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_TIMESTAMP +#define FF_API_TIMESTAMP (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif /* AVFORMAT_VERSION_H */ From afa218f372ad2616e6609e2c3b41ef458261a431 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 12 Jul 2011 16:09:10 +0200 Subject: [PATCH 470/780] Add another MP3 CAF codec tag. --- libavformat/caf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/caf.c b/libavformat/caf.c index d49cc0b9f3..1f3057dd63 100644 --- a/libavformat/caf.c +++ b/libavformat/caf.c @@ -45,6 +45,7 @@ const AVCodecTag ff_codec_caf_tags[] = { { CODEC_ID_MACE3, MKBETAG('M','A','C','3') }, { CODEC_ID_MACE6, MKBETAG('M','A','C','6') }, { CODEC_ID_MP3, MKBETAG('.','m','p','3') }, + { CODEC_ID_MP3, MKBETAG('m','s', 0 ,'U') }, { CODEC_ID_MP2, MKBETAG('.','m','p','2') }, { CODEC_ID_MP1, MKBETAG('.','m','p','1') }, { CODEC_ID_PCM_ALAW, MKBETAG('a','l','a','w') }, From e59d6b4d7255d6d3dc89580f534e18af1433fe25 Mon Sep 17 00:00:00 2001 From: Oskar Arvidsson Date: Tue, 12 Jul 2011 10:52:19 +0200 Subject: [PATCH 471/780] pix_fmt: Fix number of bits per component in yuv444p9be Signed-off-by: Ronald S. Bultje --- libavutil/pixdesc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index efc7c7ea0e..c70a41347b 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -918,9 +918,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { .log2_chroma_w= 0, .log2_chroma_h= 0, .comp = { - {0,1,1,0,9}, /* Y */ - {1,1,1,0,9}, /* U */ - {2,1,1,0,9}, /* V */ + {0,1,1,0,8}, /* Y */ + {1,1,1,0,8}, /* U */ + {2,1,1,0,8}, /* V */ }, .flags = PIX_FMT_BE, }, From c90a2538a0bb4937cdecb852fadc3f98899624a9 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 12 Jul 2011 08:15:55 -0700 Subject: [PATCH 472/780] h264: move h264_mvpred.h include. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following compile error with darwin/gcc-4.2.1: In file included from libavcodec/error_resilience.c:33: libavcodec/h264.h: In function ‘decode_mb_skip’: libavcodec/h264.h:773: error: ‘always_inline’ function could not be inlined in call to ‘pred_pskip_motion’: the function body must appear before caller libavcodec/h264.h:1334: error: called from here --- libavcodec/h264.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index f5bdb667b9..9d46ab479a 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -770,7 +770,7 @@ static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){ return h->pps.chroma_qp_table[t][qscale]; } -static av_always_inline void pred_pskip_motion(H264Context * const h); +#include "h264_mvpred.h" //For pred_pskip_motion() static void fill_decode_neighbors(H264Context *h, int mb_type){ MpegEncContext * const s = &h->s; @@ -1341,6 +1341,4 @@ static void av_unused decode_mb_skip(H264Context *h){ h->prev_mb_skipped= 1; } -#include "h264_mvpred.h" //For pred_pskip_motion() - #endif /* AVCODEC_H264_H */ From 45ecc7a294d56e41dab621512f6f70fc2578340e Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 12 Jul 2011 17:35:20 +0200 Subject: [PATCH 473/780] Support adpcm_ima_wav and adpcm_ms in caf. --- libavformat/caf.c | 2 ++ libavformat/cafenc.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/caf.c b/libavformat/caf.c index 1f3057dd63..faed166dfe 100644 --- a/libavformat/caf.c +++ b/libavformat/caf.c @@ -39,6 +39,8 @@ const AVCodecTag ff_codec_caf_tags[] = { /*{ CODEC_ID_DVAUDIO, MKBETAG('v','d','v','a') },*/ /*{ CODEC_ID_DVAUDIO, MKBETAG('d','v','c','a') },*/ { CODEC_ID_ADPCM_IMA_QT, MKBETAG('i','m','a','4') }, + { CODEC_ID_ADPCM_IMA_WAV, MKBETAG('m','s', 0, 17 ) }, + { CODEC_ID_ADPCM_MS, MKBETAG('m','s', 0, 2 ) }, { CODEC_ID_AMR_NB, MKBETAG('s','a','m','r') }, { CODEC_ID_GSM, MKBETAG('a','g','s','m') }, { CODEC_ID_GSM_MS, MKBETAG('m','s', 0, '1') }, diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c index 7cb4777bc6..43f56624a7 100644 --- a/libavformat/cafenc.c +++ b/libavformat/cafenc.c @@ -47,7 +47,7 @@ static uint32_t codec_flags(enum CodecID codec_id) { } } -static uint32_t samples_per_packet(enum CodecID codec_id) { +static uint32_t samples_per_packet(enum CodecID codec_id, int channels) { switch (codec_id) { case CODEC_ID_PCM_S8: case CODEC_ID_PCM_S16LE: @@ -84,6 +84,10 @@ static uint32_t samples_per_packet(enum CodecID codec_id) { case CODEC_ID_ALAC: case CODEC_ID_QDM2: return 4096; + case CODEC_ID_ADPCM_IMA_WAV: + return (1024 - 4 * channels) * 8 / (4 * channels) + 1; + case CODEC_ID_ADPCM_MS: + return (1024 - 7 * channels) * 2 / channels + 2; default: return 0; } @@ -133,7 +137,7 @@ static int caf_write_header(AVFormatContext *s) avio_wb32(pb, codec_tag); //< mFormatID avio_wb32(pb, codec_flags(enc->codec_id)); //< mFormatFlags avio_wb32(pb, enc->block_align); //< mBytesPerPacket - avio_wb32(pb, samples_per_packet(enc->codec_id)); //< mFramesPerPacket + avio_wb32(pb, samples_per_packet(enc->codec_id, enc->channels)); //< mFramesPerPacket avio_wb32(pb, enc->channels); //< mChannelsPerFrame avio_wb32(pb, enc->bits_per_coded_sample); //< mBitsPerChannel From 828e20733726e8e4fcf70a19d51652948d9436b6 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 8 Jul 2011 15:29:57 +0200 Subject: [PATCH 474/780] dnxhdenc: Replace a forward declaration by the proper #include. --- libavcodec/dnxhdenc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 78da1c15e2..85832a1dc3 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -28,6 +28,7 @@ #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" +#include "mpegvideo_common.h" #include "dnxhdenc.h" #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM @@ -38,8 +39,6 @@ static const AVOption options[]={ }; static const AVClass class = { "dnxhd", av_default_item_name, options, LIBAVUTIL_VERSION_INT }; -int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); - #define LAMBDA_FRAC_BITS 10 static av_always_inline void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, int line_size) From 896e59758a11ff645879098b5ebca2e753731b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Mon, 11 Jul 2011 20:35:02 +0200 Subject: [PATCH 475/780] Move resetting of channels, sample_rate back to av_find_stream_info. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resetting it on codec init would incorrectly clear the values if av_find_stream_info was already run before, in particular breaking ffplay. This fixes trac tickets #213 and #262. Signed-off-by: Reimar Döffinger --- libavcodec/aacdec.c | 3 --- libavformat/utils.c | 9 +++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 8a936da59e..d9f60d6d23 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -570,9 +570,6 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) ac->m4ac.sample_rate = avctx->sample_rate; if (avctx->extradata_size > 0) { - avctx->channels = 0; - avctx->frame_size = 0; - avctx->sample_rate = 0; if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, avctx->extradata, avctx->extradata_size) < 0) diff --git a/libavformat/utils.c b/libavformat/utils.c index 654bc8aae5..b9a4ebab9d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2261,6 +2261,15 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) for(i=0;inb_streams;i++) { AVCodec *codec; st = ic->streams[i]; + if (st->codec->codec_id == CODEC_ID_AAC && st->codec->extradata_size) { + // We need to discard these since they can be plain wrong for + // backwards compatible HE-AAC signaling. + // But when we have no extradata we need to keep them or we can't + // play anything at all. + st->codec->sample_rate = 0; + st->codec->frame_size = 0; + st->codec->channels = 0; + } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { From 987041318ff7a5e99682470a017eef06151f00ae Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 11 Jul 2011 17:04:15 +0200 Subject: [PATCH 476/780] ffplay: skip return value of avcodec_decode_video2 / avcodec_decode_subtitle2 This fixes some warnings about unused-but-set variables. --- ffplay.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ffplay.c b/ffplay.c index 706ee25d65..cb5567d283 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1457,7 +1457,7 @@ static int output_picture2(VideoState *is, AVFrame *src_frame, double pts1, int6 static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt) { - int len1, got_picture, i; + int got_picture, i; if (packet_queue_get(&is->videoq, pkt, 1) < 0) return -1; @@ -1485,9 +1485,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke return 0; } - len1 = avcodec_decode_video2(is->video_st->codec, - frame, &got_picture, - pkt); + avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt); if (got_picture) { if (decoder_reorder_pts == -1) { @@ -1828,7 +1826,7 @@ static int subtitle_thread(void *arg) VideoState *is = arg; SubPicture *sp; AVPacket pkt1, *pkt = &pkt1; - int len1, got_subtitle; + int got_subtitle; double pts; int i, j; int r, g, b, y, u, v, a; @@ -1862,9 +1860,9 @@ static int subtitle_thread(void *arg) if (pkt->pts != AV_NOPTS_VALUE) pts = av_q2d(is->subtitle_st->time_base)*pkt->pts; - len1 = avcodec_decode_subtitle2(is->subtitle_st->codec, - &sp->sub, &got_subtitle, - pkt); + avcodec_decode_subtitle2(is->subtitle_st->codec, &sp->sub, + &got_subtitle, pkt); + if (got_subtitle && sp->sub.format == 0) { sp->pts = pts; From 028216b2c2d81f7fe918163c74b0a59cd327f2f7 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 12 Jul 2011 20:36:50 +0200 Subject: [PATCH 477/780] h264: move decode_mb_skip() from h264.h to h.264_mvpred.h This resolves a circular dependency between the headers. --- libavcodec/h264.h | 41 ---------------------------------------- libavcodec/h264_mvpred.h | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 9d46ab479a..95b471539d 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -770,8 +770,6 @@ static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){ return h->pps.chroma_qp_table[t][qscale]; } -#include "h264_mvpred.h" //For pred_pskip_motion() - static void fill_decode_neighbors(H264Context *h, int mb_type){ MpegEncContext * const s = &h->s; const int mb_xy= h->mb_xy; @@ -1302,43 +1300,4 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h){ return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8|MB_TYPE_DIRECT2)*0x0001000100010001ULL)); } -/** - * decodes a P_SKIP or B_SKIP macroblock - */ -static void av_unused decode_mb_skip(H264Context *h){ - MpegEncContext * const s = &h->s; - const int mb_xy= h->mb_xy; - int mb_type=0; - - memset(h->non_zero_count[mb_xy], 0, 48); - - if(MB_FIELD) - mb_type|= MB_TYPE_INTERLACED; - - if( h->slice_type_nos == AV_PICTURE_TYPE_B ) - { - // just for fill_caches. pred_direct_motion will set the real mb_type - mb_type|= MB_TYPE_L0L1|MB_TYPE_DIRECT2|MB_TYPE_SKIP; - if(h->direct_spatial_mv_pred){ - fill_decode_neighbors(h, mb_type); - fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ... - } - ff_h264_pred_direct_motion(h, &mb_type); - mb_type|= MB_TYPE_SKIP; - } - else - { - mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP; - - fill_decode_neighbors(h, mb_type); - pred_pskip_motion(h); - } - - write_back_motion(h, mb_type); - s->current_picture.f.mb_type[mb_xy] = mb_type; - s->current_picture.f.qscale_table[mb_xy] = s->qscale; - h->slice_table[ mb_xy ]= h->slice_num; - h->prev_mb_skipped= 1; -} - #endif /* AVCODEC_H264_H */ diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h index 1d40c0a2c5..52c032337a 100644 --- a/libavcodec/h264_mvpred.h +++ b/libavcodec/h264_mvpred.h @@ -327,4 +327,43 @@ zeromv: return; } +/** + * decodes a P_SKIP or B_SKIP macroblock + */ +static void av_unused decode_mb_skip(H264Context *h){ + MpegEncContext * const s = &h->s; + const int mb_xy= h->mb_xy; + int mb_type=0; + + memset(h->non_zero_count[mb_xy], 0, 48); + + if(MB_FIELD) + mb_type|= MB_TYPE_INTERLACED; + + if( h->slice_type_nos == AV_PICTURE_TYPE_B ) + { + // just for fill_caches. pred_direct_motion will set the real mb_type + mb_type|= MB_TYPE_L0L1|MB_TYPE_DIRECT2|MB_TYPE_SKIP; + if(h->direct_spatial_mv_pred){ + fill_decode_neighbors(h, mb_type); + fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ... + } + ff_h264_pred_direct_motion(h, &mb_type); + mb_type|= MB_TYPE_SKIP; + } + else + { + mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP; + + fill_decode_neighbors(h, mb_type); + pred_pskip_motion(h); + } + + write_back_motion(h, mb_type); + s->current_picture.f.mb_type[mb_xy] = mb_type; + s->current_picture.f.qscale_table[mb_xy] = s->qscale; + h->slice_table[ mb_xy ]= h->slice_num; + h->prev_mb_skipped= 1; +} + #endif /* AVCODEC_H264_MVPRED_H */ From 2cb6dec61c8e6676105de628ba20a5b3d162976e Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 8 Jul 2011 15:33:17 +0200 Subject: [PATCH 478/780] doc: Improve references to external URLs. Sometimes it makes sense to replace a raw URL with some informative text that links to the URL instead of using the raw URL itself in the text. Also transform some mailing list references into links. --- doc/developer.texi | 36 ++++++++++++++++++++++-------------- doc/faq.texi | 17 ++++++++++------- doc/ffmpeg.texi | 4 ++-- doc/general.texi | 9 ++++----- doc/protocols.texi | 2 +- 5 files changed, 39 insertions(+), 29 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index 597ce957d1..45a4f4476b 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -31,14 +31,16 @@ only the public api is used. You can use Libav in your commercial program, but you must abide to the license, LGPL or GPL depending on the specific features used, please refer -to @url{http://libav.org/legal.html} for a quick checklist and to -@url{http://git.libav.org/?p=libav.git;a=blob;f=COPYING.GPLv2}, -@url{http://git.libav.org/?p=libav.git;a=blob;f=COPYING.GPLv3}, -@url{http://git.libav.org/?p=libav.git;a=blob;f=COPYING.LGPLv2.1}, -@url{http://git.libav.org/?p=libav.git;a=blob;f=COPYING.LGPLv3} for the -exact text of the licenses. +to @uref{http://libav.org/legal.html, our legal page} for a quick checklist and to +the following links for the exact text of each license: +@uref{http://git.libav.org/?p=libav.git;a=blob;f=COPYING.GPLv2, GPL version 2}, +@uref{http://git.libav.org/?p=libav.git;a=blob;f=COPYING.GPLv3, GPL version 3}, +@uref{http://git.libav.org/?p=libav.git;a=blob;f=COPYING.LGPLv2.1, LGPL version 2.1}, +@uref{http://git.libav.org/?p=libav.git;a=blob;f=COPYING.LGPLv3, LGPL version 3}. Any modification to the source code can be suggested for inclusion. -The best way to proceed is to send your patches to the Libav mailing list. +The best way to proceed is to send your patches to the +@uref{https://lists.libav.org/mailman/listinfo/libav-devel, libav-devel} +mailing list. @anchor{Coding Rules} @section Coding Rules @@ -177,7 +179,10 @@ should also be avoided if they don't make the code easier to understand. When applying patches that have been discussed (at length) on the mailing list, reference the thread in the log message. @item - Subscribe to the libav-devel and libav-commits mailing list. + Subscribe to the + @uref{https://lists.libav.org/mailman/listinfo/libav-devel, libav-devel} and + @uref{https://lists.libav.org/mailman/listinfo/libav-commits, libav-commits} + mailing lists. Bugs and possible improvements or general questions regarding commits are discussed on libav-devel. We expect you to react if problems with your code are uncovered. @@ -241,8 +246,9 @@ it does not cause unexpected problems. Patches should be posted as base64 encoded attachments (or any other encoding which ensures that the patch will not be trashed during -transmission) to the libav-devel mailing list, see -@url{https://lists.libav.org/mailman/listinfo/libav-devel} +transmission) to the +@uref{https://lists.libav.org/mailman/listinfo/libav-devel, libav-devel} +mailing list. It also helps quite a bit if you tell us what the patch does (for example 'replaces lrint by lrintf'), and why (for example '*BSD isn't C99 compliant @@ -314,9 +320,9 @@ send a reminder by email. Your patch should eventually be dealt with. @item Is the patch against latest Libav git master branch? @item - Are you subscribed to libav-devel? - (@url{https://lists.libav.org/mailman/listinfo/libav-devel} - the list is subscribers) + Are you subscribed to the + @uref{https://lists.libav.org/mailman/listinfo/libav-devel, libav-devel} + mailing list? (Only list subscribers are allowed to post.) @item Have you checked that the changes are minimal, so that the same cannot be achieved with a smaller patch and/or simpler final code? @@ -370,7 +376,9 @@ send a reminder by email. Your patch should eventually be dealt with. @section Patch review process -All patches posted to libav-devel will be reviewed, unless they contain a +All patches posted to the +@uref{https://lists.libav.org/mailman/listinfo/libav-devel, libav-devel} +mailing list will be reviewed, unless they contain a clear note that the patch is not for the git master branch. Reviews and comments will be posted as replies to the patch on the mailing list. The patch submitter then has to take care of every comment, diff --git a/doc/faq.texi b/doc/faq.texi index 3d7a275f89..42a135c429 100644 --- a/doc/faq.texi +++ b/doc/faq.texi @@ -24,8 +24,8 @@ help out creating them. Nowhere. We do not support old Libav versions in any way, we simply lack the time, motivation and manpower to do so. If you have a problem with an old version of Libav, upgrade to the latest git snapshot. If you -still experience the problem, then you can report it according to the -guidelines in @url{http://libav.org/bugreports.html}. +still experience the problem, then you can report it according to our +@uref{http://libav.org/bugreports.html, bug reporting guidelines}. @section Why doesn't Libav support feature [xyz]? @@ -46,7 +46,8 @@ Likely reasons @itemize @item We are busy and haven't had time yet to read your report or investigate the issue. -@item You didn't follow @url{http://libav.org/bugreports.html}. +@item You did not follow our + @uref{http://libav.org/bugreports.html, bug reporting guidelines}. @item You didn't use git master. @item You reported a segmentation fault without gdb output. @item You describe a problem but not how to reproduce it. @@ -123,8 +124,9 @@ problem and an NP-hard problem... @section ffmpeg does not work; what is wrong? -Try a @code{make distclean} in the ffmpeg source directory before the build. If this does not help see -(@url{http://libav.org/bugreports.html}). +Try a @code{make distclean} in the ffmpeg source directory before the build. +If this does not help see our +@uref{http://libav.org/bugreports.html, bug reporting guidelines}. @section How do I encode single pictures into movies? @@ -285,7 +287,8 @@ Just create an "input.avs" text file with this single line ... ffmpeg -i input.avs @end example -For ANY other help on Avisynth, please visit @url{http://www.avisynth.org/}. +For ANY other help on Avisynth, please visit the +@uref{http://www.avisynth.org/, Avisynth homepage}. @section How can I join video files? @@ -413,7 +416,7 @@ No. These tools are too bloated and they complicate the build. Libav is already organized in a highly modular manner and does not need to be rewritten in a formal object language. Further, many of the developers favor straight C; it works for them. For more arguments on this matter, -read "Programming Religion" at (@url{http://www.tux.org/lkml/#s15}). +read @uref{http://www.tux.org/lkml/#s15, "Programming Religion"}. @section I do not like the LGPL, can I contribute code under the GPL instead? diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 5246b18640..517bb0cd38 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -882,8 +882,8 @@ ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg @end example Note that you must activate the right video source and channel before -launching ffmpeg with any TV viewer such as xawtv -(@url{http://linux.bytesex.org/xawtv/}) by Gerd Knorr. You also +launching ffmpeg with any TV viewer such as +@uref{http://linux.bytesex.org/xawtv/, xawtv} by Gerd Knorr. You also have to set the audio recording levels correctly with a standard mixer. diff --git a/doc/general.texi b/doc/general.texi index c97a7575c8..ace464f024 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -836,7 +836,7 @@ noticeable when running make for a second time (for example in @code{make install}). @item In order to compile FFplay, you must have the MinGW development library -of SDL. Get it from @url{http://www.libsdl.org}. +of @uref{http://www.libsdl.org/, SDL}. Edit the @file{bin/sdl-config} script so that it points to the correct prefix where SDL was installed. Verify that @file{sdl-config} can be launched from the MSYS command line. @@ -1008,8 +1008,7 @@ Then configure Libav with the following options: (you can change the cross-prefix according to the prefix chosen for the MinGW tools). -Then you can easily test Libav with Wine -(@url{http://www.winehq.com/}). +Then you can easily test Libav with @uref{http://www.winehq.com/, Wine}. @subsection Compilation under Cygwin @@ -1048,8 +1047,8 @@ If you want to build Libav with additional libraries, download Cygwin libogg-devel, libvorbis-devel @end example -These library packages are only available from Cygwin Ports -(@url{http://sourceware.org/cygwinports/}) : +These library packages are only available from +@uref{http://sourceware.org/cygwinports/, Cygwin Ports}: @example yasm, libSDL-devel, libdirac-devel, libfaac-devel, libgsm-devel, diff --git a/doc/protocols.texi b/doc/protocols.texi index 18749efbfb..59906312fa 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -242,7 +242,7 @@ data transferred over RDT). The muxer can be used to send a stream using RTSP ANNOUNCE to a server supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's -RTSP server, @url{http://github.com/revmischa/rtsp-server}). +@uref{http://github.com/revmischa/rtsp-server, RTSP server}). The required syntax for a RTSP url is: @example From 0cdd1208bed747bc96dcf109fe0e3c607cdbba45 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Mon, 11 Jul 2011 15:13:39 +0200 Subject: [PATCH 479/780] Musepack SV7: try to read files without number of frames provided Signed-off-by: Anton Khirnov --- libavformat/mpc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libavformat/mpc.c b/libavformat/mpc.c index 0aec1e81d3..75b59e1800 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -70,7 +70,15 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n"); return -1; } - c->frames = av_malloc(c->fcount * sizeof(MPCFrame)); + if(c->fcount){ + c->frames = av_malloc(c->fcount * sizeof(MPCFrame)); + if(!c->frames){ + av_log(s, AV_LOG_ERROR, "Cannot allocate seektable\n"); + return AVERROR(ENOMEM); + } + }else{ + av_log(s, AV_LOG_WARNING, "Container reports no frames\n"); + } c->curframe = 0; c->lastframe = -1; c->curbits = 8; @@ -111,7 +119,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) int ret, size, size2, curbits, cur = c->curframe; int64_t tmp, pos; - if (c->curframe >= c->fcount) + if (c->curframe >= c->fcount && c->fcount) return -1; if(c->curframe != c->lastframe + 1){ @@ -133,7 +141,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) avio_seek(s->pb, pos, SEEK_SET); size = ((size2 + curbits + 31) & ~31) >> 3; - if(cur == c->frames_noted){ + if(cur == c->frames_noted && c->fcount){ c->frames[cur].pos = pos; c->frames[cur].size = size; c->frames[cur].skip = curbits - 20; @@ -146,7 +154,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EIO); pkt->data[0] = curbits; - pkt->data[1] = (c->curframe > c->fcount); + pkt->data[1] = (c->curframe > c->fcount) && c->fcount; pkt->data[2] = 0; pkt->data[3] = 0; From 646a9a189346392ea0e23d4eacbec890955d187c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Jul 2011 16:48:47 +0200 Subject: [PATCH 480/780] ffmpeg: remove an unused define. --- ffmpeg.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index a0f6abc87d..ba5859df4e 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -104,8 +104,6 @@ static const OptionDef options[]; #define MAX_FILES 100 #define MAX_STREAMS 1024 /* arbitrary sanity check value */ -#define FFM_PACKET_SIZE 4096 //XXX a duplicate of the line in ffm.h - static const char *last_asked_format = NULL; static double *ts_scale; static int nb_ts_scale; From c7dd3e7e43555b2922481a9242a306c5b138d69c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Jul 2011 16:49:44 +0200 Subject: [PATCH 481/780] ffmpeg: get rid of a pointless limit on number of streams. --- ffmpeg.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index ba5859df4e..1f339cb33a 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -102,7 +102,6 @@ typedef struct ChapterMap { static const OptionDef options[]; #define MAX_FILES 100 -#define MAX_STREAMS 1024 /* arbitrary sanity check value */ static const char *last_asked_format = NULL; static double *ts_scale; @@ -3081,9 +3080,6 @@ static int opt_input_ts_scale(const char *opt, const char *arg) p++; scale= strtod(p, &p); - if(stream >= MAX_STREAMS) - ffmpeg_exit(1); - ts_scale = grow_array(ts_scale, sizeof(*ts_scale), &nb_ts_scale, stream + 1); ts_scale[stream] = scale; return 0; @@ -3742,7 +3738,7 @@ static int opt_streamid(const char *opt, const char *arg) ffmpeg_exit(1); } *p++ = '\0'; - idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1); + idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, INT_MAX); streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1); streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX); return 0; From a4ad9438600ea20f4ef459f3f5f397755d48c58b Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Fri, 18 Mar 2011 00:00:15 +0000 Subject: [PATCH 482/780] wav: add an option for writing BEXT chunk Signed-off-by: Anton Khirnov --- Changelog | 4 +++ doc/general.texi | 1 + libavformat/wav.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/Changelog b/Changelog index 943d710836..782d8b3f04 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,10 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version : +- BWF muxer + + version 0.7: - E-AC-3 audio encoder diff --git a/doc/general.texi b/doc/general.texi index ace464f024..77a54a3fd0 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -66,6 +66,7 @@ library: @tab Used in Z and Z95 games. @item Brute Force & Ignorance @tab @tab X @tab Used in the game Flash Traffic: City of Angels. +@item BWF @tab X @tab @item Interplay C93 @tab @tab X @tab Used in the game Cyberia from Interplay. @item Delphine Software International CIN @tab @tab X diff --git a/libavformat/wav.c b/libavformat/wav.c index 391461044b..c9086196ca 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -23,22 +23,82 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/log.h" #include "libavutil/mathematics.h" +#include "libavutil/opt.h" #include "avformat.h" #include "avio_internal.h" #include "pcm.h" #include "riff.h" +#include "avio.h" +#include "avio_internal.h" typedef struct { + const AVClass *class; int64_t data; int64_t data_end; int64_t minpts; int64_t maxpts; int last_duration; int w64; + int write_bext; } WAVContext; #if CONFIG_WAV_MUXER +static inline void bwf_write_bext_string(AVFormatContext *s, const char *key, int maxlen) +{ + AVDictionaryEntry *tag; + int len = 0; + + if (tag = av_dict_get(s->metadata, key, NULL, 0)) { + len = strlen(tag->value); + len = FFMIN(len, maxlen); + avio_write(s->pb, tag->value, len); + } + + ffio_fill(s->pb, 0, maxlen - len); +} + +static void bwf_write_bext_chunk(AVFormatContext *s) +{ + AVDictionaryEntry *tmp_tag; + uint64_t time_reference = 0; + int64_t bext = ff_start_tag(s->pb, "bext"); + + bwf_write_bext_string(s, "description", 256); + bwf_write_bext_string(s, "originator", 32); + bwf_write_bext_string(s, "originator_reference", 32); + bwf_write_bext_string(s, "origination_date", 10); + bwf_write_bext_string(s, "origination_time", 8); + + if (tmp_tag = av_dict_get(s->metadata, "time_reference", NULL, 0)) + time_reference = strtoll(tmp_tag->value, NULL, 10); + avio_wl64(s->pb, time_reference); + avio_wl16(s->pb, 1); // set version to 1 + + if (tmp_tag = av_dict_get(s->metadata, "umid", NULL, 0)) { + unsigned char umidpart_str[17] = {0}; + int i; + uint64_t umidpart; + int len = strlen(tmp_tag->value+2); + + for (i = 0; i < len/16; i++) { + memcpy(umidpart_str, tmp_tag->value + 2 + (i*16), 16); + umidpart = strtoll(umidpart_str, NULL, 16); + avio_wb64(s->pb, umidpart); + } + ffio_fill(s->pb, 0, 64 - i*8); + } else + ffio_fill(s->pb, 0, 64); // zero UMID + + ffio_fill(s->pb, 0, 190); // Reserved + + if (tmp_tag = av_dict_get(s->metadata, "coding_history", NULL, 0)) + avio_put_str(s->pb, tmp_tag->value); + + ff_end_tag(s->pb, bext); +} + static int wav_write_header(AVFormatContext *s) { WAVContext *wav = s->priv_data; @@ -65,6 +125,9 @@ static int wav_write_header(AVFormatContext *s) ff_end_tag(pb, fact); } + if (wav->write_bext) + bwf_write_bext_chunk(s); + av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); wav->maxpts = wav->last_duration = 0; wav->minpts = INT64_MAX; @@ -125,6 +188,20 @@ static int wav_write_trailer(AVFormatContext *s) return 0; } +#define OFFSET(x) offsetof(WAVContext, x) +#define ENC AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "write_bext", "Write BEXT chunk.", OFFSET(write_bext), FF_OPT_TYPE_INT, { 0 }, 0, 1, ENC }, + { NULL }, +}; + +static const AVClass wav_muxer_class = { + .class_name = "WAV muxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVOutputFormat ff_wav_muxer = { "wav", NULL_IF_CONFIG_SMALL("WAV format"), @@ -137,6 +214,7 @@ AVOutputFormat ff_wav_muxer = { wav_write_packet, wav_write_trailer, .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0}, + .priv_class = &wav_muxer_class, }; #endif /* CONFIG_WAV_MUXER */ From 7f84055e2d3814972a61515da7f1d2659b185ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Tue, 17 May 2011 19:46:08 +0200 Subject: [PATCH 483/780] wav: refactor the 'fmt ' tag search and parsing. Moving the search and parsing of the 'fmt ' info the main loop of wav_read_header() allows tags that precede it to be parsed. Creating wav_parse_fmt_tag() makes wav_read_header() easier to read. Signed-off-by: Anton Khirnov --- libavformat/wav.c | 57 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/libavformat/wav.c b/libavformat/wav.c index c9086196ca..3e4e0c4ea4 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -264,6 +264,26 @@ static int wav_probe(AVProbeData *p) return 0; } +static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st) +{ + AVIOContext *pb = s->pb; + int ret; + + /* parse fmt header */ + *st = av_new_stream(s, 0); + if (!*st) + return AVERROR(ENOMEM); + + ret = ff_get_wav_header(pb, (*st)->codec, size); + if (ret < 0) + return ret; + (*st)->need_parsing = AVSTREAM_PARSE_FULL; + + av_set_pts_info(*st, 64, 1, (*st)->codec->sample_rate); + + return 0; +} + /* wav input */ static int wav_read_header(AVFormatContext *s, AVFormatParameters *ap) @@ -275,7 +295,8 @@ static int wav_read_header(AVFormatContext *s, AVIOContext *pb = s->pb; AVStream *st; WAVContext *wav = s->priv_data; - int ret; + int ret, got_fmt = 0; + int64_t next_tag_ofs; /* check RIFF header */ tag = avio_rl32(pb); @@ -300,32 +321,32 @@ static int wav_read_header(AVFormatContext *s, avio_skip(pb, size - 16); /* skip rest of ds64 chunk */ } - /* parse fmt header */ - size = find_tag(pb, MKTAG('f', 'm', 't', ' ')); - if (size < 0) - return -1; - st = av_new_stream(s, 0); - if (!st) - return AVERROR(ENOMEM); - - ret = ff_get_wav_header(pb, st->codec, size); - if (ret < 0) - return ret; - st->need_parsing = AVSTREAM_PARSE_FULL; - - av_set_pts_info(st, 64, 1, st->codec->sample_rate); for (;;) { if (pb->eof_reached) return -1; size = next_tag(pb, &tag); - if (tag == MKTAG('d', 'a', 't', 'a')){ + next_tag_ofs = avio_tell(pb) + size; + + if (tag == MKTAG('f', 'm', 't', ' ')) { + /* only parse the first 'fmt ' tag found */ + if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st) < 0)) { + return ret; + } else if (got_fmt) + av_log(s, AV_LOG_WARNING, "found more than one 'fmt ' tag\n"); + + got_fmt = 1; + } else if (tag == MKTAG('d', 'a', 't', 'a')) { + if (!got_fmt) { + av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'data' tag\n"); + return AVERROR_INVALIDDATA; + } + break; }else if (tag == MKTAG('f','a','c','t') && !sample_count){ sample_count = avio_rl32(pb); - size -= 4; } - avio_skip(pb, size); + avio_seek(pb, next_tag_ofs, SEEK_SET); } if (rf64) size = data_size; From 1cf18de982a0a62fa9214a6c4a5becc1a32d9caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Tue, 17 May 2011 19:52:36 +0200 Subject: [PATCH 484/780] wav: make sure neither data_size nor sample_count is negative. Signed-off-by: Anton Khirnov --- libavformat/wav.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavformat/wav.c b/libavformat/wav.c index 3e4e0c4ea4..9f902be818 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -318,6 +318,12 @@ static int wav_read_header(AVFormatContext *s, avio_rl64(pb); /* RIFF size */ data_size = avio_rl64(pb); sample_count = avio_rl64(pb); + if (data_size < 0 || sample_count < 0) { + av_log(s, AV_LOG_ERROR, "negative data_size and/or sample_count in " + "ds64: data_size = %"PRId64", sample_count = %"PRId64"\n", + data_size, sample_count); + return AVERROR_INVALIDDATA; + } avio_skip(pb, size - 16); /* skip rest of ds64 chunk */ } From 90f2ee8cb4d2b135dd33128a94ad6cf126821472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 17 Feb 2011 15:58:10 +0100 Subject: [PATCH 485/780] wav: Refactor the tag checking into a switch statement Signed-off-by: Anton Khirnov --- libavformat/wav.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libavformat/wav.c b/libavformat/wav.c index 9f902be818..cf815ef3df 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -334,7 +334,8 @@ static int wav_read_header(AVFormatContext *s, size = next_tag(pb, &tag); next_tag_ofs = avio_tell(pb) + size; - if (tag == MKTAG('f', 'm', 't', ' ')) { + switch (tag) { + case MKTAG('f', 'm', 't', ' '): /* only parse the first 'fmt ' tag found */ if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st) < 0)) { return ret; @@ -342,18 +343,22 @@ static int wav_read_header(AVFormatContext *s, av_log(s, AV_LOG_WARNING, "found more than one 'fmt ' tag\n"); got_fmt = 1; - } else if (tag == MKTAG('d', 'a', 't', 'a')) { + break; + case MKTAG('d', 'a', 't', 'a'): if (!got_fmt) { av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'data' tag\n"); return AVERROR_INVALIDDATA; } + goto break_loop; + case MKTAG('f','a','c','t'): + if (!sample_count) + sample_count = avio_rl32(pb); break; - }else if (tag == MKTAG('f','a','c','t') && !sample_count){ - sample_count = avio_rl32(pb); } avio_seek(pb, next_tag_ofs, SEEK_SET); } +break_loop: if (rf64) size = data_size; if (size < 0) From 67b1761fcbd8ddcfe7bdb47ace5f46435d8313fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Wed, 18 May 2011 13:48:02 +0200 Subject: [PATCH 486/780] wav: keep parsing until EOF if the input is seekable and we know the size of the data tag Signed-off-by: Anton Khirnov --- libavformat/wav.c | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/libavformat/wav.c b/libavformat/wav.c index cf815ef3df..a8312e254e 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -296,7 +296,7 @@ static int wav_read_header(AVFormatContext *s, AVStream *st; WAVContext *wav = s->priv_data; int ret, got_fmt = 0; - int64_t next_tag_ofs; + int64_t next_tag_ofs, data_ofs = -1; /* check RIFF header */ tag = avio_rl32(pb); @@ -327,13 +327,13 @@ static int wav_read_header(AVFormatContext *s, avio_skip(pb, size - 16); /* skip rest of ds64 chunk */ } - for (;;) { - if (pb->eof_reached) - return -1; size = next_tag(pb, &tag); next_tag_ofs = avio_tell(pb) + size; + if (pb->eof_reached) + break; + switch (tag) { case MKTAG('f', 'm', 't', ' '): /* only parse the first 'fmt ' tag found */ @@ -350,26 +350,43 @@ static int wav_read_header(AVFormatContext *s, return AVERROR_INVALIDDATA; } - goto break_loop; + if (rf64) { + next_tag_ofs = wav->data_end = avio_tell(pb) + data_size; + } else { + data_size = size; + next_tag_ofs = wav->data_end = size ? next_tag_ofs : INT64_MAX; + } + + data_ofs = avio_tell(pb); + + /* don't look for footer metadata if we can't seek or if we don't + * know where the data tag ends + */ + if (!pb->seekable || (!rf64 && !size)) + goto break_loop; + break; case MKTAG('f','a','c','t'): if (!sample_count) sample_count = avio_rl32(pb); break; } - avio_seek(pb, next_tag_ofs, SEEK_SET); + + /* seek to next tag unless we know that we'll run into EOF */ + if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) || + avio_seek(pb, next_tag_ofs, SEEK_SET) < 0) { + break; + } } break_loop: - if (rf64) - size = data_size; - if (size < 0) - return -1; - if (!size) { - wav->data_end = INT64_MAX; - } else - wav->data_end= avio_tell(pb) + size; + if (data_ofs < 0) { + av_log(s, AV_LOG_ERROR, "no 'data' tag found\n"); + return AVERROR_INVALIDDATA; + } + + avio_seek(pb, data_ofs, SEEK_SET); if (!sample_count && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id)) - sample_count = (size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id)); + sample_count = (data_size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id)); if (sample_count) st->duration = sample_count; return 0; From b21e6b707fbc80511f4886d3b272a77b86157a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Wed, 18 May 2011 13:48:39 +0200 Subject: [PATCH 487/780] wav: parse 'bext' metadata Signed-off-by: Anton Khirnov --- doc/general.texi | 2 +- libavformat/wav.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) diff --git a/doc/general.texi b/doc/general.texi index 77a54a3fd0..fe314481a3 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -66,7 +66,7 @@ library: @tab Used in Z and Z95 games. @item Brute Force & Ignorance @tab @tab X @tab Used in the game Flash Traffic: City of Angels. -@item BWF @tab X @tab +@item BWF @tab X @tab X @item Interplay C93 @tab @tab X @tab Used in the game Cyberia from Interplay. @item Delphine Software International CIN @tab @tab X diff --git a/libavformat/wav.c b/libavformat/wav.c index a8312e254e..5b9f6e4480 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -23,6 +23,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/avassert.h" +#include "libavutil/dict.h" #include "libavutil/log.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" @@ -32,6 +34,7 @@ #include "riff.h" #include "avio.h" #include "avio_internal.h" +#include "metadata.h" typedef struct { const AVClass *class; @@ -284,6 +287,97 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st) return 0; } +static inline int wav_parse_bext_string(AVFormatContext *s, const char *key, + int length) +{ + char temp[257]; + int ret; + + av_assert0(length <= sizeof(temp)); + if ((ret = avio_read(s->pb, temp, length)) < 0) + return ret; + + temp[length] = 0; + + if (strlen(temp)) + return av_dict_set(&s->metadata, key, temp, 0); + + return 0; +} + +static int wav_parse_bext_tag(AVFormatContext *s, int64_t size) +{ + char temp[131], *coding_history; + int ret, x; + uint64_t time_reference; + int64_t umid_parts[8], umid_mask = 0; + + if ((ret = wav_parse_bext_string(s, "description", 256)) < 0 || + (ret = wav_parse_bext_string(s, "originator", 32)) < 0 || + (ret = wav_parse_bext_string(s, "originator_reference", 32)) < 0 || + (ret = wav_parse_bext_string(s, "origination_date", 10)) < 0 || + (ret = wav_parse_bext_string(s, "origination_time", 8)) < 0) + return ret; + + time_reference = avio_rl64(s->pb); + snprintf(temp, sizeof(temp), "%"PRIu64, time_reference); + if ((ret = av_dict_set(&s->metadata, "time_reference", temp, 0)) < 0) + return ret; + + /* check if version is >= 1, in which case an UMID may be present */ + if (avio_rl16(s->pb) >= 1) { + for (x = 0; x < 8; x++) + umid_mask |= umid_parts[x] = avio_rb64(s->pb); + + if (umid_mask) { + /* the string formatting below is per SMPTE 330M-2004 Annex C */ + if (umid_parts[4] == 0 && umid_parts[5] == 0 && umid_parts[6] == 0 && umid_parts[7] == 0) { + /* basic UMID */ + snprintf(temp, sizeof(temp), "0x%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64, + umid_parts[0], umid_parts[1], umid_parts[2], umid_parts[3]); + } else { + /* extended UMID */ + snprintf(temp, sizeof(temp), "0x%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64 + "0x%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64, + umid_parts[0], umid_parts[1], umid_parts[2], umid_parts[3], + umid_parts[4], umid_parts[5], umid_parts[6], umid_parts[7]); + } + + if ((ret = av_dict_set(&s->metadata, "umid", temp, 0)) < 0) + return ret; + } + + avio_skip(s->pb, 190); + } else + avio_skip(s->pb, 254); + + if (size > 602) { + /* CodingHistory present */ + size -= 602; + + if (!(coding_history = av_malloc(size+1))) + return AVERROR(ENOMEM); + + if ((ret = avio_read(s->pb, coding_history, size)) < 0) + return ret; + + coding_history[size] = 0; + if ((ret = av_dict_set(&s->metadata, "coding_history", coding_history, + AV_METADATA_DONT_STRDUP_VAL)) < 0) + return ret; + } + + return 0; +} + +static const AVMetadataConv wav_metadata_conv[] = { + {"description", "comment" }, + {"originator", "encoded_by" }, + {"origination_date", "date" }, + {"origination_time", "creation_time"}, + {0}, +}; + /* wav input */ static int wav_read_header(AVFormatContext *s, AVFormatParameters *ap) @@ -369,6 +463,10 @@ static int wav_read_header(AVFormatContext *s, if (!sample_count) sample_count = avio_rl32(pb); break; + case MKTAG('b','e','x','t'): + if ((ret = wav_parse_bext_tag(s, size)) < 0) + return ret; + break; } /* seek to next tag unless we know that we'll run into EOF */ @@ -389,6 +487,9 @@ break_loop: sample_count = (data_size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id)); if (sample_count) st->duration = sample_count; + + ff_metadata_conv_ctx(s, NULL, wav_metadata_conv); + return 0; } From 001d668d40b5f87d19271c7d5521368b5187425b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 13 Jul 2011 11:45:17 +0200 Subject: [PATCH 488/780] lavf: factor out conversion of ISO8601 string to unix time --- libavformat/dvenc.c | 7 ++----- libavformat/gxfenc.c | 8 ++------ libavformat/internal.h | 5 +++++ libavformat/movenc.c | 7 ++----- libavformat/mxfenc.c | 7 ++----- libavformat/utils.c | 7 +++++++ 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 1e59bd9cc7..5aab6837c5 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -343,11 +343,8 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) c->start_time = s->timestamp; else #endif - if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { - struct tm time = {0}; - strptime(t->value, "%Y - %m - %dT%T", &time); - c->start_time = mktime(&time); - } + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) + c->start_time = ff_iso8601_to_unix_time(t->value); for (i=0; i < c->n_ast; i++) { if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc(100*AVCODEC_MAX_AUDIO_FRAME_SIZE))) { diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 2d4136ab86..99bd71938f 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -402,12 +402,8 @@ static int gxf_write_umf_material_description(AVFormatContext *s) timestamp = s->timestamp; else #endif - if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { - struct tm time = {0}; - strptime(t->value, "%Y - %m - %dT%T", &time); - timestamp = mktime(&time); - } - + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) + timestamp = ff_iso8601_to_unix_time(t->value); // XXX drop frame uint32_t timecode = diff --git a/libavformat/internal.h b/libavformat/internal.h index aba890def4..8440e6bd0a 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -248,4 +248,9 @@ void ff_make_absolute_url(char *buf, int size, const char *base, enum CodecID ff_guess_image2_codec(const char *filename); +/** + * Convert a date string in ISO8601 format to Unix timestamp. + */ +int64_t ff_iso8601_to_unix_time(const char *datestr); + #endif /* AVFORMAT_INTERNAL_H */ diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 78e5db7444..12ebef5426 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2266,11 +2266,8 @@ static int mov_write_header(AVFormatContext *s) mov->time = s->timestamp; else #endif - if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { - struct tm time = {0}; - strptime(t->value, "%Y - %m - %dT%T", &time); - mov->time = mktime(&time); - } + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) + mov->time = ff_iso8601_to_unix_time(t->value); mov->time += 0x7C25B080; //1970 based -> 1904 based if (mov->chapter_track) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index d7cc5c1c67..10ba6f3761 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1519,11 +1519,8 @@ static int mxf_write_header(AVFormatContext *s) timestamp = s->timestamp; else #endif - if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { - struct tm time = {0}; - strptime(t->value, "%Y - %m - %dT%T", &time); - timestamp = mktime(&time); - } + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) + timestamp = ff_iso8601_to_unix_time(t->value); if (timestamp) mxf->timestamp = mxf_parse_timestamp(timestamp); mxf->duration = -1; diff --git a/libavformat/utils.c b/libavformat/utils.c index bbd1b2d07b..bb12e24d8c 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3884,3 +3884,10 @@ void ff_make_absolute_url(char *buf, int size, const char *base, } av_strlcat(buf, rel, size); } + +int64_t ff_iso8601_to_unix_time(const char *datestr) +{ + struct tm time = {0}; + strptime(datestr, "%Y - %m - %dT%T", &time); + return mktime(&time); +} From 6379900c533d1e556d484e57166873f3ab2505f5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 13 Jul 2011 09:30:06 +0200 Subject: [PATCH 489/780] Add a check for strptime(). It's an XSI extension, not available on some supported systems. --- configure | 2 ++ libavformat/utils.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/configure b/configure index 02bcd0989c..596b6039e3 100755 --- a/configure +++ b/configure @@ -1105,6 +1105,7 @@ HAVE_LIST=" poll_h setrlimit strerror_r + strptime strtok_r struct_addrinfo struct_ipv6_mreq @@ -2775,6 +2776,7 @@ check_func mmap check_func ${malloc_prefix}posix_memalign && enable posix_memalign check_func setrlimit check_func strerror_r +check_func strptime check_func strtok_r check_func_headers io.h setmode check_func_headers lzo/lzo1x.h lzo1x_999_compress diff --git a/libavformat/utils.c b/libavformat/utils.c index bb12e24d8c..7e79922439 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3887,7 +3887,13 @@ void ff_make_absolute_url(char *buf, int size, const char *base, int64_t ff_iso8601_to_unix_time(const char *datestr) { +#if HAVE_STRPTIME struct tm time = {0}; strptime(datestr, "%Y - %m - %dT%T", &time); return mktime(&time); +#else + av_log(NULL, AV_LOG_WARNING, "strptime() unavailable on this system, cannot convert " + "the date string.\n"); + return 0; +#endif } From 2c4d7bf0083fc79a144ffed84200412cbf3f603c Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 13 Jul 2011 12:21:00 +0100 Subject: [PATCH 490/780] mxfenc: include needed header for ff_iso8601_to_unix_time() prototype Signed-off-by: Mans Rullgard --- libavformat/mxfenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 10ba6f3761..7dadec080f 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -39,6 +39,7 @@ #include "libavcodec/bytestream.h" #include "audiointerleave.h" #include "avformat.h" +#include "internal.h" #include "mxf.h" static const int NTSC_samples_per_frame[] = { 1602, 1601, 1602, 1601, 1602, 0 }; From 191c5f8ff33eb995b6dbc5b11af7c1a79f8381f0 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 13 Jul 2011 02:09:19 +0200 Subject: [PATCH 491/780] build: move tests/seek_test.c to libavformat and reuse generic build rules --- .gitignore | 1 - libavformat/Makefile | 2 +- tests/seek_test.c => libavformat/seek-test.c | 0 tests/Makefile | 6 +----- tests/fate-run.sh | 2 +- 5 files changed, 3 insertions(+), 8 deletions(-) rename tests/seek_test.c => libavformat/seek-test.c (100%) diff --git a/.gitignore b/.gitignore index 59a0860759..bfce23d311 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,6 @@ tests/audiogen tests/base64 tests/data tests/rotozoom -tests/seek_test tests/tiny_psnr tests/videogen tests/vsynth1 diff --git a/libavformat/Makefile b/libavformat/Makefile index ca337e0167..917b38a0d8 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -334,7 +334,7 @@ OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o OBJS-$(CONFIG_JACK_INDEV) += timefilter.o EXAMPLES = metadata output -TESTPROGS = timefilter +TESTPROGS = seek timefilter TOOLS = pktdumper probetest include $(SRC_PATH)/subdir.mak diff --git a/tests/seek_test.c b/libavformat/seek-test.c similarity index 100% rename from tests/seek_test.c rename to libavformat/seek-test.c diff --git a/tests/Makefile b/tests/Makefile index 35e803d102..4739446674 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -28,9 +28,6 @@ tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF) tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN -tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS) - $(LD) $(LDFLAGS) -o $@ $< $(FF_EXTRALIBS) - include $(SRC_PATH)/tests/fate.mak include $(SRC_PATH)/tests/fate2.mak @@ -64,7 +61,7 @@ $(filter-out %-aref,$(FATE_ACODEC)): $(AREF) $(filter-out %-vref,$(FATE_VCODEC)): $(VREF) $(FATE_LAVF): $(REFS) $(FATE_LAVFI): $(REFS) tools/lavfi-showfiltfmts$(EXESUF) -$(FATE_SEEK): fate-codec fate-lavf tests/seek_test$(EXESUF) +$(FATE_SEEK): fate-codec fate-lavf libavformat/seek-test$(EXESUF) $(FATE_ACODEC): CMD = codectest acodec $(FATE_VSYNTH1): CMD = codectest vsynth1 @@ -107,7 +104,6 @@ clean:: testclean testclean: $(RM) -r tests/vsynth1 tests/vsynth2 tests/data $(RM) $(CLEANSUFFIXES:%=tests/%) - $(RM) tests/seek_test$(EXESUF) tests/seek_test.o $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF)) -include $(wildcard tests/*.d) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 10497c497e..4121035853 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -104,7 +104,7 @@ seektest(){ file=$(echo tests/data/$d/$file) ;; esac - $target_exec $target_path/tests/seek_test $target_path/$file + $target_exec $target_path/libavformat/seek-test $target_path/$file } mkdir -p "$outdir" From 71a1d1116fd952f348d732c19ba7f4ebe041ce26 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 11 Jul 2011 16:32:54 +0200 Subject: [PATCH 492/780] Replace some gotos that lead to single return statements by direct return. --- ffmpeg.c | 10 ++++------ ffplay.c | 15 +++++++-------- ffserver.c | 6 ++---- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 1f339cb33a..ccf9c62486 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1522,7 +1522,7 @@ static int output_packet(InputStream *ist, int ist_index, ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size, &avpkt); if (ret < 0) - goto fail_decode; + return ret; avpkt.data += ret; avpkt.size -= ret; data_size = ret; @@ -1549,7 +1549,7 @@ static int output_packet(InputStream *ist, int ist_index, &picture, &got_output, &avpkt); quality = same_quality ? picture.quality : 0; if (ret < 0) - goto fail_decode; + return ret; if (!got_output) { /* no picture yet */ goto discard_packet; @@ -1569,7 +1569,7 @@ static int output_packet(InputStream *ist, int ist_index, ret = avcodec_decode_subtitle2(ist->st->codec, &subtitle, &got_output, &avpkt); if (ret < 0) - goto fail_decode; + return ret; if (!got_output) { goto discard_packet; } @@ -1577,7 +1577,7 @@ static int output_packet(InputStream *ist, int ist_index, avpkt.size = 0; break; default: - goto fail_decode; + return -1; } } else { switch(ist->st->codec->codec_type) { @@ -1849,8 +1849,6 @@ static int output_packet(InputStream *ist, int ist_index, } return 0; - fail_decode: - return -1; } static void print_sdp(AVFormatContext **avc, int n) diff --git a/ffplay.c b/ffplay.c index cb5567d283..bbbf5c6032 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1709,10 +1709,10 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src", NULL, is, graph)) < 0) - goto the_end; + return ret; if ((ret = avfilter_graph_create_filter(&filt_out, &ffsink, "out", NULL, &ffsink_ctx, graph)) < 0) - goto the_end; + return ret; if(vfilters) { AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut)); @@ -1729,18 +1729,18 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c inputs->next = NULL; if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0) - goto the_end; + return ret; av_freep(&vfilters); } else { if ((ret = avfilter_link(filt_src, 0, filt_out, 0)) < 0) - goto the_end; + return ret; } if ((ret = avfilter_graph_config(graph, NULL)) < 0) - goto the_end; + return ret; is->out_video_filter = filt_out; -the_end: + return ret; } @@ -1850,7 +1850,7 @@ static int subtitle_thread(void *arg) SDL_UnlockMutex(is->subpq_mutex); if (is->subtitleq.abort_request) - goto the_end; + return 0; sp = &is->subpq[is->subpq_windex]; @@ -1887,7 +1887,6 @@ static int subtitle_thread(void *arg) } av_free_packet(pkt); } - the_end: return 0; } diff --git a/ffserver.c b/ffserver.c index 1dc8a17f2f..ca4b54f4d4 100644 --- a/ffserver.c +++ b/ffserver.c @@ -3508,7 +3508,7 @@ static int add_av_stream(FFStream *feed, AVStream *st) case AVMEDIA_TYPE_AUDIO: if (av1->channels == av->channels && av1->sample_rate == av->sample_rate) - goto found; + return i; break; case AVMEDIA_TYPE_VIDEO: if (av1->width == av->width && @@ -3516,7 +3516,7 @@ static int add_av_stream(FFStream *feed, AVStream *st) av1->time_base.den == av->time_base.den && av1->time_base.num == av->time_base.num && av1->gop_size == av->gop_size) - goto found; + return i; break; default: abort(); @@ -3528,8 +3528,6 @@ static int add_av_stream(FFStream *feed, AVStream *st) if (!fst) return -1; return feed->nb_streams - 1; - found: - return i; } static void remove_stream(FFStream *stream) From a58858d60d37c7abfcea11bb387909bf9cd4916d Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Tue, 12 Jul 2011 15:13:29 -0700 Subject: [PATCH 493/780] lavf: Cleanup try_decode_frame() logic. This fixes AAC playback in ffplay. --- libavcodec/aacdec.c | 3 --- libavformat/utils.c | 9 +++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index f26a4b74a7..dac85c229d 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -568,9 +568,6 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) ac->m4ac.sample_rate = avctx->sample_rate; if (avctx->extradata_size > 0) { - avctx->channels = 0; - avctx->frame_size = 0; - avctx->sample_rate = 0; if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, avctx->extradata, avctx->extradata_size) < 0) diff --git a/libavformat/utils.c b/libavformat/utils.c index 7e79922439..e738dba44a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2090,7 +2090,8 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option return ret; } - if(!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st)){ + if(!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st) || + (!st->codec_info_nb_frames && st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF)) { switch(st->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: avcodec_get_frame_defaults(&picture); @@ -2387,11 +2388,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) least one frame of codec data, this makes sure the codec initializes the channel configuration and does not only trust the values from the container. */ - if (!has_codec_parameters(st->codec) || - !has_decode_delay_been_guessed(st) || - (st->codec->codec && - st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF)) - try_decode_frame(st, pkt, (options && i <= orig_nb_streams )? &options[i] : NULL); + try_decode_frame(st, pkt, (options && i <= orig_nb_streams )? &options[i] : NULL); st->codec_info_nb_frames++; count++; From 575c38d76ce546842d62a481ef03c122d55d3a69 Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Wed, 29 Jun 2011 15:01:39 +0200 Subject: [PATCH 494/780] mpegtsenc: set Random Access indicator on keyframe start packets Signed-off-by: Jindrich Makovicka Signed-off-by: Anton Khirnov --- libavformat/mpegtsenc.c | 67 ++++++++++++++++++++++++++++++++++------- tests/ref/lavf/ts | 2 +- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 83ede1d79b..72ff289df6 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -204,6 +204,7 @@ typedef struct MpegTSWriteStream { int first_pts_check; ///< first pts check needed int64_t payload_pts; int64_t payload_dts; + int payload_flags; uint8_t payload[DEFAULT_PES_PAYLOAD_SIZE]; ADTSContext *adts; } MpegTSWriteStream; @@ -621,7 +622,7 @@ static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext *pb) ts->first_pcr; } -static uint8_t* write_pcr_bits(uint8_t *buf, int64_t pcr) +static int write_pcr_bits(uint8_t *buf, int64_t pcr) { int64_t pcr_low = pcr % 300, pcr_high = pcr / 300; @@ -632,7 +633,7 @@ static uint8_t* write_pcr_bits(uint8_t *buf, int64_t pcr) *buf++ = pcr_high << 7 | pcr_low >> 8 | 0x7e; *buf++ = pcr_low; - return buf; + return 6; } /* Write a single null transport stream packet */ @@ -668,7 +669,7 @@ static void mpegts_insert_pcr_only(AVFormatContext *s, AVStream *st) *q++ = 0x10; /* Adaptation flags: PCR present */ /* PCR coded into 6 bytes */ - q = write_pcr_bits(q, get_pcr(ts, s->pb)); + q += write_pcr_bits(q, get_pcr(ts, s->pb)); /* stuffing bytes */ memset(q, 0xFF, TS_PACKET_SIZE - (q - buf)); @@ -689,6 +690,39 @@ static void write_pts(uint8_t *q, int fourbits, int64_t pts) *q++ = val; } +/* Set an adaptation field flag in an MPEG-TS packet*/ +static void set_af_flag(uint8_t *pkt, int flag) +{ + // expect at least one flag to set + assert(flag); + + if ((pkt[3] & 0x20) == 0) { + // no AF yet, set adaptation field flag + pkt[3] |= 0x20; + // 1 byte length, no flags + pkt[4] = 1; + pkt[5] = 0; + } + pkt[5] |= flag; +} + +/* Extend the adaptation field by size bytes */ +static void extend_af(uint8_t *pkt, int size) +{ + // expect already existing adaptation field + assert(pkt[3] & 0x20); + pkt[4] += size; +} + +/* Get a pointer to MPEG-TS payload (right after TS packet header) */ +static uint8_t *get_ts_payload_start(uint8_t *pkt) +{ + if (pkt[3] & 0x20) + return pkt + 5 + pkt[4]; + else + return pkt + 4; +} + /* Add a pes header to the front of payload, and segment into an integer number of * ts packets. The final ts packet is padded using an over-sized adaptation header * to exactly fill the last ts packet. @@ -696,7 +730,7 @@ static void write_pts(uint8_t *q, int fourbits, int64_t pts) */ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, const uint8_t *payload, int payload_size, - int64_t pts, int64_t dts) + int64_t pts, int64_t dts, int key) { MpegTSWriteStream *ts_st = st->priv_data; MpegTSWrite *ts = s->priv_data; @@ -741,8 +775,17 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, *q++ = val; *q++ = ts_st->pid; ts_st->cc = (ts_st->cc + 1) & 0xf; - *q++ = 0x10 | ts_st->cc | (write_pcr ? 0x20 : 0); + *q++ = 0x10 | ts_st->cc; // payload indicator + CC + if (key && is_start && pts != AV_NOPTS_VALUE) { + // set Random Access for key frames + if (ts_st->pid == ts_st->service->pcr_pid) + write_pcr = 1; + set_af_flag(buf, 0x40); + q = get_ts_payload_start(buf); + } if (write_pcr) { + set_af_flag(buf, 0x10); + q = get_ts_payload_start(buf); // add 11, pcr references the last byte of program clock reference base if (ts->mux_rate > 1) pcr = get_pcr(ts, s->pb); @@ -750,9 +793,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, pcr = (dts - delay)*300; if (dts != AV_NOPTS_VALUE && dts < pcr / 300) av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\n"); - *q++ = 7; /* AFC length */ - *q++ = 0x10; /* flags: PCR present */ - q = write_pcr_bits(q, pcr); + extend_af(buf, write_pcr_bits(q, pcr)); + q = get_ts_payload_start(buf); } if (is_start) { int pes_extension = 0; @@ -950,20 +992,22 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO) { // for video and subtitle, write a single pes packet - mpegts_write_pes(s, st, buf, size, pts, dts); + mpegts_write_pes(s, st, buf, size, pts, dts, pkt->flags & AV_PKT_FLAG_KEY); av_free(data); return 0; } if (ts_st->payload_index + size > DEFAULT_PES_PAYLOAD_SIZE) { mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index, - ts_st->payload_pts, ts_st->payload_dts); + ts_st->payload_pts, ts_st->payload_dts, + ts_st->payload_flags & AV_PKT_FLAG_KEY); ts_st->payload_index = 0; } if (!ts_st->payload_index) { ts_st->payload_pts = pts; ts_st->payload_dts = dts; + ts_st->payload_flags = pkt->flags; } memcpy(ts_st->payload + ts_st->payload_index, buf, size); @@ -988,7 +1032,8 @@ static int mpegts_write_end(AVFormatContext *s) ts_st = st->priv_data; if (ts_st->payload_index > 0) { mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index, - ts_st->payload_pts, ts_st->payload_dts); + ts_st->payload_pts, ts_st->payload_dts, + ts_st->payload_flags & AV_PKT_FLAG_KEY); } av_freep(&ts_st->adts); } diff --git a/tests/ref/lavf/ts b/tests/ref/lavf/ts index 989f8fbfba..325112cebc 100644 --- a/tests/ref/lavf/ts +++ b/tests/ref/lavf/ts @@ -1,3 +1,3 @@ -d260ac0534ff2e26b44b5192fd4fdc21 *./tests/data/lavf/lavf.ts +9708011dd80212a0041a96da878122c2 *./tests/data/lavf/lavf.ts 406644 ./tests/data/lavf/lavf.ts ./tests/data/lavf/lavf.ts CRC=0x133216c1 From 13551ad1e336573e3732fdeaf25607c47244bb80 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Jul 2011 22:42:18 +0200 Subject: [PATCH 495/780] lavf: fix segfault in av_open_input_stream() ic is NULL in case of error. --- libavformat/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index e738dba44a..71fa95526c 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -466,7 +466,8 @@ int av_open_input_stream(AVFormatContext **ic_ptr, else ic->pb = pb; - err = avformat_open_input(&ic, filename, fmt, &opts); + if ((err = avformat_open_input(&ic, filename, fmt, &opts)) < 0) + goto fail; ic->pb = ic->pb ? ic->pb : pb; // don't leak custom pb if it wasn't set above *ic_ptr = ic; From cdc5a3a194ac9275129ca88da005786ebaceb268 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 29 Jun 2011 14:13:17 -0700 Subject: [PATCH 496/780] mpeg1video: add CODEC_CAP_SLICE_THREADS. --- libavcodec/mpeg12.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 4cbfa8d636..059083277a 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -2539,7 +2539,7 @@ AVCodec ff_mpeg1video_decoder = { NULL, mpeg_decode_end, mpeg_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, + CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .flush= flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), From f501157e5352e418b28cf6728208ea028bf3505c Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 13 Jul 2011 15:49:08 -0400 Subject: [PATCH 497/780] ac3enc: fix memleak --- libavcodec/ac3enc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 809a3f5a4f..f957ee9258 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1820,6 +1820,8 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) av_freep(&s->band_psd_buffer); av_freep(&s->mask_buffer); av_freep(&s->qmant_buffer); + av_freep(&s->cpl_coord_exp_buffer); + av_freep(&s->cpl_coord_mant_buffer); for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { AC3Block *block = &s->blocks[blk]; av_freep(&block->mdct_coef); @@ -1830,6 +1832,8 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) av_freep(&block->band_psd); av_freep(&block->mask); av_freep(&block->qmant); + av_freep(&block->cpl_coord_exp); + av_freep(&block->cpl_coord_mant); } s->mdct_end(s->mdct); From 82cea7cb6c38e251f88fbf090cd5361f5d0a49de Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 13 Jul 2011 13:53:58 -0400 Subject: [PATCH 498/780] ac3enc: prefer passing AC3EncodeContext rather than AVCodecContext --- libavcodec/ac3enc.c | 23 ++++++++++++----------- libavcodec/ac3enc.h | 2 +- libavcodec/ac3enc_template.c | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index f957ee9258..f6a3b31160 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1535,10 +1535,10 @@ void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame) } -static void dprint_options(AVCodecContext *avctx) +static void dprint_options(AC3EncodeContext *s) { #ifdef DEBUG - AC3EncodeContext *s = avctx->priv_data; + AVCodecContext *avctx = s->avctx; AC3EncOptions *opt = &s->options; char strbuf[32]; @@ -1689,9 +1689,9 @@ static void validate_mix_level(void *log_ctx, const char *opt_name, * Validate metadata options as set by AVOption system. * These values can optionally be changed per-frame. */ -int ff_ac3_validate_metadata(AVCodecContext *avctx) +int ff_ac3_validate_metadata(AC3EncodeContext *s) { - AC3EncodeContext *s = avctx->priv_data; + AVCodecContext *avctx = s->avctx; AC3EncOptions *opt = &s->options; /* validate mixing levels */ @@ -1892,8 +1892,9 @@ static av_cold int set_channel_info(AC3EncodeContext *s, int channels, } -static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s) +static av_cold int validate_options(AC3EncodeContext *s) { + AVCodecContext *avctx = s->avctx; int i, ret, max_sr; /* validate channel layout */ @@ -1998,7 +1999,7 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s) } if (!s->eac3) { - ret = ff_ac3_validate_metadata(avctx); + ret = ff_ac3_validate_metadata(s); if (ret) return ret; } @@ -2085,10 +2086,10 @@ static av_cold void set_bandwidth(AC3EncodeContext *s) } -static av_cold int allocate_buffers(AVCodecContext *avctx) +static av_cold int allocate_buffers(AC3EncodeContext *s) { + AVCodecContext *avctx = s->avctx; int blk, ch; - AC3EncodeContext *s = avctx->priv_data; int channels = s->channels + 1; /* includes coupling channel */ if (s->allocate_sample_buffers(s)) @@ -2201,7 +2202,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) ff_ac3_common_init(); - ret = validate_options(avctx, s); + ret = validate_options(s); if (ret) return ret; @@ -2246,7 +2247,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) if (ret) goto init_fail; - ret = allocate_buffers(avctx); + ret = allocate_buffers(s); if (ret) goto init_fail; @@ -2255,7 +2256,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) dsputil_init(&s->dsp, avctx); ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT); - dprint_options(avctx); + dprint_options(s); return 0; init_fail: diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 54f427a523..ccef7079e4 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -243,7 +243,7 @@ int ff_ac3_encode_init(AVCodecContext *avctx); int ff_ac3_encode_close(AVCodecContext *avctx); -int ff_ac3_validate_metadata(AVCodecContext *avctx); +int ff_ac3_validate_metadata(AC3EncodeContext *s); void ff_ac3_adjust_frame_size(AC3EncodeContext *s); diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index c7243c7644..95c190b666 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -424,7 +424,7 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame, int ret; if (!s->eac3 && s->options.allow_per_frame_metadata) { - ret = ff_ac3_validate_metadata(avctx); + ret = ff_ac3_validate_metadata(s); if (ret) return ret; } From b5849f77095439e994b11c25e6063d443b36c228 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 13 Jul 2011 15:12:11 -0400 Subject: [PATCH 499/780] ac3enc: merge AC3MDCTContext with AC3EncodeContext. Since both the fixed-point and floating-point encoders use the FFTContext, this no longer needs to be in a separate context. Also, when a short-transform context is added, the same MDCT window will be used. --- libavcodec/ac3enc.c | 6 ++---- libavcodec/ac3enc.h | 22 ++++++++-------------- libavcodec/ac3enc_fixed.c | 11 +++++------ libavcodec/ac3enc_float.c | 17 ++++++++--------- libavcodec/ac3enc_template.c | 6 +++--- 5 files changed, 26 insertions(+), 36 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index f6a3b31160..fb4d33441e 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1836,8 +1836,7 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) av_freep(&block->cpl_coord_mant); } - s->mdct_end(s->mdct); - av_freep(&s->mdct); + s->mdct_end(s); av_freep(&avctx->coded_frame); return 0; @@ -2242,8 +2241,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) bit_alloc_init(s); - FF_ALLOCZ_OR_GOTO(avctx, s->mdct, sizeof(AC3MDCTContext), init_fail); - ret = s->mdct_init(avctx, s->mdct, 9); + ret = s->mdct_init(s); if (ret) goto init_fail; diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index ccef7079e4..6caf4d80c4 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -66,11 +66,6 @@ typedef int64_t CoefSumType; #endif -typedef struct AC3MDCTContext { - const SampleType *window; ///< MDCT window function - FFTContext fft; ///< FFT context for MDCT calculation -} AC3MDCTContext; - /** * Encoding Options used by AVOption. */ @@ -143,7 +138,8 @@ typedef struct AC3EncodeContext { PutBitContext pb; ///< bitstream writer context DSPContext dsp; AC3DSPContext ac3dsp; ///< AC-3 optimized functions - AC3MDCTContext *mdct; ///< MDCT context + FFTContext mdct; ///< FFT context for MDCT calculation + const SampleType *mdct_window; ///< MDCT window function array AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info @@ -226,8 +222,8 @@ typedef struct AC3EncodeContext { int ref_bap_set; ///< indicates if ref_bap pointers have been set /* fixed vs. float function pointers */ - void (*mdct_end)(AC3MDCTContext *mdct); - int (*mdct_init)(AVCodecContext *avctx, AC3MDCTContext *mdct, int nbits); + void (*mdct_end)(struct AC3EncodeContext *s); + int (*mdct_init)(struct AC3EncodeContext *s); /* fixed vs. float templated function pointers */ int (*allocate_sample_buffers)(struct AC3EncodeContext *s); @@ -262,13 +258,11 @@ void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame); /* prototypes for functions in ac3enc_fixed.c and ac3enc_float.c */ -void ff_ac3_fixed_mdct_end(AC3MDCTContext *mdct); -void ff_ac3_float_mdct_end(AC3MDCTContext *mdct); +void ff_ac3_fixed_mdct_end(AC3EncodeContext *s); +void ff_ac3_float_mdct_end(AC3EncodeContext *s); -int ff_ac3_fixed_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, - int nbits); -int ff_ac3_float_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, - int nbits); +int ff_ac3_fixed_mdct_init(AC3EncodeContext *s); +int ff_ac3_float_mdct_init(AC3EncodeContext *s); /* prototypes for functions in ac3enc_template.c */ diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index ea3a46cdfa..15c5a4bca7 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -41,9 +41,9 @@ static AVClass ac3enc_class = { "Fixed-Point AC-3 Encoder", av_default_item_name /** * Finalize MDCT and free allocated memory. */ -av_cold void AC3_NAME(mdct_end)(AC3MDCTContext *mdct) +av_cold void AC3_NAME(mdct_end)(AC3EncodeContext *s) { - ff_mdct_end(&mdct->fft); + ff_mdct_end(&s->mdct); } @@ -51,11 +51,10 @@ av_cold void AC3_NAME(mdct_end)(AC3MDCTContext *mdct) * Initialize MDCT tables. * @param nbits log2(MDCT size) */ -av_cold int AC3_NAME(mdct_init)(AVCodecContext *avctx, AC3MDCTContext *mdct, - int nbits) +av_cold int AC3_NAME(mdct_init)(AC3EncodeContext *s) { - int ret = ff_mdct_init(&mdct->fft, nbits, 0, -1.0); - mdct->window = ff_ac3_window; + int ret = ff_mdct_init(&s->mdct, 9, 0, -1.0); + s->mdct_window = ff_ac3_window; return ret; } diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 718cc1f2b2..deec79ce8f 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -45,10 +45,10 @@ static AVClass ac3enc_class = { "AC-3 Encoder", av_default_item_name, /** * Finalize MDCT and free allocated memory. */ -av_cold void ff_ac3_float_mdct_end(AC3MDCTContext *mdct) +av_cold void ff_ac3_float_mdct_end(AC3EncodeContext *s) { - ff_mdct_end(&mdct->fft); - av_freep(&mdct->window); + ff_mdct_end(&s->mdct); + av_freep(&s->mdct_window); } @@ -56,26 +56,25 @@ av_cold void ff_ac3_float_mdct_end(AC3MDCTContext *mdct) * Initialize MDCT tables. * @param nbits log2(MDCT size) */ -av_cold int ff_ac3_float_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, - int nbits) +av_cold int ff_ac3_float_mdct_init(AC3EncodeContext *s) { float *window; int i, n, n2; - n = 1 << nbits; + n = 1 << 9; n2 = n >> 1; window = av_malloc(n * sizeof(*window)); if (!window) { - av_log(avctx, AV_LOG_ERROR, "Cannot allocate memory.\n"); + av_log(s->avctx, AV_LOG_ERROR, "Cannot allocate memory.\n"); return AVERROR(ENOMEM); } ff_kbd_window_init(window, 5.0, n2); for (i = 0; i < n2; i++) window[n-1-i] = window[i]; - mdct->window = window; + s->mdct_window = window; - return ff_mdct_init(&mdct->fft, nbits, 0, -2.0 / n); + return ff_mdct_init(&s->mdct, 9, 0, -2.0 / n); } diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index 95c190b666..9b9151b3e0 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -108,13 +108,13 @@ static void apply_mdct(AC3EncodeContext *s) const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE]; apply_window(&s->dsp, s->windowed_samples, input_samples, - s->mdct->window, AC3_WINDOW_SIZE); + s->mdct_window, AC3_WINDOW_SIZE); if (s->fixed_point) block->coeff_shift[ch+1] = normalize_samples(s); - s->mdct->fft.mdct_calcw(&s->mdct->fft, block->mdct_coef[ch+1], - s->windowed_samples); + s->mdct.mdct_calcw(&s->mdct, block->mdct_coef[ch+1], + s->windowed_samples); } } } From 8e2d08551655e7838688e0c01619592acbc91dfc Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Jul 2011 16:18:45 +0200 Subject: [PATCH 500/780] ffmpeg: do not set GLOBAL_HEADER flag in the options context The removed lines have no effect, since the flag is set on all encoder for the given file and avcodec_opts are reset between files. --- ffmpeg.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index ccf9c62486..61e6858dc4 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3463,7 +3463,6 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) if(oc->oformat->flags & AVFMT_GLOBALHEADER) { video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; - avcodec_opts[AVMEDIA_TYPE_VIDEO]->flags|= CODEC_FLAG_GLOBAL_HEADER; } if (video_stream_copy) { @@ -3589,7 +3588,6 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) if (oc->oformat->flags & AVFMT_GLOBALHEADER) { audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; - avcodec_opts[AVMEDIA_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER; } if (audio_stream_copy) { st->stream_copy = 1; @@ -3640,7 +3638,6 @@ static void new_data_stream(AVFormatContext *oc, int file_idx) if (oc->oformat->flags & AVFMT_GLOBALHEADER) { data_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; - avcodec_opts[AVMEDIA_TYPE_DATA]->flags |= CODEC_FLAG_GLOBAL_HEADER; } if (data_stream_copy) { st->stream_copy = 1; @@ -3683,7 +3680,6 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) if (oc->oformat->flags & AVFMT_GLOBALHEADER) { subtitle_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; - avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->flags |= CODEC_FLAG_GLOBAL_HEADER; } if (subtitle_stream_copy) { st->stream_copy = 1; From a9eb4f0899de04a3093a04f461611c6f0664398e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Jul 2011 17:18:42 +0200 Subject: [PATCH 501/780] ffmpeg: check experimental flag after codec is opened. This doesn't access avcodec_opts, so it will work with the new options passing system. --- ffmpeg.c | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 61e6858dc4..600df65657 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -509,6 +509,23 @@ static void assert_avoptions(AVDictionary *m) } } +static void assert_codec_experimental(AVCodecContext *c, int encoder) +{ + const char *codec_string = encoder ? "encoder" : "decoder"; + AVCodec *codec; + if (c->codec->capabilities & CODEC_CAP_EXPERIMENTAL && + c->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { + av_log(NULL, AV_LOG_ERROR, "%s '%s' is experimental and might produce bad " + "results.\nAdd '-strict experimental' if you want to use it.\n", + codec_string, c->codec->name); + codec = encoder ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id); + if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) + av_log(NULL, AV_LOG_ERROR, "Or use the non experimental %s '%s'.\n", + codec_string, codec->name); + ffmpeg_exit(1); + } +} + /* similar to ff_dynarray_add() and av_fast_realloc() */ static void *grow_array(void *array, int elem_size, int *size, int new_size) { @@ -2324,6 +2341,7 @@ static int transcode(AVFormatContext **output_files, ret = AVERROR(EINVAL); goto dump_format; } + assert_codec_experimental(ost->st->codec, 1); extra_size += ost->st->codec->extradata_size; } } @@ -2358,6 +2376,7 @@ static int transcode(AVFormatContext **output_files, ret = AVERROR(EINVAL); goto dump_format; } + assert_codec_experimental(ist->st->codec, 0); //if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) // ist->st->codec->flags |= CODEC_FLAG_REPEAT_FIELD; } @@ -3114,7 +3133,7 @@ static int opt_input_ts_offset(const char *opt, const char *arg) return 0; } -static enum CodecID find_codec_or_die(const char *name, int type, int encoder, int strict) +static enum CodecID find_codec_or_die(const char *name, int type, int encoder) { const char *codec_string = encoder ? "encoder" : "decoder"; AVCodec *codec; @@ -3132,19 +3151,6 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder, i fprintf(stderr, "Invalid %s type '%s'\n", codec_string, name); ffmpeg_exit(1); } - if(codec->capabilities & CODEC_CAP_EXPERIMENTAL && - strict > FF_COMPLIANCE_EXPERIMENTAL) { - fprintf(stderr, "%s '%s' is experimental and might produce bad " - "results.\nAdd '-strict experimental' if you want to use it.\n", - codec_string, codec->name); - codec = encoder ? - avcodec_find_encoder(codec->id) : - avcodec_find_decoder(codec->id); - if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) - fprintf(stderr, "Or use the non experimental %s '%s'.\n", - codec_string, codec->name); - ffmpeg_exit(1); - } return codec->id; } @@ -3196,14 +3202,11 @@ static int opt_input_file(const char *opt, const char *filename) av_dict_set(&format_opts, "pixel_format", av_get_pix_fmt_name(frame_pix_fmt), 0); ic->video_codec_id = - find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0, - avcodec_opts[AVMEDIA_TYPE_VIDEO ]->strict_std_compliance); + find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0); ic->audio_codec_id = - find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0, - avcodec_opts[AVMEDIA_TYPE_AUDIO ]->strict_std_compliance); + find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0); ic->subtitle_codec_id= - find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0, - avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); + find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0); ic->flags |= AVFMT_FLAG_NONBLOCK; /* open the input file with generic libav function */ @@ -3431,8 +3434,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) if(!video_stream_copy){ if (video_codec_name) { - codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1, - avcodec_opts[AVMEDIA_TYPE_VIDEO]->strict_std_compliance); + codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1); codec = avcodec_find_encoder_by_name(video_codec_name); } else { codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO); @@ -3564,8 +3566,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) if(!audio_stream_copy){ if (audio_codec_name) { - codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1, - avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance); + codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1); codec = avcodec_find_encoder_by_name(audio_codec_name); } else { codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO); @@ -3658,8 +3659,7 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) if(!subtitle_stream_copy){ if (subtitle_codec_name) { - codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, - avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); + codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1); codec = avcodec_find_encoder_by_name(subtitle_codec_name); } else { codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE); From 8c8eab8bfed74cceb4a04f982f349c7c17f5eb6f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 10 Jul 2011 15:46:15 +0200 Subject: [PATCH 502/780] cmdutils: store all codec options in one dict instead of video/audio/sub Split them when codec id is known. --- cmdutils.c | 55 +++++++++++++++++++++++++++++++++--------------------- cmdutils.h | 7 ++++++- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 2124ca1439..a2fe103f9b 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -55,7 +55,7 @@ static int opt_name_count; AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; AVFormatContext *avformat_opts; struct SwsContext *sws_opts; -AVDictionary *format_opts, *video_opts, *audio_opts, *sub_opts; +AVDictionary *format_opts, *codec_opts; static const int this_year = 2011; @@ -93,9 +93,7 @@ void uninit_opts(void) av_freep(&opt_values); opt_name_count = 0; av_dict_free(&format_opts); - av_dict_free(&video_opts); - av_dict_free(&audio_opts); - av_dict_free(&sub_opts); + av_dict_free(&codec_opts); } void log_callback_help(void* ptr, int level, const char* fmt, va_list vl) @@ -299,20 +297,14 @@ unknown_opt: } #define FLAGS (o->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0 -#define SET_PREFIXED_OPTS(ch, flag, output) \ - if (opt[0] == ch && avcodec_opts[0] && (o = av_opt_find(avcodec_opts[0], opt+1, NULL, flag, 0)))\ - av_dict_set(&output, opt+1, arg, FLAGS); static int opt_default2(const char *opt, const char *arg) { const AVOption *o; - if ((o = av_opt_find(avcodec_opts[0], opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) { - if (o->flags & AV_OPT_FLAG_VIDEO_PARAM) - av_dict_set(&video_opts, opt, arg, FLAGS); - if (o->flags & AV_OPT_FLAG_AUDIO_PARAM) - av_dict_set(&audio_opts, opt, arg, FLAGS); - if (o->flags & AV_OPT_FLAG_SUBTITLE_PARAM) - av_dict_set(&sub_opts, opt, arg, FLAGS); - } else if ((o = av_opt_find(avformat_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) + if ((o = av_opt_find(avcodec_opts[0], opt, NULL, 0, AV_OPT_SEARCH_CHILDREN)) || + ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && + (o = av_opt_find(avcodec_opts[0], opt+1, NULL, 0, 0)))) + av_dict_set(&codec_opts, opt, arg, FLAGS); + else if ((o = av_opt_find(avformat_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) av_dict_set(&format_opts, opt, arg, FLAGS); else if ((o = av_opt_find(sws_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) { // XXX we only support sws_flags, not arbitrary sws options @@ -323,12 +315,6 @@ static int opt_default2(const char *opt, const char *arg) } } - if (!o) { - SET_PREFIXED_OPTS('v', AV_OPT_FLAG_VIDEO_PARAM, video_opts) - SET_PREFIXED_OPTS('a', AV_OPT_FLAG_AUDIO_PARAM, audio_opts) - SET_PREFIXED_OPTS('s', AV_OPT_FLAG_SUBTITLE_PARAM, sub_opts) - } - if (o) return 0; fprintf(stderr, "Unrecognized option '%s'\n", opt); @@ -899,6 +885,33 @@ FILE *get_preset_file(char *filename, size_t filename_size, return f; } +AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, int encoder) +{ + AVDictionary *ret = NULL; + AVDictionaryEntry *t = NULL; + AVCodec *codec = encoder ? avcodec_find_encoder(codec_id) : avcodec_find_decoder(codec_id); + int flags = encoder ? AV_OPT_FLAG_ENCODING_PARAM : AV_OPT_FLAG_DECODING_PARAM; + char prefix = 0; + + if (!codec) + return NULL; + + switch (codec->type) { + case AVMEDIA_TYPE_VIDEO: prefix = 'v'; flags |= AV_OPT_FLAG_VIDEO_PARAM; break; + case AVMEDIA_TYPE_AUDIO: prefix = 'a'; flags |= AV_OPT_FLAG_AUDIO_PARAM; break; + case AVMEDIA_TYPE_SUBTITLE: prefix = 's'; flags |= AV_OPT_FLAG_SUBTITLE_PARAM; break; + } + + while (t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX)) { + if (av_opt_find(avcodec_opts[0], t->key, NULL, flags, 0) || + (codec && codec->priv_class && av_opt_find(&codec->priv_class, t->key, NULL, flags, 0))) + av_dict_set(&ret, t->key, t->value, 0); + else if (t->key[0] == prefix && av_opt_find(avcodec_opts[0], t->key+1, NULL, flags, 0)) + av_dict_set(&ret, t->key+1, t->value, 0); + } + return ret; +} + #if CONFIG_AVFILTER static int ffsink_init(AVFilterContext *ctx, const char *args, void *opaque) diff --git a/cmdutils.h b/cmdutils.h index 02fcea4426..c581160318 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -43,7 +43,7 @@ extern const char **opt_names; extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; extern AVFormatContext *avformat_opts; extern struct SwsContext *sws_opts; -extern AVDictionary *format_opts, *video_opts, *audio_opts, *sub_opts; +extern AVDictionary *format_opts, *codec_opts; /** * Initialize the cmdutils option system, in particular @@ -151,6 +151,11 @@ void parse_options(int argc, char **argv, const OptionDef *options, void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec); +/** + * Filter out options for given codec. + */ +AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, int encoder); + /** * Print an error message to stderr, indicating filename and a human * readable description of the error code err. From 3009f521f390b2bd440d9747a9c6baf648b2087a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 25 May 2011 16:59:51 +0200 Subject: [PATCH 503/780] ffplay: use new avcodec_open2 and avformat_find_stream_info API. --- cmdutils.c | 17 +++++++++++++++++ cmdutils.h | 5 +++++ ffplay.c | 38 ++++++++++++++++++-------------------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index a2fe103f9b..b375378af9 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -912,6 +912,23 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, int e return ret; } +AVDictionary **setup_find_stream_info_opts(AVFormatContext *s) +{ + int i; + AVDictionary **opts; + + if (!s->nb_streams) + return NULL; + opts = av_mallocz(s->nb_streams * sizeof(*opts)); + if (!opts) { + av_log(NULL, AV_LOG_ERROR, "Could not alloc memory for stream options.\n"); + return NULL; + } + for (i = 0; i < s->nb_streams; i++) + opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codec->codec_id, 0); + return opts; +} + #if CONFIG_AVFILTER static int ffsink_init(AVFilterContext *ctx, const char *args, void *opaque) diff --git a/cmdutils.h b/cmdutils.h index c581160318..ae512b0f1a 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -156,6 +156,11 @@ void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec); */ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, int encoder); +/* + * Setup AVCodecContext options for avformat_find_stream_info. + */ +AVDictionary **setup_find_stream_info_opts(AVFormatContext *s); + /** * Print an error message to stderr, indicating filename and a human * readable description of the error code err. diff --git a/ffplay.c b/ffplay.c index bbbf5c6032..878ae833ef 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2130,11 +2130,15 @@ static int stream_component_open(VideoState *is, int stream_index) AVCodecContext *avctx; AVCodec *codec; SDL_AudioSpec wanted_spec, spec; + AVDictionary *opts; + AVDictionaryEntry *t = NULL; if (stream_index < 0 || stream_index >= ic->nb_streams) return -1; avctx = ic->streams[stream_index]->codec; + opts = filter_codec_opts(codec_opts, avctx->codec_id, 0); + /* prepare audio output */ if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { if (avctx->channels > 0) { @@ -2159,11 +2163,13 @@ static int stream_component_open(VideoState *is, int stream_index) avctx->error_concealment= error_concealment; avctx->thread_count= thread_count; - set_context_opts(avctx, avcodec_opts[avctx->codec_type], 0, codec); - if (!codec || - avcodec_open(avctx, codec) < 0) + avcodec_open2(avctx, codec, &opts) < 0) return -1; + if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); + return AVERROR_OPTION_NOT_FOUND; + } /* prepare audio output */ if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { @@ -2313,6 +2319,8 @@ static int decode_thread(void *arg) int eof=0; int pkt_in_play_range = 0; AVDictionaryEntry *t; + AVDictionary **opts; + int orig_nb_streams; memset(st_index, -1, sizeof(st_index)); is->video_stream = -1; @@ -2338,29 +2346,19 @@ static int decode_thread(void *arg) if(genpts) ic->flags |= AVFMT_FLAG_GENPTS; - /* Set AVCodecContext options so they will be seen by av_find_stream_info() */ - for (i = 0; i < ic->nb_streams; i++) { - AVCodecContext *dec = ic->streams[i]->codec; - switch (dec->codec_type) { - case AVMEDIA_TYPE_AUDIO: - set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], - AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, - NULL); - break; - case AVMEDIA_TYPE_VIDEO: - set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_VIDEO], - AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, - NULL); - break; - } - } + opts = setup_find_stream_info_opts(ic); + orig_nb_streams = ic->nb_streams; - err = av_find_stream_info(ic); + err = avformat_find_stream_info(ic, opts); if (err < 0) { fprintf(stderr, "%s: could not find codec parameters\n", is->filename); ret = -1; goto fail; } + for (i = 0; i < orig_nb_streams; i++) + av_dict_free(&opts[i]); + av_freep(&opts); + if(ic->pb) ic->pb->eof_reached= 0; //FIXME hack, ffplay maybe should not use url_feof() to test for the end From bf174a70cde333eba7e27063f9ce44497108f466 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 25 May 2011 17:29:25 +0200 Subject: [PATCH 504/780] ffmpeg: use new avcodec_open2 and avformat_find_stream_info API. --- ffmpeg.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 600df65657..5446be9ca4 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -291,6 +291,7 @@ typedef struct OutputStream { #endif int sws_flags; + AVDictionary *opts; } OutputStream; static OutputStream **output_streams_for_file[MAX_FILES] = { NULL }; @@ -312,6 +313,7 @@ typedef struct InputStream { int is_start; /* is 1 at the start and after a discontinuity */ int showed_multi_packet_warning; int is_past_recording_time; + AVDictionary *opts; } InputStream; typedef struct InputFile { @@ -459,6 +461,8 @@ static int ffmpeg_exit(int ret) for(i=0;iindex = idx; ost->st = st; ost->enc = codec; + if (codec) + ost->opts = filter_codec_opts(codec_opts, codec->id, 1); avcodec_get_context_defaults3(st->codec, codec); @@ -2335,13 +2341,14 @@ static int transcode(AVFormatContext **output_files, memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } - if (avcodec_open(ost->st->codec, codec) < 0) { + if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ost->st->codec, 1); + assert_avoptions(ost->opts); extra_size += ost->st->codec->extradata_size; } } @@ -2370,13 +2377,14 @@ static int transcode(AVFormatContext **output_files, } } - if (avcodec_open(ist->st->codec, codec) < 0) { + if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) { snprintf(error, sizeof(error), "Error while opening decoder for input stream #%d.%d", ist->file_index, ist->st->index); ret = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ist->st->codec, 0); + assert_avoptions(ost->opts); //if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) // ist->st->codec->flags |= CODEC_FLAG_REPEAT_FIELD; } @@ -2740,6 +2748,7 @@ static int transcode(AVFormatContext **output_files, audio_resample_close(ost->resample); if (ost->reformat_ctx) av_audio_convert_free(ost->reformat_ctx); + av_dict_free(&ost->opts); av_free(ost); } } @@ -3161,6 +3170,8 @@ static int opt_input_file(const char *opt, const char *filename) int err, i, ret, rfps, rfps_base; int64_t timestamp; uint8_t buf[128]; + AVDictionary **opts; + int orig_nb_streams; // number of streams before avformat_find_stream_info if (last_asked_format) { if (!(file_iformat = av_find_input_format(last_asked_format))) { @@ -3246,26 +3257,13 @@ static int opt_input_file(const char *opt, const char *filename) ic->loop_input = loop_input; } - /* Set AVCodecContext options so they will be seen by av_find_stream_info() */ - for (i = 0; i < ic->nb_streams; i++) { - AVCodecContext *dec = ic->streams[i]->codec; - switch (dec->codec_type) { - case AVMEDIA_TYPE_AUDIO: - set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], - AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, - NULL); - break; - case AVMEDIA_TYPE_VIDEO: - set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_VIDEO], - AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, - NULL); - break; - } - } + /* Set AVCodecContext options for avformat_find_stream_info */ + opts = setup_find_stream_info_opts(ic); + orig_nb_streams = ic->nb_streams; /* If not enough info to get the stream parameters, we decode the first frames to get it. (used in mpeg case for example) */ - ret = av_find_stream_info(ic); + ret = avformat_find_stream_info(ic, opts); if (ret < 0 && verbose >= 0) { fprintf(stderr, "%s: could not find codec parameters\n", filename); av_close_input_file(ic); @@ -3301,6 +3299,7 @@ static int opt_input_file(const char *opt, const char *filename) ist->st = st; ist->file_index = nb_input_files; ist->discard = 1; + ist->opts = filter_codec_opts(codec_opts, ist->st->codec->codec_id, 0); if (i < nb_ts_scale) ist->ts_scale = ts_scale[i]; @@ -3308,13 +3307,11 @@ static int opt_input_file(const char *opt, const char *filename) switch (dec->codec_type) { case AVMEDIA_TYPE_AUDIO: ist->dec = avcodec_find_decoder_by_name(audio_codec_name); - set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, ist->dec); if(audio_disable) st->discard= AVDISCARD_ALL; break; case AVMEDIA_TYPE_VIDEO: ist->dec = avcodec_find_decoder_by_name(video_codec_name); - set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, ist->dec); rfps = ic->streams[i]->r_frame_rate.num; rfps_base = ic->streams[i]->r_frame_rate.den; if (dec->lowres) { @@ -3373,6 +3370,9 @@ static int opt_input_file(const char *opt, const char *filename) av_freep(&ts_scale); nb_ts_scale = 0; + for (i = 0; i < orig_nb_streams; i++) + av_dict_free(&opts[i]); + av_freep(&opts); av_freep(&video_codec_name); av_freep(&audio_codec_name); av_freep(&subtitle_codec_name); @@ -3467,9 +3467,9 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; } + video_enc->codec_type = AVMEDIA_TYPE_VIDEO; if (video_stream_copy) { st->stream_copy = 1; - video_enc->codec_type = AVMEDIA_TYPE_VIDEO; video_enc->sample_aspect_ratio = st->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255); } else { @@ -3479,7 +3479,6 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) if (frame_rate.num) ost->frame_rate = frame_rate; video_enc->codec_id = codec_id; - set_context_opts(video_enc, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); video_enc->width = frame_width; video_enc->height = frame_height; @@ -3594,7 +3593,6 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) st->stream_copy = 1; } else { audio_enc->codec_id = codec_id; - set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); if (audio_qscale > QSCALE_NONE) { audio_enc->flags |= CODEC_FLAG_QSCALE; @@ -3685,7 +3683,6 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) st->stream_copy = 1; } else { subtitle_enc->codec_id = codec_id; - set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); } if (subtitle_language) { From 35d2e4e5c395bdb5b581e9caede63c7fc7a36138 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 25 May 2011 17:30:23 +0200 Subject: [PATCH 505/780] cmdutils: replace opt_default with opt_default2() and remove set_context_opts --- cmdutils.c | 108 +---------------------------------------------------- cmdutils.h | 3 -- 2 files changed, 1 insertion(+), 110 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index b375378af9..19c5d72857 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -49,9 +49,6 @@ #include #endif -const char **opt_names; -const char **opt_values; -static int opt_name_count; AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; AVFormatContext *avformat_opts; struct SwsContext *sws_opts; @@ -81,17 +78,6 @@ void uninit_opts(void) sws_freeContext(sws_opts); sws_opts = NULL; #endif - for (i = 0; i < opt_name_count; i++) { - //opt_values are only stored for codec-specific options in which case - //both the name and value are dup'd - if (opt_values[i]) { - av_freep(&opt_names[i]); - av_freep(&opt_values[i]); - } - } - av_freep(&opt_names); - av_freep(&opt_values); - opt_name_count = 0; av_dict_free(&format_opts); av_dict_free(&codec_opts); } @@ -297,7 +283,7 @@ unknown_opt: } #define FLAGS (o->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0 -static int opt_default2(const char *opt, const char *arg) +int opt_default(const char *opt, const char *arg) { const AVOption *o; if ((o = av_opt_find(avcodec_opts[0], opt, NULL, 0, AV_OPT_SEARCH_CHILDREN)) || @@ -321,66 +307,6 @@ static int opt_default2(const char *opt, const char *arg) return AVERROR_OPTION_NOT_FOUND; } -int opt_default(const char *opt, const char *arg){ - int type; - int ret= 0; - const AVOption *o= NULL; - int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0}; - - for(type=0; *avcodec_opts && type= 0; type++){ - const AVOption *o2 = av_opt_find(avcodec_opts[0], opt, NULL, opt_types[type], 0); - if(o2) - ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o); - } - if(!o && avformat_opts) - ret = av_set_string3(avformat_opts, opt, arg, 1, &o); - if(!o && sws_opts) - ret = av_set_string3(sws_opts, opt, arg, 1, &o); - if(!o){ - if (opt[0] == 'a' && avcodec_opts[AVMEDIA_TYPE_AUDIO]) - ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o); - else if(opt[0] == 'v' && avcodec_opts[AVMEDIA_TYPE_VIDEO]) - ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o); - else if(opt[0] == 's' && avcodec_opts[AVMEDIA_TYPE_SUBTITLE]) - ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o); - } - if (o && ret < 0) { - fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt); - exit(1); - } - if (!o) { - AVCodec *p = NULL; - AVOutputFormat *oformat = NULL; - while ((p=av_codec_next(p))){ - const AVClass *c = p->priv_class; - if(c && av_opt_find(&c, opt, NULL, 0, 0)) - break; - } - if (!p) { - while ((oformat = av_oformat_next(oformat))) { - const AVClass *c = oformat->priv_class; - if (c && av_opt_find(&c, opt, NULL, 0, 0)) - break; - } - } - } - - if ((ret = opt_default2(opt, arg)) < 0) - return ret; - -// av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avcodec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL)); - - //FIXME we should always use avcodec_opts, ... for storing options so there will not be any need to keep track of what i set over this - opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1)); - opt_values[opt_name_count]= o ? NULL : av_strdup(arg); - opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1)); - opt_names[opt_name_count++]= o ? o->name : av_strdup(opt); - - if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug)) - av_log_set_level(AV_LOG_DEBUG); - return 0; -} - int opt_loglevel(const char *opt, const char *arg) { const struct { const char *name; int level; } log_levels[] = { @@ -429,38 +355,6 @@ int opt_timelimit(const char *opt, const char *arg) return 0; } -void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec) -{ - int i; - void *priv_ctx=NULL; - if(!strcmp("AVCodecContext", (*(AVClass**)ctx)->class_name)){ - AVCodecContext *avctx= ctx; - if(codec && codec->priv_class && avctx->priv_data){ - priv_ctx= avctx->priv_data; - } - } else if (!strcmp("AVFormatContext", (*(AVClass**)ctx)->class_name)) { - AVFormatContext *avctx = ctx; - if (avctx->oformat && avctx->oformat->priv_class) { - priv_ctx = avctx->priv_data; - } - } - - for(i=0; iflags & flags) == flags)) - av_set_string3(ctx, opt_names[i], str, 1, NULL); - /* We need to use a differnt system to pass options to the private context because - it is not known which codec and thus context kind that will be when parsing options - we thus use opt_values directly instead of opts_ctx */ - if(!str && priv_ctx && av_get_string(priv_ctx, opt_names[i], &opt, buf, sizeof(buf))){ - av_set_string3(priv_ctx, opt_names[i], opt_values[i], 1, NULL); - } - } -} - void print_error(const char *filename, int err) { char errbuf[128]; diff --git a/cmdutils.h b/cmdutils.h index ae512b0f1a..a47f15785d 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -39,7 +39,6 @@ extern const char program_name[]; */ extern const int program_birth_year; -extern const char **opt_names; extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; extern AVFormatContext *avformat_opts; extern struct SwsContext *sws_opts; @@ -149,8 +148,6 @@ void show_help_options(const OptionDef *options, const char *msg, int mask, int void parse_options(int argc, char **argv, const OptionDef *options, void (* parse_arg_function)(const char*)); -void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec); - /** * Filter out options for given codec. */ From 6b61920ab76dc6d85ef462909951923935dd643f Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Jul 2011 18:13:10 +0200 Subject: [PATCH 506/780] lavfi: port boxblur filter from libmpcodecs With the following additions: * support to gray format * support to yuva420p format * parametric luma/chroma/alpha radius * consistency check on the radius values, avoid crashes with invalid values --- Changelog | 1 + configure | 1 + doc/filters.texi | 60 +++++++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/avfilter.h | 4 +- libavfilter/vf_boxblur.c | 350 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 416 insertions(+), 2 deletions(-) create mode 100644 libavfilter/vf_boxblur.c diff --git a/Changelog b/Changelog index 3ba34c3fcc..f1d5654138 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ releases are sorted from youngest to oldest. version next: - openal input device added +- boxblur filter added version 0.8: diff --git a/configure b/configure index f62db07702..ee8180f8ce 100755 --- a/configure +++ b/configure @@ -1497,6 +1497,7 @@ udp_protocol_deps="network" # filters blackframe_filter_deps="gpl" +boxblur_filter_deps="gpl" cropdetect_filter_deps="gpl" drawtext_filter_deps="libfreetype" frei0r_filter_deps="frei0r dlopen strtok_r" diff --git a/doc/filters.texi b/doc/filters.texi index 2ac4231be9..2c8d6e7565 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -183,6 +183,66 @@ threshold, and defaults to 98. @var{threshold} is the threshold below which a pixel value is considered black, and defaults to 32. +@section boxblur + +Apply boxblur algorithm to the input video. + +This filter accepts the parameters: +@var{luma_power}:@var{luma_radius}:@var{chroma_radius}:@var{chroma_power}:@var{alpha_radius}:@var{alpha_power} + +Chroma and alpha parameters are optional, if not specified they default +to the corresponding values set for @var{luma_radius} and +@var{luma_power}. + +@var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent +the radius in pixels of the box used for blurring the corresponding +input plane. They are expressions, and can contain the following +constants: +@table @option +@item w, h +the input width and heigth in pixels + +@item cw, ch +the input chroma image width and height in pixels + +@item hsub, vsub +horizontal and vertical chroma subsample values. For example for the +pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. +@end table + +The radius must be a non-negative number, and must be not greater than +the value of the expression @code{min(w,h)/2} for the luma and alpha planes, +and of @code{min(cw,ch)/2} for the chroma planes. + +@var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent +how many times the boxblur filter is applied to the corresponding +plane. + +Some examples follow: + +@itemize + +@item +Apply a boxblur filter with luma, chroma, and alpha radius +set to 2: +@example +boxblur=2:1 +@end example + +@item +Set luma radius to 2, alpha and chroma radius to 0 +@example +boxblur=2:1:0:0:0:0 +@end example + +@item +Set luma and chroma radius to a fraction of the video dimension +@example +boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1 +@end example + +@end itemize + @section copy Copy the input source unchanged to the output. Mainly useful for diff --git a/libavfilter/Makefile b/libavfilter/Makefile index a8233fd764..e29fe5eabd 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -25,6 +25,7 @@ OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o OBJS-$(CONFIG_ANULLSINK_FILTER) += asink_anullsink.o OBJS-$(CONFIG_BLACKFRAME_FILTER) += vf_blackframe.o +OBJS-$(CONFIG_BOXBLUR_FILTER) += vf_boxblur.o OBJS-$(CONFIG_COPY_FILTER) += vf_copy.o OBJS-$(CONFIG_CROP_FILTER) += vf_crop.o OBJS-$(CONFIG_CROPDETECT_FILTER) += vf_cropdetect.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index feae239626..8d80957cff 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -41,6 +41,7 @@ void avfilter_register_all(void) REGISTER_FILTER (ANULLSINK, anullsink, asink); REGISTER_FILTER (BLACKFRAME, blackframe, vf); + REGISTER_FILTER (BOXBLUR, boxblur, vf); REGISTER_FILTER (COPY, copy, vf); REGISTER_FILTER (CROP, crop, vf); REGISTER_FILTER (CROPDETECT, cropdetect, vf); diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 362bbfe2e5..3e1acea542 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -29,8 +29,8 @@ #include "libavutil/rational.h" #define LIBAVFILTER_VERSION_MAJOR 2 -#define LIBAVFILTER_VERSION_MINOR 24 -#define LIBAVFILTER_VERSION_MICRO 4 +#define LIBAVFILTER_VERSION_MINOR 25 +#define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c new file mode 100644 index 0000000000..7fb1ec5ba2 --- /dev/null +++ b/libavfilter/vf_boxblur.c @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2002 Michael Niedermayer + * Copyright (c) 2011 Stefano Sabatini + * + * This file is part of FFmpeg. + * + * FFmpeg 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. + * + * FFmpeg 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 FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * @file + * Apply a boxblur filter to the input video. + * Ported from MPlayer libmpcodecs/vf_boxblur.c. + */ + +#include "libavutil/avstring.h" +#include "libavutil/eval.h" +#include "libavutil/pixdesc.h" +#include "avfilter.h" + +static const char *var_names[] = { + "w", + "h", + "cw", + "ch", + "hsub", + "vsub", + NULL +}; + +enum var_name { + VAR_W, + VAR_H, + VAR_CW, + VAR_CH, + VAR_HSUB, + VAR_VSUB, + VARS_NB +}; + +typedef struct { + int radius; + int power; +} FilterParam; + +typedef struct { + FilterParam luma_param; + FilterParam chroma_param; + FilterParam alpha_param; + char luma_radius_expr [256]; + char chroma_radius_expr[256]; + char alpha_radius_expr [256]; + + int hsub, vsub; + int radius[4]; + int power[4]; + uint8_t *temp[2]; ///< temporary buffer used in blur_power() +} BoxBlurContext; + +#define Y 0 +#define U 1 +#define V 2 +#define A 3 + +static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) +{ + BoxBlurContext *boxblur = ctx->priv; + int e; + + if (!args) { + av_log(ctx, AV_LOG_ERROR, + "Filter expects 2 or 4 arguments, none provided\n"); + return AVERROR(EINVAL); + } + + e = sscanf(args, "%255[^:]:%d:%255[^:]:%d:%255[^:]:%d", + boxblur->luma_radius_expr, &boxblur->luma_param .power, + boxblur->chroma_radius_expr, &boxblur->chroma_param.power, + boxblur->alpha_radius_expr, &boxblur->alpha_param .power); + + if (e != 2 && e != 4 && e != 6) { + av_log(ctx, AV_LOG_ERROR, + "Filter expects 2 or 4 or 6 params, provided %d\n", e); + return AVERROR(EINVAL); + } + + if (e < 4) { + boxblur->chroma_param.power = boxblur->luma_param.power; + av_strlcpy(boxblur->chroma_radius_expr, boxblur->luma_radius_expr, + sizeof(boxblur->chroma_radius_expr)); + } + if (e < 6) { + boxblur->alpha_param.power = boxblur->luma_param.power; + av_strlcpy(boxblur->alpha_radius_expr, boxblur->luma_radius_expr, + sizeof(boxblur->alpha_radius_expr)); + } + + return 0; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + BoxBlurContext *boxblur = ctx->priv; + + av_freep(&boxblur->temp[0]); + av_freep(&boxblur->temp[1]); +} + +static int query_formats(AVFilterContext *ctx) +{ + enum PixelFormat pix_fmts[] = { + PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, + PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_YUVA420P, + PIX_FMT_YUV440P, PIX_FMT_GRAY8, + PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P, + PIX_FMT_YUVJ440P, + PIX_FMT_NONE + }; + + avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); + return 0; +} + +static int config_input(AVFilterLink *inlink) +{ + AVFilterContext *ctx = inlink->dst; + BoxBlurContext *boxblur = ctx->priv; + const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[inlink->format]; + int w = inlink->w, h = inlink->h; + int cw, ch; + double var_values[VARS_NB], res; + char *expr; + int ret; + + if (!(boxblur->temp[0] = av_malloc(w)) || + !(boxblur->temp[1] = av_malloc(w))) + return AVERROR(ENOMEM); + + boxblur->hsub = desc->log2_chroma_w; + boxblur->vsub = desc->log2_chroma_h; + + var_values[VAR_W] = inlink->w; + var_values[VAR_H] = inlink->h; + var_values[VAR_CW] = cw = w>>boxblur->hsub; + var_values[VAR_CH] = ch = h>>boxblur->vsub; + var_values[VAR_HSUB] = 1<hsub; + var_values[VAR_VSUB] = 1<vsub; + +#define EVAL_RADIUS_EXPR(comp) \ + expr = boxblur->comp##_radius_expr; \ + ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \ + NULL, NULL, NULL, NULL, NULL, 0, ctx); \ + boxblur->comp##_param.radius = res; \ + if (ret < 0) { \ + av_log(NULL, AV_LOG_ERROR, \ + "Error when evaluating " #comp " radius expression '%s'\n", expr); \ + return ret; \ + } + EVAL_RADIUS_EXPR(luma); + EVAL_RADIUS_EXPR(chroma); + EVAL_RADIUS_EXPR(alpha); + + av_log(ctx, AV_LOG_INFO, + "luma_radius:%d luma_power:%d " + "chroma_radius:%d chroma_power:%d " + "alpha_radius:%d alpha_power:%d " + "w:%d chroma_w:%d h:%d chroma_h:%d\n", + boxblur->luma_param .radius, boxblur->luma_param .power, + boxblur->chroma_param.radius, boxblur->chroma_param.power, + boxblur->alpha_param .radius, boxblur->alpha_param .power, + w, cw, h, ch); + +#define CHECK_RADIUS_VAL(w_, h_, comp) \ + if (boxblur->comp##_param.radius < 0 || \ + 2*boxblur->comp##_param.radius > FFMIN(w_, h_)) { \ + av_log(ctx, AV_LOG_ERROR, \ + "Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \ + boxblur->comp##_param.radius, FFMIN(w_, h_)/2); \ + return AVERROR(EINVAL); \ + } + CHECK_RADIUS_VAL(w, h, luma); + CHECK_RADIUS_VAL(cw, ch, chroma); + CHECK_RADIUS_VAL(w, h, alpha); + + boxblur->radius[Y] = boxblur->luma_param.radius; + boxblur->radius[U] = boxblur->radius[V] = boxblur->chroma_param.radius; + boxblur->radius[A] = boxblur->alpha_param.radius; + + boxblur->power[Y] = boxblur->luma_param.power; + boxblur->power[U] = boxblur->power[V] = boxblur->chroma_param.power; + boxblur->power[A] = boxblur->alpha_param.power; + + return 0; +} + +static inline void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_step, + int w, int radius) +{ + /* Naive boxblur would sum source pixels from x-radius .. x+radius + * for destination pixel x. That would be O(radius*width). + * If you now look at what source pixels represent 2 consecutive + * output pixels, then you see they are almost identical and only + * differ by 2 pixels, like: + * src0 111111111 + * dst0 1 + * src1 111111111 + * dst1 1 + * src0-src1 1 -1 + * so when you know one output pixel you can find the next by just adding + * and subtracting 1 input pixel. + * The following code adopts this faster variant. + */ + int x, sum = 0; + const int length = radius*2 + 1; + const int inv = ((1<<16) + length/2)/length; + + for (x = 0; x < radius; x++) + sum += src[x*src_step]<<1; + sum += src[radius*src_step]; + + for (x = 0; x <= radius; x++) { + sum += src[(radius+x)*src_step] - src[(radius-x)*src_step]; + dst[x*dst_step] = (sum*inv + (1<<15))>>16; + } + + for (; x < w-radius; x++) { + sum += src[(radius+x)*src_step] - src[(x-radius-1)*src_step]; + dst[x*dst_step] = (sum*inv + (1<<15))>>16; + } + + for (; x < w; x++) { + sum += src[(2*w-radius-x-1)*src_step] - src[(x-radius-1)*src_step]; + dst[x*dst_step] = (sum*inv + (1<<15))>>16; + } +} + +static inline void blur_power(uint8_t *dst, int dst_step, const uint8_t *src, int src_step, + int w, int radius, int power, uint8_t *temp[2]) +{ + uint8_t *a = temp[0], *b = temp[1]; + + if (radius && power) { + blur(a, 1, src, src_step, w, radius); + for (; power > 2; power--) { + uint8_t *c; + blur(b, 1, a, 1, w, radius); + c = a; a = b; b = c; + } + if (power > 1) { + blur(dst, dst_step, a, 1, w, radius); + } else { + int i; + for (i = 0; i < w; i++) + dst[i*dst_step] = a[i]; + } + } else { + int i; + for (i = 0; i < w; i++) + dst[i*dst_step] = src[i*src_step]; + } +} + +static void hblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, + int w, int h, int radius, int power, uint8_t *temp[2]) +{ + int y; + + if (radius == 0 && dst == src) + return; + + for (y = 0; y < h; y++) + blur_power(dst + y*dst_linesize, 1, src + y*src_linesize, 1, + w, radius, power, temp); +} + +static void vblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, + int w, int h, int radius, int power, uint8_t *temp[2]) +{ + int x; + + if (radius == 0 && dst == src) + return; + + for (x = 0; x < w; x++) + blur_power(dst + x, dst_linesize, src + x, src_linesize, + h, radius, power, temp); +} + +static void draw_slice(AVFilterLink *inlink, int y0, int h0, int slice_dir) +{ + AVFilterContext *ctx = inlink->dst; + BoxBlurContext *boxblur = ctx->priv; + AVFilterLink *outlink = inlink->dst->outputs[0]; + AVFilterBufferRef *inpicref = inlink ->cur_buf; + AVFilterBufferRef *outpicref = outlink->out_buf; + int plane; + int cw = inlink->w >> boxblur->hsub, ch = h0 >> boxblur->vsub; + int w[4] = { inlink->w, cw, cw, inlink->w }; + int h[4] = { h0, ch, ch, h0 }; + uint8_t *dst[4], *src[4]; + + for (plane = 0; inpicref->data[plane] && plane < 4; plane++) { + int y = plane == 1 || plane == 2 ? y0 >> boxblur->vsub : y0; + src[plane] = inpicref ->data[plane] + inpicref ->linesize[plane] * y; + dst[plane] = outpicref->data[plane] + outpicref->linesize[plane] * y; + } + + for (plane = 0; inpicref->data[plane] && plane < 4; plane++) + hblur(outpicref->data[plane], outpicref->linesize[plane], + inpicref ->data[plane], inpicref ->linesize[plane], + w[plane], h[plane], boxblur->radius[plane], boxblur->power[plane], + boxblur->temp); + + for (plane = 0; inpicref->data[plane] && plane < 4; plane++) + vblur(outpicref->data[plane], outpicref->linesize[plane], + outpicref->data[plane], outpicref->linesize[plane], + w[plane], h[plane], boxblur->radius[plane], boxblur->power[plane], + boxblur->temp); +} + +AVFilter avfilter_vf_boxblur = { + .name = "boxblur", + .description = NULL_IF_CONFIG_SMALL("Blur the input."), + .priv_size = sizeof(BoxBlurContext), + .init = init, + .uninit = uninit, + .query_formats = query_formats, + + .inputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_input, + .draw_slice = draw_slice, + .min_perms = AV_PERM_READ }, + { .name = NULL}}, + .outputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, }, + { .name = NULL}}, +}; From e358f7ee90fec591348ca05dff94ebaf4c1a098b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 14 Jul 2011 03:08:53 +0200 Subject: [PATCH 507/780] lavf: fix invalid reads in avformat_find_stream_info() --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 71fa95526c..cc0336a670 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2389,7 +2389,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) least one frame of codec data, this makes sure the codec initializes the channel configuration and does not only trust the values from the container. */ - try_decode_frame(st, pkt, (options && i <= orig_nb_streams )? &options[i] : NULL); + try_decode_frame(st, pkt, (options && i < orig_nb_streams )? &options[i] : NULL); st->codec_info_nb_frames++; count++; From ac4a85f47642b8d84c369bdb49b8d58611f1ca5e Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Mon, 11 Jul 2011 17:26:43 -0400 Subject: [PATCH 508/780] H.264: Add more x86 assembly for 10-bit H.264 predict functions Mainly ported from 8-bit H.264 predict. Some code ported from x264. LGPL ok by author. Signed-off-by: Ronald S. Bultje --- libavcodec/x86/h264_intrapred_10bit.asm | 231 +++++++++++++++++++++++- libavcodec/x86/h264_intrapred_init.c | 23 +++ 2 files changed, 253 insertions(+), 1 deletion(-) diff --git a/libavcodec/x86/h264_intrapred_10bit.asm b/libavcodec/x86/h264_intrapred_10bit.asm index d57fc79754..24a7bfa875 100644 --- a/libavcodec/x86/h264_intrapred_10bit.asm +++ b/libavcodec/x86/h264_intrapred_10bit.asm @@ -29,11 +29,19 @@ SECTION_RODATA SECTION .text +cextern pw_16 cextern pw_8 cextern pw_4 cextern pw_2 cextern pw_1 +pw_m32101234: dw -3, -2, -1, 0, 1, 2, 3, 4 +pw_m3: times 8 dw -3 +pw_pixel_max: times 8 dw ((1 << 10)-1) +pw_512: times 8 dw 512 +pd_17: times 4 dd 17 +pd_16: times 4 dd 16 + ; dest, left, right, src ; output: %1 = (t[n-1] + t[n]*2 + t[n+1] + 2) >> 2 %macro PRED4x4_LOWPASS 4 @@ -464,7 +472,92 @@ PRED8x8_TOP_DC mmxext, pshufw INIT_XMM PRED8x8_TOP_DC sse2 , pshuflw +;----------------------------------------------------------------------------- +; void pred8x8_plane(pixel *src, int stride) +;----------------------------------------------------------------------------- +INIT_XMM +cglobal pred8x8_plane_10_sse2, 2,7,7 + sub r0, r1 + lea r2, [r1+r1*2] + lea r3, [r0+r1*4] + mova m2, [r0] + pmaddwd m2, [pw_m32101234] + HADDD m2, m1 + movd m0, [r0-4] + psrld m0, 14 + psubw m2, m0 ; H + movd m0, [r3+r1*4-4] + movd m1, [r0+12] + paddw m0, m1 + psllw m0, 4 ; 16*(src[7*stride-1] + src[-stride+7]) + movzx r4d, word [r3+r1*1-2] ; src[4*stride-1] + movzx r5d, word [r0+r2*1-2] ; src[2*stride-1] + sub r4d, r5d + movzx r6d, word [r3+r1*2-2] ; src[5*stride-1] + movzx r5d, word [r0+r1*2-2] ; src[1*stride-1] + sub r6d, r5d + lea r4d, [r4+r6*2] + movzx r5d, word [r3+r2*1-2] ; src[6*stride-1] + movzx r6d, word [r0+r1*1-2] ; src[0*stride-1] + sub r5d, r6d + lea r5d, [r5+r5*2] + add r4d, r5d + movzx r6d, word [r3+r1*4-2] ; src[7*stride-1] + movzx r5d, word [r0+r1*0-2] ; src[ -stride-1] + sub r6d, r5d + lea r4d, [r4+r6*4] + movd m3, r4d ; V + punpckldq m2, m3 + pmaddwd m2, [pd_17] + paddd m2, [pd_16] + psrad m2, 5 ; b, c + mova m3, [pw_pixel_max] + pxor m1, m1 + SPLATW m0, m0, 1 + SPLATW m4, m2, 2 + SPLATW m2, m2, 0 + pmullw m2, [pw_m32101234] ; b + pmullw m5, m4, [pw_m3] ; c + paddw m5, [pw_16] + mov r2d, 8 + add r0, r1 +.loop: + paddsw m6, m2, m5 + paddsw m6, m0 + psraw m6, 5 + CLIPW m6, m1, m3 + mova [r0], m6 + paddw m5, m4 + add r0, r1 + dec r2d + jg .loop + REP_RET + + +;----------------------------------------------------------------------------- +; void pred8x8l_128_dc(pixel *src, int has_topleft, int has_topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED8x8L_128_DC 1 +cglobal pred8x8l_128_dc_10_%1, 4,4 + mova m0, [pw_512] + lea r1, [r3+r3*2] + lea r2, [r0+r3*4] + MOV8 r0+r3*0, m0, m0 + MOV8 r0+r3*1, m0, m0 + MOV8 r0+r3*2, m0, m0 + MOV8 r0+r1*1, m0, m0 + MOV8 r2+r3*0, m0, m0 + MOV8 r2+r3*1, m0, m0 + MOV8 r2+r3*2, m0, m0 + MOV8 r2+r1*1, m0, m0 + RET +%endmacro + +INIT_MMX +PRED8x8L_128_DC mmxext +INIT_XMM +PRED8x8L_128_DC sse2 ;----------------------------------------------------------------------------- ; void pred8x8l_top_dc(pixel *src, int has_topleft, int has_topright, int stride) @@ -1258,7 +1351,7 @@ cglobal pred16x16_horizontal_10_%1, 2,3 MOV16 r0+r1*1, m1, m1, m1, m1 lea r0, [r0+r1*2] dec r2 - jge .vloop + jg .vloop REP_RET %endmacro @@ -1266,3 +1359,139 @@ INIT_MMX PRED16x16_HORIZONTAL mmxext INIT_XMM PRED16x16_HORIZONTAL sse2 + +;----------------------------------------------------------------------------- +; void pred16x16_dc(pixel *src, int stride) +;----------------------------------------------------------------------------- +%macro PRED16x16_DC 1 +cglobal pred16x16_dc_10_%1, 2,7 + mov r4, r0 + sub r0, r1 + mova m0, [r0+0] + paddw m0, [r0+mmsize] +%if mmsize==8 + paddw m0, [r0+16] + paddw m0, [r0+24] +%endif + HADDW m0, m2 + + sub r0, 2 + movzx r3d, word [r0+r1*1] + movzx r5d, word [r0+r1*2] +%rep 7 + lea r0, [r0+r1*2] + movzx r2d, word [r0+r1*1] + add r3d, r2d + movzx r2d, word [r0+r1*2] + add r5d, r2d +%endrep + lea r3d, [r3+r5+16] + + movd m1, r3d + paddw m0, m1 + psrlw m0, 5 + SPLATW m0, m0 + mov r3d, 8 +.loop: + MOV16 r4+r1*0, m0, m0, m0, m0 + MOV16 r4+r1*1, m0, m0, m0, m0 + lea r4, [r4+r1*2] + dec r3d + jg .loop + REP_RET +%endmacro + +INIT_MMX +PRED16x16_DC mmxext +INIT_XMM +PRED16x16_DC sse2 + +;----------------------------------------------------------------------------- +; void pred16x16_top_dc(pixel *src, int stride) +;----------------------------------------------------------------------------- +%macro PRED16x16_TOP_DC 1 +cglobal pred16x16_top_dc_10_%1, 2,3 + sub r0, r1 + mova m0, [r0+0] + paddw m0, [r0+mmsize] +%if mmsize==8 + paddw m0, [r0+16] + paddw m0, [r0+24] +%endif + HADDW m0, m2 + + SPLATW m0, m0 + paddw m0, [pw_8] + psrlw m0, 4 + mov r2d, 8 +.loop: + MOV16 r0+r1*1, m0, m0, m0, m0 + MOV16 r0+r1*2, m0, m0, m0, m0 + lea r0, [r0+r1*2] + dec r2d + jg .loop + REP_RET +%endmacro + +INIT_MMX +PRED16x16_TOP_DC mmxext +INIT_XMM +PRED16x16_TOP_DC sse2 + +;----------------------------------------------------------------------------- +; void pred16x16_left_dc(pixel *src, int stride) +;----------------------------------------------------------------------------- +%macro PRED16x16_LEFT_DC 1 +cglobal pred16x16_left_dc_10_%1, 2,7 + mov r4, r0 + + sub r0, 2 + movzx r5d, word [r0+r1*0] + movzx r6d, word [r0+r1*1] +%rep 7 + lea r0, [r0+r1*2] + movzx r2d, word [r0+r1*0] + movzx r3d, word [r0+r1*1] + add r5d, r2d + add r6d, r3d +%endrep + lea r2d, [r5+r6+8] + shr r2d, 4 + + movd m0, r2d + SPLATW m0, m0 + mov r3d, 8 +.loop: + MOV16 r4+r1*0, m0, m0, m0, m0 + MOV16 r4+r1*1, m0, m0, m0, m0 + lea r4, [r4+r1*2] + dec r3d + jg .loop + REP_RET +%endmacro + +INIT_MMX +PRED16x16_LEFT_DC mmxext +INIT_XMM +PRED16x16_LEFT_DC sse2 + +;----------------------------------------------------------------------------- +; void pred16x16_128_dc(pixel *src, int stride) +;----------------------------------------------------------------------------- +%macro PRED16x16_128_DC 1 +cglobal pred16x16_128_dc_10_%1, 2,3 + mova m0, [pw_512] + mov r2d, 8 +.loop: + MOV16 r0+r1*0, m0, m0, m0, m0 + MOV16 r0+r1*1, m0, m0, m0, m0 + lea r0, [r0+r1*2] + dec r2d + jg .loop + REP_RET +%endmacro + +INIT_MMX +PRED16x16_128_DC mmxext +INIT_XMM +PRED16x16_128_DC sse2 diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c index a0c5164db1..62e4c8796b 100644 --- a/libavcodec/x86/h264_intrapred_init.c +++ b/libavcodec/x86/h264_intrapred_init.c @@ -47,6 +47,7 @@ PRED8x8(dc, 10, mmxext) PRED8x8(dc, 10, sse2) PRED8x8(top_dc, 10, mmxext) PRED8x8(top_dc, 10, sse2) +PRED8x8(plane, 10, sse2) PRED8x8(vertical, 10, sse2) PRED8x8(horizontal, 10, sse2) @@ -55,6 +56,8 @@ void ff_pred8x8l_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, int has_tople PRED8x8L(dc, 10, sse2) PRED8x8L(dc, 10, ssse3) +PRED8x8L(128_dc, 10, mmxext) +PRED8x8L(128_dc, 10, sse2) PRED8x8L(top_dc, 10, sse2) PRED8x8L(top_dc, 10, ssse3) PRED8x8L(vertical, 10, sse2) @@ -73,6 +76,14 @@ PRED8x8L(horizontal_up, 10, ssse3) #define PRED16x16(TYPE, DEPTH, OPT)\ void ff_pred16x16_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, int stride); +PRED16x16(dc, 10, mmxext) +PRED16x16(dc, 10, sse2) +PRED16x16(top_dc, 10, mmxext) +PRED16x16(top_dc, 10, sse2) +PRED16x16(128_dc, 10, mmxext) +PRED16x16(128_dc, 10, sse2) +PRED16x16(left_dc, 10, mmxext) +PRED16x16(left_dc, 10, sse2) PRED16x16(vertical, 10, mmxext) PRED16x16(vertical, 10, sse2) PRED16x16(horizontal, 10, mmxext) @@ -289,6 +300,12 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_mmxext; h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_mmxext; + h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_mmxext; + + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_10_mmxext; + h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_10_mmxext; + h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_10_mmxext; + h->pred16x16[LEFT_DC_PRED8x8 ] = ff_pred16x16_left_dc_10_mmxext; h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_10_mmxext; h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_10_mmxext; } @@ -301,18 +318,24 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_sse2; h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_sse2; + h->pred8x8[PLANE_PRED8x8 ] = ff_pred8x8_plane_10_sse2; h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vertical_10_sse2; h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_10_sse2; h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_sse2; h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_sse2; h->pred8x8l[DC_PRED ] = ff_pred8x8l_dc_10_sse2; + h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_sse2; h->pred8x8l[TOP_DC_PRED ] = ff_pred8x8l_top_dc_10_sse2; h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_sse2; h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_sse2; h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_sse2; h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_sse2; + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_10_sse2; + h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_10_sse2; + h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_10_sse2; + h->pred16x16[LEFT_DC_PRED8x8 ] = ff_pred16x16_left_dc_10_sse2; h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_10_sse2; h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_10_sse2; } From 806212498ae6b333d0c85dbc9c750580da7c6838 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 13 Jul 2011 21:51:23 +0200 Subject: [PATCH 509/780] h264: move fill_decode_neighbors()/fill_decode_caches() to h264_mvpred.h This fixes a bunch of unused function warnings. --- libavcodec/h264.h | 418 --------------------------------------- libavcodec/h264_mvpred.h | 418 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 418 insertions(+), 418 deletions(-) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 95b471539d..122a54aca0 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -770,424 +770,6 @@ static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){ return h->pps.chroma_qp_table[t][qscale]; } -static void fill_decode_neighbors(H264Context *h, int mb_type){ - MpegEncContext * const s = &h->s; - const int mb_xy= h->mb_xy; - int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; - static const uint8_t left_block_options[4][32]={ - {0,1,2,3,7,10,8,11,3+0*4, 3+1*4, 3+2*4, 3+3*4, 1+4*4, 1+8*4, 1+5*4, 1+9*4}, - {2,2,3,3,8,11,8,11,3+2*4, 3+2*4, 3+3*4, 3+3*4, 1+5*4, 1+9*4, 1+5*4, 1+9*4}, - {0,0,1,1,7,10,7,10,3+0*4, 3+0*4, 3+1*4, 3+1*4, 1+4*4, 1+8*4, 1+4*4, 1+8*4}, - {0,2,0,2,7,10,7,10,3+0*4, 3+2*4, 3+0*4, 3+2*4, 1+4*4, 1+8*4, 1+4*4, 1+8*4} - }; - - h->topleft_partition= -1; - - top_xy = mb_xy - (s->mb_stride << MB_FIELD); - - /* Wow, what a mess, why didn't they simplify the interlacing & intra - * stuff, I can't imagine that these complex rules are worth it. */ - - topleft_xy = top_xy - 1; - topright_xy= top_xy + 1; - left_xy[LBOT] = left_xy[LTOP] = mb_xy-1; - h->left_block = left_block_options[0]; - if(FRAME_MBAFF){ - const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]); - const int curr_mb_field_flag = IS_INTERLACED(mb_type); - if(s->mb_y&1){ - if (left_mb_field_flag != curr_mb_field_flag) { - left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1; - if (curr_mb_field_flag) { - left_xy[LBOT] += s->mb_stride; - h->left_block = left_block_options[3]; - } else { - topleft_xy += s->mb_stride; - // take top left mv from the middle of the mb, as opposed to all other modes which use the bottom right partition - h->topleft_partition = 0; - h->left_block = left_block_options[1]; - } - } - }else{ - if(curr_mb_field_flag){ - topleft_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1); - topright_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy + 1] >> 7) & 1) - 1); - top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy ] >> 7) & 1) - 1); - } - if (left_mb_field_flag != curr_mb_field_flag) { - if (curr_mb_field_flag) { - left_xy[LBOT] += s->mb_stride; - h->left_block = left_block_options[3]; - } else { - h->left_block = left_block_options[2]; - } - } - } - } - - h->topleft_mb_xy = topleft_xy; - h->top_mb_xy = top_xy; - h->topright_mb_xy= topright_xy; - h->left_mb_xy[LTOP] = left_xy[LTOP]; - h->left_mb_xy[LBOT] = left_xy[LBOT]; - //FIXME do we need all in the context? - - h->topleft_type = s->current_picture.f.mb_type[topleft_xy]; - h->top_type = s->current_picture.f.mb_type[top_xy]; - h->topright_type = s->current_picture.f.mb_type[topright_xy]; - h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]]; - h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]]; - - if(FMO){ - if(h->slice_table[topleft_xy ] != h->slice_num) h->topleft_type = 0; - if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; - if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0; - }else{ - if(h->slice_table[topleft_xy ] != h->slice_num){ - h->topleft_type = 0; - if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; - if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0; - } - } - if(h->slice_table[topright_xy] != h->slice_num) h->topright_type= 0; -} - -static void fill_decode_caches(H264Context *h, int mb_type){ - MpegEncContext * const s = &h->s; - int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; - int topleft_type, top_type, topright_type, left_type[LEFT_MBS]; - const uint8_t * left_block= h->left_block; - int i; - uint8_t *nnz; - uint8_t *nnz_cache; - - topleft_xy = h->topleft_mb_xy; - top_xy = h->top_mb_xy; - topright_xy = h->topright_mb_xy; - left_xy[LTOP] = h->left_mb_xy[LTOP]; - left_xy[LBOT] = h->left_mb_xy[LBOT]; - topleft_type = h->topleft_type; - top_type = h->top_type; - topright_type = h->topright_type; - left_type[LTOP]= h->left_type[LTOP]; - left_type[LBOT]= h->left_type[LBOT]; - - if(!IS_SKIP(mb_type)){ - if(IS_INTRA(mb_type)){ - int type_mask= h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1; - h->topleft_samples_available= - h->top_samples_available= - h->left_samples_available= 0xFFFF; - h->topright_samples_available= 0xEEEA; - - if(!(top_type & type_mask)){ - h->topleft_samples_available= 0xB3FF; - h->top_samples_available= 0x33FF; - h->topright_samples_available= 0x26EA; - } - if(IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])){ - if(IS_INTERLACED(mb_type)){ - if(!(left_type[LTOP] & type_mask)){ - h->topleft_samples_available&= 0xDFFF; - h->left_samples_available&= 0x5FFF; - } - if(!(left_type[LBOT] & type_mask)){ - h->topleft_samples_available&= 0xFF5F; - h->left_samples_available&= 0xFF5F; - } - }else{ - int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride]; - - assert(left_xy[LTOP] == left_xy[LBOT]); - if(!((left_typei & type_mask) && (left_type[LTOP] & type_mask))){ - h->topleft_samples_available&= 0xDF5F; - h->left_samples_available&= 0x5F5F; - } - } - }else{ - if(!(left_type[LTOP] & type_mask)){ - h->topleft_samples_available&= 0xDF5F; - h->left_samples_available&= 0x5F5F; - } - } - - if(!(topleft_type & type_mask)) - h->topleft_samples_available&= 0x7FFF; - - if(!(topright_type & type_mask)) - h->topright_samples_available&= 0xFBFF; - - if(IS_INTRA4x4(mb_type)){ - if(IS_INTRA4x4(top_type)){ - AV_COPY32(h->intra4x4_pred_mode_cache+4+8*0, h->intra4x4_pred_mode + h->mb2br_xy[top_xy]); - }else{ - h->intra4x4_pred_mode_cache[4+8*0]= - h->intra4x4_pred_mode_cache[5+8*0]= - h->intra4x4_pred_mode_cache[6+8*0]= - h->intra4x4_pred_mode_cache[7+8*0]= 2 - 3*!(top_type & type_mask); - } - for(i=0; i<2; i++){ - if(IS_INTRA4x4(left_type[LEFT(i)])){ - int8_t *mode= h->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]]; - h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= mode[6-left_block[0+2*i]]; - h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= mode[6-left_block[1+2*i]]; - }else{ - h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= - h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= 2 - 3*!(left_type[LEFT(i)] & type_mask); - } - } - } - } - - -/* -0 . T T. T T T T -1 L . .L . . . . -2 L . .L . . . . -3 . T TL . . . . -4 L . .L . . . . -5 L . .. . . . . -*/ -//FIXME constraint_intra_pred & partitioning & nnz (let us hope this is just a typo in the spec) - nnz_cache = h->non_zero_count_cache; - if(top_type){ - nnz = h->non_zero_count[top_xy]; - AV_COPY32(&nnz_cache[4+8* 0], &nnz[4*3]); - if(CHROMA444){ - AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 7]); - AV_COPY32(&nnz_cache[4+8*10], &nnz[4*11]); - }else{ - AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 5]); - AV_COPY32(&nnz_cache[4+8*10], &nnz[4* 9]); - } - }else{ - uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040; - AV_WN32A(&nnz_cache[4+8* 0], top_empty); - AV_WN32A(&nnz_cache[4+8* 5], top_empty); - AV_WN32A(&nnz_cache[4+8*10], top_empty); - } - - for (i=0; i<2; i++) { - if(left_type[LEFT(i)]){ - nnz = h->non_zero_count[left_xy[LEFT(i)]]; - nnz_cache[3+8* 1 + 2*8*i]= nnz[left_block[8+0+2*i]]; - nnz_cache[3+8* 2 + 2*8*i]= nnz[left_block[8+1+2*i]]; - if(CHROMA444){ - nnz_cache[3+8* 6 + 2*8*i]= nnz[left_block[8+0+2*i]+4*4]; - nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]+4*4]; - nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]+8*4]; - nnz_cache[3+8*12 + 2*8*i]= nnz[left_block[8+1+2*i]+8*4]; - }else{ - nnz_cache[3+8* 6 + 8*i]= nnz[left_block[8+4+2*i]]; - nnz_cache[3+8*11 + 8*i]= nnz[left_block[8+5+2*i]]; - } - }else{ - nnz_cache[3+8* 1 + 2*8*i]= - nnz_cache[3+8* 2 + 2*8*i]= - nnz_cache[3+8* 6 + 2*8*i]= - nnz_cache[3+8* 7 + 2*8*i]= - nnz_cache[3+8*11 + 2*8*i]= - nnz_cache[3+8*12 + 2*8*i]= CABAC && !IS_INTRA(mb_type) ? 0 : 64; - } - } - - if( CABAC ) { - // top_cbp - if(top_type) { - h->top_cbp = h->cbp_table[top_xy]; - } else { - h->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; - } - // left_cbp - if (left_type[LTOP]) { - h->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) - | ((h->cbp_table[left_xy[LTOP]]>>(left_block[0]&(~1)))&2) - | (((h->cbp_table[left_xy[LBOT]]>>(left_block[2]&(~1)))&2) << 2); - } else { - h->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; - } - } - } - - if(IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)){ - int list; - int b_stride = h->b_stride; - for(list=0; listlist_count; list++){ - int8_t *ref_cache = &h->ref_cache[list][scan8[0]]; - int8_t *ref = s->current_picture.f.ref_index[list]; - int16_t (*mv_cache)[2] = &h->mv_cache[list][scan8[0]]; - int16_t (*mv)[2] = s->current_picture.f.motion_val[list]; - if(!USES_LIST(mb_type, list)){ - continue; - } - assert(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred)); - - if(USES_LIST(top_type, list)){ - const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride; - AV_COPY128(mv_cache[0 - 1*8], mv[b_xy + 0]); - ref_cache[0 - 1*8]= - ref_cache[1 - 1*8]= ref[4*top_xy + 2]; - ref_cache[2 - 1*8]= - ref_cache[3 - 1*8]= ref[4*top_xy + 3]; - }else{ - AV_ZERO128(mv_cache[0 - 1*8]); - AV_WN32A(&ref_cache[0 - 1*8], ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101); - } - - if(mb_type & (MB_TYPE_16x8|MB_TYPE_8x8)){ - for(i=0; i<2; i++){ - int cache_idx = -1 + i*2*8; - if(USES_LIST(left_type[LEFT(i)], list)){ - const int b_xy= h->mb2b_xy[left_xy[LEFT(i)]] + 3; - const int b8_xy= 4*left_xy[LEFT(i)] + 1; - AV_COPY32(mv_cache[cache_idx ], mv[b_xy + b_stride*left_block[0+i*2]]); - AV_COPY32(mv_cache[cache_idx+8], mv[b_xy + b_stride*left_block[1+i*2]]); - ref_cache[cache_idx ]= ref[b8_xy + (left_block[0+i*2]&~1)]; - ref_cache[cache_idx+8]= ref[b8_xy + (left_block[1+i*2]&~1)]; - }else{ - AV_ZERO32(mv_cache[cache_idx ]); - AV_ZERO32(mv_cache[cache_idx+8]); - ref_cache[cache_idx ]= - ref_cache[cache_idx+8]= (left_type[LEFT(i)]) ? LIST_NOT_USED : PART_NOT_AVAILABLE; - } - } - }else{ - if(USES_LIST(left_type[LTOP], list)){ - const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3; - const int b8_xy= 4*left_xy[LTOP] + 1; - AV_COPY32(mv_cache[-1], mv[b_xy + b_stride*left_block[0]]); - ref_cache[-1]= ref[b8_xy + (left_block[0]&~1)]; - }else{ - AV_ZERO32(mv_cache[-1]); - ref_cache[-1]= left_type[LTOP] ? LIST_NOT_USED : PART_NOT_AVAILABLE; - } - } - - if(USES_LIST(topright_type, list)){ - const int b_xy= h->mb2b_xy[topright_xy] + 3*b_stride; - AV_COPY32(mv_cache[4 - 1*8], mv[b_xy]); - ref_cache[4 - 1*8]= ref[4*topright_xy + 2]; - }else{ - AV_ZERO32(mv_cache[4 - 1*8]); - ref_cache[4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; - } - if(ref_cache[4 - 1*8] < 0){ - if(USES_LIST(topleft_type, list)){ - const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride + (h->topleft_partition & 2*b_stride); - const int b8_xy= 4*topleft_xy + 1 + (h->topleft_partition & 2); - AV_COPY32(mv_cache[-1 - 1*8], mv[b_xy]); - ref_cache[-1 - 1*8]= ref[b8_xy]; - }else{ - AV_ZERO32(mv_cache[-1 - 1*8]); - ref_cache[-1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; - } - } - - if((mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2)) && !FRAME_MBAFF) - continue; - - if(!(mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2))){ - uint8_t (*mvd_cache)[2] = &h->mvd_cache[list][scan8[0]]; - uint8_t (*mvd)[2] = h->mvd_table[list]; - ref_cache[2+8*0] = - ref_cache[2+8*2] = PART_NOT_AVAILABLE; - AV_ZERO32(mv_cache[2+8*0]); - AV_ZERO32(mv_cache[2+8*2]); - - if( CABAC ) { - if(USES_LIST(top_type, list)){ - const int b_xy= h->mb2br_xy[top_xy]; - AV_COPY64(mvd_cache[0 - 1*8], mvd[b_xy + 0]); - }else{ - AV_ZERO64(mvd_cache[0 - 1*8]); - } - if(USES_LIST(left_type[LTOP], list)){ - const int b_xy= h->mb2br_xy[left_xy[LTOP]] + 6; - AV_COPY16(mvd_cache[-1 + 0*8], mvd[b_xy - left_block[0]]); - AV_COPY16(mvd_cache[-1 + 1*8], mvd[b_xy - left_block[1]]); - }else{ - AV_ZERO16(mvd_cache[-1 + 0*8]); - AV_ZERO16(mvd_cache[-1 + 1*8]); - } - if(USES_LIST(left_type[LBOT], list)){ - const int b_xy= h->mb2br_xy[left_xy[LBOT]] + 6; - AV_COPY16(mvd_cache[-1 + 2*8], mvd[b_xy - left_block[2]]); - AV_COPY16(mvd_cache[-1 + 3*8], mvd[b_xy - left_block[3]]); - }else{ - AV_ZERO16(mvd_cache[-1 + 2*8]); - AV_ZERO16(mvd_cache[-1 + 3*8]); - } - AV_ZERO16(mvd_cache[2+8*0]); - AV_ZERO16(mvd_cache[2+8*2]); - if(h->slice_type_nos == AV_PICTURE_TYPE_B){ - uint8_t *direct_cache = &h->direct_cache[scan8[0]]; - uint8_t *direct_table = h->direct_table; - fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16>>1, 1); - - if(IS_DIRECT(top_type)){ - AV_WN32A(&direct_cache[-1*8], 0x01010101u*(MB_TYPE_DIRECT2>>1)); - }else if(IS_8X8(top_type)){ - int b8_xy = 4*top_xy; - direct_cache[0 - 1*8]= direct_table[b8_xy + 2]; - direct_cache[2 - 1*8]= direct_table[b8_xy + 3]; - }else{ - AV_WN32A(&direct_cache[-1*8], 0x01010101*(MB_TYPE_16x16>>1)); - } - - if(IS_DIRECT(left_type[LTOP])) - direct_cache[-1 + 0*8]= MB_TYPE_DIRECT2>>1; - else if(IS_8X8(left_type[LTOP])) - direct_cache[-1 + 0*8]= direct_table[4*left_xy[LTOP] + 1 + (left_block[0]&~1)]; - else - direct_cache[-1 + 0*8]= MB_TYPE_16x16>>1; - - if(IS_DIRECT(left_type[LBOT])) - direct_cache[-1 + 2*8]= MB_TYPE_DIRECT2>>1; - else if(IS_8X8(left_type[LBOT])) - direct_cache[-1 + 2*8]= direct_table[4*left_xy[LBOT] + 1 + (left_block[2]&~1)]; - else - direct_cache[-1 + 2*8]= MB_TYPE_16x16>>1; - } - } - } - if(FRAME_MBAFF){ -#define MAP_MVS\ - MAP_F2F(scan8[0] - 1 - 1*8, topleft_type)\ - MAP_F2F(scan8[0] + 0 - 1*8, top_type)\ - MAP_F2F(scan8[0] + 1 - 1*8, top_type)\ - MAP_F2F(scan8[0] + 2 - 1*8, top_type)\ - MAP_F2F(scan8[0] + 3 - 1*8, top_type)\ - MAP_F2F(scan8[0] + 4 - 1*8, topright_type)\ - MAP_F2F(scan8[0] - 1 + 0*8, left_type[LTOP])\ - MAP_F2F(scan8[0] - 1 + 1*8, left_type[LTOP])\ - MAP_F2F(scan8[0] - 1 + 2*8, left_type[LBOT])\ - MAP_F2F(scan8[0] - 1 + 3*8, left_type[LBOT]) - if(MB_FIELD){ -#define MAP_F2F(idx, mb_type)\ - if(!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ - h->ref_cache[list][idx] <<= 1;\ - h->mv_cache[list][idx][1] /= 2;\ - h->mvd_cache[list][idx][1] >>=1;\ - } - MAP_MVS -#undef MAP_F2F - }else{ -#define MAP_F2F(idx, mb_type)\ - if(IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ - h->ref_cache[list][idx] >>= 1;\ - h->mv_cache[list][idx][1] <<= 1;\ - h->mvd_cache[list][idx][1] <<= 1;\ - } - MAP_MVS -#undef MAP_F2F - } - } - } - } - - h->neighbor_transform_size= !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]); -} - /** * gets the predicted intra4x4 prediction mode. */ diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h index 52c032337a..4751928211 100644 --- a/libavcodec/h264_mvpred.h +++ b/libavcodec/h264_mvpred.h @@ -327,6 +327,424 @@ zeromv: return; } +static void fill_decode_neighbors(H264Context *h, int mb_type){ + MpegEncContext * const s = &h->s; + const int mb_xy= h->mb_xy; + int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; + static const uint8_t left_block_options[4][32]={ + {0,1,2,3,7,10,8,11,3+0*4, 3+1*4, 3+2*4, 3+3*4, 1+4*4, 1+8*4, 1+5*4, 1+9*4}, + {2,2,3,3,8,11,8,11,3+2*4, 3+2*4, 3+3*4, 3+3*4, 1+5*4, 1+9*4, 1+5*4, 1+9*4}, + {0,0,1,1,7,10,7,10,3+0*4, 3+0*4, 3+1*4, 3+1*4, 1+4*4, 1+8*4, 1+4*4, 1+8*4}, + {0,2,0,2,7,10,7,10,3+0*4, 3+2*4, 3+0*4, 3+2*4, 1+4*4, 1+8*4, 1+4*4, 1+8*4} + }; + + h->topleft_partition= -1; + + top_xy = mb_xy - (s->mb_stride << MB_FIELD); + + /* Wow, what a mess, why didn't they simplify the interlacing & intra + * stuff, I can't imagine that these complex rules are worth it. */ + + topleft_xy = top_xy - 1; + topright_xy= top_xy + 1; + left_xy[LBOT] = left_xy[LTOP] = mb_xy-1; + h->left_block = left_block_options[0]; + if(FRAME_MBAFF){ + const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]); + const int curr_mb_field_flag = IS_INTERLACED(mb_type); + if(s->mb_y&1){ + if (left_mb_field_flag != curr_mb_field_flag) { + left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1; + if (curr_mb_field_flag) { + left_xy[LBOT] += s->mb_stride; + h->left_block = left_block_options[3]; + } else { + topleft_xy += s->mb_stride; + // take top left mv from the middle of the mb, as opposed to all other modes which use the bottom right partition + h->topleft_partition = 0; + h->left_block = left_block_options[1]; + } + } + }else{ + if(curr_mb_field_flag){ + topleft_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1); + topright_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy + 1] >> 7) & 1) - 1); + top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy ] >> 7) & 1) - 1); + } + if (left_mb_field_flag != curr_mb_field_flag) { + if (curr_mb_field_flag) { + left_xy[LBOT] += s->mb_stride; + h->left_block = left_block_options[3]; + } else { + h->left_block = left_block_options[2]; + } + } + } + } + + h->topleft_mb_xy = topleft_xy; + h->top_mb_xy = top_xy; + h->topright_mb_xy= topright_xy; + h->left_mb_xy[LTOP] = left_xy[LTOP]; + h->left_mb_xy[LBOT] = left_xy[LBOT]; + //FIXME do we need all in the context? + + h->topleft_type = s->current_picture.f.mb_type[topleft_xy]; + h->top_type = s->current_picture.f.mb_type[top_xy]; + h->topright_type = s->current_picture.f.mb_type[topright_xy]; + h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]]; + h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]]; + + if(FMO){ + if(h->slice_table[topleft_xy ] != h->slice_num) h->topleft_type = 0; + if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; + if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0; + }else{ + if(h->slice_table[topleft_xy ] != h->slice_num){ + h->topleft_type = 0; + if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0; + if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0; + } + } + if(h->slice_table[topright_xy] != h->slice_num) h->topright_type= 0; +} + +static void fill_decode_caches(H264Context *h, int mb_type){ + MpegEncContext * const s = &h->s; + int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; + int topleft_type, top_type, topright_type, left_type[LEFT_MBS]; + const uint8_t * left_block= h->left_block; + int i; + uint8_t *nnz; + uint8_t *nnz_cache; + + topleft_xy = h->topleft_mb_xy; + top_xy = h->top_mb_xy; + topright_xy = h->topright_mb_xy; + left_xy[LTOP] = h->left_mb_xy[LTOP]; + left_xy[LBOT] = h->left_mb_xy[LBOT]; + topleft_type = h->topleft_type; + top_type = h->top_type; + topright_type = h->topright_type; + left_type[LTOP]= h->left_type[LTOP]; + left_type[LBOT]= h->left_type[LBOT]; + + if(!IS_SKIP(mb_type)){ + if(IS_INTRA(mb_type)){ + int type_mask= h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1; + h->topleft_samples_available= + h->top_samples_available= + h->left_samples_available= 0xFFFF; + h->topright_samples_available= 0xEEEA; + + if(!(top_type & type_mask)){ + h->topleft_samples_available= 0xB3FF; + h->top_samples_available= 0x33FF; + h->topright_samples_available= 0x26EA; + } + if(IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])){ + if(IS_INTERLACED(mb_type)){ + if(!(left_type[LTOP] & type_mask)){ + h->topleft_samples_available&= 0xDFFF; + h->left_samples_available&= 0x5FFF; + } + if(!(left_type[LBOT] & type_mask)){ + h->topleft_samples_available&= 0xFF5F; + h->left_samples_available&= 0xFF5F; + } + }else{ + int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride]; + + assert(left_xy[LTOP] == left_xy[LBOT]); + if(!((left_typei & type_mask) && (left_type[LTOP] & type_mask))){ + h->topleft_samples_available&= 0xDF5F; + h->left_samples_available&= 0x5F5F; + } + } + }else{ + if(!(left_type[LTOP] & type_mask)){ + h->topleft_samples_available&= 0xDF5F; + h->left_samples_available&= 0x5F5F; + } + } + + if(!(topleft_type & type_mask)) + h->topleft_samples_available&= 0x7FFF; + + if(!(topright_type & type_mask)) + h->topright_samples_available&= 0xFBFF; + + if(IS_INTRA4x4(mb_type)){ + if(IS_INTRA4x4(top_type)){ + AV_COPY32(h->intra4x4_pred_mode_cache+4+8*0, h->intra4x4_pred_mode + h->mb2br_xy[top_xy]); + }else{ + h->intra4x4_pred_mode_cache[4+8*0]= + h->intra4x4_pred_mode_cache[5+8*0]= + h->intra4x4_pred_mode_cache[6+8*0]= + h->intra4x4_pred_mode_cache[7+8*0]= 2 - 3*!(top_type & type_mask); + } + for(i=0; i<2; i++){ + if(IS_INTRA4x4(left_type[LEFT(i)])){ + int8_t *mode= h->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]]; + h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= mode[6-left_block[0+2*i]]; + h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= mode[6-left_block[1+2*i]]; + }else{ + h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= + h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= 2 - 3*!(left_type[LEFT(i)] & type_mask); + } + } + } + } + + +/* +0 . T T. T T T T +1 L . .L . . . . +2 L . .L . . . . +3 . T TL . . . . +4 L . .L . . . . +5 L . .. . . . . +*/ +//FIXME constraint_intra_pred & partitioning & nnz (let us hope this is just a typo in the spec) + nnz_cache = h->non_zero_count_cache; + if(top_type){ + nnz = h->non_zero_count[top_xy]; + AV_COPY32(&nnz_cache[4+8* 0], &nnz[4*3]); + if(CHROMA444){ + AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 7]); + AV_COPY32(&nnz_cache[4+8*10], &nnz[4*11]); + }else{ + AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 5]); + AV_COPY32(&nnz_cache[4+8*10], &nnz[4* 9]); + } + }else{ + uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040; + AV_WN32A(&nnz_cache[4+8* 0], top_empty); + AV_WN32A(&nnz_cache[4+8* 5], top_empty); + AV_WN32A(&nnz_cache[4+8*10], top_empty); + } + + for (i=0; i<2; i++) { + if(left_type[LEFT(i)]){ + nnz = h->non_zero_count[left_xy[LEFT(i)]]; + nnz_cache[3+8* 1 + 2*8*i]= nnz[left_block[8+0+2*i]]; + nnz_cache[3+8* 2 + 2*8*i]= nnz[left_block[8+1+2*i]]; + if(CHROMA444){ + nnz_cache[3+8* 6 + 2*8*i]= nnz[left_block[8+0+2*i]+4*4]; + nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]+4*4]; + nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]+8*4]; + nnz_cache[3+8*12 + 2*8*i]= nnz[left_block[8+1+2*i]+8*4]; + }else{ + nnz_cache[3+8* 6 + 8*i]= nnz[left_block[8+4+2*i]]; + nnz_cache[3+8*11 + 8*i]= nnz[left_block[8+5+2*i]]; + } + }else{ + nnz_cache[3+8* 1 + 2*8*i]= + nnz_cache[3+8* 2 + 2*8*i]= + nnz_cache[3+8* 6 + 2*8*i]= + nnz_cache[3+8* 7 + 2*8*i]= + nnz_cache[3+8*11 + 2*8*i]= + nnz_cache[3+8*12 + 2*8*i]= CABAC && !IS_INTRA(mb_type) ? 0 : 64; + } + } + + if( CABAC ) { + // top_cbp + if(top_type) { + h->top_cbp = h->cbp_table[top_xy]; + } else { + h->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; + } + // left_cbp + if (left_type[LTOP]) { + h->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) + | ((h->cbp_table[left_xy[LTOP]]>>(left_block[0]&(~1)))&2) + | (((h->cbp_table[left_xy[LBOT]]>>(left_block[2]&(~1)))&2) << 2); + } else { + h->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; + } + } + } + + if(IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)){ + int list; + int b_stride = h->b_stride; + for(list=0; listlist_count; list++){ + int8_t *ref_cache = &h->ref_cache[list][scan8[0]]; + int8_t *ref = s->current_picture.f.ref_index[list]; + int16_t (*mv_cache)[2] = &h->mv_cache[list][scan8[0]]; + int16_t (*mv)[2] = s->current_picture.f.motion_val[list]; + if(!USES_LIST(mb_type, list)){ + continue; + } + assert(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred)); + + if(USES_LIST(top_type, list)){ + const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride; + AV_COPY128(mv_cache[0 - 1*8], mv[b_xy + 0]); + ref_cache[0 - 1*8]= + ref_cache[1 - 1*8]= ref[4*top_xy + 2]; + ref_cache[2 - 1*8]= + ref_cache[3 - 1*8]= ref[4*top_xy + 3]; + }else{ + AV_ZERO128(mv_cache[0 - 1*8]); + AV_WN32A(&ref_cache[0 - 1*8], ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101); + } + + if(mb_type & (MB_TYPE_16x8|MB_TYPE_8x8)){ + for(i=0; i<2; i++){ + int cache_idx = -1 + i*2*8; + if(USES_LIST(left_type[LEFT(i)], list)){ + const int b_xy= h->mb2b_xy[left_xy[LEFT(i)]] + 3; + const int b8_xy= 4*left_xy[LEFT(i)] + 1; + AV_COPY32(mv_cache[cache_idx ], mv[b_xy + b_stride*left_block[0+i*2]]); + AV_COPY32(mv_cache[cache_idx+8], mv[b_xy + b_stride*left_block[1+i*2]]); + ref_cache[cache_idx ]= ref[b8_xy + (left_block[0+i*2]&~1)]; + ref_cache[cache_idx+8]= ref[b8_xy + (left_block[1+i*2]&~1)]; + }else{ + AV_ZERO32(mv_cache[cache_idx ]); + AV_ZERO32(mv_cache[cache_idx+8]); + ref_cache[cache_idx ]= + ref_cache[cache_idx+8]= (left_type[LEFT(i)]) ? LIST_NOT_USED : PART_NOT_AVAILABLE; + } + } + }else{ + if(USES_LIST(left_type[LTOP], list)){ + const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3; + const int b8_xy= 4*left_xy[LTOP] + 1; + AV_COPY32(mv_cache[-1], mv[b_xy + b_stride*left_block[0]]); + ref_cache[-1]= ref[b8_xy + (left_block[0]&~1)]; + }else{ + AV_ZERO32(mv_cache[-1]); + ref_cache[-1]= left_type[LTOP] ? LIST_NOT_USED : PART_NOT_AVAILABLE; + } + } + + if(USES_LIST(topright_type, list)){ + const int b_xy= h->mb2b_xy[topright_xy] + 3*b_stride; + AV_COPY32(mv_cache[4 - 1*8], mv[b_xy]); + ref_cache[4 - 1*8]= ref[4*topright_xy + 2]; + }else{ + AV_ZERO32(mv_cache[4 - 1*8]); + ref_cache[4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; + } + if(ref_cache[4 - 1*8] < 0){ + if(USES_LIST(topleft_type, list)){ + const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride + (h->topleft_partition & 2*b_stride); + const int b8_xy= 4*topleft_xy + 1 + (h->topleft_partition & 2); + AV_COPY32(mv_cache[-1 - 1*8], mv[b_xy]); + ref_cache[-1 - 1*8]= ref[b8_xy]; + }else{ + AV_ZERO32(mv_cache[-1 - 1*8]); + ref_cache[-1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; + } + } + + if((mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2)) && !FRAME_MBAFF) + continue; + + if(!(mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2))){ + uint8_t (*mvd_cache)[2] = &h->mvd_cache[list][scan8[0]]; + uint8_t (*mvd)[2] = h->mvd_table[list]; + ref_cache[2+8*0] = + ref_cache[2+8*2] = PART_NOT_AVAILABLE; + AV_ZERO32(mv_cache[2+8*0]); + AV_ZERO32(mv_cache[2+8*2]); + + if( CABAC ) { + if(USES_LIST(top_type, list)){ + const int b_xy= h->mb2br_xy[top_xy]; + AV_COPY64(mvd_cache[0 - 1*8], mvd[b_xy + 0]); + }else{ + AV_ZERO64(mvd_cache[0 - 1*8]); + } + if(USES_LIST(left_type[LTOP], list)){ + const int b_xy= h->mb2br_xy[left_xy[LTOP]] + 6; + AV_COPY16(mvd_cache[-1 + 0*8], mvd[b_xy - left_block[0]]); + AV_COPY16(mvd_cache[-1 + 1*8], mvd[b_xy - left_block[1]]); + }else{ + AV_ZERO16(mvd_cache[-1 + 0*8]); + AV_ZERO16(mvd_cache[-1 + 1*8]); + } + if(USES_LIST(left_type[LBOT], list)){ + const int b_xy= h->mb2br_xy[left_xy[LBOT]] + 6; + AV_COPY16(mvd_cache[-1 + 2*8], mvd[b_xy - left_block[2]]); + AV_COPY16(mvd_cache[-1 + 3*8], mvd[b_xy - left_block[3]]); + }else{ + AV_ZERO16(mvd_cache[-1 + 2*8]); + AV_ZERO16(mvd_cache[-1 + 3*8]); + } + AV_ZERO16(mvd_cache[2+8*0]); + AV_ZERO16(mvd_cache[2+8*2]); + if(h->slice_type_nos == AV_PICTURE_TYPE_B){ + uint8_t *direct_cache = &h->direct_cache[scan8[0]]; + uint8_t *direct_table = h->direct_table; + fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16>>1, 1); + + if(IS_DIRECT(top_type)){ + AV_WN32A(&direct_cache[-1*8], 0x01010101u*(MB_TYPE_DIRECT2>>1)); + }else if(IS_8X8(top_type)){ + int b8_xy = 4*top_xy; + direct_cache[0 - 1*8]= direct_table[b8_xy + 2]; + direct_cache[2 - 1*8]= direct_table[b8_xy + 3]; + }else{ + AV_WN32A(&direct_cache[-1*8], 0x01010101*(MB_TYPE_16x16>>1)); + } + + if(IS_DIRECT(left_type[LTOP])) + direct_cache[-1 + 0*8]= MB_TYPE_DIRECT2>>1; + else if(IS_8X8(left_type[LTOP])) + direct_cache[-1 + 0*8]= direct_table[4*left_xy[LTOP] + 1 + (left_block[0]&~1)]; + else + direct_cache[-1 + 0*8]= MB_TYPE_16x16>>1; + + if(IS_DIRECT(left_type[LBOT])) + direct_cache[-1 + 2*8]= MB_TYPE_DIRECT2>>1; + else if(IS_8X8(left_type[LBOT])) + direct_cache[-1 + 2*8]= direct_table[4*left_xy[LBOT] + 1 + (left_block[2]&~1)]; + else + direct_cache[-1 + 2*8]= MB_TYPE_16x16>>1; + } + } + } + if(FRAME_MBAFF){ +#define MAP_MVS\ + MAP_F2F(scan8[0] - 1 - 1*8, topleft_type)\ + MAP_F2F(scan8[0] + 0 - 1*8, top_type)\ + MAP_F2F(scan8[0] + 1 - 1*8, top_type)\ + MAP_F2F(scan8[0] + 2 - 1*8, top_type)\ + MAP_F2F(scan8[0] + 3 - 1*8, top_type)\ + MAP_F2F(scan8[0] + 4 - 1*8, topright_type)\ + MAP_F2F(scan8[0] - 1 + 0*8, left_type[LTOP])\ + MAP_F2F(scan8[0] - 1 + 1*8, left_type[LTOP])\ + MAP_F2F(scan8[0] - 1 + 2*8, left_type[LBOT])\ + MAP_F2F(scan8[0] - 1 + 3*8, left_type[LBOT]) + if(MB_FIELD){ +#define MAP_F2F(idx, mb_type)\ + if(!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ + h->ref_cache[list][idx] <<= 1;\ + h->mv_cache[list][idx][1] /= 2;\ + h->mvd_cache[list][idx][1] >>=1;\ + } + MAP_MVS +#undef MAP_F2F + }else{ +#define MAP_F2F(idx, mb_type)\ + if(IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ + h->ref_cache[list][idx] >>= 1;\ + h->mv_cache[list][idx][1] <<= 1;\ + h->mvd_cache[list][idx][1] <<= 1;\ + } + MAP_MVS +#undef MAP_F2F + } + } + } + } + + h->neighbor_transform_size= !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]); +} + /** * decodes a P_SKIP or B_SKIP macroblock */ From 96c1e6d40d389eeb628840030dfe340d762a7ac8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 2 Jul 2011 14:47:34 +0200 Subject: [PATCH 510/780] doxygen: Make sure parameter names match between .c and .h files. --- libavcodec/lpc.c | 6 ++---- libavfilter/graphparser.c | 2 ++ libavformat/rdt.h | 14 +++++++------- libavformat/rtsp.h | 4 ++-- libavformat/url.h | 6 +++--- libavutil/parseutils.c | 16 ++++++++-------- libavutil/parseutils.h | 2 +- libswscale/swscale.h | 7 ++++--- libswscale/swscale_unscaled.c | 11 ++++++----- libswscale/utils.c | 8 ++++++-- 10 files changed, 41 insertions(+), 35 deletions(-) diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c index 31fa324216..874af0513e 100644 --- a/libavcodec/lpc.c +++ b/libavcodec/lpc.c @@ -149,10 +149,8 @@ static int estimate_best_order(double *ref, int min_order, int max_order) /** * Calculate LPC coefficients for multiple orders * - * @param lpc_type LPC method for determining coefficients - * 0 = LPC with fixed pre-defined coeffs - * 1 = LPC with coeffs determined by Levinson-Durbin recursion - * 2+ = LPC with coeffs determined by Cholesky factorization using (use_lpc-1) passes. + * @param lpc_type LPC method for determining coefficients, + * see #FFLPCType for details */ int ff_lpc_calc_coefs(LPCContext *s, const int32_t *samples, int blocksize, int min_order, diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index c1624d8471..f5e68edfa4 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -141,6 +141,8 @@ static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int ind * corresponding filter instance which is added to graph with * create_filter(). * + * @param filt_ctx Pointer that is set to the created and configured filter + * context on success, set to NULL on failure. * @param filt_ctx put here a pointer to the created filter context on * success, NULL otherwise * @param buf pointer to the buffer to parse, *buf will be updated to diff --git a/libavformat/rdt.h b/libavformat/rdt.h index 08b17bc397..a393299415 100644 --- a/libavformat/rdt.h +++ b/libavformat/rdt.h @@ -80,16 +80,16 @@ void ff_rdt_subscribe_rule(char *cmd, int size, * * @param buf input buffer * @param len length of input buffer - * @param set_id will be set to the set ID this packet belongs to - * @param seq_no will be set to the sequence number of the packet - * @param stream_id will be set to the stream ID this packet belongs to - * @param is_keyframe will be whether this packet belongs to a keyframe - * @param timestamp will be set to the timestamp of the packet + * @param pset_id will be set to the set ID this packet belongs to + * @param pseq_no will be set to the sequence number of the packet + * @param pstream_id will be set to the stream ID this packet belongs to + * @param pis_keyframe will be whether this packet belongs to a keyframe + * @param ptimestamp will be set to the timestamp of the packet * @return the amount of bytes consumed, or negative on error */ int ff_rdt_parse_header(const uint8_t *buf, int len, - int *set_id, int *seq_no, int *stream_id, - int *is_keyframe, uint32_t *timestamp); + int *pset_id, int *pseq_no, int *pstream_id, + int *pis_keyframe, uint32_t *ptimestamp); /** * Parse RDT-style packet data (header + media data). diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 7d2460fe2f..372ed96e6f 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -488,9 +488,9 @@ void ff_rtsp_close_streams(AVFormatContext *s); /** * Close all connection handles within the RTSP (de)muxer * - * @param rt RTSP (de)muxer context + * @param s RTSP (de)muxer context */ -void ff_rtsp_close_connections(AVFormatContext *rt); +void ff_rtsp_close_connections(AVFormatContext *s); /** * Get the description of the stream and set up the RTSPStream child diff --git a/libavformat/url.h b/libavformat/url.h index caafe07cce..d69d0bc5c5 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -74,12 +74,12 @@ typedef struct URLProtocol { * @return 0 in case of success, a negative value corresponding to an * AVERROR code in case of failure */ -int ffurl_alloc(URLContext **h, const char *url, int flags); +int ffurl_alloc(URLContext **puc, const char *filename, int flags); /** * Connect an URLContext that has been allocated by ffurl_alloc */ -int ffurl_connect(URLContext *h); +int ffurl_connect(URLContext *uc); /** * Create an URLContext for accessing to the resource indicated by @@ -92,7 +92,7 @@ int ffurl_connect(URLContext *h); * @return 0 in case of success, a negative value corresponding to an * AVERROR code in case of failure */ -int ffurl_open(URLContext **h, const char *url, int flags); +int ffurl_open(URLContext **puc, const char *filename, int flags); /** * Read up to size bytes from the resource accessed by h, and store diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index 9bac7ab9ce..a7a4518215 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -484,7 +484,7 @@ static time_t mktimegm(struct tm *tm) return t; } -int av_parse_time(int64_t *timeval, const char *datestr, int duration) +int av_parse_time(int64_t *timeval, const char *timestr, int duration) { const char *p; int64_t t; @@ -506,19 +506,19 @@ int av_parse_time(int64_t *timeval, const char *datestr, int duration) #undef time time_t now = time(0); - len = strlen(datestr); + len = strlen(timestr); if (len > 0) - lastch = datestr[len - 1]; + lastch = timestr[len - 1]; else lastch = '\0'; is_utc = (lastch == 'z' || lastch == 'Z'); memset(&dt, 0, sizeof(dt)); - p = datestr; + p = timestr; q = NULL; if (!duration) { - if (!strncasecmp(datestr, "now", len)) { + if (!strncasecmp(timestr, "now", len)) { *timeval = (int64_t) now * 1000000; return 0; } @@ -555,15 +555,15 @@ int av_parse_time(int64_t *timeval, const char *datestr, int duration) } } } else { - /* parse datestr as a duration */ + /* parse timestr as a duration */ if (p[0] == '-') { negative = 1; ++p; } - /* parse datestr as HH:MM:SS */ + /* parse timestr as HH:MM:SS */ q = small_strptime(p, time_fmt[0], &dt); if (!q) { - /* parse datestr as S+ */ + /* parse timestr as S+ */ dt.tm_sec = strtol(p, (char **)&q, 10); if (q == p) { /* the parsing didn't succeed */ diff --git a/libavutil/parseutils.h b/libavutil/parseutils.h index befbbb56a1..0d78b3ea3b 100644 --- a/libavutil/parseutils.h +++ b/libavutil/parseutils.h @@ -83,7 +83,7 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, * January, 1970 up to the time of the parsed date. If timestr cannot * be successfully parsed, set *time to INT64_MIN. - * @param datestr a string representing a date or a duration. + * @param timestr a string representing a date or a duration. * - If a date the syntax is: * @code * [{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH[:MM[:SS[.m...]]]}|{HH[MM[SS[.m...]]]}}[Z] diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 80e5eaab00..f05a61e212 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -215,7 +215,7 @@ struct SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat * top-bottom or bottom-top order. If slices are provided in * non-sequential order the behavior of the function is undefined. * - * @param context the scaling context previously created with + * @param c the scaling context previously created with * sws_getContext() * @param srcSlice the array containing the pointers to the planes of * the source slice @@ -232,8 +232,9 @@ struct SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat * the destination image * @return the height of the output slice */ -int sws_scale(struct SwsContext *context, const uint8_t* const srcSlice[], const int srcStride[], - int srcSliceY, int srcSliceH, uint8_t* const dst[], const int dstStride[]); +int sws_scale(struct SwsContext *c, const uint8_t* const srcSlice[], + const int srcStride[], int srcSliceY, int srcSliceH, + uint8_t* const dst[], const int dstStride[]); /** * @param inv_table the yuv2rgb coefficients, normally ff_yuv2rgb_coeffs[x] diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index b8daa6b4e7..e6dac22cfe 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -804,18 +804,19 @@ static int check_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, * swscale wrapper, so we don't need to export the SwsContext. * Assumes planar YUV to be in YUV order instead of YVU. */ -int sws_scale(SwsContext *c, const uint8_t* const src[], const int srcStride[], int srcSliceY, - int srcSliceH, uint8_t* const dst[], const int dstStride[]) +int sws_scale(struct SwsContext *c, const uint8_t* const srcSlice[], + const int srcStride[], int srcSliceY, int srcSliceH, + uint8_t* const dst[], const int dstStride[]) { int i; - const uint8_t* src2[4]= {src[0], src[1], src[2], src[3]}; + const uint8_t* src2[4]= {srcSlice[0], srcSlice[1], srcSlice[2], srcSlice[3]}; uint8_t* dst2[4]= {dst[0], dst[1], dst[2], dst[3]}; // do not mess up sliceDir if we have a "trailing" 0-size slice if (srcSliceH == 0) return 0; - if (!check_image_pointers(src, c->srcFormat, srcStride)) { + if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) { av_log(c, AV_LOG_ERROR, "bad src image pointers\n"); return 0; } @@ -836,7 +837,7 @@ int sws_scale(SwsContext *c, const uint8_t* const src[], const int srcStride[], for (i=0; i<256; i++) { int p, r, g, b,y,u,v; if(c->srcFormat == PIX_FMT_PAL8) { - p=((const uint32_t*)(src[1]))[i]; + p=((const uint32_t*)(srcSlice[1]))[i]; r= (p>>16)&0xFF; g= (p>> 8)&0xFF; b= p &0xFF; diff --git a/libswscale/utils.c b/libswscale/utils.c index 296c84557d..6647f68682 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -711,7 +711,9 @@ static void getSubSampleFactors(int *h, int *v, enum PixelFormat format) *v = av_pix_fmt_descriptors[format].log2_chroma_h; } -int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation) +int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], + int srcRange, const int table[4], int dstRange, + int brightness, int contrast, int saturation) { memcpy(c->srcColorspaceTable, inv_table, sizeof(int)*4); memcpy(c->dstColorspaceTable, table, sizeof(int)*4); @@ -734,7 +736,9 @@ int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange return 0; } -int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation) +int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, + int *srcRange, int **table, int *dstRange, + int *brightness, int *contrast, int *saturation) { if (isYUV(c->dstFormat) || isGray(c->dstFormat)) return -1; From d0fcf39f0c6201c8cce439395eee051798c0a958 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 4 Jul 2011 12:33:11 +0200 Subject: [PATCH 511/780] doxygen: Move function documentation into the macro generating the function. This fixes a bunch of related warnings where Doxygen assumed that the documentation belonged to the macro and not the function. --- Doxyfile | 3 ++- libavcodec/aacps.c | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Doxyfile b/Doxyfile index a4beaba323..bb8d92b298 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1382,7 +1382,8 @@ PREDEFINED = "__attribute__(x)=" \ # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. -EXPAND_AS_DEFINED = declare_idct +EXPAND_AS_DEFINED = declare_idct \ + READ_PAR_DATA \ # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c index d818790a6f..03d0beabdd 100644 --- a/libavcodec/aacps.c +++ b/libavcodec/aacps.c @@ -69,19 +69,19 @@ static const int huff_iid[] = { static VLC vlc_ps[10]; -/** - * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ - * Inter-channel Phase Difference/Overall Phase Difference parameters from the - * bitstream. - * - * @param avctx contains the current codec context - * @param gb pointer to the input bitstream - * @param ps pointer to the Parametric Stereo context - * @param PAR pointer to the parameter to be read - * @param e envelope to decode - * @param dt 1: time delta-coded, 0: frequency delta-coded - */ #define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION) \ +/** \ + * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ \ + * Inter-channel Phase Difference/Overall Phase Difference parameters from the \ + * bitstream. \ + * \ + * @param avctx contains the current codec context \ + * @param gb pointer to the input bitstream \ + * @param ps pointer to the Parametric Stereo context \ + * @param PAR pointer to the parameter to be read \ + * @param e envelope to decode \ + * @param dt 1: time delta-coded, 0: frequency delta-coded \ + */ \ static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, \ int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \ { \ From 8d03ca085f7d355f4c7b3bcc1fd9de488e73e739 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 14 Jul 2011 09:38:36 +0200 Subject: [PATCH 512/780] ffmpeg: print the low bitrate warning after the codec is openend. This doesn't access avcodec_opts, so it works with the new options passing system. Makes opt_bitrate() unneeded, so it's removed. --- doc/ffmpeg.texi | 4 ---- ffmpeg.c | 18 +++--------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 517bb0cd38..5a783e3c15 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -159,8 +159,6 @@ Set the ISO 639 language code (3 letters) of the current subtitle stream. @section Video Options @table @option -@item -b @var{bitrate} -Set the video bitrate in bit/s (default = 200 kb/s). @item -vframes @var{number} Set the number of video frames to record. @item -r @var{fps} @@ -555,8 +553,6 @@ Set the audio sampling frequency. For output streams it is set by default to the frequency of the corresponding input stream. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options. -@item -ab @var{bitrate} -Set the audio bitrate in bit/s (default = 64k). @item -aq @var{q} Set the audio quality (codec-specific, VBR). @item -ac @var{channels} diff --git a/ffmpeg.c b/ffmpeg.c index 5446be9ca4..dcc92ac481 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2349,6 +2349,9 @@ static int transcode(AVFormatContext **output_files, } assert_codec_experimental(ost->st->codec, 1); assert_avoptions(ost->opts); + if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) + av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." + "It takes bits/s as argument, not kbits/s\n"); extra_size += ost->st->codec->extradata_size; } } @@ -2790,18 +2793,6 @@ static int opt_frame_rate(const char *opt, const char *arg) return 0; } -static int opt_bitrate(const char *opt, const char *arg) -{ - int codec_type = opt[0]=='a' ? AVMEDIA_TYPE_AUDIO : AVMEDIA_TYPE_VIDEO; - - opt_default(opt, arg); - - if (av_get_int(avcodec_opts[codec_type], "b", NULL) < 1000) - fprintf(stderr, "WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s\n"); - - return 0; -} - static int opt_frame_crop(const char *opt, const char *arg) { fprintf(stderr, "Option '%s' has been removed, use the crop filter instead\n", opt); @@ -4290,8 +4281,6 @@ static const OptionDef options[] = { { "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)©_initial_nonkeyframes}, "copy initial non-keyframes" }, /* video options */ - { "b", HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" }, - { "vb", HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" }, { "vframes", OPT_INT | HAS_ARG | OPT_VIDEO, {(void*)&max_frames[AVMEDIA_TYPE_VIDEO]}, "set the number of video frames to record", "number" }, { "r", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_rate}, "set frame rate (Hz value, fraction or abbreviation)", "rate" }, { "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" }, @@ -4338,7 +4327,6 @@ static const OptionDef options[] = { { "force_key_frames", OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void *)&forced_key_frames}, "force key frames at specified timestamps", "timestamps" }, /* audio options */ - { "ab", HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" }, { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&max_frames[AVMEDIA_TYPE_AUDIO]}, "set the number of audio frames to record", "number" }, { "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set audio quality (codec-specific)", "quality", }, { "ar", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" }, From f2f523fffc59ea69772948e2754f3a87acd8406e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 14 Jul 2011 10:09:05 +0200 Subject: [PATCH 513/780] Add an APIChanges entry and bump minor versions for recent changes. --- doc/APIchanges | 6 ++++++ libavcodec/version.h | 2 +- libavformat/version.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 65e1da7a62..4074e3f4f2 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,12 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-07-xx - xxxxxxx - lavf 53.3.0 + Add avformat_find_stream_info(), deprecate av_find_stream_info(). + +2011-07-xx - xxxxxxx - lavc 53.6.0 + Add avcodec_open2(), deprecate avcodec_open(). + 2011-06-xx - xxxxxxx - lavu 51.8.0 - attributes.h Add av_printf_format(). diff --git a/libavcodec/version.h b/libavcodec/version.h index 32b2bb314c..a4e0402cad 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -21,7 +21,7 @@ #define AVCODEC_VERSION_H #define LIBAVCODEC_VERSION_MAJOR 53 -#define LIBAVCODEC_VERSION_MINOR 5 +#define LIBAVCODEC_VERSION_MINOR 6 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavformat/version.h b/libavformat/version.h index cae0339f62..bb12b5137a 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -24,7 +24,7 @@ #include "libavutil/avutil.h" #define LIBAVFORMAT_VERSION_MAJOR 53 -#define LIBAVFORMAT_VERSION_MINOR 2 +#define LIBAVFORMAT_VERSION_MINOR 3 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ From 6cb11979295ae5d3b9bad0965cbd6a06d9c9783b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 14 Jul 2011 10:43:24 +0200 Subject: [PATCH 514/780] APIchanges: fill in missing hashes and dates. --- doc/APIchanges | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4074e3f4f2..c533818efa 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,29 +13,29 @@ libavutil: 2011-04-18 API changes, most recent first: -2011-07-xx - xxxxxxx - lavf 53.3.0 +2011-07-10 - a67c061 - lavf 53.3.0 Add avformat_find_stream_info(), deprecate av_find_stream_info(). -2011-07-xx - xxxxxxx - lavc 53.6.0 +2011-07-10 - 0b950fe - lavc 53.6.0 Add avcodec_open2(), deprecate avcodec_open(). -2011-06-xx - xxxxxxx - lavu 51.8.0 - attributes.h +2011-06-23 - 67e9ae1 - lavu 51.8.0 - attributes.h Add av_printf_format(). -2011-06-xx - xxxxxxx - lavf 53.2.0 - avformat.h +2011-06-16 - 05e84c9, 25de595 - lavf 53.2.0 - avformat.h Add avformat_open_input and avformat_write_header(). Deprecate av_open_input_stream, av_open_input_file, AVFormatParameters and av_write_header. -2011-06-xx - xxxxxxx - lavu 51.7.0 - opt.h +2011-06-16 - 7e83e1c, dc59ec5 - lavu 51.7.0 - opt.h Add av_opt_set_dict() and av_opt_find(). Deprecate av_find_opt(). Add AV_DICT_APPEND flag. -2011-06-xx - xxxxxxx - lavu 51.6.0 - opt.h +2011-06-10 - cb7c11c - lavu 51.6.0 - opt.h Add av_opt_flag_is_set(). -2011-06-xx - xxxxxxx - lavu 51.5.0 - AVMetadata +2011-06-08 - d9f80ea - lavu 51.5.0 - AVMetadata Move AVMetadata from lavf to lavu and rename it to AVDictionary -- new installed header dict.h. All av_metadata_* functions renamed to av_dict_*. @@ -44,7 +44,7 @@ API changes, most recent first: Add av_get_bytes_per_sample() in libavutil/samplefmt.h. Deprecate av_get_bits_per_sample_fmt(). -2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h +2011-06-05 - b39b062 - lavu 51.3.0 - opt.h Add av_opt_free convenience function. 2011-05-28 - 0420bd7 - lavu 51.2.0 - pixdesc.h From 371888cad5ce1578846c8a5b8925fccbf33b701b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 14 Jul 2011 17:49:29 +0200 Subject: [PATCH 515/780] seektest: forgot adding a file (from commit 191c5f8ff33eb995b6dbc5b11af7c1a79f8381f0 during the last merge) Signed-off-by: Michael Niedermayer --- libavformat/seek-test.c | 133 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 libavformat/seek-test.c diff --git a/libavformat/seek-test.c b/libavformat/seek-test.c new file mode 100644 index 0000000000..76a3e8ccff --- /dev/null +++ b/libavformat/seek-test.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2003 Fabrice Bellard + * Copyright (c) 2007 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include + +#include "libavutil/common.h" +#include "libavutil/mathematics.h" +#include "libavformat/avformat.h" + +#undef exit +#undef printf +#undef fprintf + +static char buffer[20]; + +static const char *ret_str(int v) +{ + switch (v) { + case AVERROR_EOF: return "-EOF"; + case AVERROR(EIO): return "-EIO"; + case AVERROR(ENOMEM): return "-ENOMEM"; + case AVERROR(EINVAL): return "-EINVAL"; + default: + snprintf(buffer, sizeof(buffer), "%2d", v); + return buffer; + } +} + +static void ts_str(char buffer[60], int64_t ts, AVRational base) +{ + double tsval; + if (ts == AV_NOPTS_VALUE) { + strcpy(buffer, " NOPTS "); + return; + } + tsval = ts * av_q2d(base); + snprintf(buffer, 60, "%9f", tsval); +} + +int main(int argc, char **argv) +{ + const char *filename; + AVFormatContext *ic = NULL; + int i, ret, stream_id; + int64_t timestamp; + AVFormatParameters params, *ap= ¶ms; + memset(ap, 0, sizeof(params)); + ap->channels=1; + ap->sample_rate= 22050; + + /* initialize libavcodec, and register all codecs and formats */ + av_register_all(); + + if (argc != 2) { + printf("usage: %s input_file\n" + "\n", argv[0]); + exit(1); + } + + filename = argv[1]; + + ret = av_open_input_file(&ic, filename, NULL, 0, ap); + if (ret < 0) { + fprintf(stderr, "cannot open %s\n", filename); + exit(1); + } + + ret = av_find_stream_info(ic); + if (ret < 0) { + fprintf(stderr, "%s: could not find codec parameters\n", filename); + exit(1); + } + + for(i=0; ; i++){ + AVPacket pkt; + AVStream *av_uninit(st); + char ts_buf[60]; + + memset(&pkt, 0, sizeof(pkt)); + if(ret>=0){ + ret= av_read_frame(ic, &pkt); + if(ret>=0){ + char dts_buf[60]; + st= ic->streams[pkt.stream_index]; + ts_str(dts_buf, pkt.dts, st->time_base); + ts_str(ts_buf, pkt.pts, st->time_base); + printf("ret:%-10s st:%2d flags:%d dts:%s pts:%s pos:%7" PRId64 " size:%6d", ret_str(ret), pkt.stream_index, pkt.flags, dts_buf, ts_buf, pkt.pos, pkt.size); + av_free_packet(&pkt); + } else + printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace + printf("\n"); + } + + if(i>25) break; + + stream_id= (i>>1)%(ic->nb_streams+1) - 1; + timestamp= (i*19362894167LL) % (4*AV_TIME_BASE) - AV_TIME_BASE; + if(stream_id>=0){ + st= ic->streams[stream_id]; + timestamp= av_rescale_q(timestamp, AV_TIME_BASE_Q, st->time_base); + } + //FIXME fully test the new seek API + if(i&1) ret = avformat_seek_file(ic, stream_id, INT64_MIN, timestamp, timestamp, 0); + else ret = avformat_seek_file(ic, stream_id, timestamp, timestamp, INT64_MAX, 0); + ts_str(ts_buf, timestamp, stream_id < 0 ? AV_TIME_BASE_Q : st->time_base); + printf("ret:%-10s st:%2d flags:%d ts:%s\n", ret_str(ret), stream_id, i&1, ts_buf); + } + + av_close_input_file(ic); + + return 0; +} From f790d0092e360aa4d5f6f140a92bd954ee8859c4 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 9 Jun 2011 10:58:23 +0200 Subject: [PATCH 516/780] ffmpeg: use new avformat_open_* API. 8035f429684e368fe54af8ccedc2d4776a2d6154 --- ffmpeg.c | 84 ++++++++++++++++++++++++++++--------------------- tests/fate2.mak | 2 +- 2 files changed, 49 insertions(+), 37 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 6196a5ade5..dec4b82578 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -120,6 +120,7 @@ static double *ts_scale; static int nb_ts_scale; static AVFormatContext *output_files[MAX_FILES]; +static AVDictionary *output_opts[MAX_FILES]; static int nb_output_files = 0; static StreamMap *stream_maps = NULL; @@ -533,6 +534,7 @@ static int ffmpeg_exit(int ret) avio_close(s->pb); avformat_free_context(s); av_free(output_streams_for_file[i]); + av_dict_free(&output_opts[i]); } for(i=0;ikey); + ffmpeg_exit(1); + } +} + /* similar to ff_dynarray_add() and av_fast_realloc() */ static void *grow_array(void *array, int elem_size, int *size, int new_size) { @@ -704,10 +715,10 @@ static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx, AVCode static int read_ffserver_streams(AVFormatContext *s, const char *filename) { int i, err; - AVFormatContext *ic; + AVFormatContext *ic = NULL; int nopts = 0; - err = av_open_input_file(&ic, filename, NULL, FFM_PACKET_SIZE, NULL); + err = avformat_open_input(&ic, filename, NULL, NULL); if (err < 0) return err; /* copy stream format */ @@ -2540,11 +2551,12 @@ static int transcode(AVFormatContext **output_files, /* open files and write file headers */ for(i=0;ioformat->name, "rtp")) { want_sdp = 0; } @@ -3267,10 +3279,10 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder, i static int opt_input_file(const char *opt, const char *filename) { AVFormatContext *ic; - AVFormatParameters params, *ap = ¶ms; AVInputFormat *file_iformat = NULL; int err, i, ret, rfps, rfps_base; int64_t timestamp; + uint8_t buf[128]; if (last_asked_format) { if (!(file_iformat = av_find_input_format(last_asked_format))) { @@ -3292,21 +3304,24 @@ static int opt_input_file(const char *opt, const char *filename) print_error(filename, AVERROR(ENOMEM)); ffmpeg_exit(1); } - - memset(ap, 0, sizeof(*ap)); - ap->prealloced_context = 1; - ap->sample_rate = audio_sample_rate; - ap->channels = audio_channels; - ap->time_base.den = frame_rate.num; - ap->time_base.num = frame_rate.den; - ap->width = frame_width; - ap->height = frame_height; - ap->pix_fmt = frame_pix_fmt; - // ap->sample_fmt = audio_sample_fmt; //FIXME:not implemented in libavformat - ap->channel = video_channel; - ap->standard = video_standard; - - set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM, NULL); + if (audio_sample_rate) { + snprintf(buf, sizeof(buf), "%d", audio_sample_rate); + av_dict_set(&format_opts, "sample_rate", buf, 0); + } + if (audio_channels) { + snprintf(buf, sizeof(buf), "%d", audio_channels); + av_dict_set(&format_opts, "channels", buf, 0); + } + if (frame_rate.num) { + snprintf(buf, sizeof(buf), "%d/%d", frame_rate.num, frame_rate.den); + av_dict_set(&format_opts, "framerate", buf, 0); + } + if (frame_width && frame_height) { + snprintf(buf, sizeof(buf), "%dx%d", frame_width, frame_height); + av_dict_set(&format_opts, "video_size", buf, 0); + } + if (frame_pix_fmt != PIX_FMT_NONE) + av_dict_set(&format_opts, "pixel_format", av_get_pix_fmt_name(frame_pix_fmt), 0); ic->video_codec_id = find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0, @@ -3317,20 +3332,16 @@ static int opt_input_file(const char *opt, const char *filename) ic->subtitle_codec_id= find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0, avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); - ic->flags |= AVFMT_FLAG_NONBLOCK | AVFMT_FLAG_PRIV_OPT; + ic->flags |= AVFMT_FLAG_NONBLOCK; /* open the input file with generic libav function */ - err = av_open_input_file(&ic, filename, file_iformat, 0, ap); - if(err >= 0){ - set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM, NULL); - err = av_demuxer_open(ic, ap); - if(err < 0) - avformat_free_context(ic); - } + err = avformat_open_input(&ic, filename, file_iformat, &format_opts); if (err < 0) { print_error(filename, err); ffmpeg_exit(1); } + assert_avoptions(format_opts); + if(opt_programid) { int i, j; int found=0; @@ -3856,7 +3867,6 @@ static int opt_output_file(const char *opt, const char *filename) AVFormatContext *oc; int err, use_video, use_audio, use_subtitle, use_data; int input_has_video, input_has_audio, input_has_subtitle, input_has_data; - AVFormatParameters params, *ap = ¶ms; AVOutputFormat *file_oformat; if(nb_output_files >= FF_ARRAY_ELEMS(output_files)){ @@ -3920,6 +3930,7 @@ static int opt_output_file(const char *opt, const char *filename) av_dict_free(&metadata); } + av_dict_copy(&output_opts[nb_output_files], format_opts, 0); output_files[nb_output_files++] = oc; /* check filename in case of an image number is expected */ @@ -3959,17 +3970,9 @@ static int opt_output_file(const char *opt, const char *filename) } } - memset(ap, 0, sizeof(*ap)); - if (av_set_parameters(oc, ap) < 0) { - fprintf(stderr, "%s: Invalid encoding parameters\n", - oc->filename); - ffmpeg_exit(1); - } - oc->preload= (int)(mux_preload*AV_TIME_BASE); oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE); - set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL); if (loop_output >= 0) { av_log(NULL, AV_LOG_WARNING, "-loop_output is deprecated, use -loop\n"); oc->loop_output = loop_output; @@ -4074,6 +4077,7 @@ static int opt_help(const char *opt, const char *arg) { AVCodec *c; AVOutputFormat *oformat = NULL; + AVInputFormat *iformat = NULL; av_log_set_callback(log_callback_help); show_usage(); @@ -4124,6 +4128,14 @@ static int opt_help(const char *opt, const char *arg) } } + /* individual demuxer options */ + while ((iformat = av_iformat_next(iformat))) { + if (iformat->priv_class) { + av_opt_show2(&iformat->priv_class, NULL, AV_OPT_FLAG_DECODING_PARAM, 0); + printf("\n"); + } + } + av_opt_show2(sws_opts, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); return 0; } diff --git a/tests/fate2.mak b/tests/fate2.mak index c5b91e246f..a743f0cd59 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -165,7 +165,7 @@ fate-wmapro-2ch: CMP = oneoff fate-wmapro-2ch: REF = $(SAMPLES)/wmapro/Beethovens_9th-1_small.pcm FATE_TESTS += fate-ansi -fate-ansi: CMD = framecrc -ar 44100 -i $(SAMPLES)/ansi/TRE-IOM5.ANS -pix_fmt rgb24 +fate-ansi: CMD = framecrc -chars_per_frame 44100 -i $(SAMPLES)/ansi/TRE-IOM5.ANS -pix_fmt rgb24 FATE_TESTS += fate-wmv8-drm # discard last packet to avoid fails due to overread of VC-1 decoder From 1885824b20a493d25db4b8e5397666e3a68f45f2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 15 Jun 2011 07:34:12 +0200 Subject: [PATCH 517/780] ffmpeg: deprecate -vc and -tvstd They've been replaced by demuxer private options. 55ba12e3009fd6c8f78102f7c747496d500d0bac --- ffmpeg.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index dec4b82578..b458dbad0a 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -219,9 +219,6 @@ static int copy_initial_nonkeyframes = 0; static int rate_emu = 0; -static int video_channel = 0; -static char *video_standard; - static int audio_volume = 256; static int exit_on_error = 0; @@ -559,8 +556,6 @@ static int ffmpeg_exit(int ret) av_free(subtitle_codec_name); av_free(data_codec_name); - av_free(video_standard); - uninit_opts(); av_free(audio_buf); av_free(audio_out); @@ -3051,13 +3046,15 @@ static int opt_audio_channels(const char *opt, const char *arg) static int opt_video_channel(const char *opt, const char *arg) { - video_channel = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX); + av_log(NULL, AV_LOG_WARNING, "This option is deprecated, use -channel.\n"); + opt_default("channel", arg); return 0; } static int opt_video_standard(const char *opt, const char *arg) { - video_standard = av_strdup(arg); + av_log(NULL, AV_LOG_WARNING, "This option is deprecated, use -standard.\n"); + opt_default("standard", arg); return 0; } @@ -3478,7 +3475,6 @@ static int opt_input_file(const char *opt, const char *filename) input_files[nb_input_files - 1].ts_offset = input_ts_offset - (copy_ts ? 0 : timestamp); top_field_first = -1; - video_channel = 0; frame_rate = (AVRational){0, 0}; frame_pix_fmt = PIX_FMT_NONE; frame_height = 0; @@ -4490,8 +4486,8 @@ static const OptionDef options[] = { { "stag", HAS_ARG | OPT_EXPERT | OPT_SUBTITLE, {(void*)opt_codec_tag}, "force subtitle tag/fourcc", "fourcc/tag" }, /* grab options */ - { "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_channel}, "set video grab channel (DV1394 only)", "channel" }, - { "tvstd", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_standard}, "set television standard (NTSC, PAL (SECAM))", "standard" }, + { "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_channel}, "deprecated, use -channel", "channel" }, + { "tvstd", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_standard}, "deprecated, use -standard", "standard" }, { "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, {(void*)&input_sync}, "sync read on input", "" }, /* muxer options */ From 5a819c5e23b46bb03a9862790452ff829ea1e898 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 7 Jul 2011 02:01:07 +0200 Subject: [PATCH 518/780] avformat_open_input(): Add braces to shut up gcc warning. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libavformat/utils.c:599: warning: missing braces around initializer libavformat/utils.c:599: warning: (near initialization for ‘ap.time_base’) --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index cc0336a670..4b675e66c2 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -597,7 +597,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma { AVFormatContext *s = *ps; int ret = 0; - AVFormatParameters ap = { 0 }; + AVFormatParameters ap = { { 0 } }; AVDictionary *tmp = NULL; if (!s && !(s = avformat_alloc_context())) From ec679eb4530174fe8d1e06c6010597539f6c1c97 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 14 Jul 2011 03:12:36 +0200 Subject: [PATCH 519/780] doxygen: place empty line between brief description and detailed description Without it, Doxygen cannot separate them into different sections. --- libavcodec/8svx.c | 1 + libavcodec/qdm2.c | 1 + libavcodec/rl2.c | 1 + libavformat/iss.c | 3 ++- libavformat/rl2.c | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c index 5fdea915ff..4b60377128 100644 --- a/libavcodec/8svx.c +++ b/libavcodec/8svx.c @@ -23,6 +23,7 @@ * @file * 8svx audio decoder * @author Jaikrishnan Menon + * * supports: fibonacci delta encoding * : exponential encoding */ diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 86847adc10..2a45495c7c 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -26,6 +26,7 @@ * @file * QDM2 decoder * @author Ewald Snel, Benjamin Larsson, Alex Beregszaszi, Roberto Togni + * * The decoder is not perfect yet, there are still some distortions * especially on files encoded with 16 or 8 subbands. */ diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 3d1cea3995..c88e8ed343 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -23,6 +23,7 @@ * RL2 Video Decoder * @file * @author Sascha Sommer (saschasommer@freenet.de) + * * For more information about the RL2 format, visit: * http://wiki.multimedia.cx/index.php?title=RL2 */ diff --git a/libavformat/iss.c b/libavformat/iss.c index fe5203dbcd..100066bad2 100644 --- a/libavformat/iss.c +++ b/libavformat/iss.c @@ -23,7 +23,8 @@ * @file * Funcom ISS file demuxer * @author Jaikrishnan Menon - * for more information on the .iss file format, visit: + * + * For more information on the .iss file format, visit: * http://wiki.multimedia.cx/index.php?title=FunCom_ISS */ diff --git a/libavformat/rl2.c b/libavformat/rl2.c index 12cb391ad8..68c1a01636 100644 --- a/libavformat/rl2.c +++ b/libavformat/rl2.c @@ -23,6 +23,7 @@ * RL2 file demuxer * @file * @author Sascha Sommer (saschasommer@freenet.de) + * * For more information regarding the RL2 file format, visit: * http://wiki.multimedia.cx/index.php?title=RL2 * From f6f95d4e4930b087851165d84dec1b45e412e86b Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 14 Jul 2011 03:46:19 +0200 Subject: [PATCH 520/780] doxygen: consistently place brief description --- libavcodec/faxcompr.c | 2 +- libavcodec/faxcompr.h | 2 +- libavcodec/lzwenc.c | 2 +- libavcodec/pcxenc.c | 2 +- libavcodec/rl2.c | 2 +- libavcodec/tiff.c | 3 ++- libavcodec/tiff.h | 3 ++- libavcodec/tiffenc.c | 3 ++- libavcodec/tmv.c | 2 +- libavformat/soxdec.c | 2 +- libavformat/soxenc.c | 2 +- libavformat/tmv.c | 2 +- 12 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libavcodec/faxcompr.c b/libavcodec/faxcompr.c index 79e8d757af..e59dad676a 100644 --- a/libavcodec/faxcompr.c +++ b/libavcodec/faxcompr.c @@ -20,8 +20,8 @@ */ /** - * CCITT Fax Group 3 and 4 decompression * @file + * CCITT Fax Group 3 and 4 decompression * @author Konstantin Shishkov */ #include "avcodec.h" diff --git a/libavcodec/faxcompr.h b/libavcodec/faxcompr.h index 4742d15e59..8157f1fc21 100644 --- a/libavcodec/faxcompr.h +++ b/libavcodec/faxcompr.h @@ -20,8 +20,8 @@ */ /** - * CCITT Fax Group 3 and 4 decompression * @file + * CCITT Fax Group 3 and 4 decompression * @author Konstantin Shishkov */ #ifndef AVCODEC_FAXCOMPR_H diff --git a/libavcodec/lzwenc.c b/libavcodec/lzwenc.c index df38116c0d..cb064e7936 100644 --- a/libavcodec/lzwenc.c +++ b/libavcodec/lzwenc.c @@ -20,8 +20,8 @@ */ /** - * LZW encoder * @file + * LZW encoder * @author Bartlomiej Wolowiec */ diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c index 81629d0add..2df84afa38 100644 --- a/libavcodec/pcxenc.c +++ b/libavcodec/pcxenc.c @@ -20,8 +20,8 @@ */ /** - * PCX image encoder * @file + * PCX image encoder * @author Daniel Verkamp * @sa http://www.qzx.com/pc-gpe/pcx.txt */ diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index c88e8ed343..9d436a682f 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -20,8 +20,8 @@ */ /** - * RL2 Video Decoder * @file + * RL2 Video Decoder * @author Sascha Sommer (saschasommer@freenet.de) * * For more information about the RL2 format, visit: diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 08cd3b0a6f..7241d6f3fb 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -20,10 +20,11 @@ */ /** - * TIFF image decoder * @file + * TIFF image decoder * @author Konstantin Shishkov */ + #include "avcodec.h" #if CONFIG_ZLIB #include diff --git a/libavcodec/tiff.h b/libavcodec/tiff.h index cd7ec830e7..cf890d678b 100644 --- a/libavcodec/tiff.h +++ b/libavcodec/tiff.h @@ -20,10 +20,11 @@ */ /** - * TIFF tables * @file + * TIFF tables * @author Konstantin Shishkov */ + #ifndef AVCODEC_TIFF_H #define AVCODEC_TIFF_H diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index 5cff13bca0..3d927eb068 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -20,10 +20,11 @@ */ /** - * TIFF image encoder * @file + * TIFF image encoder * @author Bartlomiej Wolowiec */ + #include "avcodec.h" #if CONFIG_ZLIB #include diff --git a/libavcodec/tmv.c b/libavcodec/tmv.c index 80f3ac9cbc..d540182ada 100644 --- a/libavcodec/tmv.c +++ b/libavcodec/tmv.c @@ -20,8 +20,8 @@ */ /** - * 8088flex TMV video decoder * @file + * 8088flex TMV video decoder * @author Daniel Verkamp * @sa http://www.oldskool.org/pc/8088_Corruption */ diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c index b3b35b12fd..ca82ef1cca 100644 --- a/libavformat/soxdec.c +++ b/libavformat/soxdec.c @@ -23,8 +23,8 @@ */ /** - * SoX native format demuxer * @file + * SoX native format demuxer * @author Daniel Verkamp * @sa http://wiki.multimedia.cx/index.php?title=SoX_native_intermediate_format */ diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c index a0faa466df..e28c479c97 100644 --- a/libavformat/soxenc.c +++ b/libavformat/soxenc.c @@ -23,8 +23,8 @@ */ /** - * SoX native format muxer * @file + * SoX native format muxer * @author Daniel Verkamp * @sa http://wiki.multimedia.cx/index.php?title=SoX_native_intermediate_format */ diff --git a/libavformat/tmv.c b/libavformat/tmv.c index f894eab46a..79a875885e 100644 --- a/libavformat/tmv.c +++ b/libavformat/tmv.c @@ -20,8 +20,8 @@ */ /** - * 8088flex TMV file demuxer * @file + * 8088flex TMV file demuxer * @author Daniel Verkamp * @sa http://www.oldskool.org/pc/8088_Corruption */ From a2f31564b4759c02c81f3f4d1be359eb4a18f050 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 14 Jul 2011 03:54:10 +0200 Subject: [PATCH 521/780] doc: remove file name from @file directive in Doxygen usage example The file name is redundant and brittle across file renamings. --- doc/developer.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/developer.texi b/doc/developer.texi index 45a4f4476b..208c119753 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -92,7 +92,7 @@ above them explaining what the function does, even if it is just one sentence. All structures and their member variables should be documented, too. @example /** - * @@file mpeg.c + * @@file * MPEG codec. * @@author ... */ From 99b9df5281ef5e8f1991cd5edd5d5acb49a35144 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 14 Jul 2011 04:05:17 +0200 Subject: [PATCH 522/780] doxygen: misc consistency cosmetics --- libavcodec/g722.c | 1 - libavcodec/lzw.h | 2 +- libavcodec/msmpeg4.h | 4 ---- libavcodec/vaapi_h264.c | 7 ++++--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/libavcodec/g722.c b/libavcodec/g722.c index 257292de7f..74d5552071 100644 --- a/libavcodec/g722.c +++ b/libavcodec/g722.c @@ -26,7 +26,6 @@ /** * @file - * * G.722 ADPCM audio codec * * This G.722 decoder is a bit-exact implementation of the ITU G.722 diff --git a/libavcodec/lzw.h b/libavcodec/lzw.h index d1efdaf131..c6ae05732c 100644 --- a/libavcodec/lzw.h +++ b/libavcodec/lzw.h @@ -24,7 +24,7 @@ * @file * @brief LZW decoding routines * @author Fabrice Bellard - * Modified for use in TIFF by Konstantin Shishkov + * modified for use in TIFF by Konstantin Shishkov */ #ifndef AVCODEC_LZW_H diff --git a/libavcodec/msmpeg4.h b/libavcodec/msmpeg4.h index 8a0a066e48..9247accd48 100644 --- a/libavcodec/msmpeg4.h +++ b/libavcodec/msmpeg4.h @@ -19,10 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/** - * @file - */ - #ifndef AVCODEC_MSMPEG4_H #define AVCODEC_MSMPEG4_H diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c index f6d1a6d48e..51ebaaf5a0 100644 --- a/libavcodec/vaapi_h264.c +++ b/libavcodec/vaapi_h264.c @@ -23,9 +23,10 @@ #include "vaapi_internal.h" #include "h264.h" -/** @file - * This file implements the glue code between Libav's and VA API's - * structures for H.264 decoding. +/** + * @file + * This file implements the glue code between Libav's and VA API's + * structures for H.264 decoding. */ /** From 321b2a9ded0468670b7678b7c098886930ae16b2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 14 Jul 2011 21:22:12 +0200 Subject: [PATCH 523/780] ffmpeg: loose lowres hackery Signed-off-by: Michael Niedermayer --- ffmpeg.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 42c82a0b8a..b73d60a835 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2294,8 +2294,6 @@ static int transcode(AVFormatContext **output_files, ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); if (!codec->sample_rate) { codec->sample_rate = icodec->sample_rate; - if (icodec->lowres) - codec->sample_rate >>= icodec->lowres; } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; @@ -3436,8 +3434,6 @@ static int opt_input_file(const char *opt, const char *filename) rfps_base = ic->streams[i]->r_frame_rate.den; if (dec->lowres) { dec->flags |= CODEC_FLAG_EMU_EDGE; - dec->height >>= dec->lowres; - dec->width >>= dec->lowres; } if(me_threshold) dec->debug |= FF_DEBUG_MV; From 8bc3a4807e2da36f458e7784c3d390dbd19899a5 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 14 Jul 2011 21:27:13 +0200 Subject: [PATCH 524/780] cmdutils: remove #if 0-ed conflict marger trash that i forgot Signed-off-by: Michael Niedermayer --- cmdutils.c | 140 ----------------------------------------------------- 1 file changed, 140 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index d52895008d..b323e91015 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -308,147 +308,7 @@ int opt_default(const char *opt, const char *arg) fprintf(stderr, "Unrecognized option '%s'\n", opt); return AVERROR_OPTION_NOT_FOUND; } -#if 0 -<<<<<<< HEAD -int opt_default(const char *opt, const char *arg){ - int type; - int ret= 0; - const AVOption *o= NULL; - int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0}; - AVCodec *p = NULL; - AVOutputFormat *oformat = NULL; - AVInputFormat *iformat = NULL; - while ((p = av_codec_next(p))) { - const AVClass *c = p->priv_class; - if (c && av_find_opt(&c, opt, NULL, 0, 0)) - break; - } - if (p) - goto out; - while ((oformat = av_oformat_next(oformat))) { - const AVClass *c = oformat->priv_class; - if (c && av_find_opt(&c, opt, NULL, 0, 0)) - break; - } - if (oformat) - goto out; - while ((iformat = av_iformat_next(iformat))) { - const AVClass *c = iformat->priv_class; - if (c && av_find_opt(&c, opt, NULL, 0, 0)) - break; - } - if (iformat) - goto out; - - for(type=0; *avcodec_opts && type= 0; type++){ - const AVOption *o2 = av_opt_find(avcodec_opts[0], opt, NULL, opt_types[type], 0); - if(o2) - ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o); - } - if(!o && avformat_opts) - ret = av_set_string3(avformat_opts, opt, arg, 1, &o); - if(!o && sws_opts) - ret = av_set_string3(sws_opts, opt, arg, 1, &o); - if(!o){ - if (opt[0] == 'a' && avcodec_opts[AVMEDIA_TYPE_AUDIO]) - ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o); - else if(opt[0] == 'v' && avcodec_opts[AVMEDIA_TYPE_VIDEO]) - ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o); - else if(opt[0] == 's' && avcodec_opts[AVMEDIA_TYPE_SUBTITLE]) - ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o); - if (ret >= 0) - opt += 1; - } - if (o && ret < 0) { - fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt); - exit(1); - } - if (!o) { - fprintf(stderr, "Unrecognized option '%s'\n", opt); - exit(1); - } - - out: - if ((ret = opt_default2(opt, arg)) < 0) - return ret; - -// av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avcodec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL)); - - opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1)); - opt_values[opt_name_count] = av_strdup(arg); - opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1)); - opt_names[opt_name_count++] = av_strdup(opt); - - if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug)) - av_log_set_level(AV_LOG_DEBUG); - return 0; -} - -||||||| merged common ancestors -int opt_default(const char *opt, const char *arg){ - int type; - int ret= 0; - const AVOption *o= NULL; - int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0}; - - for(type=0; *avcodec_opts && type= 0; type++){ - const AVOption *o2 = av_opt_find(avcodec_opts[0], opt, NULL, opt_types[type], 0); - if(o2) - ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o); - } - if(!o && avformat_opts) - ret = av_set_string3(avformat_opts, opt, arg, 1, &o); - if(!o && sws_opts) - ret = av_set_string3(sws_opts, opt, arg, 1, &o); - if(!o){ - if (opt[0] == 'a' && avcodec_opts[AVMEDIA_TYPE_AUDIO]) - ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o); - else if(opt[0] == 'v' && avcodec_opts[AVMEDIA_TYPE_VIDEO]) - ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o); - else if(opt[0] == 's' && avcodec_opts[AVMEDIA_TYPE_SUBTITLE]) - ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o); - } - if (o && ret < 0) { - fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt); - exit(1); - } - if (!o) { - AVCodec *p = NULL; - AVOutputFormat *oformat = NULL; - while ((p=av_codec_next(p))){ - const AVClass *c = p->priv_class; - if(c && av_opt_find(&c, opt, NULL, 0, 0)) - break; - } - if (!p) { - while ((oformat = av_oformat_next(oformat))) { - const AVClass *c = oformat->priv_class; - if (c && av_opt_find(&c, opt, NULL, 0, 0)) - break; - } - } - } - - if ((ret = opt_default2(opt, arg)) < 0) - return ret; - -// av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avcodec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL)); - - //FIXME we should always use avcodec_opts, ... for storing options so there will not be any need to keep track of what i set over this - opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1)); - opt_values[opt_name_count]= o ? NULL : av_strdup(arg); - opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1)); - opt_names[opt_name_count++]= o ? o->name : av_strdup(opt); - - if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug)) - av_log_set_level(AV_LOG_DEBUG); - return 0; -} - -======= ->>>>>>> qatar/master -#endif int opt_loglevel(const char *opt, const char *arg) { const struct { const char *name; int level; } log_levels[] = { From 55eda370cb6fe9e4c21539f3f90fd940fcf7a103 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 14 Jul 2011 10:24:40 -0700 Subject: [PATCH 525/780] swscale: clip unscaled colorspace conversion path. Prevents overflows on very bright scenes when adding dither, which may lead to black dots. --- libswscale/swscale_unscaled.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index e6dac22cfe..59f31c6f64 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -454,18 +454,20 @@ static int packedCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ return srcSliceH; } -#define DITHER_COPY(dst, dstStride, wfunc, src, srcStride, rfunc, dithers, shift) \ +#define clip9(x) av_clip_uintp2(x, 9) +#define clip10(x) av_clip_uintp2(x, 10) +#define DITHER_COPY(dst, dstStride, wfunc, src, srcStride, rfunc, dithers, shift, clip) \ for (i = 0; i < height; i++) { \ const uint8_t *dither = dithers[i & 7]; \ for (j = 0; j < length - 7; j += 8) { \ - wfunc(&dst[j + 0], (rfunc(&src[j + 0]) + dither[0]) >> shift); \ - wfunc(&dst[j + 1], (rfunc(&src[j + 1]) + dither[1]) >> shift); \ - wfunc(&dst[j + 2], (rfunc(&src[j + 2]) + dither[2]) >> shift); \ - wfunc(&dst[j + 3], (rfunc(&src[j + 3]) + dither[3]) >> shift); \ - wfunc(&dst[j + 4], (rfunc(&src[j + 4]) + dither[4]) >> shift); \ - wfunc(&dst[j + 5], (rfunc(&src[j + 5]) + dither[5]) >> shift); \ - wfunc(&dst[j + 6], (rfunc(&src[j + 6]) + dither[6]) >> shift); \ - wfunc(&dst[j + 7], (rfunc(&src[j + 7]) + dither[7]) >> shift); \ + wfunc(&dst[j + 0], clip((rfunc(&src[j + 0]) + dither[0]) >> shift)); \ + wfunc(&dst[j + 1], clip((rfunc(&src[j + 1]) + dither[1]) >> shift)); \ + wfunc(&dst[j + 2], clip((rfunc(&src[j + 2]) + dither[2]) >> shift)); \ + wfunc(&dst[j + 3], clip((rfunc(&src[j + 3]) + dither[3]) >> shift)); \ + wfunc(&dst[j + 4], clip((rfunc(&src[j + 4]) + dither[4]) >> shift)); \ + wfunc(&dst[j + 5], clip((rfunc(&src[j + 5]) + dither[5]) >> shift)); \ + wfunc(&dst[j + 6], clip((rfunc(&src[j + 6]) + dither[6]) >> shift)); \ + wfunc(&dst[j + 7], clip((rfunc(&src[j + 7]) + dither[7]) >> shift)); \ } \ for (; j < length; j++) \ wfunc(&dst[j], (rfunc(&src[j]) + dither[j & 7]) >> shift); \ @@ -538,7 +540,7 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ } else if (dst_depth < src_depth) { \ DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \ srcPtr2, srcStride[plane]/2, rfunc, \ - dither_8x8_1, 1); \ + dither_8x8_1, 1, clip9); \ } else { \ COPY9_OR_10TO9_OR_10(wfunc(&dstPtr2[j], rfunc(&srcPtr2[j]))); \ } @@ -561,11 +563,11 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ if (src_depth == 9) { \ DITHER_COPY(dstPtr, dstStride[plane], W8, \ srcPtr2, srcStride[plane]/2, rfunc, \ - dither_8x8_1, 1); \ + dither_8x8_1, 1, av_clip_uint8); \ } else { \ DITHER_COPY(dstPtr, dstStride[plane], W8, \ srcPtr2, srcStride[plane]/2, rfunc, \ - dither_8x8_3, 2); \ + dither_8x8_3, 2, av_clip_uint8); \ } if (isBE(c->srcFormat)) { COPY9_OR_10TO8(AV_RB16); @@ -583,11 +585,11 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ if (dst_depth == 9) { \ DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \ srcPtr2, srcStride[plane]/2, rfunc, \ - dither_8x8_128, 7); \ + dither_8x8_128, 7, clip9); \ } else { \ DITHER_COPY(dstPtr2, dstStride[plane]/2, wfunc, \ srcPtr2, srcStride[plane]/2, rfunc, \ - dither_8x8_64, 6); \ + dither_8x8_64, 6, clip10); \ } if (isBE(c->dstFormat)) { if (isBE(c->srcFormat)) { @@ -623,7 +625,7 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ #define COPY16TO8(rfunc) \ DITHER_COPY(dstPtr, dstStride[plane], W8, \ srcPtr2, srcStride[plane]/2, rfunc, \ - dither_8x8_256, 8); + dither_8x8_256, 8, av_clip_uint8); if (isBE(c->srcFormat)) { COPY16TO8(AV_RB16); } else { From baba2eedacbbaecf55bdb89dbfe32c69799df99f Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 14 Jul 2011 10:31:27 -0700 Subject: [PATCH 526/780] swscale: extend mmx padding. Fixes a crash when forcing libc to strictly adhere to malloc sizes. --- libswscale/utils.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 6647f68682..0bde82026d 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1049,19 +1049,20 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) //Note we need at least one pixel more at the end because of the MMX code (just in case someone wanna replace the 4000/8000) /* align at 16 bytes for AltiVec */ for (i=0; ivLumBufSize; i++) { - FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i+c->vLumBufSize], dst_stride+1, fail); + FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i+c->vLumBufSize], dst_stride+16, fail); c->lumPixBuf[i] = c->lumPixBuf[i+c->vLumBufSize]; } - c->uv_off_px = dst_stride_px; - c->uv_off_byte = dst_stride; + // 64 / c->scalingBpp is the same as 16 / sizeof(scaling_intermediate) + c->uv_off_px = dst_stride_px + 64 / c->scalingBpp; + c->uv_off_byte = dst_stride + 16; for (i=0; ivChrBufSize; i++) { - FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i+c->vChrBufSize], dst_stride*2+1, fail); + FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i+c->vChrBufSize], dst_stride*2+32, fail); c->chrUPixBuf[i] = c->chrUPixBuf[i+c->vChrBufSize]; - c->chrVPixBuf[i] = c->chrVPixBuf[i+c->vChrBufSize] = c->chrUPixBuf[i] + (dst_stride >> 1); + c->chrVPixBuf[i] = c->chrVPixBuf[i+c->vChrBufSize] = c->chrUPixBuf[i] + (dst_stride >> 1) + 8; } if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) for (i=0; ivLumBufSize; i++) { - FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[i+c->vLumBufSize], dst_stride+1, fail); + FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[i+c->vLumBufSize], dst_stride+16, fail); c->alpPixBuf[i] = c->alpPixBuf[i+c->vLumBufSize]; } From daca33659d12fd85062bc1798f4eb7ffeb83cc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 14 Jul 2011 23:01:29 +0300 Subject: [PATCH 527/780] ffmpeg: Fix the check for experimental codecs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable 'codec' was used uninitialized here. Signed-off-by: Martin Storsjö --- ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index dcc92ac481..cbbd3e7b1e 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -522,7 +522,7 @@ static void assert_codec_experimental(AVCodecContext *c, int encoder) av_log(NULL, AV_LOG_ERROR, "%s '%s' is experimental and might produce bad " "results.\nAdd '-strict experimental' if you want to use it.\n", codec_string, c->codec->name); - codec = encoder ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id); + codec = encoder ? avcodec_find_encoder(c->codec->id) : avcodec_find_decoder(c->codec->id); if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) av_log(NULL, AV_LOG_ERROR, "Or use the non experimental %s '%s'.\n", codec_string, codec->name); From 863e2046fdcdf26493effb6e696d98c9dc23b4a7 Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Wed, 13 Jul 2011 14:24:47 -0400 Subject: [PATCH 528/780] ffserver: Replace two loops with one loop. Signed-off-by: Mike Williams Signed-off-by: Ronald S. Bultje --- ffserver.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/ffserver.c b/ffserver.c index ca4b54f4d4..2cbfe7589e 100644 --- a/ffserver.c +++ b/ffserver.c @@ -3644,18 +3644,6 @@ static void build_feed_streams(void) FFStream *stream, *feed; int i; - /* gather all streams */ - for(stream = first_stream; stream != NULL; stream = stream->next) { - feed = stream->feed; - if (feed) { - if (!stream->is_feed) { - /* we handle a stream coming from a feed */ - for(i=0;inb_streams;i++) - stream->feed_streams[i] = add_av_stream(feed, stream->streams[i]); - } - } - } - /* gather all streams */ for(stream = first_stream; stream != NULL; stream = stream->next) { feed = stream->feed; @@ -3663,6 +3651,10 @@ static void build_feed_streams(void) if (stream->is_feed) { for(i=0;inb_streams;i++) stream->feed_streams[i] = i; + } else { + /* we handle a stream coming from a feed */ + for(i=0;inb_streams;i++) + stream->feed_streams[i] = add_av_stream(feed, stream->streams[i]); } } } From ca5d57ef8ace36ca465208e04aaae1b461cb514a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 15 Jul 2011 00:21:15 +0300 Subject: [PATCH 529/780] ac3enc: Mark AVClasses const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/ac3enc_fixed.c | 4 ++-- libavcodec/ac3enc_float.c | 4 ++-- libavcodec/eac3enc.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index 15c5a4bca7..ed8992ebff 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -32,8 +32,8 @@ #define AC3ENC_TYPE AC3ENC_TYPE_AC3_FIXED #include "ac3enc_opts_template.c" -static AVClass ac3enc_class = { "Fixed-Point AC-3 Encoder", av_default_item_name, - ac3fixed_options, LIBAVUTIL_VERSION_INT }; +static const AVClass ac3enc_class = { "Fixed-Point AC-3 Encoder", av_default_item_name, + ac3fixed_options, LIBAVUTIL_VERSION_INT }; #include "ac3enc_template.c" diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index deec79ce8f..776d185fa4 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -35,8 +35,8 @@ #if CONFIG_AC3_ENCODER #define AC3ENC_TYPE AC3ENC_TYPE_AC3 #include "ac3enc_opts_template.c" -static AVClass ac3enc_class = { "AC-3 Encoder", av_default_item_name, - ac3_options, LIBAVUTIL_VERSION_INT }; +static const AVClass ac3enc_class = { "AC-3 Encoder", av_default_item_name, + ac3_options, LIBAVUTIL_VERSION_INT }; #endif #include "ac3enc_template.c" diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index f39b9f1925..0433db49d7 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -31,8 +31,8 @@ #define AC3ENC_TYPE AC3ENC_TYPE_EAC3 #include "ac3enc_opts_template.c" -static AVClass eac3enc_class = { "E-AC-3 Encoder", av_default_item_name, - eac3_options, LIBAVUTIL_VERSION_INT }; +static const AVClass eac3enc_class = { "E-AC-3 Encoder", av_default_item_name, + eac3_options, LIBAVUTIL_VERSION_INT }; void ff_eac3_set_cpl_states(AC3EncodeContext *s) From 6168781f70ebac7da557207750d14f57c3cd4cb3 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 14 Jul 2011 03:11:19 +0200 Subject: [PATCH 530/780] doxygen: do not include license boilerplate in Doxygen documentation --- libavcodec/huffman.c | 9 ++++++--- libavcodec/huffman.h | 9 ++++++--- libavcodec/vorbis.c | 12 +++++++----- libavcodec/vorbisdec.c | 12 +++++++----- libavcodec/vp5.c | 10 ++++++---- libavcodec/vp56.c | 10 ++++++---- libavcodec/vp56.h | 10 ++++++---- libavcodec/vp56data.c | 10 ++++++---- libavcodec/vp56data.h | 10 ++++++---- libavcodec/vp5data.h | 10 ++++++---- libavcodec/vp6.c | 18 ++++++++++-------- libavcodec/vp6data.h | 10 ++++++---- libavcodec/vp6dsp.c | 10 ++++++---- libavcodec/vp8data.h | 9 ++++++--- libavcodec/vp8dsp.c | 9 ++++++--- libavcodec/vp8dsp.h | 8 +++++--- libavcodec/yop.c | 3 +-- libavformat/flv.h | 8 ++++++-- libavformat/yop.c | 3 +-- libavutil/timer.h | 10 ++++++---- 20 files changed, 115 insertions(+), 75 deletions(-) diff --git a/libavcodec/huffman.c b/libavcodec/huffman.c index 211ea63750..4fb6530d39 100644 --- a/libavcodec/huffman.c +++ b/libavcodec/huffman.c @@ -1,6 +1,4 @@ -/** - * @file - * huffman tree builder and VLC generator +/* * Copyright (c) 2006 Konstantin Shishkov * * This file is part of Libav. @@ -20,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * huffman tree builder and VLC generator + */ + #include "avcodec.h" #include "get_bits.h" #include "huffman.h" diff --git a/libavcodec/huffman.h b/libavcodec/huffman.h index 4a60187b3c..5625313ac7 100644 --- a/libavcodec/huffman.h +++ b/libavcodec/huffman.h @@ -1,6 +1,4 @@ -/** - * @file - * huffman tree builder and VLC generator +/* * Copyright (C) 2007 Aurelien Jacobs * * This file is part of Libav. @@ -20,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * huffman tree builder and VLC generator + */ + #ifndef AVCODEC_HUFFMAN_H #define AVCODEC_HUFFMAN_H diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c index f413170b6a..8ff24ab627 100644 --- a/libavcodec/vorbis.c +++ b/libavcodec/vorbis.c @@ -1,8 +1,4 @@ -/** - * @file - * Common code for Vorbis I encoder and decoder - * @author Denes Balatoni ( dbalatoni programozo hu ) - * +/* * This file is part of Libav. * * Libav is free software; you can redistribute it and/or @@ -20,6 +16,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * Common code for Vorbis I encoder and decoder + * @author Denes Balatoni ( dbalatoni programozo hu ) + */ + #define ALT_BITSTREAM_READER_LE #include "avcodec.h" #include "get_bits.h" diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 9fc60688a2..445e68e3f2 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1,8 +1,4 @@ -/** - * @file - * Vorbis I decoder - * @author Denes Balatoni ( dbalatoni programozo hu ) - * +/* * This file is part of Libav. * * Libav is free software; you can redistribute it and/or @@ -20,6 +16,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * Vorbis I decoder + * @author Denes Balatoni ( dbalatoni programozo hu ) + */ + #include #include diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index 807309f603..a057d9bbe1 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -1,7 +1,4 @@ -/** - * @file - * VP5 compatible video decoder - * +/* * Copyright (C) 2006 Aurelien Jacobs * * This file is part of Libav. @@ -21,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP5 compatible video decoder + */ + #include #include diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index a181978334..5c7e93e5e6 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -1,7 +1,4 @@ -/** - * @file - * VP5 and VP6 compatible video decoder (common features) - * +/* * Copyright (C) 2006 Aurelien Jacobs * * This file is part of Libav. @@ -21,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP5 and VP6 compatible video decoder (common features) + */ + #include "avcodec.h" #include "bytestream.h" diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 5a55f7d6a1..8bb7251fc6 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -1,7 +1,4 @@ -/** - * @file - * VP5 and VP6 compatible video decoder (common features) - * +/* * Copyright (C) 2006 Aurelien Jacobs * * This file is part of Libav. @@ -21,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP5 and VP6 compatible video decoder (common features) + */ + #ifndef AVCODEC_VP56_H #define AVCODEC_VP56_H diff --git a/libavcodec/vp56data.c b/libavcodec/vp56data.c index 7a418761d1..aa1dcefece 100644 --- a/libavcodec/vp56data.c +++ b/libavcodec/vp56data.c @@ -1,7 +1,4 @@ -/** - * @file - * VP5 and VP6 compatible video decoder (common data) - * +/* * Copyright (C) 2006 Aurelien Jacobs * * This file is part of Libav. @@ -21,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP5 and VP6 compatible video decoder (common data) + */ + #include "vp56data.h" const uint8_t vp56_b2p[] = { 0, 0, 0, 0, 1, 2, 3, 3, 3, 3 }; diff --git a/libavcodec/vp56data.h b/libavcodec/vp56data.h index 7be5921e9f..b1f27102ae 100644 --- a/libavcodec/vp56data.h +++ b/libavcodec/vp56data.h @@ -1,7 +1,4 @@ -/** - * @file - * VP5 and VP6 compatible video decoder (common data) - * +/* * Copyright (C) 2006 Aurelien Jacobs * * This file is part of Libav. @@ -21,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP5 and VP6 compatible video decoder (common data) + */ + #ifndef AVCODEC_VP56DATA_H #define AVCODEC_VP56DATA_H diff --git a/libavcodec/vp5data.h b/libavcodec/vp5data.h index 11144a31ad..b11b99d9a9 100644 --- a/libavcodec/vp5data.h +++ b/libavcodec/vp5data.h @@ -1,7 +1,4 @@ -/** - * @file - * VP5 compatible video decoder - * +/* * Copyright (C) 2006 Aurelien Jacobs * * This file is part of Libav. @@ -21,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP5 compatible video decoder + */ + #ifndef AVCODEC_VP5DATA_H #define AVCODEC_VP5DATA_H diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 4f3f402c70..42828d8e47 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -1,13 +1,6 @@ -/** - * @file - * VP6 compatible video decoder - * +/* * Copyright (C) 2006 Aurelien Jacobs * - * The VP6F decoder accepts an optional 1 byte extradata. It is composed of: - * - upper 4bits: difference between encoded width and visible width - * - lower 4bits: difference between encoded height and visible height - * * This file is part of Libav. * * Libav is free software; you can redistribute it and/or @@ -25,6 +18,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP6 compatible video decoder + * + * The VP6F decoder accepts an optional 1 byte extradata. It is composed of: + * - upper 4 bits: difference between encoded width and visible width + * - lower 4 bits: difference between encoded height and visible height + */ + #include #include "avcodec.h" diff --git a/libavcodec/vp6data.h b/libavcodec/vp6data.h index 2ba3ef3860..9a11f89bf5 100644 --- a/libavcodec/vp6data.h +++ b/libavcodec/vp6data.h @@ -1,7 +1,4 @@ -/** - * @file - * VP6 compatible video decoder - * +/* * Copyright (C) 2006 Aurelien Jacobs * * This file is part of Libav. @@ -21,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP6 compatible video decoder + */ + #ifndef AVCODEC_VP6DATA_H #define AVCODEC_VP6DATA_H diff --git a/libavcodec/vp6dsp.c b/libavcodec/vp6dsp.c index 64282a5b3f..54a96ed13a 100644 --- a/libavcodec/vp6dsp.c +++ b/libavcodec/vp6dsp.c @@ -1,7 +1,4 @@ -/** - * @file - * VP6 DSP-oriented functions - * +/* * Copyright (C) 2006 Aurelien Jacobs * * This file is part of Libav. @@ -21,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP6 DSP-oriented functions + */ + #include "libavutil/common.h" #include "vp56dsp.h" diff --git a/libavcodec/vp8data.h b/libavcodec/vp8data.h index 4ea4581bc9..a48b0f6f9b 100644 --- a/libavcodec/vp8data.h +++ b/libavcodec/vp8data.h @@ -1,6 +1,4 @@ -/** - * VP8 compatible video decoder - * +/* * Copyright (C) 2010 David Conrad * Copyright (C) 2010 Ronald S. Bultje * @@ -21,6 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP8 compatible video decoder + */ + #ifndef AVCODEC_VP8DATA_H #define AVCODEC_VP8DATA_H diff --git a/libavcodec/vp8dsp.c b/libavcodec/vp8dsp.c index 159c070670..89c3453efc 100644 --- a/libavcodec/vp8dsp.c +++ b/libavcodec/vp8dsp.c @@ -1,6 +1,4 @@ -/** - * VP8 compatible video decoder - * +/* * Copyright (C) 2010 David Conrad * Copyright (C) 2010 Ronald S. Bultje * @@ -21,6 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP8 compatible video decoder + */ + #include "dsputil.h" #include "vp8dsp.h" diff --git a/libavcodec/vp8dsp.h b/libavcodec/vp8dsp.h index e2fb8e7cbb..5429e98c2a 100644 --- a/libavcodec/vp8dsp.h +++ b/libavcodec/vp8dsp.h @@ -1,6 +1,4 @@ -/** - * VP8 compatible video decoder - * +/* * Copyright (C) 2010 David Conrad * Copyright (C) 2010 Ronald S. Bultje * @@ -21,6 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * VP8 compatible video decoder + */ #ifndef AVCODEC_VP8DSP_H #define AVCODEC_VP8DSP_H diff --git a/libavcodec/yop.c b/libavcodec/yop.c index 1f1314b6a7..e0b26544be 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -1,5 +1,4 @@ -/** - * @file +/* * Psygnosis YOP decoder * * Copyright (C) 2010 Mohamed Naufal Basheer diff --git a/libavformat/flv.h b/libavformat/flv.h index c86e20a7cf..6418b27419 100644 --- a/libavformat/flv.h +++ b/libavformat/flv.h @@ -1,5 +1,4 @@ -/** - * @file +/* * FLV common header * * Copyright (c) 2006 The Libav Project @@ -21,6 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * FLV common header + */ + #ifndef AVFORMAT_FLV_H #define AVFORMAT_FLV_H diff --git a/libavformat/yop.c b/libavformat/yop.c index e3671874a1..bc29b0883e 100644 --- a/libavformat/yop.c +++ b/libavformat/yop.c @@ -1,5 +1,4 @@ -/** - * @file +/* * Psygnosis YOP demuxer * * Copyright (C) 2010 Mohamed Naufal Basheer diff --git a/libavutil/timer.h b/libavutil/timer.h index a2ca5cf828..341d508c44 100644 --- a/libavutil/timer.h +++ b/libavutil/timer.h @@ -1,7 +1,4 @@ -/** - * @file - * high precision timer, useful to profile code - * +/* * copyright (c) 2006 Michael Niedermayer * * This file is part of Libav. @@ -21,6 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * high precision timer, useful to profile code + */ + #ifndef AVUTIL_TIMER_H #define AVUTIL_TIMER_H From 4bd28579e51a358fc6d26040c4ccd6aefb5a90ef Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Jul 2011 18:23:02 +0200 Subject: [PATCH 531/780] vf_mp: remove boxblur wrapper It is natively included in libavfilter. --- doc/filters.texi | 1 - libavfilter/Makefile | 1 - libavfilter/avfilter.h | 2 +- libavfilter/libmpcodecs/vf_boxblur.c | 214 --------------------------- libavfilter/vf_mp.c | 2 - 5 files changed, 1 insertion(+), 219 deletions(-) delete mode 100644 libavfilter/libmpcodecs/vf_boxblur.c diff --git a/doc/filters.texi b/doc/filters.texi index 2c8d6e7565..8ad8c1e4dc 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -896,7 +896,6 @@ The list of the currently supported filters follows: @table @var @item 2xsai @item blackframe -@item boxblur @item cropdetect @item decimate @item delogo diff --git a/libavfilter/Makefile b/libavfilter/Makefile index e29fe5eabd..907b7dbab7 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -79,7 +79,6 @@ OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/mp_image.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/img_format.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_2xsai.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_blackframe.o -OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_boxblur.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_cropdetect.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_decimate.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_delogo.o diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 3e1acea542..7e4dfd8df4 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 25 -#define LIBAVFILTER_VERSION_MICRO 0 +#define LIBAVFILTER_VERSION_MICRO 1 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/libmpcodecs/vf_boxblur.c b/libavfilter/libmpcodecs/vf_boxblur.c deleted file mode 100644 index bc1ec80284..0000000000 --- a/libavfilter/libmpcodecs/vf_boxblur.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (C) 2002 Michael Niedermayer - * - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include -#include - -#include "mp_msg.h" -#include "img_format.h" -#include "mp_image.h" -#include "vf.h" - - -//===========================================================================// - -typedef struct FilterParam{ - int radius; - int power; -}FilterParam; - -struct vf_priv_s { - FilterParam lumaParam; - FilterParam chromaParam; -}; - - -/***************************************************************************/ - - -static int config(struct vf_instance *vf, - int width, int height, int d_width, int d_height, - unsigned int flags, unsigned int outfmt){ - - return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); -} - -static inline void blur(uint8_t *dst, uint8_t *src, int w, int radius, int dstStep, int srcStep){ - int x; - const int length= radius*2 + 1; - const int inv= ((1<<16) + length/2)/length; - - int sum= 0; - - for(x=0; x>16; - } - - for(; x>16; - } - - for(; x>16; - } -} - -static inline void blur2(uint8_t *dst, uint8_t *src, int w, int radius, int power, int dstStep, int srcStep){ - uint8_t temp[2][4096]; - uint8_t *a= temp[0], *b=temp[1]; - - if(radius){ - blur(a, src, w, radius, 1, srcStep); - for(; power>2; power--){ - uint8_t *c; - blur(b, a, w, radius, 1, 1); - c=a; a=b; b=c; - } - if(power>1) - blur(dst, a, w, radius, dstStep, 1); - else{ - int i; - for(i=0; iw >> mpi->chroma_x_shift; - int ch= mpi->h >> mpi->chroma_y_shift; - - mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt, - MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_READABLE, - mpi->w,mpi->h); - - assert(mpi->flags&MP_IMGFLAG_PLANAR); - - hBlur(dmpi->planes[0], mpi->planes[0], mpi->w,mpi->h, - dmpi->stride[0], mpi->stride[0], vf->priv->lumaParam.radius, vf->priv->lumaParam.power); - hBlur(dmpi->planes[1], mpi->planes[1], cw,ch, - dmpi->stride[1], mpi->stride[1], vf->priv->chromaParam.radius, vf->priv->chromaParam.power); - hBlur(dmpi->planes[2], mpi->planes[2], cw,ch, - dmpi->stride[2], mpi->stride[2], vf->priv->chromaParam.radius, vf->priv->chromaParam.power); - - vBlur(dmpi->planes[0], dmpi->planes[0], mpi->w,mpi->h, - dmpi->stride[0], dmpi->stride[0], vf->priv->lumaParam.radius, vf->priv->lumaParam.power); - vBlur(dmpi->planes[1], dmpi->planes[1], cw,ch, - dmpi->stride[1], dmpi->stride[1], vf->priv->chromaParam.radius, vf->priv->chromaParam.power); - vBlur(dmpi->planes[2], dmpi->planes[2], cw,ch, - dmpi->stride[2], dmpi->stride[2], vf->priv->chromaParam.radius, vf->priv->chromaParam.power); - - return vf_next_put_image(vf,dmpi, pts); -} - -//===========================================================================// - -static int query_format(struct vf_instance *vf, unsigned int fmt){ - switch(fmt) - { - case IMGFMT_YV12: - case IMGFMT_I420: - case IMGFMT_IYUV: - case IMGFMT_YVU9: - case IMGFMT_444P: - case IMGFMT_422P: - case IMGFMT_411P: - return vf_next_query_format(vf, fmt); - } - return 0; -} - -static int vf_open(vf_instance_t *vf, char *args){ - int e; - - vf->config=config; - vf->put_image=put_image; -// vf->get_image=get_image; - vf->query_format=query_format; - vf->priv=malloc(sizeof(struct vf_priv_s)); - memset(vf->priv, 0, sizeof(struct vf_priv_s)); - - if(args==NULL) return 0; - - e=sscanf(args, "%d:%d:%d:%d", - &vf->priv->lumaParam.radius, - &vf->priv->lumaParam.power, - &vf->priv->chromaParam.radius, - &vf->priv->chromaParam.power - ); - - if(e==2){ - vf->priv->chromaParam.radius= vf->priv->lumaParam.radius; - vf->priv->chromaParam.power = vf->priv->lumaParam.power; - }else if(e!=4) - return 0; - - if(vf->priv->lumaParam.radius < 0) return 0; - if(vf->priv->chromaParam.radius < 0) return 0; - - return 1; -} - -const vf_info_t vf_info_boxblur = { - "box blur", - "boxblur", - "Michael Niedermayer", - "", - vf_open, - NULL -}; - -//===========================================================================// diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c index 9e413b4776..c4ce3d8155 100644 --- a/libavfilter/vf_mp.c +++ b/libavfilter/vf_mp.c @@ -152,7 +152,6 @@ extern const vf_info_t vf_info_unsharp; extern const vf_info_t vf_info_swapuv; extern const vf_info_t vf_info_il; extern const vf_info_t vf_info_fil; -extern const vf_info_t vf_info_boxblur; extern const vf_info_t vf_info_sab; extern const vf_info_t vf_info_smartblur; extern const vf_info_t vf_info_perspective; @@ -202,7 +201,6 @@ extern const vf_info_t vf_info_stereo3d; static const vf_info_t* const filters[]={ &vf_info_2xsai, &vf_info_blackframe, - &vf_info_boxblur, &vf_info_cropdetect, &vf_info_decimate, &vf_info_delogo, From 1b8807964c0cf956d4bd2d6c0169dd08a89602fc Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 11 Jul 2011 16:20:05 +0200 Subject: [PATCH 532/780] vsrc_testsrc: perform some refactoring for simplifying sharing code with another test In particular creates a special test_init function, which calls a common init, and introduces a fill_picture_fn which points to the filling function. This is required by the pending patch for adding the rgbtestsrc source. --- libavfilter/vsrc_testsrc.c | 80 ++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index 6f2c3cf166..fe7bc1c675 100644 --- a/libavfilter/vsrc_testsrc.c +++ b/libavfilter/vsrc_testsrc.c @@ -40,6 +40,7 @@ typedef struct { char *size; ///< video frame size char *rate; ///< video frame rate char *duration; ///< total duration of the generated video + void (* fill_picture_fn)(AVFilterContext *ctx, AVFilterBufferRef *picref); } TestSourceContext; #define OFFSET(x) offsetof(TestSourceContext, x) @@ -53,17 +54,6 @@ static const AVOption testsrc_options[]= { { NULL }, }; -static const char *testsrc_get_name(void *ctx) -{ - return "testsrc"; -} - -static const AVClass testsrc_class = { - "TestSourceContext", - testsrc_get_name, - testsrc_options -}; - static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) { TestSourceContext *test = ctx->priv; @@ -71,7 +61,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) int64_t duration = -1; int ret = 0; - test->class = &testsrc_class; av_opt_set_defaults2(test, 0, 0); if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0) { @@ -119,6 +108,40 @@ static int config_props(AVFilterLink *outlink) return 0; } +static int request_frame(AVFilterLink *outlink) +{ + TestSourceContext *test = outlink->src->priv; + AVFilterBufferRef *picref; + + if (test->max_pts >= 0 && test->pts > test->max_pts) + return AVERROR_EOF; + picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, + test->w, test->h); + picref->pts = test->pts++; + test->nb_frame++; + test->fill_picture_fn(outlink->src, picref); + + avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); + avfilter_draw_slice(outlink, 0, picref->video->h, 1); + avfilter_end_frame(outlink); + avfilter_unref_buffer(picref); + + return 0; +} + +#if CONFIG_TESTSRC_FILTER + +static const char *testsrc_get_name(void *ctx) +{ + return "testsrc"; +} + +static const AVClass testsrc_class = { + "TestSourceContext", + testsrc_get_name, + testsrc_options +}; + /** * Fill a rectangle with value val. * @@ -191,8 +214,9 @@ static void draw_digit(int digit, uint8_t *dst, unsigned dst_linesize, #define GRADIENT_SIZE (6 * 256) -static void fill_picture(TestSourceContext *test, AVFilterBufferRef *picref) +static void test_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref) { + TestSourceContext *test = ctx->priv; uint8_t *p, *p0; int x, y; int color, color_rest; @@ -290,28 +314,16 @@ static void fill_picture(TestSourceContext *test, AVFilterBufferRef *picref) } } -static int request_frame(AVFilterLink *outlink) +static av_cold int test_init(AVFilterContext *ctx, const char *args, void *opaque) { - TestSourceContext *test = outlink->src->priv; - AVFilterBufferRef *picref; + TestSourceContext *test = ctx->priv; - if (test->max_pts >= 0 && test->pts > test->max_pts) - return AVERROR_EOF; - picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, - test->w, test->h); - picref->pts = test->pts++; - test->nb_frame++; - fill_picture(test, picref); - - avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); - avfilter_draw_slice(outlink, 0, picref->video->h, 1); - avfilter_end_frame(outlink); - avfilter_unref_buffer(picref); - - return 0; + test->class = &testsrc_class; + test->fill_picture_fn = test_fill_picture; + return init(ctx, args, opaque); } -static int query_formats(AVFilterContext *ctx) +static int test_query_formats(AVFilterContext *ctx) { static const enum PixelFormat pix_fmts[] = { PIX_FMT_RGB24, PIX_FMT_NONE @@ -324,9 +336,9 @@ AVFilter avfilter_vsrc_testsrc = { .name = "testsrc", .description = NULL_IF_CONFIG_SMALL("Generate test pattern."), .priv_size = sizeof(TestSourceContext), - .init = init, + .init = test_init, - .query_formats = query_formats, + .query_formats = test_query_formats, .inputs = (AVFilterPad[]) {{ .name = NULL}}, @@ -336,3 +348,5 @@ AVFilter avfilter_vsrc_testsrc = { .config_props = config_props, }, { .name = NULL }}, }; + +#endif /* CONFIG_TESTSRC_FILTER */ From 9dbe8d9e22835e289aea315354129b0758d1c573 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 11 Jul 2011 16:27:09 +0200 Subject: [PATCH 533/780] lavfi: add rgbtestsrc source, ported from MPlayer libmpcodecs The licence was changed from GPL to LGPL with explicit approval from the original author. See thread: Subject: [FFmpeg-devel] [PATCH] lavfi: add rgbtestsrc source, ported from MPlayer libmpcodecs Date: Mon, 11 Jul 2011 16:32:41 +0200 --- doc/filters.texi | 14 ++-- libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/avfilter.h | 4 +- libavfilter/vsrc_testsrc.c | 138 ++++++++++++++++++++++++++++++++++++- 5 files changed, 150 insertions(+), 8 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 8ad8c1e4dc..fb992a8252 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2045,13 +2045,17 @@ Some examples follow: frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay @end example -@section testsrc +@section rgbtestsrc, testsrc -Generate a test video pattern, showing a color pattern, a scrolling -gradient and a timestamp. This is mainly intended for testing -purposes. +The @code{rgbtestsrc} source generates an RGB test pattern useful for +detecting RGB vs BGR issues. You should see a red, green and blue +stripe from top to bottom. -It accepts an optional sequence of @var{key}=@var{value} pairs, +The @code{testsrc} source generates a test video pattern, showing a +color pattern, a scrolling gradient and a timestamp. This is mainly +intended for testing purposes. + +Both sources accept an optional sequence of @var{key}=@var{value} pairs, separated by ":". The description of the accepted options follows. @table @option diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 907b7dbab7..7c798bb977 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -69,6 +69,7 @@ OBJS-$(CONFIG_COLOR_FILTER) += vsrc_color.o OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o OBJS-$(CONFIG_MOVIE_FILTER) += vsrc_movie.o OBJS-$(CONFIG_NULLSRC_FILTER) += vsrc_nullsrc.o +OBJS-$(CONFIG_RGBTESTSRC_FILTER) += vsrc_testsrc.o OBJS-$(CONFIG_TESTSRC_FILTER) += vsrc_testsrc.o OBJS-$(CONFIG_BUFFERSINK_FILTER) += vsink_buffer.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 8d80957cff..99f7bc42e2 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -85,6 +85,7 @@ void avfilter_register_all(void) REGISTER_FILTER (FREI0R, frei0r_src, vsrc); REGISTER_FILTER (MOVIE, movie, vsrc); REGISTER_FILTER (NULLSRC, nullsrc, vsrc); + REGISTER_FILTER (RGBTESTSRC, rgbtestsrc, vsrc); REGISTER_FILTER (TESTSRC, testsrc, vsrc); REGISTER_FILTER (BUFFER, buffersink, vsink); diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 7e4dfd8df4..edcc726b87 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -29,8 +29,8 @@ #include "libavutil/rational.h" #define LIBAVFILTER_VERSION_MAJOR 2 -#define LIBAVFILTER_VERSION_MINOR 25 -#define LIBAVFILTER_VERSION_MICRO 1 +#define LIBAVFILTER_VERSION_MINOR 26 +#define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index fe7bc1c675..e2cf4d47ce 100644 --- a/libavfilter/vsrc_testsrc.c +++ b/libavfilter/vsrc_testsrc.c @@ -21,13 +21,19 @@ /** * @file - * Based on the test pattern generator demuxer by Nicolas George: + * Misc test sources. + * + * testsrc is based on the test pattern generator demuxer by Nicolas George: * http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2007-October/037845.html + * + * rgbtestsrc is ported from MPlayer libmpcodecs/vf_rgbtest.c by + * Michael Niedermayer. */ #include #include "libavutil/opt.h" +#include "libavutil/intreadwrite.h" #include "libavutil/parseutils.h" #include "avfilter.h" @@ -41,6 +47,9 @@ typedef struct { char *rate; ///< video frame rate char *duration; ///< total duration of the generated video void (* fill_picture_fn)(AVFilterContext *ctx, AVFilterBufferRef *picref); + + /* only used by rgbtest */ + int rgba_map[4]; } TestSourceContext; #define OFFSET(x) offsetof(TestSourceContext, x) @@ -350,3 +359,130 @@ AVFilter avfilter_vsrc_testsrc = { }; #endif /* CONFIG_TESTSRC_FILTER */ + +#if CONFIG_RGBTESTSRC_FILTER + +static const char *rgbtestsrc_get_name(void *ctx) +{ + return "rgbtestsrc"; +} + +static const AVClass rgbtestsrc_class = { + "RGBTestSourceContext", + rgbtestsrc_get_name, + testsrc_options +}; + +#define R 0 +#define G 1 +#define B 2 +#define A 3 + +static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize, + int x, int y, int r, int g, int b, enum PixelFormat fmt, + int rgba_map[4]) +{ + int32_t v; + uint8_t *p; + + switch (fmt) { + case PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); break; + case PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b >> 4) << 8) | ((g >> 4) << 4) | (r >> 4); break; + case PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<10) | ((g>>3)<<5) | (b>>3); break; + case PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<10) | ((g>>3)<<5) | (r>>3); break; + case PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<11) | ((g>>2)<<5) | (b>>3); break; + case PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<11) | ((g>>2)<<5) | (r>>3); break; + case PIX_FMT_RGB24: + case PIX_FMT_BGR24: + v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)); + p = dst + 3*x + y*dst_linesize; + AV_WL24(p, v); + break; + case PIX_FMT_RGBA: + case PIX_FMT_BGRA: + case PIX_FMT_ARGB: + case PIX_FMT_ABGR: + v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)); + p = dst + 4*x + y*dst_linesize; + AV_WL32(p, v); + break; + } +} + +static void rgbtest_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref) +{ + TestSourceContext *test = ctx->priv; + int x, y, w = picref->video->w, h = picref->video->h; + + for (y = 0; y < h; y++) { + for (x = 0; x < picref->video->w; x++) { + int c = 256*x/w; + int r = 0, g = 0, b = 0; + + if (3*y < h ) r = c; + else if (3*y < 2*h) g = c; + else b = c; + + rgbtest_put_pixel(picref->data[0], picref->linesize[0], x, y, r, g, b, + ctx->outputs[0]->format, test->rgba_map); + } + } +} + +static av_cold int rgbtest_init(AVFilterContext *ctx, const char *args, void *opaque) +{ + TestSourceContext *test = ctx->priv; + + test->class = &rgbtestsrc_class; + test->fill_picture_fn = rgbtest_fill_picture; + return init(ctx, args, opaque); +} + +static int rgbtest_query_formats(AVFilterContext *ctx) +{ + static const enum PixelFormat pix_fmts[] = { + PIX_FMT_RGBA, PIX_FMT_ARGB, PIX_FMT_BGRA, PIX_FMT_ABGR, + PIX_FMT_BGR24, PIX_FMT_RGB24, + PIX_FMT_RGB444, PIX_FMT_BGR444, + PIX_FMT_RGB565, PIX_FMT_BGR565, + PIX_FMT_RGB555, PIX_FMT_BGR555, + PIX_FMT_NONE + }; + avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); + return 0; +} + +static int rgbtest_config_props(AVFilterLink *outlink) +{ + TestSourceContext *test = outlink->src->priv; + + switch (outlink->format) { + case PIX_FMT_ARGB: test->rgba_map[A] = 0; test->rgba_map[R] = 1; test->rgba_map[G] = 2; test->rgba_map[B] = 3; break; + case PIX_FMT_ABGR: test->rgba_map[A] = 0; test->rgba_map[B] = 1; test->rgba_map[G] = 2; test->rgba_map[R] = 3; break; + case PIX_FMT_RGBA: + case PIX_FMT_RGB24: test->rgba_map[R] = 0; test->rgba_map[G] = 1; test->rgba_map[B] = 2; test->rgba_map[A] = 3; break; + case PIX_FMT_BGRA: + case PIX_FMT_BGR24: test->rgba_map[B] = 0; test->rgba_map[G] = 1; test->rgba_map[R] = 2; test->rgba_map[A] = 3; break; + } + + return config_props(outlink); +} + +AVFilter avfilter_vsrc_rgbtestsrc = { + .name = "rgbtestsrc", + .description = NULL_IF_CONFIG_SMALL("Generate RGB test pattern."), + .priv_size = sizeof(TestSourceContext), + .init = rgbtest_init, + + .query_formats = rgbtest_query_formats, + + .inputs = (AVFilterPad[]) {{ .name = NULL}}, + + .outputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .request_frame = request_frame, + .config_props = rgbtest_config_props, }, + { .name = NULL }}, +}; + +#endif /* CONFIG_RGBTESTSRC_FILTER */ From b43ca2deb617c9b8d00f2f41ddb384f2a00c5905 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 15 Jul 2011 01:29:24 +0200 Subject: [PATCH 534/780] vf_mp: remove rgbtest wrapper The filter was integrated natively into libavfilter as a source with name rgbtestsrc. --- doc/filters.texi | 1 - libavfilter/Makefile | 1 - libavfilter/libmpcodecs/vf_rgbtest.c | 171 --------------------------- libavfilter/vf_mp.c | 2 - 4 files changed, 175 deletions(-) delete mode 100644 libavfilter/libmpcodecs/vf_rgbtest.c diff --git a/doc/filters.texi b/doc/filters.texi index fb992a8252..0ffc72771c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -933,7 +933,6 @@ The list of the currently supported filters follows: @item qp @item rectangle @item remove-logo -@item rgbtest @item rotate @item sab @item screenshot diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 7c798bb977..d309534da7 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -118,7 +118,6 @@ OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_pullup.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_qp.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_rectangle.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_remove_logo.o -OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_rgbtest.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_rotate.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_sab.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_screenshot.o diff --git a/libavfilter/libmpcodecs/vf_rgbtest.c b/libavfilter/libmpcodecs/vf_rgbtest.c deleted file mode 100644 index cbed6ed367..0000000000 --- a/libavfilter/libmpcodecs/vf_rgbtest.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include - -#include "config.h" -#include "mp_msg.h" - -#include "img_format.h" -#include "mp_image.h" -#include "vf.h" - -//===========================================================================// - -struct vf_priv_s { - unsigned int fmt; - int w, h; -}; - -static unsigned int getfmt(unsigned int outfmt){ - switch(outfmt){ - case IMGFMT_RGB12: - case IMGFMT_RGB15: - case IMGFMT_RGB16: - case IMGFMT_RGB24: - case IMGFMT_RGBA: - case IMGFMT_ARGB: - case IMGFMT_BGR12: - case IMGFMT_BGR15: - case IMGFMT_BGR16: - case IMGFMT_BGR24: - case IMGFMT_BGRA: - case IMGFMT_ABGR: - return outfmt; - } - return 0; -} - -static void put_pixel(uint8_t *buf, int x, int y, int stride, int r, int g, int b, int fmt){ - switch(fmt){ - case IMGFMT_BGR12: ((uint16_t*)(buf + y*stride))[x]= - ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); - break; - case IMGFMT_RGB12: ((uint16_t*)(buf + y*stride))[x]= - ((b >> 4) << 8) | ((g >> 4) << 4) | (r >> 4); - break; - case IMGFMT_BGR15: ((uint16_t*)(buf + y*stride))[x]= ((r>>3)<<10) | ((g>>3)<<5) | (b>>3); - break; - case IMGFMT_RGB15: ((uint16_t*)(buf + y*stride))[x]= ((b>>3)<<10) | ((g>>3)<<5) | (r>>3); - break; - case IMGFMT_BGR16: ((uint16_t*)(buf + y*stride))[x]= ((r>>3)<<11) | ((g>>2)<<5) | (b>>3); - break; - case IMGFMT_RGB16: ((uint16_t*)(buf + y*stride))[x]= ((b>>3)<<11) | ((g>>2)<<5) | (r>>3); - break; - case IMGFMT_RGB24: - buf[3*x + y*stride + 0]= r; - buf[3*x + y*stride + 1]= g; - buf[3*x + y*stride + 2]= b; - break; - case IMGFMT_BGR24: - buf[3*x + y*stride + 0]= b; - buf[3*x + y*stride + 1]= g; - buf[3*x + y*stride + 2]= r; - break; - case IMGFMT_RGBA: - buf[4*x + y*stride + 0]= r; - buf[4*x + y*stride + 1]= g; - buf[4*x + y*stride + 2]= b; - break; - case IMGFMT_BGRA: - buf[4*x + y*stride + 0]= b; - buf[4*x + y*stride + 1]= g; - buf[4*x + y*stride + 2]= r; - break; - case IMGFMT_ARGB: - buf[4*x + y*stride + 1]= r; - buf[4*x + y*stride + 2]= g; - buf[4*x + y*stride + 3]= b; - break; - case IMGFMT_ABGR: - buf[4*x + y*stride + 1]= b; - buf[4*x + y*stride + 2]= g; - buf[4*x + y*stride + 3]= r; - break; - } -} - -static int config(struct vf_instance *vf, - int width, int height, int d_width, int d_height, - unsigned int flags, unsigned int outfmt){ - if (vf->priv->w > 0) { d_width = width = vf->priv->w; } - if (vf->priv->h > 0) { d_height = height = vf->priv->h; } - vf->priv->fmt=getfmt(outfmt); - mp_msg(MSGT_VFILTER,MSGL_V,"rgb test format:%s\n", vo_format_name(outfmt)); - return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); -} - -static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ - mp_image_t *dmpi; - int x, y; - int w = vf->priv->w > 0 ? vf->priv->w : mpi->w; - int h = vf->priv->h > 0 ? vf->priv->h : mpi->h; - - // hope we'll get DR buffer: - dmpi=vf_get_image(vf->next,vf->priv->fmt, - MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, - w, h); - - for(y=0; yplanes[0], x, y, dmpi->stride[0], r, g, b, vf->priv->fmt); - } - } - - return vf_next_put_image(vf,dmpi, pts); -} - -//===========================================================================// - -static int query_format(struct vf_instance *vf, unsigned int outfmt){ - unsigned int fmt=getfmt(outfmt); - if(!fmt) return 0; - return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW); -} - -static int vf_open(vf_instance_t *vf, char *args){ - vf->config=config; - vf->put_image=put_image; - vf->query_format=query_format; - vf->priv=malloc(sizeof(struct vf_priv_s)); - vf->priv->w = vf->priv->h = 0; - if (args) - sscanf(args, "%d:%d", &vf->priv->w, &vf->priv->h); - return 1; -} - -const vf_info_t vf_info_rgbtest = { - "rgbtest", - "rgbtest", - "Michael Niedermayer", - "", - vf_open, - NULL -}; - -//===========================================================================// diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c index c4ce3d8155..afb181ec32 100644 --- a/libavfilter/vf_mp.c +++ b/libavfilter/vf_mp.c @@ -181,7 +181,6 @@ extern const vf_info_t vf_info_fspp; extern const vf_info_t vf_info_pp7; extern const vf_info_t vf_info_yuvcsp; extern const vf_info_t vf_info_kerndeint; -extern const vf_info_t vf_info_rgbtest; extern const vf_info_t vf_info_qp; extern const vf_info_t vf_info_phase; extern const vf_info_t vf_info_divtc; @@ -239,7 +238,6 @@ static const vf_info_t* const filters[]={ &vf_info_qp, &vf_info_rectangle, &vf_info_remove_logo, - &vf_info_rgbtest, &vf_info_rotate, &vf_info_sab, &vf_info_screenshot, From ad4cd0c2a4d7b2c323900a57f24fcf41d53a2410 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 14 Jul 2011 03:56:07 +0200 Subject: [PATCH 535/780] doxygen: use Doxygen markup for authors and web links where appropriate --- libavcodec/alac.c | 4 +--- libavcodec/eatqi.c | 6 ++---- libavcodec/flacdec.c | 4 +--- libavcodec/lzw.c | 2 +- libavcodec/lzw.h | 2 +- libavcodec/rl2.c | 4 +--- libavcodec/tta.c | 4 ++-- libavcodec/vqavideo.c | 6 +++--- libavdevice/fbdev.c | 2 +- libavformat/iss.c | 4 +--- libavformat/rl2.c | 4 +--- libavformat/rtpdec_svq3.c | 2 +- libavformat/rtpdec_vp8.c | 2 +- 13 files changed, 17 insertions(+), 29 deletions(-) diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 4ea3f7ee84..f7e674927b 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -23,9 +23,7 @@ * @file * ALAC (Apple Lossless Audio Codec) decoder * @author 2005 David Hammerton - * - * For more information on the ALAC format, visit: - * http://crazney.net/programs/itunes/alac.html + * @see http://crazney.net/programs/itunes/alac.html * * Note: This decoder expects a 36- (0x24-)byte QuickTime atom to be * passed through the extradata[_size] fields. This atom is tacked onto diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index aa96437013..1215fa217b 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -22,10 +22,8 @@ /** * @file * Electronic Arts TQI Video Decoder - * by Peter Ross - * - * Technical details here: - * http://wiki.multimedia.cx/index.php?title=Electronic_Arts_TQI + * @author Peter Ross + * @see http://wiki.multimedia.cx/index.php?title=Electronic_Arts_TQI */ #include "avcodec.h" diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 1ce8559de6..fb18c85946 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -23,9 +23,7 @@ * @file * FLAC (Free Lossless Audio Codec) decoder * @author Alex Beregszaszi - * - * For more information on the FLAC format, visit: - * http://flac.sourceforge.net/ + * @see http://flac.sourceforge.net/ * * This decoder can be used in 1 of 2 ways: Either raw FLAC data can be fed * through, starting from the initial 'fLaC' signature; or by passing the diff --git a/libavcodec/lzw.c b/libavcodec/lzw.c index 6129429053..873b31445b 100644 --- a/libavcodec/lzw.c +++ b/libavcodec/lzw.c @@ -24,7 +24,7 @@ * @file * @brief LZW decoding routines * @author Fabrice Bellard - * Modified for use in TIFF by Konstantin Shishkov + * @author modified for use in TIFF by Konstantin Shishkov */ #include "avcodec.h" diff --git a/libavcodec/lzw.h b/libavcodec/lzw.h index c6ae05732c..ab782f5219 100644 --- a/libavcodec/lzw.h +++ b/libavcodec/lzw.h @@ -24,7 +24,7 @@ * @file * @brief LZW decoding routines * @author Fabrice Bellard - * modified for use in TIFF by Konstantin Shishkov + * @author modified for use in TIFF by Konstantin Shishkov */ #ifndef AVCODEC_LZW_H diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 9d436a682f..59f9bfb134 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -23,9 +23,7 @@ * @file * RL2 Video Decoder * @author Sascha Sommer (saschasommer@freenet.de) - * - * For more information about the RL2 format, visit: - * http://wiki.multimedia.cx/index.php?title=RL2 + * @see http://wiki.multimedia.cx/index.php?title=RL2 */ #include diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 57f5818d7b..001b1197b6 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -22,9 +22,9 @@ /** * @file * TTA (The Lossless True Audio) decoder - * (www.true-audio.com or tta.corecodec.org) + * @see http://www.true-audio.com/ + * @see http://tta.corecodec.org/ * @author Alex Beregszaszi - * */ #define ALT_BITSTREAM_READER_LE diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index caffddbfa4..55b95dceba 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -21,9 +21,9 @@ /** * @file - * VQA Video Decoder by Mike Melanson (melanson@pcisys.net) - * For more information about the VQA format, visit: - * http://wiki.multimedia.cx/index.php?title=VQA + * VQA Video Decoder + * @author Mike Melanson (melanson@pcisys.net) + * @see http://wiki.multimedia.cx/index.php?title=VQA * * The VQA video decoder outputs PAL8 or RGB555 colorspace data, depending * on the type of data in the file. diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index 2f3e0ff937..eb654aa4b3 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -24,7 +24,7 @@ * @file * Linux framebuffer input device, * inspired by code from fbgrab.c by Gunnar Monell. - * See also http://linux-fbdev.sourceforge.net/. + * @see http://linux-fbdev.sourceforge.net/ */ /* #define DEBUG */ diff --git a/libavformat/iss.c b/libavformat/iss.c index 100066bad2..7989194126 100644 --- a/libavformat/iss.c +++ b/libavformat/iss.c @@ -23,9 +23,7 @@ * @file * Funcom ISS file demuxer * @author Jaikrishnan Menon - * - * For more information on the .iss file format, visit: - * http://wiki.multimedia.cx/index.php?title=FunCom_ISS + * @see http://wiki.multimedia.cx/index.php?title=FunCom_ISS */ #include "avformat.h" diff --git a/libavformat/rl2.c b/libavformat/rl2.c index 68c1a01636..c84e4e1705 100644 --- a/libavformat/rl2.c +++ b/libavformat/rl2.c @@ -23,9 +23,7 @@ * RL2 file demuxer * @file * @author Sascha Sommer (saschasommer@freenet.de) - * - * For more information regarding the RL2 file format, visit: - * http://wiki.multimedia.cx/index.php?title=RL2 + * @see http://wiki.multimedia.cx/index.php?title=RL2 * * extradata: * 2 byte le initial drawing offset within 320x200 viewport diff --git a/libavformat/rtpdec_svq3.c b/libavformat/rtpdec_svq3.c index 331434245e..4df3e3a3e0 100644 --- a/libavformat/rtpdec_svq3.c +++ b/libavformat/rtpdec_svq3.c @@ -22,8 +22,8 @@ /** * @file * @brief RTP support for the SV3V (SVQ3) payload - * (http://wiki.multimedia.cx/index.php?title=Sorenson_Video_3#Packetization) * @author Ronald S. Bultje + * @see http://wiki.multimedia.cx/index.php?title=Sorenson_Video_3#Packetization */ #include diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c index 026728ec9d..d13c3982df 100644 --- a/libavformat/rtpdec_vp8.c +++ b/libavformat/rtpdec_vp8.c @@ -23,7 +23,7 @@ * @file * @brief RTP support for the VP8 payload * @author Josh Allmann - * ( http://www.webmproject.org/code/specs/rtp/ ) + * @see http://www.webmproject.org/code/specs/rtp/ */ #include "libavcodec/bytestream.h" From bee6d2fd76015b1ee0d73c5f3500b0a7d0109199 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 00:45:23 +0200 Subject: [PATCH 536/780] doxygen: replace @sa tag by the more readable but equivalent @see --- libavcodec/bethsoftvideo.c | 4 ++-- libavcodec/bfi.c | 2 +- libavcodec/cdgraphics.c | 4 ++-- libavcodec/pcxenc.c | 2 +- libavcodec/tmv.c | 2 +- libavformat/bethsoftvid.c | 4 ++-- libavformat/bfi.c | 2 +- libavformat/qcp.c | 2 +- libavformat/soxdec.c | 2 +- libavformat/soxenc.c | 2 +- libavformat/tmv.c | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c index d294bbfe74..bd21dbff63 100644 --- a/libavcodec/bethsoftvideo.c +++ b/libavcodec/bethsoftvideo.c @@ -23,8 +23,8 @@ * @file * @brief Bethesda Softworks VID Video Decoder * @author Nicholas Tung [ntung (at. ntung com] (2007-03) - * @sa http://wiki.multimedia.cx/index.php?title=Bethsoft_VID - * @sa http://www.svatopluk.com/andux/docs/dfvid.html + * @see http://wiki.multimedia.cx/index.php?title=Bethsoft_VID + * @see http://www.svatopluk.com/andux/docs/dfvid.html */ #include "libavutil/common.h" diff --git a/libavcodec/bfi.c b/libavcodec/bfi.c index c97dfe2dc0..3c66226041 100644 --- a/libavcodec/bfi.c +++ b/libavcodec/bfi.c @@ -23,7 +23,7 @@ * @file * @brief Brute Force & Ignorance (.bfi) video decoder * @author Sisir Koppaka ( sisir.koppaka at gmail dot com ) - * @sa http://wiki.multimedia.cx/index.php?title=BFI + * @see http://wiki.multimedia.cx/index.php?title=BFI */ #include "libavutil/common.h" diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index 2f8e98ca3d..9e3f19a5f7 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -26,8 +26,8 @@ * @file * @brief CD Graphics Video Decoder * @author Michael Tison - * @sa http://wiki.multimedia.cx/index.php?title=CD_Graphics - * @sa http://www.ccs.neu.edu/home/bchafy/cdb/info/cdg + * @see http://wiki.multimedia.cx/index.php?title=CD_Graphics + * @see http://www.ccs.neu.edu/home/bchafy/cdb/info/cdg */ /// default screen sizes diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c index 2df84afa38..6d17987d03 100644 --- a/libavcodec/pcxenc.c +++ b/libavcodec/pcxenc.c @@ -23,7 +23,7 @@ * @file * PCX image encoder * @author Daniel Verkamp - * @sa http://www.qzx.com/pc-gpe/pcx.txt + * @see http://www.qzx.com/pc-gpe/pcx.txt */ #include "avcodec.h" diff --git a/libavcodec/tmv.c b/libavcodec/tmv.c index d540182ada..870f57159c 100644 --- a/libavcodec/tmv.c +++ b/libavcodec/tmv.c @@ -23,7 +23,7 @@ * @file * 8088flex TMV video decoder * @author Daniel Verkamp - * @sa http://www.oldskool.org/pc/8088_Corruption + * @see http://www.oldskool.org/pc/8088_Corruption */ #include "avcodec.h" diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c index 5e6a776824..73564c95fe 100644 --- a/libavformat/bethsoftvid.c +++ b/libavformat/bethsoftvid.c @@ -23,8 +23,8 @@ * @file * @brief Bethesda Softworks VID (.vid) file demuxer * @author Nicholas Tung [ntung (at. ntung com] (2007-03) - * @sa http://wiki.multimedia.cx/index.php?title=Bethsoft_VID - * @sa http://www.svatopluk.com/andux/docs/dfvid.html + * @see http://wiki.multimedia.cx/index.php?title=Bethsoft_VID + * @see http://www.svatopluk.com/andux/docs/dfvid.html */ #include "libavutil/intreadwrite.h" diff --git a/libavformat/bfi.c b/libavformat/bfi.c index bc26d47c9e..72df8b2afb 100644 --- a/libavformat/bfi.c +++ b/libavformat/bfi.c @@ -23,7 +23,7 @@ * @file * @brief Brute Force & Ignorance (.bfi) file demuxer * @author Sisir Koppaka ( sisir.koppaka at gmail dot com ) - * @sa http://wiki.multimedia.cx/index.php?title=BFI + * @see http://wiki.multimedia.cx/index.php?title=BFI */ #include "libavutil/intreadwrite.h" diff --git a/libavformat/qcp.c b/libavformat/qcp.c index 635d531f44..aefb076e3b 100644 --- a/libavformat/qcp.c +++ b/libavformat/qcp.c @@ -23,7 +23,7 @@ * @file * QCP format (.qcp) demuxer * @author Kenan Gillet - * @sa RFC 3625: "The QCP File Format and Media Types for Speech Data" + * @see RFC 3625: "The QCP File Format and Media Types for Speech Data" * http://tools.ietf.org/html/rfc3625 */ diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c index ca82ef1cca..7661bf1f8f 100644 --- a/libavformat/soxdec.c +++ b/libavformat/soxdec.c @@ -26,7 +26,7 @@ * @file * SoX native format demuxer * @author Daniel Verkamp - * @sa http://wiki.multimedia.cx/index.php?title=SoX_native_intermediate_format + * @see http://wiki.multimedia.cx/index.php?title=SoX_native_intermediate_format */ #include "libavutil/intreadwrite.h" diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c index e28c479c97..d7afe70aac 100644 --- a/libavformat/soxenc.c +++ b/libavformat/soxenc.c @@ -26,7 +26,7 @@ * @file * SoX native format muxer * @author Daniel Verkamp - * @sa http://wiki.multimedia.cx/index.php?title=SoX_native_intermediate_format + * @see http://wiki.multimedia.cx/index.php?title=SoX_native_intermediate_format */ #include "libavutil/intreadwrite.h" diff --git a/libavformat/tmv.c b/libavformat/tmv.c index 79a875885e..fe8b64b3dd 100644 --- a/libavformat/tmv.c +++ b/libavformat/tmv.c @@ -23,7 +23,7 @@ * @file * 8088flex TMV file demuxer * @author Daniel Verkamp - * @sa http://www.oldskool.org/pc/8088_Corruption + * @see http://www.oldskool.org/pc/8088_Corruption */ #include "libavutil/intreadwrite.h" From 66f6bab7ad2034672f3c6fe9602b59fe291d2d60 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 00:45:59 +0200 Subject: [PATCH 537/780] mem.h: switch doxygen parameter order to match function prototype --- libavutil/mem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/mem.h b/libavutil/mem.h index 5dea492021..e14e8d038c 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -76,10 +76,10 @@ void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); * Allocate or reallocate a block of memory. * If ptr is NULL and size > 0, allocate a new block. If * size is zero, free the memory block pointed to by ptr. - * @param size Size in bytes for the memory block to be allocated or - * reallocated. * @param ptr Pointer to a memory block already allocated with * av_malloc(z)() or av_realloc() or NULL. + * @param size Size in bytes for the memory block to be allocated or + * reallocated. * @return Pointer to a newly reallocated block or NULL if the block * cannot be reallocated or the function is used to free the memory block. * @see av_fast_realloc() From e3bc07f4af25287fa4ade1e9c5501de65c8a698e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 15 Jul 2011 10:53:12 +0300 Subject: [PATCH 538/780] configure: Automatically add more flags required on symbian MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- configure | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 596b6039e3..28e3e25f18 100755 --- a/configure +++ b/configure @@ -2499,7 +2499,14 @@ case $target_os in symbian) SLIBSUF=".dll" enable dos_paths - add_cflags --include=$sysinclude/gcce/gcce.h + add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default + add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS + add_ldflags -Wl,--target1-abs,--no-undefined \ + -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \ + -Wl,--entry=_E32Startup -Wl,-u,_E32Startup + add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \ + -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \ + -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib ;; none) ;; From e6cc30c22bb2007e4d66302d6477176ecf0c0877 Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Fri, 15 Jul 2011 15:59:46 +1000 Subject: [PATCH 539/780] wtvdec: also support big-sectors when fat depth is zero Signed-off-by: Michael Niedermayer --- libavformat/wtvdec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index 816fb908fa..f13dc74372 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -164,7 +164,6 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int } wf->sectors[0] = first_sector; wf->nb_sectors = 1; - wf->sector_bits = WTV_SECTOR_BITS; } else if (depth == 1) { wf->sectors = av_malloc(WTV_SECTOR_SIZE); if (!wf->sectors) { @@ -172,7 +171,6 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int return NULL; } wf->nb_sectors = read_ints(s->pb, wf->sectors, WTV_SECTOR_SIZE / 4); - wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS; } else if (depth == 2) { uint32_t sectors1[WTV_SECTOR_SIZE / 4]; int nb_sectors1 = read_ints(s->pb, sectors1, WTV_SECTOR_SIZE / 4); @@ -189,12 +187,12 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int break; wf->nb_sectors += read_ints(s->pb, wf->sectors + i * WTV_SECTOR_SIZE / 4, WTV_SECTOR_SIZE / 4); } - wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS; } else { av_log(s, AV_LOG_ERROR, "unsupported file allocation table depth (0x%x)\n", depth); av_free(wf); return NULL; } + wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS; if (!wf->nb_sectors) { av_free(wf->sectors); From 32aef7d01909034f231c98a5ad8c23f43738e1cf Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 15 Jul 2011 18:27:30 +0200 Subject: [PATCH 540/780] ffmpeg: fix muxer private options (bug introduced by anton khirnov) Signed-off-by: Michael Niedermayer --- ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index 252f29d4a6..5548d41e78 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2579,7 +2579,7 @@ static int transcode(AVFormatContext **output_files, ret = AVERROR(EINVAL); goto dump_format; } - assert_avoptions(output_opts[i]); +// assert_avoptions(output_opts[i]); if (strcmp(output_files[i]->oformat->name, "rtp")) { want_sdp = 0; } From c3bec4cd1391c7f2ca0e98713e3721d0336b49c4 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 21 May 2011 19:13:22 +0200 Subject: [PATCH 541/780] avio: don't replicate avio_alloc_context functionality. --- libavformat/aviobuf.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index fa63ddf2b9..b5e9d4c61c 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -838,19 +838,12 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) if (!buffer) return AVERROR(ENOMEM); - *s = av_mallocz(sizeof(AVIOContext)); - if(!*s) { + *s = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h, + ffurl_read, ffurl_write, ffurl_seek); + if (!*s) { av_free(buffer); return AVERROR(ENOMEM); } - - if (ffio_init_context(*s, buffer, buffer_size, - h->flags & AVIO_FLAG_WRITE, h, - ffurl_read, ffurl_write, ffurl_seek) < 0) { - av_free(buffer); - av_freep(s); - return AVERROR(EIO); - } #if FF_API_OLD_AVIO (*s)->is_streamed = h->is_streamed; #endif From d3bb71914bcdf83311d70cb1e235cdd85527e5cf Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 15 Jul 2011 20:27:43 +0200 Subject: [PATCH 542/780] lavf/utils: drop av_ prefixes from static functions. --- libavformat/utils.c | 60 ++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 4b675e66c2..161cdb43f8 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -79,7 +79,7 @@ const char *avformat_license(void) * @param num must be >= 0 * @param den must be >= 1 */ -static void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den) +static void frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den) { num += (den >> 1); if (num >= den) { @@ -97,7 +97,7 @@ static void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den) * @param f fractional number * @param incr increment, can be positive or negative */ -static void av_frac_add(AVFrac *f, int64_t incr) +static void frac_add(AVFrac *f, int64_t incr) { int64_t num, den; @@ -1088,7 +1088,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, } -static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt) +static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) { AVStream *st; int len, ret, i; @@ -1218,7 +1218,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt) } } if(s->debug & FF_FDEBUG_TS) - av_log(s, AV_LOG_DEBUG, "av_read_frame_internal stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n", + av_log(s, AV_LOG_DEBUG, "read_frame_internal stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n", pkt->stream_index, pkt->pts, pkt->dts, @@ -1264,7 +1264,7 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) } } if(genpts){ - int ret= av_read_frame_internal(s, pkt); + int ret= read_frame_internal(s, pkt); if(ret<0){ if(pktl && ret != AVERROR(EAGAIN)){ eof=1; @@ -1278,7 +1278,7 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) return AVERROR(ENOMEM); }else{ assert(!s->packet_buffer); - return av_read_frame_internal(s, pkt); + return read_frame_internal(s, pkt); } } } @@ -1650,7 +1650,7 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i return pos; } -static int av_seek_frame_byte(AVFormatContext *s, int stream_index, int64_t pos, int flags){ +static int seek_frame_byte(AVFormatContext *s, int stream_index, int64_t pos, int flags){ int64_t pos_min, pos_max; #if 0 AVStream *st; @@ -1675,7 +1675,7 @@ static int av_seek_frame_byte(AVFormatContext *s, int stream_index, int64_t pos, return 0; } -static int av_seek_frame_generic(AVFormatContext *s, +static int seek_frame_generic(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { int index; @@ -1743,7 +1743,7 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f ff_read_frame_flush(s); if(flags & AVSEEK_FLAG_BYTE) - return av_seek_frame_byte(s, stream_index, timestamp, flags); + return seek_frame_byte(s, stream_index, timestamp, flags); if(stream_index < 0){ stream_index= av_find_default_stream_index(s); @@ -1767,7 +1767,7 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f if(s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) return av_seek_frame_binary(s, stream_index, timestamp, flags); else if (!(s->iformat->flags & AVFMT_NOGENSEARCH)) - return av_seek_frame_generic(s, stream_index, timestamp, flags); + return seek_frame_generic(s, stream_index, timestamp, flags); else return -1; } @@ -1791,7 +1791,7 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int if(s->iformat->read_seek || 1) return av_seek_frame(s, stream_index, ts, flags | (ts - min_ts > (uint64_t)(max_ts - ts) ? AVSEEK_FLAG_BACKWARD : 0)); - // try some generic seek like av_seek_frame_generic() but with new ts semantics + // try some generic seek like seek_frame_generic() but with new ts semantics } /*******************************************************/ @@ -1801,7 +1801,7 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int * * @return TRUE if the stream has accurate duration for at least one component. */ -static int av_has_duration(AVFormatContext *ic) +static int has_duration(AVFormatContext *ic) { int i; AVStream *st; @@ -1819,7 +1819,7 @@ static int av_has_duration(AVFormatContext *ic) * * Also computes the global bitrate if possible. */ -static void av_update_stream_timings(AVFormatContext *ic) +static void update_stream_timings(AVFormatContext *ic) { int64_t start_time, start_time1, end_time, end_time1; int64_t duration, duration1; @@ -1870,7 +1870,7 @@ static void fill_all_stream_timings(AVFormatContext *ic) int i; AVStream *st; - av_update_stream_timings(ic); + update_stream_timings(ic); for(i = 0;i < ic->nb_streams; i++) { st = ic->streams[i]; if (st->start_time == AV_NOPTS_VALUE) { @@ -1882,7 +1882,7 @@ static void fill_all_stream_timings(AVFormatContext *ic) } } -static void av_estimate_timings_from_bit_rate(AVFormatContext *ic) +static void estimate_timings_from_bit_rate(AVFormatContext *ic) { int64_t filesize, duration; int bit_rate, i; @@ -1919,7 +1919,7 @@ static void av_estimate_timings_from_bit_rate(AVFormatContext *ic) #define DURATION_MAX_RETRY 3 /* only usable for MPEG-PS streams */ -static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) +static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) { AVPacket pkt1, *pkt = &pkt1; AVStream *st; @@ -1936,7 +1936,7 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset for (i=0; inb_streams; i++) { st = ic->streams[i]; if (st->start_time == AV_NOPTS_VALUE && st->first_dts == AV_NOPTS_VALUE) - av_log(st->codec, AV_LOG_WARNING, "start time is not set in av_estimate_timings_from_pts\n"); + av_log(st->codec, AV_LOG_WARNING, "start time is not set in estimate_timings_from_pts\n"); if (st->parser) { av_parser_close(st->parser); @@ -1998,7 +1998,7 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset } } -static void av_estimate_timings(AVFormatContext *ic, int64_t old_offset) +static void estimate_timings(AVFormatContext *ic, int64_t old_offset) { int64_t file_size; @@ -2016,17 +2016,17 @@ static void av_estimate_timings(AVFormatContext *ic, int64_t old_offset) !strcmp(ic->iformat->name, "mpegts")) && file_size && ic->pb->seekable) { /* get accurate estimate from the PTSes */ - av_estimate_timings_from_pts(ic, old_offset); - } else if (av_has_duration(ic)) { + estimate_timings_from_pts(ic, old_offset); + } else if (has_duration(ic)) { /* at least one component has timings - we use them for all the components */ fill_all_stream_timings(ic); } else { av_log(ic, AV_LOG_WARNING, "Estimating duration from bitrate, this may be inaccurate\n"); /* less precise: use bitrate info */ - av_estimate_timings_from_bit_rate(ic); + estimate_timings_from_bit_rate(ic); } - av_update_stream_timings(ic); + update_stream_timings(ic); { int i; @@ -2311,7 +2311,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) /* NOTE: a new stream can be added there if no header in file (AVFMTCTX_NOHEADER) */ - ret = av_read_frame_internal(ic, &pkt1); + ret = read_frame_internal(ic, &pkt1); if (ret == AVERROR(EAGAIN)) continue; @@ -2467,7 +2467,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) } } - av_estimate_timings(ic, old_offset); + estimate_timings(ic, old_offset); compute_chapters_end(ic); @@ -2931,7 +2931,7 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) ret = AVERROR_INVALIDDATA; goto fail; } - av_frac_init(&st->pts, 0, 0, den); + frac_init(&st->pts, 0, 0, den); } } @@ -3009,11 +3009,11 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){ likely equal to the encoder delay, but it would be better if we had the real timestamps from the encoder */ if (frame_size >= 0 && (pkt->size || st->pts.num!=st->pts.den>>1 || st->pts.val)) { - av_frac_add(&st->pts, (int64_t)st->time_base.den * frame_size); + frac_add(&st->pts, (int64_t)st->time_base.den * frame_size); } break; case AVMEDIA_TYPE_VIDEO: - av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num); + frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num); break; default: break; @@ -3122,7 +3122,7 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk * @return 1 if a packet was output, 0 if no packet could be output, * < 0 if an error occurred */ -static int av_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush){ +static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush){ if(s->oformat->interleave_packet) return s->oformat->interleave_packet(s, out, in, flush); else @@ -3147,7 +3147,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){ for(;;){ AVPacket opkt; - int ret= av_interleave_packet(s, &opkt, pkt, 0); + int ret= interleave_packet(s, &opkt, pkt, 0); if(ret<=0) //FIXME cleanup needed for ret<0 ? return ret; @@ -3169,7 +3169,7 @@ int av_write_trailer(AVFormatContext *s) for(;;){ AVPacket pkt; - ret= av_interleave_packet(s, &pkt, NULL, 1); + ret= interleave_packet(s, &pkt, NULL, 1); if(ret<0) //FIXME cleanup needed for ret<0 ? goto fail; if(!ret) From e5902d60ce8f7cf10b6e87a57eec536b316261a3 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 15 Jul 2011 22:38:10 +0100 Subject: [PATCH 543/780] aacps: skip some memcpy() if src and dst would be equal Signed-off-by: Mans Rullgard --- libavcodec/aacps.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c index 03d0beabdd..93bdd91dea 100644 --- a/libavcodec/aacps.c +++ b/libavcodec/aacps.c @@ -813,14 +813,17 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2 const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; //Remapping - memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); - memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); - memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); - memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); - memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); - memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); - memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); - memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); + if (ps->num_env_old) { + memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); + memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); + memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); + memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); + memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); + memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); + memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); + memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); + } + if (is34) { remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); From 36ba39d140adb17997b660e89d3cc22726917353 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 15:05:51 +0200 Subject: [PATCH 544/780] flashsvenc: fix some comment typos --- libavcodec/flashsvenc.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index ad14104112..b1081ebf47 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -33,25 +33,24 @@ * The picture is divided into blocks that are zlib-compressed. * * The decoder is fed complete frames, the frameheader contains: - * 4bits of block width - * 12bits of frame width - * 4bits of block height - * 12bits of frame height + * 4 bits of block width + * 12 bits of frame width + * 4 bits of block height + * 12 bits of frame height * * Directly after the header are the compressed blocks. The blocks - * have their compressed size represented with 16bits in the beginig. + * have their compressed size represented with 16 bits in the beginning. * If the size = 0 then the block is unchanged from the previous frame. * All blocks are decompressed until the buffer is consumed. * - * Encoding ideas, a basic encoder would just use a fixed block size. - * Block sizes can be multipels of 16, from 16 to 256. The blocks don't + * Encoding ideas: A basic encoder would just use a fixed block size. + * Block sizes can be multiples of 16, from 16 to 256. The blocks don't * have to be quadratic. A brute force search with a set of different * block sizes should give a better result than to just use a fixed size. - */ - -/* TODO: - * Don't reencode the frame in brute force mode if the frame is a dupe. Speed up. - * Make the difference check faster. + * + * TODO: + * Don't reencode the frame in brute force mode if the frame is a dupe. + * Speed up. Make the difference check faster. */ #include @@ -156,12 +155,12 @@ static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf, /* loop over all block columns */ for (j = 0; j < v_blocks + (v_part ? 1 : 0); j++) { - int hp = j * block_height; // horiz position in frame + int hp = j * block_height; // horizontal position in frame int hs = (j < v_blocks) ? block_height : v_part; // size of block /* loop over all block rows */ for (i = 0; i < h_blocks + (h_part ? 1 : 0); i++) { - int wp = i * block_width; // vert position in frame + int wp = i * block_width; // vertical position in frame int ws = (i < h_blocks) ? block_width : h_part; // size of block int ret = Z_OK; uint8_t *ptr; From 4877356d8fcd873318bfc57625adde4007b66cf7 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 15:09:39 +0200 Subject: [PATCH 545/780] flashsvenc: drop some unnecessary parentheses --- libavcodec/flashsvenc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index b1081ebf47..fa6209a26b 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -84,8 +84,8 @@ static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, int dx, int dy, int diff = 0; for (i = dx + h; i > dx; i--) { - nsptr = sptr + (i * stride) + dy * 3; - npfptr = pfptr + (i * stride) + dy * 3; + nsptr = sptr + i * stride + dy * 3; + npfptr = pfptr + i * stride + dy * 3; for (j = 0; j < w * 3; j++) { diff |= npfptr[j] ^ nsptr[j]; dptr[j] = nsptr[j]; @@ -103,13 +103,13 @@ static av_cold int flashsv_encode_init(AVCodecContext *avctx) s->avctx = avctx; - if ((avctx->width > 4095) || (avctx->height > 4095)) { + if (avctx->width > 4095 || avctx->height > 4095) { av_log(avctx, AV_LOG_ERROR, "Input dimensions too large, input must be max 4096x4096 !\n"); return AVERROR_INVALIDDATA; } // Needed if zlib unused or init aborted before deflateInit - memset(&(s->zstream), 0, sizeof(z_stream)); + memset(&s->zstream, 0, sizeof(z_stream)); s->last_key_frame = 0; @@ -140,9 +140,9 @@ static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf, init_put_bits(&pb, buf, buf_size * 8); - put_bits(&pb, 4, (block_width / 16) - 1); + put_bits(&pb, 4, block_width / 16 - 1); put_bits(&pb, 12, s->image_width); - put_bits(&pb, 4, (block_height / 16) - 1); + put_bits(&pb, 4, block_height / 16 - 1); put_bits(&pb, 12, s->image_height); flush_put_bits(&pb); buf_pos = 4; @@ -179,7 +179,7 @@ static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf, ret = compress2(ptr + 2, &zsize, s->tmpblock, 3 * ws * hs, 9); - //ret = deflateReset(&(s->zstream)); + //ret = deflateReset(&s->zstream); if (ret != Z_OK) av_log(s->avctx, AV_LOG_ERROR, "error while compressing block %dx%d\n", i, j); @@ -227,7 +227,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, } if (p->linesize[0] < 0) - pfptr = s->previous_frame - ((s->image_height - 1) * p->linesize[0]); + pfptr = s->previous_frame - (s->image_height - 1) * p->linesize[0]; else pfptr = s->previous_frame; @@ -277,7 +277,7 @@ static av_cold int flashsv_encode_end(AVCodecContext *avctx) { FlashSVContext *s = avctx->priv_data; - deflateEnd(&(s->zstream)); + deflateEnd(&s->zstream); av_free(s->encbuffer); av_free(s->previous_frame); From 3d5669c6e9765b5f8096cd69e90c3e2904f19b4d Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 15:26:18 +0200 Subject: [PATCH 546/780] flashsvenc: whitespace cosmetics --- libavcodec/flashsvenc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index fa6209a26b..7a66bc2d85 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -104,7 +104,8 @@ static av_cold int flashsv_encode_init(AVCodecContext *avctx) s->avctx = avctx; if (avctx->width > 4095 || avctx->height > 4095) { - av_log(avctx, AV_LOG_ERROR, "Input dimensions too large, input must be max 4096x4096 !\n"); + av_log(avctx, AV_LOG_ERROR, + "Input dimensions too large, input must be max 4096x4096 !\n"); return AVERROR_INVALIDDATA; } @@ -181,7 +182,8 @@ static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf, //ret = deflateReset(&s->zstream); if (ret != Z_OK) - av_log(s->avctx, AV_LOG_ERROR, "error while compressing block %dx%d\n", i, j); + av_log(s->avctx, AV_LOG_ERROR, + "error while compressing block %dx%d\n", i, j); bytestream_put_be16(&ptr, (unsigned int) zsize); buf_pos += zsize + 2; @@ -241,26 +243,28 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, opt_w = 4; opt_h = 4; - if (buf_size < s->image_width*s->image_height*3) { + if (buf_size < s->image_width * s->image_height * 3) { //Conservative upper bound check for compressed data av_log(avctx, AV_LOG_ERROR, "buf_size %d < %d\n", buf_size, s->image_width * s->image_height * 3); return -1; } - res = encode_bitstream(s, p, buf, buf_size, opt_w * 16, opt_h * 16, pfptr, &I_frame); + res = encode_bitstream(s, p, buf, buf_size, opt_w * 16, opt_h * 16, + pfptr, &I_frame); //save the current frame if (p->linesize[0] > 0) memcpy(s->previous_frame, p->data[0], s->image_height * p->linesize[0]); else - memcpy(s->previous_frame, p->data[0] + p->linesize[0] * (s->image_height - 1), + memcpy(s->previous_frame, + p->data[0] + p->linesize[0] * (s->image_height - 1), s->image_height * FFABS(p->linesize[0])); //mark the frame type so the muxer can mux it correctly if (I_frame) { - p->pict_type = AV_PICTURE_TYPE_I; - p->key_frame = 1; + p->pict_type = AV_PICTURE_TYPE_I; + p->key_frame = 1; s->last_key_frame = avctx->frame_number; av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n", avctx->frame_number); } else { From b88523c25da37fb45b2df720218f5868b8e891fc Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 15:26:49 +0200 Subject: [PATCH 547/780] flashsvenc: convert some debug av_log() to av_dlog() --- libavcodec/flashsvenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index 7a66bc2d85..5d04549948 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -187,7 +187,7 @@ static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf, bytestream_put_be16(&ptr, (unsigned int) zsize); buf_pos += zsize + 2; - //av_log(avctx, AV_LOG_ERROR, "buf_pos = %d\n", buf_pos); + av_dlog(avctx, "buf_pos = %d\n", buf_pos); } else { pred_blocks++; bytestream_put_be16(&ptr, 0); @@ -266,7 +266,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; s->last_key_frame = avctx->frame_number; - av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n", avctx->frame_number); + av_dlog(avctx, "Inserting keyframe at frame %d\n", avctx->frame_number); } else { p->pict_type = AV_PICTURE_TYPE_P; p->key_frame = 0; From 12e9bf3e845bd444223e1f326edaabd36236362f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 15:28:18 +0200 Subject: [PATCH 548/780] flashsvenc: merge variable declarations and initializations --- libavcodec/flashsvenc.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index 5d04549948..ec70b72ce4 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -164,9 +164,7 @@ static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf, int wp = i * block_width; // vertical position in frame int ws = (i < h_blocks) ? block_width : h_part; // size of block int ret = Z_OK; - uint8_t *ptr; - - ptr = buf + buf_pos; + uint8_t *ptr = buf + buf_pos; /* copy the block to the temp buffer before compression * (if it differs from the previous frame's block) */ @@ -175,11 +173,9 @@ static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf, wp, hs, ws, p->linesize[0], previous_frame); if (res || *I_frame) { - unsigned long zsize; - zsize = 3 * block_width * block_height; + unsigned long zsize = 3 * block_width * block_height; ret = compress2(ptr + 2, &zsize, s->tmpblock, 3 * ws * hs, 9); - //ret = deflateReset(&s->zstream); if (ret != Z_OK) av_log(s->avctx, AV_LOG_ERROR, @@ -214,7 +210,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, uint8_t *pfptr; int res; int I_frame = 0; - int opt_w, opt_h; + int opt_w = 4, opt_h = 4; *p = *pict; @@ -240,9 +236,6 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, } } - opt_w = 4; - opt_h = 4; - if (buf_size < s->image_width * s->image_height * 3) { //Conservative upper bound check for compressed data av_log(avctx, AV_LOG_ERROR, "buf_size %d < %d\n", From 59ef6bded5d01e4debf08dc65cfd4a088652759b Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 15:28:43 +0200 Subject: [PATCH 549/780] flashsvenc: merge two consecutive if-conditions --- libavcodec/flashsvenc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index ec70b72ce4..7082040670 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -230,10 +230,9 @@ static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, pfptr = s->previous_frame; /* Check the placement of keyframes */ - if (avctx->gop_size > 0) { - if (avctx->frame_number >= s->last_key_frame + avctx->gop_size) { - I_frame = 1; - } + if (avctx->gop_size > 0 && + avctx->frame_number >= s->last_key_frame + avctx->gop_size) { + I_frame = 1; } if (buf_size < s->image_width * s->image_height * 3) { From 0686515cb49c813eedbb5f9caee3903056060e3b Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 15:55:19 +0200 Subject: [PATCH 550/780] flashsvenc: improve some variable names and fix corresponding comments --- libavcodec/flashsvenc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index 7082040670..681d6c9b1c 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -156,25 +156,27 @@ static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf, /* loop over all block columns */ for (j = 0; j < v_blocks + (v_part ? 1 : 0); j++) { - int hp = j * block_height; // horizontal position in frame - int hs = (j < v_blocks) ? block_height : v_part; // size of block + int y_pos = j * block_height; // vertical position in frame + int cur_blk_height = (j < v_blocks) ? block_height : v_part; /* loop over all block rows */ for (i = 0; i < h_blocks + (h_part ? 1 : 0); i++) { - int wp = i * block_width; // vertical position in frame - int ws = (i < h_blocks) ? block_width : h_part; // size of block + int x_pos = i * block_width; // horizontal position in frame + int cur_blk_width = (i < h_blocks) ? block_width : h_part; int ret = Z_OK; uint8_t *ptr = buf + buf_pos; /* copy the block to the temp buffer before compression * (if it differs from the previous frame's block) */ res = copy_region_enc(p->data[0], s->tmpblock, - s->image_height - (hp + hs + 1), - wp, hs, ws, p->linesize[0], previous_frame); + s->image_height - (y_pos + cur_blk_height + 1), + x_pos, cur_blk_height, cur_blk_width, + p->linesize[0], previous_frame); if (res || *I_frame) { unsigned long zsize = 3 * block_width * block_height; - ret = compress2(ptr + 2, &zsize, s->tmpblock, 3 * ws * hs, 9); + ret = compress2(ptr + 2, &zsize, s->tmpblock, + 3 * cur_blk_width * cur_blk_height, 9); //ret = deflateReset(&s->zstream); if (ret != Z_OK) From 20a6f210cdc870691018b44b41ba23e3b7e1bc2b Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 16:21:20 +0200 Subject: [PATCH 551/780] flashsvenc: drop unnecessary cast --- libavcodec/flashsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index 681d6c9b1c..2802c69b3c 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -183,7 +183,7 @@ static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf, av_log(s->avctx, AV_LOG_ERROR, "error while compressing block %dx%d\n", i, j); - bytestream_put_be16(&ptr, (unsigned int) zsize); + bytestream_put_be16(&ptr, zsize); buf_pos += zsize + 2; av_dlog(avctx, "buf_pos = %d\n", buf_pos); } else { From 86e8272a235ac233bf7dbad86bab2c45720d65ca Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 19:45:17 +0200 Subject: [PATCH 552/780] flashsvenc: replace bitstream description by a link to the specification An official specification now exists and it is both more detailed and easier to understand than the incomplete notes available here. --- libavcodec/flashsvenc.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index 2802c69b3c..6dc33b91f9 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -27,22 +27,13 @@ * Flash Screen Video encoder * @author Alex Beregszaszi * @author Benjamin Larsson + * + * A description of the bitstream format for Flash Screen Video version 1/2 + * is part of the SWF File Format Specification (version 10), which can be + * downloaded from http://www.adobe.com/devnet/swf.html. */ -/* Bitstream description - * The picture is divided into blocks that are zlib-compressed. - * - * The decoder is fed complete frames, the frameheader contains: - * 4 bits of block width - * 12 bits of frame width - * 4 bits of block height - * 12 bits of frame height - * - * Directly after the header are the compressed blocks. The blocks - * have their compressed size represented with 16 bits in the beginning. - * If the size = 0 then the block is unchanged from the previous frame. - * All blocks are decompressed until the buffer is consumed. - * +/* * Encoding ideas: A basic encoder would just use a fixed block size. * Block sizes can be multiples of 16, from 16 to 256. The blocks don't * have to be quadratic. A brute force search with a set of different From f20418c3491b745b0f82e6eb1a7debae4cfff126 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 01:06:16 +0200 Subject: [PATCH 553/780] vaapi: do not assert on value read from input bitstream User-provided data should never trigger an assert; return error instead. Also fix an instance of get_bits where get_bits_long should have been used. This eliminates the following warning: libavcodec/vaapi_mpeg2.c:112:14: warning: variable 'start_code' set but not used --- libavcodec/vaapi_mpeg2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c index 561f4bf800..b608246cb9 100644 --- a/libavcodec/vaapi_mpeg2.c +++ b/libavcodec/vaapi_mpeg2.c @@ -109,14 +109,14 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer MpegEncContext * const s = avctx->priv_data; VASliceParameterBufferMPEG2 *slice_param; GetBitContext gb; - uint32_t start_code, quantiser_scale_code, intra_slice_flag, macroblock_offset; + uint32_t quantiser_scale_code, intra_slice_flag, macroblock_offset; av_dlog(avctx, "vaapi_mpeg2_decode_slice(): buffer %p, size %d\n", buffer, size); /* Determine macroblock_offset */ init_get_bits(&gb, buffer, 8 * size); - start_code = get_bits(&gb, 32); - assert((start_code & 0xffffff00) == 0x00000100); + if (get_bits_long(&gb, 32) >> 8 != 1) /* start code */ + return AVERROR_INVALIDDATA; quantiser_scale_code = get_bits(&gb, 5); intra_slice_flag = get_bits1(&gb); if (intra_slice_flag) { From 356be9307cbffa1226bed52b26aa2ac9c7af174f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 29 Apr 2011 19:40:16 +0200 Subject: [PATCH 554/780] Remove unused structs and tables. --- libavcodec/cabac.c | 13 +---- libavcodec/mjpegdec.c | 23 -------- libavcodec/sp5x.h | 96 -------------------------------- libavcodec/vc1data.c | 125 +----------------------------------------- 4 files changed, 2 insertions(+), 255 deletions(-) diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c index 691beb0ae3..4846b32e87 100644 --- a/libavcodec/cabac.c +++ b/libavcodec/cabac.c @@ -75,18 +75,7 @@ static const uint8_t lps_state[64]= { 33,33,34,34,35,35,35,36, 36,36,37,37,37,38,38,63, }; -#if 0 -const uint8_t ff_h264_norm_shift_old[128]= { - 7,6,5,5,4,4,4,4,3,3,3,3,3,3,3,3, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -}; -#endif + const uint8_t ff_h264_norm_shift[512]= { 9,8,7,7,6,6,6,6,5,5,5,5,5,5,5,5, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 4684190e08..b28fdf8549 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1269,29 +1269,6 @@ static int mjpeg_decode_com(MJpegDecodeContext *s) return 0; } -#if 0 -static int valid_marker_list[] = -{ - /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f */ -/* 0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 1 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 2 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 3 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 4 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 5 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 6 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 7 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 8 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 9 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* a */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* b */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* c */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -/* d */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -/* e */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -/* f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, -} -#endif - /* return the 8 bit start code value and update the search state. Return -1 if no start code found */ static int find_marker(const uint8_t **pbuf_ptr, const uint8_t *buf_end) diff --git a/libavcodec/sp5x.h b/libavcodec/sp5x.h index 23c893be7f..1577302e3c 100644 --- a/libavcodec/sp5x.h +++ b/libavcodec/sp5x.h @@ -235,100 +235,4 @@ static const uint8_t sp5x_quant_table[20][64]= 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124 } }; -#if 0 -/* 4NF-M, not ZigZag */ -static const uint8_t sp5x_quant_table_orig[18][64] = -{ - /* index 0, Q50 */ - { 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 56, 68,109,103, 77, 24, 35, 55, 64, 81,104,113, 92, - 49, 64, 78, 87,103,121,120,101, 72, 92, 95, 98,112,100,103, 99 }, - { 17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }, - - /* index 1, Q70 */ - { 10, 7, 6, 10, 14, 24, 31, 37, 7, 7, 8, 11, 16, 35, 36, 33, - 8, 8, 10, 14, 24, 34, 41, 34, 8, 10, 13, 17, 31, 52, 48, 37, - 11, 13, 22, 34, 41, 65, 62, 46, 14, 21, 33, 38, 49, 62, 68, 55, - 29, 38, 47, 52, 62, 73, 72, 61, 43, 55, 57, 59, 67, 60, 62, 59 }, - { 10, 11, 14, 28, 59, 59, 59, 59, 11, 13, 16, 40, 59, 59, 59, 59, - 14, 16, 34, 59, 59, 59, 59, 59, 28, 40, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59 }, - - /* index 2, Q80 */ - { 6, 4, 4, 6, 10, 16, 20, 24, 5, 5, 6, 8, 10, 23, 24, 22, - 6, 5, 6, 10, 16, 23, 28, 22, 6, 7, 9, 12, 20, 35, 32, 25, - 7, 9, 15, 22, 27, 44, 41, 31, 10, 14, 22, 26, 32, 42, 45, 37, - 20, 26, 31, 35, 41, 48, 48, 40, 29, 37, 38, 39, 45, 40, 41, 40 }, - { 7, 7, 10, 19, 40, 40, 40, 40, 7, 8, 10, 26, 40, 40, 40, 40, - 10, 10, 22, 40, 40, 40, 40, 40, 19, 26, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 }, - - /* index 3, Q85 */ - { 5, 3, 3, 5, 7, 12, 15, 18, 4, 4, 4, 6, 8, 17, 18, 17, - 4, 4, 5, 7, 12, 17, 21, 17, 4, 5, 7, 9, 15, 26, 24, 19, - 5, 7, 11, 17, 20, 33, 31, 23, 7, 11, 17, 19, 24, 31, 34, 28, - 15, 19, 23, 26, 31, 36, 36, 30, 22, 28, 29, 29, 34, 30, 31, 30 }, - { 5, 5, 7, 14, 30, 30, 30, 30, 5, 6, 8, 20, 30, 30, 30, 30, - 7, 8, 17, 30, 30, 30, 30, 30, 14, 20, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 }, - - /* index 4, Q90 */ - { 3, 2, 2, 3, 5, 8, 10, 12, 2, 2, 3, 4, 5, 12, 12, 11, - 3, 3, 3, 5, 8, 11, 14, 11, 3, 3, 4, 6, 10, 17, 16, 12, - 4, 4, 7, 11, 14, 22, 21, 15, 5, 7, 11, 13, 16, 21, 23, 18, - 10, 13, 16, 17, 21, 24, 24, 20, 14, 18, 19, 20, 22, 20, 21, 20 }, - { 3, 4, 5, 9, 20, 20, 20, 20, 4, 4, 5, 13, 20, 20, 20, 20, - 5, 5, 11, 20, 20, 20, 20, 20, 9, 13, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 }, - - /* index 5, Q60 */ - { 13, 9, 8, 13, 19, 32, 41, 49, 10, 10, 11, 15, 21, 46, 48, 44, - 11, 10, 13, 19, 32, 46, 55, 45, 11, 14, 18, 23, 41, 70, 64, 50, - 14, 18, 30, 45, 54, 87, 82, 62, 19, 28, 44, 51, 65, 83, 90, 74, - 39, 51, 62, 70, 82, 97, 96, 81, 58, 74, 76, 78, 90, 80, 82, 79 }, - { 14, 14, 19, 38, 79, 79, 79, 79, 14, 17, 21, 53, 79, 79, 79, 79, - 19, 21, 45, 79, 79, 79, 79, 79, 38, 53, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79 }, - - /* index 6, Q25 */ - { 32, 22, 20, 32, 48, 80,102,122, 24, 24, 28, 38, 52,116,120,110, - 28, 26, 32, 48, 80,114,138,112, 28, 34, 44, 58,102,174,160,124, - 36, 44, 74,112,136,218,206,154, 48, 70,110,128,162,208,226,184, - 98,128,156,174,206,242,240,202,144,184,190,196,224,200,206,198 }, - { 34, 36, 48, 94,198,198,198,198, 36, 42, 52,132,198,198,198,198, - 48, 52,112,198,198,198,198,198, 94,132,198,198,198,198,198,198, - 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198, - 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198 }, - - /* index 7, Q95 */ - { 2, 1, 1, 2, 2, 4, 5, 6, 1, 1, 1, 2, 3, 6, 6, 6, - 1, 1, 2, 2, 4, 6, 7, 6, 1, 2, 2, 3, 5, 9, 8, 6, - 2, 2, 4, 6, 7, 11, 10, 8, 2, 4, 6, 6, 8, 10, 11, 9, - 5, 6, 8, 9, 10, 12, 12, 10, 7, 9, 10, 10, 11, 10, 10, 10 }, - { 2, 2, 2, 5, 10, 10, 10, 10, 2, 2, 3, 7, 10, 10, 10, 10, - 2, 3, 6, 10, 10, 10, 10, 10, 5, 7, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, - - /* index 8, Q93 */ - { 2, 2, 1, 2, 3, 6, 7, 9, 2, 2, 2, 3, 4, 8, 8, 8, - 2, 2, 2, 3, 6, 8, 10, 8, 2, 2, 3, 4, 7, 12, 11, 9, - 3, 3, 5, 8, 10, 15, 14, 11, 3, 5, 8, 9, 11, 15, 16, 13, - 7, 9, 11, 12, 14, 17, 17, 14, 10, 13, 13, 14, 16, 14, 14, 14 }, - { 2, 3, 3, 7, 14, 14, 14, 14, 3, 3, 4, 9, 14, 14, 14, 14, - 3, 4, 8, 14, 14, 14, 14, 14, 7, 9, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 } -}; -#endif - #endif /* AVCODEC_SP5X_H */ diff --git a/libavcodec/vc1data.c b/libavcodec/vc1data.c index 1cbf93e224..43edf746b7 100644 --- a/libavcodec/vc1data.c +++ b/libavcodec/vc1data.c @@ -187,75 +187,6 @@ const uint8_t ff_vc1_norm6_bits[64] = { 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9, 8, 10, 10, 13, 10, 13, 13, 9, 10, 13, 13, 9, 13, 9, 9, 6, }; -#if 0 -/* Normal-6 imode */ -const uint8_t ff_vc1_norm6_spec[64][5] = { -{ 0, 1, 1 }, -{ 1, 2, 4 }, -{ 2, 3, 4 }, -{ 3, 0, 8 }, -{ 4, 4, 4 }, -{ 5, 1, 8 }, -{ 6, 2, 8 }, -{ 7, 2, 5, 7, 5 }, -{ 8, 5, 4 }, -{ 9, 3, 8 }, -{10, 4, 8 }, -{11, 2, 5, 11, 5 }, -{12, 5, 8 }, -{13, 2, 5, 13, 5 }, -{14, 2, 5, 14, 5 }, -{15, 3, 5, 14, 8 }, -{16, 6, 4 }, -{17, 6, 8 }, -{18, 7, 8 }, -{19, 2, 5, 19, 5 }, -{20, 8, 8 }, -{21, 2, 5, 21, 5 }, -{22, 2, 5, 22, 5 }, -{23, 3, 5, 13, 8 }, -{24, 9, 8 }, -{25, 2, 5, 25, 5 }, -{26, 2, 5, 26, 5 }, -{27, 3, 5, 12, 8 }, -{28, 2, 5, 28, 5 }, -{29, 3, 5, 11, 8 }, -{30, 3, 5, 10, 8 }, -{31, 3, 5, 7, 4 }, -{32, 7, 4 }, -{33, 10, 8 }, -{34, 11, 8 }, -{35, 2, 5, 3, 5 }, -{36, 12, 8 }, -{37, 2, 5, 5, 5 }, -{38, 2, 5, 6, 5 }, -{39, 3, 5, 9, 8 }, -{40, 13, 8 }, -{41, 2, 5, 9, 5 }, -{42, 2, 5, 10, 5 }, -{43, 3, 5, 8, 8 }, -{44, 2, 5, 12, 5 }, -{45, 3, 5, 7, 8 }, -{46, 3, 5, 6, 8 }, -{47, 3, 5, 6, 4 }, -{48, 14, 8 }, -{49, 2, 5, 17, 5 }, -{50, 2, 5, 18, 5 }, -{51, 3, 5, 5, 8 }, -{52, 2, 5, 20, 5 }, -{53, 3, 5, 4, 8 }, -{54, 3, 5, 3, 8 }, -{55, 3, 5, 5, 4 }, -{56, 2, 5, 24, 5 }, -{57, 3, 5, 2, 8 }, -{58, 3, 5, 1, 8 }, -{59, 3, 5, 4, 4 }, -{60, 3, 5, 0, 8 }, -{61, 3, 5, 3, 4 }, -{62, 3, 5, 2, 4 }, -{63, 3, 5, 1, 1 }, -}; -#endif /* 4MV Block pattern VLC tables */ const uint8_t ff_vc1_4mv_block_pattern_codes[4][16] = { @@ -276,7 +207,7 @@ const uint8_t wmv3_dc_scale_table[32]={ }; /* P-Picture CBPCY VLC tables */ -#if 1 // Looks like original tables are not conforming to standard at all. Are they used for old WMV? +// Looks like original tables are not conforming to standard at all. Are they used for old WMV? const uint16_t ff_vc1_cbpcy_p_codes[4][64] = { { 0, 6, 15, 13, 13, 11, 3, 13, 5, 8, 49, 10, 12, 114, 102, 119, @@ -330,60 +261,6 @@ const uint8_t ff_vc1_cbpcy_p_bits[4][64] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8 } }; -#else -const uint16_t ff_vc1_cbpcy_p_codes[4][64] = { - { - 0, 1, 1, 4, 5, 1, 12, 4, 13, 14, 10, 11, 12, 7, 13, 2, - 15, 1, 96, 1, 49, 97, 2, 100, 3, 4, 5, 101, 102, 52, 53, 4, - 6, 7, 54, 103, 8, 9, 10, 110, 11, 12, 111, 56, 114, 58, 115, 5, - 13, 7, 8, 9, 10, 11, 12, 30, 13, 14, 15, 118, 119, 62, 63, 3 - }, - { - 0, 1, 2, 1, 3, 1, 16, 17, 5, 18, 12, 19, 13, 1, 28, 58, - 1, 1, 1, 2, 3, 2, 3, 236, 237, 4, 5, 238, 6, 7, 239, 8, - 9, 240, 10, 11, 121, 122, 12, 13, 14, 15, 241, 246, 16, 17, 124, 63, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 247, 125 - }, - { - 0, 1, 2, 3, 2, 3, 1, 4, 5, 24, 7, 13, 16, 17, 9, 5, - 25, 1, 1, 1, 2, 3, 96, 194, 1, 2, 98, 99, 195, 200, 101, 26, - 201, 102, 412, 413, 414, 54, 220, 111, 221, 3, 224, 113, 225, 114, 230, 29, - 231, 415, 240, 4, 241, 484, 5, 243, 3, 244, 245, 485, 492, 493, 247, 31 - }, - { - 0, 1, 1, 1, 2, 2, 3, 4, 3, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 28, 29, 30, 31 - } -}; -const uint8_t ff_vc1_cbpcy_p_bits[4][64] = { - { - 13, 6, 5, 6, 6, 7, 7, 5, 7, 7, 6, 6, 6, 5, 6, 3, - 7, 8, 8, 13, 7, 8, 13, 8, 13, 13, 13, 8, 8, 7, 7, 3, - 13, 13, 7, 8, 13, 13, 13, 8, 13, 13, 8, 7, 8, 7, 8, 3, - 13, 12, 12, 12, 12, 12, 12, 6, 12, 12, 12, 8, 8, 7, 7, 2 - }, - { - 14, 3, 3, 5, 3, 4, 5, 5, 3, 5, 4, 5, 4, 6, 5, 6, - 8, 14, 13, 8, 8, 13, 13, 8, 8, 13, 13, 8, 13, 13, 8, 13, - 13, 8, 13, 13, 7, 7, 13, 13, 13, 13, 8, 8, 13, 13, 7, 6, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 8, 7 - }, - { - 13, 5, 5, 5, 4, 4, 6, 4, 4, 6, 4, 5, 5, 5, 4, 3, - 6, 8, 10, 9, 8, 8, 7, 8, 13, 13, 7, 7, 8, 8, 7, 5, - 8, 7, 9, 9, 9, 6, 8, 7, 8, 13, 8, 7, 8, 7, 8, 5, - 8, 9, 8, 13, 8, 9, 13, 8, 12, 8, 8, 9, 9, 9, 8, 5 - }, - { - 9, 2, 3, 9, 2, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8 - } -}; -#endif /* MacroBlock Transform Type: 7.1.3.11, p89 * 8x8:B From 8b587fa29207a98c235660b3f129bac110620ec5 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 29 Apr 2011 19:49:45 +0200 Subject: [PATCH 555/780] alac: Remove unused dummy code. --- libavcodec/alac.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libavcodec/alac.c b/libavcodec/alac.c index f7e674927b..f8534f9a0f 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -284,20 +284,9 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, buffer_out[i+1] = val; } -#if 0 /* 4 and 8 are very common cases (the only ones i've seen). these * should be unrolled and optimized */ - if (predictor_coef_num == 4) { - /* FIXME: optimized general case */ - return; - } - - if (predictor_coef_table == 8) { - /* FIXME: optimized general case */ - return; - } -#endif /* general case */ if (predictor_coef_num > 0) { From 34e36f3a1c21af25c0a96f3e3f8ef82224ce8a6e Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 7 Jul 2011 01:31:02 +0200 Subject: [PATCH 556/780] libopenjpeg: Drop const qualifier to silence compiler warning. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libavcodec/libopenjpeg.c:100: warning: passing argument 2 of ‘opj_cio_open’ discards qualifiers from pointer target type /usr/include/openjpeg.h:770: note: expected ‘unsigned char *’ but argument is of type ‘const uint8_t *’ --- libavcodec/libopenjpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libopenjpeg.c b/libavcodec/libopenjpeg.c index 342dcd98ac..6e9e8fc68d 100644 --- a/libavcodec/libopenjpeg.c +++ b/libavcodec/libopenjpeg.c @@ -61,7 +61,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; + uint8_t *buf = avpkt->data; int buf_size = avpkt->size; LibOpenJPEGContext *ctx = avctx->priv_data; AVFrame *picture = &ctx->image, *output = data; From 0523dc57ffd0032b572392b1acc353db651eb23f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 7 Jul 2011 01:31:03 +0200 Subject: [PATCH 557/780] libspeexdec: Drop const qualifier to silence compiler warning. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libavcodec/libspeexdec.c:108: warning: passing argument 2 of ‘speex_bits_read_from’ discards qualifiers from pointer target type /usr/include/speex/speex_bits.h:80: note: expected ‘char *’ but argument is of type ‘const uint8_t *’ --- libavcodec/libspeexdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c index e6626dc88b..1cee71e152 100644 --- a/libavcodec/libspeexdec.c +++ b/libavcodec/libspeexdec.c @@ -96,7 +96,7 @@ static int libspeex_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; + uint8_t *buf = avpkt->data; int buf_size = avpkt->size; LibSpeexContext *s = avctx->priv_data; int16_t *output = data, *end; From 21aed0ed925e15c502135ed90dca68ba8a2e8471 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 16 Jul 2011 01:35:01 +0200 Subject: [PATCH 558/780] ppc: remove disabled code --- libavcodec/ppc/dsputil_altivec.c | 11 ----------- libavcodec/ppc/dsputil_ppc.c | 8 -------- libavcodec/ppc/fdct_altivec.c | 24 ------------------------ libavcodec/ppc/mpegvideo_altivec.c | 18 ------------------ 4 files changed, 61 deletions(-) diff --git a/libavcodec/ppc/dsputil_altivec.c b/libavcodec/ppc/dsputil_altivec.c index adce61b277..7bdd5705b9 100644 --- a/libavcodec/ppc/dsputil_altivec.c +++ b/libavcodec/ppc/dsputil_altivec.c @@ -627,16 +627,6 @@ void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, // it's faster than -funroll-loops, but using // -funroll-loops w/ this is bad - 74 cycles again. // all this is on a 7450, tuning for the 7450 -#if 0 - for (i = 0; i < h; i++) { - pixelsv1 = vec_ld(0, pixels); - pixelsv2 = vec_ld(16, pixels); - vec_st(vec_perm(pixelsv1, pixelsv2, perm), - 0, block); - pixels+=line_size; - block +=line_size; - } -#else for (i = 0; i < h; i += 4) { pixelsv1 = vec_ld( 0, pixels); pixelsv2 = vec_ld(15, pixels); @@ -657,7 +647,6 @@ void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, pixels+=line_size_4; block +=line_size_4; } -#endif } /* next one assumes that ((line_size % 16) == 0) */ diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c index 5f131f3196..3bf410c2ca 100644 --- a/libavcodec/ppc/dsputil_ppc.c +++ b/libavcodec/ppc/dsputil_ppc.c @@ -48,7 +48,6 @@ static void clear_blocks_dcbz32_ppc(DCTELEM *blocks) { register int misal = ((unsigned long)blocks & 0x00000010); register int i = 0; -#if 1 if (misal) { ((unsigned long*)blocks)[0] = 0L; ((unsigned long*)blocks)[1] = 0L; @@ -66,9 +65,6 @@ static void clear_blocks_dcbz32_ppc(DCTELEM *blocks) ((unsigned long*)blocks)[191] = 0L; i += 16; } -#else - memset(blocks, 0, sizeof(DCTELEM)*6*64); -#endif } /* same as above, when dcbzl clear a whole 128B cache line @@ -78,7 +74,6 @@ static void clear_blocks_dcbz128_ppc(DCTELEM *blocks) { register int misal = ((unsigned long)blocks & 0x0000007f); register int i = 0; -#if 1 if (misal) { // we could probably also optimize this case, // but there's not much point as the machines @@ -89,9 +84,6 @@ static void clear_blocks_dcbz128_ppc(DCTELEM *blocks) for ( ; i < sizeof(DCTELEM)*6*64 ; i += 128) { __asm__ volatile("dcbzl %0,%1" : : "b" (blocks), "r" (i) : "memory"); } -#else - memset(blocks, 0, sizeof(DCTELEM)*6*64); -#endif } #else static void clear_blocks_dcbz128_ppc(DCTELEM *blocks) diff --git a/libavcodec/ppc/fdct_altivec.c b/libavcodec/ppc/fdct_altivec.c index 8dbfe33f77..2644c96789 100644 --- a/libavcodec/ppc/fdct_altivec.c +++ b/libavcodec/ppc/fdct_altivec.c @@ -265,7 +265,6 @@ void fdct_altivec(int16_t *block) * conversion to vector float. The following code section takes advantage * of this. */ -#if 1 /* fdct rows {{{ */ x0 = ((vector float)vec_add(vs16(b00), vs16(b70))); x7 = ((vector float)vec_sub(vs16(b00), vs16(b70))); @@ -389,29 +388,6 @@ void fdct_altivec(int16_t *block) b31 = vec_add(b31, x2); b11 = vec_add(b11, x3); /* }}} */ -#else - /* convert to float {{{ */ -#define CTF(n) \ - vs32(b##n##1) = vec_unpackl(vs16(b##n##0)); \ - vs32(b##n##0) = vec_unpackh(vs16(b##n##0)); \ - b##n##1 = vec_ctf(vs32(b##n##1), 0); \ - b##n##0 = vec_ctf(vs32(b##n##0), 0); \ - - CTF(0); - CTF(1); - CTF(2); - CTF(3); - CTF(4); - CTF(5); - CTF(6); - CTF(7); - -#undef CTF - /* }}} */ - - FDCTROW(b00, b10, b20, b30, b40, b50, b60, b70); - FDCTROW(b01, b11, b21, b31, b41, b51, b61, b71); -#endif /* 8x8 matrix transpose (vector float[8][2]) {{{ */ diff --git a/libavcodec/ppc/mpegvideo_altivec.c b/libavcodec/ppc/mpegvideo_altivec.c index e02c094253..673b11d0c9 100644 --- a/libavcodec/ppc/mpegvideo_altivec.c +++ b/libavcodec/ppc/mpegvideo_altivec.c @@ -515,21 +515,6 @@ static void dct_unquantize_h263_altivec(MpegEncContext *s, qaddv = vec_splat((vec_s16)vec_lde(0, &qadd8), 0); nqaddv = vec_sub(vczero, qaddv); -#if 0 // block *is* 16 bytes-aligned, it seems. - // first make sure block[j] is 16 bytes-aligned - for(j = 0; (j <= nCoeffs) && ((((unsigned long)block) + (j << 1)) & 0x0000000F) ; j++) { - level = block[j]; - if (level) { - if (level < 0) { - level = level * qmul - qadd; - } else { - level = level * qmul + qadd; - } - block[j] = level; - } - } -#endif - // vectorize all the 16 bytes-aligned blocks // of 8 elements for(; (j + 7) <= nCoeffs ; j+=8) { @@ -599,9 +584,6 @@ void MPV_common_init_altivec(MpegEncContext *s) if ((s->avctx->dct_algo == FF_DCT_AUTO) || (s->avctx->dct_algo == FF_DCT_ALTIVEC)) { -#if 0 /* seems to cause trouble under some circumstances */ - s->dct_quantize = dct_quantize_altivec; -#endif s->dct_unquantize_h263_intra = dct_unquantize_h263_altivec; s->dct_unquantize_h263_inter = dct_unquantize_h263_altivec; } From b8783b98c5f924f2f2637bc80289b7c66a5a2ecb Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 6 Jul 2011 23:53:32 +0200 Subject: [PATCH 559/780] flashsv: split flashsv_decode_block() off from flashsv_decode_frame(). --- libavcodec/flashsv.c | 77 +++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index e1033a84cc..51831eb801 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -70,6 +70,45 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx) } +static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt, + GetBitContext *gb, int block_size, + int width, int height, int x_pos, int y_pos) +{ + struct FlashSVContext *s = avctx->priv_data; + uint8_t *line = s->tmpblock; + int k; + int ret = inflateReset(&s->zstream); + if (ret != Z_OK) { + //return -1; + } + s->zstream.next_in = avpkt->data + get_bits_count(gb) / 8; + s->zstream.avail_in = block_size; + s->zstream.next_out = s->tmpblock; + s->zstream.avail_out = s->block_size * 3; + ret = inflate(&s->zstream, Z_FINISH); + if (ret == Z_DATA_ERROR) { + av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n"); + inflateSync(&s->zstream); + ret = inflate(&s->zstream, Z_FINISH); + } + + if (ret != Z_OK && ret != Z_STREAM_END) { + //return -1; + } + /* Flash Screen Video stores the image upside down, so copy + * lines to destination in reverse order. */ + for (k = 1; k <= height; k++) { + memcpy(s->frame.data[0] + x_pos * 3 + + (s->image_height - y_pos - k) * s->frame.linesize[0], + line, width * 3); + /* advance source pointer to next line */ + line += width * 3; + } + skip_bits_long(gb, 8 * block_size); /* skip the consumed bits */ + return 0; +} + + static int flashsv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { @@ -158,41 +197,11 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* skip unchanged blocks, which have size 0 */ if (size) { - /* decompress block */ - uint8_t *line = s->tmpblock; - int k; - int ret = inflateReset(&s->zstream); - if (ret != Z_OK) { + if (flashsv_decode_block(avctx, avpkt, &gb, size, + cur_blk_width, cur_blk_height, + x_pos, y_pos)) av_log(avctx, AV_LOG_ERROR, - "error in decompression (reset) of block %dx%d\n", i, j); - /* return -1; */ - } - s->zstream.next_in = avpkt->data + get_bits_count(&gb) / 8; - s->zstream.avail_in = size; - s->zstream.next_out = s->tmpblock; - s->zstream.avail_out = s->block_size * 3; - ret = inflate(&s->zstream, Z_FINISH); - if (ret == Z_DATA_ERROR) { - av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n"); - inflateSync(&s->zstream); - ret = inflate(&s->zstream, Z_FINISH); - } - - if (ret != Z_OK && ret != Z_STREAM_END) { - av_log(avctx, AV_LOG_ERROR, - "error in decompression of block %dx%d: %d\n", i, j, ret); - /* return -1; */ - } - /* Flash Screen Video stores the image upside down, so copy - * lines to destination in reverse order. */ - for (k = 1; k <= cur_blk_height; k++) { - memcpy(s->frame.data[0] + x_pos * 3 + - (s->image_height - y_pos - k) * s->frame.linesize[0], - line, cur_blk_width * 3); - /* advance source pointer to next line */ - line += cur_blk_width * 3; - } - skip_bits_long(&gb, 8 * size); /* skip the consumed bits */ + "error in decompression of block %dx%d\n", i, j); } } } From 8b973d4937f833d1c7a226cfb2c2bc404e8f23a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jernej=20Fija=C4=8Dko?= Date: Mon, 11 Jul 2011 10:11:04 +0200 Subject: [PATCH 560/780] Patch for memory leaks in DVB subtitles decoder Signed-off-by: Joakim Plate --- libavcodec/dvbsubdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 5b09eb14d6..c5e7b1735b 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -1463,6 +1463,7 @@ static int dvbsub_decode(AVCodecContext *avctx, break; case DVBSUB_DISPLAYDEFINITION_SEGMENT: dvbsub_parse_display_definition_segment(avctx, p, segment_length); + break; case DVBSUB_DISPLAY_SEGMENT: *data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub); break; From 900321b08c95bd42e6db53864bfffbe48d6019da Mon Sep 17 00:00:00 2001 From: elupus Date: Fri, 22 Apr 2011 15:42:51 +0200 Subject: [PATCH 561/780] Don't mark generated dummy frame output from mpeg1/2 decoder as keyframe. We use this flag to tell when to assume decoded data is free from artifacts after a seek. The mpeg1/2 decoder will generate a dummy frame if decoding is started on a non keyframe. This will sadly be output from decoder to player and displayed as a gray screen. --- libavcodec/mpegvideo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index d3540c961a..3749fd9bd3 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1114,6 +1114,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) /* Allocate a dummy frame */ i= ff_find_unused_picture(s, 0); s->last_picture_ptr= &s->picture[i]; + s->last_picture_ptr->key_frame = 0; if(ff_alloc_picture(s, s->last_picture_ptr, 0) < 0) return -1; ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 0); @@ -1123,6 +1124,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) /* Allocate a dummy frame */ i= ff_find_unused_picture(s, 0); s->next_picture_ptr= &s->picture[i]; + s->next_picture_ptr->key_frame = 0; if(ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) return -1; ff_thread_report_progress((AVFrame*)s->next_picture_ptr, INT_MAX, 0); From 289c60001fb0a9a1d7a97c876d8a42b84c6874ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Sat, 16 Jul 2011 11:41:08 -0400 Subject: [PATCH 562/780] Do not decode RV30 files if the extradata is too small Signed-off-by: Diego Biurrun --- libavcodec/rv30.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 5d7109f961..e047c82fe0 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -256,6 +256,7 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx) if(avctx->extradata_size - 8 < (r->rpr - 1) * 2){ av_log(avctx, AV_LOG_ERROR, "Insufficient extradata - need at least %d bytes, got %d\n", 6 + r->rpr * 2, avctx->extradata_size); + return EINVAL; } r->parse_slice_header = rv30_parse_slice_header; r->decode_intra_types = rv30_decode_intra_types; From 7bda0c9a82eb3c9a58e0c9f170ac47fe7289f6f7 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Jul 2011 18:49:39 +0200 Subject: [PATCH 563/780] mpegvideo: fix compilation after 900321b08c95bd42e6db53864bfffbe48d6019da Replace: s->last_picture_ptr->f.key_frame = 0; with: s->last_picture_ptr->key_frame = 0; This is required since mpegvideo.h:Picture now contains an embedded AVFrame f, rather than a literal copy of the AVFrame fields. --- libavcodec/mpegvideo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 3749fd9bd3..f44824117d 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1114,7 +1114,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) /* Allocate a dummy frame */ i= ff_find_unused_picture(s, 0); s->last_picture_ptr= &s->picture[i]; - s->last_picture_ptr->key_frame = 0; + s->last_picture_ptr->f.key_frame = 0; if(ff_alloc_picture(s, s->last_picture_ptr, 0) < 0) return -1; ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 0); @@ -1124,7 +1124,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) /* Allocate a dummy frame */ i= ff_find_unused_picture(s, 0); s->next_picture_ptr= &s->picture[i]; - s->next_picture_ptr->key_frame = 0; + s->next_picture_ptr->f.key_frame = 0; if(ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) return -1; ff_thread_report_progress((AVFrame*)s->next_picture_ptr, INT_MAX, 0); From 4d4c7f8ef0366e30c9a2a8e8107eda47a603a0b8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 26 Apr 2011 16:57:55 +0200 Subject: [PATCH 564/780] Remove commented-out call to non-existing function print_pow1(). --- libavcodec/mpegaudioenc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c index ef265c905d..35a52ad571 100644 --- a/libavcodec/mpegaudioenc.c +++ b/libavcodec/mpegaudioenc.c @@ -315,8 +315,6 @@ static void filter(MpegAudioContext *s, int ch, const short *samples, int incr) int tmp1[32]; int *out; - // print_pow1(samples, 1152); - offset = s->samples_offset[ch]; out = &s->sb_samples[ch][0][0][0]; for(j=0;j<36;j++) { @@ -360,8 +358,6 @@ static void filter(MpegAudioContext *s, int ch, const short *samples, int incr) } } s->samples_offset[ch] = offset; - - // print_pow(s->sb_samples, 1152); } static void compute_scale_factors(unsigned char scale_code[SBLIMIT], From 8342a82680966055af8cbc48e0ad129411df7c44 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 16 Jul 2011 19:15:01 +0200 Subject: [PATCH 565/780] arm: remove disabled function dct_unquantize_h263_inter_iwmmxt() --- libavcodec/arm/mpegvideo_iwmmxt.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/libavcodec/arm/mpegvideo_iwmmxt.c b/libavcodec/arm/mpegvideo_iwmmxt.c index 4d5edd8050..6edc4c2ea6 100644 --- a/libavcodec/arm/mpegvideo_iwmmxt.c +++ b/libavcodec/arm/mpegvideo_iwmmxt.c @@ -93,29 +93,9 @@ static void dct_unquantize_h263_intra_iwmmxt(MpegEncContext *s, block_orig[0] = level; } -#if 0 -static void dct_unquantize_h263_inter_iwmmxt(MpegEncContext *s, - DCTELEM *block, int n, int qscale) -{ - int nCoeffs; - - assert(s->block_last_index[n]>=0); - - if(s->ac_pred) - nCoeffs=63; - else - nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ]; - - ippiQuantInvInter_Compact_H263_16s_I(block, nCoeffs+1, qscale); -} -#endif - void MPV_common_init_iwmmxt(MpegEncContext *s) { if (!(mm_flags & AV_CPU_FLAG_IWMMXT)) return; s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_iwmmxt; -#if 0 - s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_iwmmxt; -#endif } From b57df29f95d1107a66315a6744c1c3e73293b2ee Mon Sep 17 00:00:00 2001 From: Mina Nagy Zaki Date: Tue, 28 Jun 2011 08:56:19 +0300 Subject: [PATCH 566/780] lavfi: add audio channel packing negotiation fields Signed-off-by: Stefano Sabatini --- doc/APIchanges | 8 ++++++++ libavfilter/avfilter.c | 3 +++ libavfilter/avfilter.h | 18 ++++++++++++++++-- libavfilter/avfiltergraph.c | 6 +++++- libavfilter/defaults.c | 8 ++++++++ libavfilter/formats.c | 11 +++++++++++ 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index e2b271892d..94a598798d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,14 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-07-16 - xxxxxx - lavfi 2.27.0 + Add audio packing negotiation fields and helper functions. + + In particular, add AVFilterPacking enum, planar, in_packings and + out_packings fields to AVFilterLink, and the functions: + avfilter_set_common_packing_formats() + avfilter_all_packing_formats() + 2011-07-10 - a67c061 - lavf 53.3.0 Add avformat_find_stream_info(), deprecate av_find_stream_info(). diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index a57677c0e4..7003cdda5c 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -221,6 +221,9 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, if (link->out_chlayouts) avfilter_formats_changeref(&link->out_chlayouts, &filt->outputs[filt_dstpad_idx]->out_chlayouts); + if (link->out_packing) + avfilter_formats_changeref(&link->out_packing, + &filt->outputs[filt_dstpad_idx]->out_packing); return 0; } diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index edcc726b87..d89ac26e9f 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -29,7 +29,7 @@ #include "libavutil/rational.h" #define LIBAVFILTER_VERSION_MAJOR 2 -#define LIBAVFILTER_VERSION_MINOR 26 +#define LIBAVFILTER_VERSION_MINOR 27 #define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ @@ -264,6 +264,11 @@ AVFilterFormats *avfilter_all_formats(enum AVMediaType type); */ AVFilterFormats *avfilter_all_channel_layouts(void); +/** + * Return a list of all audio packing formats. + */ +AVFilterFormats *avfilter_all_packing_formats(void); + /** * Return a format list which contains the intersection of the formats of * a and b. Also, all the references of a, all the references of b, and @@ -482,6 +487,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats); void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats); void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats); +void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats); /** Default handler for query_formats() */ int avfilter_default_query_formats(AVFilterContext *ctx); @@ -570,6 +576,11 @@ struct AVFilterContext { void *priv; ///< private data for use by the filter }; +enum AVFilterPacking { + AVFILTER_PACKED = 0, + AVFILTER_PLANAR, +}; + /** * A link between two filters. This contains pointers to the source and * destination filters between which this link exists, and the indexes of @@ -597,9 +608,10 @@ struct AVFilterLink { int w; ///< agreed upon image width int h; ///< agreed upon image height AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio - /* These two parameters apply only to audio */ + /* These parameters apply only to audio */ int64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h) int64_t sample_rate; ///< samples per second + int planar; ///< agreed upon packing mode of audio buffers. true if planar. int format; ///< agreed upon media format @@ -615,6 +627,8 @@ struct AVFilterLink { AVFilterFormats *in_chlayouts; AVFilterFormats *out_chlayouts; + AVFilterFormats *in_packing; + AVFilterFormats *out_packing; /** * The buffer reference currently being sent across the link by the source diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 04768617de..8756e42bd4 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -203,8 +203,12 @@ static void pick_format(AVFilterLink *link) link->channel_layout = link->in_chlayouts->formats[0]; avfilter_formats_unref(&link->in_chlayouts); avfilter_formats_unref(&link->out_chlayouts); - } + link->in_packing->format_count = 1; + link->planar = link->in_packing->formats[0] == AVFILTER_PLANAR; + avfilter_formats_unref(&link->in_packing); + avfilter_formats_unref(&link->out_packing); + } } static void pick_formats(AVFilterGraph *graph) diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c index b03816dd24..eef9fd1278 100644 --- a/libavfilter/defaults.c +++ b/libavfilter/defaults.c @@ -239,11 +239,19 @@ void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats * offsetof(AVFilterLink, out_chlayouts)); } +void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats) +{ + set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO, + offsetof(AVFilterLink, in_packing), + offsetof(AVFilterLink, out_packing)); +} + int avfilter_default_query_formats(AVFilterContext *ctx) { avfilter_set_common_pixel_formats(ctx, avfilter_all_formats(AVMEDIA_TYPE_VIDEO)); avfilter_set_common_sample_formats(ctx, avfilter_all_formats(AVMEDIA_TYPE_AUDIO)); avfilter_set_common_channel_layouts(ctx, avfilter_all_channel_layouts()); + avfilter_set_common_packing_formats(ctx, avfilter_all_packing_formats()); return 0; } diff --git a/libavfilter/formats.c b/libavfilter/formats.c index b6e30e7ab4..214718b779 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -173,6 +173,17 @@ AVFilterFormats *avfilter_all_channel_layouts(void) return avfilter_make_format64_list(chlayouts); } +AVFilterFormats *avfilter_all_packing_formats(void) +{ + static int packing[] = { + AVFILTER_PACKED, + AVFILTER_PLANAR, + -1, + }; + + return avfilter_make_format_list(packing); +} + void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) { *ref = f; From c31a5b23b4cd566724743685e5ea158b0c818647 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 16 Jul 2011 19:24:10 +0200 Subject: [PATCH 567/780] Revert "ffmpeg: get rid of a pointless limit on number of streams." This reverts commit c7dd3e7e43555b2922481a9242a306c5b138d69c Conflicts: ffmpeg.c --- ffmpeg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index 5548d41e78..85ead5b9d4 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3220,6 +3220,9 @@ static int opt_input_ts_scale(const char *opt, const char *arg) p++; scale= strtod(p, &p); + if(stream >= MAX_STREAMS) + ffmpeg_exit(1); + ts_scale = grow_array(ts_scale, sizeof(*ts_scale), &nb_ts_scale, stream + 1); ts_scale[stream] = scale; return 0; @@ -3849,7 +3852,7 @@ static int opt_streamid(const char *opt, const char *arg) ffmpeg_exit(1); } *p++ = '\0'; - idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, INT_MAX); + idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1); streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1); streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX); return 0; From 58d7efdb2983a338af8e222358814b5fd88a9aec Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 16 Jul 2011 15:37:05 +0100 Subject: [PATCH 568/780] Use LOCAL_ALIGNED in ff_check_alignment() Signed-off-by: Mans Rullgard --- libavcodec/dsputil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 4f17b435d1..8bb7dc1181 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -2844,7 +2844,7 @@ av_cold void dsputil_static_init(void) int ff_check_alignment(void){ static int did_fail=0; - DECLARE_ALIGNED(16, int, aligned); + LOCAL_ALIGNED_16(int, aligned); if((intptr_t)&aligned & 15){ if(!did_fail){ From bd39c076885e8c6d9e05d5573433416180ef4da8 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 16 Jul 2011 19:10:43 +0100 Subject: [PATCH 569/780] des: fix #if conditional around P_shuffle CONFIG_SMALL is always defined as 0 or 1. Signed-off-by: Mans Rullgard --- libavutil/des.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/des.c b/libavutil/des.c index db2227b6ec..d3f715e8fc 100644 --- a/libavutil/des.c +++ b/libavutil/des.c @@ -39,7 +39,7 @@ static const uint8_t IP_shuffle[] = { }; #undef T -#if defined(CONFIG_SMALL) || defined(GENTABLES) +#if CONFIG_SMALL || defined(GENTABLES) #define T(a, b, c, d) 32-a,32-b,32-c,32-d static const uint8_t P_shuffle[] = { T(16, 7, 20, 21), From 2f07cb4d3938575d8c3c2cff83d0e1be8b68c7a8 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 16 Jul 2011 19:23:07 +0100 Subject: [PATCH 570/780] dct-test: remove write-only variable Signed-off-by: Mans Rullgard --- libavcodec/dct-test.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index 689aef8fa9..dbf9639c1e 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -190,7 +190,6 @@ static void idct_mmx_init(void) DECLARE_ALIGNED(16, static DCTELEM, block)[64]; DECLARE_ALIGNED(8, static DCTELEM, block1)[64]; -DECLARE_ALIGNED(8, static DCTELEM, block_org)[64]; static inline void mmx_emms(void) { @@ -245,9 +244,6 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) break; } - for (i = 0; i < 64; i++) - block_org[i] = block1[i]; - if (dct->format == MMX_PERM) { for (i = 0; i < 64; i++) block[idct_mmx_perm[i]] = block1[i]; From 412b4367c5b93586b42ea95a90d7c2f9f3e4b710 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 16 Jul 2011 09:43:33 +0200 Subject: [PATCH 571/780] rmdec: remove useless ap parameter from rm_read_header_old() --- libavformat/rmdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index fbc4d0cee6..69c4ffe400 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -371,7 +371,7 @@ skip: return 0; } -static int rm_read_header_old(AVFormatContext *s, AVFormatParameters *ap) +static int rm_read_header_old(AVFormatContext *s) { RMDemuxContext *rm = s->priv_data; AVStream *st; @@ -399,7 +399,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) tag = avio_rl32(pb); if (tag == MKTAG('.', 'r', 'a', 0xfd)) { /* very old .ra format */ - return rm_read_header_old(s, ap); + return rm_read_header_old(s); } else if (tag != MKTAG('.', 'R', 'M', 'F')) { return AVERROR(EIO); } From 62709956677d648cbf340dccd4549fa62142cb7e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 16 Jul 2011 09:53:40 +0200 Subject: [PATCH 572/780] wav: remove a use of deprecated AV_METADATA_ macro --- libavformat/wav.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/wav.c b/libavformat/wav.c index 5b9f6e4480..1f12ad109a 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -363,7 +363,7 @@ static int wav_parse_bext_tag(AVFormatContext *s, int64_t size) coding_history[size] = 0; if ((ret = av_dict_set(&s->metadata, "coding_history", coding_history, - AV_METADATA_DONT_STRDUP_VAL)) < 0) + AV_DICT_DONT_STRDUP_VAL)) < 0) return ret; } From dfc2c4d900e48fa788ad9364ac408c01cfb62b94 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 16 Jul 2011 22:18:12 +0200 Subject: [PATCH 573/780] lavf: use designated initialisers for all (de)muxers. It's more readable and less prone to breakage. --- libavformat/4xm.c | 14 +- libavformat/a64.c | 6 +- libavformat/aacdec.c | 11 +- libavformat/ac3dec.c | 22 ++- libavformat/adtsenc.c | 18 +-- libavformat/aea.c | 14 +- libavformat/aiffdec.c | 15 +- libavformat/aiffenc.c | 20 +-- libavformat/amr.c | 30 ++-- libavformat/anm.c | 12 +- libavformat/apc.c | 11 +- libavformat/ape.c | 16 +-- libavformat/applehttp.c | 16 +-- libavformat/asfdec.c | 18 +-- libavformat/asfenc.c | 44 +++--- libavformat/au.c | 33 ++--- libavformat/avidec.c | 16 +-- libavformat/avienc.c | 20 +-- libavformat/avisynth.c | 19 ++- libavformat/avs.c | 14 +- libavformat/bethsoftvid.c | 12 +- libavformat/bfi.c | 12 +- libavformat/bink.c | 15 +- libavformat/c93.c | 12 +- libavformat/cafdec.c | 15 +- libavformat/cdg.c | 10 +- libavformat/crcenc.c | 19 ++- libavformat/daud.c | 12 +- libavformat/dfa.c | 11 +- libavformat/dsicin.c | 12 +- libavformat/dtsdec.c | 11 +- libavformat/dv.c | 16 +-- libavformat/dvenc.c | 19 ++- libavformat/dxa.c | 12 +- libavformat/eacdata.c | 12 +- libavformat/electronicarts.c | 12 +- libavformat/ffmdec.c | 16 +-- libavformat/ffmenc.c | 21 ++- libavformat/filmstripdec.c | 14 +- libavformat/filmstripenc.c | 19 ++- libavformat/flacdec.c | 11 +- libavformat/flacenc.c | 19 ++- libavformat/flic.c | 12 +- libavformat/flvdec.c | 12 +- libavformat/flvenc.c | 22 +-- libavformat/framecrcenc.c | 16 +-- libavformat/gif.c | 20 +-- libavformat/gxf.c | 17 ++- libavformat/gxfenc.c | 23 ++- libavformat/idcin.c | 12 +- libavformat/idroqdec.c | 12 +- libavformat/iff.c | 12 +- libavformat/ingenientdec.c | 11 +- libavformat/ipmovie.c | 12 +- libavformat/iss.c | 12 +- libavformat/iv8.c | 11 +- libavformat/ivfdec.c | 11 +- libavformat/libnut.c | 36 ++--- libavformat/lmlm4.c | 11 +- libavformat/matroskadec.c | 16 +-- libavformat/matroskaenc.c | 60 ++++---- libavformat/md5enc.c | 36 +++-- libavformat/mm.c | 12 +- libavformat/mmf.c | 35 +++-- libavformat/mov.c | 16 +-- libavformat/movenc.c | 116 ++++++++------- libavformat/mp3dec.c | 11 +- libavformat/mp3enc.c | 40 +++--- libavformat/mpc.c | 16 +-- libavformat/mpc8.c | 15 +- libavformat/mpeg.c | 17 ++- libavformat/mpegenc.c | 99 +++++++------ libavformat/mpegts.c | 35 +++-- libavformat/mpegtsenc.c | 20 +-- libavformat/mpjpeg.c | 19 ++- libavformat/msnwc_tcp.c | 11 +- libavformat/mtv.c | 12 +- libavformat/mvi.c | 11 +- libavformat/mxfdec.c | 16 +-- libavformat/mxfenc.c | 49 +++---- libavformat/ncdec.c | 11 +- libavformat/nsvdec.c | 16 +-- libavformat/nullenc.c | 14 +- libavformat/nutdec.c | 16 +-- libavformat/nutenc.c | 24 ++-- libavformat/nuv.c | 14 +- libavformat/oggenc.c | 20 +-- libavformat/oma.c | 14 +- libavformat/psxstr.c | 14 +- libavformat/pva.c | 12 +- libavformat/r3d.c | 16 +-- libavformat/rawdec.c | 51 +++---- libavformat/rawenc.c | 263 +++++++++++++++-------------------- libavformat/rawvideodec.c | 11 +- libavformat/rl2.c | 15 +- libavformat/rmdec.c | 28 ++-- libavformat/rmenc.c | 20 +-- libavformat/rpl.c | 12 +- libavformat/rtpenc.c | 18 ++- libavformat/rtsp.c | 28 ++-- libavformat/rtspdec.c | 16 +-- libavformat/rtspenc.c | 18 ++- libavformat/sapdec.c | 14 +- libavformat/sapenc.c | 18 ++- libavformat/segafilm.c | 14 +- libavformat/sierravmd.c | 14 +- libavformat/siff.c | 12 +- libavformat/smacker.c | 14 +- libavformat/sol.c | 14 +- libavformat/soxdec.c | 14 +- libavformat/soxenc.c | 19 ++- libavformat/spdifdec.c | 11 +- libavformat/spdifenc.c | 19 ++- libavformat/swfdec.c | 12 +- libavformat/swfenc.c | 39 +++--- libavformat/thp.c | 12 +- libavformat/tiertexseq.c | 14 +- libavformat/tmv.c | 15 +- libavformat/tta.c | 15 +- libavformat/vc1test.c | 11 +- libavformat/vc1testenc.c | 20 +-- libavformat/vocdec.c | 12 +- libavformat/vocenc.c | 20 +-- libavformat/vqf.c | 15 +- libavformat/wav.c | 50 ++++--- libavformat/wc3movie.c | 14 +- libavformat/westwood.c | 24 ++-- libavformat/wv.c | 15 +- libavformat/xa.c | 12 +- libavformat/xwma.c | 12 +- libavformat/yop.c | 16 +-- libavformat/yuv4mpeg.c | 30 ++-- 132 files changed, 1311 insertions(+), 1466 deletions(-) diff --git a/libavformat/4xm.c b/libavformat/4xm.c index 32699da439..6224134948 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -345,11 +345,11 @@ static int fourxm_read_close(AVFormatContext *s) } AVInputFormat ff_fourxm_demuxer = { - "4xm", - NULL_IF_CONFIG_SMALL("4X Technologies format"), - sizeof(FourxmDemuxContext), - fourxm_probe, - fourxm_read_header, - fourxm_read_packet, - fourxm_read_close, + .name = "4xm", + .long_name = NULL_IF_CONFIG_SMALL("4X Technologies format"), + .priv_data_size = sizeof(FourxmDemuxContext), + .read_probe = fourxm_probe, + .read_header = fourxm_read_header, + .read_packet = fourxm_read_packet, + .read_close = fourxm_read_close, }; diff --git a/libavformat/a64.c b/libavformat/a64.c index 3d313e5fba..4b4981e9a8 100644 --- a/libavformat/a64.c +++ b/libavformat/a64.c @@ -170,7 +170,7 @@ AVOutputFormat ff_a64_muxer = { .extensions = "a64, A64", .priv_data_size = sizeof (A64Context), .video_codec = CODEC_ID_A64_MULTI, - a64_write_header, - a64_write_packet, - a64_write_trailer + .write_header = a64_write_header, + .write_packet = a64_write_packet, + .write_trailer = a64_write_trailer }; diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index 6a184c77d7..0c96fa49c4 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -82,12 +82,11 @@ static int adts_aac_read_header(AVFormatContext *s, } AVInputFormat ff_aac_demuxer = { - "aac", - NULL_IF_CONFIG_SMALL("raw ADTS AAC"), - 0, - adts_aac_probe, - adts_aac_read_header, - ff_raw_read_partial_packet, + .name = "aac", + .long_name = NULL_IF_CONFIG_SMALL("raw ADTS AAC"), + .read_probe = adts_aac_probe, + .read_header = adts_aac_read_header, + .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "aac", .value = CODEC_ID_AAC, diff --git a/libavformat/ac3dec.c b/libavformat/ac3dec.c index 7ed01029dd..2cb068e57c 100644 --- a/libavformat/ac3dec.c +++ b/libavformat/ac3dec.c @@ -71,12 +71,11 @@ static int ac3_probe(AVProbeData *p) } AVInputFormat ff_ac3_demuxer = { - "ac3", - NULL_IF_CONFIG_SMALL("raw AC-3"), - 0, - ac3_probe, - ff_raw_audio_read_header, - ff_raw_read_partial_packet, + .name = "ac3", + .long_name = NULL_IF_CONFIG_SMALL("raw AC-3"), + .read_probe = ac3_probe, + .read_header = ff_raw_audio_read_header, + .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "ac3", .value = CODEC_ID_AC3, @@ -90,12 +89,11 @@ static int eac3_probe(AVProbeData *p) } AVInputFormat ff_eac3_demuxer = { - "eac3", - NULL_IF_CONFIG_SMALL("raw E-AC-3"), - 0, - eac3_probe, - ff_raw_audio_read_header, - ff_raw_read_partial_packet, + .name = "eac3", + .long_name = NULL_IF_CONFIG_SMALL("raw E-AC-3"), + .read_probe = eac3_probe, + .read_header = ff_raw_audio_read_header, + .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "eac3", .value = CODEC_ID_EAC3, diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c index 75649e24dc..7f61e948fb 100644 --- a/libavformat/adtsenc.c +++ b/libavformat/adtsenc.c @@ -142,13 +142,13 @@ static int adts_write_packet(AVFormatContext *s, AVPacket *pkt) } AVOutputFormat ff_adts_muxer = { - "adts", - NULL_IF_CONFIG_SMALL("ADTS AAC"), - "audio/aac", - "aac,adts", - sizeof(ADTSContext), - CODEC_ID_AAC, - CODEC_ID_NONE, - adts_write_header, - adts_write_packet, + .name = "adts", + .long_name = NULL_IF_CONFIG_SMALL("ADTS AAC"), + .mime_type = "audio/aac", + .extensions = "aac,adts", + .priv_data_size = sizeof(ADTSContext), + .audio_codec = CODEC_ID_AAC, + .video_codec = CODEC_ID_NONE, + .write_header = adts_write_header, + .write_packet = adts_write_packet, }; diff --git a/libavformat/aea.c b/libavformat/aea.c index c6dfbb1c83..e2d853b17a 100644 --- a/libavformat/aea.c +++ b/libavformat/aea.c @@ -95,14 +95,12 @@ static int aea_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_aea_demuxer = { - "aea", - NULL_IF_CONFIG_SMALL("MD STUDIO audio"), - 0, - aea_read_probe, - aea_read_header, - aea_read_packet, - 0, - pcm_read_seek, + .name = "aea", + .long_name = NULL_IF_CONFIG_SMALL("MD STUDIO audio"), + .read_probe = aea_read_probe, + .read_header = aea_read_header, + .read_packet = aea_read_packet, + .read_seek = pcm_read_seek, .flags= AVFMT_GENERIC_INDEX, .extensions = "aea", }; diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 0e815421a7..34e6d88ab9 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -313,13 +313,12 @@ static int aiff_read_packet(AVFormatContext *s, } AVInputFormat ff_aiff_demuxer = { - "aiff", - NULL_IF_CONFIG_SMALL("Audio IFF"), - sizeof(AIFFInputContext), - aiff_probe, - aiff_read_header, - aiff_read_packet, - NULL, - pcm_read_seek, + .name = "aiff", + .long_name = NULL_IF_CONFIG_SMALL("Audio IFF"), + .priv_data_size = sizeof(AIFFInputContext), + .read_probe = aiff_probe, + .read_header = aiff_read_header, + .read_packet = aiff_read_packet, + .read_seek = pcm_read_seek, .codec_tag= (const AVCodecTag* const []){ff_codec_aiff_tags, 0}, }; diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index 5a64688483..fbe1491e78 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -148,15 +148,15 @@ static int aiff_write_trailer(AVFormatContext *s) } AVOutputFormat ff_aiff_muxer = { - "aiff", - NULL_IF_CONFIG_SMALL("Audio IFF"), - "audio/aiff", - "aif,aiff,afc,aifc", - sizeof(AIFFOutputContext), - CODEC_ID_PCM_S16BE, - CODEC_ID_NONE, - aiff_write_header, - aiff_write_packet, - aiff_write_trailer, + .name = "aiff", + .long_name = NULL_IF_CONFIG_SMALL("Audio IFF"), + .mime_type = "audio/aiff", + .extensions = "aif,aiff,afc,aifc", + .priv_data_size = sizeof(AIFFOutputContext), + .audio_codec = CODEC_ID_PCM_S16BE, + .video_codec = CODEC_ID_NONE, + .write_header = aiff_write_header, + .write_packet = aiff_write_packet, + .write_trailer = aiff_write_trailer, .codec_tag= (const AVCodecTag* const []){ff_codec_aiff_tags, 0}, }; diff --git a/libavformat/amr.c b/libavformat/amr.c index 260bd6ada6..e9c74caf27 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -174,27 +174,25 @@ static int amr_read_packet(AVFormatContext *s, #if CONFIG_AMR_DEMUXER AVInputFormat ff_amr_demuxer = { - "amr", - NULL_IF_CONFIG_SMALL("3GPP AMR file format"), - 0, /*priv_data_size*/ - amr_probe, - amr_read_header, - amr_read_packet, - NULL, + .name = "amr", + .long_name = NULL_IF_CONFIG_SMALL("3GPP AMR file format"), + .priv_data_size = 0, /*priv_data_size*/ + .read_probe = amr_probe, + .read_header = amr_read_header, + .read_packet = amr_read_packet, .flags = AVFMT_GENERIC_INDEX, }; #endif #if CONFIG_AMR_MUXER AVOutputFormat ff_amr_muxer = { - "amr", - NULL_IF_CONFIG_SMALL("3GPP AMR file format"), - "audio/amr", - "amr", - 0, - CODEC_ID_AMR_NB, - CODEC_ID_NONE, - amr_write_header, - amr_write_packet, + .name = "amr", + .long_name = NULL_IF_CONFIG_SMALL("3GPP AMR file format"), + .mime_type = "audio/amr", + .extensions = "amr", + .audio_codec = CODEC_ID_AMR_NB, + .video_codec = CODEC_ID_NONE, + .write_header = amr_write_header, + .write_packet = amr_write_packet, }; #endif diff --git a/libavformat/anm.c b/libavformat/anm.c index 4d1b5f7620..f24caf16b2 100644 --- a/libavformat/anm.c +++ b/libavformat/anm.c @@ -226,10 +226,10 @@ repeat: } AVInputFormat ff_anm_demuxer = { - "anm", - NULL_IF_CONFIG_SMALL("Deluxe Paint Animation"), - sizeof(AnmDemuxContext), - probe, - read_header, - read_packet, + .name = "anm", + .long_name = NULL_IF_CONFIG_SMALL("Deluxe Paint Animation"), + .priv_data_size = sizeof(AnmDemuxContext), + .read_probe = probe, + .read_header = read_header, + .read_packet = read_packet, }; diff --git a/libavformat/apc.c b/libavformat/apc.c index 40c6f0c4ac..109851632e 100644 --- a/libavformat/apc.c +++ b/libavformat/apc.c @@ -81,10 +81,9 @@ static int apc_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_apc_demuxer = { - "apc", - NULL_IF_CONFIG_SMALL("CRYO APC format"), - 0, - apc_probe, - apc_read_header, - apc_read_packet, + .name = "apc", + .long_name = NULL_IF_CONFIG_SMALL("CRYO APC format"), + .read_probe = apc_probe, + .read_header = apc_read_header, + .read_packet = apc_read_packet, }; diff --git a/libavformat/ape.c b/libavformat/ape.c index 90b02619e0..6787416039 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -405,13 +405,13 @@ static int ape_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp } AVInputFormat ff_ape_demuxer = { - "ape", - NULL_IF_CONFIG_SMALL("Monkey's Audio"), - sizeof(APEContext), - ape_probe, - ape_read_header, - ape_read_packet, - ape_read_close, - ape_read_seek, + .name = "ape", + .long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"), + .priv_data_size = sizeof(APEContext), + .read_probe = ape_probe, + .read_header = ape_read_header, + .read_packet = ape_read_packet, + .read_close = ape_read_close, + .read_seek = ape_read_seek, .extensions = "ape,apl,mac" }; diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index 7e0c930271..906511ed06 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -668,12 +668,12 @@ static int applehttp_probe(AVProbeData *p) } AVInputFormat ff_applehttp_demuxer = { - "applehttp", - NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming format"), - sizeof(AppleHTTPContext), - applehttp_probe, - applehttp_read_header, - applehttp_read_packet, - applehttp_close, - applehttp_read_seek, + .name = "applehttp", + .long_name = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming format"), + .priv_data_size = sizeof(AppleHTTPContext), + .read_probe = applehttp_probe, + .read_header = applehttp_read_header, + .read_packet = applehttp_read_packet, + .read_close = applehttp_close, + .read_seek = applehttp_read_seek, }; diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index ac559a0edd..a35290b041 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -1289,14 +1289,14 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int } AVInputFormat ff_asf_demuxer = { - "asf", - NULL_IF_CONFIG_SMALL("ASF format"), - sizeof(ASFContext), - asf_probe, - asf_read_header, - asf_read_packet, - asf_read_close, - asf_read_seek, - asf_read_pts, + .name = "asf", + .long_name = NULL_IF_CONFIG_SMALL("ASF format"), + .priv_data_size = sizeof(ASFContext), + .read_probe = asf_probe, + .read_header = asf_read_header, + .read_packet = asf_read_packet, + .read_close = asf_read_close, + .read_seek = asf_read_seek, + .read_timestamp = asf_read_pts, .flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH, }; diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index f9b9b3c045..cbd9cb6a49 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -882,20 +882,20 @@ static int asf_write_trailer(AVFormatContext *s) #if CONFIG_ASF_MUXER AVOutputFormat ff_asf_muxer = { - "asf", - NULL_IF_CONFIG_SMALL("ASF format"), - "video/x-ms-asf", - "asf,wmv,wma", - sizeof(ASFContext), + .name = "asf", + .long_name = NULL_IF_CONFIG_SMALL("ASF format"), + .mime_type = "video/x-ms-asf", + .extensions = "asf,wmv,wma", + .priv_data_size = sizeof(ASFContext), #if CONFIG_LIBMP3LAME - CODEC_ID_MP3, + .audio_codec = CODEC_ID_MP3, #else - CODEC_ID_MP2, + .audio_codec = CODEC_ID_MP2, #endif - CODEC_ID_MSMPEG4V3, - asf_write_header, - asf_write_packet, - asf_write_trailer, + .video_codec = CODEC_ID_MSMPEG4V3, + .write_header = asf_write_header, + .write_packet = asf_write_packet, + .write_trailer = asf_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0}, }; @@ -903,20 +903,20 @@ AVOutputFormat ff_asf_muxer = { #if CONFIG_ASF_STREAM_MUXER AVOutputFormat ff_asf_stream_muxer = { - "asf_stream", - NULL_IF_CONFIG_SMALL("ASF format"), - "video/x-ms-asf", - "asf,wmv,wma", - sizeof(ASFContext), + .name = "asf_stream", + .long_name = NULL_IF_CONFIG_SMALL("ASF format"), + .mime_type = "video/x-ms-asf", + .extensions = "asf,wmv,wma", + .priv_data_size = sizeof(ASFContext), #if CONFIG_LIBMP3LAME - CODEC_ID_MP3, + .audio_codec = CODEC_ID_MP3, #else - CODEC_ID_MP2, + .audio_codec = CODEC_ID_MP2, #endif - CODEC_ID_MSMPEG4V3, - asf_write_stream_header, - asf_write_packet, - asf_write_trailer, + .video_codec = CODEC_ID_MSMPEG4V3, + .write_header = asf_write_stream_header, + .write_packet = asf_write_packet, + .write_trailer = asf_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0}, }; diff --git a/libavformat/au.c b/libavformat/au.c index 6cffe1c1ce..d8765e3e47 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -185,30 +185,27 @@ static int au_read_packet(AVFormatContext *s, #if CONFIG_AU_DEMUXER AVInputFormat ff_au_demuxer = { - "au", - NULL_IF_CONFIG_SMALL("SUN AU format"), - 0, - au_probe, - au_read_header, - au_read_packet, - NULL, - pcm_read_seek, + .name = "au", + .long_name = NULL_IF_CONFIG_SMALL("SUN AU format"), + .read_probe = au_probe, + .read_header = au_read_header, + .read_packet = au_read_packet, + .read_seek = pcm_read_seek, .codec_tag= (const AVCodecTag* const []){codec_au_tags, 0}, }; #endif #if CONFIG_AU_MUXER AVOutputFormat ff_au_muxer = { - "au", - NULL_IF_CONFIG_SMALL("SUN AU format"), - "audio/basic", - "au", - 0, - CODEC_ID_PCM_S16BE, - CODEC_ID_NONE, - au_write_header, - au_write_packet, - au_write_trailer, + .name = "au", + .long_name = NULL_IF_CONFIG_SMALL("SUN AU format"), + .mime_type = "audio/basic", + .extensions = "au", + .audio_codec = CODEC_ID_PCM_S16BE, + .video_codec = CODEC_ID_NONE, + .write_header = au_write_header, + .write_packet = au_write_packet, + .write_trailer = au_write_trailer, .codec_tag= (const AVCodecTag* const []){codec_au_tags, 0}, }; #endif //CONFIG_AU_MUXER diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 2ea156e9ec..0ea093c6d7 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -1389,12 +1389,12 @@ static int avi_probe(AVProbeData *p) } AVInputFormat ff_avi_demuxer = { - "avi", - NULL_IF_CONFIG_SMALL("AVI format"), - sizeof(AVIContext), - avi_probe, - avi_read_header, - avi_read_packet, - avi_read_close, - avi_read_seek, + .name = "avi", + .long_name = NULL_IF_CONFIG_SMALL("AVI format"), + .priv_data_size = sizeof(AVIContext), + .read_probe = avi_probe, + .read_header = avi_read_header, + .read_packet = avi_read_packet, + .read_close = avi_read_close, + .read_seek = avi_read_seek, }; diff --git a/libavformat/avienc.c b/libavformat/avienc.c index 343396cabe..1dbed8bc80 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -639,16 +639,16 @@ static int avi_write_trailer(AVFormatContext *s) } AVOutputFormat ff_avi_muxer = { - "avi", - NULL_IF_CONFIG_SMALL("AVI format"), - "video/x-msvideo", - "avi", - sizeof(AVIContext), - CODEC_ID_MP2, - CODEC_ID_MPEG4, - avi_write_header, - avi_write_packet, - avi_write_trailer, + .name = "avi", + .long_name = NULL_IF_CONFIG_SMALL("AVI format"), + .mime_type = "video/x-msvideo", + .extensions = "avi", + .priv_data_size = sizeof(AVIContext), + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_MPEG4, + .write_header = avi_write_header, + .write_packet = avi_write_packet, + .write_trailer = avi_write_trailer, .codec_tag= (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0}, .flags= AVFMT_VARIABLE_FPS, }; diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 5e6f6bf5b9..b615796116 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -208,15 +208,12 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t pts, } AVInputFormat ff_avisynth_demuxer = { - "avs", - NULL_IF_CONFIG_SMALL("AVISynth"), - sizeof(AVISynthContext), - NULL, - avisynth_read_header, - avisynth_read_packet, - avisynth_read_close, - avisynth_read_seek, - NULL, - 0, - "avs", + .name = "avs", + .long_name = NULL_IF_CONFIG_SMALL("AVISynth"), + .priv_data_size = sizeof(AVISynthContext), + .read_header = avisynth_read_header, + .read_packet = avisynth_read_packet, + .read_close = avisynth_read_close, + .read_seek = avisynth_read_seek, + .extensions = "avs", }; diff --git a/libavformat/avs.c b/libavformat/avs.c index bd9b31d0f4..bf3d4f95bb 100644 --- a/libavformat/avs.c +++ b/libavformat/avs.c @@ -216,11 +216,11 @@ static int avs_read_close(AVFormatContext * s) } AVInputFormat ff_avs_demuxer = { - "avs", - NULL_IF_CONFIG_SMALL("AVS format"), - sizeof(AvsFormat), - avs_probe, - avs_read_header, - avs_read_packet, - avs_read_close, + .name = "avs", + .long_name = NULL_IF_CONFIG_SMALL("AVS format"), + .priv_data_size = sizeof(AvsFormat), + .read_probe = avs_probe, + .read_header = avs_read_header, + .read_packet = avs_read_packet, + .read_close = avs_read_close, }; diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c index 73564c95fe..05243cc510 100644 --- a/libavformat/bethsoftvid.c +++ b/libavformat/bethsoftvid.c @@ -223,10 +223,10 @@ static int vid_read_packet(AVFormatContext *s, } AVInputFormat ff_bethsoftvid_demuxer = { - "bethsoftvid", - NULL_IF_CONFIG_SMALL("Bethesda Softworks VID format"), - sizeof(BVID_DemuxContext), - vid_probe, - vid_read_header, - vid_read_packet, + .name = "bethsoftvid", + .long_name = NULL_IF_CONFIG_SMALL("Bethesda Softworks VID format"), + .priv_data_size = sizeof(BVID_DemuxContext), + .read_probe = vid_probe, + .read_header = vid_read_header, + .read_packet = vid_read_packet, }; diff --git a/libavformat/bfi.c b/libavformat/bfi.c index 72df8b2afb..7a02c23daf 100644 --- a/libavformat/bfi.c +++ b/libavformat/bfi.c @@ -159,10 +159,10 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt) } AVInputFormat ff_bfi_demuxer = { - "bfi", - NULL_IF_CONFIG_SMALL("Brute Force & Ignorance"), - sizeof(BFIContext), - bfi_probe, - bfi_read_header, - bfi_read_packet, + .name = "bfi", + .long_name = NULL_IF_CONFIG_SMALL("Brute Force & Ignorance"), + .priv_data_size = sizeof(BFIContext), + .read_probe = bfi_probe, + .read_header = bfi_read_header, + .read_packet = bfi_read_packet, }; diff --git a/libavformat/bink.c b/libavformat/bink.c index 067673819a..b576555deb 100644 --- a/libavformat/bink.c +++ b/libavformat/bink.c @@ -264,12 +264,11 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in } AVInputFormat ff_bink_demuxer = { - "bink", - NULL_IF_CONFIG_SMALL("Bink"), - sizeof(BinkDemuxContext), - probe, - read_header, - read_packet, - NULL, - read_seek, + .name = "bink", + .long_name = NULL_IF_CONFIG_SMALL("Bink"), + .priv_data_size = sizeof(BinkDemuxContext), + .read_probe = probe, + .read_header = read_header, + .read_packet = read_packet, + .read_seek = read_seek, }; diff --git a/libavformat/c93.c b/libavformat/c93.c index 097565a335..6cf448f6b5 100644 --- a/libavformat/c93.c +++ b/libavformat/c93.c @@ -193,10 +193,10 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_c93_demuxer = { - "c93", - NULL_IF_CONFIG_SMALL("Interplay C93"), - sizeof(C93DemuxContext), - probe, - read_header, - read_packet, + .name = "c93", + .long_name = NULL_IF_CONFIG_SMALL("Interplay C93"), + .priv_data_size = sizeof(C93DemuxContext), + .read_probe = probe, + .read_header = read_header, + .read_packet = read_packet, }; diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 68686cab97..38cde3be50 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -384,13 +384,12 @@ static int read_seek(AVFormatContext *s, int stream_index, } AVInputFormat ff_caf_demuxer = { - "caf", - NULL_IF_CONFIG_SMALL("Apple Core Audio Format"), - sizeof(CaffContext), - probe, - read_header, - read_packet, - NULL, - read_seek, + .name = "caf", + .long_name = NULL_IF_CONFIG_SMALL("Apple Core Audio Format"), + .priv_data_size = sizeof(CaffContext), + .read_probe = probe, + .read_header = read_header, + .read_packet = read_packet, + .read_seek = read_seek, .codec_tag = (const AVCodecTag*[]){ff_codec_caf_tags, 0}, }; diff --git a/libavformat/cdg.c b/libavformat/cdg.c index b47a20e06a..150496762b 100644 --- a/libavformat/cdg.c +++ b/libavformat/cdg.c @@ -56,11 +56,9 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_cdg_demuxer = { - "cdg", - NULL_IF_CONFIG_SMALL("CD Graphics Format"), - 0, - NULL, - read_header, - read_packet, + .name = "cdg", + .long_name = NULL_IF_CONFIG_SMALL("CD Graphics Format"), + .read_header = read_header, + .read_packet = read_packet, .extensions = "cdg" }; diff --git a/libavformat/crcenc.c b/libavformat/crcenc.c index 55c99d9d88..ae688e4f07 100644 --- a/libavformat/crcenc.c +++ b/libavformat/crcenc.c @@ -55,14 +55,13 @@ static int crc_write_trailer(struct AVFormatContext *s) } AVOutputFormat ff_crc_muxer = { - "crc", - NULL_IF_CONFIG_SMALL("CRC testing format"), - NULL, - "", - sizeof(CRCState), - CODEC_ID_PCM_S16LE, - CODEC_ID_RAWVIDEO, - crc_write_header, - crc_write_packet, - crc_write_trailer, + .name = "crc", + .long_name = NULL_IF_CONFIG_SMALL("CRC testing format"), + .extensions = "", + .priv_data_size = sizeof(CRCState), + .audio_codec = CODEC_ID_PCM_S16LE, + .video_codec = CODEC_ID_RAWVIDEO, + .write_header = crc_write_header, + .write_packet = crc_write_packet, + .write_trailer = crc_write_trailer, }; diff --git a/libavformat/daud.c b/libavformat/daud.c index 1b3cfcf2d9..9421d18a3b 100644 --- a/libavformat/daud.c +++ b/libavformat/daud.c @@ -71,14 +71,10 @@ static int daud_write_packet(struct AVFormatContext *s, AVPacket *pkt) #if CONFIG_DAUD_DEMUXER AVInputFormat ff_daud_demuxer = { - "daud", - NULL_IF_CONFIG_SMALL("D-Cinema audio format"), - 0, - NULL, - daud_header, - daud_packet, - NULL, - NULL, + .name = "daud", + .long_name = NULL_IF_CONFIG_SMALL("D-Cinema audio format"), + .read_header = daud_header, + .read_packet = daud_packet, .extensions = "302", }; #endif diff --git a/libavformat/dfa.c b/libavformat/dfa.c index 810853568d..cd925e05fc 100644 --- a/libavformat/dfa.c +++ b/libavformat/dfa.c @@ -109,11 +109,10 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_dfa_demuxer = { - "dfa", - NULL_IF_CONFIG_SMALL("Chronomaster DFA"), - 0, - dfa_probe, - dfa_read_header, - dfa_read_packet, + .name = "dfa", + .long_name = NULL_IF_CONFIG_SMALL("Chronomaster DFA"), + .read_probe = dfa_probe, + .read_header = dfa_read_header, + .read_packet = dfa_read_packet, .flags = AVFMT_GENERIC_INDEX, }; diff --git a/libavformat/dsicin.c b/libavformat/dsicin.c index d02de46e0f..a82ac4cb54 100644 --- a/libavformat/dsicin.c +++ b/libavformat/dsicin.c @@ -217,10 +217,10 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_dsicin_demuxer = { - "dsicin", - NULL_IF_CONFIG_SMALL("Delphine Software International CIN format"), - sizeof(CinDemuxContext), - cin_probe, - cin_read_header, - cin_read_packet, + .name = "dsicin", + .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN format"), + .priv_data_size = sizeof(CinDemuxContext), + .read_probe = cin_probe, + .read_header = cin_read_header, + .read_packet = cin_read_packet, }; diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c index 943f6a5d5a..d61855d360 100644 --- a/libavformat/dtsdec.c +++ b/libavformat/dtsdec.c @@ -66,12 +66,11 @@ static int dts_probe(AVProbeData *p) } AVInputFormat ff_dts_demuxer = { - "dts", - NULL_IF_CONFIG_SMALL("raw DTS"), - 0, - dts_probe, - ff_raw_audio_read_header, - ff_raw_read_partial_packet, + .name = "dts", + .long_name = NULL_IF_CONFIG_SMALL("raw DTS"), + .read_probe = dts_probe, + .read_header = ff_raw_audio_read_header, + .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "dts", .value = CODEC_ID_DTS, diff --git a/libavformat/dv.c b/libavformat/dv.c index f38b954605..384e4dc3da 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -520,14 +520,14 @@ static int dv_probe(AVProbeData *p) #if CONFIG_DV_DEMUXER AVInputFormat ff_dv_demuxer = { - "dv", - NULL_IF_CONFIG_SMALL("DV video format"), - sizeof(RawDVContext), - dv_probe, - dv_read_header, - dv_read_packet, - dv_read_close, - dv_read_seek, + .name = "dv", + .long_name = NULL_IF_CONFIG_SMALL("DV video format"), + .priv_data_size = sizeof(RawDVContext), + .read_probe = dv_probe, + .read_header = dv_read_header, + .read_packet = dv_read_packet, + .read_close = dv_read_close, + .read_seek = dv_read_seek, .extensions = "dv,dif", }; #endif diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 5aab6837c5..15b659bc8d 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -408,14 +408,13 @@ static int dv_write_trailer(struct AVFormatContext *s) } AVOutputFormat ff_dv_muxer = { - "dv", - NULL_IF_CONFIG_SMALL("DV video format"), - NULL, - "dv", - sizeof(DVMuxContext), - CODEC_ID_PCM_S16LE, - CODEC_ID_DVVIDEO, - dv_write_header, - dv_write_packet, - dv_write_trailer, + .name = "dv", + .long_name = NULL_IF_CONFIG_SMALL("DV video format"), + .extensions = "dv", + .priv_data_size = sizeof(DVMuxContext), + .audio_codec = CODEC_ID_PCM_S16LE, + .video_codec = CODEC_ID_DVVIDEO, + .write_header = dv_write_header, + .write_packet = dv_write_packet, + .write_trailer = dv_write_trailer, }; diff --git a/libavformat/dxa.c b/libavformat/dxa.c index 1e1d50581c..375b039df4 100644 --- a/libavformat/dxa.c +++ b/libavformat/dxa.c @@ -213,10 +213,10 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_dxa_demuxer = { - "dxa", - NULL_IF_CONFIG_SMALL("DXA"), - sizeof(DXAContext), - dxa_probe, - dxa_read_header, - dxa_read_packet, + .name = "dxa", + .long_name = NULL_IF_CONFIG_SMALL("DXA"), + .priv_data_size = sizeof(DXAContext), + .read_probe = dxa_probe, + .read_header = dxa_read_header, + .read_packet = dxa_read_packet, }; diff --git a/libavformat/eacdata.c b/libavformat/eacdata.c index 5c89559ed1..56f4e271dd 100644 --- a/libavformat/eacdata.c +++ b/libavformat/eacdata.c @@ -91,11 +91,11 @@ static int cdata_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_ea_cdata_demuxer = { - "ea_cdata", - NULL_IF_CONFIG_SMALL("Electronic Arts cdata"), - sizeof(CdataDemuxContext), - cdata_probe, - cdata_read_header, - cdata_read_packet, + .name = "ea_cdata", + .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts cdata"), + .priv_data_size = sizeof(CdataDemuxContext), + .read_probe = cdata_probe, + .read_header = cdata_read_header, + .read_packet = cdata_read_packet, .extensions = "cdata", }; diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c index 06689ddfb7..b6d6a84144 100644 --- a/libavformat/electronicarts.c +++ b/libavformat/electronicarts.c @@ -569,10 +569,10 @@ get_video_packet: } AVInputFormat ff_ea_demuxer = { - "ea", - NULL_IF_CONFIG_SMALL("Electronic Arts Multimedia Format"), - sizeof(EaDemuxContext), - ea_probe, - ea_read_header, - ea_read_packet, + .name = "ea", + .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts Multimedia Format"), + .priv_data_size = sizeof(EaDemuxContext), + .read_probe = ea_probe, + .read_header = ea_read_header, + .read_packet = ea_read_packet, }; diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index ed932703a2..9168ac57e8 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -509,12 +509,12 @@ static int ffm_probe(AVProbeData *p) } AVInputFormat ff_ffm_demuxer = { - "ffm", - NULL_IF_CONFIG_SMALL("FFM (FFserver live feed) format"), - sizeof(FFMContext), - ffm_probe, - ffm_read_header, - ffm_read_packet, - ffm_close, - ffm_seek, + .name = "ffm", + .long_name = NULL_IF_CONFIG_SMALL("FFM (FFserver live feed) format"), + .priv_data_size = sizeof(FFMContext), + .read_probe = ffm_probe, + .read_header = ffm_read_header, + .read_packet = ffm_read_packet, + .read_close = ffm_close, + .read_seek = ffm_seek, }; diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c index a31ac8e1d0..87a477fcbb 100644 --- a/libavformat/ffmenc.c +++ b/libavformat/ffmenc.c @@ -241,15 +241,14 @@ static int ffm_write_trailer(AVFormatContext *s) } AVOutputFormat ff_ffm_muxer = { - "ffm", - NULL_IF_CONFIG_SMALL("FFM (FFserver live feed) format"), - "", - "ffm", - sizeof(FFMContext), - /* not really used */ - CODEC_ID_MP2, - CODEC_ID_MPEG1VIDEO, - ffm_write_header, - ffm_write_packet, - ffm_write_trailer, + .name = "ffm", + .long_name = NULL_IF_CONFIG_SMALL("FFM (FFserver live feed) format"), + .mime_type = "", + .extensions = "ffm", + .priv_data_size = sizeof(FFMContext), + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_MPEG1VIDEO, + .write_header = ffm_write_header, + .write_packet = ffm_write_packet, + .write_trailer = ffm_write_trailer, }; diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c index 095bf9e809..e672ba0048 100644 --- a/libavformat/filmstripdec.c +++ b/libavformat/filmstripdec.c @@ -99,13 +99,11 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in } AVInputFormat ff_filmstrip_demuxer = { - "filmstrip", - NULL_IF_CONFIG_SMALL("Adobe Filmstrip"), - sizeof(FilmstripDemuxContext), - NULL, - read_header, - read_packet, - NULL, - read_seek, + .name = "filmstrip", + .long_name = NULL_IF_CONFIG_SMALL("Adobe Filmstrip"), + .priv_data_size = sizeof(FilmstripDemuxContext), + .read_header = read_header, + .read_packet = read_packet, + .read_seek = read_seek, .extensions = "flm", }; diff --git a/libavformat/filmstripenc.c b/libavformat/filmstripenc.c index 21f47550af..0e554081d5 100644 --- a/libavformat/filmstripenc.c +++ b/libavformat/filmstripenc.c @@ -72,14 +72,13 @@ static int write_trailer(AVFormatContext *s) } AVOutputFormat ff_filmstrip_muxer = { - "filmstrip", - NULL_IF_CONFIG_SMALL("Adobe Filmstrip"), - NULL, - "flm", - sizeof(FilmstripMuxContext), - CODEC_ID_NONE, - CODEC_ID_RAWVIDEO, - write_header, - write_packet, - write_trailer, + .name = "filmstrip", + .long_name = NULL_IF_CONFIG_SMALL("Adobe Filmstrip"), + .extensions = "flm", + .priv_data_size = sizeof(FilmstripMuxContext), + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_RAWVIDEO, + .write_header = write_header, + .write_packet = write_packet, + .write_trailer = write_trailer, }; diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index 02452b4c7c..1cae9f090e 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -124,12 +124,11 @@ static int flac_probe(AVProbeData *p) } AVInputFormat ff_flac_demuxer = { - "flac", - NULL_IF_CONFIG_SMALL("raw FLAC"), - 0, - flac_probe, - flac_read_header, - ff_raw_read_partial_packet, + .name = "flac", + .long_name = NULL_IF_CONFIG_SMALL("raw FLAC"), + .read_probe = flac_probe, + .read_header = flac_read_header, + .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "flac", .value = CODEC_ID_FLAC, diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index fb28a6ed4c..f14b30b0c5 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -118,15 +118,14 @@ static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt) } AVOutputFormat ff_flac_muxer = { - "flac", - NULL_IF_CONFIG_SMALL("raw FLAC"), - "audio/x-flac", - "flac", - 0, - CODEC_ID_FLAC, - CODEC_ID_NONE, - flac_write_header, - flac_write_packet, - flac_write_trailer, + .name = "flac", + .long_name = NULL_IF_CONFIG_SMALL("raw FLAC"), + .mime_type = "audio/x-flac", + .extensions = "flac", + .audio_codec = CODEC_ID_FLAC, + .video_codec = CODEC_ID_NONE, + .write_header = flac_write_header, + .write_packet = flac_write_packet, + .write_trailer = flac_write_trailer, .flags= AVFMT_NOTIMESTAMPS, }; diff --git a/libavformat/flic.c b/libavformat/flic.c index fcdf4c8040..3cea79e8a9 100644 --- a/libavformat/flic.c +++ b/libavformat/flic.c @@ -261,10 +261,10 @@ static int flic_read_packet(AVFormatContext *s, } AVInputFormat ff_flic_demuxer = { - "flic", - NULL_IF_CONFIG_SMALL("FLI/FLC/FLX animation format"), - sizeof(FlicDemuxContext), - flic_probe, - flic_read_header, - flic_read_packet, + .name = "flic", + .long_name = NULL_IF_CONFIG_SMALL("FLI/FLC/FLX animation format"), + .priv_data_size = sizeof(FlicDemuxContext), + .read_probe = flic_probe, + .read_header = flic_read_header, + .read_packet = flic_read_packet, }; diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 57eaa84696..cafbeb5c4b 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -572,12 +572,12 @@ static int flv_read_seek2(AVFormatContext *s, int stream_index, #endif AVInputFormat ff_flv_demuxer = { - "flv", - NULL_IF_CONFIG_SMALL("FLV format"), - sizeof(FLVContext), - flv_probe, - flv_read_header, - flv_read_packet, + .name = "flv", + .long_name = NULL_IF_CONFIG_SMALL("FLV format"), + .priv_data_size = sizeof(FLVContext), + .read_probe = flv_probe, + .read_header = flv_read_header, + .read_packet = flv_read_packet, .read_seek = flv_read_seek, #if 0 .read_seek2 = flv_read_seek2, diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index a3e7e25692..36f7e1f46c 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -441,20 +441,20 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) } AVOutputFormat ff_flv_muxer = { - "flv", - NULL_IF_CONFIG_SMALL("FLV format"), - "video/x-flv", - "flv", - sizeof(FLVContext), + .name = "flv", + .long_name = NULL_IF_CONFIG_SMALL("FLV format"), + .mime_type = "video/x-flv", + .extensions = "flv", + .priv_data_size = sizeof(FLVContext), #if CONFIG_LIBMP3LAME - CODEC_ID_MP3, + .audio_codec = CODEC_ID_MP3, #else // CONFIG_LIBMP3LAME - CODEC_ID_ADPCM_SWF, + .audio_codec = CODEC_ID_ADPCM_SWF, #endif // CONFIG_LIBMP3LAME - CODEC_ID_FLV1, - flv_write_header, - flv_write_packet, - flv_write_trailer, + .video_codec = CODEC_ID_FLV1, + .write_header = flv_write_header, + .write_packet = flv_write_packet, + .write_trailer = flv_write_trailer, .codec_tag= (const AVCodecTag* const []){flv_video_codec_ids, flv_audio_codec_ids, 0}, .flags= AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, }; diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c index 2bd3f547d3..f87562025c 100644 --- a/libavformat/framecrcenc.c +++ b/libavformat/framecrcenc.c @@ -34,14 +34,10 @@ static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) } AVOutputFormat ff_framecrc_muxer = { - "framecrc", - NULL_IF_CONFIG_SMALL("framecrc testing format"), - NULL, - "", - 0, - CODEC_ID_PCM_S16LE, - CODEC_ID_RAWVIDEO, - NULL, - framecrc_write_packet, - NULL, + .name = "framecrc", + .long_name = NULL_IF_CONFIG_SMALL("framecrc testing format"), + .extensions = "", + .audio_codec = CODEC_ID_PCM_S16LE, + .video_codec = CODEC_ID_RAWVIDEO, + .write_packet = framecrc_write_packet, }; diff --git a/libavformat/gif.c b/libavformat/gif.c index cf8785736b..f831787c60 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -363,15 +363,15 @@ static const AVClass gif_muxer_class = { }; AVOutputFormat ff_gif_muxer = { - "gif", - NULL_IF_CONFIG_SMALL("GIF Animation"), - "image/gif", - "gif", - sizeof(GIFContext), - CODEC_ID_NONE, - CODEC_ID_RAWVIDEO, - gif_write_header, - gif_write_packet, - gif_write_trailer, + .name = "gif", + .long_name = NULL_IF_CONFIG_SMALL("GIF Animation"), + .mime_type = "image/gif", + .extensions = "gif", + .priv_data_size = sizeof(GIFContext), + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_RAWVIDEO, + .write_header = gif_write_header, + .write_packet = gif_write_packet, + .write_trailer = gif_write_trailer, .priv_class = &gif_muxer_class, }; diff --git a/libavformat/gxf.c b/libavformat/gxf.c index 062a147a0c..8077d809b3 100644 --- a/libavformat/gxf.c +++ b/libavformat/gxf.c @@ -523,13 +523,12 @@ static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index, } AVInputFormat ff_gxf_demuxer = { - "gxf", - NULL_IF_CONFIG_SMALL("GXF format"), - sizeof(struct gxf_stream_info), - gxf_probe, - gxf_header, - gxf_packet, - NULL, - gxf_seek, - gxf_read_timestamp, + .name = "gxf", + .long_name = NULL_IF_CONFIG_SMALL("GXF format"), + .priv_data_size = sizeof(struct gxf_stream_info), + .read_probe = gxf_probe, + .read_header = gxf_header, + .read_packet = gxf_packet, + .read_seek = gxf_seek, + .read_timestamp = gxf_read_timestamp, }; diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 99bd71938f..11e1ea5798 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -943,17 +943,14 @@ static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pk } AVOutputFormat ff_gxf_muxer = { - "gxf", - NULL_IF_CONFIG_SMALL("GXF format"), - NULL, - "gxf", - sizeof(GXFContext), - CODEC_ID_PCM_S16LE, - CODEC_ID_MPEG2VIDEO, - gxf_write_header, - gxf_write_packet, - gxf_write_trailer, - 0, - NULL, - gxf_interleave_packet, + .name = "gxf", + .long_name = NULL_IF_CONFIG_SMALL("GXF format"), + .extensions = "gxf", + .priv_data_size = sizeof(GXFContext), + .audio_codec = CODEC_ID_PCM_S16LE, + .video_codec = CODEC_ID_MPEG2VIDEO, + .write_header = gxf_write_header, + .write_packet = gxf_write_packet, + .write_trailer = gxf_write_trailer, + .interleave_packet = gxf_interleave_packet, }; diff --git a/libavformat/idcin.c b/libavformat/idcin.c index 04ae687c6c..ca67e69101 100644 --- a/libavformat/idcin.c +++ b/libavformat/idcin.c @@ -292,10 +292,10 @@ static int idcin_read_packet(AVFormatContext *s, } AVInputFormat ff_idcin_demuxer = { - "idcin", - NULL_IF_CONFIG_SMALL("id Cinematic format"), - sizeof(IdcinDemuxContext), - idcin_probe, - idcin_read_header, - idcin_read_packet, + .name = "idcin", + .long_name = NULL_IF_CONFIG_SMALL("id Cinematic format"), + .priv_data_size = sizeof(IdcinDemuxContext), + .read_probe = idcin_probe, + .read_header = idcin_read_header, + .read_packet = idcin_read_packet, }; diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c index d9315966ea..1175c22e48 100644 --- a/libavformat/idroqdec.c +++ b/libavformat/idroqdec.c @@ -216,10 +216,10 @@ static int roq_read_packet(AVFormatContext *s, } AVInputFormat ff_roq_demuxer = { - "RoQ", - NULL_IF_CONFIG_SMALL("id RoQ format"), - sizeof(RoqDemuxContext), - roq_probe, - roq_read_header, - roq_read_packet, + .name = "RoQ", + .long_name = NULL_IF_CONFIG_SMALL("id RoQ format"), + .priv_data_size = sizeof(RoqDemuxContext), + .read_probe = roq_probe, + .read_header = roq_read_header, + .read_packet = roq_read_packet, }; diff --git a/libavformat/iff.c b/libavformat/iff.c index 2b84986aff..f388ca9e32 100644 --- a/libavformat/iff.c +++ b/libavformat/iff.c @@ -316,10 +316,10 @@ static int iff_read_packet(AVFormatContext *s, } AVInputFormat ff_iff_demuxer = { - "IFF", - NULL_IF_CONFIG_SMALL("IFF format"), - sizeof(IffDemuxContext), - iff_probe, - iff_read_header, - iff_read_packet, + .name = "IFF", + .long_name = NULL_IF_CONFIG_SMALL("IFF format"), + .priv_data_size = sizeof(IffDemuxContext), + .read_probe = iff_probe, + .read_header = iff_read_header, + .read_packet = iff_read_packet, }; diff --git a/libavformat/ingenientdec.c b/libavformat/ingenientdec.c index febeb2ec35..50a4357b79 100644 --- a/libavformat/ingenientdec.c +++ b/libavformat/ingenientdec.c @@ -59,12 +59,11 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_ingenient_demuxer = { - "ingenient", - NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"), - sizeof(FFRawVideoDemuxerContext), - NULL, - ff_raw_video_read_header, - ingenient_read_packet, + .name = "ingenient", + .long_name = NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"), + .priv_data_size = sizeof(FFRawVideoDemuxerContext), + .read_header = ff_raw_video_read_header, + .read_packet = ingenient_read_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "cgi", // FIXME .value = CODEC_ID_MJPEG, diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index e8ba0643f6..067ab15e66 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -616,10 +616,10 @@ static int ipmovie_read_packet(AVFormatContext *s, } AVInputFormat ff_ipmovie_demuxer = { - "ipmovie", - NULL_IF_CONFIG_SMALL("Interplay MVE format"), - sizeof(IPMVEContext), - ipmovie_probe, - ipmovie_read_header, - ipmovie_read_packet, + .name = "ipmovie", + .long_name = NULL_IF_CONFIG_SMALL("Interplay MVE format"), + .priv_data_size = sizeof(IPMVEContext), + .read_probe = ipmovie_probe, + .read_header = ipmovie_read_header, + .read_packet = ipmovie_read_packet, }; diff --git a/libavformat/iss.c b/libavformat/iss.c index 7989194126..c1dd478623 100644 --- a/libavformat/iss.c +++ b/libavformat/iss.c @@ -122,11 +122,11 @@ static int iss_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_iss_demuxer = { - "ISS", - NULL_IF_CONFIG_SMALL("Funcom ISS format"), - sizeof(IssDemuxContext), - iss_probe, - iss_read_header, - iss_read_packet, + .name = "ISS", + .long_name = NULL_IF_CONFIG_SMALL("Funcom ISS format"), + .priv_data_size = sizeof(IssDemuxContext), + .read_probe = iss_probe, + .read_header = iss_read_header, + .read_packet = iss_read_packet, }; diff --git a/libavformat/iv8.c b/libavformat/iv8.c index 22e60cf8f0..bca31dcdd5 100644 --- a/libavformat/iv8.c +++ b/libavformat/iv8.c @@ -85,12 +85,11 @@ retry: } AVInputFormat ff_iv8_demuxer = { - "iv8", - NULL_IF_CONFIG_SMALL("A format generated by IndigoVision 8000 video server"), - 0, - probe, - read_header, - read_packet, + .name = "iv8", + .long_name = NULL_IF_CONFIG_SMALL("A format generated by IndigoVision 8000 video server"), + .read_probe = probe, + .read_header = read_header, + .read_packet = read_packet, .flags= AVFMT_GENERIC_INDEX, .value = CODEC_ID_MPEG4, }; diff --git a/libavformat/ivfdec.c b/libavformat/ivfdec.c index 390173105a..9211881e53 100644 --- a/libavformat/ivfdec.c +++ b/libavformat/ivfdec.c @@ -80,12 +80,11 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_ivf_demuxer = { - "ivf", - NULL_IF_CONFIG_SMALL("On2 IVF"), - 0, - probe, - read_header, - read_packet, + .name = "ivf", + .long_name = NULL_IF_CONFIG_SMALL("On2 IVF"), + .read_probe = probe, + .read_header = read_header, + .read_packet = read_packet, .flags= AVFMT_GENERIC_INDEX, .codec_tag = (const AVCodecTag*[]){ff_codec_bmp_tags, 0}, }; diff --git a/libavformat/libnut.c b/libavformat/libnut.c index 76a621a2d7..a618c53903 100644 --- a/libavformat/libnut.c +++ b/libavformat/libnut.c @@ -151,16 +151,16 @@ static int nut_write_trailer(AVFormatContext * avf) { } AVOutputFormat ff_libnut_muxer = { - "libnut", - "nut format", - "video/x-nut", - "nut", - sizeof(NUTContext), - CODEC_ID_VORBIS, - CODEC_ID_MPEG4, - nut_write_header, - nut_write_packet, - nut_write_trailer, + .name = "libnut", + .long_name = "nut format", + .mime_type = "video/x-nut", + .extensions = "nut", + .priv_data_size = sizeof(NUTContext), + .audio_codec = CODEC_ID_VORBIS, + .video_codec = CODEC_ID_MPEG4, + .write_header = nut_write_header, + .write_packet = nut_write_packet, + .write_trailer = nut_write_trailer, .flags = AVFMT_GLOBALHEADER, }; #endif /* CONFIG_LIBNUT_MUXER */ @@ -298,13 +298,13 @@ static int nut_read_close(AVFormatContext *s) { } AVInputFormat ff_libnut_demuxer = { - "libnut", - NULL_IF_CONFIG_SMALL("NUT format"), - sizeof(NUTContext), - nut_probe, - nut_read_header, - nut_read_packet, - nut_read_close, - nut_read_seek, + .name = "libnut", + .long_name = NULL_IF_CONFIG_SMALL("NUT format"), + .priv_data_size = sizeof(NUTContext), + .read_probe = nut_probe, + .read_header = nut_read_header, + .read_packet = nut_read_packet, + .read_close = nut_read_close, + .read_seek = nut_read_seek, .extensions = "nut", }; diff --git a/libavformat/lmlm4.c b/libavformat/lmlm4.c index eafc1b60bd..0d905e4fed 100644 --- a/libavformat/lmlm4.c +++ b/libavformat/lmlm4.c @@ -118,10 +118,9 @@ static int lmlm4_read_packet(AVFormatContext *s, AVPacket *pkt) { } AVInputFormat ff_lmlm4_demuxer = { - "lmlm4", - NULL_IF_CONFIG_SMALL("lmlm4 raw format"), - 0, - lmlm4_probe, - lmlm4_read_header, - lmlm4_read_packet, + .name = "lmlm4", + .long_name = NULL_IF_CONFIG_SMALL("lmlm4 raw format"), + .read_probe = lmlm4_probe, + .read_header = lmlm4_read_header, + .read_packet = lmlm4_read_packet, }; diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 70bb765ab4..852760cc4d 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1999,12 +1999,12 @@ static int matroska_read_close(AVFormatContext *s) } AVInputFormat ff_matroska_demuxer = { - "matroska,webm", - NULL_IF_CONFIG_SMALL("Matroska/WebM file format"), - sizeof(MatroskaDemuxContext), - matroska_probe, - matroska_read_header, - matroska_read_packet, - matroska_read_close, - matroska_read_seek, + .name = "matroska,webm", + .long_name = NULL_IF_CONFIG_SMALL("Matroska/WebM file format"), + .priv_data_size = sizeof(MatroskaDemuxContext), + .read_probe = matroska_probe, + .read_header = matroska_read_header, + .read_packet = matroska_read_packet, + .read_close = matroska_read_close, + .read_seek = matroska_read_seek, }; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index d0e3c171eb..b08f546eb4 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1193,16 +1193,16 @@ static int mkv_write_trailer(AVFormatContext *s) #if CONFIG_MATROSKA_MUXER AVOutputFormat ff_matroska_muxer = { - "matroska", - NULL_IF_CONFIG_SMALL("Matroska file format"), - "video/x-matroska", - "mkv", - sizeof(MatroskaMuxContext), - CODEC_ID_MP2, - CODEC_ID_MPEG4, - mkv_write_header, - mkv_write_packet, - mkv_write_trailer, + .name = "matroska", + .long_name = NULL_IF_CONFIG_SMALL("Matroska file format"), + .mime_type = "video/x-matroska", + .extensions = "mkv", + .priv_data_size = sizeof(MatroskaMuxContext), + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_MPEG4, + .write_header = mkv_write_header, + .write_packet = mkv_write_packet, + .write_trailer = mkv_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, .codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0}, .subtitle_codec = CODEC_ID_SSA, @@ -1211,32 +1211,32 @@ AVOutputFormat ff_matroska_muxer = { #if CONFIG_WEBM_MUXER AVOutputFormat ff_webm_muxer = { - "webm", - NULL_IF_CONFIG_SMALL("WebM file format"), - "video/webm", - "webm", - sizeof(MatroskaMuxContext), - CODEC_ID_VORBIS, - CODEC_ID_VP8, - mkv_write_header, - mkv_write_packet, - mkv_write_trailer, + .name = "webm", + .long_name = NULL_IF_CONFIG_SMALL("WebM file format"), + .mime_type = "video/webm", + .extensions = "webm", + .priv_data_size = sizeof(MatroskaMuxContext), + .audio_codec = CODEC_ID_VORBIS, + .video_codec = CODEC_ID_VP8, + .write_header = mkv_write_header, + .write_packet = mkv_write_packet, + .write_trailer = mkv_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, }; #endif #if CONFIG_MATROSKA_AUDIO_MUXER AVOutputFormat ff_matroska_audio_muxer = { - "matroska", - NULL_IF_CONFIG_SMALL("Matroska file format"), - "audio/x-matroska", - "mka", - sizeof(MatroskaMuxContext), - CODEC_ID_MP2, - CODEC_ID_NONE, - mkv_write_header, - mkv_write_packet, - mkv_write_trailer, + .name = "matroska", + .long_name = NULL_IF_CONFIG_SMALL("Matroska file format"), + .mime_type = "audio/x-matroska", + .extensions = "mka", + .priv_data_size = sizeof(MatroskaMuxContext), + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_NONE, + .write_header = mkv_write_header, + .write_packet = mkv_write_packet, + .write_trailer = mkv_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0}, }; diff --git a/libavformat/md5enc.c b/libavformat/md5enc.c index 3b7d0ea8d8..dc8919a8c8 100644 --- a/libavformat/md5enc.c +++ b/libavformat/md5enc.c @@ -66,16 +66,15 @@ static int write_trailer(struct AVFormatContext *s) } AVOutputFormat ff_md5_muxer = { - "md5", - NULL_IF_CONFIG_SMALL("MD5 testing format"), - NULL, - "", - PRIVSIZE, - CODEC_ID_PCM_S16LE, - CODEC_ID_RAWVIDEO, - write_header, - write_packet, - write_trailer, + .name = "md5", + .long_name = NULL_IF_CONFIG_SMALL("MD5 testing format"), + .extensions = "", + .priv_data_size = PRIVSIZE, + .audio_codec = CODEC_ID_PCM_S16LE, + .video_codec = CODEC_ID_RAWVIDEO, + .write_header = write_header, + .write_packet = write_packet, + .write_trailer = write_trailer, }; #endif @@ -96,15 +95,12 @@ static int framemd5_write_packet(struct AVFormatContext *s, AVPacket *pkt) } AVOutputFormat ff_framemd5_muxer = { - "framemd5", - NULL_IF_CONFIG_SMALL("Per-frame MD5 testing format"), - NULL, - "", - PRIVSIZE, - CODEC_ID_PCM_S16LE, - CODEC_ID_RAWVIDEO, - NULL, - framemd5_write_packet, - NULL, + .name = "framemd5", + .long_name = NULL_IF_CONFIG_SMALL("Per-frame MD5 testing format"), + .extensions = "", + .priv_data_size = PRIVSIZE, + .audio_codec = CODEC_ID_PCM_S16LE, + .video_codec = CODEC_ID_RAWVIDEO, + .write_packet = framemd5_write_packet, }; #endif diff --git a/libavformat/mm.c b/libavformat/mm.c index dae659f3c6..20118a9de4 100644 --- a/libavformat/mm.c +++ b/libavformat/mm.c @@ -187,10 +187,10 @@ static int read_packet(AVFormatContext *s, } AVInputFormat ff_mm_demuxer = { - "mm", - NULL_IF_CONFIG_SMALL("American Laser Games MM format"), - sizeof(MmDemuxContext), - probe, - read_header, - read_packet, + .name = "mm", + .long_name = NULL_IF_CONFIG_SMALL("American Laser Games MM format"), + .priv_data_size = sizeof(MmDemuxContext), + .read_probe = probe, + .read_header = read_header, + .read_packet = read_packet, }; diff --git a/libavformat/mmf.c b/libavformat/mmf.c index 3848d5cf56..ffa6916d97 100644 --- a/libavformat/mmf.c +++ b/libavformat/mmf.c @@ -291,27 +291,26 @@ static int mmf_read_packet(AVFormatContext *s, #if CONFIG_MMF_DEMUXER AVInputFormat ff_mmf_demuxer = { - "mmf", - NULL_IF_CONFIG_SMALL("Yamaha SMAF"), - sizeof(MMFContext), - mmf_probe, - mmf_read_header, - mmf_read_packet, - NULL, - pcm_read_seek, + .name = "mmf", + .long_name = NULL_IF_CONFIG_SMALL("Yamaha SMAF"), + .priv_data_size = sizeof(MMFContext), + .read_probe = mmf_probe, + .read_header = mmf_read_header, + .read_packet = mmf_read_packet, + .read_seek = pcm_read_seek, }; #endif #if CONFIG_MMF_MUXER AVOutputFormat ff_mmf_muxer = { - "mmf", - NULL_IF_CONFIG_SMALL("Yamaha SMAF"), - "application/vnd.smaf", - "mmf", - sizeof(MMFContext), - CODEC_ID_ADPCM_YAMAHA, - CODEC_ID_NONE, - mmf_write_header, - mmf_write_packet, - mmf_write_trailer, + .name = "mmf", + .long_name = NULL_IF_CONFIG_SMALL("Yamaha SMAF"), + .mime_type = "application/vnd.smaf", + .extensions = "mmf", + .priv_data_size = sizeof(MMFContext), + .audio_codec = CODEC_ID_ADPCM_YAMAHA, + .video_codec = CODEC_ID_NONE, + .write_header = mmf_write_header, + .write_packet = mmf_write_packet, + .write_trailer = mmf_write_trailer, }; #endif diff --git a/libavformat/mov.c b/libavformat/mov.c index acde35d97e..0de2bfc325 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2611,12 +2611,12 @@ static int mov_read_close(AVFormatContext *s) } AVInputFormat ff_mov_demuxer = { - "mov,mp4,m4a,3gp,3g2,mj2", - NULL_IF_CONFIG_SMALL("QuickTime/MPEG-4/Motion JPEG 2000 format"), - sizeof(MOVContext), - mov_probe, - mov_read_header, - mov_read_packet, - mov_read_close, - mov_read_seek, + .name = "mov,mp4,m4a,3gp,3g2,mj2", + .long_name = NULL_IF_CONFIG_SMALL("QuickTime/MPEG-4/Motion JPEG 2000 format"), + .priv_data_size = sizeof(MOVContext), + .read_probe = mov_probe, + .read_header = mov_read_header, + .read_packet = mov_read_packet, + .read_close = mov_read_close, + .read_seek = mov_read_seek, }; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 12ebef5426..185d89f43a 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2338,16 +2338,15 @@ static int mov_write_trailer(AVFormatContext *s) #if CONFIG_MOV_MUXER AVOutputFormat ff_mov_muxer = { - "mov", - NULL_IF_CONFIG_SMALL("MOV format"), - NULL, - "mov", - sizeof(MOVMuxContext), - CODEC_ID_AAC, - CODEC_ID_MPEG4, - mov_write_header, - ff_mov_write_packet, - mov_write_trailer, + .name = "mov", + .long_name = NULL_IF_CONFIG_SMALL("MOV format"), + .extensions = "mov", + .priv_data_size = sizeof(MOVMuxContext), + .audio_codec = CODEC_ID_AAC, + .video_codec = CODEC_ID_MPEG4, + .write_header = mov_write_header, + .write_packet = ff_mov_write_packet, + .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){codec_movvideo_tags, codec_movaudio_tags, 0}, .priv_class = &mov_muxer_class, @@ -2355,16 +2354,15 @@ AVOutputFormat ff_mov_muxer = { #endif #if CONFIG_TGP_MUXER AVOutputFormat ff_tgp_muxer = { - "3gp", - NULL_IF_CONFIG_SMALL("3GP format"), - NULL, - "3gp", - sizeof(MOVMuxContext), - CODEC_ID_AMR_NB, - CODEC_ID_H263, - mov_write_header, - ff_mov_write_packet, - mov_write_trailer, + .name = "3gp", + .long_name = NULL_IF_CONFIG_SMALL("3GP format"), + .extensions = "3gp", + .priv_data_size = sizeof(MOVMuxContext), + .audio_codec = CODEC_ID_AMR_NB, + .video_codec = CODEC_ID_H263, + .write_header = mov_write_header, + .write_packet = ff_mov_write_packet, + .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0}, .priv_class = &mov_muxer_class, @@ -2372,16 +2370,16 @@ AVOutputFormat ff_tgp_muxer = { #endif #if CONFIG_MP4_MUXER AVOutputFormat ff_mp4_muxer = { - "mp4", - NULL_IF_CONFIG_SMALL("MP4 format"), - "application/mp4", - "mp4", - sizeof(MOVMuxContext), - CODEC_ID_AAC, - CODEC_ID_MPEG4, - mov_write_header, - ff_mov_write_packet, - mov_write_trailer, + .name = "mp4", + .long_name = NULL_IF_CONFIG_SMALL("MP4 format"), + .mime_type = "application/mp4", + .extensions = "mp4", + .priv_data_size = sizeof(MOVMuxContext), + .audio_codec = CODEC_ID_AAC, + .video_codec = CODEC_ID_MPEG4, + .write_header = mov_write_header, + .write_packet = ff_mov_write_packet, + .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0}, .priv_class = &mov_muxer_class, @@ -2389,16 +2387,15 @@ AVOutputFormat ff_mp4_muxer = { #endif #if CONFIG_PSP_MUXER AVOutputFormat ff_psp_muxer = { - "psp", - NULL_IF_CONFIG_SMALL("PSP MP4 format"), - NULL, - "mp4,psp", - sizeof(MOVMuxContext), - CODEC_ID_AAC, - CODEC_ID_MPEG4, - mov_write_header, - ff_mov_write_packet, - mov_write_trailer, + .name = "psp", + .long_name = NULL_IF_CONFIG_SMALL("PSP MP4 format"), + .extensions = "mp4,psp", + .priv_data_size = sizeof(MOVMuxContext), + .audio_codec = CODEC_ID_AAC, + .video_codec = CODEC_ID_MPEG4, + .write_header = mov_write_header, + .write_packet = ff_mov_write_packet, + .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0}, .priv_class = &mov_muxer_class, @@ -2406,16 +2403,15 @@ AVOutputFormat ff_psp_muxer = { #endif #if CONFIG_TG2_MUXER AVOutputFormat ff_tg2_muxer = { - "3g2", - NULL_IF_CONFIG_SMALL("3GP2 format"), - NULL, - "3g2", - sizeof(MOVMuxContext), - CODEC_ID_AMR_NB, - CODEC_ID_H263, - mov_write_header, - ff_mov_write_packet, - mov_write_trailer, + .name = "3g2", + .long_name = NULL_IF_CONFIG_SMALL("3GP2 format"), + .extensions = "3g2", + .priv_data_size = sizeof(MOVMuxContext), + .audio_codec = CODEC_ID_AMR_NB, + .video_codec = CODEC_ID_H263, + .write_header = mov_write_header, + .write_packet = ff_mov_write_packet, + .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0}, .priv_class = &mov_muxer_class, @@ -2423,16 +2419,16 @@ AVOutputFormat ff_tg2_muxer = { #endif #if CONFIG_IPOD_MUXER AVOutputFormat ff_ipod_muxer = { - "ipod", - NULL_IF_CONFIG_SMALL("iPod H.264 MP4 format"), - "application/mp4", - "m4v,m4a", - sizeof(MOVMuxContext), - CODEC_ID_AAC, - CODEC_ID_H264, - mov_write_header, - ff_mov_write_packet, - mov_write_trailer, + .name = "ipod", + .long_name = NULL_IF_CONFIG_SMALL("iPod H.264 MP4 format"), + .mime_type = "application/mp4", + .extensions = "m4v,m4a", + .priv_data_size = sizeof(MOVMuxContext), + .audio_codec = CODEC_ID_AAC, + .video_codec = CODEC_ID_H264, + .write_header = mov_write_header, + .write_packet = ff_mov_write_packet, + .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER, .codec_tag = (const AVCodecTag* const []){codec_ipod_tags, 0}, .priv_class = &mov_muxer_class, diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 70ced02218..dbd1c1ef65 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -188,12 +188,11 @@ static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_mp3_demuxer = { - "mp3", - NULL_IF_CONFIG_SMALL("MPEG audio layer 2/3"), - 0, - mp3_read_probe, - mp3_read_header, - mp3_read_packet, + .name = "mp3", + .long_name = NULL_IF_CONFIG_SMALL("MPEG audio layer 2/3"), + .read_probe = mp3_read_probe, + .read_header = mp3_read_header, + .read_packet = mp3_read_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "mp2,mp3,m2a", /* XXX: use probe */ }; diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 9d0ec5d929..e702e3b502 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -162,16 +162,14 @@ static int mp3_write_trailer(struct AVFormatContext *s) #if CONFIG_MP2_MUXER AVOutputFormat ff_mp2_muxer = { - "mp2", - NULL_IF_CONFIG_SMALL("MPEG audio layer 2"), - "audio/x-mpeg", - "mp2,m2a", - 0, - CODEC_ID_MP2, - CODEC_ID_NONE, - NULL, - ff_raw_write_packet, - mp3_write_trailer, + .name = "mp2", + .long_name = NULL_IF_CONFIG_SMALL("MPEG audio layer 2"), + .mime_type = "audio/x-mpeg", + .extensions = "mp2,m2a", + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_NONE, + .write_packet = ff_raw_write_packet, + .write_trailer = mp3_write_trailer, }; #endif @@ -306,17 +304,17 @@ static int mp3_write_header(struct AVFormatContext *s) } AVOutputFormat ff_mp3_muxer = { - "mp3", - NULL_IF_CONFIG_SMALL("MPEG audio layer 3"), - "audio/x-mpeg", - "mp3", - sizeof(MP3Context), - CODEC_ID_MP3, - CODEC_ID_NONE, - mp3_write_header, - ff_raw_write_packet, - mp3_write_trailer, - AVFMT_NOTIMESTAMPS, + .name = "mp3", + .long_name = NULL_IF_CONFIG_SMALL("MPEG audio layer 3"), + .mime_type = "audio/x-mpeg", + .extensions = "mp3", + .priv_data_size = sizeof(MP3Context), + .audio_codec = CODEC_ID_MP3, + .video_codec = CODEC_ID_NONE, + .write_header = mp3_write_header, + .write_packet = ff_raw_write_packet, + .write_trailer = mp3_write_trailer, + .flags = AVFMT_NOTIMESTAMPS, .priv_class = &mp3_muxer_class, }; #endif diff --git a/libavformat/mpc.c b/libavformat/mpc.c index 75b59e1800..8faa0f7320 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -222,13 +222,13 @@ static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp AVInputFormat ff_mpc_demuxer = { - "mpc", - NULL_IF_CONFIG_SMALL("Musepack"), - sizeof(MPCContext), - mpc_probe, - mpc_read_header, - mpc_read_packet, - mpc_read_close, - mpc_read_seek, + .name = "mpc", + .long_name = NULL_IF_CONFIG_SMALL("Musepack"), + .priv_data_size = sizeof(MPCContext), + .read_probe = mpc_probe, + .read_header = mpc_read_header, + .read_packet = mpc_read_packet, + .read_close = mpc_read_close, + .read_seek = mpc_read_seek, .extensions = "mpc", }; diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index c4810f6eaf..d7a7d6a825 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -281,12 +281,11 @@ static int mpc8_read_seek(AVFormatContext *s, int stream_index, int64_t timestam AVInputFormat ff_mpc8_demuxer = { - "mpc8", - NULL_IF_CONFIG_SMALL("Musepack SV8"), - sizeof(MPCContext), - mpc8_probe, - mpc8_read_header, - mpc8_read_packet, - NULL, - mpc8_read_seek, + .name = "mpc8", + .long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"), + .priv_data_size = sizeof(MPCContext), + .read_probe = mpc8_probe, + .read_header = mpc8_read_header, + .read_packet = mpc8_read_packet, + .read_seek = mpc8_read_seek, }; diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 496b9d45f5..bc450495ae 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -603,14 +603,13 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, } AVInputFormat ff_mpegps_demuxer = { - "mpeg", - NULL_IF_CONFIG_SMALL("MPEG-PS format"), - sizeof(MpegDemuxContext), - mpegps_probe, - mpegps_read_header, - mpegps_read_packet, - NULL, - NULL, //mpegps_read_seek, - mpegps_read_dts, + .name = "mpeg", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-PS format"), + .priv_data_size = sizeof(MpegDemuxContext), + .read_probe = mpegps_probe, + .read_header = mpegps_read_header, + .read_packet = mpegps_read_packet, + .read_seek = NULL, //mpegps_read_seek, + .read_timestamp = mpegps_read_dts, .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT, }; diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 5859254492..58242060fa 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -1229,75 +1229,74 @@ static int mpeg_mux_end(AVFormatContext *ctx) #if CONFIG_MPEG1SYSTEM_MUXER AVOutputFormat ff_mpeg1system_muxer = { - "mpeg", - NULL_IF_CONFIG_SMALL("MPEG-1 System format"), - "video/mpeg", - "mpg,mpeg", - sizeof(MpegMuxContext), - CODEC_ID_MP2, - CODEC_ID_MPEG1VIDEO, - mpeg_mux_init, - mpeg_mux_write_packet, - mpeg_mux_end, + .name = "mpeg", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 System format"), + .mime_type = "video/mpeg", + .extensions = "mpg,mpeg", + .priv_data_size = sizeof(MpegMuxContext), + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_MPEG1VIDEO, + .write_header = mpeg_mux_init, + .write_packet = mpeg_mux_write_packet, + .write_trailer = mpeg_mux_end, }; #endif #if CONFIG_MPEG1VCD_MUXER AVOutputFormat ff_mpeg1vcd_muxer = { - "vcd", - NULL_IF_CONFIG_SMALL("MPEG-1 System format (VCD)"), - "video/mpeg", - NULL, - sizeof(MpegMuxContext), - CODEC_ID_MP2, - CODEC_ID_MPEG1VIDEO, - mpeg_mux_init, - mpeg_mux_write_packet, - mpeg_mux_end, + .name = "vcd", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 System format (VCD)"), + .mime_type = "video/mpeg", + .priv_data_size = sizeof(MpegMuxContext), + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_MPEG1VIDEO, + .write_header = mpeg_mux_init, + .write_packet = mpeg_mux_write_packet, + .write_trailer = mpeg_mux_end, }; #endif #if CONFIG_MPEG2VOB_MUXER AVOutputFormat ff_mpeg2vob_muxer = { - "vob", - NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"), - "video/mpeg", - "vob", - sizeof(MpegMuxContext), - CODEC_ID_MP2, - CODEC_ID_MPEG2VIDEO, - mpeg_mux_init, - mpeg_mux_write_packet, - mpeg_mux_end, + .name = "vob", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"), + .mime_type = "video/mpeg", + .extensions = "vob", + .priv_data_size = sizeof(MpegMuxContext), + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_MPEG2VIDEO, + .write_header = mpeg_mux_init, + .write_packet = mpeg_mux_write_packet, + .write_trailer = mpeg_mux_end, }; #endif /* Same as mpeg2vob_mux except that the pack size is 2324 */ #if CONFIG_MPEG2SVCD_MUXER AVOutputFormat ff_mpeg2svcd_muxer = { - "svcd", - NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"), - "video/mpeg", - "vob", - sizeof(MpegMuxContext), - CODEC_ID_MP2, - CODEC_ID_MPEG2VIDEO, - mpeg_mux_init, - mpeg_mux_write_packet, - mpeg_mux_end, + .name = "svcd", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"), + .mime_type = "video/mpeg", + .extensions = "vob", + .priv_data_size = sizeof(MpegMuxContext), + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_MPEG2VIDEO, + .write_header = mpeg_mux_init, + .write_packet = mpeg_mux_write_packet, + .write_trailer = mpeg_mux_end, }; #endif /* Same as mpeg2vob_mux except the 'is_dvd' flag is set to produce NAV pkts */ #if CONFIG_MPEG2DVD_MUXER AVOutputFormat ff_mpeg2dvd_muxer = { - "dvd", - NULL_IF_CONFIG_SMALL("MPEG-2 PS format (DVD VOB)"), - "video/mpeg", - "dvd", - sizeof(MpegMuxContext), - CODEC_ID_MP2, - CODEC_ID_MPEG2VIDEO, - mpeg_mux_init, - mpeg_mux_write_packet, - mpeg_mux_end, + .name = "dvd", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (DVD VOB)"), + .mime_type = "video/mpeg", + .extensions = "dvd", + .priv_data_size = sizeof(MpegMuxContext), + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_MPEG2VIDEO, + .write_header = mpeg_mux_init, + .write_packet = mpeg_mux_write_packet, + .write_trailer = mpeg_mux_end, }; #endif diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 228f48b424..b8f02ab8c5 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1864,15 +1864,15 @@ void ff_mpegts_parse_close(MpegTSContext *ts) } AVInputFormat ff_mpegts_demuxer = { - "mpegts", - NULL_IF_CONFIG_SMALL("MPEG-2 transport stream format"), - sizeof(MpegTSContext), - mpegts_probe, - mpegts_read_header, - mpegts_read_packet, - mpegts_read_close, - read_seek, - mpegts_get_pcr, + .name = "mpegts", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 transport stream format"), + .priv_data_size = sizeof(MpegTSContext), + .read_probe = mpegts_probe, + .read_header = mpegts_read_header, + .read_packet = mpegts_read_packet, + .read_close = mpegts_read_close, + .read_seek = read_seek, + .read_timestamp = mpegts_get_pcr, .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT, #ifdef USE_SYNCPOINT_SEARCH .read_seek2 = read_seek2, @@ -1880,15 +1880,14 @@ AVInputFormat ff_mpegts_demuxer = { }; AVInputFormat ff_mpegtsraw_demuxer = { - "mpegtsraw", - NULL_IF_CONFIG_SMALL("MPEG-2 raw transport stream format"), - sizeof(MpegTSContext), - NULL, - mpegts_read_header, - mpegts_raw_read_packet, - mpegts_read_close, - read_seek, - mpegts_get_pcr, + .name = "mpegtsraw", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 raw transport stream format"), + .priv_data_size = sizeof(MpegTSContext), + .read_header = mpegts_read_header, + .read_packet = mpegts_raw_read_packet, + .read_close = mpegts_read_close, + .read_seek = read_seek, + .read_timestamp = mpegts_get_pcr, .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT, #ifdef USE_SYNCPOINT_SEARCH .read_seek2 = read_seek2, diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 72ff289df6..cc4074338a 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -1051,15 +1051,15 @@ static int mpegts_write_end(AVFormatContext *s) } AVOutputFormat ff_mpegts_muxer = { - "mpegts", - NULL_IF_CONFIG_SMALL("MPEG-2 transport stream format"), - "video/x-mpegts", - "ts,m2t", - sizeof(MpegTSWrite), - CODEC_ID_MP2, - CODEC_ID_MPEG2VIDEO, - mpegts_write_header, - mpegts_write_packet, - mpegts_write_end, + .name = "mpegts", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 transport stream format"), + .mime_type = "video/x-mpegts", + .extensions = "ts,m2t", + .priv_data_size = sizeof(MpegTSWrite), + .audio_codec = CODEC_ID_MP2, + .video_codec = CODEC_ID_MPEG2VIDEO, + .write_header = mpegts_write_header, + .write_packet = mpegts_write_packet, + .write_trailer = mpegts_write_end, .priv_class = &mpegts_muxer_class, }; diff --git a/libavformat/mpjpeg.c b/libavformat/mpjpeg.c index ebb57bf87c..6580904d7e 100644 --- a/libavformat/mpjpeg.c +++ b/libavformat/mpjpeg.c @@ -54,14 +54,13 @@ static int mpjpeg_write_trailer(AVFormatContext *s) } AVOutputFormat ff_mpjpeg_muxer = { - "mpjpeg", - NULL_IF_CONFIG_SMALL("MIME multipart JPEG format"), - "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG, - "mjpg", - 0, - CODEC_ID_NONE, - CODEC_ID_MJPEG, - mpjpeg_write_header, - mpjpeg_write_packet, - mpjpeg_write_trailer, + .name = "mpjpeg", + .long_name = NULL_IF_CONFIG_SMALL("MIME multipart JPEG format"), + .mime_type = "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG, + .extensions = "mjpg", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_MJPEG, + .write_header = mpjpeg_write_header, + .write_packet = mpjpeg_write_packet, + .write_trailer = mpjpeg_write_trailer, }; diff --git a/libavformat/msnwc_tcp.c b/libavformat/msnwc_tcp.c index d9d8000e8b..9ac724e2f2 100644 --- a/libavformat/msnwc_tcp.c +++ b/libavformat/msnwc_tcp.c @@ -131,10 +131,9 @@ static int msnwc_tcp_read_packet(AVFormatContext *ctx, AVPacket *pkt) } AVInputFormat ff_msnwc_tcp_demuxer = { - "msnwctcp", - NULL_IF_CONFIG_SMALL("MSN TCP Webcam stream"), - 0, - msnwc_tcp_probe, - msnwc_tcp_read_header, - msnwc_tcp_read_packet, + .name = "msnwctcp", + .long_name = NULL_IF_CONFIG_SMALL("MSN TCP Webcam stream"), + .read_probe = msnwc_tcp_probe, + .read_header = msnwc_tcp_read_header, + .read_packet = msnwc_tcp_read_packet, }; diff --git a/libavformat/mtv.c b/libavformat/mtv.c index 92d38e13cd..59f13fe704 100644 --- a/libavformat/mtv.c +++ b/libavformat/mtv.c @@ -197,10 +197,10 @@ static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_mtv_demuxer = { - "MTV", - NULL_IF_CONFIG_SMALL("MTV format"), - sizeof(MTVDemuxContext), - mtv_probe, - mtv_read_header, - mtv_read_packet, + .name = "MTV", + .long_name = NULL_IF_CONFIG_SMALL("MTV format"), + .priv_data_size = sizeof(MTVDemuxContext), + .read_probe = mtv_probe, + .read_header = mtv_read_header, + .read_packet = mtv_read_packet, }; diff --git a/libavformat/mvi.c b/libavformat/mvi.c index 809cdf5a3b..532c0c4f49 100644 --- a/libavformat/mvi.c +++ b/libavformat/mvi.c @@ -124,11 +124,10 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_mvi_demuxer = { - "mvi", - NULL_IF_CONFIG_SMALL("Motion Pixels MVI format"), - sizeof(MviDemuxContext), - NULL, - read_header, - read_packet, + .name = "mvi", + .long_name = NULL_IF_CONFIG_SMALL("Motion Pixels MVI format"), + .priv_data_size = sizeof(MviDemuxContext), + .read_header = read_header, + .read_packet = read_packet, .extensions = "mvi" }; diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index cf2bb6cc65..e2688b1bff 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1016,12 +1016,12 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti } AVInputFormat ff_mxf_demuxer = { - "mxf", - NULL_IF_CONFIG_SMALL("Material eXchange Format"), - sizeof(MXFContext), - mxf_probe, - mxf_read_header, - mxf_read_packet, - mxf_read_close, - mxf_read_seek, + .name = "mxf", + .long_name = NULL_IF_CONFIG_SMALL("Material eXchange Format"), + .priv_data_size = sizeof(MXFContext), + .read_probe = mxf_probe, + .read_header = mxf_read_header, + .read_packet = mxf_read_packet, + .read_close = mxf_read_close, + .read_seek = mxf_read_seek, }; diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 7dadec080f..d375e3fe0e 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1890,33 +1890,30 @@ static int mxf_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int } AVOutputFormat ff_mxf_muxer = { - "mxf", - NULL_IF_CONFIG_SMALL("Material eXchange Format"), - "application/mxf", - "mxf", - sizeof(MXFContext), - CODEC_ID_PCM_S16LE, - CODEC_ID_MPEG2VIDEO, - mxf_write_header, - mxf_write_packet, - mxf_write_footer, - AVFMT_NOTIMESTAMPS, - NULL, - mxf_interleave, + .name = "mxf", + .long_name = NULL_IF_CONFIG_SMALL("Material eXchange Format"), + .mime_type = "application/mxf", + .extensions = "mxf", + .priv_data_size = sizeof(MXFContext), + .audio_codec = CODEC_ID_PCM_S16LE, + .video_codec = CODEC_ID_MPEG2VIDEO, + .write_header = mxf_write_header, + .write_packet = mxf_write_packet, + .write_trailer = mxf_write_footer, + .flags = AVFMT_NOTIMESTAMPS, + .interleave_packet = mxf_interleave, }; AVOutputFormat ff_mxf_d10_muxer = { - "mxf_d10", - NULL_IF_CONFIG_SMALL("Material eXchange Format, D-10 Mapping"), - "application/mxf", - NULL, - sizeof(MXFContext), - CODEC_ID_PCM_S16LE, - CODEC_ID_MPEG2VIDEO, - mxf_write_header, - mxf_write_packet, - mxf_write_footer, - AVFMT_NOTIMESTAMPS, - NULL, - mxf_interleave, + .name = "mxf_d10", + .long_name = NULL_IF_CONFIG_SMALL("Material eXchange Format, D-10 Mapping"), + .mime_type = "application/mxf", + .priv_data_size = sizeof(MXFContext), + .audio_codec = CODEC_ID_PCM_S16LE, + .video_codec = CODEC_ID_MPEG2VIDEO, + .write_header = mxf_write_header, + .write_packet = mxf_write_packet, + .write_trailer = mxf_write_footer, + .flags = AVFMT_NOTIMESTAMPS, + .interleave_packet = mxf_interleave, }; diff --git a/libavformat/ncdec.c b/libavformat/ncdec.c index 7e43adcd1e..8feda75214 100644 --- a/libavformat/ncdec.c +++ b/libavformat/ncdec.c @@ -91,11 +91,10 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_nc_demuxer = { - "nc", - NULL_IF_CONFIG_SMALL("NC camera feed format"), - 0, - nc_probe, - nc_read_header, - nc_read_packet, + .name = "nc", + .long_name = NULL_IF_CONFIG_SMALL("NC camera feed format"), + .read_probe = nc_probe, + .read_header = nc_read_header, + .read_packet = nc_read_packet, .extensions = "v", }; diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index 4787331def..08c4b10362 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -776,12 +776,12 @@ static int nsv_probe(AVProbeData *p) } AVInputFormat ff_nsv_demuxer = { - "nsv", - NULL_IF_CONFIG_SMALL("Nullsoft Streaming Video"), - sizeof(NSVContext), - nsv_probe, - nsv_read_header, - nsv_read_packet, - nsv_read_close, - nsv_read_seek, + .name = "nsv", + .long_name = NULL_IF_CONFIG_SMALL("Nullsoft Streaming Video"), + .priv_data_size = sizeof(NSVContext), + .read_probe = nsv_probe, + .read_header = nsv_read_header, + .read_packet = nsv_read_packet, + .read_close = nsv_read_close, + .read_seek = nsv_read_seek, }; diff --git a/libavformat/nullenc.c b/libavformat/nullenc.c index 8e38b278b1..79fc02e528 100644 --- a/libavformat/nullenc.c +++ b/libavformat/nullenc.c @@ -27,14 +27,10 @@ static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt) } AVOutputFormat ff_null_muxer = { - "null", - NULL_IF_CONFIG_SMALL("raw null video format"), - NULL, - NULL, - 0, - AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE), - CODEC_ID_RAWVIDEO, - NULL, - null_write_packet, + .name = "null", + .long_name = NULL_IF_CONFIG_SMALL("raw null video format"), + .audio_codec = AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE), + .video_codec = CODEC_ID_RAWVIDEO, + .write_packet = null_write_packet, .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS, }; diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 93888a2bd6..493ca7efc0 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -924,14 +924,14 @@ static int nut_read_close(AVFormatContext *s) #if CONFIG_NUT_DEMUXER AVInputFormat ff_nut_demuxer = { - "nut", - NULL_IF_CONFIG_SMALL("NUT format"), - sizeof(NUTContext), - nut_probe, - nut_read_header, - nut_read_packet, - nut_read_close, - read_seek, + .name = "nut", + .long_name = NULL_IF_CONFIG_SMALL("NUT format"), + .priv_data_size = sizeof(NUTContext), + .read_probe = nut_probe, + .read_header = nut_read_header, + .read_packet = nut_read_packet, + .read_close = nut_read_close, + .read_seek = read_seek, .extensions = "nut", .codec_tag = (const AVCodecTag * const []) { ff_codec_bmp_tags, ff_nut_video_tags, ff_codec_wav_tags, ff_nut_subtitle_tags, 0 }, }; diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 412c670387..1ed073f00c 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -861,22 +861,22 @@ static int write_trailer(AVFormatContext *s){ } AVOutputFormat ff_nut_muxer = { - "nut", - NULL_IF_CONFIG_SMALL("NUT format"), - "video/x-nut", - "nut", - sizeof(NUTContext), + .name = "nut", + .long_name = NULL_IF_CONFIG_SMALL("NUT format"), + .mime_type = "video/x-nut", + .extensions = "nut", + .priv_data_size = sizeof(NUTContext), #if CONFIG_LIBVORBIS - CODEC_ID_VORBIS, + .audio_codec = CODEC_ID_VORBIS, #elif CONFIG_LIBMP3LAME - CODEC_ID_MP3, + .audio_codec = CODEC_ID_MP3, #else - CODEC_ID_MP2, + .audio_codec = CODEC_ID_MP2, #endif - CODEC_ID_MPEG4, - write_header, - write_packet, - write_trailer, + .video_codec = CODEC_ID_MPEG4, + .write_header = write_header, + .write_packet = write_packet, + .write_trailer = write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, .codec_tag = (const AVCodecTag * const []){ ff_codec_bmp_tags, ff_nut_video_tags, ff_codec_wav_tags, ff_nut_subtitle_tags, 0 }, }; diff --git a/libavformat/nuv.c b/libavformat/nuv.c index 854aadd990..36ec8fa093 100644 --- a/libavformat/nuv.c +++ b/libavformat/nuv.c @@ -259,13 +259,11 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) { } AVInputFormat ff_nuv_demuxer = { - "nuv", - NULL_IF_CONFIG_SMALL("NuppelVideo format"), - sizeof(NUVContext), - nuv_probe, - nuv_header, - nuv_packet, - NULL, - NULL, + .name = "nuv", + .long_name = NULL_IF_CONFIG_SMALL("NuppelVideo format"), + .priv_data_size = sizeof(NUVContext), + .read_probe = nuv_probe, + .read_header = nuv_header, + .read_packet = nuv_packet, .flags = AVFMT_GENERIC_INDEX, }; diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index 2b2189c10e..49dedb35d7 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -505,14 +505,14 @@ static int ogg_write_trailer(AVFormatContext *s) } AVOutputFormat ff_ogg_muxer = { - "ogg", - NULL_IF_CONFIG_SMALL("Ogg"), - "application/ogg", - "ogg,ogv,spx", - sizeof(OGGContext), - CODEC_ID_FLAC, - CODEC_ID_THEORA, - ogg_write_header, - ogg_write_packet, - ogg_write_trailer, + .name = "ogg", + .long_name = NULL_IF_CONFIG_SMALL("Ogg"), + .mime_type = "application/ogg", + .extensions = "ogg,ogv,spx", + .priv_data_size = sizeof(OGGContext), + .audio_codec = CODEC_ID_FLAC, + .video_codec = CODEC_ID_THEORA, + .write_header = ogg_write_header, + .write_packet = ogg_write_packet, + .write_trailer = ogg_write_trailer, }; diff --git a/libavformat/oma.c b/libavformat/oma.c index 0ec81ebefb..7675841792 100644 --- a/libavformat/oma.c +++ b/libavformat/oma.c @@ -192,14 +192,12 @@ static int oma_read_probe(AVProbeData *p) AVInputFormat ff_oma_demuxer = { - "oma", - NULL_IF_CONFIG_SMALL("Sony OpenMG audio"), - 0, - oma_read_probe, - oma_read_header, - oma_read_packet, - 0, - pcm_read_seek, + .name = "oma", + .long_name = NULL_IF_CONFIG_SMALL("Sony OpenMG audio"), + .read_probe = oma_read_probe, + .read_header = oma_read_header, + .read_packet = oma_read_packet, + .read_seek = pcm_read_seek, .flags= AVFMT_GENERIC_INDEX, .extensions = "oma,aa3", .codec_tag= (const AVCodecTag* const []){codec_oma_tags, 0}, diff --git a/libavformat/psxstr.c b/libavformat/psxstr.c index 646244238c..ac6104fced 100644 --- a/libavformat/psxstr.c +++ b/libavformat/psxstr.c @@ -258,11 +258,11 @@ static int str_read_close(AVFormatContext *s) } AVInputFormat ff_str_demuxer = { - "psxstr", - NULL_IF_CONFIG_SMALL("Sony Playstation STR format"), - sizeof(StrDemuxContext), - str_probe, - str_read_header, - str_read_packet, - str_read_close, + .name = "psxstr", + .long_name = NULL_IF_CONFIG_SMALL("Sony Playstation STR format"), + .priv_data_size = sizeof(StrDemuxContext), + .read_probe = str_probe, + .read_header = str_read_header, + .read_packet = str_read_packet, + .read_close = str_read_close, }; diff --git a/libavformat/pva.c b/libavformat/pva.c index 79b959cef6..22fea40db9 100644 --- a/libavformat/pva.c +++ b/libavformat/pva.c @@ -201,11 +201,11 @@ static int64_t pva_read_timestamp(struct AVFormatContext *s, int stream_index, } AVInputFormat ff_pva_demuxer = { - "pva", - NULL_IF_CONFIG_SMALL("TechnoTrend PVA file and stream format"), - sizeof(PVAContext), - pva_probe, - pva_read_header, - pva_read_packet, + .name = "pva", + .long_name = NULL_IF_CONFIG_SMALL("TechnoTrend PVA file and stream format"), + .priv_data_size = sizeof(PVAContext), + .read_probe = pva_probe, + .read_header = pva_read_header, + .read_packet = pva_read_packet, .read_timestamp = pva_read_timestamp }; diff --git a/libavformat/r3d.c b/libavformat/r3d.c index 5dd7f997e5..890b3b93c6 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -384,12 +384,12 @@ static int r3d_close(AVFormatContext *s) } AVInputFormat ff_r3d_demuxer = { - "r3d", - NULL_IF_CONFIG_SMALL("REDCODE R3D format"), - sizeof(R3DContext), - r3d_probe, - r3d_read_header, - r3d_read_packet, - r3d_close, - r3d_seek, + .name = "r3d", + .long_name = NULL_IF_CONFIG_SMALL("REDCODE R3D format"), + .priv_data_size = sizeof(R3DContext), + .read_probe = r3d_probe, + .read_header = r3d_read_header, + .read_packet = r3d_read_packet, + .read_close = r3d_close, + .read_seek = r3d_seek, }; diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index cc05c353e9..8f3fecb1e7 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -217,12 +217,11 @@ const AVClass ff_rawvideo_demuxer_class = { #if CONFIG_G722_DEMUXER AVInputFormat ff_g722_demuxer = { - "g722", - NULL_IF_CONFIG_SMALL("raw G.722"), - sizeof(RawAudioDemuxerContext), - NULL, - ff_raw_read_header, - ff_raw_read_partial_packet, + .name = "g722", + .long_name = NULL_IF_CONFIG_SMALL("raw G.722"), + .priv_data_size = sizeof(RawAudioDemuxerContext), + .read_header = ff_raw_read_header, + .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "g722,722", .value = CODEC_ID_ADPCM_G722, @@ -232,12 +231,10 @@ AVInputFormat ff_g722_demuxer = { #if CONFIG_GSM_DEMUXER AVInputFormat ff_gsm_demuxer = { - "gsm", - NULL_IF_CONFIG_SMALL("raw GSM"), - 0, - NULL, - ff_raw_audio_read_header, - ff_raw_read_partial_packet, + .name = "gsm", + .long_name = NULL_IF_CONFIG_SMALL("raw GSM"), + .read_header = ff_raw_audio_read_header, + .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "gsm", .value = CODEC_ID_GSM, @@ -250,12 +247,10 @@ FF_DEF_RAWVIDEO_DEMUXER(mjpeg, "raw MJPEG video", NULL, "mjpg,mjpeg", CODEC_ID_M #if CONFIG_MLP_DEMUXER AVInputFormat ff_mlp_demuxer = { - "mlp", - NULL_IF_CONFIG_SMALL("raw MLP"), - 0, - NULL, - ff_raw_audio_read_header, - ff_raw_read_partial_packet, + .name = "mlp", + .long_name = NULL_IF_CONFIG_SMALL("raw MLP"), + .read_header = ff_raw_audio_read_header, + .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "mlp", .value = CODEC_ID_MLP, @@ -264,12 +259,10 @@ AVInputFormat ff_mlp_demuxer = { #if CONFIG_TRUEHD_DEMUXER AVInputFormat ff_truehd_demuxer = { - "truehd", - NULL_IF_CONFIG_SMALL("raw TrueHD"), - 0, - NULL, - ff_raw_audio_read_header, - ff_raw_read_partial_packet, + .name = "truehd", + .long_name = NULL_IF_CONFIG_SMALL("raw TrueHD"), + .read_header = ff_raw_audio_read_header, + .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "thd", .value = CODEC_ID_TRUEHD, @@ -278,12 +271,10 @@ AVInputFormat ff_truehd_demuxer = { #if CONFIG_SHORTEN_DEMUXER AVInputFormat ff_shorten_demuxer = { - "shn", - NULL_IF_CONFIG_SMALL("raw Shorten"), - 0, - NULL, - ff_raw_audio_read_header, - ff_raw_read_partial_packet, + .name = "shn", + .long_name = NULL_IF_CONFIG_SMALL("raw Shorten"), + .read_header = ff_raw_audio_read_header, + .read_packet = ff_raw_read_partial_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "shn", .value = CODEC_ID_SHORTEN, diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c index 00e43df9a7..5f2065e639 100644 --- a/libavformat/rawenc.c +++ b/libavformat/rawenc.c @@ -34,195 +34,163 @@ int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt) #if CONFIG_AC3_MUXER AVOutputFormat ff_ac3_muxer = { - "ac3", - NULL_IF_CONFIG_SMALL("raw AC-3"), - "audio/x-ac3", - "ac3", - 0, - CODEC_ID_AC3, - CODEC_ID_NONE, - NULL, - ff_raw_write_packet, + .name = "ac3", + .long_name = NULL_IF_CONFIG_SMALL("raw AC-3"), + .mime_type = "audio/x-ac3", + .extensions = "ac3", + .audio_codec = CODEC_ID_AC3, + .video_codec = CODEC_ID_NONE, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_DIRAC_MUXER AVOutputFormat ff_dirac_muxer = { - "dirac", - NULL_IF_CONFIG_SMALL("raw Dirac"), - NULL, - "drc", - 0, - CODEC_ID_NONE, - CODEC_ID_DIRAC, - NULL, - ff_raw_write_packet, + .name = "dirac", + .long_name = NULL_IF_CONFIG_SMALL("raw Dirac"), + .extensions = "drc", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_DIRAC, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_DNXHD_MUXER AVOutputFormat ff_dnxhd_muxer = { - "dnxhd", - NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"), - NULL, - "dnxhd", - 0, - CODEC_ID_NONE, - CODEC_ID_DNXHD, - NULL, - ff_raw_write_packet, + .name = "dnxhd", + .long_name = NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"), + .extensions = "dnxhd", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_DNXHD, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_DTS_MUXER AVOutputFormat ff_dts_muxer = { - "dts", - NULL_IF_CONFIG_SMALL("raw DTS"), - "audio/x-dca", - "dts", - 0, - CODEC_ID_DTS, - CODEC_ID_NONE, - NULL, - ff_raw_write_packet, + .name = "dts", + .long_name = NULL_IF_CONFIG_SMALL("raw DTS"), + .mime_type = "audio/x-dca", + .extensions = "dts", + .audio_codec = CODEC_ID_DTS, + .video_codec = CODEC_ID_NONE, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_EAC3_MUXER AVOutputFormat ff_eac3_muxer = { - "eac3", - NULL_IF_CONFIG_SMALL("raw E-AC-3"), - "audio/x-eac3", - "eac3", - 0, - CODEC_ID_EAC3, - CODEC_ID_NONE, - NULL, - ff_raw_write_packet, + .name = "eac3", + .long_name = NULL_IF_CONFIG_SMALL("raw E-AC-3"), + .mime_type = "audio/x-eac3", + .extensions = "eac3", + .audio_codec = CODEC_ID_EAC3, + .video_codec = CODEC_ID_NONE, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_G722_MUXER AVOutputFormat ff_g722_muxer = { - "g722", - NULL_IF_CONFIG_SMALL("raw G.722"), - "audio/G722", - "g722", - 0, - CODEC_ID_ADPCM_G722, - CODEC_ID_NONE, - NULL, - ff_raw_write_packet, + .name = "g722", + .long_name = NULL_IF_CONFIG_SMALL("raw G.722"), + .mime_type = "audio/G722", + .extensions = "g722", + .audio_codec = CODEC_ID_ADPCM_G722, + .video_codec = CODEC_ID_NONE, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_H261_MUXER AVOutputFormat ff_h261_muxer = { - "h261", - NULL_IF_CONFIG_SMALL("raw H.261"), - "video/x-h261", - "h261", - 0, - CODEC_ID_NONE, - CODEC_ID_H261, - NULL, - ff_raw_write_packet, + .name = "h261", + .long_name = NULL_IF_CONFIG_SMALL("raw H.261"), + .mime_type = "video/x-h261", + .extensions = "h261", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_H261, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_H263_MUXER AVOutputFormat ff_h263_muxer = { - "h263", - NULL_IF_CONFIG_SMALL("raw H.263"), - "video/x-h263", - "h263", - 0, - CODEC_ID_NONE, - CODEC_ID_H263, - NULL, - ff_raw_write_packet, + .name = "h263", + .long_name = NULL_IF_CONFIG_SMALL("raw H.263"), + .mime_type = "video/x-h263", + .extensions = "h263", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_H263, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_H264_MUXER AVOutputFormat ff_h264_muxer = { - "h264", - NULL_IF_CONFIG_SMALL("raw H.264 video format"), - NULL, - "h264", - 0, - CODEC_ID_NONE, - CODEC_ID_H264, - NULL, - ff_raw_write_packet, + .name = "h264", + .long_name = NULL_IF_CONFIG_SMALL("raw H.264 video format"), + .extensions = "h264", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_H264, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_CAVSVIDEO_MUXER AVOutputFormat ff_cavsvideo_muxer = { - "cavsvideo", - NULL_IF_CONFIG_SMALL("raw Chinese AVS video"), - NULL, - "cavs", - 0, - CODEC_ID_NONE, - CODEC_ID_CAVS, - NULL, - ff_raw_write_packet, + .name = "cavsvideo", + .long_name = NULL_IF_CONFIG_SMALL("raw Chinese AVS video"), + .extensions = "cavs", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_CAVS, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_M4V_MUXER AVOutputFormat ff_m4v_muxer = { - "m4v", - NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"), - NULL, - "m4v", - 0, - CODEC_ID_NONE, - CODEC_ID_MPEG4, - NULL, - ff_raw_write_packet, + .name = "m4v", + .long_name = NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"), + .extensions = "m4v", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_MPEG4, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_MJPEG_MUXER AVOutputFormat ff_mjpeg_muxer = { - "mjpeg", - NULL_IF_CONFIG_SMALL("raw MJPEG video"), - "video/x-mjpeg", - "mjpg,mjpeg", - 0, - CODEC_ID_NONE, - CODEC_ID_MJPEG, - NULL, - ff_raw_write_packet, + .name = "mjpeg", + .long_name = NULL_IF_CONFIG_SMALL("raw MJPEG video"), + .mime_type = "video/x-mjpeg", + .extensions = "mjpg,mjpeg", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_MJPEG, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_MLP_MUXER AVOutputFormat ff_mlp_muxer = { - "mlp", - NULL_IF_CONFIG_SMALL("raw MLP"), - NULL, - "mlp", - 0, - CODEC_ID_MLP, - CODEC_ID_NONE, - NULL, - ff_raw_write_packet, + .name = "mlp", + .long_name = NULL_IF_CONFIG_SMALL("raw MLP"), + .extensions = "mlp", + .audio_codec = CODEC_ID_MLP, + .video_codec = CODEC_ID_NONE, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif @@ -241,60 +209,49 @@ AVOutputFormat ff_srt_muxer = { #if CONFIG_TRUEHD_MUXER AVOutputFormat ff_truehd_muxer = { - "truehd", - NULL_IF_CONFIG_SMALL("raw TrueHD"), - NULL, - "thd", - 0, - CODEC_ID_TRUEHD, - CODEC_ID_NONE, - NULL, - ff_raw_write_packet, + .name = "truehd", + .long_name = NULL_IF_CONFIG_SMALL("raw TrueHD"), + .extensions = "thd", + .audio_codec = CODEC_ID_TRUEHD, + .video_codec = CODEC_ID_NONE, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_MPEG1VIDEO_MUXER AVOutputFormat ff_mpeg1video_muxer = { - "mpeg1video", - NULL_IF_CONFIG_SMALL("raw MPEG-1 video"), - "video/x-mpeg", - "mpg,mpeg,m1v", - 0, - CODEC_ID_NONE, - CODEC_ID_MPEG1VIDEO, - NULL, - ff_raw_write_packet, + .name = "mpeg1video", + .long_name = NULL_IF_CONFIG_SMALL("raw MPEG-1 video"), + .mime_type = "video/x-mpeg", + .extensions = "mpg,mpeg,m1v", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_MPEG1VIDEO, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_MPEG2VIDEO_MUXER AVOutputFormat ff_mpeg2video_muxer = { - "mpeg2video", - NULL_IF_CONFIG_SMALL("raw MPEG-2 video"), - NULL, - "m2v", - 0, - CODEC_ID_NONE, - CODEC_ID_MPEG2VIDEO, - NULL, - ff_raw_write_packet, + .name = "mpeg2video", + .long_name = NULL_IF_CONFIG_SMALL("raw MPEG-2 video"), + .extensions = "m2v", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_MPEG2VIDEO, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif #if CONFIG_RAWVIDEO_MUXER AVOutputFormat ff_rawvideo_muxer = { - "rawvideo", - NULL_IF_CONFIG_SMALL("raw video format"), - NULL, - "yuv,rgb", - 0, - CODEC_ID_NONE, - CODEC_ID_RAWVIDEO, - NULL, - ff_raw_write_packet, + .name = "rawvideo", + .long_name = NULL_IF_CONFIG_SMALL("raw video format"), + .extensions = "yuv,rgb", + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_RAWVIDEO, + .write_packet = ff_raw_write_packet, .flags= AVFMT_NOTIMESTAMPS, }; #endif diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c index f8d9b65f36..e1c52abb0a 100644 --- a/libavformat/rawvideodec.c +++ b/libavformat/rawvideodec.c @@ -45,12 +45,11 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_rawvideo_demuxer = { - "rawvideo", - NULL_IF_CONFIG_SMALL("raw video format"), - sizeof(FFRawVideoDemuxerContext), - NULL, - ff_raw_read_header, - rawvideo_read_packet, + .name = "rawvideo", + .long_name = NULL_IF_CONFIG_SMALL("raw video format"), + .priv_data_size = sizeof(FFRawVideoDemuxerContext), + .read_header = ff_raw_read_header, + .read_packet = rawvideo_read_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "yuv,cif,qcif,rgb", .value = CODEC_ID_RAWVIDEO, diff --git a/libavformat/rl2.c b/libavformat/rl2.c index c84e4e1705..42b46a8e36 100644 --- a/libavformat/rl2.c +++ b/libavformat/rl2.c @@ -286,13 +286,12 @@ static int rl2_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp } AVInputFormat ff_rl2_demuxer = { - "rl2", - NULL_IF_CONFIG_SMALL("RL2 format"), - sizeof(Rl2DemuxContext), - rl2_probe, - rl2_read_header, - rl2_read_packet, - NULL, - rl2_read_seek, + .name = "rl2", + .long_name = NULL_IF_CONFIG_SMALL("RL2 format"), + .priv_data_size = sizeof(Rl2DemuxContext), + .read_probe = rl2_probe, + .read_header = rl2_read_header, + .read_packet = rl2_read_packet, + .read_seek = rl2_read_seek, }; diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 69c4ffe400..3f4d333c47 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -935,23 +935,19 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index, } AVInputFormat ff_rm_demuxer = { - "rm", - NULL_IF_CONFIG_SMALL("RealMedia format"), - sizeof(RMDemuxContext), - rm_probe, - rm_read_header, - rm_read_packet, - rm_read_close, - NULL, - rm_read_dts, + .name = "rm", + .long_name = NULL_IF_CONFIG_SMALL("RealMedia format"), + .priv_data_size = sizeof(RMDemuxContext), + .read_probe = rm_probe, + .read_header = rm_read_header, + .read_packet = rm_read_packet, + .read_close = rm_read_close, + .read_timestamp = rm_read_dts, }; AVInputFormat ff_rdt_demuxer = { - "rdt", - NULL_IF_CONFIG_SMALL("RDT demuxer"), - sizeof(RMDemuxContext), - NULL, - NULL, - NULL, - rm_read_close, + .name = "rdt", + .long_name = NULL_IF_CONFIG_SMALL("RDT demuxer"), + .priv_data_size = sizeof(RMDemuxContext), + .read_close = rm_read_close, }; diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c index 2476cb0590..0846a0ac15 100644 --- a/libavformat/rmenc.c +++ b/libavformat/rmenc.c @@ -461,15 +461,15 @@ static int rm_write_trailer(AVFormatContext *s) AVOutputFormat ff_rm_muxer = { - "rm", - NULL_IF_CONFIG_SMALL("RealMedia format"), - "application/vnd.rn-realmedia", - "rm,ra", - sizeof(RMMuxContext), - CODEC_ID_AC3, - CODEC_ID_RV10, - rm_write_header, - rm_write_packet, - rm_write_trailer, + .name = "rm", + .long_name = NULL_IF_CONFIG_SMALL("RealMedia format"), + .mime_type = "application/vnd.rn-realmedia", + .extensions = "rm,ra", + .priv_data_size = sizeof(RMMuxContext), + .audio_codec = CODEC_ID_AC3, + .video_codec = CODEC_ID_RV10, + .write_header = rm_write_header, + .write_packet = rm_write_packet, + .write_trailer = rm_write_trailer, .codec_tag= (const AVCodecTag* const []){ff_rm_codec_tags, 0}, }; diff --git a/libavformat/rpl.c b/libavformat/rpl.c index f67d3cd7c4..1e2f65f770 100644 --- a/libavformat/rpl.c +++ b/libavformat/rpl.c @@ -351,10 +351,10 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_rpl_demuxer = { - "rpl", - NULL_IF_CONFIG_SMALL("RPL/ARMovie format"), - sizeof(RPLContext), - rpl_probe, - rpl_read_header, - rpl_read_packet, + .name = "rpl", + .long_name = NULL_IF_CONFIG_SMALL("RPL/ARMovie format"), + .priv_data_size = sizeof(RPLContext), + .read_probe = rpl_probe, + .read_header = rpl_read_header, + .read_packet = rpl_read_packet, }; diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index c412158778..ef261c3022 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -462,15 +462,13 @@ static int rtp_write_trailer(AVFormatContext *s1) } AVOutputFormat ff_rtp_muxer = { - "rtp", - NULL_IF_CONFIG_SMALL("RTP output format"), - NULL, - NULL, - sizeof(RTPMuxContext), - CODEC_ID_PCM_MULAW, - CODEC_ID_NONE, - rtp_write_header, - rtp_write_packet, - rtp_write_trailer, + .name = "rtp", + .long_name = NULL_IF_CONFIG_SMALL("RTP output format"), + .priv_data_size = sizeof(RTPMuxContext), + .audio_codec = CODEC_ID_PCM_MULAW, + .video_codec = CODEC_ID_NONE, + .write_header = rtp_write_header, + .write_packet = rtp_write_packet, + .write_trailer = rtp_write_trailer, .priv_class = &rtp_muxer_class, }; diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index ce9bf1e1eb..949c174070 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1824,13 +1824,13 @@ static int sdp_read_close(AVFormatContext *s) } AVInputFormat ff_sdp_demuxer = { - "sdp", - NULL_IF_CONFIG_SMALL("SDP"), - sizeof(RTSPState), - sdp_probe, - sdp_read_header, - ff_rtsp_fetch_packet, - sdp_read_close, + .name = "sdp", + .long_name = NULL_IF_CONFIG_SMALL("SDP"), + .priv_data_size = sizeof(RTSPState), + .read_probe = sdp_probe, + .read_header = sdp_read_header, + .read_packet = ff_rtsp_fetch_packet, + .read_close = sdp_read_close, }; #endif /* CONFIG_SDP_DEMUXER */ @@ -1928,13 +1928,13 @@ fail: } AVInputFormat ff_rtp_demuxer = { - "rtp", - NULL_IF_CONFIG_SMALL("RTP input format"), - sizeof(RTSPState), - rtp_probe, - rtp_read_header, - ff_rtsp_fetch_packet, - sdp_read_close, + .name = "rtp", + .long_name = NULL_IF_CONFIG_SMALL("RTP input format"), + .priv_data_size = sizeof(RTSPState), + .read_probe = rtp_probe, + .read_header = rtp_read_header, + .read_packet = ff_rtsp_fetch_packet, + .read_close = sdp_read_close, .flags = AVFMT_NOFILE, }; #endif /* CONFIG_RTP_DEMUXER */ diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index 2dff46d1de..d154615d6f 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -412,14 +412,14 @@ const AVClass rtsp_demuxer_class = { }; AVInputFormat ff_rtsp_demuxer = { - "rtsp", - NULL_IF_CONFIG_SMALL("RTSP input format"), - sizeof(RTSPState), - rtsp_probe, - rtsp_read_header, - rtsp_read_packet, - rtsp_read_close, - rtsp_read_seek, + .name = "rtsp", + .long_name = NULL_IF_CONFIG_SMALL("RTSP input format"), + .priv_data_size = sizeof(RTSPState), + .read_probe = rtsp_probe, + .read_header = rtsp_read_header, + .read_packet = rtsp_read_packet, + .read_close = rtsp_read_close, + .read_seek = rtsp_read_seek, .flags = AVFMT_NOFILE, .read_play = rtsp_read_play, .read_pause = rtsp_read_pause, diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c index b76b6adb99..faf76c0e19 100644 --- a/libavformat/rtspenc.c +++ b/libavformat/rtspenc.c @@ -241,16 +241,14 @@ static int rtsp_write_close(AVFormatContext *s) } AVOutputFormat ff_rtsp_muxer = { - "rtsp", - NULL_IF_CONFIG_SMALL("RTSP output format"), - NULL, - NULL, - sizeof(RTSPState), - CODEC_ID_AAC, - CODEC_ID_MPEG4, - rtsp_write_header, - rtsp_write_packet, - rtsp_write_close, + .name = "rtsp", + .long_name = NULL_IF_CONFIG_SMALL("RTSP output format"), + .priv_data_size = sizeof(RTSPState), + .audio_codec = CODEC_ID_AAC, + .video_codec = CODEC_ID_MPEG4, + .write_header = rtsp_write_header, + .write_packet = rtsp_write_packet, + .write_trailer = rtsp_write_close, .flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER, .priv_class = &rtsp_muxer_class, }; diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index 15d772c780..c317821772 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -224,13 +224,13 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_sap_demuxer = { - "sap", - NULL_IF_CONFIG_SMALL("SAP input format"), - sizeof(struct SAPState), - sap_probe, - sap_read_header, - sap_fetch_packet, - sap_read_close, + .name = "sap", + .long_name = NULL_IF_CONFIG_SMALL("SAP input format"), + .priv_data_size = sizeof(struct SAPState), + .read_probe = sap_probe, + .read_header = sap_read_header, + .read_packet = sap_fetch_packet, + .read_close = sap_read_close, .flags = AVFMT_NOFILE, }; diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index 3abd79e4e8..06cac938f3 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -250,16 +250,14 @@ static int sap_write_packet(AVFormatContext *s, AVPacket *pkt) } AVOutputFormat ff_sap_muxer = { - "sap", - NULL_IF_CONFIG_SMALL("SAP output format"), - NULL, - NULL, - sizeof(struct SAPState), - CODEC_ID_AAC, - CODEC_ID_MPEG4, - sap_write_header, - sap_write_packet, - sap_write_close, + .name = "sap", + .long_name = NULL_IF_CONFIG_SMALL("SAP output format"), + .priv_data_size = sizeof(struct SAPState), + .audio_codec = CODEC_ID_AAC, + .video_codec = CODEC_ID_MPEG4, + .write_header = sap_write_header, + .write_packet = sap_write_packet, + .write_trailer = sap_write_close, .flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER, }; diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c index 0886825523..81f04c6c01 100644 --- a/libavformat/segafilm.c +++ b/libavformat/segafilm.c @@ -297,11 +297,11 @@ static int film_read_close(AVFormatContext *s) } AVInputFormat ff_segafilm_demuxer = { - "film_cpk", - NULL_IF_CONFIG_SMALL("Sega FILM/CPK format"), - sizeof(FilmDemuxContext), - film_probe, - film_read_header, - film_read_packet, - film_read_close, + .name = "film_cpk", + .long_name = NULL_IF_CONFIG_SMALL("Sega FILM/CPK format"), + .priv_data_size = sizeof(FilmDemuxContext), + .read_probe = film_probe, + .read_header = film_read_header, + .read_packet = film_read_packet, + .read_close = film_read_close, }; diff --git a/libavformat/sierravmd.c b/libavformat/sierravmd.c index c0fb22211b..4539cfb20f 100644 --- a/libavformat/sierravmd.c +++ b/libavformat/sierravmd.c @@ -281,11 +281,11 @@ static int vmd_read_close(AVFormatContext *s) } AVInputFormat ff_vmd_demuxer = { - "vmd", - NULL_IF_CONFIG_SMALL("Sierra VMD format"), - sizeof(VmdDemuxContext), - vmd_probe, - vmd_read_header, - vmd_read_packet, - vmd_read_close, + .name = "vmd", + .long_name = NULL_IF_CONFIG_SMALL("Sierra VMD format"), + .priv_data_size = sizeof(VmdDemuxContext), + .read_probe = vmd_probe, + .read_header = vmd_read_header, + .read_packet = vmd_read_packet, + .read_close = vmd_read_close, }; diff --git a/libavformat/siff.c b/libavformat/siff.c index 23c122f7a7..cdb64528e5 100644 --- a/libavformat/siff.c +++ b/libavformat/siff.c @@ -228,11 +228,11 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_siff_demuxer = { - "siff", - NULL_IF_CONFIG_SMALL("Beam Software SIFF"), - sizeof(SIFFContext), - siff_probe, - siff_read_header, - siff_read_packet, + .name = "siff", + .long_name = NULL_IF_CONFIG_SMALL("Beam Software SIFF"), + .priv_data_size = sizeof(SIFFContext), + .read_probe = siff_probe, + .read_header = siff_read_header, + .read_packet = siff_read_packet, .extensions = "vb,son" }; diff --git a/libavformat/smacker.c b/libavformat/smacker.c index db9a02bb6c..51a3b1b8b8 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -340,11 +340,11 @@ static int smacker_read_close(AVFormatContext *s) } AVInputFormat ff_smacker_demuxer = { - "smk", - NULL_IF_CONFIG_SMALL("Smacker video"), - sizeof(SmackerContext), - smacker_probe, - smacker_read_header, - smacker_read_packet, - smacker_read_close, + .name = "smk", + .long_name = NULL_IF_CONFIG_SMALL("Smacker video"), + .priv_data_size = sizeof(SmackerContext), + .read_probe = smacker_probe, + .read_header = smacker_read_header, + .read_packet = smacker_read_packet, + .read_close = smacker_read_close, }; diff --git a/libavformat/sol.c b/libavformat/sol.c index 1ebb4d2e30..6ca8d1c1ee 100644 --- a/libavformat/sol.c +++ b/libavformat/sol.c @@ -141,12 +141,10 @@ static int sol_read_packet(AVFormatContext *s, } AVInputFormat ff_sol_demuxer = { - "sol", - NULL_IF_CONFIG_SMALL("Sierra SOL format"), - 0, - sol_probe, - sol_read_header, - sol_read_packet, - NULL, - pcm_read_seek, + .name = "sol", + .long_name = NULL_IF_CONFIG_SMALL("Sierra SOL format"), + .read_probe = sol_probe, + .read_header = sol_read_header, + .read_packet = sol_read_packet, + .read_seek = pcm_read_seek, }; diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c index 7661bf1f8f..504c8371ce 100644 --- a/libavformat/soxdec.c +++ b/libavformat/soxdec.c @@ -143,12 +143,10 @@ static int sox_read_packet(AVFormatContext *s, } AVInputFormat ff_sox_demuxer = { - "sox", - NULL_IF_CONFIG_SMALL("SoX native format"), - 0, - sox_probe, - sox_read_header, - sox_read_packet, - NULL, - pcm_read_seek, + .name = "sox", + .long_name = NULL_IF_CONFIG_SMALL("SoX native format"), + .read_probe = sox_probe, + .read_header = sox_read_header, + .read_packet = sox_read_packet, + .read_seek = pcm_read_seek, }; diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c index d7afe70aac..b89203c542 100644 --- a/libavformat/soxenc.c +++ b/libavformat/soxenc.c @@ -116,14 +116,13 @@ static int sox_write_trailer(AVFormatContext *s) } AVOutputFormat ff_sox_muxer = { - "sox", - NULL_IF_CONFIG_SMALL("SoX native format"), - NULL, - "sox", - sizeof(SoXContext), - CODEC_ID_PCM_S32LE, - CODEC_ID_NONE, - sox_write_header, - sox_write_packet, - sox_write_trailer, + .name = "sox", + .long_name = NULL_IF_CONFIG_SMALL("SoX native format"), + .extensions = "sox", + .priv_data_size = sizeof(SoXContext), + .audio_codec = CODEC_ID_PCM_S32LE, + .video_codec = CODEC_ID_NONE, + .write_header = sox_write_header, + .write_packet = sox_write_packet, + .write_trailer = sox_write_trailer, }; diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c index 1c0902548c..fa2ddeb5e8 100644 --- a/libavformat/spdifdec.c +++ b/libavformat/spdifdec.c @@ -226,11 +226,10 @@ static int spdif_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_spdif_demuxer = { - "spdif", - NULL_IF_CONFIG_SMALL("IEC 61937 (compressed data in S/PDIF)"), - 0, - spdif_probe, - spdif_read_header, - spdif_read_packet, + .name = "spdif", + .long_name = NULL_IF_CONFIG_SMALL("IEC 61937 (compressed data in S/PDIF)"), + .read_probe = spdif_probe, + .read_header = spdif_read_header, + .read_packet = spdif_read_packet, .flags = AVFMT_GENERIC_INDEX, }; diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c index 735546096f..4773483f40 100644 --- a/libavformat/spdifenc.c +++ b/libavformat/spdifenc.c @@ -541,16 +541,15 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt) } AVOutputFormat ff_spdif_muxer = { - "spdif", - NULL_IF_CONFIG_SMALL("IEC 61937 (used on S/PDIF - IEC958)"), - NULL, - "spdif", - sizeof(IEC61937Context), - CODEC_ID_AC3, - CODEC_ID_NONE, - spdif_write_header, - spdif_write_packet, - spdif_write_trailer, + .name = "spdif", + .long_name = NULL_IF_CONFIG_SMALL("IEC 61937 (used on S/PDIF - IEC958)"), + .extensions = "spdif", + .priv_data_size = sizeof(IEC61937Context), + .audio_codec = CODEC_ID_AC3, + .video_codec = CODEC_ID_NONE, + .write_header = spdif_write_header, + .write_packet = spdif_write_packet, + .write_trailer = spdif_write_trailer, .flags = AVFMT_NOTIMESTAMPS, .priv_class = &class, }; diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index c838fa8e61..59977a94a6 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -207,10 +207,10 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_swf_demuxer = { - "swf", - NULL_IF_CONFIG_SMALL("Flash format"), - sizeof(SWFContext), - swf_probe, - swf_read_header, - swf_read_packet, + .name = "swf", + .long_name = NULL_IF_CONFIG_SMALL("Flash format"), + .priv_data_size = sizeof(SWFContext), + .read_probe = swf_probe, + .read_header = swf_read_header, + .read_packet = swf_read_packet, }; diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c index 4c5c3155ab..f4494cd63a 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -507,29 +507,28 @@ static int swf_write_trailer(AVFormatContext *s) #if CONFIG_SWF_MUXER AVOutputFormat ff_swf_muxer = { - "swf", - NULL_IF_CONFIG_SMALL("Flash format"), - "application/x-shockwave-flash", - "swf", - sizeof(SWFContext), - CODEC_ID_MP3, - CODEC_ID_FLV1, - swf_write_header, - swf_write_packet, - swf_write_trailer, + .name = "swf", + .long_name = NULL_IF_CONFIG_SMALL("Flash format"), + .mime_type = "application/x-shockwave-flash", + .extensions = "swf", + .priv_data_size = sizeof(SWFContext), + .audio_codec = CODEC_ID_MP3, + .video_codec = CODEC_ID_FLV1, + .write_header = swf_write_header, + .write_packet = swf_write_packet, + .write_trailer = swf_write_trailer, }; #endif #if CONFIG_AVM2_MUXER AVOutputFormat ff_avm2_muxer = { - "avm2", - NULL_IF_CONFIG_SMALL("Flash 9 (AVM2) format"), - "application/x-shockwave-flash", - NULL, - sizeof(SWFContext), - CODEC_ID_MP3, - CODEC_ID_FLV1, - swf_write_header, - swf_write_packet, - swf_write_trailer, + .name = "avm2", + .long_name = NULL_IF_CONFIG_SMALL("Flash 9 (AVM2) format"), + .mime_type = "application/x-shockwave-flash", + .priv_data_size = sizeof(SWFContext), + .audio_codec = CODEC_ID_MP3, + .video_codec = CODEC_ID_FLV1, + .write_header = swf_write_header, + .write_packet = swf_write_packet, + .write_trailer = swf_write_trailer, }; #endif diff --git a/libavformat/thp.c b/libavformat/thp.c index 51dbd810cd..3941977688 100644 --- a/libavformat/thp.c +++ b/libavformat/thp.c @@ -189,10 +189,10 @@ static int thp_read_packet(AVFormatContext *s, } AVInputFormat ff_thp_demuxer = { - "thp", - NULL_IF_CONFIG_SMALL("THP"), - sizeof(ThpDemuxContext), - thp_probe, - thp_read_header, - thp_read_packet + .name = "thp", + .long_name = NULL_IF_CONFIG_SMALL("THP"), + .priv_data_size = sizeof(ThpDemuxContext), + .read_probe = thp_probe, + .read_header = thp_read_header, + .read_packet = thp_read_packet }; diff --git a/libavformat/tiertexseq.c b/libavformat/tiertexseq.c index 7ca0464550..41ee3c61cb 100644 --- a/libavformat/tiertexseq.c +++ b/libavformat/tiertexseq.c @@ -303,11 +303,11 @@ static int seq_read_close(AVFormatContext *s) } AVInputFormat ff_tiertexseq_demuxer = { - "tiertexseq", - NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ format"), - sizeof(SeqDemuxContext), - seq_probe, - seq_read_header, - seq_read_packet, - seq_read_close, + .name = "tiertexseq", + .long_name = NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ format"), + .priv_data_size = sizeof(SeqDemuxContext), + .read_probe = seq_probe, + .read_header = seq_read_header, + .read_packet = seq_read_packet, + .read_close = seq_read_close, }; diff --git a/libavformat/tmv.c b/libavformat/tmv.c index fe8b64b3dd..10d78e18d8 100644 --- a/libavformat/tmv.c +++ b/libavformat/tmv.c @@ -179,13 +179,12 @@ static int tmv_read_seek(AVFormatContext *s, int stream_index, } AVInputFormat ff_tmv_demuxer = { - "tmv", - NULL_IF_CONFIG_SMALL("8088flex TMV"), - sizeof(TMVContext), - tmv_probe, - tmv_read_header, - tmv_read_packet, - NULL, - tmv_read_seek, + .name = "tmv", + .long_name = NULL_IF_CONFIG_SMALL("8088flex TMV"), + .priv_data_size = sizeof(TMVContext), + .read_probe = tmv_probe, + .read_header = tmv_read_header, + .read_packet = tmv_read_packet, + .read_seek = tmv_read_seek, .flags = AVFMT_GENERIC_INDEX, }; diff --git a/libavformat/tta.c b/libavformat/tta.c index 49234a81e4..d049d5e9c7 100644 --- a/libavformat/tta.c +++ b/libavformat/tta.c @@ -145,13 +145,12 @@ static int tta_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp } AVInputFormat ff_tta_demuxer = { - "tta", - NULL_IF_CONFIG_SMALL("True Audio"), - sizeof(TTAContext), - tta_probe, - tta_read_header, - tta_read_packet, - NULL, - tta_read_seek, + .name = "tta", + .long_name = NULL_IF_CONFIG_SMALL("True Audio"), + .priv_data_size = sizeof(TTAContext), + .read_probe = tta_probe, + .read_header = tta_read_header, + .read_packet = tta_read_packet, + .read_seek = tta_read_seek, .extensions = "tta", }; diff --git a/libavformat/vc1test.c b/libavformat/vc1test.c index 07f3247aa3..564b5eb03d 100644 --- a/libavformat/vc1test.c +++ b/libavformat/vc1test.c @@ -110,11 +110,10 @@ static int vc1t_read_packet(AVFormatContext *s, } AVInputFormat ff_vc1t_demuxer = { - "vc1test", - NULL_IF_CONFIG_SMALL("VC-1 test bitstream format"), - 0, - vc1t_probe, - vc1t_read_header, - vc1t_read_packet, + .name = "vc1test", + .long_name = NULL_IF_CONFIG_SMALL("VC-1 test bitstream format"), + .read_probe = vc1t_probe, + .read_header = vc1t_read_header, + .read_packet = vc1t_read_packet, .flags = AVFMT_GENERIC_INDEX, }; diff --git a/libavformat/vc1testenc.c b/libavformat/vc1testenc.c index 2b0728d248..0ee9b9000b 100644 --- a/libavformat/vc1testenc.c +++ b/libavformat/vc1testenc.c @@ -82,14 +82,14 @@ static int vc1test_write_trailer(AVFormatContext *s) } AVOutputFormat ff_vc1t_muxer = { - "rcv", - NULL_IF_CONFIG_SMALL("VC-1 test bitstream"), - "", - "rcv", - sizeof(RCVContext), - CODEC_ID_NONE, - CODEC_ID_WMV3, - vc1test_write_header, - vc1test_write_packet, - vc1test_write_trailer, + .name = "rcv", + .long_name = NULL_IF_CONFIG_SMALL("VC-1 test bitstream"), + .mime_type = "", + .extensions = "rcv", + .priv_data_size = sizeof(RCVContext), + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_WMV3, + .write_header = vc1test_write_header, + .write_packet = vc1test_write_packet, + .write_trailer = vc1test_write_trailer, }; diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c index eaa2f25492..23f1b0d579 100644 --- a/libavformat/vocdec.c +++ b/libavformat/vocdec.c @@ -157,11 +157,11 @@ static int voc_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_voc_demuxer = { - "voc", - NULL_IF_CONFIG_SMALL("Creative Voice file format"), - sizeof(VocDecContext), - voc_probe, - voc_read_header, - voc_read_packet, + .name = "voc", + .long_name = NULL_IF_CONFIG_SMALL("Creative Voice file format"), + .priv_data_size = sizeof(VocDecContext), + .read_probe = voc_probe, + .read_header = voc_read_header, + .read_packet = voc_read_packet, .codec_tag=(const AVCodecTag* const []){ff_voc_codec_tags, 0}, }; diff --git a/libavformat/vocenc.c b/libavformat/vocenc.c index bbb69c8c01..d0986bb02b 100644 --- a/libavformat/vocenc.c +++ b/libavformat/vocenc.c @@ -90,15 +90,15 @@ static int voc_write_trailer(AVFormatContext *s) } AVOutputFormat ff_voc_muxer = { - "voc", - NULL_IF_CONFIG_SMALL("Creative Voice file format"), - "audio/x-voc", - "voc", - sizeof(VocEncContext), - CODEC_ID_PCM_U8, - CODEC_ID_NONE, - voc_write_header, - voc_write_packet, - voc_write_trailer, + .name = "voc", + .long_name = NULL_IF_CONFIG_SMALL("Creative Voice file format"), + .mime_type = "audio/x-voc", + .extensions = "voc", + .priv_data_size = sizeof(VocEncContext), + .audio_codec = CODEC_ID_PCM_U8, + .video_codec = CODEC_ID_NONE, + .write_header = voc_write_header, + .write_packet = voc_write_packet, + .write_trailer = voc_write_trailer, .codec_tag=(const AVCodecTag* const []){ff_voc_codec_tags, 0}, }; diff --git a/libavformat/vqf.c b/libavformat/vqf.c index dd02abd70a..590d465c2a 100644 --- a/libavformat/vqf.c +++ b/libavformat/vqf.c @@ -250,13 +250,12 @@ static int vqf_read_seek(AVFormatContext *s, } AVInputFormat ff_vqf_demuxer = { - "vqf", - NULL_IF_CONFIG_SMALL("Nippon Telegraph and Telephone Corporation (NTT) TwinVQ"), - sizeof(VqfContext), - vqf_probe, - vqf_read_header, - vqf_read_packet, - NULL, - vqf_read_seek, + .name = "vqf", + .long_name = NULL_IF_CONFIG_SMALL("Nippon Telegraph and Telephone Corporation (NTT) TwinVQ"), + .priv_data_size = sizeof(VqfContext), + .read_probe = vqf_probe, + .read_header = vqf_read_header, + .read_packet = vqf_read_packet, + .read_seek = vqf_read_seek, .extensions = "vqf", }; diff --git a/libavformat/wav.c b/libavformat/wav.c index 1f12ad109a..ce8bec21ac 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -206,16 +206,16 @@ static const AVClass wav_muxer_class = { }; AVOutputFormat ff_wav_muxer = { - "wav", - NULL_IF_CONFIG_SMALL("WAV format"), - "audio/x-wav", - "wav", - sizeof(WAVContext), - CODEC_ID_PCM_S16LE, - CODEC_ID_NONE, - wav_write_header, - wav_write_packet, - wav_write_trailer, + .name = "wav", + .long_name = NULL_IF_CONFIG_SMALL("WAV format"), + .mime_type = "audio/x-wav", + .extensions = "wav", + .priv_data_size = sizeof(WAVContext), + .audio_codec = CODEC_ID_PCM_S16LE, + .video_codec = CODEC_ID_NONE, + .write_header = wav_write_header, + .write_packet = wav_write_packet, + .write_trailer = wav_write_trailer, .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0}, .priv_class = &wav_muxer_class, }; @@ -574,14 +574,13 @@ static int wav_read_seek(AVFormatContext *s, } AVInputFormat ff_wav_demuxer = { - "wav", - NULL_IF_CONFIG_SMALL("WAV format"), - sizeof(WAVContext), - wav_probe, - wav_read_header, - wav_read_packet, - NULL, - wav_read_seek, + .name = "wav", + .long_name = NULL_IF_CONFIG_SMALL("WAV format"), + .priv_data_size = sizeof(WAVContext), + .read_probe = wav_probe, + .read_header = wav_read_header, + .read_packet = wav_read_packet, + .read_seek = wav_read_seek, .flags= AVFMT_GENERIC_INDEX, .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0}, }; @@ -663,14 +662,13 @@ static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap) } AVInputFormat ff_w64_demuxer = { - "w64", - NULL_IF_CONFIG_SMALL("Sony Wave64 format"), - sizeof(WAVContext), - w64_probe, - w64_read_header, - wav_read_packet, - NULL, - wav_read_seek, + .name = "w64", + .long_name = NULL_IF_CONFIG_SMALL("Sony Wave64 format"), + .priv_data_size = sizeof(WAVContext), + .read_probe = w64_probe, + .read_header = w64_read_header, + .read_packet = wav_read_packet, + .read_seek = wav_read_seek, .flags = AVFMT_GENERIC_INDEX, .codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0}, }; diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c index 03483de737..0df9881887 100644 --- a/libavformat/wc3movie.c +++ b/libavformat/wc3movie.c @@ -292,11 +292,11 @@ static int wc3_read_close(AVFormatContext *s) } AVInputFormat ff_wc3_demuxer = { - "wc3movie", - NULL_IF_CONFIG_SMALL("Wing Commander III movie format"), - sizeof(Wc3DemuxContext), - wc3_probe, - wc3_read_header, - wc3_read_packet, - wc3_read_close, + .name = "wc3movie", + .long_name = NULL_IF_CONFIG_SMALL("Wing Commander III movie format"), + .priv_data_size = sizeof(Wc3DemuxContext), + .read_probe = wc3_probe, + .read_header = wc3_read_header, + .read_packet = wc3_read_packet, + .read_close = wc3_read_close, }; diff --git a/libavformat/westwood.c b/libavformat/westwood.c index 7c2b17d11c..cd05b5deb8 100644 --- a/libavformat/westwood.c +++ b/libavformat/westwood.c @@ -368,21 +368,21 @@ static int wsvqa_read_packet(AVFormatContext *s, #if CONFIG_WSAUD_DEMUXER AVInputFormat ff_wsaud_demuxer = { - "wsaud", - NULL_IF_CONFIG_SMALL("Westwood Studios audio format"), - sizeof(WsAudDemuxContext), - wsaud_probe, - wsaud_read_header, - wsaud_read_packet, + .name = "wsaud", + .long_name = NULL_IF_CONFIG_SMALL("Westwood Studios audio format"), + .priv_data_size = sizeof(WsAudDemuxContext), + .read_probe = wsaud_probe, + .read_header = wsaud_read_header, + .read_packet = wsaud_read_packet, }; #endif #if CONFIG_WSVQA_DEMUXER AVInputFormat ff_wsvqa_demuxer = { - "wsvqa", - NULL_IF_CONFIG_SMALL("Westwood Studios VQA format"), - sizeof(WsVqaDemuxContext), - wsvqa_probe, - wsvqa_read_header, - wsvqa_read_packet, + .name = "wsvqa", + .long_name = NULL_IF_CONFIG_SMALL("Westwood Studios VQA format"), + .priv_data_size = sizeof(WsVqaDemuxContext), + .read_probe = wsvqa_probe, + .read_header = wsvqa_read_header, + .read_packet = wsvqa_read_packet, }; #endif diff --git a/libavformat/wv.c b/libavformat/wv.c index d6d7099ba7..7cace17f0b 100644 --- a/libavformat/wv.c +++ b/libavformat/wv.c @@ -351,12 +351,11 @@ static int wv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, } AVInputFormat ff_wv_demuxer = { - "wv", - NULL_IF_CONFIG_SMALL("WavPack"), - sizeof(WVContext), - wv_probe, - wv_read_header, - wv_read_packet, - NULL, - wv_read_seek, + .name = "wv", + .long_name = NULL_IF_CONFIG_SMALL("WavPack"), + .priv_data_size = sizeof(WVContext), + .read_probe = wv_probe, + .read_header = wv_read_header, + .read_packet = wv_read_packet, + .read_seek = wv_read_seek, }; diff --git a/libavformat/xa.c b/libavformat/xa.c index c3421a34e7..7dd19585c2 100644 --- a/libavformat/xa.c +++ b/libavformat/xa.c @@ -119,10 +119,10 @@ static int xa_read_packet(AVFormatContext *s, } AVInputFormat ff_xa_demuxer = { - "xa", - NULL_IF_CONFIG_SMALL("Maxis XA File Format"), - sizeof(MaxisXADemuxContext), - xa_probe, - xa_read_header, - xa_read_packet, + .name = "xa", + .long_name = NULL_IF_CONFIG_SMALL("Maxis XA File Format"), + .priv_data_size = sizeof(MaxisXADemuxContext), + .read_probe = xa_probe, + .read_header = xa_read_header, + .read_packet = xa_read_packet, }; diff --git a/libavformat/xwma.c b/libavformat/xwma.c index d18ab48795..f383fd2077 100644 --- a/libavformat/xwma.c +++ b/libavformat/xwma.c @@ -252,10 +252,10 @@ static int xwma_read_packet(AVFormatContext *s, AVPacket *pkt) } AVInputFormat ff_xwma_demuxer = { - "xwma", - NULL_IF_CONFIG_SMALL("Microsoft xWMA"), - sizeof(XWMAContext), - xwma_probe, - xwma_read_header, - xwma_read_packet, + .name = "xwma", + .long_name = NULL_IF_CONFIG_SMALL("Microsoft xWMA"), + .priv_data_size = sizeof(XWMAContext), + .read_probe = xwma_probe, + .read_header = xwma_read_header, + .read_packet = xwma_read_packet, }; diff --git a/libavformat/yop.c b/libavformat/yop.c index bc29b0883e..76116fb6b6 100644 --- a/libavformat/yop.c +++ b/libavformat/yop.c @@ -202,14 +202,14 @@ static int yop_read_seek(AVFormatContext *s, int stream_index, } AVInputFormat ff_yop_demuxer = { - "yop", - NULL_IF_CONFIG_SMALL("Psygnosis YOP Format"), - sizeof(YopDecContext), - yop_probe, - yop_read_header, - yop_read_packet, - yop_read_close, - yop_read_seek, + .name = "yop", + .long_name = NULL_IF_CONFIG_SMALL("Psygnosis YOP Format"), + .priv_data_size = sizeof(YopDecContext), + .read_probe = yop_probe, + .read_header = yop_read_header, + .read_packet = yop_read_packet, + .read_close = yop_read_close, + .read_seek = yop_read_seek, .extensions = "yop", .flags = AVFMT_GENERIC_INDEX, }; diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c index 9a6a0c8315..37d8d8a028 100644 --- a/libavformat/yuv4mpeg.c +++ b/libavformat/yuv4mpeg.c @@ -170,15 +170,15 @@ static int yuv4_write_header(AVFormatContext *s) } AVOutputFormat ff_yuv4mpegpipe_muxer = { - "yuv4mpegpipe", - NULL_IF_CONFIG_SMALL("YUV4MPEG pipe format"), - "", - "y4m", - sizeof(int), - CODEC_ID_NONE, - CODEC_ID_RAWVIDEO, - yuv4_write_header, - yuv4_write_packet, + .name = "yuv4mpegpipe", + .long_name = NULL_IF_CONFIG_SMALL("YUV4MPEG pipe format"), + .mime_type = "", + .extensions = "y4m", + .priv_data_size = sizeof(int), + .audio_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_RAWVIDEO, + .write_header = yuv4_write_header, + .write_packet = yuv4_write_packet, .flags = AVFMT_RAWPICTURE, }; #endif @@ -391,12 +391,12 @@ static int yuv4_probe(AVProbeData *pd) #if CONFIG_YUV4MPEGPIPE_DEMUXER AVInputFormat ff_yuv4mpegpipe_demuxer = { - "yuv4mpegpipe", - NULL_IF_CONFIG_SMALL("YUV4MPEG pipe format"), - sizeof(struct frame_attributes), - yuv4_probe, - yuv4_read_header, - yuv4_read_packet, + .name = "yuv4mpegpipe", + .long_name = NULL_IF_CONFIG_SMALL("YUV4MPEG pipe format"), + .priv_data_size = sizeof(struct frame_attributes), + .read_probe = yuv4_probe, + .read_header = yuv4_read_header, + .read_packet = yuv4_read_packet, .extensions = "y4m" }; #endif From 25dfda7f318c570990aab5f699b9cb3e22bcd4c6 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Jul 2011 23:08:29 +0200 Subject: [PATCH 574/780] lavf: rename enc variable in utils.c:has_codec_parameters() Rename it to "avctx", the old name was confusing as the function is used also with decoder contexts. Signed-off-by: Anton Khirnov --- libavformat/utils.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 161cdb43f8..1ecbd61ff7 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2044,29 +2044,29 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset) } } -static int has_codec_parameters(AVCodecContext *enc) +static int has_codec_parameters(AVCodecContext *avctx) { int val; - switch(enc->codec_type) { + switch (avctx->codec_type) { case AVMEDIA_TYPE_AUDIO: - val = enc->sample_rate && enc->channels && enc->sample_fmt != AV_SAMPLE_FMT_NONE; - if(!enc->frame_size && - (enc->codec_id == CODEC_ID_VORBIS || - enc->codec_id == CODEC_ID_AAC || - enc->codec_id == CODEC_ID_MP1 || - enc->codec_id == CODEC_ID_MP2 || - enc->codec_id == CODEC_ID_MP3 || - enc->codec_id == CODEC_ID_SPEEX)) + val = avctx->sample_rate && avctx->channels && avctx->sample_fmt != AV_SAMPLE_FMT_NONE; + if (!avctx->frame_size && + (avctx->codec_id == CODEC_ID_VORBIS || + avctx->codec_id == CODEC_ID_AAC || + avctx->codec_id == CODEC_ID_MP1 || + avctx->codec_id == CODEC_ID_MP2 || + avctx->codec_id == CODEC_ID_MP3 || + avctx->codec_id == CODEC_ID_SPEEX)) return 0; break; case AVMEDIA_TYPE_VIDEO: - val = enc->width && enc->pix_fmt != PIX_FMT_NONE; + val = avctx->width && avctx->pix_fmt != PIX_FMT_NONE; break; default: val = 1; break; } - return enc->codec_id != CODEC_ID_NONE && val != 0; + return avctx->codec_id != CODEC_ID_NONE && val != 0; } static int has_decode_delay_been_guessed(AVStream *st) From a4e540c4f58f4c3b8d2cd924d6cd7ebf8183b074 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Jul 2011 23:08:06 +0200 Subject: [PATCH 575/780] ffplay: warn that -s is no longer working, suggest alternative Also remove now unused variables. Signed-off-by: Anton Khirnov --- doc/ffplay.texi | 4 ++-- ffplay.c | 14 +++----------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/doc/ffplay.texi b/doc/ffplay.texi index e5de3d2d6d..8e40c8fd3d 100644 --- a/doc/ffplay.texi +++ b/doc/ffplay.texi @@ -38,8 +38,8 @@ Force displayed width. @item -y @var{height} Force displayed height. @item -s @var{size} -Set frame size (WxH or abbreviation), needed for videos which don't -contain a header with the frame size like raw YUV. +This option has been removed. Use private format options for specifying the +input video size. @item -an Disable audio. @item -vn diff --git a/ffplay.c b/ffplay.c index 878ae833ef..35c40b5263 100644 --- a/ffplay.c +++ b/ffplay.c @@ -226,8 +226,6 @@ static int fs_screen_width; static int fs_screen_height; static int screen_width = 0; static int screen_height = 0; -static int frame_width = 0; -static int frame_height = 0; static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE; static int audio_disable; static int video_disable; @@ -2823,15 +2821,9 @@ static void event_loop(void) static int opt_frame_size(const char *opt, const char *arg) { - if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) { - fprintf(stderr, "Incorrect frame size\n"); - return AVERROR(EINVAL); - } - if ((frame_width % 2) != 0 || (frame_height % 2) != 0) { - fprintf(stderr, "Frame size must be a multiple of 2\n"); - return AVERROR(EINVAL); - } - return 0; + av_log(NULL, AV_LOG_ERROR, + "Option '%s' has been removed, use private format options instead\n", opt); + return AVERROR(EINVAL); } static int opt_width(const char *opt, const char *arg) From 0a858048af695e0d5788f0613fc2dc490572e1de Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Jul 2011 22:43:11 +0200 Subject: [PATCH 576/780] ffplay: warn that -pix_fmt is no longer working, suggest alternative Also remove now unused variable. Signed-off-by: Anton Khirnov --- doc/ffplay.texi | 3 ++- ffplay.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/ffplay.texi b/doc/ffplay.texi index 8e40c8fd3d..d60852603a 100644 --- a/doc/ffplay.texi +++ b/doc/ffplay.texi @@ -69,7 +69,8 @@ also sources and sinks). @section Advanced options @table @option @item -pix_fmt @var{format} -Set pixel format. +This option has been removed. Use private options for specifying the +input pixel format. @item -stats Show the stream duration, the codec parameters, the current position in the stream and the audio/video synchronisation drift. diff --git a/ffplay.c b/ffplay.c index 35c40b5263..77c9d4b2f3 100644 --- a/ffplay.c +++ b/ffplay.c @@ -226,7 +226,6 @@ static int fs_screen_width; static int fs_screen_height; static int screen_width = 0; static int screen_height = 0; -static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE; static int audio_disable; static int video_disable; static int wanted_stream[AVMEDIA_TYPE_NB]={ @@ -2850,8 +2849,9 @@ static int opt_format(const char *opt, const char *arg) static int opt_frame_pix_fmt(const char *opt, const char *arg) { - frame_pix_fmt = av_get_pix_fmt(arg); - return 0; + av_log(NULL, AV_LOG_ERROR, + "Option '%s' has been removed, use private format options instead\n", opt); + return AVERROR(EINVAL); } static int opt_sync(const char *opt, const char *arg) From fd065d3e799033ed0159f766067f3deefecaf48a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 7 Jul 2011 23:16:56 +0200 Subject: [PATCH 577/780] cabac: Move code only used in the cabac test program to cabac.c. --- libavcodec/cabac.c | 134 +++++++++++++++++++++++++++++++++++ libavcodec/cabac.h | 172 --------------------------------------------- 2 files changed, 134 insertions(+), 172 deletions(-) diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c index 4846b32e87..57ab395ed7 100644 --- a/libavcodec/cabac.c +++ b/libavcodec/cabac.c @@ -166,6 +166,140 @@ void ff_init_cabac_states(CABACContext *c){ #include "avcodec.h" #include "cabac.h" +static void put_cabac(CABACContext *c, uint8_t * const state, int bit){ + int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + *state]; + + if(bit == ((*state)&1)){ + c->range -= RangeLPS; + *state= ff_h264_mps_state[*state]; + }else{ + c->low += c->range - RangeLPS; + c->range = RangeLPS; + *state= ff_h264_lps_state[*state]; + } + + renorm_cabac_encoder(c); + +#ifdef STRICT_LIMITS + c->symCount++; +#endif +} + +/** + * @param bit 0 -> write zero bit, !=0 write one bit + */ +static void put_cabac_bypass(CABACContext *c, int bit){ + c->low += c->low; + + if(bit){ + c->low += c->range; + } +//FIXME optimize + if(c->low<0x200){ + put_cabac_bit(c, 0); + }else if(c->low<0x400){ + c->outstanding_count++; + c->low -= 0x200; + }else{ + put_cabac_bit(c, 1); + c->low -= 0x400; + } + +#ifdef STRICT_LIMITS + c->symCount++; +#endif +} + +/** + * + * @return the number of bytes written + */ +static int put_cabac_terminate(CABACContext *c, int bit){ + c->range -= 2; + + if(!bit){ + renorm_cabac_encoder(c); + }else{ + c->low += c->range; + c->range= 2; + + renorm_cabac_encoder(c); + + assert(c->low <= 0x1FF); + put_cabac_bit(c, c->low>>9); + put_bits(&c->pb, 2, ((c->low>>7)&3)|1); + + flush_put_bits(&c->pb); //FIXME FIXME FIXME XXX wrong + } + +#ifdef STRICT_LIMITS + c->symCount++; +#endif + + return (put_bits_count(&c->pb)+7)>>3; +} + +/** + * put (truncated) unary binarization. + */ +static void put_cabac_u(CABACContext *c, uint8_t * state, int v, int max, int max_index, int truncated){ + int i; + + assert(v <= max); + + for(i=0; i= m){ //FIXME optimize + put_cabac_bypass(c, 1); + v-= m; + m+= m; + } + put_cabac_bypass(c, 0); + while(m>>=1){ + put_cabac_bypass(c, v&m); + } + } + + if(is_signed) + put_cabac_bypass(c, sign); + } +} + int main(void){ CABACContext c; uint8_t b[9*SIZE]; diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index 57d1d70d29..126064276a 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -90,178 +90,6 @@ static inline void renorm_cabac_encoder(CABACContext *c){ } } -#ifdef TEST -static void put_cabac(CABACContext *c, uint8_t * const state, int bit){ - int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + *state]; - - if(bit == ((*state)&1)){ - c->range -= RangeLPS; - *state= ff_h264_mps_state[*state]; - }else{ - c->low += c->range - RangeLPS; - c->range = RangeLPS; - *state= ff_h264_lps_state[*state]; - } - - renorm_cabac_encoder(c); - -#ifdef STRICT_LIMITS - c->symCount++; -#endif -} - -static void put_cabac_static(CABACContext *c, int RangeLPS, int bit){ - assert(c->range > RangeLPS); - - if(!bit){ - c->range -= RangeLPS; - }else{ - c->low += c->range - RangeLPS; - c->range = RangeLPS; - } - - renorm_cabac_encoder(c); - -#ifdef STRICT_LIMITS - c->symCount++; -#endif -} - -/** - * @param bit 0 -> write zero bit, !=0 write one bit - */ -static void put_cabac_bypass(CABACContext *c, int bit){ - c->low += c->low; - - if(bit){ - c->low += c->range; - } -//FIXME optimize - if(c->low<0x200){ - put_cabac_bit(c, 0); - }else if(c->low<0x400){ - c->outstanding_count++; - c->low -= 0x200; - }else{ - put_cabac_bit(c, 1); - c->low -= 0x400; - } - -#ifdef STRICT_LIMITS - c->symCount++; -#endif -} - -/** - * - * @return the number of bytes written - */ -static int put_cabac_terminate(CABACContext *c, int bit){ - c->range -= 2; - - if(!bit){ - renorm_cabac_encoder(c); - }else{ - c->low += c->range; - c->range= 2; - - renorm_cabac_encoder(c); - - assert(c->low <= 0x1FF); - put_cabac_bit(c, c->low>>9); - put_bits(&c->pb, 2, ((c->low>>7)&3)|1); - - flush_put_bits(&c->pb); //FIXME FIXME FIXME XXX wrong - } - -#ifdef STRICT_LIMITS - c->symCount++; -#endif - - return (put_bits_count(&c->pb)+7)>>3; -} - -/** - * put (truncated) unary binarization. - */ -static void put_cabac_u(CABACContext *c, uint8_t * state, int v, int max, int max_index, int truncated){ - int i; - - assert(v <= max); - -#if 1 - for(i=0; i= m){ //FIXME optimize - put_cabac_bypass(c, 1); - v-= m; - m+= m; - } - put_cabac_bypass(c, 0); - while(m>>=1){ - put_cabac_bypass(c, v&m); - } - } - - if(is_signed) - put_cabac_bypass(c, sign); - } -} -#endif /* TEST */ - static void refill(CABACContext *c){ #if CABAC_BITS == 16 c->low+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1); From fc096e2e861e821a743bf9c42abee0fb41fff5d6 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 17 Jul 2011 14:05:03 +0200 Subject: [PATCH 578/780] Revert "Do not decode RV30 files if the extradata is too small" This commit is plain wrong, theres no reason to error out at this point nor is the error value guranteed to be negative as it should be This reverts commit 289c60001fb0a9a1d7a97c876d8a42b84c6874ac. --- libavcodec/rv30.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index c36bf44e8e..cd11079d52 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -256,7 +256,6 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx) if(avctx->extradata_size - 8 < (r->rpr - 1) * 2){ av_log(avctx, AV_LOG_ERROR, "Insufficient extradata - need at least %d bytes, got %d\n", 6 + r->rpr * 2, avctx->extradata_size); - return EINVAL; } r->parse_slice_header = rv30_parse_slice_header; r->decode_intra_types = rv30_decode_intra_types; From 0218808d4980b794c78f57931d671508aed500b5 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 17 Jul 2011 15:40:05 +0100 Subject: [PATCH 579/780] fate: separate lavf-mxf_d10 test from lavf-mxf Signed-off-by: Mans Rullgard --- configure | 2 +- tests/lavf-regression.sh | 3 +++ tests/ref/lavf/mxf | 3 --- tests/ref/lavf/mxf_d10 | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 tests/ref/lavf/mxf_d10 diff --git a/configure b/configure index 28e3e25f18..28e008fa1e 100755 --- a/configure +++ b/configure @@ -1573,7 +1573,7 @@ test_deps _muxer _demuxer \ mmf \ mov \ pcm_mulaw=mulaw \ - mxf \ + mxf="mxf mxf_d10" \ nut \ ogg \ rawvideo=pixfmt \ diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh index 6d2d6d8162..38a190cecf 100755 --- a/tests/lavf-regression.sh +++ b/tests/lavf-regression.sh @@ -64,6 +64,9 @@ fi if [ -n "$do_mxf" ] ; then do_lavf mxf "-ar 48000 -bf 2 -timecode_frame_start 264363" +fi + +if [ -n "$do_mxf_d10" ]; then do_lavf mxf_d10 "-ar 48000 -ac 2 -r 25 -s 720x576 -vf pad=720:608:0:32 -vcodec mpeg2video -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -qscale 1 -ps 1 -qmin 1 -rc_max_vbv_use 1 -rc_min_vbv_use 1 -pix_fmt yuv422p -minrate 30000k -maxrate 30000k -b 30000k -bufsize 1200000 -top 1 -rc_init_occupancy 1200000 -qmax 12 -f mxf_d10" fi diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf index d4bbe2f25e..b5aea3c17e 100644 --- a/tests/ref/lavf/mxf +++ b/tests/ref/lavf/mxf @@ -1,6 +1,3 @@ 6e9bd63c5cadd7550ad313553ebf665f *./tests/data/lavf/lavf.mxf 525881 ./tests/data/lavf/lavf.mxf ./tests/data/lavf/lavf.mxf CRC=0x4ace0849 -e7168856f2b54c6272685967e707fb21 *./tests/data/lavf/lavf.mxf_d10 -5330989 ./tests/data/lavf/lavf.mxf_d10 -./tests/data/lavf/lavf.mxf_d10 CRC=0xc3f4f92e diff --git a/tests/ref/lavf/mxf_d10 b/tests/ref/lavf/mxf_d10 new file mode 100644 index 0000000000..f59a99ee0f --- /dev/null +++ b/tests/ref/lavf/mxf_d10 @@ -0,0 +1,3 @@ +e7168856f2b54c6272685967e707fb21 *./tests/data/lavf/lavf.mxf_d10 +5330989 ./tests/data/lavf/lavf.mxf_d10 +./tests/data/lavf/lavf.mxf_d10 CRC=0xc3f4f92e From 9cab9421ce3f6254e695b2b2bd31d28099162daf Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 17 Jul 2011 13:35:21 +0200 Subject: [PATCH 580/780] vc1: remove disabled code --- libavcodec/vc1data.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h index 1ccc9bbf6e..131fd3a0ca 100644 --- a/libavcodec/vc1data.h +++ b/libavcodec/vc1data.h @@ -74,20 +74,11 @@ extern VLC ff_vc1_ac_coeff_table[8]; //@} -#if 0 //original bfraction from vc9data.h, not conforming to standard -/* Denominator used for ff_vc1_bfraction_lut */ -#define B_FRACTION_DEN 840 - -/* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */ -extern const int16_t ff_vc1_bfraction_lut[23]; -#else /* Denominator used for ff_vc1_bfraction_lut */ #define B_FRACTION_DEN 256 /* pre-computed scales for all bfractions and base=256 */ extern const int16_t ff_vc1_bfraction_lut[23]; -#endif - extern const uint8_t ff_vc1_bfraction_bits[23]; extern const uint8_t ff_vc1_bfraction_codes[23]; From 473e547e80fd74c44179905a4fa99cfc39cc9b79 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 17 Jul 2011 13:28:11 +0200 Subject: [PATCH 581/780] motion_est: remove disabled code --- libavcodec/motion_est.c | 52 ------------ libavcodec/motion_est_template.c | 141 ------------------------------- 2 files changed, 193 deletions(-) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 86b357d9f2..4ad47faf66 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -374,30 +374,6 @@ int ff_init_me(MpegEncContext *s){ return 0; } -#if 0 -static int pix_dev(uint8_t * pix, int line_size, int mean) -{ - int s, i, j; - - s = 0; - for (i = 0; i < 16; i++) { - for (j = 0; j < 16; j += 8) { - s += FFABS(pix[0]-mean); - s += FFABS(pix[1]-mean); - s += FFABS(pix[2]-mean); - s += FFABS(pix[3]-mean); - s += FFABS(pix[4]-mean); - s += FFABS(pix[5]-mean); - s += FFABS(pix[6]-mean); - s += FFABS(pix[7]-mean); - pix += 8; - } - pix += line_size - 16; - } - return s; -} -#endif - static inline void no_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr) { @@ -1214,30 +1190,6 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, intra_score= s->dsp.mb_cmp[0](s, c->scratchpad, pix, s->linesize, 16); } -#if 0 //FIXME - /* get chroma score */ - if(c->avctx->mb_cmp&FF_CMP_CHROMA){ - for(i=1; i<3; i++){ - uint8_t *dest_c; - int mean; - - if(s->out_format == FMT_H263){ - mean= (s->dc_val[i][mb_x + mb_y*s->b8_stride] + 4)>>3; //FIXME not exact but simple ;) - }else{ - mean= (s->last_dc[i] + 4)>>3; - } - dest_c = s->new_picture.f.data[i] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; - - mean*= 0x01010101; - for(i=0; i<8; i++){ - *(uint32_t*)(&c->scratchpad[i*s->uvlinesize+ 0]) = mean; - *(uint32_t*)(&c->scratchpad[i*s->uvlinesize+ 4]) = mean; - } - - intra_score+= s->dsp.mb_cmp[1](s, c->scratchpad, dest_c, s->uvlinesize); - } - } -#endif intra_score += c->mb_penalty_factor*16; if(intra_score < dmin){ @@ -1850,10 +1802,6 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, if(dmin>256*256*16) type&= ~CANDIDATE_MB_TYPE_DIRECT; //do not try direct mode if it is invalid for this MB if(s->codec_id == CODEC_ID_MPEG4 && type&CANDIDATE_MB_TYPE_DIRECT && s->flags&CODEC_FLAG_MV0 && *(uint32_t*)s->b_direct_mv_table[xy]) type |= CANDIDATE_MB_TYPE_DIRECT0; -#if 0 - if(s->out_format == FMT_MPEG1) - type |= CANDIDATE_MB_TYPE_INTRA; -#endif } s->mb_type[mb_y*s->mb_stride + mb_x]= type; diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index 576bb3da43..88e23ae9d4 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -44,75 +44,6 @@ COPY3_IF_LT(dmin, d, bx, hx, by, hy)\ } -#if 0 -static int hpel_motion_search)(MpegEncContext * s, - int *mx_ptr, int *my_ptr, int dmin, - uint8_t *ref_data[3], - int size) -{ - const int xx = 16 * s->mb_x + 8*(n&1); - const int yy = 16 * s->mb_y + 8*(n>>1); - const int mx = *mx_ptr; - const int my = *my_ptr; - const int penalty_factor= c->sub_penalty_factor; - - LOAD_COMMON - - // INIT; - //FIXME factorize - me_cmp_func cmp, chroma_cmp, cmp_sub, chroma_cmp_sub; - - if(s->no_rounding /*FIXME b_type*/){ - hpel_put= &s->dsp.put_no_rnd_pixels_tab[size]; - chroma_hpel_put= &s->dsp.put_no_rnd_pixels_tab[size+1]; - }else{ - hpel_put=& s->dsp.put_pixels_tab[size]; - chroma_hpel_put= &s->dsp.put_pixels_tab[size+1]; - } - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; - cmp_sub= s->dsp.me_sub_cmp[size]; - chroma_cmp_sub= s->dsp.me_sub_cmp[size+1]; - - if(c->skip){ //FIXME somehow move up (benchmark) - *mx_ptr = 0; - *my_ptr = 0; - return dmin; - } - - if(c->avctx->me_cmp != c->avctx->me_sub_cmp){ - CMP_HPEL(dmin, 0, 0, mx, my, size); - if(mx || my) - dmin += (mv_penalty[2*mx - pred_x] + mv_penalty[2*my - pred_y])*penalty_factor; - } - - if (mx > xmin && mx < xmax && - my > ymin && my < ymax) { - int bx=2*mx, by=2*my; - int d= dmin; - - CHECK_HALF_MV(1, 1, mx-1, my-1) - CHECK_HALF_MV(0, 1, mx , my-1) - CHECK_HALF_MV(1, 1, mx , my-1) - CHECK_HALF_MV(1, 0, mx-1, my ) - CHECK_HALF_MV(1, 0, mx , my ) - CHECK_HALF_MV(1, 1, mx-1, my ) - CHECK_HALF_MV(0, 1, mx , my ) - CHECK_HALF_MV(1, 1, mx , my ) - - assert(bx >= xmin*2 || bx <= xmax*2 || by >= ymin*2 || by <= ymax*2); - - *mx_ptr = bx; - *my_ptr = by; - }else{ - *mx_ptr =2*mx; - *my_ptr =2*my; - } - - return dmin; -} - -#else static int hpel_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, @@ -218,7 +149,6 @@ static int hpel_motion_search(MpegEncContext * s, return dmin; } -#endif static int no_sub_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr, int dmin, @@ -321,7 +251,6 @@ static int qpel_motion_search(MpegEncContext * s, int best_pos[8][2]; memset(best, 64, sizeof(int)*8); -#if 1 if(s->me.dia_size>=2){ const int tl= score_map[(index-(1<>2, ny>>2) } -#if 0 - const int tl= score_map[(index-(1<>2, (ny + oy[i])>>2) - } -#endif -#if 0 - //outer ring - CHECK_QUARTER_MV(1, 3, mx-1, my-1) - CHECK_QUARTER_MV(1, 2, mx-1, my-1) - CHECK_QUARTER_MV(1, 1, mx-1, my-1) - CHECK_QUARTER_MV(2, 1, mx-1, my-1) - CHECK_QUARTER_MV(3, 1, mx-1, my-1) - CHECK_QUARTER_MV(0, 1, mx , my-1) - CHECK_QUARTER_MV(1, 1, mx , my-1) - CHECK_QUARTER_MV(2, 1, mx , my-1) - CHECK_QUARTER_MV(3, 1, mx , my-1) - CHECK_QUARTER_MV(3, 2, mx , my-1) - CHECK_QUARTER_MV(3, 3, mx , my-1) - CHECK_QUARTER_MV(3, 0, mx , my ) - CHECK_QUARTER_MV(3, 1, mx , my ) - CHECK_QUARTER_MV(3, 2, mx , my ) - CHECK_QUARTER_MV(3, 3, mx , my ) - CHECK_QUARTER_MV(2, 3, mx , my ) - CHECK_QUARTER_MV(1, 3, mx , my ) - CHECK_QUARTER_MV(0, 3, mx , my ) - CHECK_QUARTER_MV(3, 3, mx-1, my ) - CHECK_QUARTER_MV(2, 3, mx-1, my ) - CHECK_QUARTER_MV(1, 3, mx-1, my ) - CHECK_QUARTER_MV(1, 2, mx-1, my ) - CHECK_QUARTER_MV(1, 1, mx-1, my ) - CHECK_QUARTER_MV(1, 0, mx-1, my ) -#endif assert(bx >= xmin*4 && bx <= xmax*4 && by >= ymin*4 && by <= ymax*4); *mx_ptr = bx; From e0ae2174dbbc8528008afb3549e1673dff96db4d Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 17 Jul 2011 13:30:00 +0200 Subject: [PATCH 582/780] simple_idct: remove disabled code --- libavcodec/simple_idct.c | 12 --- libavcodec/x86/simple_idct_mmx.c | 133 ------------------------------- 2 files changed, 145 deletions(-) diff --git a/libavcodec/simple_idct.c b/libavcodec/simple_idct.c index 4af11bec51..d21e5ed340 100644 --- a/libavcodec/simple_idct.c +++ b/libavcodec/simple_idct.c @@ -34,17 +34,6 @@ #include "mathops.h" #include "simple_idct.h" -#if 0 -#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */ -#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */ -#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */ -#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */ -#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */ -#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */ -#define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */ -#define ROW_SHIFT 8 -#define COL_SHIFT 17 -#else #define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 @@ -54,7 +43,6 @@ #define W7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define ROW_SHIFT 11 #define COL_SHIFT 20 // 6 -#endif static inline void idctRowCondDC (DCTELEM * row) { diff --git a/libavcodec/x86/simple_idct_mmx.c b/libavcodec/x86/simple_idct_mmx.c index d78ae6b508..dc285cf728 100644 --- a/libavcodec/x86/simple_idct_mmx.c +++ b/libavcodec/x86/simple_idct_mmx.c @@ -37,11 +37,7 @@ #define C1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define C2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define C3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 -#if 0 -#define C4 16384 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 -#else #define C4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) - 0.5 -#endif #define C5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define C6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define C7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 @@ -80,135 +76,6 @@ DECLARE_ALIGNED(8, static const int16_t, coeffs)[]= { C3, -C1, C3, -C1 }; -#if 0 -static void unused_var_killer(void) -{ - int a= wm1010 + d40000; - temp[0]=a; -} - -static void inline idctCol (int16_t * col, int16_t *input) -{ -#undef C0 -#undef C1 -#undef C2 -#undef C3 -#undef C4 -#undef C5 -#undef C6 -#undef C7 - int a0, a1, a2, a3, b0, b1, b2, b3; - const int C0 = 23170; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C1 = 22725; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C2 = 21407; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C3 = 19266; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C4 = 16383; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C5 = 12873; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C6 = 8867; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C7 = 4520; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 -/* - if( !(col[8*1] | col[8*2] |col[8*3] |col[8*4] |col[8*5] |col[8*6] | col[8*7])) { - col[8*0] = col[8*1] = col[8*2] = col[8*3] = col[8*4] = - col[8*5] = col[8*6] = col[8*7] = col[8*0]<<3; - return; - }*/ - -col[8*0] = input[8*0 + 0]; -col[8*1] = input[8*2 + 0]; -col[8*2] = input[8*0 + 1]; -col[8*3] = input[8*2 + 1]; -col[8*4] = input[8*4 + 0]; -col[8*5] = input[8*6 + 0]; -col[8*6] = input[8*4 + 1]; -col[8*7] = input[8*6 + 1]; - - a0 = C4*col[8*0] + C2*col[8*2] + C4*col[8*4] + C6*col[8*6] + (1<<(COL_SHIFT-1)); - a1 = C4*col[8*0] + C6*col[8*2] - C4*col[8*4] - C2*col[8*6] + (1<<(COL_SHIFT-1)); - a2 = C4*col[8*0] - C6*col[8*2] - C4*col[8*4] + C2*col[8*6] + (1<<(COL_SHIFT-1)); - a3 = C4*col[8*0] - C2*col[8*2] + C4*col[8*4] - C6*col[8*6] + (1<<(COL_SHIFT-1)); - - b0 = C1*col[8*1] + C3*col[8*3] + C5*col[8*5] + C7*col[8*7]; - b1 = C3*col[8*1] - C7*col[8*3] - C1*col[8*5] - C5*col[8*7]; - b2 = C5*col[8*1] - C1*col[8*3] + C7*col[8*5] + C3*col[8*7]; - b3 = C7*col[8*1] - C5*col[8*3] + C3*col[8*5] - C1*col[8*7]; - - col[8*0] = (a0 + b0) >> COL_SHIFT; - col[8*1] = (a1 + b1) >> COL_SHIFT; - col[8*2] = (a2 + b2) >> COL_SHIFT; - col[8*3] = (a3 + b3) >> COL_SHIFT; - col[8*4] = (a3 - b3) >> COL_SHIFT; - col[8*5] = (a2 - b2) >> COL_SHIFT; - col[8*6] = (a1 - b1) >> COL_SHIFT; - col[8*7] = (a0 - b0) >> COL_SHIFT; -} - -static void inline idctRow (int16_t * output, int16_t * input) -{ - int16_t row[8]; - - int a0, a1, a2, a3, b0, b1, b2, b3; - const int C0 = 23170; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C1 = 22725; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C2 = 21407; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C3 = 19266; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C4 = 16383; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C5 = 12873; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C6 = 8867; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - const int C7 = 4520; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 - -row[0] = input[0]; -row[2] = input[1]; -row[4] = input[4]; -row[6] = input[5]; -row[1] = input[8]; -row[3] = input[9]; -row[5] = input[12]; -row[7] = input[13]; - - if( !(row[1] | row[2] |row[3] |row[4] |row[5] |row[6] | row[7]) ) { - row[0] = row[1] = row[2] = row[3] = row[4] = - row[5] = row[6] = row[7] = row[0]<<3; - output[0] = row[0]; - output[2] = row[1]; - output[4] = row[2]; - output[6] = row[3]; - output[8] = row[4]; - output[10] = row[5]; - output[12] = row[6]; - output[14] = row[7]; - return; - } - - a0 = C4*row[0] + C2*row[2] + C4*row[4] + C6*row[6] + (1<<(ROW_SHIFT-1)); - a1 = C4*row[0] + C6*row[2] - C4*row[4] - C2*row[6] + (1<<(ROW_SHIFT-1)); - a2 = C4*row[0] - C6*row[2] - C4*row[4] + C2*row[6] + (1<<(ROW_SHIFT-1)); - a3 = C4*row[0] - C2*row[2] + C4*row[4] - C6*row[6] + (1<<(ROW_SHIFT-1)); - - b0 = C1*row[1] + C3*row[3] + C5*row[5] + C7*row[7]; - b1 = C3*row[1] - C7*row[3] - C1*row[5] - C5*row[7]; - b2 = C5*row[1] - C1*row[3] + C7*row[5] + C3*row[7]; - b3 = C7*row[1] - C5*row[3] + C3*row[5] - C1*row[7]; - - row[0] = (a0 + b0) >> ROW_SHIFT; - row[1] = (a1 + b1) >> ROW_SHIFT; - row[2] = (a2 + b2) >> ROW_SHIFT; - row[3] = (a3 + b3) >> ROW_SHIFT; - row[4] = (a3 - b3) >> ROW_SHIFT; - row[5] = (a2 - b2) >> ROW_SHIFT; - row[6] = (a1 - b1) >> ROW_SHIFT; - row[7] = (a0 - b0) >> ROW_SHIFT; - - output[0] = row[0]; - output[2] = row[1]; - output[4] = row[2]; - output[6] = row[3]; - output[8] = row[4]; - output[10] = row[5]; - output[12] = row[6]; - output[14] = row[7]; -} -#endif - static inline void idct(int16_t *block) { DECLARE_ALIGNED(8, int64_t, align_tmp)[16]; From e9f98c90229999c0e654bd77af55d7020347440a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 17 Jul 2011 15:27:14 +0100 Subject: [PATCH 583/780] ffmpeg: fix operation with --disable-avfilter The width and height must be copied from the input before being used. Signed-off-by: Mans Rullgard --- ffmpeg.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index cbbd3e7b1e..de5b8c28e3 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2219,6 +2219,12 @@ static int transcode(AVFormatContext **output_files, fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); ffmpeg_exit(1); } + + if (!codec->width || !codec->height) { + codec->width = icodec->width; + codec->height = icodec->height; + } + ost->video_resample = codec->width != icodec->width || codec->height != icodec->height || codec->pix_fmt != icodec->pix_fmt; @@ -2245,10 +2251,7 @@ static int transcode(AVFormatContext **output_files, #endif codec->bits_per_raw_sample= 0; } - if (!codec->width || !codec->height) { - codec->width = icodec->width; - codec->height = icodec->height; - } + ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; From 08e09ed7db732ebc53b8c60d7a39ac0abd49694f Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 17 Jul 2011 15:27:41 +0100 Subject: [PATCH 584/780] ffmpeg: fix some indentation Signed-off-by: Mans Rullgard --- ffmpeg.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index de5b8c28e3..776cfabacd 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2232,18 +2232,18 @@ static int transcode(AVFormatContext **output_files, #if !CONFIG_AVFILTER avcodec_get_frame_defaults(&ost->pict_tmp); if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt, - codec->width, codec->height)) { + codec->width, codec->height)) { fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n"); ffmpeg_exit(1); } ost->img_resample_ctx = sws_getContext( icodec->width, icodec->height, - icodec->pix_fmt, - codec->width, - codec->height, - codec->pix_fmt, - ost->sws_flags, NULL, NULL, NULL); + icodec->pix_fmt, + codec->width, + codec->height, + codec->pix_fmt, + ost->sws_flags, NULL, NULL, NULL); if (ost->img_resample_ctx == NULL) { fprintf(stderr, "Cannot get resampling context\n"); ffmpeg_exit(1); From 172ee1da2b2b7c84733822092eb29fcaec102055 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 17 Jul 2011 14:17:10 +0100 Subject: [PATCH 585/780] random_seed: use proper #includes Use <> for system headers, add needed math.h, drop unnecessary avutil.h. Signed-off-by: Mans Rullgard --- libavutil/random_seed.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c index a1078d8bbb..ee71542652 100644 --- a/libavutil/random_seed.c +++ b/libavutil/random_seed.c @@ -20,10 +20,10 @@ #include #include +#include +#include #include "timer.h" -#include "time.h" #include "random_seed.h" -#include "avutil.h" static int read_random(uint32_t *dst, const char *file) { From 8f62ef0f95cd0bc915086a9d3d66b27fceb6916f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 17 Jul 2011 18:43:11 +0300 Subject: [PATCH 586/780] x86: Use LOCAL_ALIGNED in mpegvideo_mmx_template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/x86/mpegvideo_mmx_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/x86/mpegvideo_mmx_template.c b/libavcodec/x86/mpegvideo_mmx_template.c index 0f01cb24b9..0b6cff3540 100644 --- a/libavcodec/x86/mpegvideo_mmx_template.c +++ b/libavcodec/x86/mpegvideo_mmx_template.c @@ -98,7 +98,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s, x86_reg last_non_zero_p1; int level=0, q; //=0 is because gcc says uninitialized ... const uint16_t *qmat, *bias; - DECLARE_ALIGNED(16, int16_t, temp_block)[64]; + LOCAL_ALIGNED_16(int16_t, temp_block, [64]); assert((7&(int)(&temp_block[0])) == 0); //did gcc align it correctly? From 6eaaf8da88f8fff9160c92c84128c182f934e0d9 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 17 Jul 2011 23:51:10 +0200 Subject: [PATCH 587/780] gxfenc: place variable declarations before statements libavformat/gxfenc.c:409: warning: ISO C90 forbids mixed declarations and code --- libavformat/gxfenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 11e1ea5798..89969b26e1 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -396,6 +396,7 @@ static int gxf_write_umf_material_description(AVFormatContext *s) int timecode_base = gxf->time_base.den == 60000 ? 60 : 50; int64_t timestamp = 0; AVDictionaryEntry *t; + uint32_t timecode; #if FF_API_TIMESTAMP if (s->timestamp) @@ -406,7 +407,7 @@ static int gxf_write_umf_material_description(AVFormatContext *s) timestamp = ff_iso8601_to_unix_time(t->value); // XXX drop frame - uint32_t timecode = + timecode = gxf->nb_fields / (timecode_base * 3600) % 24 << 24 | // hours gxf->nb_fields / (timecode_base * 60) % 60 << 16 | // minutes gxf->nb_fields / timecode_base % 60 << 8 | // seconds From c99c0e2625d5f19854586fc2142c673ce05c9f40 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 17 Jul 2011 13:26:53 +0200 Subject: [PATCH 588/780] tta: remove disabled code --- libavcodec/tta.c | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 001b1197b6..96de9c3202 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -66,23 +66,6 @@ typedef struct TTAContext { TTAChannel *ch_ctx; } TTAContext; -#if 0 -static inline int shift_1(int i) -{ - if (i < 32) - return 1 << i; - else - return 0x80000000; // 16 << 31 -} - -static inline int shift_16(int i) -{ - if (i < 28) - return 16 << i; - else - return 0x80000000; // 16 << 27 -} -#else static const uint32_t shift_1[] = { 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000020, 0x00000040, 0x00000080, @@ -97,7 +80,6 @@ static const uint32_t shift_1[] = { }; static const uint32_t * const shift_16 = shift_1 + 4; -#endif static const int32_t ttafilter_configs[4][2] = { {10, 1}, @@ -389,19 +371,6 @@ static int tta_decode_frame(AVCodecContext *avctx, } *predictor = *p; -#if 0 - // extract 32bit float from last two int samples - if (s->is_float && ((p - data) & 1)) { - uint32_t neg = *p & 0x80000000; - uint32_t hi = *(p - 1); - uint32_t lo = abs(*p) - 1; - - hi += (hi || lo) ? 0x3f80 : 0; - // SWAP16: swap all the 16 bits - *(p - 1) = (hi << 16) | SWAP16(lo) | neg; - } -#endif - /*if ((get_bits_count(&s->gb)+7)/8 > buf_size) { av_log(NULL, AV_LOG_INFO, "overread!!\n"); From 65083b49117cb64c0e9a3741da9ed1cfbf64aff3 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 17 Jul 2011 13:29:13 +0200 Subject: [PATCH 589/780] dsputil: remove disabled code --- libavcodec/dsputil.c | 32 ----------------------------- libavcodec/x86/dsputil_mmx.c | 39 ------------------------------------ 2 files changed, 71 deletions(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 8bb7dc1181..6cbbf3d82e 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -175,16 +175,6 @@ static int pix_norm1_c(uint8_t * pix, int line_size) s = 0; for (i = 0; i < 16; i++) { for (j = 0; j < 16; j += 8) { -#if 0 - s += sq[pix[0]]; - s += sq[pix[1]]; - s += sq[pix[2]]; - s += sq[pix[3]]; - s += sq[pix[4]]; - s += sq[pix[5]]; - s += sq[pix[6]]; - s += sq[pix[7]]; -#else #if LONG_MAX > 2147483647 register uint64_t x=*(uint64_t*)pix; s += sq[x&0xff]; @@ -206,7 +196,6 @@ static int pix_norm1_c(uint8_t * pix, int line_size) s += sq[(x>>8)&0xff]; s += sq[(x>>16)&0xff]; s += sq[(x>>24)&0xff]; -#endif #endif pix += 8; } @@ -819,27 +808,6 @@ static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int dst += stride; } } -#if 0 -#define TPEL_WIDTH(width)\ -static void put_tpel_pixels ## width ## _mc00_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc00_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc10_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc10_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc20_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc20_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc01_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc01_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc11_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc11_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc21_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc21_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc02_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc02_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc12_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc12_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc22_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc22_c(dst, src, stride, width, height);} -#endif #define QPEL_MC(r, OPNAME, RND, OP) \ static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 4e84f63378..29fff276ad 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -1665,10 +1665,6 @@ QPEL_2TAP(put_, 8, 3dnow) QPEL_2TAP(avg_, 8, 3dnow) -#if 0 -static void just_return(void) { return; } -#endif - #if HAVE_YASM typedef void emu_edge_core_func (uint8_t *buf, const uint8_t *src, x86_reg linesize, x86_reg start_y, @@ -2953,39 +2949,4 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) if (CONFIG_ENCODERS) dsputilenc_init_mmx(c, avctx); - -#if 0 - // for speed testing - get_pixels = just_return; - put_pixels_clamped = just_return; - add_pixels_clamped = just_return; - - pix_abs16x16 = just_return; - pix_abs16x16_x2 = just_return; - pix_abs16x16_y2 = just_return; - pix_abs16x16_xy2 = just_return; - - put_pixels_tab[0] = just_return; - put_pixels_tab[1] = just_return; - put_pixels_tab[2] = just_return; - put_pixels_tab[3] = just_return; - - put_no_rnd_pixels_tab[0] = just_return; - put_no_rnd_pixels_tab[1] = just_return; - put_no_rnd_pixels_tab[2] = just_return; - put_no_rnd_pixels_tab[3] = just_return; - - avg_pixels_tab[0] = just_return; - avg_pixels_tab[1] = just_return; - avg_pixels_tab[2] = just_return; - avg_pixels_tab[3] = just_return; - - avg_no_rnd_pixels_tab[0] = just_return; - avg_no_rnd_pixels_tab[1] = just_return; - avg_no_rnd_pixels_tab[2] = just_return; - avg_no_rnd_pixels_tab[3] = just_return; - - //av_fdct = just_return; - //ff_idct = just_return; -#endif } From 9bc8bcddbd4fc394e2268e9849dcbf3bad6de980 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 15 Jul 2011 15:40:31 +0200 Subject: [PATCH 590/780] vf_libopencv: replace opencv/cxtypes.h #include by opencv/cxcore.h cxtypes.h works with version 2.1 and older, cxcore.h works with 2.2 and older. Signed-off-by: Diego Biurrun --- libavfilter/vf_libopencv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c index 5a52f246ba..6e343af7ef 100644 --- a/libavfilter/vf_libopencv.c +++ b/libavfilter/vf_libopencv.c @@ -26,7 +26,7 @@ /* #define DEBUG */ #include -#include +#include #include "libavutil/avstring.h" #include "libavutil/file.h" #include "avfilter.h" From 93263dc19e441f347baf9c36b5bc83693f16d084 Mon Sep 17 00:00:00 2001 From: ami_stuff Date: Mon, 18 Jul 2011 13:59:30 +0200 Subject: [PATCH 591/780] au: add computation for duration Signed-off-by: Stefano Sabatini --- libavformat/au.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/au.c b/libavformat/au.c index f01c853a59..593442807c 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -120,7 +120,7 @@ static int au_probe(AVProbeData *p) static int au_read_header(AVFormatContext *s, AVFormatParameters *ap) { - int size; + int size, data_size = 0; unsigned int tag; AVIOContext *pb = s->pb; unsigned int id, channels, rate; @@ -132,7 +132,12 @@ static int au_read_header(AVFormatContext *s, if (tag != MKTAG('.', 's', 'n', 'd')) return -1; size = avio_rb32(pb); /* header size */ - avio_rb32(pb); /* data size */ + data_size = avio_rb32(pb); /* data size in bytes */ + + if (data_size < 0) { + av_log(s, AV_LOG_ERROR, "Invalid negative data size '%d' found\n", data_size); + return AVERROR_INVALIDDATA; + } id = avio_rb32(pb); rate = avio_rb32(pb); @@ -159,6 +164,7 @@ static int au_read_header(AVFormatContext *s, st->codec->codec_id = codec; st->codec->channels = channels; st->codec->sample_rate = rate; + st->duration = (((int64_t)data_size)<<3) / (st->codec->channels * av_get_bits_per_sample(codec)); av_set_pts_info(st, 64, 1, rate); return 0; } From e463f0e9790b4ee00b1a0572e5de600476ee0618 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 18 Jul 2011 18:03:28 +0200 Subject: [PATCH 592/780] dsputil: restore mistakenly removed hunk of disabled code This particular part serves to document the optimized code variant. --- libavcodec/dsputil.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 6cbbf3d82e..f24985ce4c 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -175,6 +175,16 @@ static int pix_norm1_c(uint8_t * pix, int line_size) s = 0; for (i = 0; i < 16; i++) { for (j = 0; j < 16; j += 8) { +#if 0 + s += sq[pix[0]]; + s += sq[pix[1]]; + s += sq[pix[2]]; + s += sq[pix[3]]; + s += sq[pix[4]]; + s += sq[pix[5]]; + s += sq[pix[6]]; + s += sq[pix[7]]; +#else #if LONG_MAX > 2147483647 register uint64_t x=*(uint64_t*)pix; s += sq[x&0xff]; @@ -196,6 +206,7 @@ static int pix_norm1_c(uint8_t * pix, int line_size) s += sq[(x>>8)&0xff]; s += sq[(x>>16)&0xff]; s += sq[(x>>24)&0xff]; +#endif #endif pix += 8; } From 76e25dbca6eb6ea899baa042902bd038bd2e3056 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 17 Jul 2011 13:27:27 +0200 Subject: [PATCH 593/780] rtsp: remove disabled code --- libavformat/rtsp.c | 8 -------- libavformat/rtsp.h | 3 --- libavformat/rtspdec.c | 6 ------ 3 files changed, 17 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 949c174070..8b70c8b28a 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1116,17 +1116,9 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, } } -#if 0 - /* then try on any port */ - if (ffurl_open(&rtsp_st->rtp_handle, "rtp://", AVIO_FLAG_READ) < 0) { - err = AVERROR_INVALIDDATA; - goto fail; - } -#else av_log(s, AV_LOG_ERROR, "Unable to open an input RTP port\n"); err = AVERROR(EIO); goto fail; -#endif rtp_opened: port = rtp_get_local_rtp_port(rtsp_st->rtp_handle); diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 372ed96e6f..265d9f837f 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -220,9 +220,6 @@ typedef struct RTSPState { * see rtsp_read_play() and rtsp_read_seek(). */ int64_t seek_timestamp; - /* XXX: currently we use unbuffered input */ - // AVIOContext rtsp_gb; - int seq; /**< RTSP command sequence number */ /** copy of RTSPMessageHeader->session_id, i.e. the server-provided session diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index d154615d6f..430c086544 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -383,12 +383,6 @@ static int rtsp_read_close(AVFormatContext *s) { RTSPState *rt = s->priv_data; -#if 0 - /* NOTE: it is valid to flush the buffer here */ - if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) { - avio_close(&rt->rtsp_gb); - } -#endif ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL); ff_rtsp_close_streams(s); From b13c6e336cea3bafd182448d97e50c42c4d7a710 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 17 Jul 2011 19:47:58 +0100 Subject: [PATCH 594/780] fate: make vsynth tests depend on only the relevant vref Signed-off-by: Mans Rullgard --- tests/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Makefile b/tests/Makefile index 4739446674..0a9e402c66 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -58,7 +58,8 @@ FATE = $(FATE_ACODEC) \ $(FATE_SEEK) \ $(filter-out %-aref,$(FATE_ACODEC)): $(AREF) -$(filter-out %-vref,$(FATE_VCODEC)): $(VREF) +$(filter-out %-vref,$(FATE_VSYNTH1)): fate-vsynth1-vref +$(filter-out %-vref,$(FATE_VSYNTH2)): fate-vsynth2-vref $(FATE_LAVF): $(REFS) $(FATE_LAVFI): $(REFS) tools/lavfi-showfiltfmts$(EXESUF) $(FATE_SEEK): fate-codec fate-lavf libavformat/seek-test$(EXESUF) From 3f5dcde7e656618e531968fff25773d80e96278f Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 17 Jul 2011 11:24:34 +0100 Subject: [PATCH 595/780] Remove VLAs in ff_amrwb_lsp2lpc() Signed-off-by: Mans Rullgard --- libavcodec/lsp.c | 4 ++-- libavcodec/lsp.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c index 26b35843b6..1b4afa22e8 100644 --- a/libavcodec/lsp.c +++ b/libavcodec/lsp.c @@ -120,8 +120,8 @@ void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order) void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order) { int lp_half_order = lp_order >> 1; - double buf[lp_half_order + 1]; - double pa[lp_half_order + 1]; + double buf[MAX_LP_HALF_ORDER + 1]; + double pa[MAX_LP_HALF_ORDER + 1]; double *qa = buf + 1; int i,j; diff --git a/libavcodec/lsp.h b/libavcodec/lsp.h index 3648ec74e5..4b955678ee 100644 --- a/libavcodec/lsp.h +++ b/libavcodec/lsp.h @@ -91,7 +91,7 @@ void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order); void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order); -#define MAX_LP_HALF_ORDER 8 +#define MAX_LP_HALF_ORDER 10 #define MAX_LP_ORDER (2*MAX_LP_HALF_ORDER) /** From f04d4345da29782035f241d605de5df3cefbfeda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Mon, 18 Jul 2011 19:53:36 +0200 Subject: [PATCH 596/780] Remove a pointless/bad "static". MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It has no advantage and seems to cause compile issues with some combinations of compiler/compiler flags/PIC. Signed-off-by: Reimar Döffinger --- libavcodec/motionpixels_tablegen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/motionpixels_tablegen.h b/libavcodec/motionpixels_tablegen.h index b56dec64a4..b9802e589d 100644 --- a/libavcodec/motionpixels_tablegen.h +++ b/libavcodec/motionpixels_tablegen.h @@ -30,7 +30,7 @@ typedef struct YuvPixel { } YuvPixel; static int mp_yuv_to_rgb(int y, int v, int u, int clip_rgb) { - static const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; int r, g, b; r = (1000 * y + 701 * v) / 1000; From 47b71eea099b3fe2c7e16644878ad9b7067974e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 17 Jul 2011 13:03:57 +0200 Subject: [PATCH 597/780] Bink: clip AC coefficients during dequantization. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes artefacts with Neverwinter Nights WOTCLogo.bik (http://drmccoy.de/zeugs/WOTCLogo.bik). Fixes trac ticket #352. Signed-off-by: Reimar Döffinger --- libavcodec/bink.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libavcodec/bink.c b/libavcodec/bink.c index ef07747dbc..4328a43525 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -571,6 +571,22 @@ static inline int binkb_get_value(BinkContext *c, int bundle_num) return ret; } +static inline DCTELEM dequant(DCTELEM in, uint32_t quant, int dc) +{ + /* Note: multiplication is unsigned but we want signed shift + * otherwise clipping breaks. + * TODO: The official decoder does not use clipping at all + * but instead uses the full 32-bit result. + * However clipping at least gets rid of the case that a + * half-black half-white intra block gets black and white swapped + * and should cause at most minor differences (except for DC). */ + int32_t res = in * quant; + res >>= 11; + if (!dc) + res = av_clip_int16(res); + return res; +} + /** * Read 8x8 block of DCT coefficients. * @@ -669,10 +685,10 @@ static int read_dct_coeffs(GetBitContext *gb, DCTELEM block[64], const uint8_t * quant = quant_matrices[quant_idx]; - block[0] = (block[0] * quant[0]) >> 11; + block[0] = dequant(block[0], quant[0], 1); for (i = 0; i < coef_count; i++) { int idx = coef_idx[i]; - block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11; + block[scan[idx]] = dequant(block[scan[idx]], quant[idx], 0); } return 0; From dbb5ee8ea78e6fa22407523f4ecedfebe3db302f Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 18 Jul 2011 15:23:22 +0100 Subject: [PATCH 598/780] simple_idct: remove code for DCTELEM != int16 DCTELEM can never be changed to anything else, too much code depends on it. Signed-off-by: Mans Rullgard --- libavcodec/simple_idct.c | 45 ++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/libavcodec/simple_idct.c b/libavcodec/simple_idct.c index d21e5ed340..c82f0925cf 100644 --- a/libavcodec/simple_idct.c +++ b/libavcodec/simple_idct.c @@ -59,39 +59,24 @@ static inline void idctRowCondDC (DCTELEM * row) #else #define ROW0_MASK 0xffffLL #endif - if(sizeof(DCTELEM)==2){ - if ( ((((uint64_t *)row)[0] & ~ROW0_MASK) | - ((uint64_t *)row)[1]) == 0) { - temp = (row[0] << 3) & 0xffff; - temp += temp << 16; - temp += temp << 32; - ((uint64_t *)row)[0] = temp; - ((uint64_t *)row)[1] = temp; - return; - } - }else{ - if (!(row[1]|row[2]|row[3]|row[4]|row[5]|row[6]|row[7])) { - row[0]=row[1]=row[2]=row[3]=row[4]=row[5]=row[6]=row[7]= row[0] << 3; - return; - } + if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) { + temp = (row[0] << 3) & 0xffff; + temp += temp << 16; + temp += temp << 32; + ((uint64_t *)row)[0] = temp; + ((uint64_t *)row)[1] = temp; + return; } #else - if(sizeof(DCTELEM)==2){ - if (!(((uint32_t*)row)[1] | - ((uint32_t*)row)[2] | - ((uint32_t*)row)[3] | - row[1])) { - temp = (row[0] << 3) & 0xffff; - temp += temp << 16; - ((uint32_t*)row)[0]=((uint32_t*)row)[1] = + if (!(((uint32_t*)row)[1] | + ((uint32_t*)row)[2] | + ((uint32_t*)row)[3] | + row[1])) { + temp = (row[0] << 3) & 0xffff; + temp += temp << 16; + ((uint32_t*)row)[0]=((uint32_t*)row)[1] = ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp; - return; - } - }else{ - if (!(row[1]|row[2]|row[3]|row[4]|row[5]|row[6]|row[7])) { - row[0]=row[1]=row[2]=row[3]=row[4]=row[5]=row[6]=row[7]= row[0] << 3; - return; - } + return; } #endif From 3e9409b1d0ca6ee7063fa04d940af36a20b46a8b Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 18 Jul 2011 16:04:25 +0100 Subject: [PATCH 599/780] simple_idct: simplify some ifdeffery Signed-off-by: Mans Rullgard --- libavcodec/simple_idct.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/libavcodec/simple_idct.c b/libavcodec/simple_idct.c index c82f0925cf..0ffbfcaf33 100644 --- a/libavcodec/simple_idct.c +++ b/libavcodec/simple_idct.c @@ -29,6 +29,8 @@ based upon some outcommented c code from mpeg2dec (idct_mmx.c written by Aaron Holtzman ) */ + +#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "dsputil.h" #include "mathops.h" @@ -47,20 +49,11 @@ static inline void idctRowCondDC (DCTELEM * row) { int a0, a1, a2, a3, b0, b1, b2, b3; -#if HAVE_FAST_64BIT - uint64_t temp; -#else - uint32_t temp; -#endif #if HAVE_FAST_64BIT -#if HAVE_BIGENDIAN -#define ROW0_MASK 0xffff000000000000LL -#else -#define ROW0_MASK 0xffffLL -#endif +#define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN) if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) { - temp = (row[0] << 3) & 0xffff; + uint64_t temp = (row[0] << 3) & 0xffff; temp += temp << 16; temp += temp << 32; ((uint64_t *)row)[0] = temp; @@ -72,7 +65,7 @@ static inline void idctRowCondDC (DCTELEM * row) ((uint32_t*)row)[2] | ((uint32_t*)row)[3] | row[1])) { - temp = (row[0] << 3) & 0xffff; + uint32_t temp = (row[0] << 3) & 0xffff; temp += temp << 16; ((uint32_t*)row)[0]=((uint32_t*)row)[1] = ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp; @@ -100,12 +93,7 @@ static inline void idctRowCondDC (DCTELEM * row) b3 = MUL16(W7, row[1]); MAC16(b3, -W5, row[3]); -#if HAVE_FAST_64BIT - temp = ((uint64_t*)row)[1]; -#else - temp = ((uint32_t*)row)[2] | ((uint32_t*)row)[3]; -#endif - if (temp != 0) { + if (AV_RN64A(row + 4)) { a0 += W4*row[4] + W6*row[6]; a1 += - W4*row[4] - W2*row[6]; a2 += - W4*row[4] + W2*row[6]; From 257f274dfa000ae0add4aef8bd11375c8d32add0 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Sat, 16 Jul 2011 10:09:17 +0200 Subject: [PATCH 600/780] Do not use AVFMT_FLAG_NONBLOCK for the output file. Restore the commit 0de8ebf by Carl Eugen Hoyos that was lost during the merge 58257ea. --- ffmpeg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index 662b5e52c5..fb72a3a5d1 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3976,7 +3976,6 @@ static int opt_output_file(const char *opt, const char *filename) av_log(NULL, AV_LOG_WARNING, "-loop_output is deprecated, use -loop\n"); oc->loop_output = loop_output; } - oc->flags |= AVFMT_FLAG_NONBLOCK; frame_rate = (AVRational){0, 0}; frame_width = 0; From 29b42c66f70ec7f8bcac87cb3cb35ec13dc0c71e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 19 Jul 2011 10:20:56 +0100 Subject: [PATCH 601/780] dsputil: fix ff_check_alignment() The change to LOCAL_ALIGNED means the declared object must be an array and the subsequent test should not use the & operator. Noticed by Uoti Urpala. Signed-off-by: Mans Rullgard --- libavcodec/dsputil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index f24985ce4c..a3e8d6cd95 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -2823,9 +2823,9 @@ av_cold void dsputil_static_init(void) int ff_check_alignment(void){ static int did_fail=0; - LOCAL_ALIGNED_16(int, aligned); + LOCAL_ALIGNED_16(int, aligned, [4]); - if((intptr_t)&aligned & 15){ + if((intptr_t)aligned & 15){ if(!did_fail){ #if HAVE_MMX || HAVE_ALTIVEC av_log(NULL, AV_LOG_ERROR, From 31b69928e5fd3d40dda4091ae7db340c582113af Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 12 Jul 2011 16:44:22 -0400 Subject: [PATCH 602/780] cosmetics: rename eac3dec_data.c/h to eac3_data.c/h since the tables will also be used in the E-AC-3 encoder. --- libavcodec/Makefile | 2 +- libavcodec/{eac3dec_data.c => eac3_data.c} | 4 ++-- libavcodec/{eac3dec_data.h => eac3_data.h} | 8 ++++---- libavcodec/eac3dec.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) rename libavcodec/{eac3dec_data.c => eac3_data.c} (99%) rename libavcodec/{eac3dec_data.h => eac3_data.h} (90%) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index fb603f864d..2c52c8d453 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -122,7 +122,7 @@ OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o OBJS-$(CONFIG_DVVIDEO_DECODER) += dv.o dvdata.o OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o dvdata.o OBJS-$(CONFIG_DXA_DECODER) += dxa.o -OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3dec_data.o +OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3_data.o OBJS-$(CONFIG_EAC3_ENCODER) += eac3enc.o ac3enc.o ac3enc_float.o \ ac3tab.o ac3.o kbdwin.o OBJS-$(CONFIG_EACMV_DECODER) += eacmv.o diff --git a/libavcodec/eac3dec_data.c b/libavcodec/eac3_data.c similarity index 99% rename from libavcodec/eac3dec_data.c rename to libavcodec/eac3_data.c index 4cea26fcb3..b0416f3ce7 100644 --- a/libavcodec/eac3dec_data.c +++ b/libavcodec/eac3_data.c @@ -1,5 +1,5 @@ /* - * E-AC-3 decoder tables + * E-AC-3 tables * Copyright (c) 2007 Bartlomiej Wolowiec * * This file is part of Libav. @@ -24,7 +24,7 @@ * Tables taken directly from the E-AC-3 spec. */ -#include "eac3dec_data.h" +#include "eac3_data.h" #include "ac3.h" const uint8_t ff_eac3_bits_vs_hebap[20] = { diff --git a/libavcodec/eac3dec_data.h b/libavcodec/eac3_data.h similarity index 90% rename from libavcodec/eac3dec_data.h rename to libavcodec/eac3_data.h index 91892a30d6..4d88ce0a53 100644 --- a/libavcodec/eac3dec_data.h +++ b/libavcodec/eac3_data.h @@ -1,5 +1,5 @@ /* - * E-AC-3 decoder tables + * E-AC-3 tables * Copyright (c) 2007 Bartlomiej Wolowiec * * This file is part of Libav. @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_EAC3DEC_DATA_H -#define AVCODEC_EAC3DEC_DATA_H +#ifndef AVCODEC_EAC3_DATA_H +#define AVCODEC_EAC3_DATA_H #include @@ -33,4 +33,4 @@ extern const int16_t (* const ff_eac3_mantissa_vq[8])[6]; extern const uint8_t ff_eac3_frm_expstr[32][6]; extern const float ff_eac3_spx_atten_tab[32][3]; -#endif /* AVCODEC_EAC3DEC_DATA_H */ +#endif /* AVCODEC_EAC3_DATA_H */ diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c index 54007686dd..212f6b4e38 100644 --- a/libavcodec/eac3dec.c +++ b/libavcodec/eac3dec.c @@ -51,7 +51,7 @@ #include "ac3_parser.h" #include "ac3dec.h" #include "ac3dec_data.h" -#include "eac3dec_data.h" +#include "eac3_data.h" /** gain adaptive quantization mode */ typedef enum { From 08a747afb98c11da48b89339c2f1c5fdc56ced7e Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 13 Jul 2011 12:20:29 -0400 Subject: [PATCH 603/780] eac3enc: use frame exponent strategy when applicable. This checks if the set of selected exponent strategies for all blocks in a channel are in the frame exponent strategy table, and if so, writes the table index instead of each strategy. This saves up to 7 bits per channel per frame, so the overall effect on quality is small. --- libavcodec/Makefile | 2 +- libavcodec/ac3enc.c | 41 ++++++++++++++++++++++++----- libavcodec/ac3enc.h | 2 ++ libavcodec/eac3enc.c | 61 +++++++++++++++++++++++++++++++++++++++++--- libavcodec/eac3enc.h | 10 ++++++++ 5 files changed, 106 insertions(+), 10 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 2c52c8d453..26800b3851 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -124,7 +124,7 @@ OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o dvdata.o OBJS-$(CONFIG_DXA_DECODER) += dxa.o OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3_data.o OBJS-$(CONFIG_EAC3_ENCODER) += eac3enc.o ac3enc.o ac3enc_float.o \ - ac3tab.o ac3.o kbdwin.o + ac3tab.o ac3.o kbdwin.o eac3_data.o OBJS-$(CONFIG_EACMV_DECODER) += eacmv.o OBJS-$(CONFIG_EAMAD_DECODER) += eamad.o eaidct.o mpeg12.o \ mpeg12data.o mpegvideo.o \ diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index fb4d33441e..e7a5b1611e 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -194,6 +194,7 @@ void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) { int blk, ch; int got_cpl_snr; + int num_cpl_blocks; /* set coupling use flags for each block/channel */ /* TODO: turn coupling on/off and adjust start band based on bit usage */ @@ -206,12 +207,14 @@ void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) /* enable coupling for each block if at least 2 channels have coupling enabled for that block */ got_cpl_snr = 0; + num_cpl_blocks = 0; for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { AC3Block *block = &s->blocks[blk]; block->num_cpl_channels = 0; for (ch = 1; ch <= s->fbw_channels; ch++) block->num_cpl_channels += block->channel_in_cpl[ch]; block->cpl_in_use = block->num_cpl_channels > 1; + num_cpl_blocks += block->cpl_in_use; if (!block->cpl_in_use) { block->num_cpl_channels = 0; for (ch = 1; ch <= s->fbw_channels; ch++) @@ -237,6 +240,8 @@ void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) block->new_snr_offsets = 0; } } + if (!num_cpl_blocks) + s->cpl_on = 0; /* set bandwidth for each channel */ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { @@ -301,6 +306,9 @@ static av_cold void exponent_init(AC3EncodeContext *s) } /* LFE */ exponent_group_tab[0][0][7] = 2; + + if (CONFIG_EAC3_ENCODER && s->eac3) + ff_eac3_exponent_init(); } @@ -342,8 +350,15 @@ static void compute_exp_strategy(AC3EncodeContext *s) exp_strategy[0] = EXP_NEW; exp += AC3_MAX_COEFS; for (blk = 1; blk < AC3_MAX_BLOCKS; blk++, exp += AC3_MAX_COEFS) { - if ((ch == CPL_CH && (!s->blocks[blk].cpl_in_use || !s->blocks[blk-1].cpl_in_use)) || - (ch > CPL_CH && (s->blocks[blk].channel_in_cpl[ch] != s->blocks[blk-1].channel_in_cpl[ch]))) { + if (ch == CPL_CH) { + if (!s->blocks[blk-1].cpl_in_use) { + exp_strategy[blk] = EXP_NEW; + continue; + } else if (!s->blocks[blk].cpl_in_use) { + exp_strategy[blk] = EXP_REUSE; + continue; + } + } else if (s->blocks[blk].channel_in_cpl[ch] != s->blocks[blk-1].channel_in_cpl[ch]) { exp_strategy[blk] = EXP_NEW; continue; } @@ -377,6 +392,10 @@ static void compute_exp_strategy(AC3EncodeContext *s) for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) s->exp_strategy[ch][blk] = EXP_REUSE; } + + /* for E-AC-3, determine frame exponent strategy */ + if (CONFIG_EAC3_ENCODER && s->eac3) + ff_eac3_get_frame_exp_strategy(s); } @@ -611,8 +630,12 @@ static void count_frame_bits_fixed(AC3EncodeContext *s) frame_bits += 2; frame_bits += 10; /* exponent strategy */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) - frame_bits += 2 * s->fbw_channels + s->lfe_on; + if (s->use_frame_exp_strategy) + frame_bits += 5 * s->fbw_channels; + else + frame_bits += AC3_MAX_BLOCKS * 2 * s->fbw_channels; + if (s->lfe_on) + frame_bits += AC3_MAX_BLOCKS; /* converter exponent strategy */ frame_bits += s->fbw_channels * 5; /* snr offsets */ @@ -735,8 +758,14 @@ static void count_frame_bits(AC3EncodeContext *s) } } /* coupling exponent strategy */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) - frame_bits += 2 * s->blocks[blk].cpl_in_use; + if (s->cpl_on) { + if (s->use_frame_exp_strategy) { + frame_bits += 5 * s->cpl_on; + } else { + for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + frame_bits += 2 * s->blocks[blk].cpl_in_use; + } + } } else { if (opt->audio_production_info) frame_bits += 7; diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 6caf4d80c4..a4a8fd4325 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -217,6 +217,8 @@ typedef struct AC3EncodeContext { uint8_t *cpl_coord_mant_buffer; uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies + uint8_t frame_exp_strategy[AC3_MAX_CHANNELS]; ///< frame exp strategy index + int use_frame_exp_strategy; ///< indicates use of frame exp strategy uint8_t exp_ref_block[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< reference blocks for EXP_REUSE uint8_t *ref_bap [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap) int ref_bap_set; ///< indicates if ref_bap pointers have been set diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 0433db49d7..153428fdfb 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -27,6 +27,7 @@ #define CONFIG_AC3ENC_FLOAT 1 #include "ac3enc.h" #include "eac3enc.h" +#include "eac3_data.h" #define AC3ENC_TYPE AC3ENC_TYPE_EAC3 @@ -35,6 +36,51 @@ static const AVClass eac3enc_class = { "E-AC-3 Encoder", av_default_item_name, eac3_options, LIBAVUTIL_VERSION_INT }; +/** + * LUT for finding a matching frame exponent strategy index from a set of + * exponent strategies for a single channel across all 6 blocks. + */ +static int8_t eac3_frame_expstr_index_tab[3][4][4][4][4][4]; + + +void ff_eac3_exponent_init(void) +{ + int i; + + memset(eac3_frame_expstr_index_tab, -1, sizeof(eac3_frame_expstr_index_tab)); + for (i = 0; i < 32; i++) { + eac3_frame_expstr_index_tab[ff_eac3_frm_expstr[i][0]-1] + [ff_eac3_frm_expstr[i][1]] + [ff_eac3_frm_expstr[i][2]] + [ff_eac3_frm_expstr[i][3]] + [ff_eac3_frm_expstr[i][4]] + [ff_eac3_frm_expstr[i][5]] = i; + } +} + + +void ff_eac3_get_frame_exp_strategy(AC3EncodeContext *s) +{ + int ch; + + s->use_frame_exp_strategy = 1; + for (ch = !s->cpl_on; ch <= s->fbw_channels; ch++) { + int expstr = eac3_frame_expstr_index_tab[s->exp_strategy[ch][0]-1] + [s->exp_strategy[ch][1]] + [s->exp_strategy[ch][2]] + [s->exp_strategy[ch][3]] + [s->exp_strategy[ch][4]] + [s->exp_strategy[ch][5]]; + if (expstr < 0) { + s->use_frame_exp_strategy = 0; + break; + } + s->frame_exp_strategy[ch] = expstr; + } +} + + + void ff_eac3_set_cpl_states(AC3EncodeContext *s) { int ch, blk; @@ -98,7 +144,7 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) put_bits(&s->pb, 1, 0); /* no additional bit stream info */ /* frame header */ - put_bits(&s->pb, 1, 1); /* exponent strategy syntax = each block */ + put_bits(&s->pb, 1, !s->use_frame_exp_strategy);/* exponent strategy syntax */ put_bits(&s->pb, 1, 0); /* aht enabled = no */ put_bits(&s->pb, 2, 0); /* snr offset strategy = 1 */ put_bits(&s->pb, 1, 0); /* transient pre-noise processing enabled = no */ @@ -120,16 +166,25 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) } } /* exponent strategy */ + if (s->use_frame_exp_strategy) { + for (ch = !s->cpl_on; ch <= s->fbw_channels; ch++) + put_bits(&s->pb, 5, s->frame_exp_strategy[ch]); + } else { for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); + } if (s->lfe_on) { for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]); } /* E-AC-3 to AC-3 converter exponent strategy (unfortunately not optional...) */ - for (ch = 1; ch <= s->fbw_channels; ch++) - put_bits(&s->pb, 5, 0); + for (ch = 1; ch <= s->fbw_channels; ch++) { + if (s->use_frame_exp_strategy) + put_bits(&s->pb, 5, s->frame_exp_strategy[ch]); + else + put_bits(&s->pb, 5, 0); + } /* snr offsets */ put_bits(&s->pb, 6, s->coarse_snr_offset); put_bits(&s->pb, 4, s->fine_snr_offset[1]); diff --git a/libavcodec/eac3enc.h b/libavcodec/eac3enc.h index eacb8cf164..a92a24c2fa 100644 --- a/libavcodec/eac3enc.h +++ b/libavcodec/eac3enc.h @@ -29,6 +29,16 @@ #include "ac3enc.h" +/** + * Initialize E-AC-3 exponent tables. + */ +void ff_eac3_exponent_init(void); + +/** + * Determine frame exponent strategy use and indices. + */ +void ff_eac3_get_frame_exp_strategy(AC3EncodeContext *s); + /** * Set coupling states. * This determines whether certain flags must be written to the bitstream or From 953302656aaaeb1bc737b59fae2d5a11b75d9f7d Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 13 Jul 2011 12:49:15 -0400 Subject: [PATCH 604/780] cosmetics: indentation --- libavcodec/eac3enc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 153428fdfb..09fa80fcb9 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -170,9 +170,9 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) for (ch = !s->cpl_on; ch <= s->fbw_channels; ch++) put_bits(&s->pb, 5, s->frame_exp_strategy[ch]); } else { - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) - for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) - put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); + for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) + put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); } if (s->lfe_on) { for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) From 045ef52ef513973a134f95c10a33f9ccb89ec92f Mon Sep 17 00:00:00 2001 From: Erik Slagter Date: Mon, 18 Jul 2011 20:04:15 +0200 Subject: [PATCH 605/780] libx264.c: distinguish between x264 parameter errors. Signed-off-by: Michael Niedermayer --- libavcodec/libx264.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index cc5b9837f8..670a7802e1 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -198,14 +198,19 @@ static void check_default_settings(AVCodecContext *avctx) } } -#define OPT_STR(opt, param) \ - do { \ - if (param && x264_param_parse(&x4->params, opt, param) < 0) { \ - av_log(avctx, AV_LOG_ERROR, \ - "bad value for '%s': '%s'\n", opt, param); \ - return -1; \ - } \ - } while (0); \ +#define OPT_STR(opt, param) \ + do { \ + int ret; \ + if (param && (ret = x264_param_parse(&x4->params, opt, param)) < 0) { \ + if(ret == X264_PARAM_BAD_NAME) \ + av_log(avctx, AV_LOG_ERROR, \ + "bad option '%s': '%s'\n", opt, param); \ + else \ + av_log(avctx, AV_LOG_ERROR, \ + "bad value for '%s': '%s'\n", opt, param); \ + return -1; \ + } \ + } while (0); static av_cold int X264_init(AVCodecContext *avctx) { From 69619a13c3fef940cba545cf0a283ff22771dd71 Mon Sep 17 00:00:00 2001 From: Chris Evans Date: Tue, 19 Jul 2011 17:51:48 -0700 Subject: [PATCH 606/780] matroskadec: fix integer underflow if header length < probe length. This fixes a crash with specifically crafted files. Signed-off-by: Ronald S. Bultje --- libavformat/matroskadec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 852760cc4d..037997742c 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -903,6 +903,8 @@ static int matroska_probe(AVProbeData *p) * Not fully fool-proof, but good enough. */ for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++) { int probelen = strlen(matroska_doctypes[i]); + if (total < probelen) + continue; for (n = 4+size; n <= 4+size+total-probelen; n++) if (!memcmp(p->buf+n, matroska_doctypes[i], probelen)) return AVPROBE_SCORE_MAX; From e23a05ab0605693aa715b95120bc0132079ded06 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 20 Jul 2011 09:55:48 +0100 Subject: [PATCH 607/780] Fix incorrect max_lowres values Signed-off-by: Mans Rullgard --- libavcodec/cdgraphics.c | 1 - libavcodec/kgv1dec.c | 1 - libavcodec/pngdec.c | 1 - libavcodec/pnmdec.c | 5 ----- libavcodec/sp5xdec.c | 2 +- 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index 9e3f19a5f7..6493709aaf 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -377,6 +377,5 @@ AVCodec ff_cdgraphics_decoder = { cdg_decode_end, cdg_decode_frame, CODEC_CAP_DR1, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"), }; diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 57684340af..88c54bf817 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -173,6 +173,5 @@ AVCodec ff_kgv1_decoder = { NULL, decode_end, decode_frame, - .max_lowres = 1, .long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"), }; diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 7477f6746b..1268c9e781 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -667,6 +667,5 @@ AVCodec ff_png_decoder = { decode_frame, CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, NULL, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PNG image"), }; diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c index b9f20c0569..988ea0c267 100644 --- a/libavcodec/pnmdec.c +++ b/libavcodec/pnmdec.c @@ -199,7 +199,6 @@ AVCodec ff_pgm_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE}, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"), }; #endif @@ -216,7 +215,6 @@ AVCodec ff_pgmyuv_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), }; #endif @@ -233,7 +231,6 @@ AVCodec ff_ppm_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE}, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"), }; #endif @@ -250,7 +247,6 @@ AVCodec ff_pbm_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE}, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"), }; #endif @@ -267,7 +263,6 @@ AVCodec ff_pam_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE}, - .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), }; #endif diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index 6726c18ca9..ae25733530 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -104,7 +104,7 @@ AVCodec ff_sp5x_decoder = { sp5x_decode_frame, CODEC_CAP_DR1, NULL, - .max_lowres = 5, + .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"), }; From 1b4a17094ebdc605a9414d4d98653a1bfb0ea0a4 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 17 Jul 2011 13:09:04 +0200 Subject: [PATCH 608/780] h264: remove some disabled code --- libavcodec/h264.c | 149 ---------------------------------------------- 1 file changed, 149 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index cbeeb07425..5adce242ce 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3459,52 +3459,6 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){ } } } - -#if 0 - for(;s->mb_y < s->mb_height; s->mb_y++){ - for(;s->mb_x < s->mb_width; s->mb_x++){ - int ret= decode_mb(h); - - ff_h264_hl_decode_mb(h); - - if(ret<0){ - av_log(s->avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y); - ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask); - - return -1; - } - - if(++s->mb_x >= s->mb_width){ - s->mb_x=0; - if(++s->mb_y >= s->mb_height){ - if(get_bits_count(s->gb) == s->gb.size_in_bits){ - ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask); - - return 0; - }else{ - ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask); - - return -1; - } - } - } - - if(get_bits_count(s->?gb) >= s->gb?.size_in_bits){ - if(get_bits_count(s->gb) == s->gb.size_in_bits){ - ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask); - - return 0; - }else{ - ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask); - - return -1; - } - } - } - s->mb_x=0; - ff_draw_horiz_band(s, 16*s->mb_y, 16); - } -#endif } /** @@ -3971,109 +3925,6 @@ int main(void){ STOP_TIMER("get_se_golomb"); } -#if 0 - printf("testing 4x4 (I)DCT\n"); - - DCTELEM block[16]; - uint8_t src[16], ref[16]; - uint64_t error= 0, max_error=0; - - for(i=0; ih264dsp.h264_idct_add(ref, block, 4); -/* for(j=0; j<16; j++){ - printf("%d ", ref[j]); - } - printf("\n");*/ - - for(j=0; j<16; j++){ - int diff= FFABS(src[j] - ref[j]); - - error+= diff*diff; - max_error= FFMAX(max_error, diff); - } - } - printf("error=%f max_error=%d\n", ((float)error)/COUNT/16, (int)max_error ); - printf("testing quantizer\n"); - for(qp=0; qp<52; qp++){ - for(i=0; i<16; i++) - src1_block[i]= src2_block[i]= random()%255; - - } - printf("Testing NAL layer\n"); - - uint8_t bitstream[COUNT]; - uint8_t nal[COUNT*2]; - H264Context h; - memset(&h, 0, sizeof(H264Context)); - - for(i=0; i Date: Sun, 17 Jul 2011 20:43:15 +0100 Subject: [PATCH 609/780] Remove snow/dwt test program This test program so full of programming errors it is impossible to make sense of it. Signed-off-by: Mans Rullgard --- libavcodec/Makefile | 2 +- libavcodec/snow.c | 121 -------------------------------------------- 2 files changed, 1 insertion(+), 122 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 26800b3851..f23ade2734 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -667,7 +667,7 @@ SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h EXAMPLES = api -TESTPROGS = cabac dct fft fft-fixed h264 iirfilter rangecoder snow +TESTPROGS = cabac dct fft fft-fixed h264 iirfilter rangecoder TESTPROGS-$(HAVE_MMX) += motion TESTOBJS = dctref.o diff --git a/libavcodec/snow.c b/libavcodec/snow.c index e1f6c57352..3162e5cf98 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -3689,124 +3689,3 @@ AVCodec ff_snow_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Snow"), }; #endif - - -#ifdef TEST -#undef malloc -#undef free -#undef printf - -#include "libavutil/lfg.h" -#include "libavutil/mathematics.h" - -int main(void){ - int width=256; - int height=256; - int buffer[2][width*height]; - SnowContext s; - int i; - AVLFG prng; - s.spatial_decomposition_count=6; - s.spatial_decomposition_type=1; - - av_lfg_init(&prng, 1); - - printf("testing 5/3 DWT\n"); - for(i=0; i20) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]); - - { - int level, orientation, x, y; - int64_t errors[8][4]; - int64_t g=0; - - memset(errors, 0, sizeof(errors)); - s.spatial_decomposition_count=3; - s.spatial_decomposition_type=0; - for(level=0; level> (s.spatial_decomposition_count-level); - int h= height >> (s.spatial_decomposition_count-level); - int stride= width << (s.spatial_decomposition_count-level); - DWTELEM *buf= buffer[0]; - int64_t error=0; - - if(orientation&1) buf+=w; - if(orientation>1) buf+=stride>>1; - - memset(buffer[0], 0, sizeof(int)*width*height); - buf[w/2 + h/2*stride]= 256*256; - ff_spatial_idwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count); - for(y=0; y> (s.spatial_decomposition_count-level); - //int h= height >> (s.spatial_decomposition_count-level); - int stride= width << (s.spatial_decomposition_count-level); - DWTELEM *buf= buffer[0]; - int64_t error=0; - - buf+=w; - buf+=stride>>1; - - memset(buffer[0], 0, sizeof(int)*width*height); - for(y=0; y Date: Wed, 20 Jul 2011 09:46:18 +0100 Subject: [PATCH 610/780] Remove h264_lowres_idct_put/add functions Use of these has been broken ever since the h264 idct was changed to always use transposed inputs. Furthermore, they were only ever used if some *other* non-default idct was requested. Signed-off-by: Mans Rullgard --- libavcodec/dsputil.c | 25 ++-------------- libavcodec/dsputil.h | 2 -- libavcodec/h264idct_template.c | 53 ++++++++++++++-------------------- 3 files changed, 23 insertions(+), 57 deletions(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index a3e8d6cd95..e2cf708940 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -2863,29 +2863,8 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) #endif //CONFIG_ENCODERS if(avctx->lowres==1){ - if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO || !CONFIG_H264_DECODER){ - c->idct_put= ff_jref_idct4_put; - c->idct_add= ff_jref_idct4_add; - }else{ - if (avctx->codec_id != CODEC_ID_H264) { - c->idct_put= ff_h264_lowres_idct_put_8_c; - c->idct_add= ff_h264_lowres_idct_add_8_c; - } else { - switch (avctx->bits_per_raw_sample) { - case 9: - c->idct_put= ff_h264_lowres_idct_put_9_c; - c->idct_add= ff_h264_lowres_idct_add_9_c; - break; - case 10: - c->idct_put= ff_h264_lowres_idct_put_10_c; - c->idct_add= ff_h264_lowres_idct_add_10_c; - break; - default: - c->idct_put= ff_h264_lowres_idct_put_8_c; - c->idct_add= ff_h264_lowres_idct_add_8_c; - } - } - } + c->idct_put= ff_jref_idct4_put; + c->idct_add= ff_jref_idct4_add; c->idct = j_rev_dct4; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->lowres==2){ diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 5a97b442ad..8cd3af60ca 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -58,8 +58,6 @@ void ff_h264_idct8_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride) void ff_h264_idct_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\ void ff_h264_idct8_dc_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\ void ff_h264_idct_dc_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\ -void ff_h264_lowres_idct_add_ ## depth ## _c(uint8_t *dst, int stride, DCTELEM *block);\ -void ff_h264_lowres_idct_put_ ## depth ## _c(uint8_t *dst, int stride, DCTELEM *block);\ void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c index 55c1d3a4d8..ba5571576d 100644 --- a/libavcodec/h264idct_template.c +++ b/libavcodec/h264idct_template.c @@ -46,52 +46,41 @@ static const uint8_t scan8[16*3]={ }; #endif -static av_always_inline void FUNCC(idct_internal)(uint8_t *_dst, DCTELEM *_block, int stride, int block_stride, int shift, int add){ +void FUNCC(ff_h264_idct_add)(uint8_t *_dst, DCTELEM *_block, int stride) +{ int i; INIT_CLIP pixel *dst = (pixel*)_dst; dctcoef *block = (dctcoef*)_block; stride /= sizeof(pixel); - block[0] += 1<<(shift-1); + block[0] += 1 << 5; for(i=0; i<4; i++){ - const int z0= block[i + block_stride*0] + block[i + block_stride*2]; - const int z1= block[i + block_stride*0] - block[i + block_stride*2]; - const int z2= (block[i + block_stride*1]>>1) - block[i + block_stride*3]; - const int z3= block[i + block_stride*1] + (block[i + block_stride*3]>>1); + const int z0= block[i + 4*0] + block[i + 4*2]; + const int z1= block[i + 4*0] - block[i + 4*2]; + const int z2= (block[i + 4*1]>>1) - block[i + 4*3]; + const int z3= block[i + 4*1] + (block[i + 4*3]>>1); - block[i + block_stride*0]= z0 + z3; - block[i + block_stride*1]= z1 + z2; - block[i + block_stride*2]= z1 - z2; - block[i + block_stride*3]= z0 - z3; + block[i + 4*0]= z0 + z3; + block[i + 4*1]= z1 + z2; + block[i + 4*2]= z1 - z2; + block[i + 4*3]= z0 - z3; } for(i=0; i<4; i++){ - const int z0= block[0 + block_stride*i] + block[2 + block_stride*i]; - const int z1= block[0 + block_stride*i] - block[2 + block_stride*i]; - const int z2= (block[1 + block_stride*i]>>1) - block[3 + block_stride*i]; - const int z3= block[1 + block_stride*i] + (block[3 + block_stride*i]>>1); + const int z0= block[0 + 4*i] + block[2 + 4*i]; + const int z1= block[0 + 4*i] - block[2 + 4*i]; + const int z2= (block[1 + 4*i]>>1) - block[3 + 4*i]; + const int z3= block[1 + 4*i] + (block[3 + 4*i]>>1); - dst[i + 0*stride]= CLIP(add*dst[i + 0*stride] + ((z0 + z3) >> shift)); - dst[i + 1*stride]= CLIP(add*dst[i + 1*stride] + ((z1 + z2) >> shift)); - dst[i + 2*stride]= CLIP(add*dst[i + 2*stride] + ((z1 - z2) >> shift)); - dst[i + 3*stride]= CLIP(add*dst[i + 3*stride] + ((z0 - z3) >> shift)); + dst[i + 0*stride]= CLIP(dst[i + 0*stride] + ((z0 + z3) >> 6)); + dst[i + 1*stride]= CLIP(dst[i + 1*stride] + ((z1 + z2) >> 6)); + dst[i + 2*stride]= CLIP(dst[i + 2*stride] + ((z1 - z2) >> 6)); + dst[i + 3*stride]= CLIP(dst[i + 3*stride] + ((z0 - z3) >> 6)); } } -void FUNCC(ff_h264_idct_add)(uint8_t *dst, DCTELEM *block, int stride){ - FUNCC(idct_internal)(dst, block, stride, 4, 6, 1); -} - -void FUNCC(ff_h264_lowres_idct_add)(uint8_t *dst, int stride, DCTELEM *block){ - FUNCC(idct_internal)(dst, block, stride, 8, 3, 1); -} - -void FUNCC(ff_h264_lowres_idct_put)(uint8_t *dst, int stride, DCTELEM *block){ - FUNCC(idct_internal)(dst, block, stride, 8, 3, 0); -} - void FUNCC(ff_h264_idct8_add)(uint8_t *_dst, DCTELEM *_block, int stride){ int i; INIT_CLIP @@ -200,7 +189,7 @@ void FUNCC(ff_h264_idct_add16)(uint8_t *dst, const int *block_offset, DCTELEM *b int nnz = nnzc[ scan8[i] ]; if(nnz){ if(nnz==1 && ((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride); - else FUNCC(idct_internal )(dst + block_offset[i], block + i*16*sizeof(pixel), stride, 4, 6, 1); + else FUNCC(ff_h264_idct_add )(dst + block_offset[i], block + i*16*sizeof(pixel), stride); } } } @@ -208,7 +197,7 @@ void FUNCC(ff_h264_idct_add16)(uint8_t *dst, const int *block_offset, DCTELEM *b void FUNCC(ff_h264_idct_add16intra)(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[15*8]){ int i; for(i=0; i<16; i++){ - if(nnzc[ scan8[i] ]) FUNCC(idct_internal )(dst + block_offset[i], block + i*16*sizeof(pixel), stride, 4, 6, 1); + if(nnzc[ scan8[i] ]) FUNCC(ff_h264_idct_add )(dst + block_offset[i], block + i*16*sizeof(pixel), stride); else if(((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride); } } From e7a972e113ddf3271c4c0e01a2d57e23ac5195f1 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 20 Jul 2011 16:05:05 +0100 Subject: [PATCH 611/780] simple_idct: add 10-bit version Signed-off-by: Mans Rullgard --- libavcodec/alpha/dsputil_alpha.c | 2 +- libavcodec/arm/dsputil_init_arm.c | 2 +- libavcodec/arm/dsputil_init_armv5te.c | 5 +- libavcodec/arm/dsputil_init_armv6.c | 5 +- libavcodec/arm/dsputil_init_neon.c | 2 +- libavcodec/bfin/dsputil_bfin.c | 22 +- libavcodec/dct-test.c | 2 +- libavcodec/dsputil.c | 15 +- libavcodec/ppc/dsputil_ppc.c | 2 +- libavcodec/ps2/dsputil_mmi.c | 3 +- libavcodec/sh4/dsputil_sh4.c | 3 +- libavcodec/simple_idct.c | 338 +--------------------- libavcodec/simple_idct.h | 11 +- libavcodec/simple_idct_template.c | 401 ++++++++++++++++++++++++++ libavcodec/sparc/dsputil_vis.c | 3 +- libavcodec/vc1.c | 4 +- libavcodec/x86/dsputil_mmx.c | 2 +- 17 files changed, 461 insertions(+), 361 deletions(-) create mode 100644 libavcodec/simple_idct_template.c diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c index 32bb0fc932..039608b9ed 100644 --- a/libavcodec/alpha/dsputil_alpha.c +++ b/libavcodec/alpha/dsputil_alpha.c @@ -335,7 +335,7 @@ void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx) put_pixels_clamped_axp_p = c->put_pixels_clamped; add_pixels_clamped_axp_p = c->add_pixels_clamped; - if (!avctx->lowres && + if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 && (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLEALPHA)) { c->idct_put = ff_simple_idct_put_axp; diff --git a/libavcodec/arm/dsputil_init_arm.c b/libavcodec/arm/dsputil_init_arm.c index 777a2f954e..5b4b24a43e 100644 --- a/libavcodec/arm/dsputil_init_arm.c +++ b/libavcodec/arm/dsputil_init_arm.c @@ -80,7 +80,7 @@ void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) ff_put_pixels_clamped = c->put_pixels_clamped; ff_add_pixels_clamped = c->add_pixels_clamped; - if (!avctx->lowres) { + if (!avctx->lowres && avctx->bits_per_raw_sample <= 8) { if(avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_ARM){ c->idct_put = j_rev_dct_arm_put; diff --git a/libavcodec/arm/dsputil_init_armv5te.c b/libavcodec/arm/dsputil_init_armv5te.c index 572e06cf36..e0224dabfb 100644 --- a/libavcodec/arm/dsputil_init_armv5te.c +++ b/libavcodec/arm/dsputil_init_armv5te.c @@ -29,8 +29,9 @@ void ff_prefetch_arm(void *mem, int stride, int h); void av_cold ff_dsputil_init_armv5te(DSPContext* c, AVCodecContext *avctx) { - if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO || - avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) { + if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 && + (avctx->idct_algo == FF_IDCT_AUTO || + avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) { c->idct_put = ff_simple_idct_put_armv5te; c->idct_add = ff_simple_idct_add_armv5te; c->idct = ff_simple_idct_armv5te; diff --git a/libavcodec/arm/dsputil_init_armv6.c b/libavcodec/arm/dsputil_init_armv6.c index 7584aeefc6..d442415aec 100644 --- a/libavcodec/arm/dsputil_init_armv6.c +++ b/libavcodec/arm/dsputil_init_armv6.c @@ -74,8 +74,9 @@ void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx) { const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; - if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO || - avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) { + if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 && + (avctx->idct_algo == FF_IDCT_AUTO || + avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) { c->idct_put = ff_simple_idct_put_armv6; c->idct_add = ff_simple_idct_add_armv6; c->idct = ff_simple_idct_armv6; diff --git a/libavcodec/arm/dsputil_init_neon.c b/libavcodec/arm/dsputil_init_neon.c index 3f58dea9cd..ce45caf53e 100644 --- a/libavcodec/arm/dsputil_init_neon.c +++ b/libavcodec/arm/dsputil_init_neon.c @@ -177,7 +177,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) { const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; - if (!avctx->lowres) { + if (!avctx->lowres && avctx->bits_per_raw_sample <= 8) { if (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLENEON) { c->idct_put = ff_simple_idct_put_neon; diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c index 0db2d8baf8..d06bd8e4fd 100644 --- a/libavcodec/bfin/dsputil_bfin.c +++ b/libavcodec/bfin/dsputil_bfin.c @@ -256,16 +256,18 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) if (avctx->dct_algo == FF_DCT_AUTO) c->fdct = ff_bfin_fdct; - if (avctx->idct_algo==FF_IDCT_VP3) { - c->idct_permutation_type = FF_NO_IDCT_PERM; - c->idct = ff_bfin_vp3_idct; - c->idct_add = ff_bfin_vp3_idct_add; - c->idct_put = ff_bfin_vp3_idct_put; - } else if (avctx->idct_algo == FF_IDCT_AUTO) { - c->idct_permutation_type = FF_NO_IDCT_PERM; - c->idct = ff_bfin_idct; - c->idct_add = bfin_idct_add; - c->idct_put = bfin_idct_put; + if (avctx->bits_per_raw_sample <= 8) { + if (avctx->idct_algo == FF_IDCT_VP3) { + c->idct_permutation_type = FF_NO_IDCT_PERM; + c->idct = ff_bfin_vp3_idct; + c->idct_add = ff_bfin_vp3_idct_add; + c->idct_put = ff_bfin_vp3_idct_put; + } else if (avctx->idct_algo == FF_IDCT_AUTO) { + c->idct_permutation_type = FF_NO_IDCT_PERM; + c->idct = ff_bfin_idct; + c->idct_add = bfin_idct_add; + c->idct_put = bfin_idct_put; + } } } diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index dbf9639c1e..136f5c4742 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -111,7 +111,7 @@ static const struct algo idct_tab[] = { { "FAANI", ff_faanidct, NO_PERM }, { "REF-DBL", ff_ref_idct, NO_PERM }, { "INT", j_rev_dct, MMX_PERM }, - { "SIMPLE-C", ff_simple_idct, NO_PERM }, + { "SIMPLE-C", ff_simple_idct_8, NO_PERM }, #if HAVE_MMX #if CONFIG_GPL diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index e2cf708940..4b26f68387 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -2237,7 +2237,7 @@ static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *s s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i); s->dct_unquantize_inter(s, temp, 0, s->qscale); - ff_simple_idct(temp); //FIXME + ff_simple_idct_8(temp); //FIXME for(i=0; i<64; i++) sum+= (temp[i]-bak[i])*(temp[i]-bak[i]); @@ -2878,6 +2878,12 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->idct = j_rev_dct1; c->idct_permutation_type= FF_NO_IDCT_PERM; }else{ + if (avctx->bits_per_raw_sample == 10) { + c->idct_put = ff_simple_idct_put_10; + c->idct_add = ff_simple_idct_add_10; + c->idct = ff_simple_idct_10; + c->idct_permutation_type = FF_NO_IDCT_PERM; + } else { if(avctx->idct_algo==FF_IDCT_INT){ c->idct_put= ff_jref_idct_put; c->idct_add= ff_jref_idct_add; @@ -2908,11 +2914,12 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->idct_put = ff_bink_idct_put_c; c->idct_permutation_type = FF_NO_IDCT_PERM; }else{ //accurate/default - c->idct_put= ff_simple_idct_put; - c->idct_add= ff_simple_idct_add; - c->idct = ff_simple_idct; + c->idct_put = ff_simple_idct_put_8; + c->idct_add = ff_simple_idct_add_8; + c->idct = ff_simple_idct_8; c->idct_permutation_type= FF_NO_IDCT_PERM; } + } } c->get_pixels = get_pixels_c; diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c index 3bf410c2ca..c1f68fc5f7 100644 --- a/libavcodec/ppc/dsputil_ppc.c +++ b/libavcodec/ppc/dsputil_ppc.c @@ -178,7 +178,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx) } #endif //CONFIG_ENCODERS - if (avctx->lowres==0) { + if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) { if ((avctx->idct_algo == FF_IDCT_AUTO) || (avctx->idct_algo == FF_IDCT_ALTIVEC)) { c->idct_put = idct_put_altivec; diff --git a/libavcodec/ps2/dsputil_mmi.c b/libavcodec/ps2/dsputil_mmi.c index f4503a9030..585709679b 100644 --- a/libavcodec/ps2/dsputil_mmi.c +++ b/libavcodec/ps2/dsputil_mmi.c @@ -156,7 +156,8 @@ void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx) c->get_pixels = get_pixels_mmi; - if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_PS2){ + if (avctx->bits_per_raw_sample <= 8 && + (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_PS2)) { c->idct_put= ff_mmi_idct_put; c->idct_add= ff_mmi_idct_add; c->idct = ff_mmi_idct; diff --git a/libavcodec/sh4/dsputil_sh4.c b/libavcodec/sh4/dsputil_sh4.c index 9ea48ad4a1..bf58a9cbbd 100644 --- a/libavcodec/sh4/dsputil_sh4.c +++ b/libavcodec/sh4/dsputil_sh4.c @@ -97,7 +97,8 @@ void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx) if (!high_bit_depth) c->clear_blocks = clear_blocks_sh4; - if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){ + if (avctx->bits_per_raw_sample <= 8 && + (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4)) { c->idct_put = idct_put; c->idct_add = idct_add; c->idct = idct_sh4; diff --git a/libavcodec/simple_idct.c b/libavcodec/simple_idct.c index 0ffbfcaf33..b62658bdb3 100644 --- a/libavcodec/simple_idct.c +++ b/libavcodec/simple_idct.c @@ -25,339 +25,19 @@ * simpleidct in C. */ -/* - based upon some outcommented c code from mpeg2dec (idct_mmx.c - written by Aaron Holtzman ) - */ - #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "dsputil.h" #include "mathops.h" #include "simple_idct.h" -#define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 -#define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 -#define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 -#define W4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 -#define W5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 -#define W6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 -#define W7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 -#define ROW_SHIFT 11 -#define COL_SHIFT 20 // 6 +#define BIT_DEPTH 8 +#include "simple_idct_template.c" +#undef BIT_DEPTH -static inline void idctRowCondDC (DCTELEM * row) -{ - int a0, a1, a2, a3, b0, b1, b2, b3; - -#if HAVE_FAST_64BIT -#define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN) - if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) { - uint64_t temp = (row[0] << 3) & 0xffff; - temp += temp << 16; - temp += temp << 32; - ((uint64_t *)row)[0] = temp; - ((uint64_t *)row)[1] = temp; - return; - } -#else - if (!(((uint32_t*)row)[1] | - ((uint32_t*)row)[2] | - ((uint32_t*)row)[3] | - row[1])) { - uint32_t temp = (row[0] << 3) & 0xffff; - temp += temp << 16; - ((uint32_t*)row)[0]=((uint32_t*)row)[1] = - ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp; - return; - } -#endif - - a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1)); - a1 = a0; - a2 = a0; - a3 = a0; - - /* no need to optimize : gcc does it */ - a0 += W2 * row[2]; - a1 += W6 * row[2]; - a2 -= W6 * row[2]; - a3 -= W2 * row[2]; - - b0 = MUL16(W1, row[1]); - MAC16(b0, W3, row[3]); - b1 = MUL16(W3, row[1]); - MAC16(b1, -W7, row[3]); - b2 = MUL16(W5, row[1]); - MAC16(b2, -W1, row[3]); - b3 = MUL16(W7, row[1]); - MAC16(b3, -W5, row[3]); - - if (AV_RN64A(row + 4)) { - a0 += W4*row[4] + W6*row[6]; - a1 += - W4*row[4] - W2*row[6]; - a2 += - W4*row[4] + W2*row[6]; - a3 += W4*row[4] - W6*row[6]; - - MAC16(b0, W5, row[5]); - MAC16(b0, W7, row[7]); - - MAC16(b1, -W1, row[5]); - MAC16(b1, -W5, row[7]); - - MAC16(b2, W7, row[5]); - MAC16(b2, W3, row[7]); - - MAC16(b3, W3, row[5]); - MAC16(b3, -W1, row[7]); - } - - row[0] = (a0 + b0) >> ROW_SHIFT; - row[7] = (a0 - b0) >> ROW_SHIFT; - row[1] = (a1 + b1) >> ROW_SHIFT; - row[6] = (a1 - b1) >> ROW_SHIFT; - row[2] = (a2 + b2) >> ROW_SHIFT; - row[5] = (a2 - b2) >> ROW_SHIFT; - row[3] = (a3 + b3) >> ROW_SHIFT; - row[4] = (a3 - b3) >> ROW_SHIFT; -} - -static inline void idctSparseColPut (uint8_t *dest, int line_size, - DCTELEM * col) -{ - int a0, a1, a2, a3, b0, b1, b2, b3; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - - /* XXX: I did that only to give same values as previous code */ - a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); - a1 = a0; - a2 = a0; - a3 = a0; - - a0 += + W2*col[8*2]; - a1 += + W6*col[8*2]; - a2 += - W6*col[8*2]; - a3 += - W2*col[8*2]; - - b0 = MUL16(W1, col[8*1]); - b1 = MUL16(W3, col[8*1]); - b2 = MUL16(W5, col[8*1]); - b3 = MUL16(W7, col[8*1]); - - MAC16(b0, + W3, col[8*3]); - MAC16(b1, - W7, col[8*3]); - MAC16(b2, - W1, col[8*3]); - MAC16(b3, - W5, col[8*3]); - - if(col[8*4]){ - a0 += + W4*col[8*4]; - a1 += - W4*col[8*4]; - a2 += - W4*col[8*4]; - a3 += + W4*col[8*4]; - } - - if (col[8*5]) { - MAC16(b0, + W5, col[8*5]); - MAC16(b1, - W1, col[8*5]); - MAC16(b2, + W7, col[8*5]); - MAC16(b3, + W3, col[8*5]); - } - - if(col[8*6]){ - a0 += + W6*col[8*6]; - a1 += - W2*col[8*6]; - a2 += + W2*col[8*6]; - a3 += - W6*col[8*6]; - } - - if (col[8*7]) { - MAC16(b0, + W7, col[8*7]); - MAC16(b1, - W5, col[8*7]); - MAC16(b2, + W3, col[8*7]); - MAC16(b3, - W1, col[8*7]); - } - - dest[0] = cm[(a0 + b0) >> COL_SHIFT]; - dest += line_size; - dest[0] = cm[(a1 + b1) >> COL_SHIFT]; - dest += line_size; - dest[0] = cm[(a2 + b2) >> COL_SHIFT]; - dest += line_size; - dest[0] = cm[(a3 + b3) >> COL_SHIFT]; - dest += line_size; - dest[0] = cm[(a3 - b3) >> COL_SHIFT]; - dest += line_size; - dest[0] = cm[(a2 - b2) >> COL_SHIFT]; - dest += line_size; - dest[0] = cm[(a1 - b1) >> COL_SHIFT]; - dest += line_size; - dest[0] = cm[(a0 - b0) >> COL_SHIFT]; -} - -static inline void idctSparseColAdd (uint8_t *dest, int line_size, - DCTELEM * col) -{ - int a0, a1, a2, a3, b0, b1, b2, b3; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - - /* XXX: I did that only to give same values as previous code */ - a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); - a1 = a0; - a2 = a0; - a3 = a0; - - a0 += + W2*col[8*2]; - a1 += + W6*col[8*2]; - a2 += - W6*col[8*2]; - a3 += - W2*col[8*2]; - - b0 = MUL16(W1, col[8*1]); - b1 = MUL16(W3, col[8*1]); - b2 = MUL16(W5, col[8*1]); - b3 = MUL16(W7, col[8*1]); - - MAC16(b0, + W3, col[8*3]); - MAC16(b1, - W7, col[8*3]); - MAC16(b2, - W1, col[8*3]); - MAC16(b3, - W5, col[8*3]); - - if(col[8*4]){ - a0 += + W4*col[8*4]; - a1 += - W4*col[8*4]; - a2 += - W4*col[8*4]; - a3 += + W4*col[8*4]; - } - - if (col[8*5]) { - MAC16(b0, + W5, col[8*5]); - MAC16(b1, - W1, col[8*5]); - MAC16(b2, + W7, col[8*5]); - MAC16(b3, + W3, col[8*5]); - } - - if(col[8*6]){ - a0 += + W6*col[8*6]; - a1 += - W2*col[8*6]; - a2 += + W2*col[8*6]; - a3 += - W6*col[8*6]; - } - - if (col[8*7]) { - MAC16(b0, + W7, col[8*7]); - MAC16(b1, - W5, col[8*7]); - MAC16(b2, + W3, col[8*7]); - MAC16(b3, - W1, col[8*7]); - } - - dest[0] = cm[dest[0] + ((a0 + b0) >> COL_SHIFT)]; - dest += line_size; - dest[0] = cm[dest[0] + ((a1 + b1) >> COL_SHIFT)]; - dest += line_size; - dest[0] = cm[dest[0] + ((a2 + b2) >> COL_SHIFT)]; - dest += line_size; - dest[0] = cm[dest[0] + ((a3 + b3) >> COL_SHIFT)]; - dest += line_size; - dest[0] = cm[dest[0] + ((a3 - b3) >> COL_SHIFT)]; - dest += line_size; - dest[0] = cm[dest[0] + ((a2 - b2) >> COL_SHIFT)]; - dest += line_size; - dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)]; - dest += line_size; - dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)]; -} - -static inline void idctSparseCol (DCTELEM * col) -{ - int a0, a1, a2, a3, b0, b1, b2, b3; - - /* XXX: I did that only to give same values as previous code */ - a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); - a1 = a0; - a2 = a0; - a3 = a0; - - a0 += + W2*col[8*2]; - a1 += + W6*col[8*2]; - a2 += - W6*col[8*2]; - a3 += - W2*col[8*2]; - - b0 = MUL16(W1, col[8*1]); - b1 = MUL16(W3, col[8*1]); - b2 = MUL16(W5, col[8*1]); - b3 = MUL16(W7, col[8*1]); - - MAC16(b0, + W3, col[8*3]); - MAC16(b1, - W7, col[8*3]); - MAC16(b2, - W1, col[8*3]); - MAC16(b3, - W5, col[8*3]); - - if(col[8*4]){ - a0 += + W4*col[8*4]; - a1 += - W4*col[8*4]; - a2 += - W4*col[8*4]; - a3 += + W4*col[8*4]; - } - - if (col[8*5]) { - MAC16(b0, + W5, col[8*5]); - MAC16(b1, - W1, col[8*5]); - MAC16(b2, + W7, col[8*5]); - MAC16(b3, + W3, col[8*5]); - } - - if(col[8*6]){ - a0 += + W6*col[8*6]; - a1 += - W2*col[8*6]; - a2 += + W2*col[8*6]; - a3 += - W6*col[8*6]; - } - - if (col[8*7]) { - MAC16(b0, + W7, col[8*7]); - MAC16(b1, - W5, col[8*7]); - MAC16(b2, + W3, col[8*7]); - MAC16(b3, - W1, col[8*7]); - } - - col[0 ] = ((a0 + b0) >> COL_SHIFT); - col[8 ] = ((a1 + b1) >> COL_SHIFT); - col[16] = ((a2 + b2) >> COL_SHIFT); - col[24] = ((a3 + b3) >> COL_SHIFT); - col[32] = ((a3 - b3) >> COL_SHIFT); - col[40] = ((a2 - b2) >> COL_SHIFT); - col[48] = ((a1 - b1) >> COL_SHIFT); - col[56] = ((a0 - b0) >> COL_SHIFT); -} - -void ff_simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block) -{ - int i; - for(i=0; i<8; i++) - idctRowCondDC(block + i*8); - - for(i=0; i<8; i++) - idctSparseColPut(dest + i, line_size, block + i); -} - -void ff_simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block) -{ - int i; - for(i=0; i<8; i++) - idctRowCondDC(block + i*8); - - for(i=0; i<8; i++) - idctSparseColAdd(dest + i, line_size, block + i); -} - -void ff_simple_idct(DCTELEM *block) -{ - int i; - for(i=0; i<8; i++) - idctRowCondDC(block + i*8); - - for(i=0; i<8; i++) - idctSparseCol(block + i); -} +#define BIT_DEPTH 10 +#include "simple_idct_template.c" +#undef BIT_DEPTH /* 2x4x8 idct */ @@ -428,7 +108,7 @@ void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block) /* IDCT8 on each line */ for(i=0; i<8; i++) { - idctRowCondDC(block + i*8); + idctRowCondDC_8(block + i*8); } /* IDCT4 and store */ @@ -503,7 +183,7 @@ void ff_simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block) /* IDCT8 on each line */ for(i=0; i<4; i++) { - idctRowCondDC(block + i*8); + idctRowCondDC_8(block + i*8); } /* IDCT4 and store */ @@ -523,7 +203,7 @@ void ff_simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block) /* IDCT8 and store */ for(i=0; i<4; i++){ - idctSparseColAdd(dest + i, line_size, block + i); + idctSparseColAdd_8(dest + i, line_size, block + i); } } diff --git a/libavcodec/simple_idct.h b/libavcodec/simple_idct.h index 23bae9c2fe..a33eb964ce 100644 --- a/libavcodec/simple_idct.h +++ b/libavcodec/simple_idct.h @@ -31,12 +31,17 @@ #include #include "dsputil.h" -void ff_simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block); -void ff_simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block); +void ff_simple_idct_put_8(uint8_t *dest, int line_size, DCTELEM *block); +void ff_simple_idct_add_8(uint8_t *dest, int line_size, DCTELEM *block); +void ff_simple_idct_8(DCTELEM *block); + +void ff_simple_idct_put_10(uint8_t *dest, int line_size, DCTELEM *block); +void ff_simple_idct_add_10(uint8_t *dest, int line_size, DCTELEM *block); +void ff_simple_idct_10(DCTELEM *block); + void ff_simple_idct_mmx(int16_t *block); void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block); void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block); -void ff_simple_idct(DCTELEM *block); void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block); diff --git a/libavcodec/simple_idct_template.c b/libavcodec/simple_idct_template.c new file mode 100644 index 0000000000..be49cb9570 --- /dev/null +++ b/libavcodec/simple_idct_template.c @@ -0,0 +1,401 @@ +/* + * Simple IDCT + * + * Copyright (c) 2001 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * simpleidct in C. + */ + +/* + based upon some outcommented c code from mpeg2dec (idct_mmx.c + written by Aaron Holtzman ) + */ + +#include "bit_depth_template.c" + +#undef W1 +#undef W2 +#undef W3 +#undef W4 +#undef W5 +#undef W6 +#undef W7 +#undef ROW_SHIFT +#undef COL_SHIFT +#undef DC_SHIFT +#undef MUL +#undef MAC + +#if BIT_DEPTH == 8 + +#define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define W4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define W5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define W6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define W7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 + +#define ROW_SHIFT 11 +#define COL_SHIFT 20 +#define DC_SHIFT 3 + +#define MUL(a, b) MUL16(a, b) +#define MAC(a, b, c) MAC16(a, b, c) + +#elif BIT_DEPTH == 10 + +#define W1 90901 +#define W2 85627 +#define W3 77062 +#define W4 65535 +#define W5 51491 +#define W6 35468 +#define W7 18081 + +#define ROW_SHIFT 15 +#define COL_SHIFT 20 +#define DC_SHIFT 1 + +#define MUL(a, b) ((a) * (b)) +#define MAC(a, b, c) ((a) += (b) * (c)) + +#else + +#error "Unsupported bitdepth" + +#endif + +static inline void FUNC(idctRowCondDC)(DCTELEM *row) +{ + int a0, a1, a2, a3, b0, b1, b2, b3; + +#if HAVE_FAST_64BIT +#define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN) + if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) { + uint64_t temp = (row[0] << DC_SHIFT) & 0xffff; + temp += temp << 16; + temp += temp << 32; + ((uint64_t *)row)[0] = temp; + ((uint64_t *)row)[1] = temp; + return; + } +#else + if (!(((uint32_t*)row)[1] | + ((uint32_t*)row)[2] | + ((uint32_t*)row)[3] | + row[1])) { + uint32_t temp = (row[0] << DC_SHIFT) & 0xffff; + temp += temp << 16; + ((uint32_t*)row)[0]=((uint32_t*)row)[1] = + ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp; + return; + } +#endif + + a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1)); + a1 = a0; + a2 = a0; + a3 = a0; + + /* no need to optimize : gcc does it */ + a0 += W2 * row[2]; + a1 += W6 * row[2]; + a2 -= W6 * row[2]; + a3 -= W2 * row[2]; + + b0 = MUL(W1, row[1]); + MAC(b0, W3, row[3]); + b1 = MUL(W3, row[1]); + MAC(b1, -W7, row[3]); + b2 = MUL(W5, row[1]); + MAC(b2, -W1, row[3]); + b3 = MUL(W7, row[1]); + MAC(b3, -W5, row[3]); + + if (AV_RN64A(row + 4)) { + a0 += W4*row[4] + W6*row[6]; + a1 += - W4*row[4] - W2*row[6]; + a2 += - W4*row[4] + W2*row[6]; + a3 += W4*row[4] - W6*row[6]; + + MAC(b0, W5, row[5]); + MAC(b0, W7, row[7]); + + MAC(b1, -W1, row[5]); + MAC(b1, -W5, row[7]); + + MAC(b2, W7, row[5]); + MAC(b2, W3, row[7]); + + MAC(b3, W3, row[5]); + MAC(b3, -W1, row[7]); + } + + row[0] = (a0 + b0) >> ROW_SHIFT; + row[7] = (a0 - b0) >> ROW_SHIFT; + row[1] = (a1 + b1) >> ROW_SHIFT; + row[6] = (a1 - b1) >> ROW_SHIFT; + row[2] = (a2 + b2) >> ROW_SHIFT; + row[5] = (a2 - b2) >> ROW_SHIFT; + row[3] = (a3 + b3) >> ROW_SHIFT; + row[4] = (a3 - b3) >> ROW_SHIFT; +} + +static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size, + DCTELEM *col) +{ + int a0, a1, a2, a3, b0, b1, b2, b3; + INIT_CLIP; + + /* XXX: I did that only to give same values as previous code */ + a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); + a1 = a0; + a2 = a0; + a3 = a0; + + a0 += + W2*col[8*2]; + a1 += + W6*col[8*2]; + a2 += - W6*col[8*2]; + a3 += - W2*col[8*2]; + + b0 = MUL(W1, col[8*1]); + b1 = MUL(W3, col[8*1]); + b2 = MUL(W5, col[8*1]); + b3 = MUL(W7, col[8*1]); + + MAC(b0, + W3, col[8*3]); + MAC(b1, - W7, col[8*3]); + MAC(b2, - W1, col[8*3]); + MAC(b3, - W5, col[8*3]); + + if(col[8*4]){ + a0 += + W4*col[8*4]; + a1 += - W4*col[8*4]; + a2 += - W4*col[8*4]; + a3 += + W4*col[8*4]; + } + + if (col[8*5]) { + MAC(b0, + W5, col[8*5]); + MAC(b1, - W1, col[8*5]); + MAC(b2, + W7, col[8*5]); + MAC(b3, + W3, col[8*5]); + } + + if(col[8*6]){ + a0 += + W6*col[8*6]; + a1 += - W2*col[8*6]; + a2 += + W2*col[8*6]; + a3 += - W6*col[8*6]; + } + + if (col[8*7]) { + MAC(b0, + W7, col[8*7]); + MAC(b1, - W5, col[8*7]); + MAC(b2, + W3, col[8*7]); + MAC(b3, - W1, col[8*7]); + } + + dest[0] = CLIP((a0 + b0) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a1 + b1) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a2 + b2) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a3 + b3) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a3 - b3) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a2 - b2) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a1 - b1) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a0 - b0) >> COL_SHIFT); +} + +static inline void FUNC(idctSparseColAdd)(pixel *dest, int line_size, + DCTELEM *col) +{ + int a0, a1, a2, a3, b0, b1, b2, b3; + INIT_CLIP; + + /* XXX: I did that only to give same values as previous code */ + a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); + a1 = a0; + a2 = a0; + a3 = a0; + + a0 += + W2*col[8*2]; + a1 += + W6*col[8*2]; + a2 += - W6*col[8*2]; + a3 += - W2*col[8*2]; + + b0 = MUL(W1, col[8*1]); + b1 = MUL(W3, col[8*1]); + b2 = MUL(W5, col[8*1]); + b3 = MUL(W7, col[8*1]); + + MAC(b0, + W3, col[8*3]); + MAC(b1, - W7, col[8*3]); + MAC(b2, - W1, col[8*3]); + MAC(b3, - W5, col[8*3]); + + if(col[8*4]){ + a0 += + W4*col[8*4]; + a1 += - W4*col[8*4]; + a2 += - W4*col[8*4]; + a3 += + W4*col[8*4]; + } + + if (col[8*5]) { + MAC(b0, + W5, col[8*5]); + MAC(b1, - W1, col[8*5]); + MAC(b2, + W7, col[8*5]); + MAC(b3, + W3, col[8*5]); + } + + if(col[8*6]){ + a0 += + W6*col[8*6]; + a1 += - W2*col[8*6]; + a2 += + W2*col[8*6]; + a3 += - W6*col[8*6]; + } + + if (col[8*7]) { + MAC(b0, + W7, col[8*7]); + MAC(b1, - W5, col[8*7]); + MAC(b2, + W3, col[8*7]); + MAC(b3, - W1, col[8*7]); + } + + dest[0] = CLIP(dest[0] + ((a0 + b0) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a1 + b1) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a2 + b2) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a3 + b3) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a3 - b3) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a2 - b2) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a1 - b1) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a0 - b0) >> COL_SHIFT)); +} + +static inline void FUNC(idctSparseCol)(DCTELEM *col) +{ + int a0, a1, a2, a3, b0, b1, b2, b3; + + /* XXX: I did that only to give same values as previous code */ + a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); + a1 = a0; + a2 = a0; + a3 = a0; + + a0 += + W2*col[8*2]; + a1 += + W6*col[8*2]; + a2 += - W6*col[8*2]; + a3 += - W2*col[8*2]; + + b0 = MUL(W1, col[8*1]); + b1 = MUL(W3, col[8*1]); + b2 = MUL(W5, col[8*1]); + b3 = MUL(W7, col[8*1]); + + MAC(b0, + W3, col[8*3]); + MAC(b1, - W7, col[8*3]); + MAC(b2, - W1, col[8*3]); + MAC(b3, - W5, col[8*3]); + + if(col[8*4]){ + a0 += + W4*col[8*4]; + a1 += - W4*col[8*4]; + a2 += - W4*col[8*4]; + a3 += + W4*col[8*4]; + } + + if (col[8*5]) { + MAC(b0, + W5, col[8*5]); + MAC(b1, - W1, col[8*5]); + MAC(b2, + W7, col[8*5]); + MAC(b3, + W3, col[8*5]); + } + + if(col[8*6]){ + a0 += + W6*col[8*6]; + a1 += - W2*col[8*6]; + a2 += + W2*col[8*6]; + a3 += - W6*col[8*6]; + } + + if (col[8*7]) { + MAC(b0, + W7, col[8*7]); + MAC(b1, - W5, col[8*7]); + MAC(b2, + W3, col[8*7]); + MAC(b3, - W1, col[8*7]); + } + + col[0 ] = ((a0 + b0) >> COL_SHIFT); + col[8 ] = ((a1 + b1) >> COL_SHIFT); + col[16] = ((a2 + b2) >> COL_SHIFT); + col[24] = ((a3 + b3) >> COL_SHIFT); + col[32] = ((a3 - b3) >> COL_SHIFT); + col[40] = ((a2 - b2) >> COL_SHIFT); + col[48] = ((a1 - b1) >> COL_SHIFT); + col[56] = ((a0 - b0) >> COL_SHIFT); +} + +void FUNC(ff_simple_idct_put)(uint8_t *dest_, int line_size, DCTELEM *block) +{ + pixel *dest = (pixel *)dest_; + int i; + for(i=0; i<8; i++) + FUNC(idctRowCondDC)(block + i*8); + + for(i=0; i<8; i++) + FUNC(idctSparseColPut)(dest + i, line_size, block + i); +} + +void FUNC(ff_simple_idct_add)(uint8_t *dest_, int line_size, DCTELEM *block) +{ + pixel *dest = (pixel *)dest_; + int i; + for(i=0; i<8; i++) + FUNC(idctRowCondDC)(block + i*8); + + for(i=0; i<8; i++) + FUNC(idctSparseColAdd)(dest + i, line_size, block + i); +} + +void FUNC(ff_simple_idct)(DCTELEM *block) +{ + int i; + for(i=0; i<8; i++) + FUNC(idctRowCondDC)(block + i*8); + + for(i=0; i<8; i++) + FUNC(idctSparseCol)(block + i); +} diff --git a/libavcodec/sparc/dsputil_vis.c b/libavcodec/sparc/dsputil_vis.c index ab9258b2b9..9811b2622e 100644 --- a/libavcodec/sparc/dsputil_vis.c +++ b/libavcodec/sparc/dsputil_vis.c @@ -3956,7 +3956,8 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx) const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; if (accel & ACCEL_SPARC_VIS) { - if(avctx->idct_algo==FF_IDCT_SIMPLEVIS){ + if (avctx->bits_per_raw_sample <= 8 && + avctx->idct_algo == FF_IDCT_SIMPLEVIS) { c->idct_put = ff_simple_idct_put_vis; c->idct_add = ff_simple_idct_add_vis; c->idct = ff_simple_idct_vis; diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 32869b97d1..1f83dd27b8 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -337,11 +337,11 @@ int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitConte v->res_fasttx = get_bits1(gb); if (!v->res_fasttx) { - v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct; + v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct_8; v->vc1dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add; v->vc1dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add; v->vc1dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add; - v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add; + v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add_8; v->vc1dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add; v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add; v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add; diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 29fff276ad..84ae47b04d 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2465,7 +2465,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) if (mm_flags & AV_CPU_FLAG_MMX) { const int idct_algo= avctx->idct_algo; - if(avctx->lowres==0){ + if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) { if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){ c->idct_put= ff_simple_idct_put_mmx; c->idct_add= ff_simple_idct_add_mmx; From d9a9f50a3683b577e9c391ce8cab9edc9b239fcb Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Mon, 18 Jul 2011 17:48:45 -0700 Subject: [PATCH 612/780] dsputil: Replace a LONG_MAX check with HAVE_FAST_64BIT. --- libavcodec/dsputil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 4b26f68387..457495f07e 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -185,7 +185,7 @@ static int pix_norm1_c(uint8_t * pix, int line_size) s += sq[pix[6]]; s += sq[pix[7]]; #else -#if LONG_MAX > 2147483647 +#if HAVE_FAST_64BIT register uint64_t x=*(uint64_t*)pix; s += sq[x&0xff]; s += sq[(x>>8)&0xff]; From e4b50572b7bae9edd0374f2ef918e6c68a4da018 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Mon, 18 Jul 2011 17:49:23 -0700 Subject: [PATCH 613/780] dsputil: Remove extra blank line at end. --- libavcodec/dsputil.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 457495f07e..fa9b591fad 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -3266,4 +3266,3 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n"); } } - From 80469eafb747018cb9d9a2547f65def715d073b2 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 20 Jul 2011 09:24:07 -0700 Subject: [PATCH 614/780] mpegvideo: fix invalid picture unreferencing. Mpegvideo would free frames as soon as they're not the next or prev picture. This is fine for a single-threading model, but fails miserably in a system where pictures can be referenced (as e.g. last/prev pic) in other threads. Keeping track of ownership of pictures keeps image references (e.g. motion vectors, or the reference of a motion vector) alive as long as the picture data itself is alive. This also happens to fix make THREADS=[3-16] fate-vsynth[12]-error. --- libavcodec/mpegvideo.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 27dcd74a5a..d422e12bc1 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -318,7 +318,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){ s->prev_pict_types[0]= s->dropable ? AV_PICTURE_TYPE_B : s->pict_type; if (pic->f.age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->f.age] == AV_PICTURE_TYPE_B) pic->f.age = INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway. - pic->owner2 = NULL; + pic->owner2 = s; return 0; fail: //for the FF_ALLOCZ_OR_GOTO macro @@ -1041,14 +1041,16 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) /* mark&release old frames */ if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->f.data[0]) { if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){ - free_frame_buffer(s, s->last_picture_ptr); + if (s->last_picture_ptr->owner2 == s) + free_frame_buffer(s, s->last_picture_ptr); /* release forgotten pictures */ /* if(mpeg124/h263) */ if(!s->encoding){ for(i=0; ipicture_count; i++){ - if (s->picture[i].f.data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].f.reference) { - av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n"); + if (s->picture[i].owner2 == s && s->picture[i].f.data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].f.reference) { + if (!(avctx->active_thread_type & FF_THREAD_FRAME)) + av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n"); free_frame_buffer(s, &s->picture[i]); } } From a005174b2500c180b9e7344d882af6cf79c79d8f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 20 Jul 2011 18:37:15 +0200 Subject: [PATCH 615/780] Remove unused code under G729_BITEXACT #ifdef. G729_BITEXACT is never set, so the code is all dead code. --- libavcodec/acelp_pitch_delay.c | 11 ----- libavcodec/celp_math.c | 85 ---------------------------------- libavcodec/lsp.c | 4 -- 3 files changed, 100 deletions(-) diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c index 2b791b5aa3..395247dd2a 100644 --- a/libavcodec/acelp_pitch_delay.c +++ b/libavcodec/acelp_pitch_delay.c @@ -105,20 +105,9 @@ int16_t ff_acelp_decode_gain_code( for(i=0; iscalarproduct_int16(fc_v, fc_v, subframe_size, 0))) >> 3) & ~0x3ff); - - mr_energy = (5439 * (mr_energy >> 15)) >> 8; // (0.15) = (0.15) * (7.23) - - return bidir_sal( - ((ff_exp2(mr_energy & 0x7fff) + 16) >> 5) * (gain_corr_factor >> 1), - (mr_energy >> 15) - 25 - ); -#else mr_energy = gain_corr_factor * exp(M_LN10 / (20 << 23) * mr_energy) / sqrt(dsp->scalarproduct_int16(fc_v, fc_v, subframe_size, 0)); return mr_energy >> 12; -#endif } float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy, diff --git a/libavcodec/celp_math.c b/libavcodec/celp_math.c index 4ab20ad29f..8d36d4e900 100644 --- a/libavcodec/celp_math.c +++ b/libavcodec/celp_math.c @@ -27,82 +27,6 @@ #include "avcodec.h" #include "celp_math.h" -#ifdef G729_BITEXACT -/** - * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64) - */ -static const int16_t base_cos[64] = -{ - 32767, 32729, 32610, 32413, 32138, 31786, 31357, 30853, - 30274, 29622, 28899, 28106, 27246, 26320, 25330, 24279, - 23170, 22006, 20788, 19520, 18205, 16846, 15447, 14010, - 12540, 11039, 9512, 7962, 6393, 4808, 3212, 1608, - 0, -1608, -3212, -4808, -6393, -7962, -9512, -11039, - -12540, -14010, -15447, -16846, -18205, -19520, -20788, -22006, - -23170, -24279, -25330, -26320, -27246, -28106, -28899, -29622, - -30274, -30853, -31357, -31786, -32138, -32413, -32610, -32729 -}; - -/** - * Slope used to compute cos(x) - * - * cos(ind*64+offset) = base_cos[ind]+offset*slope_cos[ind] - * values multiplied by 1<<19 - */ -static const int16_t slope_cos[64] = -{ - -632, -1893, -3150, -4399, -5638, -6863, -8072, -9261, - -10428, -11570, -12684, -13767, -14817, -15832, -16808, -17744, - -18637, -19486, -20287, -21039, -21741, -22390, -22986, -23526, - -24009, -24435, -24801, -25108, -25354, -25540, -25664, -25726, - -25726, -25664, -25540, -25354, -25108, -24801, -24435, -24009, - -23526, -22986, -22390, -21741, -21039, -20287, -19486, -18637, - -17744, -16808, -15832, -14817, -13767, -12684, -11570, -10428, - -9261, -8072, -6863, -5638, -4399, -3150, -1893, -632 -}; - -/** - * Table used to compute exp2(x) - * - * tab_exp2[i] = (1<<14) * exp2(i/32) = 2^(i/32) i=0..32 - */ -static const uint16_t tab_exp2[33] = -{ - 16384, 16743, 17109, 17484, 17867, 18258, 18658, 19066, 19484, 19911, - 20347, 20792, 21247, 21713, 22188, 22674, 23170, 23678, 24196, 24726, - 25268, 25821, 26386, 26964, 27554, 28158, 28774, 29405, 30048, 30706, - 31379, 32066, 32767 -}; - -int16_t ff_cos(uint16_t arg) -{ - uint8_t offset= arg; - uint8_t ind = arg >> 8; - - assert(arg < 0x4000); - - return FFMAX(base_cos[ind] + ((slope_cos[ind] * offset) >> 12), -0x8000); -} - -int ff_exp2(uint16_t power) -{ - uint16_t frac_x0; - uint16_t frac_dx; - int result; - - assert(power <= 0x7fff); - - frac_x0 = power >> 10; - frac_dx = (power & 0x03ff) << 5; - - result = tab_exp2[frac_x0] << 15; - result += frac_dx * (tab_exp2[frac_x0+1] - tab_exp2[frac_x0]); - - return result >> 10; -} - -#else // G729_BITEXACT - /** * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64) */ @@ -154,8 +78,6 @@ int ff_exp2(uint16_t power) return result + ((result*(power&31)*89)>>22); } -#endif // else G729_BITEXACT - /** * Table used to compute log2(x) * @@ -163,17 +85,10 @@ int ff_exp2(uint16_t power) */ static const uint16_t tab_log2[33] = { -#ifdef G729_BITEXACT - 0, 1455, 2866, 4236, 5568, 6863, 8124, 9352, - 10549, 11716, 12855, 13967, 15054, 16117, 17156, 18172, - 19167, 20142, 21097, 22033, 22951, 23852, 24735, 25603, - 26455, 27291, 28113, 28922, 29716, 30497, 31266, 32023, 32767, -#else 4, 1459, 2870, 4240, 5572, 6867, 8127, 9355, 10552, 11719, 12858, 13971, 15057, 16120, 17158, 18175, 19170, 20145, 21100, 22036, 22954, 23854, 24738, 25605, 26457, 27294, 28116, 28924, 29719, 30500, 31269, 32025, 32769, -#endif }; int ff_log2(uint32_t value) diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c index 1b4afa22e8..834346bc25 100644 --- a/libavcodec/lsp.c +++ b/libavcodec/lsp.c @@ -150,11 +150,7 @@ void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd /* LSP values for first subframe (3.2.5 of G.729, Equation 24)*/ for(i=0; i> 1) + (lsp_prev[i] >> 1); -#else lsp_1st[i] = (lsp_2nd[i] + lsp_prev[i]) >> 1; -#endif ff_acelp_lsp2lpc(lp_1st, lsp_1st, lp_order >> 1); From 79a9aab56f06b870bfb8090e8e29fabdd0cfc6df Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 15 Jul 2011 02:37:33 +0200 Subject: [PATCH 616/780] Remove unused and non-compiling vestigial g729 decoder --- libavcodec/acelp_vectors.c | 20 --- libavcodec/acelp_vectors.h | 31 ---- libavcodec/amrnbdec.c | 2 +- libavcodec/g729data.h | 278 ------------------------------- libavcodec/g729dec.c | 331 ------------------------------------- 5 files changed, 1 insertion(+), 661 deletions(-) delete mode 100644 libavcodec/g729data.h delete mode 100644 libavcodec/g729dec.c diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c index 25a6ff27df..b7c05e743f 100644 --- a/libavcodec/acelp_vectors.c +++ b/libavcodec/acelp_vectors.c @@ -48,26 +48,6 @@ const uint8_t ff_fc_2pulses_9bits_track1_gray[16] = 28, 26, }; -const uint8_t ff_fc_2pulses_9bits_track2_gray[32] = -{ - 0, 2, - 5, 4, - 12, 10, - 7, 9, - 25, 24, - 20, 22, - 14, 15, - 19, 17, - 36, 31, - 21, 26, - 1, 6, - 16, 11, - 27, 29, - 32, 30, - 39, 37, - 34, 35, -}; - const uint8_t ff_fc_4pulses_8bits_tracks_13[16] = { 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, diff --git a/libavcodec/acelp_vectors.h b/libavcodec/acelp_vectors.h index 07d1000d3f..2c5d319e45 100644 --- a/libavcodec/acelp_vectors.h +++ b/libavcodec/acelp_vectors.h @@ -81,37 +81,6 @@ extern const uint8_t ff_fc_4pulses_8bits_track_4[32]; extern const uint8_t ff_fc_2pulses_9bits_track1[16]; extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16]; -/** - * Track|Pulse| Positions - * ----------------------------------------- - * 2 | 1 | 0, 7, 14, 20, 27, 34, 1, 21 - * | | 2, 9, 15, 22, 29, 35, 6, 26 - * | | 4,10, 17, 24, 30, 37, 11, 31 - * | | 5,12, 19, 25, 32, 39, 16, 36 - * ----------------------------------------- - * - * @remark Track in the table should be read top-to-bottom, left-to-right. - * - * @note (EE.1) This table (from the reference code) does not comply with - * the specification. - * The specification contains the following table: - * - * Track|Pulse| Positions - * ----------------------------------------- - * 2 | 1 | 0, 5, 10, 15, 20, 25, 30, 35 - * | | 1, 6, 11, 16, 21, 26, 31, 36 - * | | 2, 7, 12, 17, 22, 27, 32, 37 - * | | 4, 9, 14, 19, 24, 29, 34, 39 - * - * ----------------------------------------- - * - * @note (EE.2) Reference G.729D code also uses gray decoding for each - * pulse index before looking up the value in the table. - * - * Used in G.729 @@6.4k (with gray coding) - */ -extern const uint8_t ff_fc_2pulses_9bits_track2_gray[32]; - /** * b60 hamming windowed sinc function coefficients */ diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index 1c90aadb12..501b137780 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -83,7 +83,7 @@ /** Maximum sharpening factor * * The specification says 0.8, which should be 13107, but the reference C code - * uses 13017 instead. (Amusingly the same applies to SHARP_MAX in g729dec.c.) + * uses 13017 instead. (Amusingly the same applies to SHARP_MAX in bitexact G.729.) */ #define SHARP_MAX 0.79449462890625 diff --git a/libavcodec/g729data.h b/libavcodec/g729data.h deleted file mode 100644 index 48010a7683..0000000000 --- a/libavcodec/g729data.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * data for G.729 decoder - * Copyright (c) 2007 Vladimir Voroshilov - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_G729DATA_H -#define AVCODEC_G729DATA_H - -#include - -#define MA_NP 4 ///< Moving Average (MA) prediction order - -#define VQ_1ST_BITS 7 ///< first stage vector of quantizer (size in bits) -#define VQ_2ND_BITS 5 ///< second stage vector of quantizer (size in bits) - -#define GC_1ST_IDX_BITS_8K 3 ///< gain codebook (first stage) index, 8k mode (size in bits) -#define GC_2ND_IDX_BITS_8K 4 ///< gain codebook (second stage) index, 8k mode (size in bits) - -#define GC_1ST_IDX_BITS_6K4 3 ///< gain codebook (first stage) index, 6.4k mode (size in bits) -#define GC_2ND_IDX_BITS_6K4 3 ///< gain codebook (second stage) index, 6.4k mode (size in bits) - -/** - * first stage LSP codebook - * (10-dimensional, with 128 entries (3.24 of G.729) - */ -static const int16_t cb_lsp_1st[1< -#include -#include -#include -#include -#include -#include - -#include "avcodec.h" -#include "libavutil/avutil.h" -#include "get_bits.h" - -#include "lsp.h" -#include "celp_math.h" -#include "acelp_filters.h" -#include "acelp_pitch_delay.h" -#include "acelp_vectors.h" -#include "g729data.h" - -/** - * minimum quantized LSF value (3.2.4) - * 0.005 in Q13 - */ -#define LSFQ_MIN 40 - -/** - * maximum quantized LSF value (3.2.4) - * 3.135 in Q13 - */ -#define LSFQ_MAX 25681 - -/** - * minimum LSF distance (3.2.4) - * 0.0391 in Q13 - */ -#define LSFQ_DIFF_MIN 321 - -/** - * minimum gain pitch value (3.8, Equation 47) - * 0.2 in (1.14) - */ -#define SHARP_MIN 3277 - -/** - * maximum gain pitch value (3.8, Equation 47) - * (EE) This does not comply with the specification. - * Specification says about 0.8, which should be - * 13107 in (1.14), but reference C code uses - * 13017 (equals to 0.7945) instead of it. - */ -#define SHARP_MAX 13017 - -/** - * subframe size - */ -#define SUBFRAME_SIZE 40 - - -typedef struct { - uint8_t ac_index_bits[2]; ///< adaptive codebook index for second subframe (size in bits) - uint8_t parity_bit; ///< parity bit for pitch delay - uint8_t gc_1st_index_bits; ///< gain codebook (first stage) index (size in bits) - uint8_t gc_2nd_index_bits; ///< gain codebook (second stage) index (size in bits) - uint8_t fc_signs_bits; ///< number of pulses in fixed-codebook vector - uint8_t fc_indexes_bits; ///< size (in bits) of fixed-codebook index entry -} G729FormatDescription; - -typedef struct { - int pitch_delay_int_prev; ///< integer part of previous subframe's pitch delay (4.1.3) - - /// (2.13) LSP quantizer outputs - int16_t past_quantizer_output_buf[MA_NP + 1][10]; - int16_t* past_quantizer_outputs[MA_NP + 1]; - - int16_t lsfq[10]; ///< (2.13) quantized LSF coefficients from previous frame - int16_t lsp_buf[2][10]; ///< (0.15) LSP coefficients (previous and current frames) (3.2.5) - int16_t *lsp[2]; ///< pointers to lsp_buf -} G729Context; - -static const G729FormatDescription format_g729_8k = { - .ac_index_bits = {8,5}, - .parity_bit = 1, - .gc_1st_index_bits = GC_1ST_IDX_BITS_8K, - .gc_2nd_index_bits = GC_2ND_IDX_BITS_8K, - .fc_signs_bits = 4, - .fc_indexes_bits = 13, -}; - -static const G729FormatDescription format_g729d_6k4 = { - .ac_index_bits = {8,4}, - .parity_bit = 0, - .gc_1st_index_bits = GC_1ST_IDX_BITS_6K4, - .gc_2nd_index_bits = GC_2ND_IDX_BITS_6K4, - .fc_signs_bits = 2, - .fc_indexes_bits = 9, -}; - -/** - * @brief pseudo random number generator - */ -static inline uint16_t g729_prng(uint16_t value) -{ - return 31821 * value + 13849; -} - -/** - * Get parity bit of bit 2..7 - */ -static inline int get_parity(uint8_t value) -{ - return (0x6996966996696996ULL >> (value >> 2)) & 1; -} - -static void lsf_decode(int16_t* lsfq, int16_t* past_quantizer_outputs[MA_NP + 1], - int16_t ma_predictor, - int16_t vq_1st, int16_t vq_2nd_low, int16_t vq_2nd_high) -{ - int i,j; - static const uint8_t min_distance[2]={10, 5}; //(2.13) - int16_t* quantizer_output = past_quantizer_outputs[MA_NP]; - - for (i = 0; i < 5; i++) { - quantizer_output[i] = cb_lsp_1st[vq_1st][i ] + cb_lsp_2nd[vq_2nd_low ][i ]; - quantizer_output[i + 5] = cb_lsp_1st[vq_1st][i + 5] + cb_lsp_2nd[vq_2nd_high][i + 5]; - } - - for (j = 0; j < 2; j++) { - for (i = 1; i < 10; i++) { - int diff = (quantizer_output[i - 1] - quantizer_output[i] + min_distance[j]) >> 1; - if (diff > 0) { - quantizer_output[i - 1] -= diff; - quantizer_output[i ] += diff; - } - } - } - - for (i = 0; i < 10; i++) { - int sum = quantizer_output[i] * cb_ma_predictor_sum[ma_predictor][i]; - for (j = 0; j < MA_NP; j++) - sum += past_quantizer_outputs[j][i] * cb_ma_predictor[ma_predictor][j][i]; - - lsfq[i] = sum >> 15; - } - - /* Rotate past_quantizer_outputs. */ - memmove(past_quantizer_outputs + 1, past_quantizer_outputs, MA_NP * sizeof(int16_t*)); - past_quantizer_outputs[0] = quantizer_output; - - ff_acelp_reorder_lsf(lsfq, LSFQ_DIFF_MIN, LSFQ_MIN, LSFQ_MAX, 10); -} - -static av_cold int decoder_init(AVCodecContext * avctx) -{ - G729Context* ctx = avctx->priv_data; - int i,k; - - if (avctx->channels != 1) { - av_log(avctx, AV_LOG_ERROR, "Only mono sound is supported (requested channels: %d).\n", avctx->channels); - return AVERROR(EINVAL); - } - - /* Both 8kbit/s and 6.4kbit/s modes uses two subframes per frame. */ - avctx->frame_size = SUBFRAME_SIZE << 1; - - for (k = 0; k < MA_NP + 1; k++) { - ctx->past_quantizer_outputs[k] = ctx->past_quantizer_output_buf[k]; - for (i = 1; i < 11; i++) - ctx->past_quantizer_outputs[k][i - 1] = (18717 * i) >> 3; - } - - ctx->lsp[0] = ctx->lsp_buf[0]; - ctx->lsp[1] = ctx->lsp_buf[1]; - memcpy(ctx->lsp[0], lsp_init, 10 * sizeof(int16_t)); - - return 0; -} - -static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, - AVPacket *avpkt) -{ - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; - int16_t *out_frame = data; - GetBitContext gb; - G729FormatDescription format; - int frame_erasure = 0; ///< frame erasure detected during decoding - int bad_pitch = 0; ///< parity check failed - int i; - G729Context *ctx = avctx->priv_data; - int16_t lp[2][11]; // (3.12) - uint8_t ma_predictor; ///< switched MA predictor of LSP quantizer - uint8_t quantizer_1st; ///< first stage vector of quantizer - uint8_t quantizer_2nd_lo; ///< second stage lower vector of quantizer (size in bits) - uint8_t quantizer_2nd_hi; ///< second stage higher vector of quantizer (size in bits) - - int pitch_delay_int; // pitch delay, integer part - int pitch_delay_3x; // pitch delay, multiplied by 3 - - if (*data_size < SUBFRAME_SIZE << 2) { - av_log(avctx, AV_LOG_ERROR, "Error processing packet: output buffer too small\n"); - return AVERROR(EIO); - } - - if (buf_size == 10) { - format = format_g729_8k; - av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729 @ 8kbit/s"); - } else if (buf_size == 8) { - format = format_g729d_6k4; - av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729D @ 6.4kbit/s"); - } else { - av_log(avctx, AV_LOG_ERROR, "Packet size %d is unknown.\n", buf_size); - return AVERROR_INVALIDDATA; - } - - for (i=0; i < buf_size; i++) - frame_erasure |= buf[i]; - frame_erasure = !frame_erasure; - - init_get_bits(&gb, buf, buf_size); - - ma_predictor = get_bits(&gb, 1); - quantizer_1st = get_bits(&gb, VQ_1ST_BITS); - quantizer_2nd_lo = get_bits(&gb, VQ_2ND_BITS); - quantizer_2nd_hi = get_bits(&gb, VQ_2ND_BITS); - - lsf_decode(ctx->lsfq, ctx->past_quantizer_outputs, - ma_predictor, - quantizer_1st, quantizer_2nd_lo, quantizer_2nd_hi); - - ff_acelp_lsf2lsp(ctx->lsp[1], ctx->lsfq, 10); - - ff_acelp_lp_decode(&lp[0][0], &lp[1][0], ctx->lsp[1], ctx->lsp[0], 10); - - FFSWAP(int16_t*, ctx->lsp[1], ctx->lsp[0]); - - for (i = 0; i < 2; i++) { - uint8_t ac_index; ///< adaptive codebook index - uint8_t pulses_signs; ///< fixed-codebook vector pulse signs - int fc_indexes; ///< fixed-codebook indexes - uint8_t gc_1st_index; ///< gain codebook (first stage) index - uint8_t gc_2nd_index; ///< gain codebook (second stage) index - - ac_index = get_bits(&gb, format.ac_index_bits[i]); - if(!i && format.parity_bit) - bad_pitch = get_parity(ac_index) == get_bits1(&gb); - fc_indexes = get_bits(&gb, format.fc_indexes_bits); - pulses_signs = get_bits(&gb, format.fc_signs_bits); - gc_1st_index = get_bits(&gb, format.gc_1st_index_bits); - gc_2nd_index = get_bits(&gb, format.gc_2nd_index_bits); - - if(!i) { - if (bad_pitch) - pitch_delay_3x = 3 * ctx->pitch_delay_int_prev; - else - pitch_delay_3x = ff_acelp_decode_8bit_to_1st_delay3(ac_index); - } else { - int pitch_delay_min = av_clip(ctx->pitch_delay_int_prev - 5, - PITCH_DELAY_MIN, PITCH_DELAY_MAX - 9); - - if(packet_type == FORMAT_G729D_6K4) - pitch_delay_3x = ff_acelp_decode_4bit_to_2nd_delay3(ac_index, pitch_delay_min); - else - pitch_delay_3x = ff_acelp_decode_5_6_bit_to_2nd_delay3(ac_index, pitch_delay_min); - } - - /* Round pitch delay to nearest (used everywhere except ff_acelp_interpolate). */ - pitch_delay_int = (pitch_delay_3x + 1) / 3; - - ff_acelp_weighted_vector_sum(fc + pitch_delay_int, - fc + pitch_delay_int, - fc, 1 << 14, - av_clip(ctx->gain_pitch, SHARP_MIN, SHARP_MAX), - 0, 14, - SUBFRAME_SIZE - pitch_delay_int); - - if (frame_erasure) { - ctx->gain_pitch = (29491 * ctx->gain_pitch) >> 15; // 0.90 (0.15) - ctx->gain_code = ( 2007 * ctx->gain_code ) >> 11; // 0.98 (0.11) - - gain_corr_factor = 0; - } else { - ctx->gain_pitch = cb_gain_1st_8k[gc_1st_index][0] + - cb_gain_2nd_8k[gc_2nd_index][0]; - gain_corr_factor = cb_gain_1st_8k[gc_1st_index][1] + - cb_gain_2nd_8k[gc_2nd_index][1]; - - ff_acelp_weighted_vector_sum(ctx->exc + i * SUBFRAME_SIZE, - ctx->exc + i * SUBFRAME_SIZE, fc, - (!voicing && frame_erasure) ? 0 : ctx->gain_pitch, - ( voicing && frame_erasure) ? 0 : ctx->gain_code, - 1 << 13, 14, SUBFRAME_SIZE); - - ctx->pitch_delay_int_prev = pitch_delay_int; - } - - *data_size = SUBFRAME_SIZE << 2; - return buf_size; -} - -AVCodec ff_g729_decoder = -{ - "g729", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_G729, - sizeof(G729Context), - decoder_init, - NULL, - NULL, - decode_frame, - .long_name = NULL_IF_CONFIG_SMALL("G.729"), -}; From 558c268318f968b77b1cd8bc55ad4429e4c39948 Mon Sep 17 00:00:00 2001 From: Sean McGovern Date: Wed, 20 Jul 2011 17:25:41 -0400 Subject: [PATCH 617/780] configure: add -xc99 to LDFLAGS for Sun CC Using Sun's compiler on Solaris, -xc99 is as much a linker flag as a compiler flag, so add it to LDFLAGS. Signed-off-by: Diego Biurrun --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 28e008fa1e..3953cfc44b 100755 --- a/configure +++ b/configure @@ -2014,6 +2014,7 @@ elif $cc -V 2>&1 | grep -q Sun; then cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-) DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)' DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1' + add_ldflags -xc99 speed_cflags='-O5' size_cflags='-O5 -xspace' filter_cflags=suncc_flags From eedb1f2034e18d4a292167aef5efea6606874a7b Mon Sep 17 00:00:00 2001 From: Joseph Artsimovich Date: Mon, 18 Jul 2011 11:22:15 +0100 Subject: [PATCH 618/780] swscale: mark YUV422P10(LE,BE) as supported for output Signed-off-by: Mans Rullgard --- libswscale/utils.c | 2 ++ tests/ref/lavfi/pixdesc | 2 ++ tests/ref/lavfi/pixfmts_copy | 2 ++ tests/ref/lavfi/pixfmts_null | 2 ++ tests/ref/lavfi/pixfmts_scale | 2 ++ tests/ref/lavfi/pixfmts_vflip | 2 ++ 6 files changed, 12 insertions(+) diff --git a/libswscale/utils.c b/libswscale/utils.c index 0bde82026d..c6abb6b446 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -176,10 +176,12 @@ int sws_isSupportedInput(enum PixelFormat pix_fmt) || (x)==PIX_FMT_YUV420P9LE \ || (x)==PIX_FMT_YUV420P10LE \ || (x)==PIX_FMT_YUV420P16LE \ + || (x)==PIX_FMT_YUV422P10LE \ || (x)==PIX_FMT_YUV422P16LE \ || (x)==PIX_FMT_YUV444P16LE \ || (x)==PIX_FMT_YUV420P9BE \ || (x)==PIX_FMT_YUV420P10BE \ + || (x)==PIX_FMT_YUV422P10BE \ || (x)==PIX_FMT_YUV420P16BE \ || (x)==PIX_FMT_YUV422P16BE \ || (x)==PIX_FMT_YUV444P16BE \ diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc index a82f8ed9b6..3730988777 100644 --- a/tests/ref/lavfi/pixdesc +++ b/tests/ref/lavfi/pixdesc @@ -38,6 +38,8 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a +yuv422p10be 107c6e31a3d4d598bca1d8426aaa54f5 +yuv422p10le 3f478be644add24b6cc77e718a6e2afa yuv422p16be dc9886f2fccf87cc54b27e071a2c251e yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index a82f8ed9b6..3730988777 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -38,6 +38,8 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a +yuv422p10be 107c6e31a3d4d598bca1d8426aaa54f5 +yuv422p10le 3f478be644add24b6cc77e718a6e2afa yuv422p16be dc9886f2fccf87cc54b27e071a2c251e yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index a82f8ed9b6..3730988777 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -38,6 +38,8 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a +yuv422p10be 107c6e31a3d4d598bca1d8426aaa54f5 +yuv422p10le 3f478be644add24b6cc77e718a6e2afa yuv422p16be dc9886f2fccf87cc54b27e071a2c251e yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index 094e52462f..392b9ce601 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -38,6 +38,8 @@ yuv420p16le cba8b390ad5e7b8678e419b8ce79c008 yuv420p9be a073b2d93b2a7dce2069ba252bc43175 yuv420p9le b67233c3c7d93763d07d88f697c145e1 yuv422p 918e37701ee7377d16a8a6c119c56a40 +yuv422p10be 533fd21e7943c20a1026b19069b3b867 +yuv422p10le 59b20a4a8609f5da2dc54c78aea11e6c yuv422p16be 2cf502d7d386db1f1b3b946679d897b1 yuv422p16le 3002a4e47520731dcee5929aff49eb74 yuv440p 461503fdb9b90451020aa3b25ddf041c diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index 8702eca796..2b62518a28 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -38,6 +38,8 @@ yuv420p16le 0f609e588e5a258644ef85170d70e030 yuv420p9be be40ec975fb2873891643cbbbddbc3b0 yuv420p9le 7e606310d3f5ff12badf911e8f333471 yuv422p d7f5cb44d9b0210d66d6a8762640ab34 +yuv422p10be a28b051168af49435c04af5f58dce47b +yuv422p10le 35936ffff30df2697f47b9b8d2cb7dea yuv422p16be 51d9aa4e78d121c226d919ce97976fe4 yuv422p16le 12965c54bda8932ca72da194419a9908 yuv440p 876385e96165acf51271b20e5d85a416 From 1073823984cf2938896fa30f9cc3d25640bbc19a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 20 Jul 2011 18:38:37 +0100 Subject: [PATCH 619/780] dnxhdenc: whitespace cosmetics Signed-off-by: Mans Rullgard --- libavcodec/dnxhdenc.c | 62 ++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 85832a1dc3..58698a48ab 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -52,10 +52,10 @@ static av_always_inline void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const pixels += line_size; block += 8; } - memcpy(block , block- 8, sizeof(*block)*8); - memcpy(block+ 8, block-16, sizeof(*block)*8); - memcpy(block+16, block-24, sizeof(*block)*8); - memcpy(block+24, block-32, sizeof(*block)*8); + memcpy(block, block - 8, sizeof(*block) * 8); + memcpy(block + 8, block - 16, sizeof(*block) * 8); + memcpy(block + 16, block - 24, sizeof(*block) * 8); + memcpy(block + 24, block - 32, sizeof(*block) * 8); } static int dnxhd_init_vlc(DNXHDEncContext *ctx) @@ -64,9 +64,9 @@ static int dnxhd_init_vlc(DNXHDEncContext *ctx) int max_level = 1<<(ctx->cid_table->bit_depth+2); FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_codes, max_level*4*sizeof(*ctx->vlc_codes), fail); - FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_bits , max_level*4*sizeof(*ctx->vlc_bits ), fail); - FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_codes, 63*2 , fail); - FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_bits , 63 , fail); + FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_bits, max_level*4*sizeof(*ctx->vlc_bits) , fail); + FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_codes, 63*2, fail); + FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_bits, 63, fail); ctx->vlc_codes += max_level*2; ctx->vlc_bits += max_level*2; @@ -119,8 +119,8 @@ static int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias) uint16_t weight_matrix[64] = {1,}; // convert_matrix needs uint16_t* int qscale, i; - FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l, (ctx->m.avctx->qmax+1) * 64 * sizeof(int) , fail); - FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c, (ctx->m.avctx->qmax+1) * 64 * sizeof(int) , fail); + FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l, (ctx->m.avctx->qmax+1) * 64 * sizeof(int), fail); + FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c, (ctx->m.avctx->qmax+1) * 64 * sizeof(int), fail); FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t), fail); FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t), fail); @@ -218,7 +218,7 @@ static int dnxhd_encode_init(AVCodecContext *avctx) FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->slice_size, ctx->m.mb_height*sizeof(uint32_t), fail); FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->slice_offs, ctx->m.mb_height*sizeof(uint32_t), fail); FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_bits, ctx->m.mb_num *sizeof(uint16_t), fail); - FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale, ctx->m.mb_num *sizeof(uint8_t) , fail); + FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale, ctx->m.mb_num *sizeof(uint8_t), fail); ctx->frame.key_frame = 1; ctx->frame.pict_type = AV_PICTURE_TYPE_I; @@ -341,7 +341,7 @@ static av_always_inline int dnxhd_ssd_block(DCTELEM *qblock, DCTELEM *block) int score = 0; int i; for (i = 0; i < 64; i++) - score += (block[i]-qblock[i])*(block[i]-qblock[i]); + score += (block[i] - qblock[i]) * (block[i] - qblock[i]); return score; } @@ -369,26 +369,28 @@ static av_always_inline void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, in const uint8_t *ptr_v = ctx->thread[0]->src[2] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << 3); DSPContext *dsp = &ctx->m.dsp; - dsp->get_pixels(ctx->blocks[0], ptr_y , ctx->m.linesize); + dsp->get_pixels(ctx->blocks[0], ptr_y, ctx->m.linesize); dsp->get_pixels(ctx->blocks[1], ptr_y + 8, ctx->m.linesize); - dsp->get_pixels(ctx->blocks[2], ptr_u , ctx->m.uvlinesize); - dsp->get_pixels(ctx->blocks[3], ptr_v , ctx->m.uvlinesize); + dsp->get_pixels(ctx->blocks[2], ptr_u, ctx->m.uvlinesize); + dsp->get_pixels(ctx->blocks[3], ptr_v, ctx->m.uvlinesize); if (mb_y+1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) { if (ctx->interlaced) { - ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + ctx->dct_y_offset , ctx->m.linesize); + ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + ctx->dct_y_offset, ctx->m.linesize); ctx->get_pixels_8x4_sym(ctx->blocks[5], ptr_y + ctx->dct_y_offset + 8, ctx->m.linesize); - ctx->get_pixels_8x4_sym(ctx->blocks[6], ptr_u + ctx->dct_uv_offset , ctx->m.uvlinesize); - ctx->get_pixels_8x4_sym(ctx->blocks[7], ptr_v + ctx->dct_uv_offset , ctx->m.uvlinesize); + ctx->get_pixels_8x4_sym(ctx->blocks[6], ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize); + ctx->get_pixels_8x4_sym(ctx->blocks[7], ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize); } else { - dsp->clear_block(ctx->blocks[4]); dsp->clear_block(ctx->blocks[5]); - dsp->clear_block(ctx->blocks[6]); dsp->clear_block(ctx->blocks[7]); + dsp->clear_block(ctx->blocks[4]); + dsp->clear_block(ctx->blocks[5]); + dsp->clear_block(ctx->blocks[6]); + dsp->clear_block(ctx->blocks[7]); } } else { - dsp->get_pixels(ctx->blocks[4], ptr_y + ctx->dct_y_offset , ctx->m.linesize); + dsp->get_pixels(ctx->blocks[4], ptr_y + ctx->dct_y_offset, ctx->m.linesize); dsp->get_pixels(ctx->blocks[5], ptr_y + ctx->dct_y_offset + 8, ctx->m.linesize); - dsp->get_pixels(ctx->blocks[6], ptr_u + ctx->dct_uv_offset , ctx->m.uvlinesize); - dsp->get_pixels(ctx->blocks[7], ptr_v + ctx->dct_uv_offset , ctx->m.uvlinesize); + dsp->get_pixels(ctx->blocks[6], ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize); + dsp->get_pixels(ctx->blocks[7], ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize); } } @@ -496,14 +498,14 @@ static void dnxhd_setup_threads_slices(DNXHDEncContext *ctx) for (mb_y = 0; mb_y < ctx->m.mb_height; mb_y++) { int thread_size; ctx->slice_offs[mb_y] = offset; - ctx->slice_size[mb_y] = 0; - for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) { - unsigned mb = mb_y * ctx->m.mb_width + mb_x; - ctx->slice_size[mb_y] += ctx->mb_bits[mb]; - } - ctx->slice_size[mb_y] = (ctx->slice_size[mb_y]+31)&~31; - ctx->slice_size[mb_y] >>= 3; - thread_size = ctx->slice_size[mb_y]; + ctx->slice_size[mb_y] = 0; + for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) { + unsigned mb = mb_y * ctx->m.mb_width + mb_x; + ctx->slice_size[mb_y] += ctx->mb_bits[mb]; + } + ctx->slice_size[mb_y] = (ctx->slice_size[mb_y]+31)&~31; + ctx->slice_size[mb_y] >>= 3; + thread_size = ctx->slice_size[mb_y]; offset += thread_size; } } From b04997839786c56e5000569d0192fa629e2d3a76 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 20 Jul 2011 18:41:37 +0100 Subject: [PATCH 620/780] dnxhdenc: remove inline from function only called through pointer Signed-off-by: Mans Rullgard --- libavcodec/dnxhdenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 58698a48ab..b65d0bf669 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -41,7 +41,7 @@ static const AVClass class = { "dnxhd", av_default_item_name, options, LIBAVUTIL #define LAMBDA_FRAC_BITS 10 -static av_always_inline void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, int line_size) +static void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, int line_size) { int i; for (i = 0; i < 4; i++) { From 42c27f2ecae38abd7d6b75070998fb2f98089389 Mon Sep 17 00:00:00 2001 From: Joseph Artsimovich Date: Mon, 18 Jul 2011 11:21:33 +0100 Subject: [PATCH 621/780] dnxhd: rename some data tables Signed-off-by: Mans Rullgard --- libavcodec/dnxhddata.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c index 642b22fb5d..677fb8f5be 100644 --- a/libavcodec/dnxhddata.c +++ b/libavcodec/dnxhddata.c @@ -448,7 +448,7 @@ static const uint8_t dnxhd_1238_ac_index_flag[257] = { 1, }; -static const uint16_t dnxhd_1238_run_codes[62] = { +static const uint16_t dnxhd_1235_1238_1241_run_codes[62] = { 0, 4, 10, 11, 24, 25, 26, 27, 56, 57, 58, 59, 120, 242, 486, 487, 488, 489, 980, 981, 982, 983, 984, 985, @@ -459,7 +459,7 @@ static const uint16_t dnxhd_1238_run_codes[62] = { 1018, 1019, 1020, 1021, 1022, 1023, }; -static const uint8_t dnxhd_1238_run_bits[62] = { +static const uint8_t dnxhd_1235_1238_1241_run_bits[62] = { 1, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, @@ -473,15 +473,15 @@ static const uint8_t dnxhd_1238_run[62] = { 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, }; -static const uint8_t dnxhd_1241_dc_codes[14] = { +static const uint8_t dnxhd_1235_1241_dc_codes[14] = { 10, 62, 11, 12, 13, 0, 1, 2, 3, 4, 14, 30, 126, 127, }; -static const uint8_t dnxhd_1241_dc_bits[14] = { +static const uint8_t dnxhd_1235_1241_dc_bits[14] = { 4, 6, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 7, 7, }; -static const uint16_t dnxhd_1241_ac_codes[257] = { +static const uint16_t dnxhd_1235_1241_ac_codes[257] = { 0, 1, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 116, 117, 118, 119, 240, 241, 242, 243, 244, 245, 492, 493, @@ -517,7 +517,7 @@ static const uint16_t dnxhd_1241_ac_codes[257] = { 65535, }; -static const uint8_t dnxhd_1241_ac_bits[257] = { +static const uint8_t dnxhd_1235_1241_ac_bits[257] = { 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, @@ -537,7 +537,7 @@ static const uint8_t dnxhd_1241_ac_bits[257] = { 16, }; -static const uint8_t dnxhd_1241_ac_level[257] = { +static const uint8_t dnxhd_1235_1241_ac_level[257] = { 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 6, 7, 22, 23, 24, 25, 26, 27, 28, 29, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 38, @@ -557,7 +557,7 @@ static const uint8_t dnxhd_1241_ac_level[257] = { 64, }; -static const uint8_t dnxhd_1241_ac_run_flag[257] = { +static const uint8_t dnxhd_1235_1241_ac_run_flag[257] = { 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -577,7 +577,7 @@ static const uint8_t dnxhd_1241_ac_run_flag[257] = { 1, }; -static const uint8_t dnxhd_1241_ac_index_flag[257] = { +static const uint8_t dnxhd_1235_1241_ac_index_flag[257] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -597,7 +597,7 @@ static const uint8_t dnxhd_1241_ac_index_flag[257] = { 1, }; -static const uint8_t dnxhd_1241_run[62] = { +static const uint8_t dnxhd_1235_1241_run[62] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 17, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, @@ -890,14 +890,14 @@ const CIDEntry ff_dnxhd_cid_table[] = { dnxhd_1238_dc_codes, dnxhd_1238_dc_bits, dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level, dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag, - dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1238_run, + dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1238_run, { 175, 185, 220, 365, 440 } }, { 1241, 1920, 1080, 1, 917504, 458752, 6, 10, dnxhd_1241_luma_weight, dnxhd_1241_chroma_weight, - dnxhd_1241_dc_codes, dnxhd_1241_dc_bits, - dnxhd_1241_ac_codes, dnxhd_1241_ac_bits, dnxhd_1241_ac_level, - dnxhd_1241_ac_run_flag, dnxhd_1241_ac_index_flag, - dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1241_run, + dnxhd_1235_1241_dc_codes, dnxhd_1235_1241_dc_bits, + dnxhd_1235_1241_ac_codes, dnxhd_1235_1241_ac_bits, dnxhd_1235_1241_ac_level, + dnxhd_1235_1241_ac_run_flag, dnxhd_1235_1241_ac_index_flag, + dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1235_1241_run, { 185, 220 } }, { 1242, 1920, 1080, 1, 606208, 303104, 4, 8, dnxhd_1242_luma_weight, dnxhd_1242_chroma_weight, @@ -911,7 +911,7 @@ const CIDEntry ff_dnxhd_cid_table[] = { dnxhd_1238_dc_codes, dnxhd_1238_dc_bits, dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level, dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag, - dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1238_run, + dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1238_run, { 185, 220 } }, { 1251, 1280, 720, 0, 458752, 458752, 4, 8, dnxhd_1251_luma_weight, dnxhd_1251_chroma_weight, From a82beafd64529cba8c20bd24f63d6af7dccffb7d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 21 Jul 2011 02:21:14 +0100 Subject: [PATCH 622/780] dsputil: allow 9/10-bit functions for non-h264 codecs Signed-off-by: Mans Rullgard --- libavcodec/dsputil.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index fa9b591fad..4008389a9d 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -3192,21 +3192,18 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) dspfunc2(avg_h264_qpel, 1, 8, depth);\ dspfunc2(avg_h264_qpel, 2, 4, depth); - if (avctx->codec_id != CODEC_ID_H264 || avctx->bits_per_raw_sample == 8) { - BIT_DEPTH_FUNCS(8) - } else { - switch (avctx->bits_per_raw_sample) { - case 9: - BIT_DEPTH_FUNCS(9) - break; - case 10: - BIT_DEPTH_FUNCS(10) - break; - default: - av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", avctx->bits_per_raw_sample); - BIT_DEPTH_FUNCS(8) - break; - } + switch (avctx->bits_per_raw_sample) { + case 9: + BIT_DEPTH_FUNCS(9); + break; + case 10: + BIT_DEPTH_FUNCS(10); + break; + default: + av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", avctx->bits_per_raw_sample); + case 8: + BIT_DEPTH_FUNCS(8); + break; } From e7bcc5baf721d6a80fcb79674aad4171e5ca94e7 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 21 Jul 2011 03:56:44 +0100 Subject: [PATCH 623/780] simple_idct: change 10-bit add/put stride from pixels to bytes This matches other dsputil functions and simplifies calls. Signed-off-by: Mans Rullgard --- libavcodec/simple_idct_template.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/simple_idct_template.c b/libavcodec/simple_idct_template.c index be49cb9570..1b6115d41f 100644 --- a/libavcodec/simple_idct_template.c +++ b/libavcodec/simple_idct_template.c @@ -372,6 +372,9 @@ void FUNC(ff_simple_idct_put)(uint8_t *dest_, int line_size, DCTELEM *block) { pixel *dest = (pixel *)dest_; int i; + + line_size /= sizeof(pixel); + for(i=0; i<8; i++) FUNC(idctRowCondDC)(block + i*8); @@ -383,6 +386,9 @@ void FUNC(ff_simple_idct_add)(uint8_t *dest_, int line_size, DCTELEM *block) { pixel *dest = (pixel *)dest_; int i; + + line_size /= sizeof(pixel); + for(i=0; i<8; i++) FUNC(idctRowCondDC)(block + i*8); From 633aa01f728b3f67b420e9e34ef21a995578d613 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 21 Jul 2011 11:00:47 +0200 Subject: [PATCH 624/780] libavfilter: fix --enable-small Signed-off-by: Michael Niedermayer --- libavfilter/vf_lut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index a1f93ffc91..bc74a9d489 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -341,8 +341,8 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) #define DEFINE_LUT_FILTER(name_, description_, init_) \ AVFilter avfilter_vf_##name_ = { \ - .name = NULL_IF_CONFIG_SMALL(#name_), \ - .description = description_, \ + .name = #name_, \ + .description = NULL_IF_CONFIG_SMALL(description_), \ .priv_size = sizeof(LutContext), \ \ .init = init_, \ From 7df701a1925cc46cea5a01988cbabc1e6b3a49b1 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 21 Jul 2011 10:58:56 +0100 Subject: [PATCH 625/780] dsputil: remove huge #if 0 block Signed-off-by: Mans Rullgard --- libavcodec/dsputil_template.c | 145 ---------------------------------- 1 file changed, 145 deletions(-) diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index 645a881a19..9f8cf557c8 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -230,150 +230,6 @@ static void FUNCC(add_pixels4)(uint8_t *restrict _pixels, DCTELEM *_block, int l } } -#if 0 - -#define PIXOP2(OPNAME, OP) \ -static void OPNAME ## _pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ -{\ - int i;\ - for(i=0; i>1));\ - pixels+=line_size;\ - block +=line_size;\ - }\ -}\ -\ -static void OPNAME ## _pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ -{\ - int i;\ - for(i=0; i>1));\ - pixels+=line_size;\ - block +=line_size;\ - }\ -}\ -\ -static void OPNAME ## _no_rnd_pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ -{\ - int i;\ - for(i=0; i>1));\ - pixels+=line_size;\ - block +=line_size;\ - }\ -}\ -\ -static void OPNAME ## _pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ -{\ - int i;\ - for(i=0; i>1));\ - pixels+=line_size;\ - block +=line_size;\ - }\ -}\ -\ -static void OPNAME ## _pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ -{\ - int i;\ - const uint64_t a= AV_RN64(pixels );\ - const uint64_t b= AV_RN64(pixels+1);\ - uint64_t l0= (a&0x0303030303030303ULL)\ - + (b&0x0303030303030303ULL)\ - + 0x0202020202020202ULL;\ - uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ - + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ - uint64_t l1,h1;\ -\ - pixels+=line_size;\ - for(i=0; i>2)\ - + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ - OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ - pixels+=line_size;\ - block +=line_size;\ - a= AV_RN64(pixels );\ - b= AV_RN64(pixels+1);\ - l0= (a&0x0303030303030303ULL)\ - + (b&0x0303030303030303ULL)\ - + 0x0202020202020202ULL;\ - h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ - + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ - OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ - pixels+=line_size;\ - block +=line_size;\ - }\ -}\ -\ -static void OPNAME ## _no_rnd_pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ -{\ - int i;\ - const uint64_t a= AV_RN64(pixels );\ - const uint64_t b= AV_RN64(pixels+1);\ - uint64_t l0= (a&0x0303030303030303ULL)\ - + (b&0x0303030303030303ULL)\ - + 0x0101010101010101ULL;\ - uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ - + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ - uint64_t l1,h1;\ -\ - pixels+=line_size;\ - for(i=0; i>2)\ - + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ - OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ - pixels+=line_size;\ - block +=line_size;\ - a= AV_RN64(pixels );\ - b= AV_RN64(pixels+1);\ - l0= (a&0x0303030303030303ULL)\ - + (b&0x0303030303030303ULL)\ - + 0x0101010101010101ULL;\ - h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ - + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ - OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ - pixels+=line_size;\ - block +=line_size;\ - }\ -}\ -\ -CALL_2X_PIXELS(OPNAME ## _pixels16_c , OPNAME ## _pixels_c , 8*sizeof(pixel))\ -CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels_x2_c , 8*sizeof(pixel))\ -CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels_y2_c , 8*sizeof(pixel))\ -CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels_xy2_c, 8*sizeof(pixel))\ -CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels_x2_c , 8*sizeof(pixel))\ -CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels_y2_c , 8*sizeof(pixel))\ -CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels_xy2_c, 8*sizeof(pixel)) - -#define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEFEFEFEFEULL)>>1) ) -#else // 64 bit variant - #define PIXOP2(OPNAME, OP) \ static void FUNCC(OPNAME ## _pixels2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ int i;\ @@ -749,7 +605,6 @@ CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_y2) , FUNCC(OPNAME ## _no_rnd_pi CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_xy2), FUNCC(OPNAME ## _no_rnd_pixels8_xy2), 8*sizeof(pixel))\ #define op_avg(a, b) a = rnd_avg_pixel4(a, b) -#endif #define op_put(a, b) a = b PIXOP2(avg, op_avg) From daa62372293a265d8885be94ffd3f243ed1adb91 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 18 Jul 2011 14:02:07 +0200 Subject: [PATCH 626/780] au: reuse the result of the previous call to av_get_bits_per_sample() Avoid an unnecessary call to the function, slighlty more robust/readable. --- libavformat/au.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/au.c b/libavformat/au.c index 593442807c..870f46f65d 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -120,7 +120,7 @@ static int au_probe(AVProbeData *p) static int au_read_header(AVFormatContext *s, AVFormatParameters *ap) { - int size, data_size = 0; + int size, bps, data_size = 0; unsigned int tag; AVIOContext *pb = s->pb; unsigned int id, channels, rate; @@ -145,7 +145,7 @@ static int au_read_header(AVFormatContext *s, codec = ff_codec_get_id(codec_au_tags, id); - if (!av_get_bits_per_sample(codec)) { + if (!(bps = av_get_bits_per_sample(codec))) { av_log_ask_for_sample(s, "could not determine bits per sample\n"); return AVERROR_INVALIDDATA; } @@ -164,7 +164,7 @@ static int au_read_header(AVFormatContext *s, st->codec->codec_id = codec; st->codec->channels = channels; st->codec->sample_rate = rate; - st->duration = (((int64_t)data_size)<<3) / (st->codec->channels * av_get_bits_per_sample(codec)); + st->duration = (((int64_t)data_size)<<3) / (st->codec->channels * bps); av_set_pts_info(st, 64, 1, rate); return 0; } From c76974524a622745f3e8e105eb84793ccdb87d0b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 17 Jul 2011 17:05:14 +0200 Subject: [PATCH 627/780] vf_blackframe: port missing features from libmpcodecs blackframe Use and show picref->video->pict_type and key_frame information. The pict_type and key_frame information was not available at the time of the port. --- libavfilter/avfilter.h | 2 +- libavfilter/vf_blackframe.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index d89ac26e9f..05cac39449 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 27 -#define LIBAVFILTER_VERSION_MICRO 0 +#define LIBAVFILTER_VERSION_MICRO 1 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c index 41b4a92ce5..843e8273f4 100644 --- a/libavfilter/vf_blackframe.c +++ b/libavfilter/vf_blackframe.c @@ -34,6 +34,7 @@ typedef struct { unsigned int bthresh; ///< black threshold unsigned int frame; ///< frame number unsigned int nblack; ///< number of black pixels counted so far + unsigned int last_keyframe; ///< frame number of the last received key-frame } BlackFrameContext; static int query_formats(AVFilterContext *ctx) @@ -56,6 +57,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) blackframe->bthresh = 32; blackframe->nblack = 0; blackframe->frame = 0; + blackframe->last_keyframe = 0; if (args) sscanf(args, "%u:%u", &blackframe->bamount, &blackframe->bthresh); @@ -95,11 +97,16 @@ static void end_frame(AVFilterLink *inlink) AVFilterBufferRef *picref = inlink->cur_buf; int pblack = 0; + if (picref->video->key_frame) + blackframe->last_keyframe = blackframe->frame; + pblack = blackframe->nblack * 100 / (inlink->w * inlink->h); if (pblack >= blackframe->bamount) - av_log(ctx, AV_LOG_INFO, "frame:%u pblack:%u pos:%"PRId64" pts:%"PRId64" t:%f\n", + av_log(ctx, AV_LOG_INFO, "frame:%u pblack:%u pos:%"PRId64" pts:%"PRId64" t:%f " + "type:%c last_keyframe:%d\n", blackframe->frame, pblack, picref->pos, picref->pts, - picref->pts == AV_NOPTS_VALUE ? -1 : picref->pts * av_q2d(inlink->time_base)); + picref->pts == AV_NOPTS_VALUE ? -1 : picref->pts * av_q2d(inlink->time_base), + av_get_picture_type_char(picref->video->pict_type), blackframe->last_keyframe); blackframe->frame++; blackframe->nblack = 0; From 8c2863b87f651bfce061d5b0e03cd756b049a553 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 17 Jul 2011 17:39:05 +0200 Subject: [PATCH 628/780] vf_mp: remove cropdetect wrapper The cropdetect filter is natively integrated into libavfilter. --- doc/filters.texi | 1 - libavfilter/Makefile | 1 - libavfilter/avfilter.h | 2 +- libavfilter/libmpcodecs/vf_cropdetect.c | 201 ------------------------ libavfilter/vf_mp.c | 2 - 5 files changed, 1 insertion(+), 206 deletions(-) delete mode 100644 libavfilter/libmpcodecs/vf_cropdetect.c diff --git a/doc/filters.texi b/doc/filters.texi index 0ffc72771c..5c1a2808d0 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -896,7 +896,6 @@ The list of the currently supported filters follows: @table @var @item 2xsai @item blackframe -@item cropdetect @item decimate @item delogo @item denoise3d diff --git a/libavfilter/Makefile b/libavfilter/Makefile index d309534da7..4e903291cf 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -80,7 +80,6 @@ OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/mp_image.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/img_format.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_2xsai.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_blackframe.o -OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_cropdetect.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_decimate.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_delogo.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_denoise3d.o diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 05cac39449..2fe1f14ec7 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 27 -#define LIBAVFILTER_VERSION_MICRO 1 +#define LIBAVFILTER_VERSION_MICRO 2 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/libmpcodecs/vf_cropdetect.c b/libavfilter/libmpcodecs/vf_cropdetect.c deleted file mode 100644 index c3de24793b..0000000000 --- a/libavfilter/libmpcodecs/vf_cropdetect.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include - -#include "config.h" -#include "mp_msg.h" -#include "help_mp.h" - -#include "img_format.h" -#include "mp_image.h" -#include "vf.h" - -struct vf_priv_s { - int x1,y1,x2,y2; - int limit; - int round; - int reset_count; - int fno; -}; - -static int checkline(unsigned char* src,int stride,int len,int bpp){ - int total=0; - int div=len; - switch(bpp){ - case 1: - while(--len>=0){ - total+=src[0]; src+=stride; - } - break; - case 3: - case 4: - while(--len>=0){ - total+=src[0]+src[1]+src[2]; src+=stride; - } - div*=3; - break; - } - total/=div; -// printf("total=%d\n",total); - return total; -} - -//===========================================================================// - -static int config(struct vf_instance *vf, - int width, int height, int d_width, int d_height, - unsigned int flags, unsigned int outfmt){ - vf->priv->x1=width - 1; - vf->priv->y1=height - 1; - vf->priv->x2=0; - vf->priv->y2=0; - vf->priv->fno=-2; - return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); -} - -static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ - mp_image_t *dmpi; - int bpp=mpi->bpp/8; - int w,h,x,y,shrink_by; - - // hope we'll get DR buffer: - dmpi=vf_get_image(vf->next,mpi->imgfmt, - MP_IMGTYPE_EXPORT, 0, - mpi->w, mpi->h); - - dmpi->planes[0]=mpi->planes[0]; - dmpi->planes[1]=mpi->planes[1]; - dmpi->planes[2]=mpi->planes[2]; - dmpi->stride[0]=mpi->stride[0]; - dmpi->stride[1]=mpi->stride[1]; - dmpi->stride[2]=mpi->stride[2]; - dmpi->width=mpi->width; - dmpi->height=mpi->height; - -if(++vf->priv->fno>0){ // ignore first 2 frames - they may be empty - - // Reset the crop area every reset_count frames, if reset_count is > 0 - if(vf->priv->reset_count > 0 && vf->priv->fno > vf->priv->reset_count){ - vf->priv->x1=mpi->w-1; - vf->priv->y1=mpi->h-1; - vf->priv->x2=0; - vf->priv->y2=0; - vf->priv->fno=1; - } - - for(y=0;ypriv->y1;y++){ - if(checkline(mpi->planes[0]+mpi->stride[0]*y,bpp,mpi->w,bpp)>vf->priv->limit){ - vf->priv->y1=y; - break; - } - } - - for(y=mpi->h-1;y>vf->priv->y2;y--){ - if(checkline(mpi->planes[0]+mpi->stride[0]*y,bpp,mpi->w,bpp)>vf->priv->limit){ - vf->priv->y2=y; - break; - } - } - - for(y=0;ypriv->x1;y++){ - if(checkline(mpi->planes[0]+bpp*y,mpi->stride[0],mpi->h,bpp)>vf->priv->limit){ - vf->priv->x1=y; - break; - } - } - - for(y=mpi->w-1;y>vf->priv->x2;y--){ - if(checkline(mpi->planes[0]+bpp*y,mpi->stride[0],mpi->h,bpp)>vf->priv->limit){ - vf->priv->x2=y; - break; - } - } - - // round x and y (up), important for yuv colorspaces - // make sure they stay rounded! - x=(vf->priv->x1+1)&(~1); - y=(vf->priv->y1+1)&(~1); - - w = vf->priv->x2 - x + 1; - h = vf->priv->y2 - y + 1; - - // w and h must be divisible by 2 as well because of yuv - // colorspace problems. - if (vf->priv->round <= 1) - vf->priv->round = 16; - if (vf->priv->round % 2) - vf->priv->round *= 2; - - shrink_by = w % vf->priv->round; - w -= shrink_by; - x += (shrink_by / 2 + 1) & ~1; - - shrink_by = h % vf->priv->round; - h -= shrink_by; - y += (shrink_by / 2 + 1) & ~1; - - mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_CropArea, - vf->priv->x1,vf->priv->x2, - vf->priv->y1,vf->priv->y2, - w,h,x,y); - - -} - - return vf_next_put_image(vf,dmpi, pts); -} - -static int query_format(struct vf_instance *vf, unsigned int fmt) { - switch(fmt) { - // the default limit value works only right with YV12 right now. - case IMGFMT_YV12: - return vf_next_query_format(vf, fmt); - } - return 0; -} -//===========================================================================// - -static int vf_open(vf_instance_t *vf, char *args){ - vf->config=config; - vf->put_image=put_image; - vf->query_format=query_format; - vf->priv=malloc(sizeof(struct vf_priv_s)); - vf->priv->limit=24; // should be option - vf->priv->round = 0; - vf->priv->reset_count = 0; - if(args) sscanf(args, "%d:%d:%d", - &vf->priv->limit, - &vf->priv->round, - &vf->priv->reset_count); - return 1; -} - -const vf_info_t vf_info_cropdetect = { - "autodetect crop size", - "cropdetect", - "A'rpi", - "", - vf_open, - NULL -}; - -//===========================================================================// diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c index afb181ec32..752d6cb127 100644 --- a/libavfilter/vf_mp.c +++ b/libavfilter/vf_mp.c @@ -136,7 +136,6 @@ extern const vf_info_t vf_info_palette; extern const vf_info_t vf_info_lavc; extern const vf_info_t vf_info_zrmjpeg; extern const vf_info_t vf_info_dvbscale; -extern const vf_info_t vf_info_cropdetect; extern const vf_info_t vf_info_test; extern const vf_info_t vf_info_noise; extern const vf_info_t vf_info_yvu9; @@ -200,7 +199,6 @@ extern const vf_info_t vf_info_stereo3d; static const vf_info_t* const filters[]={ &vf_info_2xsai, &vf_info_blackframe, - &vf_info_cropdetect, &vf_info_decimate, &vf_info_delogo, &vf_info_denoise3d, From a402f109599c589ba75f6d95cf071a205406d9d7 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 21 Jul 2011 09:48:29 +0100 Subject: [PATCH 629/780] simple_idct: make repeated code a macro Signed-off-by: Mans Rullgard --- libavcodec/simple_idct_template.c | 197 ++++++++---------------------- 1 file changed, 53 insertions(+), 144 deletions(-) diff --git a/libavcodec/simple_idct_template.c b/libavcodec/simple_idct_template.c index 1b6115d41f..81845c962d 100644 --- a/libavcodec/simple_idct_template.c +++ b/libavcodec/simple_idct_template.c @@ -161,60 +161,63 @@ static inline void FUNC(idctRowCondDC)(DCTELEM *row) row[4] = (a3 - b3) >> ROW_SHIFT; } +#define IDCT_COLS do { \ + a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); \ + a1 = a0; \ + a2 = a0; \ + a3 = a0; \ + \ + a0 += W2*col[8*2]; \ + a1 += W6*col[8*2]; \ + a2 += -W6*col[8*2]; \ + a3 += -W2*col[8*2]; \ + \ + b0 = MUL(W1, col[8*1]); \ + b1 = MUL(W3, col[8*1]); \ + b2 = MUL(W5, col[8*1]); \ + b3 = MUL(W7, col[8*1]); \ + \ + MAC(b0, W3, col[8*3]); \ + MAC(b1, -W7, col[8*3]); \ + MAC(b2, -W1, col[8*3]); \ + MAC(b3, -W5, col[8*3]); \ + \ + if (col[8*4]) { \ + a0 += W4*col[8*4]; \ + a1 += -W4*col[8*4]; \ + a2 += -W4*col[8*4]; \ + a3 += W4*col[8*4]; \ + } \ + \ + if (col[8*5]) { \ + MAC(b0, W5, col[8*5]); \ + MAC(b1, -W1, col[8*5]); \ + MAC(b2, W7, col[8*5]); \ + MAC(b3, W3, col[8*5]); \ + } \ + \ + if (col[8*6]) { \ + a0 += W6*col[8*6]; \ + a1 += -W2*col[8*6]; \ + a2 += W2*col[8*6]; \ + a3 += -W6*col[8*6]; \ + } \ + \ + if (col[8*7]) { \ + MAC(b0, W7, col[8*7]); \ + MAC(b1, -W5, col[8*7]); \ + MAC(b2, W3, col[8*7]); \ + MAC(b3, -W1, col[8*7]); \ + } \ + } while (0) + static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size, DCTELEM *col) { int a0, a1, a2, a3, b0, b1, b2, b3; INIT_CLIP; - /* XXX: I did that only to give same values as previous code */ - a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); - a1 = a0; - a2 = a0; - a3 = a0; - - a0 += + W2*col[8*2]; - a1 += + W6*col[8*2]; - a2 += - W6*col[8*2]; - a3 += - W2*col[8*2]; - - b0 = MUL(W1, col[8*1]); - b1 = MUL(W3, col[8*1]); - b2 = MUL(W5, col[8*1]); - b3 = MUL(W7, col[8*1]); - - MAC(b0, + W3, col[8*3]); - MAC(b1, - W7, col[8*3]); - MAC(b2, - W1, col[8*3]); - MAC(b3, - W5, col[8*3]); - - if(col[8*4]){ - a0 += + W4*col[8*4]; - a1 += - W4*col[8*4]; - a2 += - W4*col[8*4]; - a3 += + W4*col[8*4]; - } - - if (col[8*5]) { - MAC(b0, + W5, col[8*5]); - MAC(b1, - W1, col[8*5]); - MAC(b2, + W7, col[8*5]); - MAC(b3, + W3, col[8*5]); - } - - if(col[8*6]){ - a0 += + W6*col[8*6]; - a1 += - W2*col[8*6]; - a2 += + W2*col[8*6]; - a3 += - W6*col[8*6]; - } - - if (col[8*7]) { - MAC(b0, + W7, col[8*7]); - MAC(b1, - W5, col[8*7]); - MAC(b2, + W3, col[8*7]); - MAC(b3, - W1, col[8*7]); - } + IDCT_COLS; dest[0] = CLIP((a0 + b0) >> COL_SHIFT); dest += line_size; @@ -239,54 +242,7 @@ static inline void FUNC(idctSparseColAdd)(pixel *dest, int line_size, int a0, a1, a2, a3, b0, b1, b2, b3; INIT_CLIP; - /* XXX: I did that only to give same values as previous code */ - a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); - a1 = a0; - a2 = a0; - a3 = a0; - - a0 += + W2*col[8*2]; - a1 += + W6*col[8*2]; - a2 += - W6*col[8*2]; - a3 += - W2*col[8*2]; - - b0 = MUL(W1, col[8*1]); - b1 = MUL(W3, col[8*1]); - b2 = MUL(W5, col[8*1]); - b3 = MUL(W7, col[8*1]); - - MAC(b0, + W3, col[8*3]); - MAC(b1, - W7, col[8*3]); - MAC(b2, - W1, col[8*3]); - MAC(b3, - W5, col[8*3]); - - if(col[8*4]){ - a0 += + W4*col[8*4]; - a1 += - W4*col[8*4]; - a2 += - W4*col[8*4]; - a3 += + W4*col[8*4]; - } - - if (col[8*5]) { - MAC(b0, + W5, col[8*5]); - MAC(b1, - W1, col[8*5]); - MAC(b2, + W7, col[8*5]); - MAC(b3, + W3, col[8*5]); - } - - if(col[8*6]){ - a0 += + W6*col[8*6]; - a1 += - W2*col[8*6]; - a2 += + W2*col[8*6]; - a3 += - W6*col[8*6]; - } - - if (col[8*7]) { - MAC(b0, + W7, col[8*7]); - MAC(b1, - W5, col[8*7]); - MAC(b2, + W3, col[8*7]); - MAC(b3, - W1, col[8*7]); - } + IDCT_COLS; dest[0] = CLIP(dest[0] + ((a0 + b0) >> COL_SHIFT)); dest += line_size; @@ -309,54 +265,7 @@ static inline void FUNC(idctSparseCol)(DCTELEM *col) { int a0, a1, a2, a3, b0, b1, b2, b3; - /* XXX: I did that only to give same values as previous code */ - a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); - a1 = a0; - a2 = a0; - a3 = a0; - - a0 += + W2*col[8*2]; - a1 += + W6*col[8*2]; - a2 += - W6*col[8*2]; - a3 += - W2*col[8*2]; - - b0 = MUL(W1, col[8*1]); - b1 = MUL(W3, col[8*1]); - b2 = MUL(W5, col[8*1]); - b3 = MUL(W7, col[8*1]); - - MAC(b0, + W3, col[8*3]); - MAC(b1, - W7, col[8*3]); - MAC(b2, - W1, col[8*3]); - MAC(b3, - W5, col[8*3]); - - if(col[8*4]){ - a0 += + W4*col[8*4]; - a1 += - W4*col[8*4]; - a2 += - W4*col[8*4]; - a3 += + W4*col[8*4]; - } - - if (col[8*5]) { - MAC(b0, + W5, col[8*5]); - MAC(b1, - W1, col[8*5]); - MAC(b2, + W7, col[8*5]); - MAC(b3, + W3, col[8*5]); - } - - if(col[8*6]){ - a0 += + W6*col[8*6]; - a1 += - W2*col[8*6]; - a2 += + W2*col[8*6]; - a3 += - W6*col[8*6]; - } - - if (col[8*7]) { - MAC(b0, + W7, col[8*7]); - MAC(b1, - W5, col[8*7]); - MAC(b2, + W3, col[8*7]); - MAC(b3, - W1, col[8*7]); - } + IDCT_COLS; col[0 ] = ((a0 + b0) >> COL_SHIFT); col[8 ] = ((a1 + b1) >> COL_SHIFT); From 2cc4f3b21f33740db1728bae104f336e7008731c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 21 Jul 2011 09:49:17 +0100 Subject: [PATCH 630/780] simple_idct: whitespace cosmetics Signed-off-by: Mans Rullgard --- libavcodec/simple_idct_template.c | 220 +++++++++++++++--------------- 1 file changed, 110 insertions(+), 110 deletions(-) diff --git a/libavcodec/simple_idct_template.c b/libavcodec/simple_idct_template.c index 81845c962d..6d3f6f764d 100644 --- a/libavcodec/simple_idct_template.c +++ b/libavcodec/simple_idct_template.c @@ -87,78 +87,77 @@ static inline void FUNC(idctRowCondDC)(DCTELEM *row) { - int a0, a1, a2, a3, b0, b1, b2, b3; + int a0, a1, a2, a3, b0, b1, b2, b3; #if HAVE_FAST_64BIT #define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN) - if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) { - uint64_t temp = (row[0] << DC_SHIFT) & 0xffff; - temp += temp << 16; - temp += temp << 32; - ((uint64_t *)row)[0] = temp; - ((uint64_t *)row)[1] = temp; - return; - } + if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) { + uint64_t temp = (row[0] << DC_SHIFT) & 0xffff; + temp += temp << 16; + temp += temp << 32; + ((uint64_t *)row)[0] = temp; + ((uint64_t *)row)[1] = temp; + return; + } #else - if (!(((uint32_t*)row)[1] | - ((uint32_t*)row)[2] | - ((uint32_t*)row)[3] | - row[1])) { - uint32_t temp = (row[0] << DC_SHIFT) & 0xffff; - temp += temp << 16; - ((uint32_t*)row)[0]=((uint32_t*)row)[1] = - ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp; - return; - } + if (!(((uint32_t*)row)[1] | + ((uint32_t*)row)[2] | + ((uint32_t*)row)[3] | + row[1])) { + uint32_t temp = (row[0] << DC_SHIFT) & 0xffff; + temp += temp << 16; + ((uint32_t*)row)[0]=((uint32_t*)row)[1] = + ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp; + return; + } #endif - a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1)); - a1 = a0; - a2 = a0; - a3 = a0; + a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1)); + a1 = a0; + a2 = a0; + a3 = a0; - /* no need to optimize : gcc does it */ - a0 += W2 * row[2]; - a1 += W6 * row[2]; - a2 -= W6 * row[2]; - a3 -= W2 * row[2]; + a0 += W2 * row[2]; + a1 += W6 * row[2]; + a2 -= W6 * row[2]; + a3 -= W2 * row[2]; - b0 = MUL(W1, row[1]); - MAC(b0, W3, row[3]); - b1 = MUL(W3, row[1]); - MAC(b1, -W7, row[3]); - b2 = MUL(W5, row[1]); - MAC(b2, -W1, row[3]); - b3 = MUL(W7, row[1]); - MAC(b3, -W5, row[3]); + b0 = MUL(W1, row[1]); + MAC(b0, W3, row[3]); + b1 = MUL(W3, row[1]); + MAC(b1, -W7, row[3]); + b2 = MUL(W5, row[1]); + MAC(b2, -W1, row[3]); + b3 = MUL(W7, row[1]); + MAC(b3, -W5, row[3]); - if (AV_RN64A(row + 4)) { - a0 += W4*row[4] + W6*row[6]; - a1 += - W4*row[4] - W2*row[6]; - a2 += - W4*row[4] + W2*row[6]; - a3 += W4*row[4] - W6*row[6]; + if (AV_RN64A(row + 4)) { + a0 += W4*row[4] + W6*row[6]; + a1 += - W4*row[4] - W2*row[6]; + a2 += - W4*row[4] + W2*row[6]; + a3 += W4*row[4] - W6*row[6]; - MAC(b0, W5, row[5]); - MAC(b0, W7, row[7]); + MAC(b0, W5, row[5]); + MAC(b0, W7, row[7]); - MAC(b1, -W1, row[5]); - MAC(b1, -W5, row[7]); + MAC(b1, -W1, row[5]); + MAC(b1, -W5, row[7]); - MAC(b2, W7, row[5]); - MAC(b2, W3, row[7]); + MAC(b2, W7, row[5]); + MAC(b2, W3, row[7]); - MAC(b3, W3, row[5]); - MAC(b3, -W1, row[7]); - } + MAC(b3, W3, row[5]); + MAC(b3, -W1, row[7]); + } - row[0] = (a0 + b0) >> ROW_SHIFT; - row[7] = (a0 - b0) >> ROW_SHIFT; - row[1] = (a1 + b1) >> ROW_SHIFT; - row[6] = (a1 - b1) >> ROW_SHIFT; - row[2] = (a2 + b2) >> ROW_SHIFT; - row[5] = (a2 - b2) >> ROW_SHIFT; - row[3] = (a3 + b3) >> ROW_SHIFT; - row[4] = (a3 - b3) >> ROW_SHIFT; + row[0] = (a0 + b0) >> ROW_SHIFT; + row[7] = (a0 - b0) >> ROW_SHIFT; + row[1] = (a1 + b1) >> ROW_SHIFT; + row[6] = (a1 - b1) >> ROW_SHIFT; + row[2] = (a2 + b2) >> ROW_SHIFT; + row[5] = (a2 - b2) >> ROW_SHIFT; + row[3] = (a3 + b3) >> ROW_SHIFT; + row[4] = (a3 - b3) >> ROW_SHIFT; } #define IDCT_COLS do { \ @@ -214,67 +213,67 @@ static inline void FUNC(idctRowCondDC)(DCTELEM *row) static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size, DCTELEM *col) { - int a0, a1, a2, a3, b0, b1, b2, b3; - INIT_CLIP; + int a0, a1, a2, a3, b0, b1, b2, b3; + INIT_CLIP; - IDCT_COLS; + IDCT_COLS; - dest[0] = CLIP((a0 + b0) >> COL_SHIFT); - dest += line_size; - dest[0] = CLIP((a1 + b1) >> COL_SHIFT); - dest += line_size; - dest[0] = CLIP((a2 + b2) >> COL_SHIFT); - dest += line_size; - dest[0] = CLIP((a3 + b3) >> COL_SHIFT); - dest += line_size; - dest[0] = CLIP((a3 - b3) >> COL_SHIFT); - dest += line_size; - dest[0] = CLIP((a2 - b2) >> COL_SHIFT); - dest += line_size; - dest[0] = CLIP((a1 - b1) >> COL_SHIFT); - dest += line_size; - dest[0] = CLIP((a0 - b0) >> COL_SHIFT); + dest[0] = CLIP((a0 + b0) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a1 + b1) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a2 + b2) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a3 + b3) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a3 - b3) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a2 - b2) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a1 - b1) >> COL_SHIFT); + dest += line_size; + dest[0] = CLIP((a0 - b0) >> COL_SHIFT); } static inline void FUNC(idctSparseColAdd)(pixel *dest, int line_size, DCTELEM *col) { - int a0, a1, a2, a3, b0, b1, b2, b3; - INIT_CLIP; + int a0, a1, a2, a3, b0, b1, b2, b3; + INIT_CLIP; - IDCT_COLS; + IDCT_COLS; - dest[0] = CLIP(dest[0] + ((a0 + b0) >> COL_SHIFT)); - dest += line_size; - dest[0] = CLIP(dest[0] + ((a1 + b1) >> COL_SHIFT)); - dest += line_size; - dest[0] = CLIP(dest[0] + ((a2 + b2) >> COL_SHIFT)); - dest += line_size; - dest[0] = CLIP(dest[0] + ((a3 + b3) >> COL_SHIFT)); - dest += line_size; - dest[0] = CLIP(dest[0] + ((a3 - b3) >> COL_SHIFT)); - dest += line_size; - dest[0] = CLIP(dest[0] + ((a2 - b2) >> COL_SHIFT)); - dest += line_size; - dest[0] = CLIP(dest[0] + ((a1 - b1) >> COL_SHIFT)); - dest += line_size; - dest[0] = CLIP(dest[0] + ((a0 - b0) >> COL_SHIFT)); + dest[0] = CLIP(dest[0] + ((a0 + b0) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a1 + b1) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a2 + b2) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a3 + b3) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a3 - b3) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a2 - b2) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a1 - b1) >> COL_SHIFT)); + dest += line_size; + dest[0] = CLIP(dest[0] + ((a0 - b0) >> COL_SHIFT)); } static inline void FUNC(idctSparseCol)(DCTELEM *col) { - int a0, a1, a2, a3, b0, b1, b2, b3; + int a0, a1, a2, a3, b0, b1, b2, b3; - IDCT_COLS; + IDCT_COLS; - col[0 ] = ((a0 + b0) >> COL_SHIFT); - col[8 ] = ((a1 + b1) >> COL_SHIFT); - col[16] = ((a2 + b2) >> COL_SHIFT); - col[24] = ((a3 + b3) >> COL_SHIFT); - col[32] = ((a3 - b3) >> COL_SHIFT); - col[40] = ((a2 - b2) >> COL_SHIFT); - col[48] = ((a1 - b1) >> COL_SHIFT); - col[56] = ((a0 - b0) >> COL_SHIFT); + col[0 ] = ((a0 + b0) >> COL_SHIFT); + col[8 ] = ((a1 + b1) >> COL_SHIFT); + col[16] = ((a2 + b2) >> COL_SHIFT); + col[24] = ((a3 + b3) >> COL_SHIFT); + col[32] = ((a3 - b3) >> COL_SHIFT); + col[40] = ((a2 - b2) >> COL_SHIFT); + col[48] = ((a1 - b1) >> COL_SHIFT); + col[56] = ((a0 - b0) >> COL_SHIFT); } void FUNC(ff_simple_idct_put)(uint8_t *dest_, int line_size, DCTELEM *block) @@ -284,10 +283,10 @@ void FUNC(ff_simple_idct_put)(uint8_t *dest_, int line_size, DCTELEM *block) line_size /= sizeof(pixel); - for(i=0; i<8; i++) + for (i = 0; i < 8; i++) FUNC(idctRowCondDC)(block + i*8); - for(i=0; i<8; i++) + for (i = 0; i < 8; i++) FUNC(idctSparseColPut)(dest + i, line_size, block + i); } @@ -298,19 +297,20 @@ void FUNC(ff_simple_idct_add)(uint8_t *dest_, int line_size, DCTELEM *block) line_size /= sizeof(pixel); - for(i=0; i<8; i++) + for (i = 0; i < 8; i++) FUNC(idctRowCondDC)(block + i*8); - for(i=0; i<8; i++) + for (i = 0; i < 8; i++) FUNC(idctSparseColAdd)(dest + i, line_size, block + i); } void FUNC(ff_simple_idct)(DCTELEM *block) { int i; - for(i=0; i<8; i++) + + for (i = 0; i < 8; i++) FUNC(idctRowCondDC)(block + i*8); - for(i=0; i<8; i++) + for (i = 0; i < 8; i++) FUNC(idctSparseCol)(block + i); } From 371584c42bffa21991a0e0d97a03f6d42123ba1f Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 13 Jul 2011 18:17:54 +0100 Subject: [PATCH 631/780] build: add -L flags before existing LDFLAGS This ensures the linker picks the just built libraries even if LDFLAGS for some reason contains -L flags pointing at other directories containing libav libraries. Signed-off-by: Mans Rullgard --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a27fe28934..9d6ec3a46d 100644 --- a/Makefile +++ b/Makefile @@ -20,13 +20,15 @@ $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_PATH)/%=%)); $(INSTALL)) endif +ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale + IFLAGS := -I. -I$(SRC_PATH) CPPFLAGS := $(IFLAGS) $(CPPFLAGS) CFLAGS += $(ECFLAGS) CCFLAGS = $(CFLAGS) YASMFLAGS += $(IFLAGS) -Pconfig.asm HOSTCFLAGS += $(IFLAGS) -LDFLAGS += $(ALLFFLIBS:%=-Llib%) +LDFLAGS := $(ALLFFLIBS:%=-Llib%) $(LDFLAGS) define COMPILE $($(1)DEP) @@ -66,8 +68,6 @@ BASENAMES = ffmpeg ffplay ffprobe ffserver ALLPROGS = $(BASENAMES:%=%$(EXESUF)) ALLMANPAGES = $(BASENAMES:%=%.1) -ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale - FFLIBS-$(CONFIG_AVDEVICE) += avdevice FFLIBS-$(CONFIG_AVFILTER) += avfilter FFLIBS-$(CONFIG_AVFORMAT) += avformat From e5985185d2eda942333ebbb72bd7d043ffe40be7 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 21 Jul 2011 14:25:01 +0200 Subject: [PATCH 632/780] rv30: return AVERROR(EINVAL) instead of EINVAL On some platforms EINVAL could be positive, ensure we return negative values. --- libavcodec/rv30.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index e047c82fe0..17ea801802 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -256,7 +256,7 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx) if(avctx->extradata_size - 8 < (r->rpr - 1) * 2){ av_log(avctx, AV_LOG_ERROR, "Insufficient extradata - need at least %d bytes, got %d\n", 6 + r->rpr * 2, avctx->extradata_size); - return EINVAL; + return AVERROR(EINVAL); } r->parse_slice_header = rv30_parse_slice_header; r->decode_intra_types = rv30_decode_intra_types; From ba99474b1d3282afd5111d7e4ce542030f3f0ccc Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 21 Jul 2011 16:50:00 +0200 Subject: [PATCH 633/780] h264: fix h264-test Signed-off-by: Michael Niedermayer --- libavcodec/h264.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index fe3cd93c0f..1fde7455ae 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3870,6 +3870,7 @@ static inline void fill_mb_avail(H264Context *h){ #undef random #define COUNT 8000 #define SIZE (COUNT*40) +extern AVCodec ff_h264_decoder; int main(void){ int i; uint8_t temp[SIZE]; @@ -3879,6 +3880,8 @@ int main(void){ DSPContext dsp; AVCodecContext avctx; + avcodec_get_context_defaults3(&avctx, &ff_h264_decoder); + dsputil_init(&dsp, &avctx); init_put_bits(&pb, temp, SIZE); From 09e8163625ec985fa4388000fe90b9a3550122aa Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 19 Jul 2011 14:23:47 +0200 Subject: [PATCH 634/780] imgconvert: remove unused glue and xglue macros Signed-off-by: Diego Biurrun --- libavcodec/imgconvert.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 351ed7ada7..c446aaca38 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -42,9 +42,6 @@ #include "x86/dsputil_mmx.h" #endif -#define xglue(x, y) x ## y -#define glue(x, y) xglue(x, y) - #define FF_COLOR_RGB 0 /**< RGB color space */ #define FF_COLOR_GRAY 1 /**< gray color space */ #define FF_COLOR_YUV 2 /**< YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */ From 364d64275c66ac3b6dff699e80c167b6815e8f57 Mon Sep 17 00:00:00 2001 From: Thierry Foucu Date: Wed, 20 Jul 2011 20:33:22 -0700 Subject: [PATCH 635/780] ffprobe: display bitstream level. Signed-off-by: Ronald S. Bultje --- ffprobe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ffprobe.c b/ffprobe.c index cb4a4c3106..2457b063a5 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -201,6 +201,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) } printf("pix_fmt=%s\n", dec_ctx->pix_fmt != PIX_FMT_NONE ? av_pix_fmt_descriptors[dec_ctx->pix_fmt].name : "unknown"); + printf("level=%d\n", dec_ctx->level); break; case AVMEDIA_TYPE_AUDIO: From 0637e50579c77ce16373a45dc173aa449e3a8011 Mon Sep 17 00:00:00 2001 From: Thierry Foucu Date: Wed, 20 Jul 2011 20:33:23 -0700 Subject: [PATCH 636/780] mpeg4: decode Level Profile for MPEG4 Part 2. Signed-off-by: Ronald S. Bultje --- libavcodec/mpeg4videodec.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index df0191dc9f..b48f44d998 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -1523,6 +1523,22 @@ static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){ return 0; } +static int mpeg4_decode_profile_level(MpegEncContext * s, GetBitContext *gb){ + int profile_and_level_indication; + + profile_and_level_indication = get_bits(gb, 8); + + s->avctx->profile = (profile_and_level_indication & 0xf0) >> 4; + s->avctx->level = (profile_and_level_indication & 0x0f); + + // for Simple profile, level 0 + if (s->avctx->profile == 0 && s->avctx->level == 8) { + s->avctx->level = 0; + } + + return 0; +} + static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){ int width, height, vo_ver_id; @@ -2177,6 +2193,9 @@ int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb) else if(startcode == GOP_STARTCODE){ mpeg4_decode_gop_header(s, gb); } + else if(startcode == VOS_STARTCODE){ + mpeg4_decode_profile_level(s, gb); + } else if(startcode == VOP_STARTCODE){ break; } From c4ab43ff3c65de1d3d565a12e1ac8fae176bbd1a Mon Sep 17 00:00:00 2001 From: Thierry Foucu Date: Wed, 20 Jul 2011 20:33:24 -0700 Subject: [PATCH 637/780] mpeg4: add Mpeg4 Profiles names. Signed-off-by: Ronald S. Bultje --- libavcodec/avcodec.h | 17 +++++++++++++++++ libavcodec/mpeg4videodec.c | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 2d4515519a..b6cac7c77d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2231,6 +2231,23 @@ typedef struct AVCodecContext { #define FF_PROFILE_VC1_COMPLEX 2 #define FF_PROFILE_VC1_ADVANCED 3 +#define FF_PROFILE_MPEG4_SIMPLE 0 +#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1 +#define FF_PROFILE_MPEG4_CORE 2 +#define FF_PROFILE_MPEG4_MAIN 3 +#define FF_PROFILE_MPEG4_N_BIT 4 +#define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5 +#define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6 +#define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7 +#define FF_PROFILE_MPEG4_HYBRID 8 +#define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9 +#define FF_PROFILE_MPEG4_CORE_SCALABLE 10 +#define FF_PROFILE_MPEG4_ADVANCED_CODING 11 +#define FF_PROFILE_MPEG4_ADVANCED_CORE 12 +#define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13 +#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14 +#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15 + /** * level * - encoding: Set by user. diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index b48f44d998..b1abb618ef 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -2256,6 +2256,25 @@ static av_cold int decode_init(AVCodecContext *avctx) return 0; } +static const AVProfile mpeg4_video_profiles[] = { + { FF_PROFILE_MPEG4_SIMPLE, "Simple Profile" }, + { FF_PROFILE_MPEG4_SIMPLE_SCALABLE, "Simple Scalable Profile" }, + { FF_PROFILE_MPEG4_CORE, "Core Profile" }, + { FF_PROFILE_MPEG4_MAIN, "Main Profile" }, + { FF_PROFILE_MPEG4_N_BIT, "N-bit Profile" }, + { FF_PROFILE_MPEG4_SCALABLE_TEXTURE, "Scalable Texture Profile" }, + { FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION, "Simple Face Animation Profile" }, + { FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE, "Basic Animated Texture Profile" }, + { FF_PROFILE_MPEG4_HYBRID, "Hybrid Profile" }, + { FF_PROFILE_MPEG4_ADVANCED_REAL_TIME, "Advanced Real Time Simple Profile" }, + { FF_PROFILE_MPEG4_CORE_SCALABLE, "Code Scalable Profile" }, + { FF_PROFILE_MPEG4_ADVANCED_CODING, "Advanced Coding Profile" }, + { FF_PROFILE_MPEG4_ADVANCED_CORE, "Advanced Core Profile" }, + { FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE, "Advanced Scalable Texture Profile" }, + { FF_PROFILE_MPEG4_SIMPLE_STUDIO, "Simple Studio Profile" }, + { FF_PROFILE_MPEG4_ADVANCED_SIMPLE, "Advanced Simple Profile" }, +}; + AVCodec ff_mpeg4_decoder = { "mpeg4", AVMEDIA_TYPE_VIDEO, @@ -2270,6 +2289,7 @@ AVCodec ff_mpeg4_decoder = { .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), .pix_fmts= ff_hwaccel_pixfmt_list_420, + .profiles = NULL_IF_CONFIG_SMALL(mpeg4_video_profiles), .update_thread_context= ONLY_IF_THREADS_ENABLED(ff_mpeg_update_thread_context) }; From 73c0dd939d503aaf83d3266181a156615eeb77d5 Mon Sep 17 00:00:00 2001 From: Thierry Foucu Date: Wed, 20 Jul 2011 20:33:25 -0700 Subject: [PATCH 638/780] mov: add clcp type track as Subtitle stream. Signed-off-by: Ronald S. Bultje --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 0de2bfc325..92b1b14f15 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -451,7 +451,7 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom) st->codec->codec_type = AVMEDIA_TYPE_AUDIO; else if(type == MKTAG('m','1','a',' ')) st->codec->codec_id = CODEC_ID_MP2; - else if(type == MKTAG('s','u','b','p')) + else if((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p'))) st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; avio_rb32(pb); /* component manufacture */ From 0a72533e9854aa615bb6d1569dd5f0c4cd031429 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 20 Jul 2011 20:01:56 +0100 Subject: [PATCH 639/780] jfdctint: add 10-bit version Signed-off-by: Mans Rullgard --- libavcodec/bfin/dsputil_bfin.c | 6 +- libavcodec/dct-test.c | 2 +- libavcodec/dsputil.c | 27 ++- libavcodec/dsputil.h | 6 +- libavcodec/jfdctint.c | 413 ++------------------------------ libavcodec/jfdctint_template.c | 405 +++++++++++++++++++++++++++++++ libavcodec/mpegvideo_enc.c | 3 +- libavcodec/ppc/dsputil_ppc.c | 5 +- libavcodec/x86/dsputilenc_mmx.c | 3 +- 9 files changed, 454 insertions(+), 416 deletions(-) create mode 100644 libavcodec/jfdctint_template.c diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c index d06bd8e4fd..691c060733 100644 --- a/libavcodec/bfin/dsputil_bfin.c +++ b/libavcodec/bfin/dsputil_bfin.c @@ -253,10 +253,10 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) /* c->put_no_rnd_pixels_tab[0][3] = ff_bfin_put_pixels16_xy2_nornd; */ } - if (avctx->dct_algo == FF_DCT_AUTO) - c->fdct = ff_bfin_fdct; - if (avctx->bits_per_raw_sample <= 8) { + if (avctx->dct_algo == FF_DCT_AUTO) + c->fdct = ff_bfin_fdct; + if (avctx->idct_algo == FF_IDCT_VP3) { c->idct_permutation_type = FF_NO_IDCT_PERM; c->idct = ff_bfin_vp3_idct; diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index 136f5c4742..962b370c2b 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -88,7 +88,7 @@ static const struct algo fdct_tab[] = { { "REF-DBL", ff_ref_fdct, NO_PERM }, { "FAAN", ff_faandct, FAAN_SCALE }, { "IJG-AAN-INT", fdct_ifast, SCALE_PERM }, - { "IJG-LLM-INT", ff_jpeg_fdct_islow, NO_PERM }, + { "IJG-LLM-INT", ff_jpeg_fdct_islow_8, NO_PERM }, #if HAVE_MMX { "MMX", ff_fdct_mmx, NO_PERM, AV_CPU_FLAG_MMX }, diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 4008389a9d..a99be55eac 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -2848,17 +2848,22 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) ff_check_alignment(); #if CONFIG_ENCODERS - if(avctx->dct_algo==FF_DCT_FASTINT) { - c->fdct = fdct_ifast; - c->fdct248 = fdct_ifast248; - } - else if(avctx->dct_algo==FF_DCT_FAAN) { - c->fdct = ff_faandct; - c->fdct248 = ff_faandct248; - } - else { - c->fdct = ff_jpeg_fdct_islow; //slow/accurate/default - c->fdct248 = ff_fdct248_islow; + if (avctx->bits_per_raw_sample == 10) { + c->fdct = ff_jpeg_fdct_islow_10; + c->fdct248 = ff_fdct248_islow_10; + } else { + if(avctx->dct_algo==FF_DCT_FASTINT) { + c->fdct = fdct_ifast; + c->fdct248 = fdct_ifast248; + } + else if(avctx->dct_algo==FF_DCT_FAAN) { + c->fdct = ff_faandct; + c->fdct248 = ff_faandct248; + } + else { + c->fdct = ff_jpeg_fdct_islow_8; //slow/accurate/default + c->fdct248 = ff_fdct248_islow_8; + } } #endif //CONFIG_ENCODERS diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 8cd3af60ca..47c13a1adb 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -40,8 +40,10 @@ typedef short DCTELEM; void fdct_ifast (DCTELEM *data); void fdct_ifast248 (DCTELEM *data); -void ff_jpeg_fdct_islow (DCTELEM *data); -void ff_fdct248_islow (DCTELEM *data); +void ff_jpeg_fdct_islow_8(DCTELEM *data); +void ff_jpeg_fdct_islow_10(DCTELEM *data); +void ff_fdct248_islow_8(DCTELEM *data); +void ff_fdct248_islow_10(DCTELEM *data); void j_rev_dct (DCTELEM *data); void j_rev_dct4 (DCTELEM *data); diff --git a/libavcodec/jfdctint.c b/libavcodec/jfdctint.c index 072c7440b5..0482bc5643 100644 --- a/libavcodec/jfdctint.c +++ b/libavcodec/jfdctint.c @@ -1,402 +1,25 @@ -/* - * jfdctint.c - * - * This file is part of the Independent JPEG Group's software. - * - * The authors make NO WARRANTY or representation, either express or implied, - * with respect to this software, its quality, accuracy, merchantability, or - * fitness for a particular purpose. This software is provided "AS IS", and - * you, its user, assume the entire risk as to its quality and accuracy. - * - * This software is copyright (C) 1991-1996, Thomas G. Lane. - * All Rights Reserved except as specified below. - * - * Permission is hereby granted to use, copy, modify, and distribute this - * software (or portions thereof) for any purpose, without fee, subject to - * these conditions: - * (1) If any part of the source code for this software is distributed, then - * this README file must be included, with this copyright and no-warranty - * notice unaltered; and any additions, deletions, or changes to the original - * files must be clearly indicated in accompanying documentation. - * (2) If only executable code is distributed, then the accompanying - * documentation must state that "this software is based in part on the work - * of the Independent JPEG Group". - * (3) Permission for use of this software is granted only if the user accepts - * full responsibility for any undesirable consequences; the authors accept - * NO LIABILITY for damages of any kind. - * - * These conditions apply to any software derived from or based on the IJG - * code, not just to the unmodified library. If you use our work, you ought - * to acknowledge us. - * - * Permission is NOT granted for the use of any IJG author's name or company - * name in advertising or publicity relating to this software or products - * derived from it. This software may be referred to only as "the Independent - * JPEG Group's software". - * - * We specifically permit and encourage the use of this software as the basis - * of commercial products, provided that all warranty or liability claims are - * assumed by the product vendor. - * - * This file contains a slow-but-accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - /** - * @file - * Independent JPEG Group's slow & accurate dct. - */ - -#include -#include -#include "libavutil/common.h" -#include "dsputil.h" - -#define DCTSIZE 8 -#define BITS_IN_JSAMPLE 8 -#define GLOBAL(x) x -#define RIGHT_SHIFT(x, n) ((x) >> (n)) -#define MULTIPLY16C16(var,const) ((var)*(const)) - -#if 1 //def USE_ACCURATE_ROUNDING -#define DESCALE(x,n) RIGHT_SHIFT((x) + (1 << ((n) - 1)), n) -#else -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: + * This file is part of Libav. * - * Each 1-D DCT step produces outputs which are a factor of sqrt(N) - * larger than the true DCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D DCT, - * because the y0 and y4 outputs need not be divided by sqrt(N). - * In the IJG code, this factor of 8 is removed by the quantization step - * (in jcdctmgr.c), NOT in this module. + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. + * Libav 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 + * Lesser General Public License for more details. * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (For 12-bit sample data, the intermediate - * array is int32_t anyway.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 4 /* set this to 2 if 16x16 multiplies are faster */ -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif +#define BIT_DEPTH 8 +#include "jfdctint_template.c" +#undef BIT_DEPTH -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((int32_t) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((int32_t) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((int32_t) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((int32_t) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((int32_t) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((int32_t) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((int32_t) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((int32_t) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((int32_t) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((int32_t) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((int32_t) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((int32_t) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an int32_t variable by an int32_t constant to yield an int32_t result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 && CONST_BITS<=13 && PASS1_BITS<=2 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -static av_always_inline void row_fdct(DCTELEM * data){ - int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - int tmp10, tmp11, tmp12, tmp13; - int z1, z2, z3, z4, z5; - DCTELEM *dataptr; - int ctr; - - /* Pass 1: process rows. */ - /* Note results are scaled up by sqrt(8) compared to a true DCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); - dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS-PASS1_BITS); - dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS-PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); - dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); - dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); - dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); - - dataptr += DCTSIZE; /* advance pointer to next row */ - } -} - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -ff_jpeg_fdct_islow (DCTELEM * data) -{ - int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - int tmp10, tmp11, tmp12, tmp13; - int z1, z2, z3, z4, z5; - DCTELEM *dataptr; - int ctr; - - row_fdct(data); - - /* Pass 2: process columns. - * We remove the PASS1_BITS scaling, but leave the results scaled up - * by an overall factor of 8. - */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); - dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS+PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, - CONST_BITS+PASS1_BITS); - - dataptr++; /* advance pointer to next column */ - } -} - -/* - * The secret of DCT2-4-8 is really simple -- you do the usual 1-DCT - * on the rows and then, instead of doing even and odd, part on the colums - * you do even part two times. - */ -GLOBAL(void) -ff_fdct248_islow (DCTELEM * data) -{ - int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - int tmp10, tmp11, tmp12, tmp13; - int z1; - DCTELEM *dataptr; - int ctr; - - row_fdct(data); - - /* Pass 2: process columns. - * We remove the PASS1_BITS scaling, but leave the results scaled up - * by an overall factor of 8. - */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*1]; - tmp1 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*3]; - tmp2 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*6] + dataptr[DCTSIZE*7]; - tmp4 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*1]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*3]; - tmp6 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*5]; - tmp7 = dataptr[DCTSIZE*6] - dataptr[DCTSIZE*7]; - - tmp10 = tmp0 + tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - tmp13 = tmp0 - tmp3; - - dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); - dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS+PASS1_BITS); - - tmp10 = tmp4 + tmp7; - tmp11 = tmp5 + tmp6; - tmp12 = tmp5 - tmp6; - tmp13 = tmp4 - tmp7; - - dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); - dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS+PASS1_BITS); - - dataptr++; /* advance pointer to next column */ - } -} +#define BIT_DEPTH 10 +#include "jfdctint_template.c" +#undef BIT_DEPTH diff --git a/libavcodec/jfdctint_template.c b/libavcodec/jfdctint_template.c new file mode 100644 index 0000000000..e60e72a412 --- /dev/null +++ b/libavcodec/jfdctint_template.c @@ -0,0 +1,405 @@ +/* + * jfdctint.c + * + * This file is part of the Independent JPEG Group's software. + * + * The authors make NO WARRANTY or representation, either express or implied, + * with respect to this software, its quality, accuracy, merchantability, or + * fitness for a particular purpose. This software is provided "AS IS", and + * you, its user, assume the entire risk as to its quality and accuracy. + * + * This software is copyright (C) 1991-1996, Thomas G. Lane. + * All Rights Reserved except as specified below. + * + * Permission is hereby granted to use, copy, modify, and distribute this + * software (or portions thereof) for any purpose, without fee, subject to + * these conditions: + * (1) If any part of the source code for this software is distributed, then + * this README file must be included, with this copyright and no-warranty + * notice unaltered; and any additions, deletions, or changes to the original + * files must be clearly indicated in accompanying documentation. + * (2) If only executable code is distributed, then the accompanying + * documentation must state that "this software is based in part on the work + * of the Independent JPEG Group". + * (3) Permission for use of this software is granted only if the user accepts + * full responsibility for any undesirable consequences; the authors accept + * NO LIABILITY for damages of any kind. + * + * These conditions apply to any software derived from or based on the IJG + * code, not just to the unmodified library. If you use our work, you ought + * to acknowledge us. + * + * Permission is NOT granted for the use of any IJG author's name or company + * name in advertising or publicity relating to this software or products + * derived from it. This software may be referred to only as "the Independent + * JPEG Group's software". + * + * We specifically permit and encourage the use of this software as the basis + * of commercial products, provided that all warranty or liability claims are + * assumed by the product vendor. + * + * This file contains a slow-but-accurate integer implementation of the + * forward DCT (Discrete Cosine Transform). + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on an algorithm described in + * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT + * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, + * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. + * The primary algorithm described there uses 11 multiplies and 29 adds. + * We use their alternate method with 12 multiplies and 32 adds. + * The advantage of this method is that no data path contains more than one + * multiplication; this allows a very simple and accurate implementation in + * scaled fixed-point arithmetic, with a minimal number of shifts. + */ + +/** + * @file + * Independent JPEG Group's slow & accurate dct. + */ + +#include "libavutil/common.h" +#include "dsputil.h" + +#include "bit_depth_template.c" + +#define DCTSIZE 8 +#define BITS_IN_JSAMPLE BIT_DEPTH +#define GLOBAL(x) x +#define RIGHT_SHIFT(x, n) ((x) >> (n)) +#define MULTIPLY16C16(var,const) ((var)*(const)) + +#if 1 //def USE_ACCURATE_ROUNDING +#define DESCALE(x,n) RIGHT_SHIFT((x) + (1 << ((n) - 1)), n) +#else +#define DESCALE(x,n) RIGHT_SHIFT(x, n) +#endif + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 +#error "Sorry, this code only copes with 8x8 DCTs." +#endif + + +/* + * The poop on this scaling stuff is as follows: + * + * Each 1-D DCT step produces outputs which are a factor of sqrt(N) + * larger than the true DCT outputs. The final outputs are therefore + * a factor of N larger than desired; since N=8 this can be cured by + * a simple right shift at the end of the algorithm. The advantage of + * this arrangement is that we save two multiplications per 1-D DCT, + * because the y0 and y4 outputs need not be divided by sqrt(N). + * In the IJG code, this factor of 8 is removed by the quantization step + * (in jcdctmgr.c), NOT in this module. + * + * We have to do addition and subtraction of the integer inputs, which + * is no problem, and multiplication by fractional constants, which is + * a problem to do in integer arithmetic. We multiply all the constants + * by CONST_SCALE and convert them to integer constants (thus retaining + * CONST_BITS bits of precision in the constants). After doing a + * multiplication we have to divide the product by CONST_SCALE, with proper + * rounding, to produce the correct output. This division can be done + * cheaply as a right shift of CONST_BITS bits. We postpone shifting + * as long as possible so that partial sums can be added together with + * full fractional precision. + * + * The outputs of the first pass are scaled up by PASS1_BITS bits so that + * they are represented to better-than-integral precision. These outputs + * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word + * with the recommended scaling. (For 12-bit sample data, the intermediate + * array is int32_t anyway.) + * + * To avoid overflow of the 32-bit intermediate results in pass 2, we must + * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis + * shows that the values given below are the most effective. + */ + +#undef CONST_BITS +#undef PASS1_BITS +#undef OUT_SHIFT + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 4 /* set this to 2 if 16x16 multiplies are faster */ +#define OUT_SHIFT PASS1_BITS +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#define OUT_SHIFT (PASS1_BITS + 1) +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_298631336 ((int32_t) 2446) /* FIX(0.298631336) */ +#define FIX_0_390180644 ((int32_t) 3196) /* FIX(0.390180644) */ +#define FIX_0_541196100 ((int32_t) 4433) /* FIX(0.541196100) */ +#define FIX_0_765366865 ((int32_t) 6270) /* FIX(0.765366865) */ +#define FIX_0_899976223 ((int32_t) 7373) /* FIX(0.899976223) */ +#define FIX_1_175875602 ((int32_t) 9633) /* FIX(1.175875602) */ +#define FIX_1_501321110 ((int32_t) 12299) /* FIX(1.501321110) */ +#define FIX_1_847759065 ((int32_t) 15137) /* FIX(1.847759065) */ +#define FIX_1_961570560 ((int32_t) 16069) /* FIX(1.961570560) */ +#define FIX_2_053119869 ((int32_t) 16819) /* FIX(2.053119869) */ +#define FIX_2_562915447 ((int32_t) 20995) /* FIX(2.562915447) */ +#define FIX_3_072711026 ((int32_t) 25172) /* FIX(3.072711026) */ +#else +#define FIX_0_298631336 FIX(0.298631336) +#define FIX_0_390180644 FIX(0.390180644) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_175875602 FIX(1.175875602) +#define FIX_1_501321110 FIX(1.501321110) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_1_961570560 FIX(1.961570560) +#define FIX_2_053119869 FIX(2.053119869) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_072711026 FIX(3.072711026) +#endif + + +/* Multiply an int32_t variable by an int32_t constant to yield an int32_t result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 && CONST_BITS<=13 && PASS1_BITS<=2 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +static av_always_inline void FUNC(row_fdct)(DCTELEM *data) +{ + int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + int tmp10, tmp11, tmp12, tmp13; + int z1, z2, z3, z4, z5; + DCTELEM *dataptr; + int ctr; + + /* Pass 1: process rows. */ + /* Note results are scaled up by sqrt(8) compared to a true DCT; */ + /* furthermore, we scale the results by 2**PASS1_BITS. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". + */ + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); + dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); + dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), + CONST_BITS-PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * cK represents cos(K*pi/16). + * i0..i3 in the paper are tmp4..tmp7 here. + */ + + z1 = tmp4 + tmp7; + z2 = tmp5 + tmp6; + z3 = tmp4 + tmp6; + z4 = tmp5 + tmp7; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); + dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } +} + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +FUNC(ff_jpeg_fdct_islow)(DCTELEM *data) +{ + int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + int tmp10, tmp11, tmp12, tmp13; + int z1, z2, z3, z4, z5; + DCTELEM *dataptr; + int ctr; + + FUNC(row_fdct)(data); + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". + */ + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = DESCALE(tmp10 + tmp11, OUT_SHIFT); + dataptr[DCTSIZE*4] = DESCALE(tmp10 - tmp11, OUT_SHIFT); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); + dataptr[DCTSIZE*2] = DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), + CONST_BITS + OUT_SHIFT); + dataptr[DCTSIZE*6] = DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), + CONST_BITS + OUT_SHIFT); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * cK represents cos(K*pi/16). + * i0..i3 in the paper are tmp4..tmp7 here. + */ + + z1 = tmp4 + tmp7; + z2 = tmp5 + tmp6; + z3 = tmp4 + tmp6; + z4 = tmp5 + tmp7; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + dataptr[DCTSIZE*7] = DESCALE(tmp4 + z1 + z3, CONST_BITS + OUT_SHIFT); + dataptr[DCTSIZE*5] = DESCALE(tmp5 + z2 + z4, CONST_BITS + OUT_SHIFT); + dataptr[DCTSIZE*3] = DESCALE(tmp6 + z2 + z3, CONST_BITS + OUT_SHIFT); + dataptr[DCTSIZE*1] = DESCALE(tmp7 + z1 + z4, CONST_BITS + OUT_SHIFT); + + dataptr++; /* advance pointer to next column */ + } +} + +/* + * The secret of DCT2-4-8 is really simple -- you do the usual 1-DCT + * on the rows and then, instead of doing even and odd, part on the colums + * you do even part two times. + */ +GLOBAL(void) +FUNC(ff_fdct248_islow)(DCTELEM *data) +{ + int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + int tmp10, tmp11, tmp12, tmp13; + int z1; + DCTELEM *dataptr; + int ctr; + + FUNC(row_fdct)(data); + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*1]; + tmp1 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*3]; + tmp2 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*6] + dataptr[DCTSIZE*7]; + tmp4 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*1]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*3]; + tmp6 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*5]; + tmp7 = dataptr[DCTSIZE*6] - dataptr[DCTSIZE*7]; + + tmp10 = tmp0 + tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + tmp13 = tmp0 - tmp3; + + dataptr[DCTSIZE*0] = DESCALE(tmp10 + tmp11, OUT_SHIFT); + dataptr[DCTSIZE*4] = DESCALE(tmp10 - tmp11, OUT_SHIFT); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); + dataptr[DCTSIZE*2] = DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), + CONST_BITS+OUT_SHIFT); + dataptr[DCTSIZE*6] = DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), + CONST_BITS+OUT_SHIFT); + + tmp10 = tmp4 + tmp7; + tmp11 = tmp5 + tmp6; + tmp12 = tmp5 - tmp6; + tmp13 = tmp4 - tmp7; + + dataptr[DCTSIZE*1] = DESCALE(tmp10 + tmp11, OUT_SHIFT); + dataptr[DCTSIZE*5] = DESCALE(tmp10 - tmp11, OUT_SHIFT); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); + dataptr[DCTSIZE*3] = DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), + CONST_BITS + OUT_SHIFT); + dataptr[DCTSIZE*7] = DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), + CONST_BITS + OUT_SHIFT); + + dataptr++; /* advance pointer to next column */ + } +} diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 4b4636b32b..c4ca7b30a9 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -69,7 +69,8 @@ void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][6 for(qscale=qmin; qscale<=qmax; qscale++){ int i; - if (dsp->fdct == ff_jpeg_fdct_islow + if (dsp->fdct == ff_jpeg_fdct_islow_8 || + dsp->fdct == ff_jpeg_fdct_islow_10 #ifdef FAAN_POSTSCALE || dsp->fdct == ff_faandct #endif diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c index c1f68fc5f7..b6de39fae7 100644 --- a/libavcodec/ppc/dsputil_ppc.c +++ b/libavcodec/ppc/dsputil_ppc.c @@ -172,8 +172,9 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx) c->gmc1 = gmc1_altivec; #if CONFIG_ENCODERS - if (avctx->dct_algo == FF_DCT_AUTO || - avctx->dct_algo == FF_DCT_ALTIVEC) { + if (avctx->bits_per_raw_sample <= 8 && + (avctx->dct_algo == FF_DCT_AUTO || + avctx->dct_algo == FF_DCT_ALTIVEC)) { c->fdct = fdct_altivec; } #endif //CONFIG_ENCODERS diff --git a/libavcodec/x86/dsputilenc_mmx.c b/libavcodec/x86/dsputilenc_mmx.c index 037389137b..ea03e9232f 100644 --- a/libavcodec/x86/dsputilenc_mmx.c +++ b/libavcodec/x86/dsputilenc_mmx.c @@ -1101,7 +1101,8 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx) if (mm_flags & AV_CPU_FLAG_MMX) { const int dct_algo = avctx->dct_algo; - if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){ + if (avctx->bits_per_raw_sample <= 8 && + (dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) { if(mm_flags & AV_CPU_FLAG_SSE2){ c->fdct = ff_fdct_sse2; }else if(mm_flags & AV_CPU_FLAG_MMX2){ From 5cc2600964c72dad995efb18c918a63e0965f8db Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 21 Jul 2011 12:39:41 +0100 Subject: [PATCH 640/780] dsputil: create 16/32-bit dctcoef versions of some functions High bitdepth H.264 needs 32-bit transform coefficients, whereas dnxhd does not. This creates a conflict with the templated functions operating on DCTELEM data. This patch adds a field allowing the caller to choose the element size in dsputil_init() and adds the required functions. Signed-off-by: Mans Rullgard --- libavcodec/dsputil.c | 24 +++++--- libavcodec/dsputil.h | 5 ++ libavcodec/dsputil_template.c | 106 +++++++++++++++++++--------------- libavcodec/h264.c | 1 + 4 files changed, 80 insertions(+), 56 deletions(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index a99be55eac..b18164065d 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -3159,13 +3159,13 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth) -#define BIT_DEPTH_FUNCS(depth)\ +#define BIT_DEPTH_FUNCS(depth, dct)\ c->draw_edges = FUNCC(draw_edges , depth);\ c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\ - c->clear_block = FUNCC(clear_block , depth);\ - c->clear_blocks = FUNCC(clear_blocks , depth);\ - c->add_pixels8 = FUNCC(add_pixels8 , depth);\ - c->add_pixels4 = FUNCC(add_pixels4 , depth);\ + c->clear_block = FUNCC(clear_block ## dct , depth);\ + c->clear_blocks = FUNCC(clear_blocks ## dct , depth);\ + c->add_pixels8 = FUNCC(add_pixels8 ## dct , depth);\ + c->add_pixels4 = FUNCC(add_pixels4 ## dct , depth);\ c->put_no_rnd_pixels_l2[0] = FUNCC(put_no_rnd_pixels16_l2, depth);\ c->put_no_rnd_pixels_l2[1] = FUNCC(put_no_rnd_pixels8_l2 , depth);\ \ @@ -3199,15 +3199,23 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) switch (avctx->bits_per_raw_sample) { case 9: - BIT_DEPTH_FUNCS(9); + if (c->dct_bits == 32) { + BIT_DEPTH_FUNCS(9, _32); + } else { + BIT_DEPTH_FUNCS(9, _16); + } break; case 10: - BIT_DEPTH_FUNCS(10); + if (c->dct_bits == 32) { + BIT_DEPTH_FUNCS(10, _32); + } else { + BIT_DEPTH_FUNCS(10, _16); + } break; default: av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", avctx->bits_per_raw_sample); case 8: - BIT_DEPTH_FUNCS(8); + BIT_DEPTH_FUNCS(8, _16); break; } diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 47c13a1adb..0ba36d77ec 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -219,6 +219,11 @@ void ff_put_signed_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int lin * DSPContext. */ typedef struct DSPContext { + /** + * Size of DCT coefficients. + */ + int dct_bits; + /* pixel ops : interface with DCT */ void (*get_pixels)(DCTELEM *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size); void (*diff_pixels)(DCTELEM *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride); diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index 9f8cf557c8..5863275c00 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -192,43 +192,66 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, i } } -static void FUNCC(add_pixels8)(uint8_t *restrict _pixels, DCTELEM *_block, int line_size) -{ - int i; - pixel *restrict pixels = (pixel *restrict)_pixels; - dctcoef *block = (dctcoef*)_block; - line_size /= sizeof(pixel); - - for(i=0;i<8;i++) { - pixels[0] += block[0]; - pixels[1] += block[1]; - pixels[2] += block[2]; - pixels[3] += block[3]; - pixels[4] += block[4]; - pixels[5] += block[5]; - pixels[6] += block[6]; - pixels[7] += block[7]; - pixels += line_size; - block += 8; - } +#define DCTELEM_FUNCS(dctcoef, suffix) \ +static void FUNCC(add_pixels8 ## suffix)(uint8_t *restrict _pixels, \ + DCTELEM *_block, \ + int line_size) \ +{ \ + int i; \ + pixel *restrict pixels = (pixel *restrict)_pixels; \ + dctcoef *block = (dctcoef*)_block; \ + line_size /= sizeof(pixel); \ + \ + for(i=0;i<8;i++) { \ + pixels[0] += block[0]; \ + pixels[1] += block[1]; \ + pixels[2] += block[2]; \ + pixels[3] += block[3]; \ + pixels[4] += block[4]; \ + pixels[5] += block[5]; \ + pixels[6] += block[6]; \ + pixels[7] += block[7]; \ + pixels += line_size; \ + block += 8; \ + } \ +} \ + \ +static void FUNCC(add_pixels4 ## suffix)(uint8_t *restrict _pixels, \ + DCTELEM *_block, \ + int line_size) \ +{ \ + int i; \ + pixel *restrict pixels = (pixel *restrict)_pixels; \ + dctcoef *block = (dctcoef*)_block; \ + line_size /= sizeof(pixel); \ + \ + for(i=0;i<4;i++) { \ + pixels[0] += block[0]; \ + pixels[1] += block[1]; \ + pixels[2] += block[2]; \ + pixels[3] += block[3]; \ + pixels += line_size; \ + block += 4; \ + } \ +} \ + \ +static void FUNCC(clear_block ## suffix)(DCTELEM *block) \ +{ \ + memset(block, 0, sizeof(dctcoef)*64); \ +} \ + \ +/** \ + * memset(blocks, 0, sizeof(DCTELEM)*6*64) \ + */ \ +static void FUNCC(clear_blocks ## suffix)(DCTELEM *blocks) \ +{ \ + memset(blocks, 0, sizeof(dctcoef)*6*64); \ } -static void FUNCC(add_pixels4)(uint8_t *restrict _pixels, DCTELEM *_block, int line_size) -{ - int i; - pixel *restrict pixels = (pixel *restrict)_pixels; - dctcoef *block = (dctcoef*)_block; - line_size /= sizeof(pixel); - - for(i=0;i<4;i++) { - pixels[0] += block[0]; - pixels[1] += block[1]; - pixels[2] += block[2]; - pixels[3] += block[3]; - pixels += line_size; - block += 4; - } -} +DCTELEM_FUNCS(DCTELEM, _16) +#if BIT_DEPTH > 8 +DCTELEM_FUNCS(dctcoef, _32) +#endif #define PIXOP2(OPNAME, OP) \ static void FUNCC(OPNAME ## _pixels2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ @@ -1231,16 +1254,3 @@ void FUNCC(ff_put_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) { void FUNCC(ff_avg_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) { FUNCC(avg_pixels16)(dst, src, stride, 16); } - -static void FUNCC(clear_block)(DCTELEM *block) -{ - memset(block, 0, sizeof(dctcoef)*64); -} - -/** - * memset(blocks, 0, sizeof(DCTELEM)*6*64) - */ -static void FUNCC(clear_blocks)(DCTELEM *blocks) -{ - memset(blocks, 0, sizeof(dctcoef)*6*64); -} diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 5adce242ce..928a96ab35 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3702,6 +3702,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma); ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma); + s->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16; dsputil_init(&s->dsp, s->avctx); } else { av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma); From 874f1a901d9f2d1d6825be309ed046abc7672b03 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 21 Jul 2011 02:31:57 +0100 Subject: [PATCH 641/780] dsputil: template get_pixels() for different bit depths Signed-off-by: Mans Rullgard --- libavcodec/alpha/dsputil_alpha.c | 3 ++- libavcodec/arm/dsputil_init_armv6.c | 3 ++- libavcodec/bfin/dsputil_bfin.c | 2 +- libavcodec/dsputil.c | 21 +-------------------- libavcodec/dsputil_template.c | 23 +++++++++++++++++++++++ libavcodec/mlib/dsputil_mlib.c | 3 ++- libavcodec/ppc/dsputil_altivec.c | 5 ++--- libavcodec/ps2/dsputil_mmi.c | 2 +- libavcodec/x86/dsputilenc_mmx.c | 7 +++++-- 9 files changed, 39 insertions(+), 30 deletions(-) diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c index 039608b9ed..3efcf096b4 100644 --- a/libavcodec/alpha/dsputil_alpha.c +++ b/libavcodec/alpha/dsputil_alpha.c @@ -321,7 +321,8 @@ void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx) c->put_pixels_clamped = put_pixels_clamped_mvi_asm; c->add_pixels_clamped = add_pixels_clamped_mvi_asm; - c->get_pixels = get_pixels_mvi; + if (!high_bit_depth) + c->get_pixels = get_pixels_mvi; c->diff_pixels = diff_pixels_mvi; c->sad[0] = pix_abs16x16_mvi_asm; c->sad[1] = pix_abs8x8_mvi; diff --git a/libavcodec/arm/dsputil_init_armv6.c b/libavcodec/arm/dsputil_init_armv6.c index d442415aec..07124c2773 100644 --- a/libavcodec/arm/dsputil_init_armv6.c +++ b/libavcodec/arm/dsputil_init_armv6.c @@ -106,8 +106,9 @@ void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx) c->avg_pixels_tab[1][0] = ff_avg_pixels8_armv6; } + if (!high_bit_depth) + c->get_pixels = ff_get_pixels_armv6; c->add_pixels_clamped = ff_add_pixels_clamped_armv6; - c->get_pixels = ff_get_pixels_armv6; c->diff_pixels = ff_diff_pixels_armv6; c->pix_abs[0][0] = ff_pix_abs16_armv6; diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c index 691c060733..f88ae66b15 100644 --- a/libavcodec/bfin/dsputil_bfin.c +++ b/libavcodec/bfin/dsputil_bfin.c @@ -199,12 +199,12 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) { const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; - c->get_pixels = ff_bfin_get_pixels; c->diff_pixels = ff_bfin_diff_pixels; c->put_pixels_clamped = ff_bfin_put_pixels_clamped; c->add_pixels_clamped = ff_bfin_add_pixels_clamped; if (!high_bit_depth) + c->get_pixels = ff_bfin_get_pixels; c->clear_blocks = bfin_clear_blocks; c->pix_sum = ff_bfin_pix_sum; c->pix_norm1 = ff_bfin_pix_norm1; diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index b18164065d..09e58f46d2 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -307,25 +307,6 @@ static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) return s; } -static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size) -{ - int i; - - /* read the pixels */ - for(i=0;i<8;i++) { - block[0] = pixels[0]; - block[1] = pixels[1]; - block[2] = pixels[2]; - block[3] = pixels[3]; - block[4] = pixels[4]; - block[5] = pixels[5]; - block[6] = pixels[6]; - block[7] = pixels[7]; - pixels += line_size; - block += 8; - } -} - static void diff_pixels_c(DCTELEM *restrict block, const uint8_t *s1, const uint8_t *s2, int stride){ int i; @@ -2927,7 +2908,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) } } - c->get_pixels = get_pixels_c; c->diff_pixels = diff_pixels_c; c->put_pixels_clamped = ff_put_pixels_clamped_c; c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c; @@ -3160,6 +3140,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) #define BIT_DEPTH_FUNCS(depth, dct)\ + c->get_pixels = FUNCC(get_pixels ## dct , depth);\ c->draw_edges = FUNCC(draw_edges , depth);\ c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\ c->clear_block = FUNCC(clear_block ## dct , depth);\ diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index 5863275c00..72ed6bfd2a 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -193,6 +193,29 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, i } #define DCTELEM_FUNCS(dctcoef, suffix) \ +static void FUNCC(get_pixels ## suffix)(DCTELEM *restrict _block, \ + const uint8_t *_pixels, \ + int line_size) \ +{ \ + const pixel *pixels = (const pixel *) _pixels; \ + dctcoef *restrict block = (dctcoef *) _block; \ + int i; \ + \ + /* read the pixels */ \ + for(i=0;i<8;i++) { \ + block[0] = pixels[0]; \ + block[1] = pixels[1]; \ + block[2] = pixels[2]; \ + block[3] = pixels[3]; \ + block[4] = pixels[4]; \ + block[5] = pixels[5]; \ + block[6] = pixels[6]; \ + block[7] = pixels[7]; \ + pixels += line_size / sizeof(pixel); \ + block += 8; \ + } \ +} \ + \ static void FUNCC(add_pixels8 ## suffix)(uint8_t *restrict _pixels, \ DCTELEM *_block, \ int line_size) \ diff --git a/libavcodec/mlib/dsputil_mlib.c b/libavcodec/mlib/dsputil_mlib.c index c0f2c036c6..b915ffeb20 100644 --- a/libavcodec/mlib/dsputil_mlib.c +++ b/libavcodec/mlib/dsputil_mlib.c @@ -423,11 +423,12 @@ void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx) { const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; - c->get_pixels = get_pixels_mlib; c->diff_pixels = diff_pixels_mlib; c->add_pixels_clamped = add_pixels_clamped_mlib; if (!high_bit_depth) { + c->get_pixels = get_pixels_mlib; + c->put_pixels_tab[0][0] = put_pixels16_mlib; c->put_pixels_tab[0][1] = put_pixels16_x2_mlib; c->put_pixels_tab[0][2] = put_pixels16_y2_mlib; diff --git a/libavcodec/ppc/dsputil_altivec.c b/libavcodec/ppc/dsputil_altivec.c index 7bdd5705b9..f0526722d6 100644 --- a/libavcodec/ppc/dsputil_altivec.c +++ b/libavcodec/ppc/dsputil_altivec.c @@ -1387,11 +1387,10 @@ void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx) c->sse[0]= sse16_altivec; c->pix_sum = pix_sum_altivec; c->diff_pixels = diff_pixels_altivec; - c->get_pixels = get_pixels_altivec; - if (!high_bit_depth) - c->clear_block = clear_block_altivec; c->add_bytes= add_bytes_altivec; if (!high_bit_depth) { + c->get_pixels = get_pixels_altivec; + c->clear_block = clear_block_altivec; c->put_pixels_tab[0][0] = put_pixels16_altivec; /* the two functions do the same thing, so use the same code */ c->put_no_rnd_pixels_tab[0][0] = put_pixels16_altivec; diff --git a/libavcodec/ps2/dsputil_mmi.c b/libavcodec/ps2/dsputil_mmi.c index 585709679b..94a5a8cb48 100644 --- a/libavcodec/ps2/dsputil_mmi.c +++ b/libavcodec/ps2/dsputil_mmi.c @@ -152,9 +152,9 @@ void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx) c->put_pixels_tab[0][0] = put_pixels16_mmi; c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi; - } c->get_pixels = get_pixels_mmi; + } if (avctx->bits_per_raw_sample <= 8 && (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_PS2)) { diff --git a/libavcodec/x86/dsputilenc_mmx.c b/libavcodec/x86/dsputilenc_mmx.c index ea03e9232f..7362234c86 100644 --- a/libavcodec/x86/dsputilenc_mmx.c +++ b/libavcodec/x86/dsputilenc_mmx.c @@ -1098,6 +1098,7 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx) { int mm_flags = av_get_cpu_flags(); + int bit_depth = avctx->bits_per_raw_sample; if (mm_flags & AV_CPU_FLAG_MMX) { const int dct_algo = avctx->dct_algo; @@ -1112,7 +1113,8 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx) } } - c->get_pixels = get_pixels_mmx; + if (bit_depth <= 8) + c->get_pixels = get_pixels_mmx; c->diff_pixels = diff_pixels_mmx; c->pix_sum = pix_sum16_mmx; @@ -1159,7 +1161,8 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx) } if(mm_flags & AV_CPU_FLAG_SSE2){ - c->get_pixels = get_pixels_sse2; + if (bit_depth <= 8) + c->get_pixels = get_pixels_sse2; c->sum_abs_dctelem= sum_abs_dctelem_sse2; #if HAVE_YASM && HAVE_ALIGNED_STACK c->hadamard8_diff[0]= ff_hadamard8_diff16_sse2; From a617c6aaa3e6c0201c9ea31d319808273efd78b0 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 21 Jul 2011 10:05:15 +0100 Subject: [PATCH 642/780] dsputil: update per-arch init funcs for non-h264 high bit depth Signed-off-by: Mans Rullgard --- libavcodec/alpha/dsputil_alpha.c | 2 +- libavcodec/arm/dsputil_init_arm.c | 2 +- libavcodec/arm/dsputil_init_armv6.c | 2 +- libavcodec/arm/dsputil_init_neon.c | 2 +- libavcodec/arm/dsputil_iwmmxt.c | 2 +- libavcodec/bfin/dsputil_bfin.c | 2 +- libavcodec/mlib/dsputil_mlib.c | 2 +- libavcodec/ppc/dsputil_altivec.c | 2 +- libavcodec/ppc/dsputil_ppc.c | 2 +- libavcodec/ppc/h264_altivec.c | 2 +- libavcodec/ps2/dsputil_mmi.c | 2 +- libavcodec/sh4/dsputil_align.c | 2 +- libavcodec/sh4/dsputil_sh4.c | 2 +- libavcodec/sparc/dsputil_vis.c | 2 +- libavcodec/x86/dsputil_mmx.c | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c index 3efcf096b4..acd8e03f2b 100644 --- a/libavcodec/alpha/dsputil_alpha.c +++ b/libavcodec/alpha/dsputil_alpha.c @@ -270,7 +270,7 @@ static void put_pixels16_axp_asm(uint8_t *block, const uint8_t *pixels, void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx) { - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; if (!high_bit_depth) { c->put_pixels_tab[0][0] = put_pixels16_axp_asm; diff --git a/libavcodec/arm/dsputil_init_arm.c b/libavcodec/arm/dsputil_init_arm.c index 5b4b24a43e..743be1a239 100644 --- a/libavcodec/arm/dsputil_init_arm.c +++ b/libavcodec/arm/dsputil_init_arm.c @@ -75,7 +75,7 @@ static void simple_idct_arm_add(uint8_t *dest, int line_size, DCTELEM *block) void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) { - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; ff_put_pixels_clamped = c->put_pixels_clamped; ff_add_pixels_clamped = c->add_pixels_clamped; diff --git a/libavcodec/arm/dsputil_init_armv6.c b/libavcodec/arm/dsputil_init_armv6.c index 07124c2773..eff4ee38c2 100644 --- a/libavcodec/arm/dsputil_init_armv6.c +++ b/libavcodec/arm/dsputil_init_armv6.c @@ -72,7 +72,7 @@ int ff_pix_sum_armv6(uint8_t *pix, int line_size); void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx) { - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 && (avctx->idct_algo == FF_IDCT_AUTO || diff --git a/libavcodec/arm/dsputil_init_neon.c b/libavcodec/arm/dsputil_init_neon.c index ce45caf53e..238fdae41f 100644 --- a/libavcodec/arm/dsputil_init_neon.c +++ b/libavcodec/arm/dsputil_init_neon.c @@ -175,7 +175,7 @@ void ff_apply_window_int16_neon(int16_t *dst, const int16_t *src, void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) { - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; if (!avctx->lowres && avctx->bits_per_raw_sample <= 8) { if (avctx->idct_algo == FF_IDCT_AUTO || diff --git a/libavcodec/arm/dsputil_iwmmxt.c b/libavcodec/arm/dsputil_iwmmxt.c index 86f8fddfcf..dec5d77472 100644 --- a/libavcodec/arm/dsputil_iwmmxt.c +++ b/libavcodec/arm/dsputil_iwmmxt.c @@ -155,7 +155,7 @@ static void nop(uint8_t *block, const uint8_t *pixels, int line_size, int h) void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx) { int mm_flags = AV_CPU_FLAG_IWMMXT; /* multimedia extension flags */ - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; if (avctx->dsp_mask) { if (avctx->dsp_mask & AV_CPU_FLAG_FORCE) diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c index f88ae66b15..58ec394d7b 100644 --- a/libavcodec/bfin/dsputil_bfin.c +++ b/libavcodec/bfin/dsputil_bfin.c @@ -197,7 +197,7 @@ static int bfin_pix_abs8_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_si void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) { - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; c->diff_pixels = ff_bfin_diff_pixels; c->put_pixels_clamped = ff_bfin_put_pixels_clamped; diff --git a/libavcodec/mlib/dsputil_mlib.c b/libavcodec/mlib/dsputil_mlib.c index b915ffeb20..bfa5153def 100644 --- a/libavcodec/mlib/dsputil_mlib.c +++ b/libavcodec/mlib/dsputil_mlib.c @@ -421,7 +421,7 @@ static void ff_fdct_mlib(DCTELEM *data) void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx) { - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; c->diff_pixels = diff_pixels_mlib; c->add_pixels_clamped = add_pixels_clamped_mlib; diff --git a/libavcodec/ppc/dsputil_altivec.c b/libavcodec/ppc/dsputil_altivec.c index f0526722d6..7ab533600d 100644 --- a/libavcodec/ppc/dsputil_altivec.c +++ b/libavcodec/ppc/dsputil_altivec.c @@ -1373,7 +1373,7 @@ static void avg_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int l void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx) { - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; c->pix_abs[0][1] = sad16_x2_altivec; c->pix_abs[0][2] = sad16_y2_altivec; diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c index b6de39fae7..24b12ee2ae 100644 --- a/libavcodec/ppc/dsputil_ppc.c +++ b/libavcodec/ppc/dsputil_ppc.c @@ -145,7 +145,7 @@ static void prefetch_ppc(void *mem, int stride, int h) void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx) { - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; // Common optimizations whether AltiVec is available or not c->prefetch = prefetch_ppc; diff --git a/libavcodec/ppc/h264_altivec.c b/libavcodec/ppc/h264_altivec.c index 05fae831c9..8dd4ea392e 100644 --- a/libavcodec/ppc/h264_altivec.c +++ b/libavcodec/ppc/h264_altivec.c @@ -967,7 +967,7 @@ H264_WEIGHT( 8, 8) H264_WEIGHT( 8, 4) void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) { - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { if (!high_bit_depth) { diff --git a/libavcodec/ps2/dsputil_mmi.c b/libavcodec/ps2/dsputil_mmi.c index 94a5a8cb48..77755b0d4c 100644 --- a/libavcodec/ps2/dsputil_mmi.c +++ b/libavcodec/ps2/dsputil_mmi.c @@ -142,7 +142,7 @@ static void put_pixels16_mmi(uint8_t *block, const uint8_t *pixels, int line_siz void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx) { const int idct_algo= avctx->idct_algo; - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; if (!high_bit_depth) { c->clear_blocks = clear_blocks_mmi; diff --git a/libavcodec/sh4/dsputil_align.c b/libavcodec/sh4/dsputil_align.c index db40ece670..0c293a1248 100644 --- a/libavcodec/sh4/dsputil_align.c +++ b/libavcodec/sh4/dsputil_align.c @@ -333,7 +333,7 @@ DEFFUNC(avg,no_rnd,xy,16,OP_XY,PACK) void dsputil_init_align(DSPContext* c, AVCodecContext *avctx) { - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; if (!high_bit_depth) { c->put_pixels_tab[0][0] = put_rnd_pixels16_o; diff --git a/libavcodec/sh4/dsputil_sh4.c b/libavcodec/sh4/dsputil_sh4.c index bf58a9cbbd..51c1a53d7d 100644 --- a/libavcodec/sh4/dsputil_sh4.c +++ b/libavcodec/sh4/dsputil_sh4.c @@ -92,7 +92,7 @@ static void idct_add(uint8_t *dest, int line_size, DCTELEM *block) void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx) { const int idct_algo= avctx->idct_algo; - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; dsputil_init_align(c,avctx); if (!high_bit_depth) diff --git a/libavcodec/sparc/dsputil_vis.c b/libavcodec/sparc/dsputil_vis.c index 9811b2622e..e45bfd28e6 100644 --- a/libavcodec/sparc/dsputil_vis.c +++ b/libavcodec/sparc/dsputil_vis.c @@ -3953,7 +3953,7 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx) { /* VIS-specific optimizations */ int accel = vis_level (); - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; if (accel & ACCEL_SPARC_VIS) { if (avctx->bits_per_raw_sample <= 8 && diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 84ae47b04d..dd318a1399 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2437,7 +2437,7 @@ void ff_vector_clip_int32_sse41 (int32_t *dst, const int32_t *src, int32_t min void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) { int mm_flags = av_get_cpu_flags(); - const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + const int high_bit_depth = avctx->bits_per_raw_sample > 8; const int bit_depth = avctx->bits_per_raw_sample; if (avctx->dsp_mask) { From 5ab21439fdfb8e239eb778128590d95967067b46 Mon Sep 17 00:00:00 2001 From: Joseph Artsimovich Date: Wed, 20 Jul 2011 18:58:27 +0100 Subject: [PATCH 643/780] dnxhd: 10-bit support Signed-off-by: Mans Rullgard --- libavcodec/dnxhddata.c | 202 ++++++++++++++++++++++++++++++- libavcodec/dnxhddata.h | 2 +- libavcodec/dnxhddec.c | 57 +++++---- libavcodec/dnxhdenc.c | 240 ++++++++++++++++++++++++++++--------- libavcodec/dnxhdenc.h | 4 + libavcodec/x86/dnxhd_mmx.c | 3 +- 6 files changed, 427 insertions(+), 81 deletions(-) diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c index 677fb8f5be..576e85e05c 100644 --- a/libavcodec/dnxhddata.c +++ b/libavcodec/dnxhddata.c @@ -22,6 +22,28 @@ #include "avcodec.h" #include "dnxhddata.h" +static const uint8_t dnxhd_1235_luma_weight[] = { + 0, 32, 32, 32, 33, 35, 38, 39, + 32, 33, 32, 33, 36, 36, 39, 42, + 32, 32, 33, 36, 35, 37, 41, 43, + 31, 33, 34, 36, 36, 40, 42, 48, + 32, 34, 36, 37, 39, 42, 46, 51, + 36, 37, 37, 39, 41, 46, 51, 55, + 37, 39, 41, 41, 47, 50, 55, 56, + 41, 42, 41, 44, 50, 53, 60, 60 +}; + +static const uint8_t dnxhd_1235_chroma_weight[] = { + 0, 32, 33, 34, 39, 41, 54, 59, + 33, 34, 35, 38, 43, 49, 58, 84, + 34, 37, 39, 44, 46, 55, 74, 87, + 40, 42, 47, 48, 58, 70, 87, 86, + 43, 50, 56, 63, 72, 94, 91, 82, + 55, 63, 65, 75, 93, 89, 85, 73, + 61, 67, 82, 81, 83, 90, 79, 73, + 74, 84, 75, 78, 90, 85, 73, 73 +}; + static const uint8_t dnxhd_1237_luma_weight[] = { 0, 32, 33, 34, 34, 36, 37, 36, 36, 37, 38, 38, 38, 39, 41, 44, @@ -132,6 +154,28 @@ static const uint8_t dnxhd_1243_chroma_weight[] = { 46, 45, 46, 47, 47, 48, 47, 47, }; +static const uint8_t dnxhd_1250_luma_weight[] = { + 0, 32, 35, 35, 36, 36, 41, 43, + 32, 34, 35, 36, 37, 39, 43, 47, + 33, 34, 36, 38, 38, 42, 42, 50, + 34, 36, 38, 38, 41, 40, 47, 54, + 35, 38, 39, 40, 39, 45, 49, 58, + 38, 39, 40, 39, 46, 47, 54, 60, + 38, 39, 41, 46, 46, 48, 57, 62, + 40, 41, 44, 45, 49, 54, 63, 63 +}; + +static const uint8_t dnxhd_1250_chroma_weight[] = { + 0, 32, 35, 36, 40, 42, 51, 51, + 35, 36, 39, 39, 43, 51, 52, 55, + 36, 41, 41, 43, 51, 53, 54, 56, + 43, 44, 45, 50, 54, 54, 55, 57, + 45, 48, 50, 51, 55, 58, 59, 58, + 49, 52, 49, 57, 58, 62, 58, 60, + 51, 51, 56, 58, 62, 61, 59, 62, + 52, 52, 60, 61, 59, 59, 63, 63 +}; + static const uint8_t dnxhd_1251_luma_weight[] = { 0, 32, 32, 34, 34, 34, 34, 35, 35, 35, 36, 37, 36, 36, 35, 36, @@ -604,6 +648,146 @@ static const uint8_t dnxhd_1235_1241_run[62] = { 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, }; +static const uint8_t dnxhd_1250_dc_codes[14] = { + 10, 62, 11, 12, 13, 0, 1, 2, 3, 4, 14, 30, 126, 127 +}; +static const uint8_t dnxhd_1250_dc_bits[14] = { + 4, 6, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 7, 7 +}; +static const uint16_t dnxhd_1250_ac_codes[257] = { + 0, 1, 4, 10, 11, 24, 25, 26, + 54, 55, 56, 57, 116, 117, 118, 119, + 240, 241, 242, 243, 244, 245, 492, 493, + 494, 495, 496, 497, 498, 998, 999, 1000, + 1001, 1002, 1003, 1004, 1005, 1006, 2014, 2015, + 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, + 2024, 2025, 4052, 4053, 4054, 4055, 4056, 4057, + 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, + 4066, 4067, 8136, 8137, 8138, 8139, 8140, 8141, + 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, + 8150, 8151, 8152, 8153, 8154, 8155, 8156, 16314, + 16315, 16316, 16317, 16318, 16319, 16320, 16321, 16322, + 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, + 16331, 16332, 16333, 16334, 16335, 16336, 16337, 16338, + 32678, 32679, 32680, 32681, 32682, 32683, 32684, 32685, + 32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693, + 32694, 32695, 32696, 32697, 32698, 32699, 32700, 32701, + 32702, 32703, 32704, 32705, 32706, 32707, 32708, 32709, + 32710, 32711, 32712, 65426, 65427, 65428, 65429, 65430, + 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, + 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, + 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, + 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, + 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, + 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, + 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, + 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, + 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, + 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, + 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, + 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, + 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, + 65535 +}; +static const uint8_t dnxhd_1250_ac_bits[257] = { + 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16 +}; +static const uint8_t dnxhd_1250_ac_level[257] = { + 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, + 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 22, 6, 23, 24, 25, + 26, 27, 28, 29, 7, 8, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 9, 10, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 11, + 12, 13, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, + 3, 4, 5, 14, 15, 16, 17, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 18, 19, 20, 21, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 55, 56, 22, 23, 24, + 25, 26, 27, 54, 57, 58, 59, 60, 61, 62, 63, 64, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64 +}; +static const uint8_t dnxhd_1250_ac_run_flag[257] = { + 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1 +}; +static const uint8_t dnxhd_1250_ac_index_flag[257] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1 +}; +static const uint16_t dnxhd_1250_run_codes[62] = { + 0, 4, 5, 12, 26, 27, 28, 58, + 118, 119, 120, 242, 486, 487, 976, 977, + 978, 979, 980, 981, 982, 983, 984, 985, + 986, 987, 988, 989, 990, 991, 992, 993, + 994, 995, 996, 997, 998, 999, 1000, 1001, + 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, + 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, + 1018, 1019, 1020, 1021, 1022, 1023 +}; +static const uint8_t dnxhd_1250_run_bits[62] = { + 1, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7, 8, 9, 9, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 +}; +static const uint8_t dnxhd_1250_run[62] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62 +}; + static const uint8_t dnxhd_1251_dc_codes[12] = { 0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63, }; @@ -878,6 +1062,13 @@ static const uint8_t dnxhd_1252_ac_index_flag[257] = { }; const CIDEntry ff_dnxhd_cid_table[] = { + { 1235, 1920, 1080, 0, 917504, 917504, 6, 10, + dnxhd_1235_luma_weight, dnxhd_1235_chroma_weight, + dnxhd_1235_1241_dc_codes, dnxhd_1235_1241_dc_bits, + dnxhd_1235_1241_ac_codes, dnxhd_1235_1241_ac_bits, dnxhd_1235_1241_ac_level, + dnxhd_1235_1241_ac_run_flag, dnxhd_1235_1241_ac_index_flag, + dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1235_1241_run, + { 175, 185, 365, 440 } }, { 1237, 1920, 1080, 0, 606208, 606208, 4, 8, dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight, dnxhd_1237_dc_codes, dnxhd_1237_dc_bits, @@ -913,6 +1104,13 @@ const CIDEntry ff_dnxhd_cid_table[] = { dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag, dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1238_run, { 185, 220 } }, + { 1250, 1280, 720, 0, 458752, 458752, 6, 10, + dnxhd_1250_luma_weight, dnxhd_1250_chroma_weight, + dnxhd_1250_dc_codes, dnxhd_1250_dc_bits, + dnxhd_1250_ac_codes, dnxhd_1250_ac_bits, dnxhd_1250_ac_level, + dnxhd_1250_ac_run_flag, dnxhd_1250_ac_index_flag, + dnxhd_1250_run_codes, dnxhd_1250_run_bits, dnxhd_1250_run, + { 90, 180, 220 } }, { 1251, 1280, 720, 0, 458752, 458752, 4, 8, dnxhd_1251_luma_weight, dnxhd_1251_chroma_weight, dnxhd_1251_dc_codes, dnxhd_1251_dc_bits, @@ -945,7 +1143,7 @@ int ff_dnxhd_get_cid_table(int cid) return -1; } -int ff_dnxhd_find_cid(AVCodecContext *avctx) +int ff_dnxhd_find_cid(AVCodecContext *avctx, int bit_depth) { int i, j; int mbs = avctx->bit_rate/1000000; @@ -955,7 +1153,7 @@ int ff_dnxhd_find_cid(AVCodecContext *avctx) const CIDEntry *cid = &ff_dnxhd_cid_table[i]; if (cid->width == avctx->width && cid->height == avctx->height && cid->interlaced == !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT) && - cid->bit_depth == 8) { // until 10 bit is supported + cid->bit_depth == bit_depth) { for (j = 0; j < sizeof(cid->bit_rates); j++) { if (cid->bit_rates[j] == mbs) return cid->cid; diff --git a/libavcodec/dnxhddata.h b/libavcodec/dnxhddata.h index df841872fc..74cf0b522f 100644 --- a/libavcodec/dnxhddata.h +++ b/libavcodec/dnxhddata.h @@ -46,6 +46,6 @@ typedef struct { extern const CIDEntry ff_dnxhd_cid_table[]; int ff_dnxhd_get_cid_table(int cid); -int ff_dnxhd_find_cid(AVCodecContext *avctx); +int ff_dnxhd_find_cid(AVCodecContext *avctx, int bit_depth); #endif /* AVCODEC_DNXHDDATA_H */ diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 6928b32263..7b32cd3ed4 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -1,6 +1,9 @@ /* * VC3/DNxHD decoder. * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier + * Copyright (c) 2011 MirriAd Ltd + * + * 10 bit support added by MirriAd Ltd, Joseph Artsimovich * * This file is part of Libav. * @@ -43,6 +46,7 @@ typedef struct { DECLARE_ALIGNED(16, DCTELEM, blocks)[8][64]; ScanTable scantable; const CIDEntry *cid_table; + int bit_depth; // 8, 10 or 0 if not initialized at all. } DNXHDContext; #define DNXHD_VLC_BITS 9 @@ -53,7 +57,6 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx) DNXHDContext *ctx = avctx->priv_data; ctx->avctx = avctx; - dsputil_init(&ctx->dsp, avctx); avctx->coded_frame = &ctx->picture; ctx->picture.type = AV_PICTURE_TYPE_I; ctx->picture.key_frame = 1; @@ -73,7 +76,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid) init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257, ctx->cid_table->ac_bits, 1, 1, ctx->cid_table->ac_codes, 2, 2, 0); - init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, ctx->cid_table->bit_depth+4, + init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, ctx->bit_depth + 4, ctx->cid_table->dc_bits, 1, 1, ctx->cid_table->dc_codes, 1, 1, 0); init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62, @@ -110,8 +113,19 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si av_dlog(ctx->avctx, "width %d, heigth %d\n", ctx->width, ctx->height); if (buf[0x21] & 0x40) { - av_log(ctx->avctx, AV_LOG_ERROR, "10 bit per component\n"); - return -1; + ctx->avctx->pix_fmt = PIX_FMT_YUV422P10; + ctx->avctx->bits_per_raw_sample = 10; + if (ctx->bit_depth != 10) { + dsputil_init(&ctx->dsp, ctx->avctx); + ctx->bit_depth = 10; + } + } else { + ctx->avctx->pix_fmt = PIX_FMT_YUV422P; + ctx->avctx->bits_per_raw_sample = 8; + if (ctx->bit_depth != 8) { + dsputil_init(&ctx->dsp, ctx->avctx); + ctx->bit_depth = 8; + } } ctx->cid = AV_RB32(buf + 0x28); @@ -204,7 +218,7 @@ static void dnxhd_decode_dct_block(DNXHDContext *ctx, DCTELEM *block, int n, int //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j); //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weigth %d\n", level, weigth_matrix[i]); level = (2*level+1) * qscale * weigth_matrix[i]; - if (ctx->cid_table->bit_depth == 10) { + if (ctx->bit_depth == 10) { if (weigth_matrix[i] != 8) level += 8; level >>= 4; @@ -220,10 +234,11 @@ static void dnxhd_decode_dct_block(DNXHDContext *ctx, DCTELEM *block, int n, int static int dnxhd_decode_macroblock(DNXHDContext *ctx, int x, int y) { + int shift1 = ctx->bit_depth == 10; int dct_linesize_luma = ctx->picture.linesize[0]; int dct_linesize_chroma = ctx->picture.linesize[1]; uint8_t *dest_y, *dest_u, *dest_v; - int dct_offset; + int dct_y_offset, dct_x_offset; int qscale, i; qscale = get_bits(&ctx->gb, 11); @@ -240,9 +255,9 @@ static int dnxhd_decode_macroblock(DNXHDContext *ctx, int x, int y) dct_linesize_chroma <<= 1; } - dest_y = ctx->picture.data[0] + ((y * dct_linesize_luma) << 4) + (x << 4); - dest_u = ctx->picture.data[1] + ((y * dct_linesize_chroma) << 4) + (x << 3); - dest_v = ctx->picture.data[2] + ((y * dct_linesize_chroma) << 4) + (x << 3); + dest_y = ctx->picture.data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 + shift1)); + dest_u = ctx->picture.data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1)); + dest_v = ctx->picture.data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1)); if (ctx->cur_field) { dest_y += ctx->picture.linesize[0]; @@ -250,18 +265,19 @@ static int dnxhd_decode_macroblock(DNXHDContext *ctx, int x, int y) dest_v += ctx->picture.linesize[2]; } - dct_offset = dct_linesize_luma << 3; - ctx->dsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]); - ctx->dsp.idct_put(dest_y + 8, dct_linesize_luma, ctx->blocks[1]); - ctx->dsp.idct_put(dest_y + dct_offset, dct_linesize_luma, ctx->blocks[4]); - ctx->dsp.idct_put(dest_y + dct_offset + 8, dct_linesize_luma, ctx->blocks[5]); + dct_y_offset = dct_linesize_luma << 3; + dct_x_offset = 8 << shift1; + ctx->dsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]); + ctx->dsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]); + ctx->dsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[4]); + ctx->dsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[5]); if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) { - dct_offset = dct_linesize_chroma << 3; - ctx->dsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]); - ctx->dsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]); - ctx->dsp.idct_put(dest_u + dct_offset, dct_linesize_chroma, ctx->blocks[6]); - ctx->dsp.idct_put(dest_v + dct_offset, dct_linesize_chroma, ctx->blocks[7]); + dct_y_offset = dct_linesize_chroma << 3; + ctx->dsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]); + ctx->dsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]); + ctx->dsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[6]); + ctx->dsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[7]); } return 0; @@ -273,7 +289,7 @@ static int dnxhd_decode_macroblocks(DNXHDContext *ctx, const uint8_t *buf, int b for (y = 0; y < ctx->mb_height; y++) { ctx->last_dc[0] = ctx->last_dc[1] = - ctx->last_dc[2] = 1<<(ctx->cid_table->bit_depth+2); // for levels +2^(bitdepth-1) + ctx->last_dc[2] = 1 << (ctx->bit_depth + 2); // for levels +2^(bitdepth-1) init_get_bits(&ctx->gb, buf + ctx->mb_scan_index[y], (buf_size - ctx->mb_scan_index[y]) << 3); for (x = 0; x < ctx->mb_width; x++) { //START_TIMER; @@ -306,7 +322,6 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size, first_field = 1; } - avctx->pix_fmt = PIX_FMT_YUV422P; if (av_image_check_size(ctx->width, ctx->height, 0, avctx)) return -1; avcodec_set_dimensions(avctx, ctx->width, ctx->height); diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index b65d0bf669..3fb10d4380 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -1,8 +1,10 @@ /* * VC3/DNxHD encoder * Copyright (c) 2007 Baptiste Coudurier + * Copyright (c) 2011 MirriAd Ltd * * VC-3 encoder funded by the British Broadcasting Corporation + * 10 bit support added by MirriAd Ltd, Joseph Artsimovich * * This file is part of Libav. * @@ -32,6 +34,7 @@ #include "dnxhdenc.h" #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +#define DNX10BIT_QMAT_SHIFT 18 // The largest value that will not lead to overflow for 10bit samples. static const AVOption options[]={ {"nitris_compat", "encode with Avid Nitris compatibility", offsetof(DNXHDEncContext, nitris_compat), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, VE}, @@ -41,7 +44,7 @@ static const AVClass class = { "dnxhd", av_default_item_name, options, LIBAVUTIL #define LAMBDA_FRAC_BITS 10 -static void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, int line_size) +static void dnxhd_8bit_get_pixels_8x4_sym(DCTELEM *restrict block, const uint8_t *pixels, int line_size) { int i; for (i = 0; i < 4; i++) { @@ -58,6 +61,43 @@ static void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, memcpy(block + 24, block - 32, sizeof(*block) * 8); } +static av_always_inline void dnxhd_10bit_get_pixels_8x4_sym(DCTELEM *restrict block, const uint8_t *pixels, int line_size) +{ + int i; + + block += 32; + + for (i = 0; i < 4; i++) { + memcpy(block + i * 8, pixels + i * line_size, 8 * sizeof(*block)); + memcpy(block - (i+1) * 8, pixels + i * line_size, 8 * sizeof(*block)); + } +} + +static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, DCTELEM *block, + int n, int qscale, int *overflow) +{ + const uint8_t *scantable= ctx->intra_scantable.scantable; + const int *qmat = ctx->q_intra_matrix[qscale]; + int last_non_zero = 0; + + ctx->dsp.fdct(block); + + // Divide by 4 with rounding, to compensate scaling of DCT coefficients + block[0] = (block[0] + 2) >> 2; + + for (int i = 1; i < 64; ++i) { + int j = scantable[i]; + int sign = block[j] >> 31; + int level = (block[j] ^ sign) - sign; + level = level * qmat[j] >> DNX10BIT_QMAT_SHIFT; + block[j] = (level ^ sign) - sign; + if (level) + last_non_zero = i; + } + + return last_non_zero; +} + static int dnxhd_init_vlc(DNXHDEncContext *ctx) { int i, j, level, run; @@ -118,31 +158,55 @@ static int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias) // init first elem to 1 to avoid div by 0 in convert_matrix uint16_t weight_matrix[64] = {1,}; // convert_matrix needs uint16_t* int qscale, i; + const uint8_t *luma_weight_table = ctx->cid_table->luma_weight; + const uint8_t *chroma_weight_table = ctx->cid_table->chroma_weight; FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l, (ctx->m.avctx->qmax+1) * 64 * sizeof(int), fail); FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c, (ctx->m.avctx->qmax+1) * 64 * sizeof(int), fail); FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t), fail); FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t), fail); - for (i = 1; i < 64; i++) { - int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]]; - weight_matrix[j] = ctx->cid_table->luma_weight[i]; - } - ff_convert_matrix(&ctx->m.dsp, ctx->qmatrix_l, ctx->qmatrix_l16, weight_matrix, - ctx->m.intra_quant_bias, 1, ctx->m.avctx->qmax, 1); - for (i = 1; i < 64; i++) { - int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]]; - weight_matrix[j] = ctx->cid_table->chroma_weight[i]; - } - ff_convert_matrix(&ctx->m.dsp, ctx->qmatrix_c, ctx->qmatrix_c16, weight_matrix, - ctx->m.intra_quant_bias, 1, ctx->m.avctx->qmax, 1); - for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) { - for (i = 0; i < 64; i++) { - ctx->qmatrix_l [qscale] [i] <<= 2; ctx->qmatrix_c [qscale] [i] <<= 2; - ctx->qmatrix_l16[qscale][0][i] <<= 2; ctx->qmatrix_l16[qscale][1][i] <<= 2; - ctx->qmatrix_c16[qscale][0][i] <<= 2; ctx->qmatrix_c16[qscale][1][i] <<= 2; + if (ctx->cid_table->bit_depth == 8) { + for (i = 1; i < 64; i++) { + int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]]; + weight_matrix[j] = ctx->cid_table->luma_weight[i]; + } + ff_convert_matrix(&ctx->m.dsp, ctx->qmatrix_l, ctx->qmatrix_l16, weight_matrix, + ctx->m.intra_quant_bias, 1, ctx->m.avctx->qmax, 1); + for (i = 1; i < 64; i++) { + int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]]; + weight_matrix[j] = ctx->cid_table->chroma_weight[i]; + } + ff_convert_matrix(&ctx->m.dsp, ctx->qmatrix_c, ctx->qmatrix_c16, weight_matrix, + ctx->m.intra_quant_bias, 1, ctx->m.avctx->qmax, 1); + + for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) { + for (i = 0; i < 64; i++) { + ctx->qmatrix_l [qscale] [i] <<= 2; ctx->qmatrix_c [qscale] [i] <<= 2; + ctx->qmatrix_l16[qscale][0][i] <<= 2; ctx->qmatrix_l16[qscale][1][i] <<= 2; + ctx->qmatrix_c16[qscale][0][i] <<= 2; ctx->qmatrix_c16[qscale][1][i] <<= 2; + } + } + } else { + // 10-bit + for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) { + for (i = 1; i < 64; i++) { + int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]]; + + // The quantization formula from the VC-3 standard is: + // quantized = sign(block[i]) * floor(abs(block[i]/s) * p / (qscale * weight_table[i])) + // Where p is 32 for 8-bit samples and 8 for 10-bit ones. + // The s factor compensates scaling of DCT coefficients done by the DCT routines, + // and therefore is not present in standard. It's 8 for 8-bit samples and 4 for 10-bit ones. + // We want values of ctx->qtmatrix_l and ctx->qtmatrix_r to be: + // ((1 << DNX10BIT_QMAT_SHIFT) * (p / s)) / (qscale * weight_table[i]) + // For 10-bit samples, p / s == 2 + ctx->qmatrix_l[qscale][j] = (1 << (DNX10BIT_QMAT_SHIFT + 1)) / (qscale * luma_weight_table[i]); + ctx->qmatrix_c[qscale][j] = (1 << (DNX10BIT_QMAT_SHIFT + 1)) / (qscale * chroma_weight_table[i]); + } } } + return 0; fail: return -1; @@ -165,10 +229,22 @@ static int dnxhd_init_rc(DNXHDEncContext *ctx) static int dnxhd_encode_init(AVCodecContext *avctx) { DNXHDEncContext *ctx = avctx->priv_data; - int i, index; + int i, index, bit_depth; - ctx->cid = ff_dnxhd_find_cid(avctx); - if (!ctx->cid || avctx->pix_fmt != PIX_FMT_YUV422P) { + switch (avctx->pix_fmt) { + case PIX_FMT_YUV422P: + bit_depth = 8; + break; + case PIX_FMT_YUV422P10: + bit_depth = 10; + break; + default: + av_log(avctx, AV_LOG_ERROR, "pixel format is incompatible with DNxHD\n"); + return -1; + } + + ctx->cid = ff_dnxhd_find_cid(avctx, bit_depth); + if (!ctx->cid) { av_log(avctx, AV_LOG_ERROR, "video parameters incompatible with DNxHD\n"); return -1; } @@ -181,15 +257,25 @@ static int dnxhd_encode_init(AVCodecContext *avctx) ctx->m.mb_intra = 1; ctx->m.h263_aic = 1; - ctx->get_pixels_8x4_sym = dnxhd_get_pixels_8x4; + avctx->bits_per_raw_sample = ctx->cid_table->bit_depth; dsputil_init(&ctx->m.dsp, avctx); ff_dct_common_init(&ctx->m); + if (!ctx->m.dct_quantize) + ctx->m.dct_quantize = dct_quantize_c; + + if (ctx->cid_table->bit_depth == 10) { + ctx->m.dct_quantize = dnxhd_10bit_dct_quantize; + ctx->get_pixels_8x4_sym = dnxhd_10bit_get_pixels_8x4_sym; + ctx->block_width_l2 = 4; + } else { + ctx->get_pixels_8x4_sym = dnxhd_8bit_get_pixels_8x4_sym; + ctx->block_width_l2 = 3; + } + #if HAVE_MMX ff_dnxhd_init_mmx(ctx); #endif - if (!ctx->m.dct_quantize) - ctx->m.dct_quantize = dct_quantize_c; ctx->m.mb_height = (avctx->height + 15) / 16; ctx->m.mb_width = (avctx->width + 15) / 16; @@ -255,7 +341,7 @@ static int dnxhd_write_header(AVCodecContext *avctx, uint8_t *buf) AV_WB16(buf + 0x1a, avctx->width); // SPL AV_WB16(buf + 0x1d, avctx->height>>ctx->interlaced); // NAL - buf[0x21] = 0x38; // FIXME 8 bit per comp + buf[0x21] = ctx->cid_table->bit_depth == 10 ? 0x58 : 0x38; buf[0x22] = 0x88 + (ctx->interlaced<<2); AV_WB32(buf + 0x28, ctx->cid); // CID buf[0x2c] = ctx->interlaced ? 0 : 0x80; @@ -321,15 +407,27 @@ static av_always_inline void dnxhd_unquantize_c(DNXHDEncContext *ctx, DCTELEM *b if (level) { if (level < 0) { level = (1-2*level) * qscale * weight_matrix[i]; - if (weight_matrix[i] != 32) - level += 32; - level >>= 6; + if (ctx->cid_table->bit_depth == 10) { + if (weight_matrix[i] != 8) + level += 8; + level >>= 4; + } else { + if (weight_matrix[i] != 32) + level += 32; + level >>= 6; + } level = -level; } else { level = (2*level+1) * qscale * weight_matrix[i]; - if (weight_matrix[i] != 32) - level += 32; - level >>= 6; + if (ctx->cid_table->bit_depth == 10) { + if (weight_matrix[i] != 8) + level += 8; + level >>= 4; + } else { + if (weight_matrix[i] != 32) + level += 32; + level >>= 6; + } } block[j] = level; } @@ -364,22 +462,24 @@ static av_always_inline int dnxhd_calc_ac_bits(DNXHDEncContext *ctx, DCTELEM *bl static av_always_inline void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y) { - const uint8_t *ptr_y = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize) + (mb_x << 4); - const uint8_t *ptr_u = ctx->thread[0]->src[1] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << 3); - const uint8_t *ptr_v = ctx->thread[0]->src[2] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << 3); + const int bs = ctx->block_width_l2; + const int bw = 1 << bs; + const uint8_t *ptr_y = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize) + (mb_x << bs+1); + const uint8_t *ptr_u = ctx->thread[0]->src[1] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs); + const uint8_t *ptr_v = ctx->thread[0]->src[2] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs); DSPContext *dsp = &ctx->m.dsp; - dsp->get_pixels(ctx->blocks[0], ptr_y, ctx->m.linesize); - dsp->get_pixels(ctx->blocks[1], ptr_y + 8, ctx->m.linesize); - dsp->get_pixels(ctx->blocks[2], ptr_u, ctx->m.uvlinesize); - dsp->get_pixels(ctx->blocks[3], ptr_v, ctx->m.uvlinesize); + dsp->get_pixels(ctx->blocks[0], ptr_y, ctx->m.linesize); + dsp->get_pixels(ctx->blocks[1], ptr_y + bw, ctx->m.linesize); + dsp->get_pixels(ctx->blocks[2], ptr_u, ctx->m.uvlinesize); + dsp->get_pixels(ctx->blocks[3], ptr_v, ctx->m.uvlinesize); if (mb_y+1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) { if (ctx->interlaced) { - ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + ctx->dct_y_offset, ctx->m.linesize); - ctx->get_pixels_8x4_sym(ctx->blocks[5], ptr_y + ctx->dct_y_offset + 8, ctx->m.linesize); - ctx->get_pixels_8x4_sym(ctx->blocks[6], ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize); - ctx->get_pixels_8x4_sym(ctx->blocks[7], ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize); + ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + ctx->dct_y_offset, ctx->m.linesize); + ctx->get_pixels_8x4_sym(ctx->blocks[5], ptr_y + ctx->dct_y_offset + bw, ctx->m.linesize); + ctx->get_pixels_8x4_sym(ctx->blocks[6], ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize); + ctx->get_pixels_8x4_sym(ctx->blocks[7], ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize); } else { dsp->clear_block(ctx->blocks[4]); dsp->clear_block(ctx->blocks[5]); @@ -387,10 +487,10 @@ static av_always_inline void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, in dsp->clear_block(ctx->blocks[7]); } } else { - dsp->get_pixels(ctx->blocks[4], ptr_y + ctx->dct_y_offset, ctx->m.linesize); - dsp->get_pixels(ctx->blocks[5], ptr_y + ctx->dct_y_offset + 8, ctx->m.linesize); - dsp->get_pixels(ctx->blocks[6], ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize); - dsp->get_pixels(ctx->blocks[7], ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize); + dsp->get_pixels(ctx->blocks[4], ptr_y + ctx->dct_y_offset, ctx->m.linesize); + dsp->get_pixels(ctx->blocks[5], ptr_y + ctx->dct_y_offset + bw, ctx->m.linesize); + dsp->get_pixels(ctx->blocks[6], ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize); + dsp->get_pixels(ctx->blocks[7], ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize); } } @@ -417,7 +517,7 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, int jobnr, i ctx->m.last_dc[0] = ctx->m.last_dc[1] = - ctx->m.last_dc[2] = 1024; + ctx->m.last_dc[2] = 1 << (ctx->cid_table->bit_depth + 2); for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) { unsigned mb = mb_y * ctx->m.mb_width + mb_x; @@ -440,6 +540,8 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, int jobnr, i diff = block[0] - ctx->m.last_dc[n]; if (diff < 0) nbits = av_log2_16bit(-2*diff); else nbits = av_log2_16bit( 2*diff); + + assert(nbits < ctx->cid_table->bit_depth + 4); dc_bits += ctx->cid_table->dc_bits[nbits] + nbits; ctx->m.last_dc[n] = block[0]; @@ -465,7 +567,7 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg, int jobnr, int ctx->m.last_dc[0] = ctx->m.last_dc[1] = - ctx->m.last_dc[2] = 1024; + ctx->m.last_dc[2] = 1 << (ctx->cid_table->bit_depth + 2); for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) { unsigned mb = mb_y * ctx->m.mb_width + mb_x; int qscale = ctx->mb_qscale[mb]; @@ -515,13 +617,39 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int jobnr, int DNXHDEncContext *ctx = avctx->priv_data; int mb_y = jobnr, mb_x; ctx = ctx->thread[threadnr]; - for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) { - unsigned mb = mb_y * ctx->m.mb_width + mb_x; - uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y<<4) * ctx->m.linesize) + (mb_x<<4); - int sum = ctx->m.dsp.pix_sum(pix, ctx->m.linesize); - int varc = (ctx->m.dsp.pix_norm1(pix, ctx->m.linesize) - (((unsigned)(sum*sum))>>8)+128)>>8; - ctx->mb_cmp[mb].value = varc; - ctx->mb_cmp[mb].mb = mb; + if (ctx->cid_table->bit_depth == 8) { + uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y<<4) * ctx->m.linesize); + for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) { + unsigned mb = mb_y * ctx->m.mb_width + mb_x; + int sum = ctx->m.dsp.pix_sum(pix, ctx->m.linesize); + int varc = (ctx->m.dsp.pix_norm1(pix, ctx->m.linesize) - (((unsigned)(sum*sum))>>8)+128)>>8; + ctx->mb_cmp[mb].value = varc; + ctx->mb_cmp[mb].mb = mb; + } + } else { // 10-bit + int const linesize = ctx->m.linesize >> 1; + for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x) { + uint16_t *pix = (uint16_t*)ctx->thread[0]->src[0] + ((mb_y << 4) * linesize) + (mb_x << 4); + unsigned mb = mb_y * ctx->m.mb_width + mb_x; + int sum = 0; + int sqsum = 0; + int mean, sqmean; + // Macroblocks are 16x16 pixels, unlike DCT blocks which are 8x8. + for (int i = 0; i < 16; ++i) { + for (int j = 0; j < 16; ++j) { + // Turn 16-bit pixels into 10-bit ones. + int const sample = (unsigned)pix[j] >> 6; + sum += sample; + sqsum += sample * sample; + // 2^10 * 2^10 * 16 * 16 = 2^28, which is less than INT_MAX + } + pix += linesize; + } + mean = sum >> 8; // 16*16 == 2^8 + sqmean = sqsum >> 8; + ctx->mb_cmp[mb].value = sqmean - mean * mean; + ctx->mb_cmp[mb].mb = mb; + } } return 0; } @@ -871,7 +999,7 @@ AVCodec ff_dnxhd_encoder = { dnxhd_encode_picture, dnxhd_encode_end, .capabilities = CODEC_CAP_SLICE_THREADS, - .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_NONE}, + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_YUV422P10, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), .priv_class = &class, }; diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index bb24540a9f..861546a54c 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -52,8 +52,12 @@ typedef struct DNXHDEncContext { struct DNXHDEncContext *thread[MAX_THREADS]; + // Because our samples are either 8 or 16 bits for 8-bit and 10-bit + // encoding respectively, these refer either to bytes or to two-byte words. unsigned dct_y_offset; unsigned dct_uv_offset; + unsigned block_width_l2; + int interlaced; int cur_field; diff --git a/libavcodec/x86/dnxhd_mmx.c b/libavcodec/x86/dnxhd_mmx.c index f00ce9b188..e193d62e21 100644 --- a/libavcodec/x86/dnxhd_mmx.c +++ b/libavcodec/x86/dnxhd_mmx.c @@ -53,6 +53,7 @@ static void get_pixels_8x4_sym_sse2(DCTELEM *block, const uint8_t *pixels, int l void ff_dnxhd_init_mmx(DNXHDEncContext *ctx) { if (av_get_cpu_flags() & AV_CPU_FLAG_SSE2) { - ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2; + if (ctx->cid_table->bit_depth == 8) + ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2; } } From 4555874af19acd0cbd6e856e032468ff52ceaa63 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 21 Jul 2011 00:55:24 +0100 Subject: [PATCH 644/780] dnxhd: add regression test for 10-bit Signed-off-by: Mans Rullgard --- tests/codec-regression.sh | 5 +++++ tests/ref/vsynth1/dnxhd_720p_10bit | 4 ++++ tests/ref/vsynth2/dnxhd_720p_10bit | 4 ++++ 3 files changed, 13 insertions(+) create mode 100644 tests/ref/vsynth1/dnxhd_720p_10bit create mode 100644 tests/ref/vsynth2/dnxhd_720p_10bit diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh index ccedbdbfef..a420c573c9 100755 --- a/tests/codec-regression.sh +++ b/tests/codec-regression.sh @@ -230,6 +230,11 @@ do_video_encoding dnxhd-720p-rd.dnxhd "-threads 4 -mbd rd -s hd720 -b 90M -pix_f do_video_decoding "" "-s cif -pix_fmt yuv420p" fi +if [ -n "$do_dnxhd_720p_10bit" ] ; then +do_video_encoding dnxhd-720p-10bit.dnxhd "-s hd720 -b 90M -pix_fmt yuv422p10 -vframes 5 -an" +do_video_decoding "" "-s cif -pix_fmt yuv420p" +fi + if [ -n "$do_svq1" ] ; then do_video_encoding svq1.mov "-an -vcodec svq1 -qscale 3 -pix_fmt yuv410p" do_video_decoding "" "-pix_fmt yuv420p" diff --git a/tests/ref/vsynth1/dnxhd_720p_10bit b/tests/ref/vsynth1/dnxhd_720p_10bit new file mode 100644 index 0000000000..4a815a973c --- /dev/null +++ b/tests/ref/vsynth1/dnxhd_720p_10bit @@ -0,0 +1,4 @@ +3ed972af47641d39a19916b0cd119120 *./tests/data/vsynth1/dnxhd-720p-10bit.dnxhd +2293760 ./tests/data/vsynth1/dnxhd-720p-10bit.dnxhd +b64efb0b4eb934bb66f4530c12d5d7fa *./tests/data/dnxhd_720p_10bit.vsynth1.out.yuv +stddev: 6.27 PSNR: 32.18 MAXDIFF: 65 bytes: 760320/ 7603200 diff --git a/tests/ref/vsynth2/dnxhd_720p_10bit b/tests/ref/vsynth2/dnxhd_720p_10bit new file mode 100644 index 0000000000..734df4ffe2 --- /dev/null +++ b/tests/ref/vsynth2/dnxhd_720p_10bit @@ -0,0 +1,4 @@ +0b8389955cce583bd2db7d2e727a6f15 *./tests/data/vsynth2/dnxhd-720p-10bit.dnxhd +2293760 ./tests/data/vsynth2/dnxhd-720p-10bit.dnxhd +bde04e992df2473e89aef4460265332d *./tests/data/dnxhd_720p_10bit.vsynth2.out.yuv +stddev: 1.45 PSNR: 44.89 MAXDIFF: 22 bytes: 760320/ 7603200 From be7bd626c4832c4bc5295a01bfd68156ac78ccba Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Thu, 14 Jul 2011 13:02:45 -0400 Subject: [PATCH 645/780] eac3enc: use different numbers of blocks per frame to allow higher bitrates --- libavcodec/ac3enc.c | 179 ++++++++++++++++++++--------------- libavcodec/ac3enc.h | 2 + libavcodec/ac3enc_fixed.c | 2 +- libavcodec/ac3enc_float.c | 2 +- libavcodec/ac3enc_template.c | 24 ++--- libavcodec/eac3enc.c | 30 ++++-- 6 files changed, 142 insertions(+), 97 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index e7a5b1611e..017b1d4b93 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -186,7 +186,7 @@ void ff_ac3_adjust_frame_size(AC3EncodeContext *s) s->frame_size = s->frame_size_min + 2 * (s->bits_written * s->sample_rate < s->samples_written * s->bit_rate); s->bits_written += s->frame_size * 8; - s->samples_written += AC3_FRAME_SIZE; + s->samples_written += AC3_BLOCK_SIZE * s->num_blocks; } @@ -198,7 +198,7 @@ void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) /* set coupling use flags for each block/channel */ /* TODO: turn coupling on/off and adjust start band based on bit usage */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; for (ch = 1; ch <= s->fbw_channels; ch++) block->channel_in_cpl[ch] = s->cpl_on; @@ -208,7 +208,7 @@ void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) enabled for that block */ got_cpl_snr = 0; num_cpl_blocks = 0; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; block->num_cpl_channels = 0; for (ch = 1; ch <= s->fbw_channels; ch++) @@ -244,7 +244,7 @@ void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) s->cpl_on = 0; /* set bandwidth for each channel */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; for (ch = 1; ch <= s->fbw_channels; ch++) { if (block->channel_in_cpl[ch]) @@ -269,7 +269,7 @@ void ff_ac3_apply_rematrixing(AC3EncodeContext *s) if (!s->rematrixing_enabled) return; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; if (block->new_rematrixing_strategy) flags = block->rematrixing_flags; @@ -318,7 +318,7 @@ static av_cold void exponent_init(AC3EncodeContext *s) static void extract_exponents(AC3EncodeContext *s) { int ch = !s->cpl_on; - int chan_size = AC3_MAX_COEFS * AC3_MAX_BLOCKS * (s->channels - ch + 1); + int chan_size = AC3_MAX_COEFS * s->num_blocks * (s->channels - ch + 1); AC3Block *block = &s->blocks[0]; s->ac3dsp.extract_exponents(block->exp[ch], block->fixed_coef[ch], chan_size); @@ -331,6 +331,15 @@ static void extract_exponents(AC3EncodeContext *s) */ #define EXP_DIFF_THRESHOLD 500 +/** + * Table used to select exponent strategy based on exponent reuse block interval. + */ +static const uint8_t exp_strategy_reuse_tab[4][6] = { + { EXP_D15, EXP_D15, EXP_D15, EXP_D15, EXP_D15, EXP_D15 }, + { EXP_D15, EXP_D15, EXP_D15, EXP_D15, EXP_D15, EXP_D15 }, + { EXP_D25, EXP_D25, EXP_D15, EXP_D15, EXP_D15, EXP_D15 }, + { EXP_D45, EXP_D25, EXP_D25, EXP_D15, EXP_D15, EXP_D15 } +}; /** * Calculate exponent strategies for all channels. @@ -349,7 +358,7 @@ static void compute_exp_strategy(AC3EncodeContext *s) reused in the next frame */ exp_strategy[0] = EXP_NEW; exp += AC3_MAX_COEFS; - for (blk = 1; blk < AC3_MAX_BLOCKS; blk++, exp += AC3_MAX_COEFS) { + for (blk = 1; blk < s->num_blocks; blk++, exp += AC3_MAX_COEFS) { if (ch == CPL_CH) { if (!s->blocks[blk-1].cpl_in_use) { exp_strategy[blk] = EXP_NEW; @@ -373,23 +382,18 @@ static void compute_exp_strategy(AC3EncodeContext *s) /* now select the encoding strategy type : if exponents are often recoded, we use a coarse encoding */ blk = 0; - while (blk < AC3_MAX_BLOCKS) { + while (blk < s->num_blocks) { blk1 = blk + 1; - while (blk1 < AC3_MAX_BLOCKS && exp_strategy[blk1] == EXP_REUSE) + while (blk1 < s->num_blocks && exp_strategy[blk1] == EXP_REUSE) blk1++; - switch (blk1 - blk) { - case 1: exp_strategy[blk] = EXP_D45; break; - case 2: - case 3: exp_strategy[blk] = EXP_D25; break; - default: exp_strategy[blk] = EXP_D15; break; - } + exp_strategy[blk] = exp_strategy_reuse_tab[s->num_blks_code][blk1-blk-1]; blk = blk1; } } if (s->lfe_on) { ch = s->lfe_channel; s->exp_strategy[ch][0] = EXP_D15; - for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) + for (blk = 1; blk < s->num_blocks; blk++) s->exp_strategy[ch][blk] = EXP_REUSE; } @@ -487,7 +491,7 @@ static void encode_exponents(AC3EncodeContext *s) cpl = (ch == CPL_CH); blk = 0; - while (blk < AC3_MAX_BLOCKS) { + while (blk < s->num_blocks) { AC3Block *block = &s->blocks[blk]; if (cpl && !block->cpl_in_use) { exp += AC3_MAX_COEFS; @@ -500,7 +504,7 @@ static void encode_exponents(AC3EncodeContext *s) /* count the number of EXP_REUSE blocks after the current block and set exponent reference block numbers */ s->exp_ref_block[ch][blk] = blk; - while (blk1 < AC3_MAX_BLOCKS && exp_strategy[blk1] == EXP_REUSE) { + while (blk1 < s->num_blocks && exp_strategy[blk1] == EXP_REUSE) { s->exp_ref_block[ch][blk1] = blk; blk1++; } @@ -536,7 +540,7 @@ static void group_exponents(AC3EncodeContext *s) int exp0, exp1; bit_count = 0; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; for (ch = !block->cpl_in_use; ch <= s->channels; ch++) { int exp_strategy = s->exp_strategy[ch][blk]; @@ -625,30 +629,38 @@ static void count_frame_bits_fixed(AC3EncodeContext *s) if (s->eac3) { /* bitstream info header */ frame_bits += 35; - frame_bits += 1 + 1 + 1; + frame_bits += 1 + 1; + if (s->num_blocks != 0x6) + frame_bits++; + frame_bits++; /* audio frame header */ - frame_bits += 2; + if (s->num_blocks == 6) + frame_bits += 2; frame_bits += 10; /* exponent strategy */ if (s->use_frame_exp_strategy) frame_bits += 5 * s->fbw_channels; else - frame_bits += AC3_MAX_BLOCKS * 2 * s->fbw_channels; + frame_bits += s->num_blocks * 2 * s->fbw_channels; if (s->lfe_on) - frame_bits += AC3_MAX_BLOCKS; + frame_bits += s->num_blocks; /* converter exponent strategy */ - frame_bits += s->fbw_channels * 5; + if (s->num_blks_code != 0x3) + frame_bits++; + else + frame_bits += s->fbw_channels * 5; /* snr offsets */ frame_bits += 10; /* block start info */ - frame_bits++; + if (s->num_blocks != 1) + frame_bits++; } else { frame_bits += 49; frame_bits += frame_bits_inc[s->channel_mode]; } /* audio blocks */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { if (!s->eac3) { /* block switch flags */ frame_bits += s->fbw_channels; @@ -750,7 +762,7 @@ static void count_frame_bits(AC3EncodeContext *s) /* coupling */ if (s->channel_mode > AC3_CHMODE_MONO) { frame_bits++; - for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 1; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; frame_bits++; if (block->new_cpl_strategy) @@ -762,7 +774,7 @@ static void count_frame_bits(AC3EncodeContext *s) if (s->use_frame_exp_strategy) { frame_bits += 5 * s->cpl_on; } else { - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + for (blk = 0; blk < s->num_blocks; blk++) frame_bits += 2 * s->blocks[blk].cpl_in_use; } } @@ -778,7 +790,7 @@ static void count_frame_bits(AC3EncodeContext *s) } /* audio blocks */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; /* coupling strategy */ @@ -865,7 +877,7 @@ static void bit_alloc_masking(AC3EncodeContext *s) { int blk, ch; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; for (ch = !block->cpl_in_use; ch <= s->channels; ch++) { /* We only need psd and mask for calculating bap. @@ -901,9 +913,9 @@ static void reset_block_bap(AC3EncodeContext *s) ref_bap = s->bap_buffer; for (ch = 0; ch <= s->channels; ch++) { - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + for (blk = 0; blk < s->num_blocks; blk++) s->ref_bap[ch][blk] = ref_bap + AC3_MAX_COEFS * s->exp_ref_block[ch][blk]; - ref_bap += AC3_MAX_COEFS * AC3_MAX_BLOCKS; + ref_bap += AC3_MAX_COEFS * s->num_blocks; } s->ref_bap_set = 1; } @@ -936,7 +948,7 @@ static void count_mantissa_bits_update_ch(AC3EncodeContext *s, int ch, { int blk; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; if (ch == CPL_CH && !block->cpl_in_use) continue; @@ -980,7 +992,7 @@ static int bit_alloc(AC3EncodeContext *s, int snr_offset) snr_offset = (snr_offset - 240) << 2; reset_block_bap(s); - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; for (ch = !block->cpl_in_use; ch <= s->channels; ch++) { @@ -1194,7 +1206,7 @@ void ff_ac3_quantize_mantissas(AC3EncodeContext *s) { int blk, ch, ch0=0, got_cpl; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; AC3Mant m = { 0 }; @@ -1557,7 +1569,7 @@ void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame) s->output_frame_header(s); - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + for (blk = 0; blk < s->num_blocks; blk++) output_audio_block(s, blk); output_frame_end(s); @@ -1585,6 +1597,7 @@ static void dprint_options(AC3EncodeContext *s) av_dlog(avctx, "channel_layout: %s\n", strbuf); av_dlog(avctx, "sample_rate: %d\n", s->sample_rate); av_dlog(avctx, "bit_rate: %d\n", s->bit_rate); + av_dlog(avctx, "blocks/frame: %d (code=%d)\n", s->num_blocks, s->num_blks_code); if (s->cutoff) av_dlog(avctx, "cutoff: %d\n", s->cutoff); @@ -1851,7 +1864,7 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) av_freep(&s->qmant_buffer); av_freep(&s->cpl_coord_exp_buffer); av_freep(&s->cpl_coord_mant_buffer); - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; av_freep(&block->mdct_coef); av_freep(&block->fixed_coef); @@ -1958,18 +1971,30 @@ static av_cold int validate_options(AC3EncodeContext *s) /* validate bit rate */ if (s->eac3) { int max_br, min_br, wpf, min_br_dist, min_br_code; + int num_blks_code, num_blocks, frame_samples; /* calculate min/max bitrate */ - max_br = 2048 * s->sample_rate / AC3_FRAME_SIZE * 16; - min_br = ((s->sample_rate + (AC3_FRAME_SIZE-1)) / AC3_FRAME_SIZE) * 16; + /* TODO: More testing with 3 and 2 blocks. All E-AC-3 samples I've + found use either 6 blocks or 1 block, even though 2 or 3 blocks + would work as far as the bit rate is concerned. */ + for (num_blks_code = 3; num_blks_code >= 0; num_blks_code--) { + num_blocks = ((int[]){ 1, 2, 3, 6 })[num_blks_code]; + frame_samples = AC3_BLOCK_SIZE * num_blocks; + max_br = 2048 * s->sample_rate / frame_samples * 16; + min_br = ((s->sample_rate + (frame_samples-1)) / frame_samples) * 16; + if (avctx->bit_rate <= max_br) + break; + } if (avctx->bit_rate < min_br || avctx->bit_rate > max_br) { av_log(avctx, AV_LOG_ERROR, "invalid bit rate. must be %d to %d " "for this sample rate\n", min_br, max_br); return AVERROR(EINVAL); } + s->num_blks_code = num_blks_code; + s->num_blocks = num_blocks; /* calculate words-per-frame for the selected bitrate */ - wpf = (avctx->bit_rate / 16) * AC3_FRAME_SIZE / s->sample_rate; + wpf = (avctx->bit_rate / 16) * frame_samples / s->sample_rate; av_assert1(wpf > 0 && wpf <= 2048); /* find the closest AC-3 bitrate code to the selected bitrate. @@ -2001,6 +2026,8 @@ static av_cold int validate_options(AC3EncodeContext *s) } s->frame_size_code = i << 1; s->frame_size_min = 2 * ff_ac3_frame_size_tab[s->frame_size_code][s->bit_alloc.sr_code]; + s->num_blks_code = 0x3; + s->num_blocks = 6; } s->bit_rate = avctx->bit_rate; s->frame_size = s->frame_size_min; @@ -2065,13 +2092,13 @@ static av_cold void set_bandwidth(AC3EncodeContext *s) /* set number of coefficients for each channel */ for (ch = 1; ch <= s->fbw_channels; ch++) { s->start_freq[ch] = 0; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + for (blk = 0; blk < s->num_blocks; blk++) s->blocks[blk].end_freq[ch] = s->bandwidth_code * 3 + 73; } /* LFE channel always has 7 coefs */ if (s->lfe_on) { s->start_freq[s->lfe_channel] = 0; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + for (blk = 0; blk < s->num_blocks; blk++) s->blocks[blk].end_freq[ch] = 7; } @@ -2108,7 +2135,7 @@ static av_cold void set_bandwidth(AC3EncodeContext *s) s->start_freq[CPL_CH] = cpl_start_band * 12 + 37; s->cpl_end_freq = cpl_end_band * 12 + 37; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + for (blk = 0; blk < s->num_blocks; blk++) s->blocks[blk].end_freq[CPL_CH] = s->cpl_end_freq; } } @@ -2119,35 +2146,37 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) AVCodecContext *avctx = s->avctx; int blk, ch; int channels = s->channels + 1; /* includes coupling channel */ + int channel_blocks = channels * s->num_blocks; + int total_coefs = AC3_MAX_COEFS * channel_blocks; if (s->allocate_sample_buffers(s)) goto alloc_fail; - FF_ALLOC_OR_GOTO(avctx, s->bap_buffer, AC3_MAX_BLOCKS * channels * - AC3_MAX_COEFS * sizeof(*s->bap_buffer), alloc_fail); - FF_ALLOC_OR_GOTO(avctx, s->bap1_buffer, AC3_MAX_BLOCKS * channels * - AC3_MAX_COEFS * sizeof(*s->bap1_buffer), alloc_fail); - FF_ALLOCZ_OR_GOTO(avctx, s->mdct_coef_buffer, AC3_MAX_BLOCKS * channels * - AC3_MAX_COEFS * sizeof(*s->mdct_coef_buffer), alloc_fail); - FF_ALLOC_OR_GOTO(avctx, s->exp_buffer, AC3_MAX_BLOCKS * channels * - AC3_MAX_COEFS * sizeof(*s->exp_buffer), alloc_fail); - FF_ALLOC_OR_GOTO(avctx, s->grouped_exp_buffer, AC3_MAX_BLOCKS * channels * - 128 * sizeof(*s->grouped_exp_buffer), alloc_fail); - FF_ALLOC_OR_GOTO(avctx, s->psd_buffer, AC3_MAX_BLOCKS * channels * - AC3_MAX_COEFS * sizeof(*s->psd_buffer), alloc_fail); - FF_ALLOC_OR_GOTO(avctx, s->band_psd_buffer, AC3_MAX_BLOCKS * channels * - 64 * sizeof(*s->band_psd_buffer), alloc_fail); - FF_ALLOC_OR_GOTO(avctx, s->mask_buffer, AC3_MAX_BLOCKS * channels * - 64 * sizeof(*s->mask_buffer), alloc_fail); - FF_ALLOC_OR_GOTO(avctx, s->qmant_buffer, AC3_MAX_BLOCKS * channels * - AC3_MAX_COEFS * sizeof(*s->qmant_buffer), alloc_fail); + FF_ALLOC_OR_GOTO(avctx, s->bap_buffer, total_coefs * + sizeof(*s->bap_buffer), alloc_fail); + FF_ALLOC_OR_GOTO(avctx, s->bap1_buffer, total_coefs * + sizeof(*s->bap1_buffer), alloc_fail); + FF_ALLOCZ_OR_GOTO(avctx, s->mdct_coef_buffer, total_coefs * + sizeof(*s->mdct_coef_buffer), alloc_fail); + FF_ALLOC_OR_GOTO(avctx, s->exp_buffer, total_coefs * + sizeof(*s->exp_buffer), alloc_fail); + FF_ALLOC_OR_GOTO(avctx, s->grouped_exp_buffer, channel_blocks * 128 * + sizeof(*s->grouped_exp_buffer), alloc_fail); + FF_ALLOC_OR_GOTO(avctx, s->psd_buffer, total_coefs * + sizeof(*s->psd_buffer), alloc_fail); + FF_ALLOC_OR_GOTO(avctx, s->band_psd_buffer, channel_blocks * 64 * + sizeof(*s->band_psd_buffer), alloc_fail); + FF_ALLOC_OR_GOTO(avctx, s->mask_buffer, channel_blocks * 64 * + sizeof(*s->mask_buffer), alloc_fail); + FF_ALLOC_OR_GOTO(avctx, s->qmant_buffer, total_coefs * + sizeof(*s->qmant_buffer), alloc_fail); if (s->cpl_enabled) { - FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_exp_buffer, AC3_MAX_BLOCKS * channels * - 16 * sizeof(*s->cpl_coord_exp_buffer), alloc_fail); - FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_mant_buffer, AC3_MAX_BLOCKS * channels * - 16 * sizeof(*s->cpl_coord_mant_buffer), alloc_fail); + FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_exp_buffer, channel_blocks * 16 * + sizeof(*s->cpl_coord_exp_buffer), alloc_fail); + FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_mant_buffer, channel_blocks * 16 * + sizeof(*s->cpl_coord_mant_buffer), alloc_fail); } - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; FF_ALLOCZ_OR_GOTO(avctx, block->mdct_coef, channels * sizeof(*block->mdct_coef), alloc_fail); @@ -2183,23 +2212,23 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) } /* arrangement: channel, block, coeff */ - block->exp[ch] = &s->exp_buffer [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * ch + blk)]; - block->mdct_coef[ch] = &s->mdct_coef_buffer [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * ch + blk)]; + block->exp[ch] = &s->exp_buffer [AC3_MAX_COEFS * (s->num_blocks * ch + blk)]; + block->mdct_coef[ch] = &s->mdct_coef_buffer [AC3_MAX_COEFS * (s->num_blocks * ch + blk)]; } } if (!s->fixed_point) { - FF_ALLOCZ_OR_GOTO(avctx, s->fixed_coef_buffer, AC3_MAX_BLOCKS * channels * - AC3_MAX_COEFS * sizeof(*s->fixed_coef_buffer), alloc_fail); - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + FF_ALLOCZ_OR_GOTO(avctx, s->fixed_coef_buffer, total_coefs * + sizeof(*s->fixed_coef_buffer), alloc_fail); + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, channels * sizeof(*block->fixed_coef), alloc_fail); for (ch = 0; ch < channels; ch++) - block->fixed_coef[ch] = &s->fixed_coef_buffer[AC3_MAX_COEFS * (AC3_MAX_BLOCKS * ch + blk)]; + block->fixed_coef[ch] = &s->fixed_coef_buffer[AC3_MAX_COEFS * (s->num_blocks * ch + blk)]; } } else { - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, channels * sizeof(*block->fixed_coef), alloc_fail); @@ -2226,14 +2255,14 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) s->eac3 = avctx->codec_id == CODEC_ID_EAC3; - avctx->frame_size = AC3_FRAME_SIZE; - ff_ac3_common_init(); ret = validate_options(s); if (ret) return ret; + avctx->frame_size = AC3_BLOCK_SIZE * s->num_blocks; + s->bitstream_mode = avctx->audio_service_type; if (s->bitstream_mode == AV_AUDIO_SERVICE_TYPE_KARAOKE) s->bitstream_mode = 0x7; diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index a4a8fd4325..407e751b40 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -151,6 +151,8 @@ typedef struct AC3EncodeContext { int bit_rate; ///< target bit rate, in bits-per-second int sample_rate; ///< sampling frequency, in Hz + int num_blks_code; ///< number of blocks code (numblkscod) + int num_blocks; ///< number of blocks per frame int frame_size_min; ///< minimum frame size in case rounding is necessary int frame_size; ///< current frame size in bytes int frame_size_code; ///< frame size code (frmsizecod) diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index ed8992ebff..508ecb1efb 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -93,7 +93,7 @@ static void scale_coefficients(AC3EncodeContext *s) { int blk, ch; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; for (ch = 1; ch <= s->channels; ch++) { s->ac3dsp.ac3_rshift_int32(block->mdct_coef[ch], AC3_MAX_COEFS, diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 776d185fa4..9f691a1e16 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -103,7 +103,7 @@ static int normalize_samples(AC3EncodeContext *s) */ static void scale_coefficients(AC3EncodeContext *s) { - int chan_size = AC3_MAX_COEFS * AC3_MAX_BLOCKS; + int chan_size = AC3_MAX_COEFS * s->num_blocks; s->ac3dsp.float_to_fixed24(s->fixed_coef_buffer + chan_size, s->mdct_coef_buffer + chan_size, chan_size * s->channels); diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index 9b9151b3e0..c4e2a121bf 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -79,13 +79,13 @@ static void deinterleave_input_samples(AC3EncodeContext *s, int sinc; /* copy last 256 samples of previous frame to the start of the current frame */ - memcpy(&s->planar_samples[ch][0], &s->planar_samples[ch][AC3_FRAME_SIZE], + memcpy(&s->planar_samples[ch][0], &s->planar_samples[ch][AC3_BLOCK_SIZE * s->num_blocks], AC3_BLOCK_SIZE * sizeof(s->planar_samples[0][0])); /* deinterleave */ sinc = s->channels; sptr = samples + s->channel_map[ch]; - for (i = AC3_BLOCK_SIZE; i < AC3_FRAME_SIZE+AC3_BLOCK_SIZE; i++) { + for (i = AC3_BLOCK_SIZE; i < AC3_BLOCK_SIZE * (s->num_blocks + 1); i++) { s->planar_samples[ch][i] = *sptr; sptr += sinc; } @@ -103,7 +103,7 @@ static void apply_mdct(AC3EncodeContext *s) int blk, ch; for (ch = 0; ch < s->channels; ch++) { - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE]; @@ -159,7 +159,7 @@ static void apply_channel_coupling(AC3EncodeContext *s) cpl_start = FFMIN(256, cpl_start + num_cpl_coefs) - num_cpl_coefs; /* calculate coupling channel from fbw channels */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; CoefType *cpl_coef = &block->mdct_coef[CPL_CH][cpl_start]; if (!block->cpl_in_use) @@ -188,7 +188,7 @@ static void apply_channel_coupling(AC3EncodeContext *s) while (i < s->cpl_end_freq) { int band_size = s->cpl_band_sizes[bnd]; for (ch = CPL_CH; ch <= s->fbw_channels; ch++) { - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; if (!block->cpl_in_use || (ch > CPL_CH && !block->channel_in_cpl[ch])) continue; @@ -203,7 +203,7 @@ static void apply_channel_coupling(AC3EncodeContext *s) } /* determine which blocks to send new coupling coordinates for */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; AC3Block *block0 = blk ? &s->blocks[blk-1] : NULL; int new_coords = 0; @@ -261,7 +261,7 @@ static void apply_channel_coupling(AC3EncodeContext *s) coordinates in successive blocks */ for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { blk = 0; - while (blk < AC3_MAX_BLOCKS) { + while (blk < s->num_blocks) { int blk1; CoefSumType energy_cpl; AC3Block *block = &s->blocks[blk]; @@ -273,7 +273,7 @@ static void apply_channel_coupling(AC3EncodeContext *s) energy_cpl = energy[blk][CPL_CH][bnd]; blk1 = blk+1; - while (!s->blocks[blk1].new_cpl_coords && blk1 < AC3_MAX_BLOCKS) { + while (!s->blocks[blk1].new_cpl_coords && blk1 < s->num_blocks) { if (s->blocks[blk1].cpl_in_use) energy_cpl += energy[blk1][CPL_CH][bnd]; blk1++; @@ -285,7 +285,7 @@ static void apply_channel_coupling(AC3EncodeContext *s) continue; energy_ch = energy[blk][ch][bnd]; blk1 = blk+1; - while (!s->blocks[blk1].new_cpl_coords && blk1 < AC3_MAX_BLOCKS) { + while (!s->blocks[blk1].new_cpl_coords && blk1 < s->num_blocks) { if (s->blocks[blk1].cpl_in_use) energy_ch += energy[blk1][ch][bnd]; blk1++; @@ -297,7 +297,7 @@ static void apply_channel_coupling(AC3EncodeContext *s) } /* calculate exponents/mantissas for coupling coordinates */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; if (!block->cpl_in_use || !block->new_cpl_coords) continue; @@ -362,7 +362,7 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s) if (s->channel_mode != AC3_CHMODE_STEREO) return; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { block = &s->blocks[blk]; block->new_rematrixing_strategy = !blk; @@ -440,7 +440,7 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame, scale_coefficients(s); clip_coefficients(&s->dsp, s->blocks[0].mdct_coef[1], - AC3_MAX_COEFS * AC3_MAX_BLOCKS * s->channels); + AC3_MAX_COEFS * s->num_blocks * s->channels); s->cpl_on = s->cpl_enabled; ff_ac3_compute_coupling_strategy(s); diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 09fa80fcb9..038aa2a234 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -63,6 +63,11 @@ void ff_eac3_get_frame_exp_strategy(AC3EncodeContext *s) { int ch; + if (s->num_blocks < 6) { + s->use_frame_exp_strategy = 0; + return; + } + s->use_frame_exp_strategy = 1; for (ch = !s->cpl_on; ch <= s->fbw_channels; ch++) { int expstr = eac3_frame_expstr_index_tab[s->exp_strategy[ch][0]-1] @@ -89,7 +94,7 @@ void ff_eac3_set_cpl_states(AC3EncodeContext *s) /* set first cpl coords */ for (ch = 1; ch <= s->fbw_channels; ch++) first_cpl_coords[ch] = 1; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; for (ch = 1; ch <= s->fbw_channels; ch++) { if (block->channel_in_cpl[ch]) { @@ -104,7 +109,7 @@ void ff_eac3_set_cpl_states(AC3EncodeContext *s) } /* set first cpl leak */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; if (block->cpl_in_use) { block->new_cpl_leak = 2; @@ -130,7 +135,7 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ } else { put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ - put_bits(&s->pb, 2, 0x3); /* number of blocks = 6 */ + put_bits(&s->pb, 2, s->num_blks_code); /* number of blocks */ } put_bits(&s->pb, 3, s->channel_mode); /* audio coding mode */ put_bits(&s->pb, 1, s->lfe_on); /* LFE channel indicator */ @@ -141,11 +146,15 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) /* TODO: mixing metadata */ put_bits(&s->pb, 1, 0); /* no info metadata */ /* TODO: info metadata */ + if (s->num_blocks != 6) + put_bits(&s->pb, 1, !(s->avctx->frame_number % 6)); /* converter sync flag */ put_bits(&s->pb, 1, 0); /* no additional bit stream info */ /* frame header */ + if (s->num_blocks == 6) { put_bits(&s->pb, 1, !s->use_frame_exp_strategy);/* exponent strategy syntax */ put_bits(&s->pb, 1, 0); /* aht enabled = no */ + } put_bits(&s->pb, 2, 0); /* snr offset strategy = 1 */ put_bits(&s->pb, 1, 0); /* transient pre-noise processing enabled = no */ put_bits(&s->pb, 1, 0); /* block switch syntax enabled = no */ @@ -158,7 +167,7 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) /* coupling strategy use flags */ if (s->channel_mode > AC3_CHMODE_MONO) { put_bits(&s->pb, 1, s->blocks[0].cpl_in_use); - for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) { + for (blk = 1; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; put_bits(&s->pb, 1, block->new_cpl_strategy); if (block->new_cpl_strategy) @@ -170,26 +179,31 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) for (ch = !s->cpl_on; ch <= s->fbw_channels; ch++) put_bits(&s->pb, 5, s->frame_exp_strategy[ch]); } else { - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + for (blk = 0; blk < s->num_blocks; blk++) for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); } if (s->lfe_on) { - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + for (blk = 0; blk < s->num_blocks; blk++) put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]); } - /* E-AC-3 to AC-3 converter exponent strategy (unfortunately not optional...) */ + /* E-AC-3 to AC-3 converter exponent strategy (not optional when num blocks == 6) */ + if (s->num_blocks != 6) { + put_bits(&s->pb, 1, 0); + } else { for (ch = 1; ch <= s->fbw_channels; ch++) { if (s->use_frame_exp_strategy) put_bits(&s->pb, 5, s->frame_exp_strategy[ch]); else put_bits(&s->pb, 5, 0); } + } /* snr offsets */ put_bits(&s->pb, 6, s->coarse_snr_offset); put_bits(&s->pb, 4, s->fine_snr_offset[1]); /* block start info */ - put_bits(&s->pb, 1, 0); + if (s->num_blocks > 1) + put_bits(&s->pb, 1, 0); } From 4cc843facdc8cd922c423a09c5fff911137e4b4c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 17 Jul 2011 13:27:46 +0200 Subject: [PATCH 646/780] rtp: remove disabled code --- libavformat/rtpdec.c | 16 ---------------- libavformat/rtpproto.c | 23 ----------------------- 2 files changed, 39 deletions(-) diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 2c262d9bd3..37122600a5 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -218,22 +218,6 @@ static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq) return 1; } -#if 0 -/** -* This function is currently unused; without a valid local ntp time, I don't see how we could calculate the -* difference between the arrival and sent timestamp. As a result, the jitter and transit statistics values -* never change. I left this in in case someone else can see a way. (rdm) -*/ -static void rtcp_update_jitter(RTPStatistics *s, uint32_t sent_timestamp, uint32_t arrival_timestamp) -{ - uint32_t transit= arrival_timestamp - sent_timestamp; - int d; - s->transit= transit; - d= FFABS(transit - s->transit); - s->jitter += d - ((s->jitter + 8)>>4); -} -#endif - int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) { AVIOContext *pb; diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index dba1d35b03..0367198f36 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -225,20 +225,6 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) int len, n; struct pollfd p[2] = {{s->rtp_fd, POLLIN, 0}, {s->rtcp_fd, POLLIN, 0}}; -#if 0 - for(;;) { - from_len = sizeof(from); - len = recvfrom (s->rtp_fd, buf, size, 0, - (struct sockaddr *)&from, &from_len); - if (len < 0) { - if (ff_neterrno() == AVERROR(EAGAIN) || - ff_neterrno() == AVERROR(EINTR)) - continue; - return AVERROR(EIO); - } - break; - } -#else for(;;) { if (url_interrupt_cb()) return AVERROR_EXIT; @@ -277,7 +263,6 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size) return AVERROR(EIO); } } -#endif return len; } @@ -296,14 +281,6 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size) } ret = ffurl_write(hd, buf, size); -#if 0 - { - struct timespec ts; - ts.tv_sec = 0; - ts.tv_nsec = 10 * 1000000; - nanosleep(&ts, NULL); - } -#endif return ret; } From bb32fded3623a20ff8999c2924315841c08c985c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 21 Jul 2011 19:04:37 +0100 Subject: [PATCH 647/780] dnxhddec: optimise dnxhd_decode_dct_block() Template the function for 8/10-bit and use lowlevel bitstream macros. 6% faster overall on i7 gcc 4.5. Signed-off-by: Mans Rullgard --- libavcodec/dnxhddec.c | 108 +++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 39 deletions(-) diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 7b32cd3ed4..426be2e985 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -31,7 +31,7 @@ #include "dnxhddata.h" #include "dsputil.h" -typedef struct { +typedef struct DNXHDContext { AVCodecContext *avctx; AVFrame picture; GetBitContext gb; @@ -47,11 +47,16 @@ typedef struct { ScanTable scantable; const CIDEntry *cid_table; int bit_depth; // 8, 10 or 0 if not initialized at all. + void (*decode_dct_block)(struct DNXHDContext *ctx, DCTELEM *block, + int n, int qscale); } DNXHDContext; #define DNXHD_VLC_BITS 9 #define DNXHD_DC_VLC_BITS 7 +static void dnxhd_decode_dct_block_8(DNXHDContext *ctx, DCTELEM *block, int n, int qscale); +static void dnxhd_decode_dct_block_10(DNXHDContext *ctx, DCTELEM *block, int n, int qscale); + static av_cold int dnxhd_decode_init(AVCodecContext *avctx) { DNXHDContext *ctx = avctx->priv_data; @@ -118,6 +123,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si if (ctx->bit_depth != 10) { dsputil_init(&ctx->dsp, ctx->avctx); ctx->bit_depth = 10; + ctx->decode_dct_block = dnxhd_decode_dct_block_10; } } else { ctx->avctx->pix_fmt = PIX_FMT_YUV422P; @@ -125,6 +131,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si if (ctx->bit_depth != 8) { dsputil_init(&ctx->dsp, ctx->avctx); ctx->bit_depth = 8; + ctx->decode_dct_block = dnxhd_decode_dct_block_8; } } @@ -165,71 +172,94 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si return 0; } -static int dnxhd_decode_dc(DNXHDContext *ctx) +static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx, + DCTELEM *block, int n, + int qscale, + int index_bits, + int level_bias, + int level_shift) { - int len; - - len = get_vlc2(&ctx->gb, ctx->dc_vlc.table, DNXHD_DC_VLC_BITS, 1); - return len ? get_xbits(&ctx->gb, len) : 0; -} - -static void dnxhd_decode_dct_block(DNXHDContext *ctx, DCTELEM *block, int n, int qscale) -{ - int i, j, index, index2; + int i, j, index1, index2, len; int level, component, sign; - const uint8_t *weigth_matrix; + const uint8_t *weight_matrix; + OPEN_READER(bs, &ctx->gb); if (n&2) { component = 1 + (n&1); - weigth_matrix = ctx->cid_table->chroma_weight; + weight_matrix = ctx->cid_table->chroma_weight; } else { component = 0; - weigth_matrix = ctx->cid_table->luma_weight; + weight_matrix = ctx->cid_table->luma_weight; } - ctx->last_dc[component] += dnxhd_decode_dc(ctx); + UPDATE_CACHE(bs, &ctx->gb); + GET_VLC(len, bs, &ctx->gb, ctx->dc_vlc.table, DNXHD_DC_VLC_BITS, 1); + if (len) { + level = GET_CACHE(bs, &ctx->gb); + LAST_SKIP_BITS(bs, &ctx->gb, len); + sign = ~level >> 31; + level = (NEG_USR32(sign ^ level, len) ^ sign) - sign; + ctx->last_dc[component] += level; + } block[0] = ctx->last_dc[component]; //av_log(ctx->avctx, AV_LOG_DEBUG, "dc %d\n", block[0]); + for (i = 1; ; i++) { - index = get_vlc2(&ctx->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2); - //av_log(ctx->avctx, AV_LOG_DEBUG, "index %d\n", index); - level = ctx->cid_table->ac_level[index]; + UPDATE_CACHE(bs, &ctx->gb); + GET_VLC(index1, bs, &ctx->gb, ctx->ac_vlc.table, + DNXHD_VLC_BITS, 2); + //av_log(ctx->avctx, AV_LOG_DEBUG, "index %d\n", index1); + level = ctx->cid_table->ac_level[index1]; if (!level) { /* EOB */ //av_log(ctx->avctx, AV_LOG_DEBUG, "EOB\n"); - return; - } - sign = get_sbits(&ctx->gb, 1); - - if (ctx->cid_table->ac_index_flag[index]) { - level += get_bits(&ctx->gb, ctx->cid_table->index_bits)<<6; + break; } - if (ctx->cid_table->ac_run_flag[index]) { - index2 = get_vlc2(&ctx->gb, ctx->run_vlc.table, DNXHD_VLC_BITS, 2); + sign = SHOW_SBITS(bs, &ctx->gb, 1); + SKIP_BITS(bs, &ctx->gb, 1); + + if (ctx->cid_table->ac_index_flag[index1]) { + level += SHOW_UBITS(bs, &ctx->gb, index_bits) << 6; + SKIP_BITS(bs, &ctx->gb, index_bits); + } + + if (ctx->cid_table->ac_run_flag[index1]) { + UPDATE_CACHE(bs, &ctx->gb); + GET_VLC(index2, bs, &ctx->gb, ctx->run_vlc.table, + DNXHD_VLC_BITS, 2); i += ctx->cid_table->run[index2]; } if (i > 63) { av_log(ctx->avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", n, i); - return; + break; } j = ctx->scantable.permutated[i]; //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j); - //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weigth %d\n", level, weigth_matrix[i]); - level = (2*level+1) * qscale * weigth_matrix[i]; - if (ctx->bit_depth == 10) { - if (weigth_matrix[i] != 8) - level += 8; - level >>= 4; - } else { - if (weigth_matrix[i] != 32) - level += 32; - level >>= 6; - } + //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weight %d\n", level, weight_matrix[i]); + level = (2*level+1) * qscale * weight_matrix[i]; + if (weight_matrix[i] != level_bias) + level += level_bias; + level >>= level_shift; + //av_log(NULL, AV_LOG_DEBUG, "i %d, j %d, end level %d\n", i, j, level); block[j] = (level^sign) - sign; } + + CLOSE_READER(bs, &ctx->gb); +} + +static void dnxhd_decode_dct_block_8(DNXHDContext *ctx, DCTELEM *block, + int n, int qscale) +{ + dnxhd_decode_dct_block(ctx, block, n, qscale, 4, 32, 6); +} + +static void dnxhd_decode_dct_block_10(DNXHDContext *ctx, DCTELEM *block, + int n, int qscale) +{ + dnxhd_decode_dct_block(ctx, block, n, qscale, 6, 8, 4); } static int dnxhd_decode_macroblock(DNXHDContext *ctx, int x, int y) @@ -247,7 +277,7 @@ static int dnxhd_decode_macroblock(DNXHDContext *ctx, int x, int y) for (i = 0; i < 8; i++) { ctx->dsp.clear_block(ctx->blocks[i]); - dnxhd_decode_dct_block(ctx, ctx->blocks[i], i, qscale); + ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale); } if (ctx->picture.interlaced_frame) { From 657eac048eb267d781de83849fe7616d29320832 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 21 Jul 2011 15:16:12 +0200 Subject: [PATCH 648/780] version.sh: handle shallow clones and snapshots. Shallow clones (--depth X) lack the N tag used to compute the revision number: use 'git-YYYY-MM-DD-hhhhhhh' as revision, where hhhhhhh is the short git hash. Snapshots from gitweb do not have git information at all, but they have the short git hash in the directory name: append it to the release number. --- version.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/version.sh b/version.sh index 41ae520ecc..8d084c2df3 100755 --- a/version.sh +++ b/version.sh @@ -5,9 +5,29 @@ if ! test "$revision"; then revision=$(cd "$1" && git describe --tags --match N 2> /dev/null) fi +# Shallow Git clones (--depth) do not have the N tag: +# use 'git-YYYY-MM-DD-hhhhhhh'. +test "$revision" || revision=$(cd "$1" && + git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null) + +# Snapshots from gitweb are in a directory called ffmpeg-hhhhhhh or +# ffmpeg-HEAD-hhhhhhh. +if [ -z "$revision" ]; then + srcdir=$(cd "$1" && pwd) + case "$srcdir" in + */ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) + git_hash="${srcdir##*-}";; + */ffmpeg-HEAD-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) + git_hash="${srcdir##*-}";; + esac +fi + # no revision number found test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null) +# Append the Git hash if we have one +test "$revision" && test "$git_hash" && revision="$revision-$git_hash" + # releases extract the version number from the VERSION file version=$(cd "$1" && cat VERSION 2> /dev/null) test "$version" || version=$revision From c2d23309ef87c3f1a515860425a5a898aab9b760 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 16 Jul 2011 12:02:55 +0200 Subject: [PATCH 649/780] add Flash Screen Video 2 decoder Signed-off-by: Ronald S. Bultje --- Changelog | 1 + configure | 1 + doc/general.texi | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/flashsv.c | 307 +++++++++++++++++++++++++++++++++++++++-- libavcodec/version.h | 2 +- 7 files changed, 301 insertions(+), 13 deletions(-) diff --git a/Changelog b/Changelog index 782d8b3f04..7b8be5b302 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ releases are sorted from youngest to oldest. version : - BWF muxer +- Flash Screen Video 2 decoder version 0.7: diff --git a/configure b/configure index 3953cfc44b..a83d3396e1 100755 --- a/configure +++ b/configure @@ -1270,6 +1270,7 @@ flac_decoder_select="golomb" flac_encoder_select="golomb lpc" flashsv_decoder_select="zlib" flashsv_encoder_select="zlib" +flashsv2_decoder_select="zlib" flv_decoder_select="h263_decoder" flv_encoder_select="h263_encoder" fraps_decoder_select="huffman" diff --git a/doc/general.texi b/doc/general.texi index fe314481a3..c9919390d6 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -401,6 +401,7 @@ following image formats are supported: @tab experimental lossless codec (fourcc: FFV1) @item Flash Screen Video v1 @tab X @tab X @tab fourcc: FSV1 +@item Flash Screen Video v2 @tab @tab X @item Flash Video (FLV) @tab X @tab X @tab Sorenson H.263 used in Flash @item Fraps @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f23ade2734..99ecbbf567 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -146,6 +146,7 @@ OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flac.o OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o +OBJS-$(CONFIG_FLASHSV2_DECODER) += flashsv.o OBJS-$(CONFIG_FLIC_DECODER) += flicvideo.o OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 71b6094089..dcef0d6d94 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -106,6 +106,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (FFV1, ffv1); REGISTER_ENCDEC (FFVHUFF, ffvhuff); REGISTER_ENCDEC (FLASHSV, flashsv); + REGISTER_DECODER (FLASHSV2, flashsv2); REGISTER_DECODER (FLIC, flic); REGISTER_ENCDEC (FLV, flv); REGISTER_DECODER (FOURXM, fourxm); diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 51831eb801..57d33c06da 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -25,6 +25,8 @@ * Flash Screen Video decoder * @author Alex Beregszaszi * @author Benjamin Larsson + * @author Daniel Verkamp + * @author Konstantin Shishkov * * A description of the bitstream format for Flash Screen Video version 1/2 * is part of the SWF File Format Specification (version 10), which can be @@ -35,9 +37,17 @@ #include #include +#include "libavutil/intreadwrite.h" #include "avcodec.h" +#include "bytestream.h" #include "get_bits.h" +typedef struct BlockInfo { + uint8_t *pos; + int size; + int unp_size; +} BlockInfo; + typedef struct FlashSVContext { AVCodecContext *avctx; AVFrame frame; @@ -46,9 +56,50 @@ typedef struct FlashSVContext { uint8_t *tmpblock; int block_size; z_stream zstream; + int ver; + const uint32_t *pal; + int is_keyframe; + uint8_t *keyframedata; + uint8_t *keyframe; + BlockInfo *blocks; + uint8_t *deflate_block; + int deflate_block_size; + int color_depth; + int zlibprime_curr, zlibprime_prev; + int diff_start, diff_height; } FlashSVContext; +static int decode_hybrid(const uint8_t *sptr, uint8_t *dptr, int dx, int dy, + int h, int w, int stride, const uint32_t *pal) +{ + int x, y; + const uint8_t *orig_src = sptr; + + for (y = dx+h; y > dx; y--) { + uint8_t *dst = dptr + (y * stride) + dy * 3; + for (x = 0; x < w; x++) { + if (*sptr & 0x80) { + /* 15-bit color */ + unsigned c = AV_RB16(sptr) & ~0x8000; + unsigned b = c & 0x1F; + unsigned g = (c >> 5) & 0x1F; + unsigned r = c >> 10; + /* 000aaabb -> aaabbaaa */ + *dst++ = (b << 3) | (b >> 2); + *dst++ = (g << 3) | (g >> 2); + *dst++ = (r << 3) | (r >> 2); + sptr += 2; + } else { + /* palette index */ + uint32_t c = pal[*sptr++]; + bytestream_put_le24(&dst, c); + } + } + } + return sptr - orig_src; +} + static av_cold int flashsv_decode_init(AVCodecContext *avctx) { FlashSVContext *s = avctx->priv_data; @@ -70,9 +121,42 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx) } +static void flashsv2_prime(FlashSVContext *s, uint8_t *src, + int size, int unp_size) +{ + z_stream zs; + + zs.zalloc = NULL; + zs.zfree = NULL; + zs.opaque = NULL; + + s->zstream.next_in = src; + s->zstream.avail_in = size; + s->zstream.next_out = s->tmpblock; + s->zstream.avail_out = s->block_size * 3; + inflate(&s->zstream, Z_SYNC_FLUSH); + + deflateInit(&zs, 0); + zs.next_in = s->tmpblock; + zs.avail_in = s->block_size * 3 - s->zstream.avail_out; + zs.next_out = s->deflate_block; + zs.avail_out = s->deflate_block_size; + deflate(&zs, Z_SYNC_FLUSH); + deflateEnd(&zs); + + inflateReset(&s->zstream); + + s->zstream.next_in = s->deflate_block; + s->zstream.avail_in = s->deflate_block_size - zs.avail_out; + s->zstream.next_out = s->tmpblock; + s->zstream.avail_out = s->block_size * 3; + inflate(&s->zstream, Z_SYNC_FLUSH); +} + static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt, GetBitContext *gb, int block_size, - int width, int height, int x_pos, int y_pos) + int width, int height, int x_pos, int y_pos, + int blk_idx) { struct FlashSVContext *s = avctx->priv_data; uint8_t *line = s->tmpblock; @@ -81,6 +165,10 @@ static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt, if (ret != Z_OK) { //return -1; } + if (s->zlibprime_curr || s->zlibprime_prev) { + flashsv2_prime(s, s->blocks[blk_idx].pos, s->blocks[blk_idx].size, + s->blocks[blk_idx].unp_size); + } s->zstream.next_in = avpkt->data + get_bits_count(gb) / 8; s->zstream.avail_in = block_size; s->zstream.next_out = s->tmpblock; @@ -95,19 +183,48 @@ static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt, if (ret != Z_OK && ret != Z_STREAM_END) { //return -1; } - /* Flash Screen Video stores the image upside down, so copy - * lines to destination in reverse order. */ - for (k = 1; k <= height; k++) { - memcpy(s->frame.data[0] + x_pos * 3 + - (s->image_height - y_pos - k) * s->frame.linesize[0], - line, width * 3); - /* advance source pointer to next line */ - line += width * 3; + + if (s->is_keyframe) { + s->blocks[blk_idx].pos = s->keyframedata + (get_bits_count(gb) / 8); + s->blocks[blk_idx].size = block_size; + s->blocks[blk_idx].unp_size = s->block_size * 3 - s->zstream.avail_out; + } + if (!s->color_depth) { + /* Flash Screen Video stores the image upside down, so copy + * lines to destination in reverse order. */ + for (k = 1; k <= s->diff_height; k++) { + memcpy(s->frame.data[0] + x_pos * 3 + + (s->image_height - y_pos - s->diff_start - k) * s->frame.linesize[0], + line, width * 3); + /* advance source pointer to next line */ + line += width * 3; + } + } else { + /* hybrid 15-bit/palette mode */ + decode_hybrid(s->tmpblock, s->frame.data[0], + s->image_height - (y_pos + 1 + s->diff_start + s->diff_height), + x_pos, s->diff_height, width, + s->frame.linesize[0], s->pal); } skip_bits_long(gb, 8 * block_size); /* skip the consumed bits */ return 0; } +static int calc_deflate_block_size(int tmpblock_size) +{ + z_stream zstream; + int size; + + zstream.zalloc = Z_NULL; + zstream.zfree = Z_NULL; + zstream.opaque = Z_NULL; + if (deflateInit(&zstream, 0) != Z_OK) + return -1; + size = deflateBound(&zstream, tmpblock_size); + deflateEnd(&zstream); + + return size; +} static int flashsv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) @@ -131,6 +248,18 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->block_height = 16 * (get_bits(&gb, 4) + 1); s->image_height = get_bits(&gb, 12); + if (s->ver == 2) { + skip_bits(&gb, 6); + if (get_bits1(&gb)) { + av_log_missing_feature(avctx, "iframe", 1); + return AVERROR_PATCHWELCOME; + } + if (get_bits1(&gb)) { + av_log_missing_feature(avctx, "custom palette", 1); + return AVERROR_PATCHWELCOME; + } + } + /* calculate number of blocks and size of border (partial) blocks */ h_blocks = s->image_width / s->block_width; h_part = s->image_width % s->block_width; @@ -140,11 +269,25 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* the block size could change between frames, make sure the buffer * is large enough, if not, get a larger one */ if (s->block_size < s->block_width * s->block_height) { - av_free(s->tmpblock); - if ((s->tmpblock = av_malloc(3 * s->block_width * s->block_height)) == NULL) { + int tmpblock_size = 3 * s->block_width * s->block_height; + + s->tmpblock = av_realloc(s->tmpblock, tmpblock_size); + if (!s->tmpblock) { av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); return AVERROR(ENOMEM); } + if (s->ver == 2) { + s->deflate_block_size = calc_deflate_block_size(tmpblock_size); + if (s->deflate_block_size <= 0) { + av_log(avctx, AV_LOG_ERROR, "Can't determine deflate buffer size.\n"); + return -1; + } + s->deflate_block = av_realloc(s->deflate_block, s->deflate_block_size); + if (!s->deflate_block) { + av_log(avctx, AV_LOG_ERROR, "Can't allocate deflate buffer.\n"); + return AVERROR(ENOMEM); + } + } } s->block_size = s->block_width * s->block_height; @@ -163,6 +306,16 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } + /* we care for keyframes only in Screen Video v2 */ + s->is_keyframe = (avpkt->flags & AV_PKT_FLAG_KEY) && (s->ver == 2); + if (s->is_keyframe) { + s->keyframedata = av_realloc(s->keyframedata, avpkt->size); + memcpy(s->keyframedata, avpkt->data, avpkt->size); + s->blocks = av_realloc(s->blocks, + (v_blocks + !!v_part) * (h_blocks + !!h_part) + * sizeof(s->blocks[0])); + } + av_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", s->image_width, s->image_height, s->block_width, s->block_height, h_blocks, v_blocks, h_part, v_part); @@ -186,25 +339,90 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, for (i = 0; i < h_blocks + (h_part ? 1 : 0); i++) { int x_pos = i * s->block_width; // horizontal position in frame int cur_blk_width = (i < h_blocks) ? s->block_width : h_part; + int has_diff = 0; /* get the size of the compressed zlib chunk */ int size = get_bits(&gb, 16); + + s->color_depth = 0; + s->zlibprime_curr = 0; + s->zlibprime_prev = 0; + s->diff_start = 0; + s->diff_height = cur_blk_height; + if (8 * size > get_bits_left(&gb)) { avctx->release_buffer(avctx, &s->frame); s->frame.data[0] = NULL; return AVERROR_INVALIDDATA; } + if (s->ver == 2 && size) { + skip_bits(&gb, 3); + s->color_depth = get_bits(&gb, 2); + has_diff = get_bits1(&gb); + s->zlibprime_curr = get_bits1(&gb); + s->zlibprime_prev = get_bits1(&gb); + + if (s->color_depth != 0 && s->color_depth != 2) { + av_log(avctx, AV_LOG_ERROR, + "%dx%d invalid color depth %d\n", i, j, s->color_depth); + return -1; + } + + if (has_diff) { + s->diff_start = get_bits(&gb, 8); + s->diff_height = get_bits(&gb, 8); + av_log(avctx, AV_LOG_DEBUG, + "%dx%d diff start %d height %d\n", + i, j, s->diff_start, s->diff_height); + size -= 2; + } + + if (s->zlibprime_prev) + av_log(avctx, AV_LOG_DEBUG, "%dx%d zlibprime_prev\n", i, j); + + if (s->zlibprime_curr) { + int col = get_bits(&gb, 8); + int row = get_bits(&gb, 8); + av_log(avctx, AV_LOG_DEBUG, "%dx%d zlibprime_curr %dx%d\n", i, j, col, row); + size -= 2; + av_log_missing_feature(avctx, "zlibprime_curr", 1); + return AVERROR_PATCHWELCOME; + } + size--; // account for flags byte + } + + if (has_diff) { + int k; + int off = (s->image_height - y_pos - 1) * s->frame.linesize[0]; + + for (k = 0; k < cur_blk_height; k++) + memcpy(s->frame.data[0] + off - k*s->frame.linesize[0] + x_pos*3, + s->keyframe + off - k*s->frame.linesize[0] + x_pos*3, + cur_blk_width * 3); + } + /* skip unchanged blocks, which have size 0 */ if (size) { if (flashsv_decode_block(avctx, avpkt, &gb, size, cur_blk_width, cur_blk_height, - x_pos, y_pos)) + x_pos, y_pos, + i + j * (h_blocks + !!h_part))) av_log(avctx, AV_LOG_ERROR, "error in decompression of block %dx%d\n", i, j); } } } + if (s->is_keyframe && s->ver == 2) { + if (!s->keyframe) { + s->keyframe = av_malloc(s->frame.linesize[0] * avctx->height); + if (!s->keyframe) { + av_log(avctx, AV_LOG_ERROR, "Cannot allocate image data\n"); + return AVERROR(ENOMEM); + } + } + memcpy(s->keyframe, s->frame.data[0], s->frame.linesize[0] * avctx->height); + } *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; @@ -233,6 +451,7 @@ static av_cold int flashsv_decode_end(AVCodecContext *avctx) } +#if CONFIG_FLASHSV_DECODER AVCodec ff_flashsv_decoder = { .name = "flashsv", .type = AVMEDIA_TYPE_VIDEO, @@ -245,3 +464,67 @@ AVCodec ff_flashsv_decoder = { .pix_fmts = (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video v1"), }; +#endif /* CONFIG_FLASHSV_DECODER */ + +#if CONFIG_FLASHSV2_DECODER +static const uint32_t ff_flashsv2_default_palette[128] = { + 0x000000, 0x333333, 0x666666, 0x999999, 0xCCCCCC, 0xFFFFFF, + 0x330000, 0x660000, 0x990000, 0xCC0000, 0xFF0000, 0x003300, + 0x006600, 0x009900, 0x00CC00, 0x00FF00, 0x000033, 0x000066, + 0x000099, 0x0000CC, 0x0000FF, 0x333300, 0x666600, 0x999900, + 0xCCCC00, 0xFFFF00, 0x003333, 0x006666, 0x009999, 0x00CCCC, + 0x00FFFF, 0x330033, 0x660066, 0x990099, 0xCC00CC, 0xFF00FF, + 0xFFFF33, 0xFFFF66, 0xFFFF99, 0xFFFFCC, 0xFF33FF, 0xFF66FF, + 0xFF99FF, 0xFFCCFF, 0x33FFFF, 0x66FFFF, 0x99FFFF, 0xCCFFFF, + 0xCCCC33, 0xCCCC66, 0xCCCC99, 0xCCCCFF, 0xCC33CC, 0xCC66CC, + 0xCC99CC, 0xCCFFCC, 0x33CCCC, 0x66CCCC, 0x99CCCC, 0xFFCCCC, + 0x999933, 0x999966, 0x9999CC, 0x9999FF, 0x993399, 0x996699, + 0x99CC99, 0x99FF99, 0x339999, 0x669999, 0xCC9999, 0xFF9999, + 0x666633, 0x666699, 0x6666CC, 0x6666FF, 0x663366, 0x669966, + 0x66CC66, 0x66FF66, 0x336666, 0x996666, 0xCC6666, 0xFF6666, + 0x333366, 0x333399, 0x3333CC, 0x3333FF, 0x336633, 0x339933, + 0x33CC33, 0x33FF33, 0x663333, 0x993333, 0xCC3333, 0xFF3333, + 0x003366, 0x336600, 0x660033, 0x006633, 0x330066, 0x663300, + 0x336699, 0x669933, 0x993366, 0x339966, 0x663399, 0x996633, + 0x6699CC, 0x99CC66, 0xCC6699, 0x66CC99, 0x9966CC, 0xCC9966, + 0x99CCFF, 0xCCFF99, 0xFF99CC, 0x99FFCC, 0xCC99FF, 0xFFCC99, + 0x111111, 0x222222, 0x444444, 0x555555, 0xAAAAAA, 0xBBBBBB, + 0xDDDDDD, 0xEEEEEE +}; + +static av_cold int flashsv2_decode_init(AVCodecContext *avctx) +{ + FlashSVContext *s = avctx->priv_data; + flashsv_decode_init(avctx); + s->pal = ff_flashsv2_default_palette; + s->ver = 2; + + return 0; +} + +static av_cold int flashsv2_decode_end(AVCodecContext *avctx) +{ + FlashSVContext *s = avctx->priv_data; + + av_freep(&s->keyframedata); + av_freep(&s->blocks); + av_freep(&s->keyframe); + av_freep(&s->deflate_block); + flashsv_decode_end(avctx); + + return 0; +} + +AVCodec ff_flashsv2_decoder = { + .name = "flashsv2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_FLASHSV2, + .priv_data_size = sizeof(FlashSVContext), + .init = flashsv2_decode_init, + .close = flashsv2_decode_end, + .decode = flashsv_decode_frame, + .capabilities = CODEC_CAP_DR1, + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video v2"), +}; +#endif /* CONFIG_FLASHSV2_DECODER */ diff --git a/libavcodec/version.h b/libavcodec/version.h index a4e0402cad..8d40899557 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -21,7 +21,7 @@ #define AVCODEC_VERSION_H #define LIBAVCODEC_VERSION_MAJOR 53 -#define LIBAVCODEC_VERSION_MINOR 6 +#define LIBAVCODEC_VERSION_MINOR 7 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From 505345ed5d180093a44da8d70ac541898c31c22f Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 22 Jul 2011 10:13:22 -0700 Subject: [PATCH 650/780] riff: Add mpgv MPEG-2 fourcc Supported by mplayer and seen in the wild. --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 27f45b91d9..c426ae5de6 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -131,6 +131,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_MPEG2VIDEO, MKTAG('s', 'l', 'i', 'f') }, { CODEC_ID_MPEG2VIDEO, MKTAG('E', 'M', '2', 'V') }, { CODEC_ID_MPEG2VIDEO, MKTAG('M', '7', '0', '1') }, /* Matrox MPEG2 intra-only */ + { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', 'v') }, { CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') }, { CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') }, { CODEC_ID_MJPEG, MKTAG('d', 'm', 'b', '1') }, From 406fbd24dc62db4853cb24b24f40caf3e70ee2e8 Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Thu, 21 Jul 2011 21:15:58 -0400 Subject: [PATCH 651/780] H.264: Add optimizations to predict x86 assembly. Signed-off-by: Ronald S. Bultje --- libavcodec/x86/h264_intrapred.asm | 5 +- libavcodec/x86/h264_intrapred_10bit.asm | 1139 +++++++++-------------- libavcodec/x86/h264_intrapred_init.c | 29 +- 3 files changed, 448 insertions(+), 725 deletions(-) diff --git a/libavcodec/x86/h264_intrapred.asm b/libavcodec/x86/h264_intrapred.asm index cbf3cf7a5c..c1cd5c4d25 100644 --- a/libavcodec/x86/h264_intrapred.asm +++ b/libavcodec/x86/h264_intrapred.asm @@ -2611,12 +2611,11 @@ cglobal pred4x4_down_left_mmxext, 3,3 punpckldq m1, [r1] movq m2, m1 movq m3, m1 - movq m4, m1 psllq m1, 8 pxor m2, m1 psrlq m2, 8 - pxor m3, m2 - PRED4x4_LOWPASS m0, m1, m3, m4, m5 + pxor m2, m3 + PRED4x4_LOWPASS m0, m1, m2, m3, m4 lea r1, [r0+r2*2] psrlq m0, 8 movd [r0+r2*1], m0 diff --git a/libavcodec/x86/h264_intrapred_10bit.asm b/libavcodec/x86/h264_intrapred_10bit.asm index 24a7bfa875..e14e31a38c 100644 --- a/libavcodec/x86/h264_intrapred_10bit.asm +++ b/libavcodec/x86/h264_intrapred_10bit.asm @@ -27,8 +27,6 @@ SECTION_RODATA -SECTION .text - cextern pw_16 cextern pw_8 cextern pw_4 @@ -42,6 +40,8 @@ pw_512: times 8 dw 512 pd_17: times 4 dd 17 pd_16: times 4 dd 16 +SECTION .text + ; dest, left, right, src ; output: %1 = (t[n-1] + t[n]*2 + t[n+1] + 2) >> 2 %macro PRED4x4_LOWPASS 4 @@ -64,13 +64,11 @@ cglobal pred4x4_down_right_10_%1, 3,3 movq m3, [r0] punpckhdq m1, m2 PALIGNR m3, m1, 10, m1 - mova m1, m3 movhps m4, [r1+r2*1-8] - PALIGNR m3, m4, 14, m4 - mova m2, m3 + PALIGNR m0, m3, m4, 14, m4 movhps m4, [r1+r2*2-8] - PALIGNR m3, m4, 14, m4 - PRED4x4_LOWPASS m0, m3, m1, m2 + PALIGNR m2, m0, m4, 14, m4 + PRED4x4_LOWPASS m0, m2, m3, m0 movq [r1+r2*2], m0 psrldq m0, 2 movq [r1+r2*1], m0 @@ -104,22 +102,20 @@ cglobal pred4x4_vertical_right_10_%1, 3,3,6 pavgw m5, m0 movhps m1, [r0+r2*1-8] PALIGNR m0, m1, 14, m1 ; ....t3t2t1t0ltl0 - mova m1, m0 movhps m2, [r0+r2*2-8] - PALIGNR m0, m2, 14, m2 ; ..t3t2t1t0ltl0l1 - mova m2, m0 + PALIGNR m1, m0, m2, 14, m2 ; ..t3t2t1t0ltl0l1 movhps m3, [r1+r2*1-8] - PALIGNR m0, m3, 14, m3 ; t3t2t1t0ltl0l1l2 - PRED4x4_LOWPASS m3, m1, m0, m2 - pslldq m1, m3, 12 - psrldq m3, 4 + PALIGNR m2, m1, m3, 14, m3 ; t3t2t1t0ltl0l1l2 + PRED4x4_LOWPASS m1, m0, m2, m1 + pslldq m0, m1, 12 + psrldq m1, 4 movq [r0+r2*1], m5 - movq [r0+r2*2], m3 - PALIGNR m5, m1, 14, m2 - pslldq m1, 2 + movq [r0+r2*2], m1 + PALIGNR m5, m0, 14, m2 + pslldq m0, 2 movq [r1+r2*1], m5 - PALIGNR m3, m1, 14, m1 - movq [r1+r2*2], m3 + PALIGNR m1, m0, 14, m0 + movq [r1+r2*2], m1 RET %endmacro @@ -152,9 +148,9 @@ cglobal pred4x4_horizontal_down_10_%1, 3,3 punpckhdq m1, m2 ; l0 l1 l2 l3 punpckhqdq m1, m0 ; t2 t1 t0 lt l0 l1 l2 l3 psrldq m0, m1, 4 ; .. .. t2 t1 t0 lt l0 l1 - psrldq m2, m1, 2 ; .. t2 t1 t0 lt l0 l1 l2 - pavgw m5, m1, m2 - PRED4x4_LOWPASS m3, m1, m0, m2 + psrldq m3, m1, 2 ; .. t2 t1 t0 lt l0 l1 l2 + pavgw m5, m1, m3 + PRED4x4_LOWPASS m3, m1, m0, m3 punpcklwd m5, m3 psrldq m3, 8 PALIGNR m3, m5, 12, m4 @@ -220,17 +216,15 @@ cglobal pred4x4_dc_10_mmxext, 3,3 ;----------------------------------------------------------------------------- ; void pred4x4_down_left(pixel *src, const pixel *topright, int stride) ;----------------------------------------------------------------------------- -;TODO: more AVX here %macro PRED4x4_DL 1 cglobal pred4x4_down_left_10_%1, 3,3 sub r0, r2 - movq m1, [r0] - movhps m1, [r1] - pslldq m5, m1, 2 - pxor m2, m5, m1 - psrldq m2, 2 - pxor m3, m1, m2 - PRED4x4_LOWPASS m0, m5, m3, m1 + movq m0, [r0] + movhps m0, [r1] + psrldq m2, m0, 2 + pslldq m3, m0, 2 + pshufhw m2, m2, 10100100b + PRED4x4_LOWPASS m0, m3, m2, m0 lea r1, [r0+r2*2] movhps [r1+r2*2], m0 psrldq m0, 2 @@ -257,10 +251,10 @@ cglobal pred4x4_vertical_left_10_%1, 3,3 sub r0, r2 movu m1, [r0] movhps m1, [r1] - psrldq m3, m1, 2 + psrldq m0, m1, 2 psrldq m2, m1, 4 - pavgw m4, m3, m1 - PRED4x4_LOWPASS m0, m1, m2, m3 + pavgw m4, m0, m1 + PRED4x4_LOWPASS m0, m1, m2, m0 lea r1, [r0+r2*2] movq [r0+r2*1], m4 movq [r0+r2*2], m0 @@ -298,13 +292,13 @@ cglobal pred4x4_horizontal_up_10_mmxext, 3,3 pavgw m2, m0 pshufw m5, m0, 11111110b - PRED4x4_LOWPASS m3, m0, m5, m1 + PRED4x4_LOWPASS m1, m0, m5, m1 movq m6, m2 - punpcklwd m6, m3 + punpcklwd m6, m1 movq [r0+r2*1], m6 psrlq m2, 16 - psrlq m3, 16 - punpcklwd m2, m3 + psrlq m1, 16 + punpcklwd m2, m1 movq [r0+r2*2], m2 psrlq m2, 32 movd [r1+r2*1], m2 @@ -333,7 +327,7 @@ cglobal pred8x8_vertical_10_sse2, 2,2 ;----------------------------------------------------------------------------- INIT_XMM cglobal pred8x8_horizontal_10_sse2, 2,3 - mov r2, 4 + mov r2d, 4 .loop: movq m0, [r0+r1*0-8] movq m1, [r0+r1*1-8] @@ -344,7 +338,7 @@ cglobal pred8x8_horizontal_10_sse2, 2,3 mova [r0+r1*0], m0 mova [r0+r1*1], m1 lea r0, [r0+r1*2] - dec r2 + dec r2d jg .loop REP_RET @@ -362,53 +356,53 @@ cglobal pred8x8_horizontal_10_sse2, 2,3 %endmacro %macro PRED8x8_DC 2 -cglobal pred8x8_dc_10_%1, 2,4 -%ifdef ARCH_X86_64 -%define t0 r10 -%else -%define t0 r0m -%endif +cglobal pred8x8_dc_10_%1, 2,6 sub r0, r1 pxor m4, m4 movq m0, [r0+0] movq m1, [r0+8] - HADDW m0, m2 - mov t0, r0 - HADDW m1, m2 +%if mmsize==16 + punpcklwd m0, m1 + movhlps m1, m0 + paddw m0, m1 +%else + pshufw m2, m0, 00001110b + pshufw m3, m1, 00001110b + paddw m0, m2 + paddw m1, m3 + punpcklwd m0, m1 +%endif + %2 m2, m0, 00001110b + paddw m0, m2 + lea r5, [r1*3] + lea r4, [r0+r1*4] movzx r2d, word [r0+r1*1-2] movzx r3d, word [r0+r1*2-2] - lea r0, [r0+r1*2] add r2d, r3d - movzx r3d, word [r0+r1*1-2] + movzx r3d, word [r0+r5*1-2] add r2d, r3d - movzx r3d, word [r0+r1*2-2] + movzx r3d, word [r4-2] add r2d, r3d - lea r0, [r0+r1*2] movd m2, r2d ; s2 - movzx r2d, word [r0+r1*1-2] - movzx r3d, word [r0+r1*2-2] - lea r0, [r0+r1*2] + movzx r2d, word [r4+r1*1-2] + movzx r3d, word [r4+r1*2-2] add r2d, r3d - movzx r3d, word [r0+r1*1-2] + movzx r3d, word [r4+r5*1-2] add r2d, r3d - movzx r3d, word [r0+r1*2-2] + movzx r3d, word [r4+r1*4-2] add r2d, r3d movd m3, r2d ; s3 - punpcklwd m0, m1 - mov r0, t0 punpcklwd m2, m3 punpckldq m0, m2 ; s0, s1, s2, s3 %2 m3, m0, 11110110b ; s2, s1, s3, s3 - lea r2, [r1+r1*2] %2 m0, m0, 01110100b ; s0, s1, s3, s1 paddw m0, m3 - lea r3, [r0+r1*4] psrlw m0, 2 pavgw m0, m4 ; s0+s2, s1, s3, s1+s3 -%ifidn %1, sse2 +%if mmsize==16 punpcklwd m0, m0 pshufd m3, m0, 11111010b punpckldq m0, m0 @@ -421,12 +415,12 @@ cglobal pred8x8_dc_10_%1, 2,4 %endif MOV8 r0+r1*1, m1, m2 MOV8 r0+r1*2, m1, m2 - MOV8 r0+r2*1, m1, m2 + MOV8 r0+r5*1, m1, m2 MOV8 r0+r1*4, m1, m2 - MOV8 r3+r1*1, m3, m4 - MOV8 r3+r1*2, m3, m4 - MOV8 r3+r2*1, m3, m4 - MOV8 r3+r1*4, m3, m4 + MOV8 r4+r1*1, m3, m4 + MOV8 r4+r1*2, m3, m4 + MOV8 r4+r5*1, m3, m4 + MOV8 r4+r1*4, m3, m4 RET %endmacro @@ -438,39 +432,29 @@ PRED8x8_DC sse2 , pshuflw ;----------------------------------------------------------------------------- ; void pred8x8_top_dc(pixel *src, int stride) ;----------------------------------------------------------------------------- -%macro PRED8x8_TOP_DC 2 -cglobal pred8x8_top_dc_10_%1, 2,4 - sub r0, r1 - movq m0, [r0+0] - movq m1, [r0+8] - HADDW m0, m2 - HADDW m1, m3 - lea r2, [r1+r1*2] - paddw m0, [pw_2] - paddw m1, [pw_2] - lea r3, [r0+r1*4] - psrlw m0, 2 - psrlw m1, 2 - %2 m0, m0, 0 - %2 m1, m1, 0 -%ifidn %1, sse2 - punpcklqdq m0, m1 -%endif - MOV8 r0+r1*1, m0, m1 - MOV8 r0+r1*2, m0, m1 - MOV8 r0+r2*1, m0, m1 - MOV8 r0+r1*4, m0, m1 - MOV8 r3+r1*1, m0, m1 - MOV8 r3+r1*2, m0, m1 - MOV8 r3+r2*1, m0, m1 - MOV8 r3+r1*4, m0, m1 - RET -%endmacro - -INIT_MMX -PRED8x8_TOP_DC mmxext, pshufw INIT_XMM -PRED8x8_TOP_DC sse2 , pshuflw +cglobal pred8x8_top_dc_10_sse2, 2,4 + sub r0, r1 + mova m0, [r0] + pshuflw m1, m0, 0x4e + pshufhw m1, m1, 0x4e + paddw m0, m1 + pshuflw m1, m0, 0xb1 + pshufhw m1, m1, 0xb1 + paddw m0, m1 + lea r2, [r1*3] + lea r3, [r0+r1*4] + paddw m0, [pw_2] + psrlw m0, 2 + mova [r0+r1*1], m0 + mova [r0+r1*2], m0 + mova [r0+r2*1], m0 + mova [r0+r1*4], m0 + mova [r3+r1*1], m0 + mova [r3+r1*2], m0 + mova [r3+r2*1], m0 + mova [r3+r1*4], m0 + RET ;----------------------------------------------------------------------------- ; void pred8x8_plane(pixel *src, int stride) @@ -478,7 +462,7 @@ PRED8x8_TOP_DC sse2 , pshuflw INIT_XMM cglobal pred8x8_plane_10_sse2, 2,7,7 sub r0, r1 - lea r2, [r1+r1*2] + lea r2, [r1*3] lea r3, [r0+r1*4] mova m2, [r0] pmaddwd m2, [pw_m32101234] @@ -500,7 +484,7 @@ cglobal pred8x8_plane_10_sse2, 2,7,7 movzx r5d, word [r3+r2*1-2] ; src[6*stride-1] movzx r6d, word [r0+r1*1-2] ; src[0*stride-1] sub r5d, r6d - lea r5d, [r5+r5*2] + lea r5d, [r5*3] add r4d, r5d movzx r6d, word [r3+r1*4-2] ; src[7*stride-1] movzx r5d, word [r0+r1*0-2] ; src[ -stride-1] @@ -540,8 +524,8 @@ cglobal pred8x8_plane_10_sse2, 2,7,7 ;----------------------------------------------------------------------------- %macro PRED8x8L_128_DC 1 cglobal pred8x8l_128_dc_10_%1, 4,4 - mova m0, [pw_512] - lea r1, [r3+r3*2] + mova m0, [pw_512] ; (1<<(BIT_DEPTH-1)) + lea r1, [r3*3] lea r2, [r0+r3*4] MOV8 r0+r3*0, m0, m0 MOV8 r0+r3*1, m0, m0 @@ -565,37 +549,17 @@ PRED8x8L_128_DC sse2 %macro PRED8x8L_TOP_DC 1 cglobal pred8x8l_top_dc_10_%1, 4,4,6 sub r0, r3 - pxor m7, m7 - mova m0, [r0-16] - mova m3, [r0] - mova m1, [r0+16] - mova m2, m3 - mova m4, m3 - PALIGNR m2, m0, 14, m0 - PALIGNR m1, m4, 2, m4 - test r1, r1 ; top_left - jz .fix_lt_2 - test r2, r2 ; top_right - jz .fix_tr_1 - jmp .body -.fix_lt_2: - mova m5, m3 - pxor m5, m2 - pslldq m5, 14 - psrldq m5, 14 - pxor m2, m5 - test r2, r2 ; top_right - jnz .body -.fix_tr_1: - mova m5, m3 - pxor m5, m1 - psrldq m5, 14 - pslldq m5, 14 - pxor m1, m5 -.body - lea r1, [r3+r3*2] + mova m0, [r0] + shr r1d, 14 + shr r2d, 13 + neg r1 + pslldq m1, m0, 2 + psrldq m2, m0, 2 + pinsrw m1, [r0+r1], 0 + pinsrw m2, [r0+r2+14], 7 + lea r1, [r3*3] lea r2, [r0+r3*4] - PRED4x4_LOWPASS m0, m2, m1, m3 + PRED4x4_LOWPASS m0, m2, m1, m0 HADDW m0, m1 paddw m0, [pw_4] psrlw m0, 3 @@ -612,110 +576,70 @@ cglobal pred8x8l_top_dc_10_%1, 4,4,6 %endmacro INIT_XMM -%define PALIGNR PALIGNR_MMX PRED8x8L_TOP_DC sse2 -%define PALIGNR PALIGNR_SSSE3 -PRED8x8L_TOP_DC ssse3 +%ifdef HAVE_AVX +INIT_AVX +PRED8x8L_TOP_DC avx +%endif ;----------------------------------------------------------------------------- ;void pred8x8l_dc(pixel *src, int has_topleft, int has_topright, int stride) ;----------------------------------------------------------------------------- ;TODO: see if scalar is faster %macro PRED8x8L_DC 1 -cglobal pred8x8l_dc_10_%1, 4,5,8 +cglobal pred8x8l_dc_10_%1, 4,6,6 sub r0, r3 - lea r4, [r0+r3*2] - mova m0, [r0+r3*1-16] - punpckhwd m0, [r0+r3*0-16] - mova m1, [r4+r3*1-16] - punpckhwd m1, [r0+r3*2-16] - mov r4, r0 + lea r4, [r0+r3*4] + lea r5, [r3*3] + mova m0, [r0+r3*2-16] + punpckhwd m0, [r0+r3*1-16] + mova m1, [r4+r3*0-16] + punpckhwd m1, [r0+r5*1-16] punpckhdq m1, m0 - lea r0, [r0+r3*4] - mova m2, [r0+r3*1-16] - punpckhwd m2, [r0+r3*0-16] - lea r0, [r0+r3*2] - mova m3, [r0+r3*1-16] - punpckhwd m3, [r0+r3*0-16] + mova m2, [r4+r3*2-16] + punpckhwd m2, [r4+r3*1-16] + mova m3, [r4+r3*4-16] + punpckhwd m3, [r4+r5*1-16] punpckhdq m3, m2 punpckhqdq m3, m1 - lea r0, [r0+r3*2] - mova m0, [r0+r3*0-16] - mova m1, [r4] - mov r0, r4 - mova m4, m3 - mova m2, m3 - PALIGNR m4, m0, 14, m0 - PALIGNR m1, m2, 2, m2 - test r1, r1 - jnz .do_left -.fix_lt_1: - mova m5, m3 - pxor m5, m4 - psrldq m5, 14 - pslldq m5, 12 - pxor m1, m5 - jmp .do_left -.fix_lt_2: - mova m5, m3 - pxor m5, m2 - pslldq m5, 14 - psrldq m5, 14 - pxor m2, m5 - test r2, r2 - jnz .body -.fix_tr_1: - mova m5, m3 - pxor m5, m1 - psrldq m5, 14 - pslldq m5, 14 - pxor m1, m5 - jmp .body -.do_left: - mova m0, m4 - PRED4x4_LOWPASS m2, m1, m4, m3 - mova m4, m0 - mova m7, m2 - PRED4x4_LOWPASS m1, m3, m0, m4 - pslldq m1, 14 - PALIGNR m7, m1, 14, m3 - mova m0, [r0-16] - mova m3, [r0] - mova m1, [r0+16] - mova m2, m3 - mova m4, m3 - PALIGNR m2, m0, 14, m0 - PALIGNR m1, m4, 2, m4 - test r1, r1 - jz .fix_lt_2 - test r2, r2 - jz .fix_tr_1 -.body - lea r1, [r3+r3*2] - PRED4x4_LOWPASS m6, m2, m1, m3 - HADDW m7, m0 - HADDW m6, m0 - lea r2, [r0+r3*4] - paddw m7, [pw_8] - paddw m7, m6 - psrlw m7, 4 - SPLATW m7, m7 - mova [r0+r3*1], m7 - mova [r0+r3*2], m7 - mova [r0+r1*1], m7 - mova [r0+r3*4], m7 - mova [r2+r3*1], m7 - mova [r2+r3*2], m7 - mova [r2+r1*1], m7 - mova [r2+r3*4], m7 + mova m0, [r0] + shr r1d, 14 + shr r2d, 13 + neg r1 + pslldq m1, m0, 2 + psrldq m2, m0, 2 + pinsrw m1, [r0+r1], 0 + pinsrw m2, [r0+r2+14], 7 + not r1 + and r1, r3 + pslldq m4, m3, 2 + psrldq m5, m3, 2 + pshuflw m4, m4, 11100101b + pinsrw m5, [r0+r1-2], 7 + PRED4x4_LOWPASS m3, m4, m5, m3 + PRED4x4_LOWPASS m0, m2, m1, m0 + paddw m0, m3 + HADDW m0, m1 + paddw m0, [pw_8] + psrlw m0, 4 + SPLATW m0, m0 + mova [r0+r3*1], m0 + mova [r0+r3*2], m0 + mova [r0+r5*1], m0 + mova [r0+r3*4], m0 + mova [r4+r3*1], m0 + mova [r4+r3*2], m0 + mova [r4+r5*1], m0 + mova [r4+r3*4], m0 RET %endmacro INIT_XMM -%define PALIGNR PALIGNR_MMX PRED8x8L_DC sse2 -%define PALIGNR PALIGNR_SSSE3 -PRED8x8L_DC ssse3 +%ifdef HAVE_AVX +INIT_AVX +PRED8x8L_DC avx +%endif ;----------------------------------------------------------------------------- ; void pred8x8l_vertical(pixel *src, int has_topleft, int has_topright, int stride) @@ -723,36 +647,17 @@ PRED8x8L_DC ssse3 %macro PRED8x8L_VERTICAL 1 cglobal pred8x8l_vertical_10_%1, 4,4,6 sub r0, r3 - mova m0, [r0-16] - mova m3, [r0] - mova m1, [r0+16] - mova m2, m3 - mova m4, m3 - PALIGNR m2, m0, 14, m0 - PALIGNR m1, m4, 2, m4 - test r1, r1 ; top_left - jz .fix_lt_2 - test r2, r2 ; top_right - jz .fix_tr_1 - jmp .body -.fix_lt_2: - mova m5, m3 - pxor m5, m2 - pslldq m5, 14 - psrldq m5, 14 - pxor m2, m5 - test r2, r2 ; top_right - jnz .body -.fix_tr_1: - mova m5, m3 - pxor m5, m1 - psrldq m5, 14 - pslldq m5, 14 - pxor m1, m5 -.body - lea r1, [r3+r3*2] + mova m0, [r0] + shr r1d, 14 + shr r2d, 13 + neg r1 + pslldq m1, m0, 2 + psrldq m2, m0, 2 + pinsrw m1, [r0+r1], 0 + pinsrw m2, [r0+r2+14], 7 + lea r1, [r3*3] lea r2, [r0+r3*4] - PRED4x4_LOWPASS m0, m2, m1, m3 + PRED4x4_LOWPASS m0, m2, m1, m0 mova [r0+r3*1], m0 mova [r0+r3*2], m0 mova [r0+r1*1], m0 @@ -765,70 +670,56 @@ cglobal pred8x8l_vertical_10_%1, 4,4,6 %endmacro INIT_XMM -%define PALIGNR PALIGNR_MMX PRED8x8L_VERTICAL sse2 -%define PALIGNR PALIGNR_SSSE3 -PRED8x8L_VERTICAL ssse3 +%ifdef HAVE_AVX +INIT_AVX +PRED8x8L_VERTICAL avx +%endif ;----------------------------------------------------------------------------- ; void pred8x8l_horizontal(uint8_t *src, int has_topleft, int has_topright, int stride) ;----------------------------------------------------------------------------- %macro PRED8x8L_HORIZONTAL 1 -cglobal pred8x8l_horizontal_10_%1, 4,4,8 - sub r0, r3 - lea r2, [r0+r3*2] - mova m0, [r0+r3*1-16] - test r1, r1 - lea r1, [r0+r3] - cmovnz r1, r0 - punpckhwd m0, [r1+r3*0-16] - mova m1, [r2+r3*1-16] - punpckhwd m1, [r0+r3*2-16] - mov r2, r0 +cglobal pred8x8l_horizontal_10_%1, 4,4,5 + mova m0, [r0-16] + shr r1d, 14 + dec r1 + and r1, r3 + sub r1, r3 + punpckhwd m0, [r0+r1-16] + mova m1, [r0+r3*2-16] + punpckhwd m1, [r0+r3*1-16] + lea r2, [r0+r3*4] + lea r1, [r3*3] punpckhdq m1, m0 - lea r0, [r0+r3*4] - mova m2, [r0+r3*1-16] - punpckhwd m2, [r0+r3*0-16] - lea r0, [r0+r3*2] - mova m3, [r0+r3*1-16] - punpckhwd m3, [r0+r3*0-16] + mova m2, [r2+r3*0-16] + punpckhwd m2, [r0+r1-16] + mova m3, [r2+r3*2-16] + punpckhwd m3, [r2+r3*1-16] punpckhdq m3, m2 punpckhqdq m3, m1 - lea r0, [r0+r3*2] - mova m0, [r0+r3*0-16] - mova m1, [r1+r3*0-16] - mov r0, r2 - mova m4, m3 - mova m2, m3 - PALIGNR m4, m0, 14, m0 - PALIGNR m1, m2, 2, m2 - mova m0, m4 - PRED4x4_LOWPASS m2, m1, m4, m3 - mova m4, m0 - mova m7, m2 - PRED4x4_LOWPASS m1, m3, m0, m4 - pslldq m1, 14 - PALIGNR m7, m1, 14, m3 - lea r1, [r3+r3*2] - punpckhwd m3, m7, m7 - punpcklwd m7, m7 + PALIGNR m4, m3, [r2+r1-16], 14, m0 + pslldq m0, m4, 2 + pshuflw m0, m0, 11100101b + PRED4x4_LOWPASS m4, m3, m0, m4 + punpckhwd m3, m4, m4 + punpcklwd m4, m4 pshufd m0, m3, 0xff pshufd m1, m3, 0xaa - lea r2, [r0+r3*4] pshufd m2, m3, 0x55 pshufd m3, m3, 0x00 - pshufd m4, m7, 0xff - pshufd m5, m7, 0xaa - pshufd m6, m7, 0x55 - pshufd m7, m7, 0x00 - mova [r0+r3*1], m0 - mova [r0+r3*2], m1 - mova [r0+r1*1], m2 - mova [r0+r3*4], m3 - mova [r2+r3*1], m4 - mova [r2+r3*2], m5 - mova [r2+r1*1], m6 - mova [r2+r3*4], m7 + mova [r0+r3*0], m0 + mova [r0+r3*1], m1 + mova [r0+r3*2], m2 + mova [r0+r1*1], m3 + pshufd m0, m4, 0xff + pshufd m1, m4, 0xaa + pshufd m2, m4, 0x55 + pshufd m3, m4, 0x00 + mova [r2+r3*0], m0 + mova [r2+r3*1], m1 + mova [r2+r3*2], m2 + mova [r2+r1*1], m3 RET %endmacro @@ -837,116 +728,68 @@ INIT_XMM PRED8x8L_HORIZONTAL sse2 %define PALIGNR PALIGNR_SSSE3 PRED8x8L_HORIZONTAL ssse3 +%ifdef HAVE_AVX +INIT_AVX +PRED8x8L_HORIZONTAL avx +%endif ;----------------------------------------------------------------------------- ;void pred8x8l_down_left(pixel *src, int has_topleft, int has_topright, int stride) ;----------------------------------------------------------------------------- %macro PRED8x8L_DOWN_LEFT 1 -cglobal pred8x8l_down_left_10_%1, 4,4,8 +cglobal pred8x8l_down_left_10_%1, 4,4,7 sub r0, r3 - mova m0, [r0-16] mova m3, [r0] + shr r1d, 14 + neg r1 + shr r2d, 13 + pslldq m1, m3, 2 + psrldq m2, m3, 2 + pinsrw m1, [r0+r1], 0 + pinsrw m2, [r0+r2+14], 7 + PRED4x4_LOWPASS m6, m2, m1, m3 + jz .fix_tr ; flags from shr r2d mova m1, [r0+16] - mova m2, m3 - mova m4, m3 - PALIGNR m2, m0, 14, m0 - PALIGNR m1, m4, 2, m4 - test r1, r1 - jz .fix_lt_2 - test r2, r2 - jz .fix_tr_1 - jmp .do_top -.fix_lt_2: - mova m5, m3 - pxor m5, m2 - pslldq m5, 14 - psrldq m5, 14 - pxor m2, m5 - test r2, r2 - jnz .do_top -.fix_tr_1: - mova m5, m3 - pxor m5, m1 - psrldq m5, 14 - pslldq m5, 14 - pxor m1, m5 - jmp .do_top -.fix_tr_2: + psrldq m5, m1, 2 + PALIGNR m2, m1, m3, 14, m3 + pshufhw m5, m5, 10100100b + PRED4x4_LOWPASS m1, m2, m5, m1 +.do_topright: + lea r1, [r3*3] + psrldq m5, m1, 14 + lea r2, [r0+r3*4] + PALIGNR m2, m1, m6, 2, m0 + PALIGNR m3, m1, m6, 14, m0 + PALIGNR m5, m1, 2, m0 + pslldq m4, m6, 2 + PRED4x4_LOWPASS m6, m4, m2, m6 + PRED4x4_LOWPASS m1, m3, m5, m1 + mova [r2+r3*4], m1 + PALIGNR m1, m6, 14, m2 + pslldq m6, 2 + mova [r2+r1*1], m1 + PALIGNR m1, m6, 14, m2 + pslldq m6, 2 + mova [r2+r3*2], m1 + PALIGNR m1, m6, 14, m2 + pslldq m6, 2 + mova [r2+r3*1], m1 + PALIGNR m1, m6, 14, m2 + pslldq m6, 2 + mova [r0+r3*4], m1 + PALIGNR m1, m6, 14, m2 + pslldq m6, 2 + mova [r0+r1*1], m1 + PALIGNR m1, m6, 14, m2 + pslldq m6, 2 + mova [r0+r3*2], m1 + PALIGNR m1, m6, 14, m6 + mova [r0+r3*1], m1 + RET +.fix_tr: punpckhwd m3, m3 pshufd m1, m3, 0xFF jmp .do_topright -.do_top: - PRED4x4_LOWPASS m4, m2, m1, m3 - mova m7, m4 - test r2, r2 - jz .fix_tr_2 - mova m0, [r0+16] - mova m5, m0 - mova m2, m0 - mova m4, m0 - psrldq m5, 14 - PALIGNR m2, m3, 14, m3 - PALIGNR m5, m4, 2, m4 - PRED4x4_LOWPASS m1, m2, m5, m0 -.do_topright: - lea r1, [r3+r3*2] - mova m6, m1 - psrldq m1, 14 - mova m4, m1 - lea r2, [r0+r3*4] - mova m2, m6 - PALIGNR m2, m7, 2, m0 - mova m3, m6 - PALIGNR m3, m7, 14, m0 - PALIGNR m4, m6, 2, m0 - mova m5, m7 - mova m1, m7 - mova m7, m6 - pslldq m1, 2 - PRED4x4_LOWPASS m0, m1, m2, m5 - PRED4x4_LOWPASS m1, m3, m4, m7 - mova [r2+r3*4], m1 - mova m2, m0 - pslldq m1, 2 - psrldq m2, 14 - pslldq m0, 2 - por m1, m2 - mova [r2+r1*1], m1 - mova m2, m0 - pslldq m1, 2 - psrldq m2, 14 - pslldq m0, 2 - por m1, m2 - mova [r2+r3*2], m1 - mova m2, m0 - pslldq m1, 2 - psrldq m2, 14 - pslldq m0, 2 - por m1, m2 - mova [r2+r3*1], m1 - mova m2, m0 - pslldq m1, 2 - psrldq m2, 14 - pslldq m0, 2 - por m1, m2 - mova [r0+r3*4], m1 - mova m2, m0 - pslldq m1, 2 - psrldq m2, 14 - pslldq m0, 2 - por m1, m2 - mova [r0+r1*1], m1 - mova m2, m0 - pslldq m1, 2 - psrldq m2, 14 - pslldq m0, 2 - por m1, m2 - mova [r0+r3*2], m1 - pslldq m1, 2 - psrldq m0, 14 - por m1, m0 - mova [r0+r3*1], m1 - RET %endmacro INIT_XMM @@ -954,139 +797,73 @@ INIT_XMM PRED8x8L_DOWN_LEFT sse2 %define PALIGNR PALIGNR_SSSE3 PRED8x8L_DOWN_LEFT ssse3 +%ifdef HAVE_AVX +INIT_AVX +PRED8x8L_DOWN_LEFT avx +%endif ;----------------------------------------------------------------------------- -;void pred8x8l_down_right_mxext(pixel *src, int has_topleft, int has_topright, int stride) +;void pred8x8l_down_right(pixel *src, int has_topleft, int has_topright, int stride) ;----------------------------------------------------------------------------- %macro PRED8x8L_DOWN_RIGHT 1 +; standard forbids this when has_topleft is false +; no need to check cglobal pred8x8l_down_right_10_%1, 4,5,8 sub r0, r3 - lea r4, [r0+r3*2] + lea r4, [r0+r3*4] + lea r1, [r3*3] mova m0, [r0+r3*1-16] punpckhwd m0, [r0+r3*0-16] - mova m1, [r4+r3*1-16] + mova m1, [r0+r1*1-16] punpckhwd m1, [r0+r3*2-16] - mov r4, r0 punpckhdq m1, m0 - lea r0, [r0+r3*4] - mova m2, [r0+r3*1-16] - punpckhwd m2, [r0+r3*0-16] - lea r0, [r0+r3*2] - mova m3, [r0+r3*1-16] - punpckhwd m3, [r0+r3*0-16] + mova m2, [r4+r3*1-16] + punpckhwd m2, [r4+r3*0-16] + mova m3, [r4+r1*1-16] + punpckhwd m3, [r4+r3*2-16] punpckhdq m3, m2 punpckhqdq m3, m1 - lea r0, [r0+r3*2] - mova m0, [r0+r3*0-16] - mova m1, [r4] - mov r0, r4 - mova m4, m3 - mova m2, m3 - PALIGNR m4, m0, 14, m0 - PALIGNR m1, m2, 2, m2 - test r1, r1 ; top_left - jz .fix_lt_1 -.do_left: - mova m0, m4 - PRED4x4_LOWPASS m2, m1, m4, m3 - mova m4, m0 - mova m7, m2 - mova m6, m2 - PRED4x4_LOWPASS m1, m3, m0, m4 - pslldq m1, 14 - PALIGNR m7, m1, 14, m3 - mova m0, [r0-16] + mova m0, [r4+r3*4-16] + mova m1, [r0] + PALIGNR m4, m3, m0, 14, m0 + PALIGNR m1, m3, 2, m2 + pslldq m0, m4, 2 + pshuflw m0, m0, 11100101b + PRED4x4_LOWPASS m6, m1, m4, m3 + PRED4x4_LOWPASS m4, m3, m0, m4 mova m3, [r0] - mova m1, [r0+16] - mova m2, m3 - mova m4, m3 - PALIGNR m2, m0, 14, m0 - PALIGNR m1, m4, 2, m4 - test r1, r1 ; top_left - jz .fix_lt_2 - test r2, r2 ; top_right - jz .fix_tr_1 -.do_top: - PRED4x4_LOWPASS m4, m2, m1, m3 - mova m5, m4 - jmp .body -.fix_lt_1: - mova m5, m3 - pxor m5, m4 - psrldq m5, 14 - pslldq m5, 12 - pxor m1, m5 - jmp .do_left -.fix_lt_2: - mova m5, m3 - pxor m5, m2 - pslldq m5, 14 - psrldq m5, 14 - pxor m2, m5 - test r2, r2 ; top_right - jnz .do_top -.fix_tr_1: - mova m5, m3 - pxor m5, m1 - psrldq m5, 14 - pslldq m5, 14 - pxor m1, m5 - jmp .do_top -.body - lea r1, [r3+r3*2] - mova m1, m7 - mova m7, m5 - mova m5, m6 - mova m2, m7 - lea r2, [r0+r3*4] - PALIGNR m2, m6, 2, m0 - mova m3, m7 - PALIGNR m3, m6, 14, m0 - mova m4, m7 - psrldq m4, 2 - PRED4x4_LOWPASS m0, m1, m2, m5 - PRED4x4_LOWPASS m1, m3, m4, m7 - mova [r2+r3*4], m0 - mova m2, m1 - psrldq m0, 2 - pslldq m2, 14 - psrldq m1, 2 - por m0, m2 - mova [r2+r1*1], m0 - mova m2, m1 - psrldq m0, 2 - pslldq m2, 14 - psrldq m1, 2 - por m0, m2 - mova [r2+r3*2], m0 - mova m2, m1 - psrldq m0, 2 - pslldq m2, 14 - psrldq m1, 2 - por m0, m2 - mova [r2+r3*1], m0 - mova m2, m1 - psrldq m0, 2 - pslldq m2, 14 - psrldq m1, 2 - por m0, m2 - mova [r0+r3*4], m0 - mova m2, m1 - psrldq m0, 2 - pslldq m2, 14 - psrldq m1, 2 - por m0, m2 - mova [r0+r1*1], m0 - mova m2, m1 - psrldq m0, 2 - pslldq m2, 14 - psrldq m1, 2 - por m0, m2 - mova [r0+r3*2], m0 - psrldq m0, 2 - pslldq m1, 14 - por m0, m1 - mova [r0+r3*1], m0 + shr r2d, 13 + pslldq m1, m3, 2 + psrldq m2, m3, 2 + pinsrw m1, [r0-2], 0 + pinsrw m2, [r0+r2+14], 7 + PRED4x4_LOWPASS m3, m2, m1, m3 + PALIGNR m2, m3, m6, 2, m0 + PALIGNR m5, m3, m6, 14, m0 + psrldq m7, m3, 2 + PRED4x4_LOWPASS m6, m4, m2, m6 + PRED4x4_LOWPASS m3, m5, m7, m3 + mova [r4+r3*4], m6 + PALIGNR m3, m6, 14, m2 + pslldq m6, 2 + mova [r0+r3*1], m3 + PALIGNR m3, m6, 14, m2 + pslldq m6, 2 + mova [r0+r3*2], m3 + PALIGNR m3, m6, 14, m2 + pslldq m6, 2 + mova [r0+r1*1], m3 + PALIGNR m3, m6, 14, m2 + pslldq m6, 2 + mova [r0+r3*4], m3 + PALIGNR m3, m6, 14, m2 + pslldq m6, 2 + mova [r4+r3*1], m3 + PALIGNR m3, m6, 14, m2 + pslldq m6, 2 + mova [r4+r3*2], m3 + PALIGNR m3, m6, 14, m6 + mova [r4+r1*1], m3 RET %endmacro @@ -1095,114 +872,69 @@ INIT_XMM PRED8x8L_DOWN_RIGHT sse2 %define PALIGNR PALIGNR_SSSE3 PRED8x8L_DOWN_RIGHT ssse3 +%ifdef HAVE_AVX +INIT_AVX +PRED8x8L_DOWN_RIGHT avx +%endif ;----------------------------------------------------------------------------- ; void pred8x8l_vertical_right(pixel *src, int has_topleft, int has_topright, int stride) ;----------------------------------------------------------------------------- %macro PRED8x8L_VERTICAL_RIGHT 1 -cglobal pred8x8l_vertical_right_10_%1, 4,5,8 +; likewise with 8x8l_down_right +cglobal pred8x8l_vertical_right_10_%1, 4,5,7 sub r0, r3 - lea r4, [r0+r3*2] + lea r4, [r0+r3*4] + lea r1, [r3*3] mova m0, [r0+r3*1-16] punpckhwd m0, [r0+r3*0-16] - mova m1, [r4+r3*1-16] + mova m1, [r0+r1*1-16] punpckhwd m1, [r0+r3*2-16] - mov r4, r0 punpckhdq m1, m0 - lea r0, [r0+r3*4] - mova m2, [r0+r3*1-16] - punpckhwd m2, [r0+r3*0-16] - lea r0, [r0+r3*2] - mova m3, [r0+r3*1-16] - punpckhwd m3, [r0+r3*0-16] + mova m2, [r4+r3*1-16] + punpckhwd m2, [r4+r3*0-16] + mova m3, [r4+r1*1-16] + punpckhwd m3, [r4+r3*2-16] punpckhdq m3, m2 punpckhqdq m3, m1 - lea r0, [r0+r3*2] - mova m0, [r0+r3*0-16] - mova m1, [r4] - mov r0, r4 - mova m4, m3 - mova m2, m3 - PALIGNR m4, m0, 14, m0 - PALIGNR m1, m2, 2, m2 - test r1, r1 - jz .fix_lt_1 - jmp .do_left -.fix_lt_1: - mova m5, m3 - pxor m5, m4 - psrldq m5, 14 - pslldq m5, 12 - pxor m1, m5 - jmp .do_left -.fix_lt_2: - mova m5, m3 - pxor m5, m2 - pslldq m5, 14 - psrldq m5, 14 - pxor m2, m5 - test r2, r2 - jnz .do_top -.fix_tr_1: - mova m5, m3 - pxor m5, m1 - psrldq m5, 14 - pslldq m5, 14 - pxor m1, m5 - jmp .do_top -.do_left: - mova m0, m4 - PRED4x4_LOWPASS m2, m1, m4, m3 - mova m7, m2 - mova m0, [r0-16] - mova m3, [r0] - mova m1, [r0+16] - mova m2, m3 - mova m4, m3 - PALIGNR m2, m0, 14, m0 - PALIGNR m1, m4, 2, m4 - test r1, r1 - jz .fix_lt_2 - test r2, r2 - jz .fix_tr_1 -.do_top - PRED4x4_LOWPASS m6, m2, m1, m3 - lea r1, [r3+r3*2] - mova m2, m6 - mova m3, m6 - PALIGNR m3, m7, 14, m0 - PALIGNR m6, m7, 12, m1 - mova m4, m3 - pavgw m3, m2 - lea r2, [r0+r3*4] - PRED4x4_LOWPASS m0, m6, m2, m4 - mova [r0+r3*1], m3 + mova m0, [r4+r3*4-16] + mova m1, [r0] + PALIGNR m4, m3, m0, 14, m0 + PALIGNR m1, m3, 2, m2 + PRED4x4_LOWPASS m3, m1, m4, m3 + mova m2, [r0] + shr r2d, 13 + pslldq m1, m2, 2 + psrldq m5, m2, 2 + pinsrw m1, [r0-2], 0 + pinsrw m5, [r0+r2+14], 7 + PRED4x4_LOWPASS m2, m5, m1, m2 + PALIGNR m6, m2, m3, 12, m1 + PALIGNR m5, m2, m3, 14, m0 + PRED4x4_LOWPASS m0, m6, m2, m5 + pavgw m2, m5 mova [r0+r3*2], m0 - mova m5, m0 - mova m6, m3 - mova m1, m7 - mova m2, m1 - pslldq m2, 2 - mova m3, m1 - pslldq m3, 4 - PRED4x4_LOWPASS m0, m1, m3, m2 - PALIGNR m6, m0, 14, m2 - mova [r0+r1*1], m6 - pslldq m0, 2 - PALIGNR m5, m0, 14, m1 - mova [r0+r3*4], m5 - pslldq m0, 2 - PALIGNR m6, m0, 14, m2 - mova [r2+r3*1], m6 - pslldq m0, 2 - PALIGNR m5, m0, 14, m1 - mova [r2+r3*2], m5 - pslldq m0, 2 - PALIGNR m6, m0, 14, m2 - mova [r2+r1*1], m6 - pslldq m0, 2 - PALIGNR m5, m0, 14, m1 - mova [r2+r3*4], m5 + mova [r0+r3*1], m2 + pslldq m6, m3, 4 + pslldq m1, m3, 2 + PRED4x4_LOWPASS m1, m3, m6, m1 + PALIGNR m2, m1, 14, m4 + mova [r0+r1*1], m2 + pslldq m1, 2 + PALIGNR m0, m1, 14, m3 + mova [r0+r3*4], m0 + pslldq m1, 2 + PALIGNR m2, m1, 14, m4 + mova [r4+r3*1], m2 + pslldq m1, 2 + PALIGNR m0, m1, 14, m3 + mova [r4+r3*2], m0 + pslldq m1, 2 + PALIGNR m2, m1, 14, m4 + mova [r4+r1*1], m2 + pslldq m1, 2 + PALIGNR m0, m1, 14, m1 + mova [r4+r3*4], m0 RET %endmacro @@ -1211,84 +943,60 @@ INIT_XMM PRED8x8L_VERTICAL_RIGHT sse2 %define PALIGNR PALIGNR_SSSE3 PRED8x8L_VERTICAL_RIGHT ssse3 +%ifdef HAVE_AVX +INIT_AVX +PRED8x8L_VERTICAL_RIGHT avx +%endif ;----------------------------------------------------------------------------- ; void pred8x8l_horizontal_up(pixel *src, int has_topleft, int has_topright, int stride) ;----------------------------------------------------------------------------- %macro PRED8x8L_HORIZONTAL_UP 1 -cglobal pred8x8l_horizontal_up_10_%1, 4,4,8 - sub r0, r3 - lea r2, [r0+r3*2] - mova m0, [r0+r3*1-16] - test r1, r1 - lea r1, [r0+r3] - cmovnz r1, r0 - punpckhwd m0, [r1+r3*0-16] - mova m1, [r2+r3*1-16] - punpckhwd m1, [r0+r3*2-16] - mov r2, r0 - punpckhdq m1, m0 - lea r0, [r0+r3*4] - mova m2, [r0+r3*1-16] - punpckhwd m2, [r0+r3*0-16] - lea r0, [r0+r3*2] - mova m3, [r0+r3*1-16] - punpckhwd m3, [r0+r3*0-16] - punpckhdq m3, m2 - punpckhqdq m3, m1 - lea r0, [r0+r3*2] +cglobal pred8x8l_horizontal_up_10_%1, 4,4,6 mova m0, [r0+r3*0-16] - mova m1, [r1+r3*0-16] - mov r0, r2 - mova m4, m3 - mova m2, m3 - PALIGNR m4, m0, 14, m0 - PALIGNR m1, m2, 2, m2 - mova m0, m4 - PRED4x4_LOWPASS m2, m1, m4, m3 - mova m4, m0 - mova m7, m2 - PRED4x4_LOWPASS m1, m3, m0, m4 - pslldq m1, 14 - PALIGNR m7, m1, 14, m3 - lea r1, [r3+r3*2] - pshufd m0, m7, 00011011b ; l6 l7 l4 l5 l2 l3 l0 l1 - pslldq m7, 14 ; l7 .. .. .. .. .. .. .. - mova m2, m0 - pslld m0, 16 - psrld m2, 16 - por m2, m0 ; l7 l6 l5 l4 l3 l2 l1 l0 - mova m3, m2 - mova m4, m2 - mova m5, m2 - psrldq m2, 2 - psrldq m3, 4 + punpckhwd m0, [r0+r3*1-16] + shr r1d, 14 + dec r1 + and r1, r3 + sub r1, r3 + mova m4, [r0+r1*1-16] + lea r1, [r3*3] lea r2, [r0+r3*4] - por m2, m7 ; l7 l7 l6 l5 l4 l3 l2 l1 - punpckhwd m7, m7 - por m3, m7 ; l7 l7 l7 l6 l5 l4 l3 l2 - pavgw m4, m2 - PRED4x4_LOWPASS m1, m3, m5, m2 - mova m5, m4 - punpcklwd m4, m1 ; p4 p3 p2 p1 - punpckhwd m5, m1 ; p8 p7 p6 p5 - mova m6, m5 - mova m7, m5 - mova m0, m5 - PALIGNR m5, m4, 4, m1 - pshufd m1, m6, 11111001b - PALIGNR m6, m4, 8, m2 - pshufd m2, m7, 11111110b - PALIGNR m7, m4, 12, m3 - pshufd m3, m0, 11111111b - mova [r0+r3*1], m4 - mova [r0+r3*2], m5 - mova [r0+r1*1], m6 - mova [r0+r3*4], m7 + mova m1, [r0+r3*2-16] + punpckhwd m1, [r0+r1*1-16] + punpckhdq m0, m1 + mova m2, [r2+r3*0-16] + punpckhwd m2, [r2+r3*1-16] + mova m3, [r2+r3*2-16] + punpckhwd m3, [r2+r1*1-16] + punpckhdq m2, m3 + punpckhqdq m0, m2 + PALIGNR m1, m0, m4, 14, m4 + psrldq m2, m0, 2 + pshufhw m2, m2, 10100100b + PRED4x4_LOWPASS m0, m1, m2, m0 + psrldq m1, m0, 2 + psrldq m2, m0, 4 + pshufhw m1, m1, 10100100b + pshufhw m2, m2, 01010100b + pavgw m4, m0, m1 + PRED4x4_LOWPASS m1, m2, m0, m1 + punpckhwd m5, m4, m1 + punpcklwd m4, m1 + mova [r2+r3*0], m5 + mova [r0+r3*0], m4 + pshufd m0, m5, 11111001b + pshufd m1, m5, 11111110b + pshufd m2, m5, 11111111b mova [r2+r3*1], m0 mova [r2+r3*2], m1 mova [r2+r1*1], m2 - mova [r2+r3*4], m3 + PALIGNR m2, m5, m4, 4, m0 + PALIGNR m3, m5, m4, 8, m1 + PALIGNR m5, m5, m4, 12, m4 + mova [r0+r3*1], m2 + mova [r0+r3*2], m3 + mova [r0+r1*1], m5 RET %endmacro @@ -1297,7 +1005,10 @@ INIT_XMM PRED8x8L_HORIZONTAL_UP sse2 %define PALIGNR PALIGNR_SSSE3 PRED8x8L_HORIZONTAL_UP ssse3 - +%ifdef HAVE_AVX +INIT_AVX +PRED8x8L_HORIZONTAL_UP avx +%endif ;----------------------------------------------------------------------------- @@ -1315,7 +1026,7 @@ PRED8x8L_HORIZONTAL_UP ssse3 %macro PRED16x16_VERTICAL 1 cglobal pred16x16_vertical_10_%1, 2,3 sub r0, r1 - mov r2, 8 + mov r2d, 8 mova m0, [r0+ 0] mova m1, [r0+mmsize] %if mmsize==8 @@ -1326,7 +1037,7 @@ cglobal pred16x16_vertical_10_%1, 2,3 MOV16 r0+r1*1, m0, m1, m2, m3 MOV16 r0+r1*2, m0, m1, m2, m3 lea r0, [r0+r1*2] - dec r2 + dec r2d jg .loop REP_RET %endmacro @@ -1341,7 +1052,7 @@ PRED16x16_VERTICAL sse2 ;----------------------------------------------------------------------------- %macro PRED16x16_HORIZONTAL 1 cglobal pred16x16_horizontal_10_%1, 2,3 - mov r2, 8 + mov r2d, 8 .vloop: movd m0, [r0+r1*0-4] movd m1, [r0+r1*1-4] @@ -1350,7 +1061,7 @@ cglobal pred16x16_horizontal_10_%1, 2,3 MOV16 r0+r1*0, m0, m0, m0, m0 MOV16 r0+r1*1, m1, m1, m1, m1 lea r0, [r0+r1*2] - dec r2 + dec r2d jg .vloop REP_RET %endmacro @@ -1364,8 +1075,8 @@ PRED16x16_HORIZONTAL sse2 ; void pred16x16_dc(pixel *src, int stride) ;----------------------------------------------------------------------------- %macro PRED16x16_DC 1 -cglobal pred16x16_dc_10_%1, 2,7 - mov r4, r0 +cglobal pred16x16_dc_10_%1, 2,6 + mov r5, r0 sub r0, r1 mova m0, [r0+0] paddw m0, [r0+mmsize] @@ -1375,17 +1086,17 @@ cglobal pred16x16_dc_10_%1, 2,7 %endif HADDW m0, m2 - sub r0, 2 - movzx r3d, word [r0+r1*1] - movzx r5d, word [r0+r1*2] + lea r0, [r0+r1-2] + movzx r3d, word [r0] + movzx r4d, word [r0+r1] %rep 7 lea r0, [r0+r1*2] - movzx r2d, word [r0+r1*1] + movzx r2d, word [r0] add r3d, r2d - movzx r2d, word [r0+r1*2] - add r5d, r2d + movzx r2d, word [r0+r1] + add r4d, r2d %endrep - lea r3d, [r3+r5+16] + lea r3d, [r3+r4+16] movd m1, r3d paddw m0, m1 @@ -1393,9 +1104,9 @@ cglobal pred16x16_dc_10_%1, 2,7 SPLATW m0, m0 mov r3d, 8 .loop: - MOV16 r4+r1*0, m0, m0, m0, m0 - MOV16 r4+r1*1, m0, m0, m0, m0 - lea r4, [r4+r1*2] + MOV16 r5+r1*0, m0, m0, m0, m0 + MOV16 r5+r1*1, m0, m0, m0, m0 + lea r5, [r5+r1*2] dec r3d jg .loop REP_RET @@ -1442,29 +1153,29 @@ PRED16x16_TOP_DC sse2 ; void pred16x16_left_dc(pixel *src, int stride) ;----------------------------------------------------------------------------- %macro PRED16x16_LEFT_DC 1 -cglobal pred16x16_left_dc_10_%1, 2,7 - mov r4, r0 +cglobal pred16x16_left_dc_10_%1, 2,6 + mov r5, r0 sub r0, 2 - movzx r5d, word [r0+r1*0] - movzx r6d, word [r0+r1*1] + movzx r3d, word [r0] + movzx r4d, word [r0+r1] %rep 7 lea r0, [r0+r1*2] - movzx r2d, word [r0+r1*0] - movzx r3d, word [r0+r1*1] - add r5d, r2d - add r6d, r3d + movzx r2d, word [r0] + add r3d, r2d + movzx r2d, word [r0+r1] + add r4d, r2d %endrep - lea r2d, [r5+r6+8] - shr r2d, 4 + lea r3d, [r3+r4+8] + shr r3d, 4 - movd m0, r2d + movd m0, r3d SPLATW m0, m0 mov r3d, 8 .loop: - MOV16 r4+r1*0, m0, m0, m0, m0 - MOV16 r4+r1*1, m0, m0, m0, m0 - lea r4, [r4+r1*2] + MOV16 r5+r1*0, m0, m0, m0, m0 + MOV16 r5+r1*1, m0, m0, m0, m0 + lea r5, [r5+r1*2] dec r3d jg .loop REP_RET diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c index 62e4c8796b..55387f623e 100644 --- a/libavcodec/x86/h264_intrapred_init.c +++ b/libavcodec/x86/h264_intrapred_init.c @@ -45,7 +45,6 @@ void ff_pred8x8_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, int stride); PRED8x8(dc, 10, mmxext) PRED8x8(dc, 10, sse2) -PRED8x8(top_dc, 10, mmxext) PRED8x8(top_dc, 10, sse2) PRED8x8(plane, 10, sse2) PRED8x8(vertical, 10, sse2) @@ -55,23 +54,28 @@ PRED8x8(horizontal, 10, sse2) void ff_pred8x8l_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, int has_topleft, int has_topright, int stride); PRED8x8L(dc, 10, sse2) -PRED8x8L(dc, 10, ssse3) +PRED8x8L(dc, 10, avx) PRED8x8L(128_dc, 10, mmxext) PRED8x8L(128_dc, 10, sse2) PRED8x8L(top_dc, 10, sse2) -PRED8x8L(top_dc, 10, ssse3) +PRED8x8L(top_dc, 10, avx) PRED8x8L(vertical, 10, sse2) -PRED8x8L(vertical, 10, ssse3) +PRED8x8L(vertical, 10, avx) PRED8x8L(horizontal, 10, sse2) PRED8x8L(horizontal, 10, ssse3) +PRED8x8L(horizontal, 10, avx) PRED8x8L(down_left, 10, sse2) PRED8x8L(down_left, 10, ssse3) +PRED8x8L(down_left, 10, avx) PRED8x8L(down_right, 10, sse2) PRED8x8L(down_right, 10, ssse3) +PRED8x8L(down_right, 10, avx) PRED8x8L(vertical_right, 10, sse2) PRED8x8L(vertical_right, 10, ssse3) +PRED8x8L(vertical_right, 10, avx) PRED8x8L(horizontal_up, 10, sse2) PRED8x8L(horizontal_up, 10, ssse3) +PRED8x8L(horizontal_up, 10, avx) #define PRED16x16(TYPE, DEPTH, OPT)\ void ff_pred16x16_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, int stride); @@ -298,7 +302,6 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_mmxext; - h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_mmxext; h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_mmxext; @@ -344,18 +347,28 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_ssse3; h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3; - h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_ssse3; h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_ssse3; - h->pred8x8l[DC_PRED ] = ff_pred8x8l_dc_10_ssse3; - h->pred8x8l[TOP_DC_PRED ] = ff_pred8x8l_top_dc_10_ssse3; h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_ssse3; + h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_ssse3; + h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_ssse3; + h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_ssse3; } #if HAVE_AVX if (mm_flags & AV_CPU_FLAG_AVX) { h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx; h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx; + h->pred4x4[VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_10_avx; h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_avx; h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_avx; + + h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_avx; + h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_avx; + h->pred8x8l[DC_PRED ] = ff_pred8x8l_dc_10_avx; + h->pred8x8l[TOP_DC_PRED ] = ff_pred8x8l_top_dc_10_avx; + h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_avx; + h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_avx; + h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_avx; + h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_avx; } #endif /* HAVE_AVX */ } From b4cfb8254eeeb2fc0aa2c0c36a5ede208af47a79 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 22 Jul 2011 00:13:27 +0100 Subject: [PATCH 652/780] dnxhddec: avoid a branch in 10-bit decode_dct_block() The minimum weight value is 32 so this test can be skipped for the 10-bit case. Overall speedup 3-4%. Signed-off-by: Mans Rullgard --- libavcodec/dnxhddec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 426be2e985..63ccd08b48 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -239,7 +239,7 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx, //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j); //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weight %d\n", level, weight_matrix[i]); level = (2*level+1) * qscale * weight_matrix[i]; - if (weight_matrix[i] != level_bias) + if (level_bias < 32 || weight_matrix[i] != level_bias) level += level_bias; level >>= level_shift; From 00a9ac424eeb273785cc529f14e481ff88c02eac Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Jul 2011 15:38:23 +0200 Subject: [PATCH 653/780] examples/encoding.c: adopt a less restrictive license Adopt ISC (Internet Systems Consortium) license in place of LGPL, consistent with the other examples. Fabrice explicitely approved the relicensing. --- doc/examples/encoding.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/doc/examples/encoding.c b/doc/examples/encoding.c index 042947a060..7efd5facce 100644 --- a/doc/examples/encoding.c +++ b/doc/examples/encoding.c @@ -1,21 +1,23 @@ /* * Copyright (c) 2001 Fabrice Bellard * - * This file is part of FFmpeg. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * FFmpeg 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ /** From cc0dc50d027b8aca27b07ef5cededde2e9d96d57 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 17 Jul 2011 17:07:39 +0200 Subject: [PATCH 654/780] vf_mp: remove blackframe filter wrapper blackframe is integrated as a native filter. --- doc/filters.texi | 1 - libavfilter/Makefile | 1 - libavfilter/avfilter.h | 2 +- libavfilter/libmpcodecs/vf_blackframe.c | 148 ------------------------ libavfilter/vf_mp.c | 2 - 5 files changed, 1 insertion(+), 153 deletions(-) delete mode 100644 libavfilter/libmpcodecs/vf_blackframe.c diff --git a/doc/filters.texi b/doc/filters.texi index 5c1a2808d0..8054bffb1d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -895,7 +895,6 @@ the named filter. The list of the currently supported filters follows: @table @var @item 2xsai -@item blackframe @item decimate @item delogo @item denoise3d diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 4e903291cf..6007fedca5 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -79,7 +79,6 @@ OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/mp_image.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/img_format.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_2xsai.o -OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_blackframe.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_decimate.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_delogo.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_denoise3d.o diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 2fe1f14ec7..913a52b22f 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 27 -#define LIBAVFILTER_VERSION_MICRO 2 +#define LIBAVFILTER_VERSION_MICRO 3 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/libmpcodecs/vf_blackframe.c b/libavfilter/libmpcodecs/vf_blackframe.c deleted file mode 100644 index c72552c99e..0000000000 --- a/libavfilter/libmpcodecs/vf_blackframe.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * detect frames that are (almost) black - * search for black frames to detect scene transitions - * (c) 2006 Julian Hall - * - * based on code designed for skipping commercials - * (c) 2002-2003 Brian J. Murrell - * - * cleanup, simplify, speedup (c) 2006 by Ivo van Poorten - * - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include - -#include "config.h" -#include "mp_msg.h" - -#include "img_format.h" -#include "mp_image.h" -#include "vf.h" - -struct vf_priv_s { - unsigned int bamount, bthresh, frame, lastkeyframe; -}; - -static int config(struct vf_instance *vf, int width, int height, int d_width, - int d_height, unsigned int flags, unsigned int outfmt) { - return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); -} - -static int query_format(struct vf_instance *vf, unsigned fmt) { - switch(fmt) { - case IMGFMT_YVU9: - case IMGFMT_IF09: - case IMGFMT_YV12: - case IMGFMT_I420: - case IMGFMT_IYUV: - case IMGFMT_CLPL: - case IMGFMT_Y800: - case IMGFMT_Y8: - case IMGFMT_NV12: - case IMGFMT_NV21: - case IMGFMT_444P: - case IMGFMT_422P: - case IMGFMT_411P: - case IMGFMT_HM12: - return vf_next_query_format(vf, fmt); - } - return 0; -} - -static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ - mp_image_t *dmpi; - int x, y; - int nblack=0, pblack=0; - unsigned char *yplane = mpi->planes[0]; - unsigned int ystride = mpi->stride[0]; - int pict_type = mpi->pict_type; - int w = mpi->w, h = mpi->h; - int bthresh = vf->priv->bthresh; - int bamount = vf->priv->bamount; - static const char *const picttypes[4] = { "unknown", "I", "P", "B" }; - - for (y=1; y<=h; y++) { - for (x=0; x 3 || pict_type < 0) pict_type = 0; - if (pict_type == 1) vf->priv->lastkeyframe = vf->priv->frame; - - if (pblack >= bamount) - mp_msg(MSGT_VFILTER, MSGL_INFO,"vf_blackframe: %u, %i%%, %s (I:%u)\n", - vf->priv->frame, pblack, picttypes[pict_type], - vf->priv->lastkeyframe); - - vf->priv->frame++; - - dmpi = vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_EXPORT, 0, - mpi->width, mpi->height); - dmpi->planes[0] = mpi->planes[0]; - dmpi->stride[0] = mpi->stride[0]; - dmpi->planes[1] = mpi->planes[1]; - dmpi->stride[1] = mpi->stride[1]; - dmpi->planes[2] = mpi->planes[2]; - dmpi->stride[2] = mpi->stride[2]; - - vf_clone_mpi_attributes(dmpi, mpi); - - return vf_next_put_image(vf, dmpi, pts); -} - -static int control(struct vf_instance *vf, int request, void* data){ - return vf_next_control(vf,request,data); -} - -static void uninit(struct vf_instance *vf) { - free(vf->priv); -} - -static int vf_open(vf_instance_t *vf, char *args){ - vf->priv = malloc(sizeof(struct vf_priv_s)); - if (!vf->priv) return 0; - - vf->config = config; - vf->put_image = put_image; - vf->control = control; - vf->uninit = uninit; - vf->query_format = query_format; - - vf->priv->bamount = 98; - vf->priv->bthresh = 0x20; - vf->priv->frame = 0; - vf->priv->lastkeyframe = 0; - - if (args) - sscanf(args, "%u:%u", &vf->priv->bamount, &vf->priv->bthresh); - return 1; -} - -const vf_info_t vf_info_blackframe = { - "detects black frames", - "blackframe", - "Brian J. Murrell, Julian Hall, Ivo van Poorten", - "Useful for detecting scene transitions", - vf_open, - NULL -}; diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c index 752d6cb127..86f6244863 100644 --- a/libavfilter/vf_mp.c +++ b/libavfilter/vf_mp.c @@ -189,7 +189,6 @@ extern const vf_info_t vf_info_screenshot; extern const vf_info_t vf_info_ass; extern const vf_info_t vf_info_mcdeint; extern const vf_info_t vf_info_yadif; -extern const vf_info_t vf_info_blackframe; extern const vf_info_t vf_info_geq; extern const vf_info_t vf_info_ow; extern const vf_info_t vf_info_fixpts; @@ -198,7 +197,6 @@ extern const vf_info_t vf_info_stereo3d; static const vf_info_t* const filters[]={ &vf_info_2xsai, - &vf_info_blackframe, &vf_info_decimate, &vf_info_delogo, &vf_info_denoise3d, From 49f612ee2954720f50ee37ae38303f251af0e4eb Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 19 Jul 2011 14:16:04 +0200 Subject: [PATCH 655/780] imgconvert: remove useless PixFmtInfo.nb_channels field --- libavcodec/imgconvert.c | 65 +++++------------------------------------ 1 file changed, 7 insertions(+), 58 deletions(-) diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 6593e88214..81e5cc0218 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -60,7 +60,6 @@ #endif typedef struct PixFmtInfo { - uint8_t nb_channels; /**< number of channels (including alpha) */ uint8_t color_type; /**< color type (see FF_COLOR_xxx constants) */ uint8_t pixel_type; /**< pixel storage type (see FF_PIXEL_xxx constants) */ uint8_t is_alpha : 1; /**< true if alpha can be specified */ @@ -71,94 +70,78 @@ typedef struct PixFmtInfo { static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { /* YUV formats */ [PIX_FMT_YUV420P] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUV422P] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUV444P] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUYV422] = { - .nb_channels = 1, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_UYVY422] = { - .nb_channels = 1, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_YUV410P] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUV411P] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUV440P] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUV420P16LE] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_YUV422P16LE] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_YUV444P16LE] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_YUV420P16BE] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_YUV422P16BE] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_YUV444P16BE] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, - /* YUV formats with alpha plane */ [PIX_FMT_YUVA420P] = { - .nb_channels = 4, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, @@ -166,25 +149,21 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { /* JPEG YUV */ [PIX_FMT_YUVJ420P] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV_JPEG, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUVJ422P] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV_JPEG, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUVJ444P] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV_JPEG, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUVJ440P] = { - .nb_channels = 3, .color_type = FF_COLOR_YUV_JPEG, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, @@ -192,67 +171,57 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { /* RGB formats */ [PIX_FMT_RGB24] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_BGR24] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_ARGB] = { - .nb_channels = 4, .is_alpha = 1, + .is_alpha = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_RGB48BE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 16, }, [PIX_FMT_RGB48LE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 16, }, [PIX_FMT_RGB565BE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, }, [PIX_FMT_RGB565LE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, }, [PIX_FMT_RGB555BE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, }, [PIX_FMT_RGB555LE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, }, [PIX_FMT_RGB444BE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 4, }, [PIX_FMT_RGB444LE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 4, @@ -260,31 +229,26 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { /* gray / mono formats */ [PIX_FMT_GRAY16BE] = { - .nb_channels = 1, .color_type = FF_COLOR_GRAY, .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_GRAY16LE] = { - .nb_channels = 1, .color_type = FF_COLOR_GRAY, .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_GRAY8] = { - .nb_channels = 1, .color_type = FF_COLOR_GRAY, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_MONOWHITE] = { - .nb_channels = 1, .color_type = FF_COLOR_GRAY, .pixel_type = FF_PIXEL_PLANAR, .depth = 1, }, [PIX_FMT_MONOBLACK] = { - .nb_channels = 1, .color_type = FF_COLOR_GRAY, .pixel_type = FF_PIXEL_PLANAR, .depth = 1, @@ -292,116 +256,101 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { /* paletted formats */ [PIX_FMT_PAL8] = { - .nb_channels = 4, .is_alpha = 1, + .is_alpha = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PALETTE, .depth = 8, }, [PIX_FMT_UYYVYY411] = { - .nb_channels = 1, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_ABGR] = { - .nb_channels = 4, .is_alpha = 1, + .is_alpha = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_BGR565BE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, }, [PIX_FMT_BGR565LE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, }, [PIX_FMT_BGR555BE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, }, [PIX_FMT_BGR555LE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, }, [PIX_FMT_BGR444BE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 4, }, [PIX_FMT_BGR444LE] = { - .nb_channels = 3, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 4, }, [PIX_FMT_RGB8] = { - .nb_channels = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_RGB4] = { - .nb_channels = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 4, }, [PIX_FMT_RGB4_BYTE] = { - .nb_channels = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_BGR8] = { - .nb_channels = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_BGR4] = { - .nb_channels = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 4, }, [PIX_FMT_BGR4_BYTE] = { - .nb_channels = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_NV12] = { - .nb_channels = 2, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_NV21] = { - .nb_channels = 2, .color_type = FF_COLOR_YUV, .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_BGRA] = { - .nb_channels = 4, .is_alpha = 1, + .is_alpha = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_RGBA] = { - .nb_channels = 4, .is_alpha = 1, + .is_alpha = 1, .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, @@ -579,13 +528,13 @@ static int avg_bits_per_pixel(enum PixelFormat pix_fmt) bits = 12; break; default: - bits = pf->depth * pf->nb_channels; + bits = av_get_bits_per_pixel(desc); break; } break; case FF_PIXEL_PLANAR: if (desc->log2_chroma_w == 0 && desc->log2_chroma_h == 0) { - bits = pf->depth * pf->nb_channels; + bits = av_get_bits_per_pixel(desc); } else { bits = pf->depth + ((2 * pf->depth) >> (desc->log2_chroma_w + desc->log2_chroma_h)); From 3b8bb503eea726219ad7aa4d9586163a5a199cae Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 19 Jul 2011 15:38:53 +0200 Subject: [PATCH 656/780] imgconvert: store padded size information in PixFmtInfo, simplify avg_bits_per_pixel() Prefer data-driven over procedural logic in avg_bits_per_pixel(), simplify and improve robustness, as it is easy to miss a function update when a new format is added. --- libavcodec/imgconvert.c | 62 +++++++++++------------------------------ 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 81e5cc0218..a5b73845f9 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -64,6 +64,7 @@ typedef struct PixFmtInfo { uint8_t pixel_type; /**< pixel storage type (see FF_PIXEL_xxx constants) */ uint8_t is_alpha : 1; /**< true if alpha can be specified */ uint8_t depth; /**< bit depth of the color components */ + uint8_t padded_size; /**< padded size in bits if different from the non-padded size */ } PixFmtInfo; /* this table gives more information about formats */ @@ -210,21 +211,25 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, + .padded_size = 16, }, [PIX_FMT_RGB555LE] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, + .padded_size = 16, }, [PIX_FMT_RGB444BE] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 4, + .padded_size = 16, }, [PIX_FMT_RGB444LE] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 4, + .padded_size = 16, }, /* gray / mono formats */ @@ -276,31 +281,37 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, + .padded_size = 16, }, [PIX_FMT_BGR565LE] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, + .padded_size = 16, }, [PIX_FMT_BGR555BE] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, + .padded_size = 16, }, [PIX_FMT_BGR555LE] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 5, + .padded_size = 16, }, [PIX_FMT_BGR444BE] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 4, + .padded_size = 16, }, [PIX_FMT_BGR444LE] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 4, + .padded_size = 16, }, [PIX_FMT_RGB8] = { .color_type = FF_COLOR_RGB, @@ -316,6 +327,7 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, + .padded_size = 8, }, [PIX_FMT_BGR8] = { .color_type = FF_COLOR_RGB, @@ -331,6 +343,7 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { .color_type = FF_COLOR_RGB, .pixel_type = FF_PIXEL_PACKED, .depth = 8, + .padded_size = 8, }, [PIX_FMT_NV12] = { .color_type = FF_COLOR_YUV, @@ -500,54 +513,11 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_ static int avg_bits_per_pixel(enum PixelFormat pix_fmt) { - int bits; - const PixFmtInfo *pf; + const PixFmtInfo *info = &pix_fmt_info[pix_fmt]; const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; - pf = &pix_fmt_info[pix_fmt]; - switch(pf->pixel_type) { - case FF_PIXEL_PACKED: - switch(pix_fmt) { - case PIX_FMT_YUYV422: - case PIX_FMT_UYVY422: - case PIX_FMT_RGB565BE: - case PIX_FMT_RGB565LE: - case PIX_FMT_RGB555BE: - case PIX_FMT_RGB555LE: - case PIX_FMT_RGB444BE: - case PIX_FMT_RGB444LE: - case PIX_FMT_BGR565BE: - case PIX_FMT_BGR565LE: - case PIX_FMT_BGR555BE: - case PIX_FMT_BGR555LE: - case PIX_FMT_BGR444BE: - case PIX_FMT_BGR444LE: - bits = 16; - break; - case PIX_FMT_UYYVYY411: - bits = 12; - break; - default: - bits = av_get_bits_per_pixel(desc); - break; - } - break; - case FF_PIXEL_PLANAR: - if (desc->log2_chroma_w == 0 && desc->log2_chroma_h == 0) { - bits = av_get_bits_per_pixel(desc); - } else { - bits = pf->depth + ((2 * pf->depth) >> - (desc->log2_chroma_w + desc->log2_chroma_h)); - } - break; - case FF_PIXEL_PALETTE: - bits = 8; - break; - default: - bits = -1; - break; - } - return bits; + return info->padded_size ? + info->padded_size : av_get_bits_per_pixel(desc); } static enum PixelFormat avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask, From 9c2651ab44fac3fcacd576852a7570ac64f3686e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 19 Jul 2011 12:01:48 +0200 Subject: [PATCH 657/780] parseutils: add some documentation for small_strptime() --- libavutil/parseutils.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index 866682220c..2000778a32 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -401,7 +401,16 @@ static int date_get_num(const char **pp, return val; } -/* small strptime for ffmpeg */ +/** + * Parse the input string p according to the format string fmt and + * store its results in the structure dt. + * This implementation supports only a subset of the formats supported + * by the standard strptime(). + * + * @return a pointer to the first character not processed in this + * function call, or NULL in case the function fails to match all of + * the fmt string and therefore an error occurred + */ static const char *small_strptime(const char *p, const char *fmt, struct tm *dt) From 8c0fa61a9713a1306fca7997dd04d72ea1f060ea Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 9 Jun 2011 03:35:50 +0200 Subject: [PATCH 658/780] jpegdec: actually search for and parse RSTn Fixes decoding of MJPEG files produced by some UVC Logitec web cameras, such as "Notebook Pro" and "HD C910". References: http://trac.videolan.org/vlc/ticket/4215 http://ffmpeg.org/trac/ffmpeg/ticket/267 Signed-off-by: Michael Niedermayer Reviewed-by: Kostya (cherry picked from commit 7b8ed831eb8432d202dad16dedc1758b018bb1fa) --- libavcodec/mjpegdec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index b28fdf8549..7eea6d78aa 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -879,9 +879,12 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i } } - if (s->restart_interval && !--s->restart_count) { + if (s->restart_interval && show_bits(&s->gb, 8) == 0xFF){ /* skip RSTn */ + --s->restart_count; align_get_bits(&s->gb); - skip_bits(&s->gb, 16); /* skip RSTn */ + while(show_bits(&s->gb, 8) == 0xFF) + skip_bits(&s->gb, 8); + skip_bits(&s->gb, 8); for (i=0; ilast_dc[i] = 1024; } From 52e24c7d7e3a449aa1e4043e77f082150d733e7a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 24 Jul 2011 16:21:37 +0200 Subject: [PATCH 659/780] mpeg4videodec: simplify mpeg4_decode_profile_level() Signed-off-by: Michael Niedermayer --- libavcodec/mpeg4videodec.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index b983a44855..b44f2f0803 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -1528,12 +1528,9 @@ static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){ } static int mpeg4_decode_profile_level(MpegEncContext * s, GetBitContext *gb){ - int profile_and_level_indication; - profile_and_level_indication = get_bits(gb, 8); - - s->avctx->profile = (profile_and_level_indication & 0xf0) >> 4; - s->avctx->level = (profile_and_level_indication & 0x0f); + s->avctx->profile = get_bits(gb, 4); + s->avctx->level = get_bits(gb, 4); // for Simple profile, level 0 if (s->avctx->profile == 0 && s->avctx->level == 8) { From 9e4ed295dab61fe0538a73ab88070e3af201f1e6 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 24 Jul 2011 16:22:18 +0200 Subject: [PATCH 660/780] mpeg4_decode_profile_level: fix indention Signed-off-by: Michael Niedermayer --- libavcodec/mpeg4videodec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index b44f2f0803..e35c0993e7 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -1529,15 +1529,15 @@ static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){ static int mpeg4_decode_profile_level(MpegEncContext * s, GetBitContext *gb){ - s->avctx->profile = get_bits(gb, 4); - s->avctx->level = get_bits(gb, 4); + s->avctx->profile = get_bits(gb, 4); + s->avctx->level = get_bits(gb, 4); - // for Simple profile, level 0 - if (s->avctx->profile == 0 && s->avctx->level == 8) { - s->avctx->level = 0; - } + // for Simple profile, level 0 + if (s->avctx->profile == 0 && s->avctx->level == 8) { + s->avctx->level = 0; + } - return 0; + return 0; } static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){ From 88084eecdfd163802a47501935408acbe07b1691 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 24 Jul 2011 23:52:42 +0200 Subject: [PATCH 661/780] Use little endian for caf codec tags. --- libavformat/caf.c | 52 ++++++++++++++++++++++---------------------- libavformat/cafdec.c | 4 ++-- libavformat/cafenc.c | 4 ++-- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/libavformat/caf.c b/libavformat/caf.c index faed166dfe..ce0d19b947 100644 --- a/libavformat/caf.c +++ b/libavformat/caf.c @@ -32,34 +32,34 @@ * Known codec tags for CAF */ const AVCodecTag ff_codec_caf_tags[] = { - { CODEC_ID_AAC, MKBETAG('a','a','c',' ') }, - { CODEC_ID_AC3, MKBETAG('a','c','-','3') }, - { CODEC_ID_ALAC, MKBETAG('a','l','a','c') }, + { CODEC_ID_AAC, MKTAG('a','a','c',' ') }, + { CODEC_ID_AC3, MKTAG('a','c','-','3') }, + { CODEC_ID_ALAC, MKTAG('a','l','a','c') }, /* FIXME: use DV demuxer, as done in MOV */ - /*{ CODEC_ID_DVAUDIO, MKBETAG('v','d','v','a') },*/ - /*{ CODEC_ID_DVAUDIO, MKBETAG('d','v','c','a') },*/ - { CODEC_ID_ADPCM_IMA_QT, MKBETAG('i','m','a','4') }, - { CODEC_ID_ADPCM_IMA_WAV, MKBETAG('m','s', 0, 17 ) }, - { CODEC_ID_ADPCM_MS, MKBETAG('m','s', 0, 2 ) }, - { CODEC_ID_AMR_NB, MKBETAG('s','a','m','r') }, - { CODEC_ID_GSM, MKBETAG('a','g','s','m') }, - { CODEC_ID_GSM_MS, MKBETAG('m','s', 0, '1') }, - { CODEC_ID_MACE3, MKBETAG('M','A','C','3') }, - { CODEC_ID_MACE6, MKBETAG('M','A','C','6') }, - { CODEC_ID_MP3, MKBETAG('.','m','p','3') }, - { CODEC_ID_MP3, MKBETAG('m','s', 0 ,'U') }, - { CODEC_ID_MP2, MKBETAG('.','m','p','2') }, - { CODEC_ID_MP1, MKBETAG('.','m','p','1') }, - { CODEC_ID_PCM_ALAW, MKBETAG('a','l','a','w') }, - { CODEC_ID_PCM_MULAW, MKBETAG('u','l','a','w') }, - { CODEC_ID_QCELP, MKBETAG('Q','c','l','p') }, - { CODEC_ID_QDM2, MKBETAG('Q','D','M','2') }, - { CODEC_ID_QDM2, MKBETAG('Q','D','M','C') }, + /*{ CODEC_ID_DVAUDIO, MKTAG('v','d','v','a') },*/ + /*{ CODEC_ID_DVAUDIO, MKTAG('d','v','c','a') },*/ + { CODEC_ID_ADPCM_IMA_QT, MKTAG('i','m','a','4') }, + { CODEC_ID_ADPCM_IMA_WAV, MKTAG('m','s', 0, 17 ) }, + { CODEC_ID_ADPCM_MS, MKTAG('m','s', 0, 2 ) }, + { CODEC_ID_AMR_NB, MKTAG('s','a','m','r') }, + { CODEC_ID_GSM, MKTAG('a','g','s','m') }, + { CODEC_ID_GSM_MS, MKTAG('m','s', 0, '1') }, + { CODEC_ID_MACE3, MKTAG('M','A','C','3') }, + { CODEC_ID_MACE6, MKTAG('M','A','C','6') }, + { CODEC_ID_MP3, MKTAG('.','m','p','3') }, + { CODEC_ID_MP3, MKTAG('m','s', 0 ,'U') }, + { CODEC_ID_MP2, MKTAG('.','m','p','2') }, + { CODEC_ID_MP1, MKTAG('.','m','p','1') }, + { CODEC_ID_PCM_ALAW, MKTAG('a','l','a','w') }, + { CODEC_ID_PCM_MULAW, MKTAG('u','l','a','w') }, + { CODEC_ID_QCELP, MKTAG('Q','c','l','p') }, + { CODEC_ID_QDM2, MKTAG('Q','D','M','2') }, + { CODEC_ID_QDM2, MKTAG('Q','D','M','C') }, /* currently unsupported codecs */ - /*{ AC-3 over S/PDIF MKBETAG('c','a','c','3') },*/ - /*{ MPEG4CELP MKBETAG('c','e','l','p') },*/ - /*{ MPEG4HVXC MKBETAG('h','v','x','c') },*/ - /*{ MPEG4TwinVQ MKBETAG('t','w','v','q') },*/ + /*{ AC-3 over S/PDIF MKTAG('c','a','c','3') },*/ + /*{ MPEG4CELP MKTAG('c','e','l','p') },*/ + /*{ MPEG4HVXC MKTAG('h','v','x','c') },*/ + /*{ MPEG4TwinVQ MKTAG('t','w','v','q') },*/ { CODEC_ID_NONE, 0 }, }; diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index da01598f13..8b0daddd58 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -68,7 +68,7 @@ static int read_desc_chunk(AVFormatContext *s) /* parse format description */ st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->sample_rate = av_int2dbl(avio_rb64(pb)); - st->codec->codec_tag = avio_rb32(pb); + st->codec->codec_tag = avio_rl32(pb); flags = avio_rb32(pb); caf->bytes_per_packet = avio_rb32(pb); st->codec->block_align = caf->bytes_per_packet; @@ -85,7 +85,7 @@ static int read_desc_chunk(AVFormatContext *s) } /* determine codec */ - if (st->codec->codec_tag == MKBETAG('l','p','c','m')) + if (st->codec->codec_tag == MKTAG('l','p','c','m')) st->codec->codec_id = ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, (flags ^ 0x2) | 0x4); else st->codec->codec_id = ff_codec_get_id(ff_codec_caf_tags, st->codec->codec_tag); diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c index 43f56624a7..c324b8ead4 100644 --- a/libavformat/cafenc.c +++ b/libavformat/cafenc.c @@ -114,7 +114,7 @@ static int caf_write_header(AVFormatContext *s) case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: - codec_tag = MKBETAG('l','p','c','m'); + codec_tag = MKTAG('l','p','c','m'); } if (!codec_tag) { @@ -134,7 +134,7 @@ static int caf_write_header(AVFormatContext *s) ffio_wfourcc(pb, "desc"); //< Audio Description chunk avio_wb64(pb, 32); //< mChunkSize avio_wb64(pb, av_dbl2int(enc->sample_rate)); //< mSampleRate - avio_wb32(pb, codec_tag); //< mFormatID + avio_wl32(pb, codec_tag); //< mFormatID avio_wb32(pb, codec_flags(enc->codec_id)); //< mFormatFlags avio_wb32(pb, enc->block_align); //< mBytesPerPacket avio_wb32(pb, samples_per_packet(enc->codec_id, enc->channels)); //< mFramesPerPacket From c899bedbca77de42014a1092ae2857c61f2d4b76 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 24 Jul 2011 02:36:02 +0200 Subject: [PATCH 662/780] lsws: use array for storing the supported in/out information --- libswscale/utils.c | 201 ++++++++++++++++++--------------------------- 1 file changed, 78 insertions(+), 123 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index aa887310a1..8a103889be 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -66,137 +66,92 @@ const char *swscale_license(void) #define RET 0xC3 //near return opcode for x86 -#define isSupportedIn(x) ( \ - (x)==PIX_FMT_YUV420P \ - || (x)==PIX_FMT_YUVA420P \ - || (x)==PIX_FMT_YUYV422 \ - || (x)==PIX_FMT_UYVY422 \ - || (x)==PIX_FMT_RGB48BE \ - || (x)==PIX_FMT_RGB48LE \ - || (x)==PIX_FMT_RGB32 \ - || (x)==PIX_FMT_RGB32_1 \ - || (x)==PIX_FMT_BGR48BE \ - || (x)==PIX_FMT_BGR48LE \ - || (x)==PIX_FMT_BGR24 \ - || (x)==PIX_FMT_BGR565LE \ - || (x)==PIX_FMT_BGR565BE \ - || (x)==PIX_FMT_BGR555LE \ - || (x)==PIX_FMT_BGR555BE \ - || (x)==PIX_FMT_BGR32 \ - || (x)==PIX_FMT_BGR32_1 \ - || (x)==PIX_FMT_RGB24 \ - || (x)==PIX_FMT_RGB565LE \ - || (x)==PIX_FMT_RGB565BE \ - || (x)==PIX_FMT_RGB555LE \ - || (x)==PIX_FMT_RGB555BE \ - || (x)==PIX_FMT_GRAY8 \ - || (x)==PIX_FMT_GRAY8A \ - || (x)==PIX_FMT_YUV410P \ - || (x)==PIX_FMT_YUV440P \ - || (x)==PIX_FMT_NV12 \ - || (x)==PIX_FMT_NV21 \ - || (x)==PIX_FMT_GRAY16BE \ - || (x)==PIX_FMT_GRAY16LE \ - || (x)==PIX_FMT_YUV444P \ - || (x)==PIX_FMT_YUV422P \ - || (x)==PIX_FMT_YUV411P \ - || (x)==PIX_FMT_YUVJ420P \ - || (x)==PIX_FMT_YUVJ422P \ - || (x)==PIX_FMT_YUVJ440P \ - || (x)==PIX_FMT_YUVJ444P \ - || (x)==PIX_FMT_PAL8 \ - || (x)==PIX_FMT_BGR8 \ - || (x)==PIX_FMT_RGB8 \ - || (x)==PIX_FMT_BGR4_BYTE \ - || (x)==PIX_FMT_RGB4_BYTE \ - || (x)==PIX_FMT_YUV440P \ - || (x)==PIX_FMT_MONOWHITE \ - || (x)==PIX_FMT_MONOBLACK \ - || (x)==PIX_FMT_YUV420P9LE \ - || (x)==PIX_FMT_YUV444P9LE \ - || (x)==PIX_FMT_YUV420P10LE \ - || (x)==PIX_FMT_YUV422P10LE \ - || (x)==PIX_FMT_YUV444P10LE \ - || (x)==PIX_FMT_YUV420P16LE \ - || (x)==PIX_FMT_YUV422P16LE \ - || (x)==PIX_FMT_YUV444P16LE \ - || (x)==PIX_FMT_YUV422P10LE \ - || (x)==PIX_FMT_YUV420P9BE \ - || (x)==PIX_FMT_YUV444P9BE \ - || (x)==PIX_FMT_YUV420P10BE \ - || (x)==PIX_FMT_YUV444P10BE \ - || (x)==PIX_FMT_YUV422P10BE \ - || (x)==PIX_FMT_YUV420P16BE \ - || (x)==PIX_FMT_YUV422P16BE \ - || (x)==PIX_FMT_YUV444P16BE \ - || (x)==PIX_FMT_YUV422P10BE \ - ) +typedef struct FormatEntry { +int is_supported_in, is_supported_out; +} FormatEntry; + +const static FormatEntry format_entries[PIX_FMT_NB] = { + [PIX_FMT_YUV420P] = { 1 , 1 }, + [PIX_FMT_YUYV422] = { 1 , 1 }, + [PIX_FMT_RGB24] = { 1 , 1 }, + [PIX_FMT_BGR24] = { 1 , 1 }, + [PIX_FMT_YUV422P] = { 1 , 1 }, + [PIX_FMT_YUV444P] = { 1 , 1 }, + [PIX_FMT_YUV410P] = { 1 , 1 }, + [PIX_FMT_YUV411P] = { 1 , 1 }, + [PIX_FMT_GRAY8] = { 1 , 1 }, + [PIX_FMT_MONOWHITE] = { 1 , 1 }, + [PIX_FMT_MONOBLACK] = { 1 , 1 }, + [PIX_FMT_PAL8] = { 1 , 0 }, + [PIX_FMT_YUVJ420P] = { 1 , 1 }, + [PIX_FMT_YUVJ422P] = { 1 , 1 }, + [PIX_FMT_YUVJ444P] = { 1 , 1 }, + [PIX_FMT_UYVY422] = { 1 , 1 }, + [PIX_FMT_UYYVYY411] = { 0 , 0 }, + [PIX_FMT_BGR8] = { 1 , 1 }, + [PIX_FMT_BGR4] = { 0 , 1 }, + [PIX_FMT_BGR4_BYTE] = { 1 , 1 }, + [PIX_FMT_RGB8] = { 1 , 1 }, + [PIX_FMT_RGB4] = { 0 , 1 }, + [PIX_FMT_RGB4_BYTE] = { 1 , 1 }, + [PIX_FMT_NV12] = { 1 , 1 }, + [PIX_FMT_NV21] = { 1 , 1 }, + [PIX_FMT_ARGB] = { 1 , 1 }, + [PIX_FMT_RGBA] = { 1 , 1 }, + [PIX_FMT_ABGR] = { 1 , 1 }, + [PIX_FMT_BGRA] = { 1 , 1 }, + [PIX_FMT_GRAY16BE] = { 1 , 1 }, + [PIX_FMT_GRAY16LE] = { 1 , 1 }, + [PIX_FMT_YUV440P] = { 1 , 1 }, + [PIX_FMT_YUVJ440P] = { 1 , 1 }, + [PIX_FMT_YUVA420P] = { 1 , 1 }, + [PIX_FMT_RGB48BE] = { 1 , 1 }, + [PIX_FMT_RGB48LE] = { 1 , 1 }, + [PIX_FMT_RGB565BE] = { 1 , 1 }, + [PIX_FMT_RGB565LE] = { 1 , 1 }, + [PIX_FMT_RGB555BE] = { 1 , 1 }, + [PIX_FMT_RGB555LE] = { 1 , 1 }, + [PIX_FMT_BGR565BE] = { 1 , 1 }, + [PIX_FMT_BGR565LE] = { 1 , 1 }, + [PIX_FMT_BGR555BE] = { 1 , 1 }, + [PIX_FMT_BGR555LE] = { 1 , 1 }, + [PIX_FMT_YUV420P16LE] = { 1 , 1 }, + [PIX_FMT_YUV420P16BE] = { 1 , 1 }, + [PIX_FMT_YUV422P16LE] = { 1 , 1 }, + [PIX_FMT_YUV422P16BE] = { 1 , 1 }, + [PIX_FMT_YUV444P16LE] = { 1 , 1 }, + [PIX_FMT_YUV444P16BE] = { 1 , 1 }, + [PIX_FMT_RGB444LE] = { 0 , 1 }, + [PIX_FMT_RGB444BE] = { 0 , 1 }, + [PIX_FMT_BGR444LE] = { 0 , 1 }, + [PIX_FMT_BGR444BE] = { 0 , 1 }, + [PIX_FMT_GRAY8A] = { 1 , 0 }, + [PIX_FMT_BGR48BE] = { 1 , 1 }, + [PIX_FMT_BGR48LE] = { 1 , 1 }, + [PIX_FMT_YUV420P9BE] = { 1 , 1 }, + [PIX_FMT_YUV420P9LE] = { 1 , 1 }, + [PIX_FMT_YUV420P10BE] = { 1 , 1 }, + [PIX_FMT_YUV420P10LE] = { 1 , 1 }, + [PIX_FMT_YUV422P10BE] = { 1 , 1 }, + [PIX_FMT_YUV422P10LE] = { 1 , 1 }, + [PIX_FMT_YUV444P9BE] = { 1 , 0 }, + [PIX_FMT_YUV444P9LE] = { 1 , 0 }, + [PIX_FMT_YUV444P10BE] = { 1 , 0 }, + [PIX_FMT_YUV444P10LE] = { 1 , 0 }, +}; + +#define isSupportedIn(x) (format_entries[x].is_supported_in) int sws_isSupportedInput(enum PixelFormat pix_fmt) { - return isSupportedIn(pix_fmt); + return format_entries[pix_fmt].is_supported_in; } -#define isSupportedOut(x) ( \ - (x)==PIX_FMT_YUV420P \ - || (x)==PIX_FMT_YUVA420P \ - || (x)==PIX_FMT_YUYV422 \ - || (x)==PIX_FMT_UYVY422 \ - || (x)==PIX_FMT_YUV444P \ - || (x)==PIX_FMT_YUV422P \ - || (x)==PIX_FMT_YUV411P \ - || (x)==PIX_FMT_YUVJ420P \ - || (x)==PIX_FMT_YUVJ422P \ - || (x)==PIX_FMT_YUVJ440P \ - || (x)==PIX_FMT_YUVJ444P \ - || isRGBinBytes(x) \ - || isBGRinBytes(x) \ - || (x)==PIX_FMT_RGB565LE \ - || (x)==PIX_FMT_RGB565BE \ - || (x)==PIX_FMT_RGB555LE \ - || (x)==PIX_FMT_RGB555BE \ - || (x)==PIX_FMT_RGB444LE \ - || (x)==PIX_FMT_RGB444BE \ - || (x)==PIX_FMT_BGR565LE \ - || (x)==PIX_FMT_BGR565BE \ - || (x)==PIX_FMT_BGR555LE \ - || (x)==PIX_FMT_BGR555BE \ - || (x)==PIX_FMT_BGR444LE \ - || (x)==PIX_FMT_BGR444BE \ - || (x)==PIX_FMT_RGB8 \ - || (x)==PIX_FMT_BGR8 \ - || (x)==PIX_FMT_RGB4_BYTE \ - || (x)==PIX_FMT_BGR4_BYTE \ - || (x)==PIX_FMT_RGB4 \ - || (x)==PIX_FMT_BGR4 \ - || (x)==PIX_FMT_MONOBLACK \ - || (x)==PIX_FMT_MONOWHITE \ - || (x)==PIX_FMT_NV12 \ - || (x)==PIX_FMT_NV21 \ - || (x)==PIX_FMT_GRAY16BE \ - || (x)==PIX_FMT_GRAY16LE \ - || (x)==PIX_FMT_GRAY8 \ - || (x)==PIX_FMT_YUV410P \ - || (x)==PIX_FMT_YUV440P \ - || (x)==PIX_FMT_YUV422P10LE \ - || (x)==PIX_FMT_YUV420P9LE \ - || (x)==PIX_FMT_YUV420P10LE \ - || (x)==PIX_FMT_YUV420P16LE \ - || (x)==PIX_FMT_YUV422P10LE \ - || (x)==PIX_FMT_YUV422P16LE \ - || (x)==PIX_FMT_YUV444P16LE \ - || (x)==PIX_FMT_YUV422P10BE \ - || (x)==PIX_FMT_YUV420P9BE \ - || (x)==PIX_FMT_YUV420P10BE \ - || (x)==PIX_FMT_YUV422P10BE \ - || (x)==PIX_FMT_YUV420P16BE \ - || (x)==PIX_FMT_YUV422P16BE \ - || (x)==PIX_FMT_YUV444P16BE \ - ) +#define isSupportedOut(x) (format_entries[x].is_supported_out) int sws_isSupportedOutput(enum PixelFormat pix_fmt) { - return isSupportedOut(pix_fmt); + return format_entries[pix_fmt].is_supported_out; } extern const int32_t ff_yuv2rgb_coeffs[8][4]; From d7e14c0d103a2c9cca6c50568e09b40d6f48ea19 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 23 Jul 2011 15:37:05 +0200 Subject: [PATCH 663/780] imgconvert: remove PixFmtInfo.pixel_type field The field is only used for checking if a format is YUV planar and if the format is paletted. This patch replaces the current is_planar_yuv() code with a function which uses the pixdesc information. The new implementation is less efficient, but this should not be an issue as the functions which use it (av_picture_crop/pad()) are deprecated and currently never used in the codebase. --- libavcodec/imgconvert.c | 90 +++++++++++------------------------------ 1 file changed, 23 insertions(+), 67 deletions(-) diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index a5b73845f9..fbe8141336 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -47,10 +47,6 @@ #define FF_COLOR_YUV 2 /**< YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */ #define FF_COLOR_YUV_JPEG 3 /**< YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */ -#define FF_PIXEL_PLANAR 0 /**< each channel has one component in AVPicture */ -#define FF_PIXEL_PACKED 1 /**< only one components containing all the channels */ -#define FF_PIXEL_PALETTE 2 /**< one components containing indexes for a palette */ - #if HAVE_MMX && HAVE_YASM #define deinterlace_line_inplace ff_deinterlace_line_inplace_mmx #define deinterlace_line ff_deinterlace_line_mmx @@ -61,7 +57,6 @@ typedef struct PixFmtInfo { uint8_t color_type; /**< color type (see FF_COLOR_xxx constants) */ - uint8_t pixel_type; /**< pixel storage type (see FF_PIXEL_xxx constants) */ uint8_t is_alpha : 1; /**< true if alpha can be specified */ uint8_t depth; /**< bit depth of the color components */ uint8_t padded_size; /**< padded size in bits if different from the non-padded size */ @@ -72,162 +67,132 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { /* YUV formats */ [PIX_FMT_YUV420P] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUV422P] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUV444P] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUYV422] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_UYVY422] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_YUV410P] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUV411P] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUV440P] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUV420P16LE] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_YUV422P16LE] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_YUV444P16LE] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_YUV420P16BE] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_YUV422P16BE] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_YUV444P16BE] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, /* YUV formats with alpha plane */ [PIX_FMT_YUVA420P] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, /* JPEG YUV */ [PIX_FMT_YUVJ420P] = { .color_type = FF_COLOR_YUV_JPEG, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUVJ422P] = { .color_type = FF_COLOR_YUV_JPEG, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUVJ444P] = { .color_type = FF_COLOR_YUV_JPEG, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_YUVJ440P] = { .color_type = FF_COLOR_YUV_JPEG, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, /* RGB formats */ [PIX_FMT_RGB24] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_BGR24] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_ARGB] = { .is_alpha = 1, .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_RGB48BE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 16, }, [PIX_FMT_RGB48LE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 16, }, [PIX_FMT_RGB565BE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 5, }, [PIX_FMT_RGB565LE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 5, }, [PIX_FMT_RGB555BE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 5, .padded_size = 16, }, [PIX_FMT_RGB555LE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 5, .padded_size = 16, }, [PIX_FMT_RGB444BE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 4, .padded_size = 16, }, [PIX_FMT_RGB444LE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 4, .padded_size = 16, }, @@ -235,27 +200,22 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { /* gray / mono formats */ [PIX_FMT_GRAY16BE] = { .color_type = FF_COLOR_GRAY, - .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_GRAY16LE] = { .color_type = FF_COLOR_GRAY, - .pixel_type = FF_PIXEL_PLANAR, .depth = 16, }, [PIX_FMT_GRAY8] = { .color_type = FF_COLOR_GRAY, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_MONOWHITE] = { .color_type = FF_COLOR_GRAY, - .pixel_type = FF_PIXEL_PLANAR, .depth = 1, }, [PIX_FMT_MONOBLACK] = { .color_type = FF_COLOR_GRAY, - .pixel_type = FF_PIXEL_PLANAR, .depth = 1, }, @@ -263,109 +223,90 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { [PIX_FMT_PAL8] = { .is_alpha = 1, .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PALETTE, .depth = 8, }, [PIX_FMT_UYYVYY411] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_ABGR] = { .is_alpha = 1, .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_BGR565BE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 5, .padded_size = 16, }, [PIX_FMT_BGR565LE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 5, .padded_size = 16, }, [PIX_FMT_BGR555BE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 5, .padded_size = 16, }, [PIX_FMT_BGR555LE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 5, .padded_size = 16, }, [PIX_FMT_BGR444BE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 4, .padded_size = 16, }, [PIX_FMT_BGR444LE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 4, .padded_size = 16, }, [PIX_FMT_RGB8] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_RGB4] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 4, }, [PIX_FMT_RGB4_BYTE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, .padded_size = 8, }, [PIX_FMT_BGR8] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_BGR4] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 4, }, [PIX_FMT_BGR4_BYTE] = { .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, .padded_size = 8, }, [PIX_FMT_NV12] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_NV21] = { .color_type = FF_COLOR_YUV, - .pixel_type = FF_PIXEL_PLANAR, .depth = 8, }, [PIX_FMT_BGRA] = { .is_alpha = 1, .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, [PIX_FMT_RGBA] = { .is_alpha = 1, .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, .depth = 8, }, }; @@ -505,8 +446,8 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_ loss |= FF_LOSS_CHROMA; if (!pf->is_alpha && (ps->is_alpha && has_alpha)) loss |= FF_LOSS_ALPHA; - if (pf->pixel_type == FF_PIXEL_PALETTE && - (ps->pixel_type != FF_PIXEL_PALETTE && ps->color_type != FF_COLOR_GRAY)) + if (dst_pix_fmt == PIX_FMT_PAL8 && + (src_pix_fmt != PIX_FMT_PAL8 && ps->color_type != FF_COLOR_GRAY)) loss |= FF_LOSS_COLORQUANT; return loss; } @@ -692,11 +633,26 @@ void avpicture_free(AVPicture *picture) } /* return true if yuv planar */ -static inline int is_yuv_planar(const PixFmtInfo *ps) +static inline int is_yuv_planar(enum PixelFormat fmt) { - return (ps->color_type == FF_COLOR_YUV || - ps->color_type == FF_COLOR_YUV_JPEG) && - ps->pixel_type == FF_PIXEL_PLANAR; + const PixFmtInfo *info = &pix_fmt_info[fmt]; + const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[fmt]; + int i; + int planes[4] = { 0 }; + + if (info->color_type != FF_COLOR_YUV && + info->color_type != FF_COLOR_YUV_JPEG) + return 0; + + /* set the used planes */ + for (i = 0; i < desc->nb_components; i++) + planes[desc->comp[i].plane] = 1; + + /* if there is an unused plane, the format is not planar */ + for (i = 0; i < desc->nb_components; i++) + if (!planes[i]) + return 0; + return 1; } int av_picture_crop(AVPicture *dst, const AVPicture *src, @@ -711,7 +667,7 @@ int av_picture_crop(AVPicture *dst, const AVPicture *src, y_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_h; x_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_w; - if (is_yuv_planar(&pix_fmt_info[pix_fmt])) { + if (is_yuv_planar(pix_fmt)) { dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band; dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift); dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift); @@ -740,7 +696,7 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, int i, y; if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB || - !is_yuv_planar(&pix_fmt_info[pix_fmt])) return -1; + !is_yuv_planar(pix_fmt)) return -1; for (i = 0; i < 3; i++) { x_shift = i ? av_pix_fmt_descriptors[pix_fmt].log2_chroma_w : 0; From e8794f1d5e9b76330985d2b6d3856b05cfa72c2e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 25 Jul 2011 13:02:53 +0200 Subject: [PATCH 664/780] lsws: fix weird indent --- libswscale/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 8a103889be..91bb5bb927 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -67,7 +67,7 @@ const char *swscale_license(void) #define RET 0xC3 //near return opcode for x86 typedef struct FormatEntry { -int is_supported_in, is_supported_out; + int is_supported_in, is_supported_out; } FormatEntry; const static FormatEntry format_entries[PIX_FMT_NB] = { From bd652ff66e2062df5a05030f211c23e7d4e0be36 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 25 Jul 2011 15:50:13 +0200 Subject: [PATCH 665/780] udp: allow fifo size to be tuned seperately Signed-off-by: Michael Niedermayer --- libavformat/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index cbf3b434d5..dda7ec2d13 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -426,7 +426,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) if (av_find_info_tag(buf, sizeof(buf), "connect", p)) { s->is_connected = strtol(buf, NULL, 10); } - if (av_find_info_tag(buf, sizeof(buf), "buf_size", p)) { + if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) { s->circular_buffer_size = strtol(buf, NULL, 10)*188; } } From 158eb8599a2811ad8eed9939878982f172b79a89 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 25 Jul 2011 15:50:56 +0200 Subject: [PATCH 666/780] rtp: disable udp fifos, the rtp code cannot work with the fifos in its current form as rtp bypasses the public API. Signed-off-by: Michael Niedermayer --- libavformat/rtpproto.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 6e76825d24..d2ce53c670 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -115,6 +115,7 @@ static void build_udp_url(char *buf, int buf_size, url_add_option(buf, buf_size, "pkt_size=%d", max_packet_size); if (connect) url_add_option(buf, buf_size, "connect=1"); + url_add_option(buf, buf_size, "fifo_size=0"); } /** From 981f6fc988dc33e81566fdaf4087da3cfa3ddb04 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 25 Jul 2011 20:48:55 +0200 Subject: [PATCH 667/780] ffmpeg: better timebase guessing for stream copy Signed-off-by: Michael Niedermayer --- ffmpeg.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index fb72a3a5d1..5a1ab0f64d 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2237,13 +2237,23 @@ static int transcode(AVFormatContext **output_files, goto fail; memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; - if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ - codec->time_base = icodec->time_base; - codec->time_base.num *= icodec->ticks_per_frame; - av_reduce(&codec->time_base.num, &codec->time_base.den, - codec->time_base.num, codec->time_base.den, INT_MAX); - }else - codec->time_base = ist->st->time_base; + + codec->time_base = ist->st->time_base; + if(!strcmp(os->oformat->name, "avi")) { + if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > 2*av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ + codec->time_base = icodec->time_base; + codec->time_base.num *= icodec->ticks_per_frame; + codec->time_base.den *= 2; + } + } else if(!(os->oformat->flags & AVFMT_VARIABLE_FPS)) { + if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ + codec->time_base = icodec->time_base; + codec->time_base.num *= icodec->ticks_per_frame; + } + } + av_reduce(&codec->time_base.num, &codec->time_base.den, + codec->time_base.num, codec->time_base.den, INT_MAX); + switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(audio_volume != 256) { From 2962049ac318c1577c15e934a50b64572b2e877c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 25 Jul 2011 22:25:24 +0200 Subject: [PATCH 668/780] muxer opts: fix avdict use in case of early private context alloc Signed-off-by: Michael Niedermayer --- libavformat/utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/utils.c b/libavformat/utils.c index 44ecd0a47f..38407b9d4b 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2929,6 +2929,9 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) av_dict_copy(&tmp, *options, 0); if ((ret = av_opt_set_dict(s, &tmp)) < 0) goto fail; + if (s->priv_data && s->oformat->priv_class && *(const AVClass**)s->priv_data==s->oformat->priv_class && + (ret = av_opt_set_dict(s->priv_data, &tmp)) < 0) + goto fail; // some sanity checks if (s->nb_streams == 0 && !(s->oformat->flags & AVFMT_NOSTREAMS)) { From ab3d241be17ac376f0dfdbbce0e4ce2c319c6eea Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 1 Jun 2011 15:06:08 +0200 Subject: [PATCH 669/780] ape: adjust some printf format strings to correctly match argument types --- libavformat/ape.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavformat/ape.c b/libavformat/ape.c index 6787416039..a49da5c73a 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -129,9 +129,11 @@ static void ape_dumpinfo(AVFormatContext * s, APEContext * ape_ctx) } else { for (i = 0; i < ape_ctx->seektablelength / sizeof(uint32_t); i++) { if (i < ape_ctx->totalframes - 1) { - av_log(s, AV_LOG_DEBUG, "%8d %d (%d bytes)\n", i, ape_ctx->seektable[i], ape_ctx->seektable[i + 1] - ape_ctx->seektable[i]); + av_log(s, AV_LOG_DEBUG, "%8d %"PRIu32" (%"PRIu32" bytes)\n", + i, ape_ctx->seektable[i], + ape_ctx->seektable[i + 1] - ape_ctx->seektable[i]); } else { - av_log(s, AV_LOG_DEBUG, "%8d %d\n", i, ape_ctx->seektable[i]); + av_log(s, AV_LOG_DEBUG, "%8d %"PRIu32"\n", i, ape_ctx->seektable[i]); } } } @@ -169,7 +171,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) ape->fileversion = avio_rl16(pb); if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) { - av_log(s, AV_LOG_ERROR, "Unsupported file version - %"PRId16".%02"PRId16"\n", + av_log(s, AV_LOG_ERROR, "Unsupported file version - %d.%02d\n", ape->fileversion / 1000, (ape->fileversion % 1000) / 10); return -1; } @@ -253,7 +255,8 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) return -1; } if (ape->seektablelength && (ape->seektablelength / sizeof(*ape->seektable)) < ape->totalframes) { - av_log(s, AV_LOG_ERROR, "Number of seek entries is less than number of frames: %ld vs. %"PRIu32"\n", + av_log(s, AV_LOG_ERROR, + "Number of seek entries is less than number of frames: %zu vs. %"PRIu32"\n", ape->seektablelength / sizeof(*ape->seektable), ape->totalframes); return AVERROR_INVALIDDATA; } From 7cbb856efe6ccab7485bb96ad3887472a6519ffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Tue, 26 Jul 2011 22:28:26 +0200 Subject: [PATCH 670/780] Remove useless NULL check. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We dereferenced the pointer two lines above, no point in checking for NULL afterwards. In addition it cannot be NULL the way it was initialized just one line further above. Signed-off-by: Reimar Döffinger --- libavcodec/dv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index bfd5ae4413..bd9290a768 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -1109,7 +1109,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, vsc_pack = buf + 80*5 + 48 + 5; if ( *vsc_pack == dv_video_control ) { apt = buf[4] & 0x07; - is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07))); + is16_9 = (vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07); avctx->sample_aspect_ratio = s->sys->sar[is16_9]; } From da4c7cce2100a4e4f9276b4f17e260be47b53f41 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 26 Jul 2011 12:23:43 +0100 Subject: [PATCH 671/780] x86: fix build with gcc 4.7 The upcoming gcc 4.7 has more advanced constant propagation resulting some inline asm operands becoming constants and thus emitted as literals, sometimes in contexts where this results in invalid instructions. This patch changes the constraints of the relevant operands to "rm" thus forcing a valid type. While obviously suboptimal, this is what older gcc versions already did, and there is no change to the code generated with these. Signed-off-by: Mans Rullgard --- libavcodec/x86/h264_qpel_mmx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/x86/h264_qpel_mmx.c b/libavcodec/x86/h264_qpel_mmx.c index 91ba39f1da..b7a4183c1b 100644 --- a/libavcodec/x86/h264_qpel_mmx.c +++ b/libavcodec/x86/h264_qpel_mmx.c @@ -399,7 +399,7 @@ static av_noinline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, "2: \n\t"\ \ : "+a"(src), "+c"(dst)\ - : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\ + : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\ : "memory"\ );\ src += 4-(h+5)*srcStride;\ @@ -447,7 +447,7 @@ static av_always_inline void OPNAME ## h264_qpel8or16_hv1_lowpass_ ## MMX(int16_ QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\ "2: \n\t"\ : "+a"(src)\ - : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)\ + : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)\ : "memory"\ );\ tmp += 4;\ @@ -824,7 +824,7 @@ static av_noinline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, "2: \n\t"\ \ : "+a"(src), "+c"(dst)\ - : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\ + : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\ : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \ "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\ "memory"\ @@ -879,7 +879,7 @@ static av_always_inline void put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp, u QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48) "2: \n\t" : "+a"(src) - : "c"(tmp), "S"((x86_reg)srcStride), "g"(size) + : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size) : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7",) "memory" From 9b3139ebca0ee1e97c6f72e25607dee5f4ecdf89 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 14 Jul 2011 00:00:43 +0200 Subject: [PATCH 672/780] dctref: make sure function declarations match between .c and .h file --- libavcodec/dctref.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/dctref.h b/libavcodec/dctref.h index ba89abd752..a93b70d9f2 100644 --- a/libavcodec/dctref.h +++ b/libavcodec/dctref.h @@ -22,10 +22,8 @@ #ifndef AVCODEC_DCTREF_H #define AVCODEC_DCTREF_H -#include "dsputil.h" - -void ff_ref_fdct(DCTELEM *block); -void ff_ref_idct(DCTELEM *block); +void ff_ref_fdct(short *block); +void ff_ref_idct(short *block); void ff_ref_dct_init(void); #endif /* AVCODEC_DCTREF_H */ From 001e600c3b8668191f96d7a1e46da0d7fff546de Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 13 Jul 2011 18:12:43 +0200 Subject: [PATCH 673/780] configure: spelling cosmetics --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index a83d3396e1..ef2c566d85 100755 --- a/configure +++ b/configure @@ -3404,5 +3404,5 @@ pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extr pkgconfig_generate libavformat "Libav container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION" pkgconfig_generate libavdevice "Libav device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION" pkgconfig_generate libavfilter "Libav video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" -pkgconfig_generate libpostproc "Libav post processing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION" +pkgconfig_generate libpostproc "Libav postprocessing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION" pkgconfig_generate libswscale "Libav image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION" From 64bb65632645e56482c250e5ac48b1049dbb627a Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 25 Jul 2011 14:09:55 +0200 Subject: [PATCH 674/780] lsws: factorize some logging code in sws_init_context() --- libswscale/utils.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 91bb5bb927..8cb6f5f674 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1069,29 +1069,17 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) if (c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR)) av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR MMX2 scaler for horizontal scaling\n"); else { - if (c->hLumFilterSize==4) - av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizontal luminance scaling\n"); - else if (c->hLumFilterSize==8) - av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizontal luminance scaling\n"); - else - av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizontal luminance scaling\n"); - - if (c->hChrFilterSize==4) - av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizontal chrominance scaling\n"); - else if (c->hChrFilterSize==8) - av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizontal chrominance scaling\n"); - else - av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizontal chrominance scaling\n"); + av_log(c, AV_LOG_VERBOSE, "using %s-tap MMX scaler for horizontal luminance scaling\n", + c->hLumFilterSize == 4 ? "4" : + c->hLumFilterSize == 8 ? "8" : "n"); + av_log(c, AV_LOG_VERBOSE, "using %s-tap MMX scaler for horizontal chrominance scaling\n", + c->hChrFilterSize == 4 ? "4" : + c->hChrFilterSize == 8 ? "8" : "n"); } } else { -#if HAVE_MMX - av_log(c, AV_LOG_VERBOSE, "using x86 asm scaler for horizontal scaling\n"); -#else - if (flags & SWS_FAST_BILINEAR) - av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR C scaler for horizontal scaling\n"); - else - av_log(c, AV_LOG_VERBOSE, "using C scaler for horizontal scaling\n"); -#endif + av_log(c, AV_LOG_VERBOSE, "using %s scaler for horizontal scaling\n", + HAVE_MMX ? "x86 asm" : + flags & SWS_FAST_BILINEAR ? "FAST_BILINEAR C" : "C"); } if (isPlanarYUV(dstFormat)) { if (c->vLumFilterSize==1) From 07f49ca1d1027f57400acbf7ca1aada9a1812648 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 25 Jul 2011 13:04:11 +0200 Subject: [PATCH 675/780] lsws: remove redundant macros isSupportedIn/Out Directly call sws_isSupportedInput/Output. --- libswscale/utils.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 8cb6f5f674..7e8d9719fd 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -140,15 +140,11 @@ const static FormatEntry format_entries[PIX_FMT_NB] = { [PIX_FMT_YUV444P10LE] = { 1 , 0 }, }; -#define isSupportedIn(x) (format_entries[x].is_supported_in) - int sws_isSupportedInput(enum PixelFormat pix_fmt) { return format_entries[pix_fmt].is_supported_in; } -#define isSupportedOut(x) (format_entries[x].is_supported_out) - int sws_isSupportedOutput(enum PixelFormat pix_fmt) { return format_entries[pix_fmt].is_supported_out; @@ -759,11 +755,11 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) unscaled = (srcW == dstW && srcH == dstH); - if (!isSupportedIn(srcFormat)) { + if (!sws_isSupportedInput(srcFormat)) { av_log(c, AV_LOG_ERROR, "%s is not supported as input pixel format\n", av_get_pix_fmt_name(srcFormat)); return AVERROR(EINVAL); } - if (!isSupportedOut(dstFormat)) { + if (!sws_isSupportedOutput(dstFormat)) { av_log(c, AV_LOG_ERROR, "%s is not supported as output pixel format\n", av_get_pix_fmt_name(dstFormat)); return AVERROR(EINVAL); } From e324619ca9294458892b29dfdbdcce9cb65363a7 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 24 Jul 2011 15:38:59 +0200 Subject: [PATCH 676/780] imgconvert: change logic in avcodec_get_pix_fmt_loss() Avoid the use of the brittle/inconsistent information in PixFmtInfo.depth, and implement a possibly more robust logic which exposes the information in pixdesc. Also allow the removal of PixFmtInfo.depth, since this is the only use of it. --- libavcodec/imgconvert.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index fbe8141336..c48478cafc 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -393,28 +393,50 @@ int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height) return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height); } +static int get_pix_fmt_depth(int *min, int *max, enum PixelFormat pix_fmt) +{ + const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + int i; + + if (!desc->nb_components) { + *min = *max = 0; + return AVERROR(EINVAL); + } + + *min = INT_MAX, *max = -INT_MAX; + for (i = 0; i < desc->nb_components; i++) { + *min = FFMIN(desc->comp[i].depth_minus1+1, *min); + *max = FFMAX(desc->comp[i].depth_minus1+1, *max); + } + return 0; +} + int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt, int has_alpha) { const PixFmtInfo *pf, *ps; const AVPixFmtDescriptor *src_desc = &av_pix_fmt_descriptors[src_pix_fmt]; const AVPixFmtDescriptor *dst_desc = &av_pix_fmt_descriptors[dst_pix_fmt]; - int loss; + int src_min_depth, src_max_depth, dst_min_depth, dst_max_depth; + int ret, loss; ps = &pix_fmt_info[src_pix_fmt]; /* compute loss */ loss = 0; - pf = &pix_fmt_info[dst_pix_fmt]; - if (pf->depth < ps->depth || - ((dst_pix_fmt == PIX_FMT_RGB555BE || dst_pix_fmt == PIX_FMT_RGB555LE || - dst_pix_fmt == PIX_FMT_BGR555BE || dst_pix_fmt == PIX_FMT_BGR555LE) && - (src_pix_fmt == PIX_FMT_RGB565BE || src_pix_fmt == PIX_FMT_RGB565LE || - src_pix_fmt == PIX_FMT_BGR565BE || src_pix_fmt == PIX_FMT_BGR565LE))) + + if ((ret = get_pix_fmt_depth(&src_min_depth, &src_max_depth, src_pix_fmt)) < 0) + return ret; + if ((ret = get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) < 0) + return ret; + if (dst_min_depth < src_min_depth || + dst_max_depth < src_max_depth) loss |= FF_LOSS_DEPTH; if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w || dst_desc->log2_chroma_h > src_desc->log2_chroma_h) loss |= FF_LOSS_RESOLUTION; + + pf = &pix_fmt_info[dst_pix_fmt]; switch(pf->color_type) { case FF_COLOR_RGB: if (ps->color_type != FF_COLOR_RGB && From 90b043a698d6ffd78ac01774af5840ab327a203e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 27 Jul 2011 02:01:14 +0200 Subject: [PATCH 677/780] examples/muxing.c: fix typo, futur -> future --- doc/examples/muxing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c index 9f94a7808c..38aa3006ba 100644 --- a/doc/examples/muxing.c +++ b/doc/examples/muxing.c @@ -372,7 +372,7 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st) if (oc->oformat->flags & AVFMT_RAWPICTURE) { /* raw video case. The API will change slightly in the near - futur for that */ + future for that. */ AVPacket pkt; av_init_packet(&pkt); From c617d7b86a69aefafb0a5d6a9f916f9c97974c8f Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 27 Jul 2011 02:04:53 +0200 Subject: [PATCH 678/780] examples/muxing.c: apply misc style fixes --- doc/examples/muxing.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c index 38aa3006ba..fee987f5e9 100644 --- a/doc/examples/muxing.c +++ b/doc/examples/muxing.c @@ -81,7 +81,7 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum CodecID codec_id) c->channels = 2; // some formats want stream headers to be separate - if(oc->oformat->flags & AVFMT_GLOBALHEADER) + if (oc->oformat->flags & AVFMT_GLOBALHEADER) c->flags |= CODEC_FLAG_GLOBAL_HEADER; return st; @@ -144,7 +144,7 @@ static void get_audio_frame(int16_t *samples, int frame_size, int nb_channels) int16_t *q; q = samples; - for(j=0;jchannels); - pkt.size= avcodec_encode_audio(c, audio_outbuf, audio_outbuf_size, samples); + pkt.size = avcodec_encode_audio(c, audio_outbuf, audio_outbuf_size, samples); if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base); pkt.flags |= AV_PKT_FLAG_KEY; - pkt.stream_index= st->index; - pkt.data= audio_outbuf; + pkt.stream_index = st->index; + pkt.data = audio_outbuf; /* write the compressed frame in the media file */ if (av_interleaved_write_frame(oc, &pkt) != 0) { @@ -233,7 +233,7 @@ static AVStream *add_video_stream(AVFormatContext *oc, enum CodecID codec_id) c->mb_decision=2; } // some formats want stream headers to be separate - if(oc->oformat->flags & AVFMT_GLOBALHEADER) + if (oc->oformat->flags & AVFMT_GLOBALHEADER) c->flags |= CODEC_FLAG_GLOBAL_HEADER; return st; @@ -319,15 +319,15 @@ static void fill_yuv_image(AVFrame *pict, int frame_index, int width, int height i = frame_index; /* Y */ - for(y=0;ydata[0][y * pict->linesize[0] + x] = x + y + i * 3; } } /* Cb and Cr */ - for(y=0;ydata[1][y * pict->linesize[1] + x] = 128 + y + i * 2; pict->data[2][y * pict->linesize[2] + x] = 64 + x + i * 5; } @@ -377,9 +377,9 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st) av_init_packet(&pkt); pkt.flags |= AV_PKT_FLAG_KEY; - pkt.stream_index= st->index; - pkt.data= (uint8_t *)picture; - pkt.size= sizeof(AVPicture); + pkt.stream_index = st->index; + pkt.data = (uint8_t *)picture; + pkt.size = sizeof(AVPicture); ret = av_interleaved_write_frame(oc, &pkt); } else { @@ -394,9 +394,9 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st) pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base); if(c->coded_frame->key_frame) pkt.flags |= AV_PKT_FLAG_KEY; - pkt.stream_index= st->index; - pkt.data= video_outbuf; - pkt.size= out_size; + pkt.stream_index = st->index; + pkt.data = video_outbuf; + pkt.size = out_size; /* write the compressed frame in the media file */ ret = av_interleaved_write_frame(oc, &pkt); @@ -458,7 +458,7 @@ int main(int argc, char **argv) if (!oc) { exit(1); } - fmt= oc->oformat; + fmt = oc->oformat; /* add the audio and video streams using the default format codecs and initialize the codecs */ From 2968bedf129558024ea87a1aabc4aa2d3a5bcb6e Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 23 Jul 2011 15:46:35 +0200 Subject: [PATCH 679/780] bink: make IDCT take 32-bit input Since IDCT transforming 32-bit input to 8-bit output is unusual and unpractical for most codecs, move Bink IDCT into separate context. Get rid of an additional permutation table while at it since SIMD support for Bink IDCT is unlikely to be implemented in foreseeable future. Quantisation tables also have to change type to signed for proper dequantisation of DCT coefficients. Signed-off-by: Mans Rullgard --- libavcodec/Makefile | 2 +- libavcodec/bink.c | 58 ++++++++++++++-------------- libavcodec/binkdata.h | 4 +- libavcodec/{binkidct.c => binkdsp.c} | 21 ++++++---- libavcodec/binkdsp.h | 39 +++++++++++++++++++ libavcodec/dsputil.c | 5 --- 6 files changed, 86 insertions(+), 43 deletions(-) rename libavcodec/{binkidct.c => binkdsp.c} (86%) create mode 100644 libavcodec/binkdsp.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 99ecbbf567..36e07a9fc1 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -89,7 +89,7 @@ OBJS-$(CONFIG_AURA2_DECODER) += aura.o OBJS-$(CONFIG_AVS_DECODER) += avs.o OBJS-$(CONFIG_BETHSOFTVID_DECODER) += bethsoftvideo.o OBJS-$(CONFIG_BFI_DECODER) += bfi.o -OBJS-$(CONFIG_BINK_DECODER) += bink.o binkidct.o +OBJS-$(CONFIG_BINK_DECODER) += bink.o binkdsp.o OBJS-$(CONFIG_BINKAUDIO_DCT_DECODER) += binkaudio.o wma.o OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o wma.o OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o diff --git a/libavcodec/bink.c b/libavcodec/bink.c index e085aa54e2..8e989d9dd9 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -24,6 +24,7 @@ #include "avcodec.h" #include "dsputil.h" #include "binkdata.h" +#include "binkdsp.h" #include "mathops.h" #define ALT_BITSTREAM_READER_LE @@ -60,8 +61,8 @@ static const int binkb_bundle_signed[BINKB_NB_SRC] = { 0, 0, 0, 1, 1, 0, 1, 0, 0, 0 }; -static uint32_t binkb_intra_quant[16][64]; -static uint32_t binkb_inter_quant[16][64]; +static int32_t binkb_intra_quant[16][64]; +static int32_t binkb_inter_quant[16][64]; /** * IDs for different data types used in Bink video codec @@ -109,11 +110,11 @@ typedef struct Bundle { typedef struct BinkContext { AVCodecContext *avctx; DSPContext dsp; + BinkDSPContext bdsp; AVFrame pic, last; int version; ///< internal Bink file version int has_alpha; int swap_planes; - ScanTable scantable; ///< permutated scantable for DCT coeffs decoding Bundle bundle[BINKB_NB_SRC]; ///< bundles for decoding all data types Tree col_high[16]; ///< trees for decoding high nibble in "colours" data type @@ -580,8 +581,8 @@ static inline int binkb_get_value(BinkContext *c, int bundle_num) * @param quant_matrices quantization matrices * @return 0 for success, negative value in other cases */ -static int read_dct_coeffs(GetBitContext *gb, DCTELEM block[64], const uint8_t *scan, - const uint32_t quant_matrices[16][64], int q) +static int read_dct_coeffs(GetBitContext *gb, int32_t block[64], const uint8_t *scan, + const int32_t quant_matrices[16][64], int q) { int coef_list[128]; int mode_list[128]; @@ -590,7 +591,7 @@ static int read_dct_coeffs(GetBitContext *gb, DCTELEM block[64], const uint8_t * int coef_count = 0; int coef_idx[64]; int quant_idx; - const uint32_t *quant; + const int32_t *quant; coef_list[list_end] = 4; mode_list[list_end++] = 0; coef_list[list_end] = 24; mode_list[list_end++] = 0; @@ -791,6 +792,7 @@ static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, const uint8_t *scan; int xoff, yoff; LOCAL_ALIGNED_16(DCTELEM, block, [64]); + LOCAL_ALIGNED_16(int32_t, dctblock, [64]); int coordmap[64]; int ybias = is_key ? -15 : 0; int qp; @@ -845,11 +847,11 @@ static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS); break; case 2: - c->dsp.clear_block(block); - block[0] = binkb_get_value(c, BINKB_SRC_INTRA_DC); + memset(dctblock, 0, sizeof(*dctblock) * 64); + dctblock[0] = binkb_get_value(c, BINKB_SRC_INTRA_DC); qp = binkb_get_value(c, BINKB_SRC_INTRA_Q); - read_dct_coeffs(gb, block, c->scantable.permutated, binkb_intra_quant, qp); - c->dsp.idct_put(dst, stride, block); + read_dct_coeffs(gb, dctblock, bink_scan, binkb_intra_quant, qp); + c->bdsp.idct_put(dst, stride, dctblock); break; case 3: xoff = binkb_get_value(c, BINKB_SRC_X_OFF); @@ -878,11 +880,11 @@ static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, } else { put_pixels8x8_overlapped(dst, ref, stride); } - c->dsp.clear_block(block); - block[0] = binkb_get_value(c, BINKB_SRC_INTER_DC); + memset(dctblock, 0, sizeof(*dctblock) * 64); + dctblock[0] = binkb_get_value(c, BINKB_SRC_INTER_DC); qp = binkb_get_value(c, BINKB_SRC_INTER_Q); - read_dct_coeffs(gb, block, c->scantable.permutated, binkb_inter_quant, qp); - c->dsp.idct_add(dst, stride, block); + read_dct_coeffs(gb, dctblock, bink_scan, binkb_inter_quant, qp); + c->bdsp.idct_add(dst, stride, dctblock); break; case 5: v = binkb_get_value(c, BINKB_SRC_COLORS); @@ -937,6 +939,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, int xoff, yoff; LOCAL_ALIGNED_16(DCTELEM, block, [64]); LOCAL_ALIGNED_16(uint8_t, ublock, [64]); + LOCAL_ALIGNED_16(int32_t, dctblock, [64]); int coordmap[64]; const int stride = c->pic.linesize[plane_idx]; @@ -1019,11 +1022,10 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, ublock[*scan++] = get_value(c, BINK_SRC_COLORS); break; case INTRA_BLOCK: - c->dsp.clear_block(block); - block[0] = get_value(c, BINK_SRC_INTRA_DC); - read_dct_coeffs(gb, block, c->scantable.permutated, bink_intra_quant, -1); - c->dsp.idct(block); - c->dsp.put_pixels_nonclamped(block, ublock, 8); + memset(dctblock, 0, sizeof(*dctblock) * 64); + dctblock[0] = get_value(c, BINK_SRC_INTRA_DC); + read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1); + c->bdsp.idct_put(ublock, 8, dctblock); break; case FILL_BLOCK: v = get_value(c, BINK_SRC_COLORS); @@ -1103,10 +1105,10 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, c->dsp.add_pixels8(dst, block, stride); break; case INTRA_BLOCK: - c->dsp.clear_block(block); - block[0] = get_value(c, BINK_SRC_INTRA_DC); - read_dct_coeffs(gb, block, c->scantable.permutated, bink_intra_quant, -1); - c->dsp.idct_put(dst, stride, block); + memset(dctblock, 0, sizeof(*dctblock) * 64); + dctblock[0] = get_value(c, BINK_SRC_INTRA_DC); + read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1); + c->bdsp.idct_put(dst, stride, dctblock); break; case FILL_BLOCK: v = get_value(c, BINK_SRC_COLORS); @@ -1117,10 +1119,10 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, yoff = get_value(c, BINK_SRC_Y_OFF); ref = prev + xoff + yoff * stride; c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8); - c->dsp.clear_block(block); - block[0] = get_value(c, BINK_SRC_INTER_DC); - read_dct_coeffs(gb, block, c->scantable.permutated, bink_inter_quant, -1); - c->dsp.idct_add(dst, stride, block); + memset(dctblock, 0, sizeof(*dctblock) * 64); + dctblock[0] = get_value(c, BINK_SRC_INTER_DC); + read_dct_coeffs(gb, dctblock, bink_scan, bink_inter_quant, -1); + c->bdsp.idct_add(dst, stride, dctblock); break; case PATTERN_BLOCK: for (i = 0; i < 2; i++) @@ -1288,7 +1290,7 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->idct_algo = FF_IDCT_BINK; dsputil_init(&c->dsp, avctx); - ff_init_scantable(c->dsp.idct_permutation, &c->scantable, bink_scan); + ff_binkdsp_init(&c->bdsp); init_bundles(c); diff --git a/libavcodec/binkdata.h b/libavcodec/binkdata.h index db289ad3a1..60f0a59b49 100644 --- a/libavcodec/binkdata.h +++ b/libavcodec/binkdata.h @@ -285,7 +285,7 @@ static const uint8_t bink_patterns[16][64] = { } }; -static const uint32_t bink_intra_quant[16][64] = { +static const int32_t bink_intra_quant[16][64] = { { 0x010000, 0x016315, 0x01E83D, 0x02A535, 0x014E7B, 0x016577, 0x02F1E6, 0x02724C, 0x010000, 0x00EEDA, 0x024102, 0x017F9B, 0x00BE80, 0x00611E, 0x01083C, 0x00A552, @@ -448,7 +448,7 @@ static const uint32_t bink_intra_quant[16][64] = { }, }; -static const uint32_t bink_inter_quant[16][64] = { +static const int32_t bink_inter_quant[16][64] = { { 0x010000, 0x017946, 0x01A5A9, 0x0248DC, 0x016363, 0x0152A7, 0x0243EC, 0x0209EA, 0x012000, 0x00E248, 0x01BBDA, 0x015CBC, 0x00A486, 0x0053E0, 0x00F036, 0x008095, diff --git a/libavcodec/binkidct.c b/libavcodec/binkdsp.c similarity index 86% rename from libavcodec/binkidct.c rename to libavcodec/binkdsp.c index 2326a616d5..109906f262 100644 --- a/libavcodec/binkidct.c +++ b/libavcodec/binkdsp.c @@ -1,5 +1,5 @@ /* - * Bink IDCT algorithm + * Bink DSP routines * Copyright (c) 2009 Kostya Shishkov * * This file is part of Libav. @@ -21,10 +21,11 @@ /** * @file - * Bink IDCT algorithm + * Bink DSP routines */ #include "dsputil.h" +#include "binkdsp.h" #define A1 2896 /* (1/sqrt(2))<<12 */ #define A2 2217 @@ -62,7 +63,7 @@ #define MUNGE_ROW(x) (((x) + 0x7F)>>8) #define IDCT_ROW(dest,src) IDCT_TRANSFORM(dest,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,MUNGE_ROW,src) -static inline void bink_idct_col(int *dest, const DCTELEM *src) +static inline void bink_idct_col(int *dest, const int32_t *src) { if ((src[8]|src[16]|src[24]|src[32]|src[40]|src[48]|src[56])==0) { dest[0] = @@ -78,7 +79,7 @@ static inline void bink_idct_col(int *dest, const DCTELEM *src) } } -void ff_bink_idct_c(DCTELEM *block) +static void bink_idct_c(int32_t *block) { int i; int temp[64]; @@ -90,17 +91,17 @@ void ff_bink_idct_c(DCTELEM *block) } } -void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block) +static void bink_idct_add_c(uint8_t *dest, int linesize, int32_t *block) { int i, j; - ff_bink_idct_c(block); + bink_idct_c(block); for (i = 0; i < 8; i++, dest += linesize, block += 8) for (j = 0; j < 8; j++) dest[j] += block[j]; } -void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block) +static void bink_idct_put_c(uint8_t *dest, int linesize, int32_t *block) { int i; int temp[64]; @@ -110,3 +111,9 @@ void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block) IDCT_ROW( (&dest[i*linesize]), (&temp[8*i]) ); } } + +void ff_binkdsp_init(BinkDSPContext *c) +{ + c->idct_add = bink_idct_add_c; + c->idct_put = bink_idct_put_c; +} diff --git a/libavcodec/binkdsp.h b/libavcodec/binkdsp.h new file mode 100644 index 0000000000..8253ab3004 --- /dev/null +++ b/libavcodec/binkdsp.h @@ -0,0 +1,39 @@ +/* + * Bink DSP routines + * Copyright (c) 2009 Kostya Shishkov + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Bink DSP routines + */ + +#ifndef AVCODEC_BINKDSP_H +#define AVCODEC_BINKDSP_H + +#include "dsputil.h" + +typedef struct BinkDSPContext { + void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, int32_t *block/*align 16*/); + void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, int32_t *block/*align 16*/); +} BinkDSPContext; + +void ff_binkdsp_init(BinkDSPContext *c); + +#endif /* AVCODEC_BINKDSP_H */ diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 09e58f46d2..04c2ff67a4 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -2894,11 +2894,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) }else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) { c->idct_put= ff_ea_idct_put_c; c->idct_permutation_type= FF_NO_IDCT_PERM; - }else if(CONFIG_BINK_DECODER && avctx->idct_algo==FF_IDCT_BINK) { - c->idct = ff_bink_idct_c; - c->idct_add = ff_bink_idct_add_c; - c->idct_put = ff_bink_idct_put_c; - c->idct_permutation_type = FF_NO_IDCT_PERM; }else{ //accurate/default c->idct_put = ff_simple_idct_put_8; c->idct_add = ff_simple_idct_add_8; From cbd58a872d343f5996ed7ab917c8839dbfd99eaa Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 27 Jul 2011 14:47:56 +0100 Subject: [PATCH 680/780] dsputil: remove some unused functions Signed-off-by: Mans Rullgard --- libavcodec/arm/dsputil_init_neon.c | 14 ---- libavcodec/arm/dsputil_neon.S | 104 ----------------------------- libavcodec/dsputil.c | 72 -------------------- libavcodec/dsputil.h | 27 -------- 4 files changed, 217 deletions(-) diff --git a/libavcodec/arm/dsputil_init_neon.c b/libavcodec/arm/dsputil_init_neon.c index 238fdae41f..101bd055a1 100644 --- a/libavcodec/arm/dsputil_init_neon.c +++ b/libavcodec/arm/dsputil_init_neon.c @@ -143,14 +143,6 @@ void ff_vector_fmul_window_neon(float *dst, const float *src0, const float *src1, const float *win, int len); void ff_vector_fmul_scalar_neon(float *dst, const float *src, float mul, int len); -void ff_vector_fmul_sv_scalar_2_neon(float *dst, const float *src, - const float **vp, float mul, int len); -void ff_vector_fmul_sv_scalar_4_neon(float *dst, const float *src, - const float **vp, float mul, int len); -void ff_sv_fmul_scalar_2_neon(float *dst, const float **vp, float mul, - int len); -void ff_sv_fmul_scalar_4_neon(float *dst, const float **vp, float mul, - int len); void ff_butterflies_float_neon(float *v1, float *v2, int len); float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len); void ff_vector_fmul_reverse_neon(float *dst, const float *src0, @@ -320,12 +312,6 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) c->vector_clipf = ff_vector_clipf_neon; c->vector_clip_int32 = ff_vector_clip_int32_neon; - c->vector_fmul_sv_scalar[0] = ff_vector_fmul_sv_scalar_2_neon; - c->vector_fmul_sv_scalar[1] = ff_vector_fmul_sv_scalar_4_neon; - - c->sv_fmul_scalar[0] = ff_sv_fmul_scalar_2_neon; - c->sv_fmul_scalar[1] = ff_sv_fmul_scalar_4_neon; - if (CONFIG_VORBIS_DECODER) c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_neon; diff --git a/libavcodec/arm/dsputil_neon.S b/libavcodec/arm/dsputil_neon.S index 3b9b542a68..aef8a129ee 100644 --- a/libavcodec/arm/dsputil_neon.S +++ b/libavcodec/arm/dsputil_neon.S @@ -587,110 +587,6 @@ NOVFP vdup.32 q8, r2 .unreq len endfunc -function ff_vector_fmul_sv_scalar_2_neon, export=1 -VFP vdup.32 d16, d0[0] -NOVFP vdup.32 d16, r3 -NOVFP ldr r3, [sp] - vld1.32 {d0},[r1,:64]! - vld1.32 {d1},[r1,:64]! -1: subs r3, r3, #4 - vmul.f32 d4, d0, d16 - vmul.f32 d5, d1, d16 - ldr r12, [r2], #4 - vld1.32 {d2},[r12,:64] - ldr r12, [r2], #4 - vld1.32 {d3},[r12,:64] - vmul.f32 d4, d4, d2 - vmul.f32 d5, d5, d3 - beq 2f - vld1.32 {d0},[r1,:64]! - vld1.32 {d1},[r1,:64]! - vst1.32 {d4},[r0,:64]! - vst1.32 {d5},[r0,:64]! - b 1b -2: vst1.32 {d4},[r0,:64]! - vst1.32 {d5},[r0,:64]! - bx lr -endfunc - -function ff_vector_fmul_sv_scalar_4_neon, export=1 -VFP vdup.32 q10, d0[0] -NOVFP vdup.32 q10, r3 -NOVFP ldr r3, [sp] - push {lr} - bics lr, r3, #7 - beq 3f - vld1.32 {q0},[r1,:128]! - vld1.32 {q2},[r1,:128]! -1: ldr r12, [r2], #4 - vld1.32 {q1},[r12,:128] - ldr r12, [r2], #4 - vld1.32 {q3},[r12,:128] - vmul.f32 q8, q0, q10 - vmul.f32 q8, q8, q1 - vmul.f32 q9, q2, q10 - vmul.f32 q9, q9, q3 - subs lr, lr, #8 - beq 2f - vld1.32 {q0},[r1,:128]! - vld1.32 {q2},[r1,:128]! - vst1.32 {q8},[r0,:128]! - vst1.32 {q9},[r0,:128]! - b 1b -2: vst1.32 {q8},[r0,:128]! - vst1.32 {q9},[r0,:128]! - ands r3, r3, #7 - it eq - popeq {pc} -3: vld1.32 {q0},[r1,:128]! - ldr r12, [r2], #4 - vld1.32 {q1},[r12,:128] - vmul.f32 q0, q0, q10 - vmul.f32 q0, q0, q1 - vst1.32 {q0},[r0,:128]! - subs r3, r3, #4 - bgt 3b - pop {pc} -endfunc - -function ff_sv_fmul_scalar_2_neon, export=1 -VFP len .req r2 -NOVFP len .req r3 -VFP vdup.32 q8, d0[0] -NOVFP vdup.32 q8, r2 - ldr r12, [r1], #4 - vld1.32 {d0},[r12,:64] - ldr r12, [r1], #4 - vld1.32 {d1},[r12,:64] -1: vmul.f32 q1, q0, q8 - subs len, len, #4 - beq 2f - ldr r12, [r1], #4 - vld1.32 {d0},[r12,:64] - ldr r12, [r1], #4 - vld1.32 {d1},[r12,:64] - vst1.32 {q1},[r0,:128]! - b 1b -2: vst1.32 {q1},[r0,:128]! - bx lr - .unreq len -endfunc - -function ff_sv_fmul_scalar_4_neon, export=1 -VFP len .req r2 -NOVFP len .req r3 -VFP vdup.32 q8, d0[0] -NOVFP vdup.32 q8, r2 -1: ldr r12, [r1], #4 - vld1.32 {q0},[r12,:128] - vmul.f32 q0, q0, q8 - vst1.32 {q0},[r0,:128]! - subs len, len, #4 - bgt 1b - bx lr - .unreq len -endfunc - function ff_butterflies_float_neon, export=1 1: vld1.32 {q0},[r0,:128] vld1.32 {q1},[r1,:128] diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 04c2ff67a4..e1be534585 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -405,27 +405,6 @@ void ff_put_signed_pixels_clamped_c(const DCTELEM *block, } } -static void put_pixels_nonclamped_c(const DCTELEM *block, uint8_t *restrict pixels, - int line_size) -{ - int i; - - /* read the pixels */ - for(i=0;i<8;i++) { - pixels[0] = block[0]; - pixels[1] = block[1]; - pixels[2] = block[2]; - pixels[3] = block[3]; - pixels[4] = block[4]; - pixels[5] = block[5]; - pixels[6] = block[6]; - pixels[7] = block[7]; - - pixels += line_size; - block += 8; - } -} - void ff_add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels, int line_size) { @@ -2492,50 +2471,6 @@ static void vector_fmul_scalar_c(float *dst, const float *src, float mul, dst[i] = src[i] * mul; } -static void vector_fmul_sv_scalar_2_c(float *dst, const float *src, - const float **sv, float mul, int len) -{ - int i; - for (i = 0; i < len; i += 2, sv++) { - dst[i ] = src[i ] * sv[0][0] * mul; - dst[i+1] = src[i+1] * sv[0][1] * mul; - } -} - -static void vector_fmul_sv_scalar_4_c(float *dst, const float *src, - const float **sv, float mul, int len) -{ - int i; - for (i = 0; i < len; i += 4, sv++) { - dst[i ] = src[i ] * sv[0][0] * mul; - dst[i+1] = src[i+1] * sv[0][1] * mul; - dst[i+2] = src[i+2] * sv[0][2] * mul; - dst[i+3] = src[i+3] * sv[0][3] * mul; - } -} - -static void sv_fmul_scalar_2_c(float *dst, const float **sv, float mul, - int len) -{ - int i; - for (i = 0; i < len; i += 2, sv++) { - dst[i ] = sv[0][0] * mul; - dst[i+1] = sv[0][1] * mul; - } -} - -static void sv_fmul_scalar_4_c(float *dst, const float **sv, float mul, - int len) -{ - int i; - for (i = 0; i < len; i += 4, sv++) { - dst[i ] = sv[0][0] * mul; - dst[i+1] = sv[0][1] * mul; - dst[i+2] = sv[0][2] * mul; - dst[i+3] = sv[0][3] * mul; - } -} - static void butterflies_float_c(float *restrict v1, float *restrict v2, int len) { @@ -2906,7 +2841,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->diff_pixels = diff_pixels_c; c->put_pixels_clamped = ff_put_pixels_clamped_c; c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c; - c->put_pixels_nonclamped = put_pixels_nonclamped_c; c->add_pixels_clamped = ff_add_pixels_clamped_c; c->sum_abs_dctelem = sum_abs_dctelem_c; c->gmc1 = gmc1_c; @@ -3088,12 +3022,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->butterflies_float = butterflies_float_c; c->vector_fmul_scalar = vector_fmul_scalar_c; - c->vector_fmul_sv_scalar[0] = vector_fmul_sv_scalar_2_c; - c->vector_fmul_sv_scalar[1] = vector_fmul_sv_scalar_4_c; - - c->sv_fmul_scalar[0] = sv_fmul_scalar_2_c; - c->sv_fmul_scalar[1] = sv_fmul_scalar_4_c; - c->shrink[0]= av_image_copy_plane; c->shrink[1]= ff_shrink22; c->shrink[2]= ff_shrink44; diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 0ba36d77ec..b6f0607b08 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -229,7 +229,6 @@ typedef struct DSPContext { void (*diff_pixels)(DCTELEM *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride); void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size); void (*put_signed_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size); - void (*put_pixels_nonclamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size); void (*add_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size); void (*add_pixels8)(uint8_t *pixels, DCTELEM *block, int line_size); void (*add_pixels4)(uint8_t *pixels, DCTELEM *block, int line_size); @@ -423,32 +422,6 @@ typedef struct DSPContext { */ void (*vector_fmul_scalar)(float *dst, const float *src, float mul, int len); - /** - * Multiply a vector of floats by concatenated short vectors of - * floats and by a scalar float. Source and destination vectors - * must overlap exactly or not at all. - * [0]: short vectors of length 2, 8-byte aligned - * [1]: short vectors of length 4, 16-byte aligned - * @param dst output vector, 16-byte aligned - * @param src input vector, 16-byte aligned - * @param sv array of pointers to short vectors - * @param mul scalar value - * @param len number of elements in src and dst, multiple of 4 - */ - void (*vector_fmul_sv_scalar[2])(float *dst, const float *src, - const float **sv, float mul, int len); - /** - * Multiply short vectors of floats by a scalar float, store - * concatenated result. - * [0]: short vectors of length 2, 8-byte aligned - * [1]: short vectors of length 4, 16-byte aligned - * @param dst output vector, 16-byte aligned - * @param sv array of pointers to short vectors - * @param mul scalar value - * @param len number of output elements, multiple of 4 - */ - void (*sv_fmul_scalar[2])(float *dst, const float **sv, - float mul, int len); /** * Calculate the scalar product of two vectors of floats. * @param v1 first vector, 16-byte aligned From 1b3539d4534f9877b463fb8b7fa56b7d20dd1338 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 27 Jul 2011 15:47:02 +0100 Subject: [PATCH 681/780] dsputil: move a bink-only function to binkdsp Signed-off-by: Mans Rullgard --- libavcodec/bink.c | 2 +- libavcodec/binkdsp.c | 17 +++++++++++++++++ libavcodec/binkdsp.h | 1 + libavcodec/dsputil.c | 17 ----------------- libavcodec/dsputil.h | 1 - 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 8e989d9dd9..8f42ff8bea 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1050,7 +1050,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, return -1; } if (blk != FILL_BLOCK) - c->dsp.scale_block(ublock, dst, stride); + c->bdsp.scale_block(ublock, dst, stride); bx++; dst += 8; prev += 8; diff --git a/libavcodec/binkdsp.c b/libavcodec/binkdsp.c index 109906f262..1f7855b30b 100644 --- a/libavcodec/binkdsp.c +++ b/libavcodec/binkdsp.c @@ -112,8 +112,25 @@ static void bink_idct_put_c(uint8_t *dest, int linesize, int32_t *block) } } +static void scale_block_c(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize) +{ + int i, j; + uint16_t *dst1 = (uint16_t *) dst; + uint16_t *dst2 = (uint16_t *)(dst + linesize); + + for (j = 0; j < 8; j++) { + for (i = 0; i < 8; i++) { + dst1[i] = dst2[i] = src[i] * 0x0101; + } + src += 8; + dst1 += linesize; + dst2 += linesize; + } +} + void ff_binkdsp_init(BinkDSPContext *c) { c->idct_add = bink_idct_add_c; c->idct_put = bink_idct_put_c; + c->scale_block = scale_block_c; } diff --git a/libavcodec/binkdsp.h b/libavcodec/binkdsp.h index 8253ab3004..d105f717e9 100644 --- a/libavcodec/binkdsp.h +++ b/libavcodec/binkdsp.h @@ -32,6 +32,7 @@ typedef struct BinkDSPContext { void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, int32_t *block/*align 16*/); void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, int32_t *block/*align 16*/); + void (*scale_block)(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize); } BinkDSPContext; void ff_binkdsp_init(BinkDSPContext *c); diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index e1be534585..d31860166d 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -486,22 +486,6 @@ static void fill_block8_c(uint8_t *block, uint8_t value, int line_size, int h) } } -static void scale_block_c(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize) -{ - int i, j; - uint16_t *dst1 = (uint16_t *) dst; - uint16_t *dst2 = (uint16_t *)(dst + linesize); - - for (j = 0; j < 8; j++) { - for (i = 0; i < 8; i++) { - dst1[i] = dst2[i] = src[i] * 0x0101; - } - src += 8; - dst1 += linesize; - dst2 += linesize; - } -} - #define avg2(a,b) ((a+b+1)>>1) #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) @@ -2850,7 +2834,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->fill_block_tab[0] = fill_block16_c; c->fill_block_tab[1] = fill_block8_c; - c->scale_block = scale_block_c; /* TODO [0] 16 [1] 8 */ c->pix_abs[0][0] = pix_abs16_c; diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index b6f0607b08..93fbe9c6f7 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -559,7 +559,6 @@ typedef struct DSPContext { /* bink functions */ op_fill_func fill_block_tab[2]; - void (*scale_block)(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize); } DSPContext; void dsputil_static_init(void); From c358a0364e26ffcd8f5986a85997882e1c36eed2 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 27 Jul 2011 15:49:03 +0100 Subject: [PATCH 682/780] dsputil: remove stale bink prototypes and comments Signed-off-by: Mans Rullgard --- libavcodec/dsputil.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 93fbe9c6f7..536357a529 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -111,11 +111,6 @@ void ff_vp3_idct_dc_add_c(uint8_t *dest/*align 8*/, int line_size, const DCTELEM void ff_vp3_v_loop_filter_c(uint8_t *src, int stride, int *bounding_values); void ff_vp3_h_loop_filter_c(uint8_t *src, int stride, int *bounding_values); -/* Bink functions */ -void ff_bink_idct_c (DCTELEM *block); -void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block); -void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block); - /* EA functions */ void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block); @@ -557,7 +552,6 @@ typedef struct DSPContext { h264_chroma_mc_func put_rv40_chroma_pixels_tab[3]; h264_chroma_mc_func avg_rv40_chroma_pixels_tab[3]; - /* bink functions */ op_fill_func fill_block_tab[2]; } DSPContext; From e72f3d10f64f5c65a67aa21dcc79a85ee55e912e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 27 Jul 2011 16:14:33 +0100 Subject: [PATCH 683/780] dnxhdenc: fix declarations in for loops Apparently the gcc warning doesn't trigger on these. Signed-off-by: Mans Rullgard --- libavcodec/dnxhdenc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 3fb10d4380..1a0c8ce02e 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -79,13 +79,14 @@ static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, DCTELEM *block, const uint8_t *scantable= ctx->intra_scantable.scantable; const int *qmat = ctx->q_intra_matrix[qscale]; int last_non_zero = 0; + int i; ctx->dsp.fdct(block); // Divide by 4 with rounding, to compensate scaling of DCT coefficients block[0] = (block[0] + 2) >> 2; - for (int i = 1; i < 64; ++i) { + for (i = 1; i < 64; ++i) { int j = scantable[i]; int sign = block[j] >> 31; int level = (block[j] ^ sign) - sign; @@ -634,9 +635,10 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int jobnr, int int sum = 0; int sqsum = 0; int mean, sqmean; + int i, j; // Macroblocks are 16x16 pixels, unlike DCT blocks which are 8x8. - for (int i = 0; i < 16; ++i) { - for (int j = 0; j < 16; ++j) { + for (i = 0; i < 16; ++i) { + for (j = 0; j < 16; ++j) { // Turn 16-bit pixels into 10-bit ones. int const sample = (unsigned)pix[j] >> 6; sum += sample; From 1bca72e1bd2fa5db2585a58e452c384ca73bf0eb Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 29 May 2011 19:16:46 -0400 Subject: [PATCH 684/780] eac3enc: support writing of basic mixing and info metadata --- libavcodec/ac3enc.c | 243 ++++++++++++++++++++---------- libavcodec/ac3enc.h | 2 + libavcodec/ac3enc_opts_template.c | 14 +- libavcodec/ac3enc_template.c | 2 +- libavcodec/eac3enc.c | 46 +++++- 5 files changed, 212 insertions(+), 95 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 017b1d4b93..a3b77ec6ed 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -759,6 +759,30 @@ static void count_frame_bits(AC3EncodeContext *s) /* header */ if (s->eac3) { + if (opt->eac3_mixing_metadata) { + if (s->channel_mode > AC3_CHMODE_STEREO) + frame_bits += 2; + if (s->has_center) + frame_bits += 6; + if (s->has_surround) + frame_bits += 6; + frame_bits += s->lfe_on; + frame_bits += 1 + 1 + 2; + if (s->channel_mode < AC3_CHMODE_STEREO) + frame_bits++; + frame_bits++; + } + if (opt->eac3_info_metadata) { + frame_bits += 3 + 1 + 1; + if (s->channel_mode == AC3_CHMODE_STEREO) + frame_bits += 2 + 2; + if (s->channel_mode >= AC3_CHMODE_2F2R) + frame_bits += 2; + frame_bits++; + if (opt->audio_production_info) + frame_bits += 5 + 2 + 1; + frame_bits++; + } /* coupling */ if (s->channel_mode > AC3_CHMODE_MONO) { frame_bits++; @@ -1736,20 +1760,145 @@ int ff_ac3_validate_metadata(AC3EncodeContext *s) AVCodecContext *avctx = s->avctx; AC3EncOptions *opt = &s->options; - /* validate mixing levels */ - if (s->has_center) { - validate_mix_level(avctx, "center_mix_level", &opt->center_mix_level, - cmixlev_options, CMIXLEV_NUM_OPTIONS, 1, 0, - &s->center_mix_level); + opt->audio_production_info = 0; + opt->extended_bsi_1 = 0; + opt->extended_bsi_2 = 0; + opt->eac3_mixing_metadata = 0; + opt->eac3_info_metadata = 0; + + /* determine mixing metadata / xbsi1 use */ + if (s->channel_mode > AC3_CHMODE_STEREO && opt->preferred_stereo_downmix >= 0) { + opt->extended_bsi_1 = 1; + opt->eac3_mixing_metadata = 1; } - if (s->has_surround) { - validate_mix_level(avctx, "surround_mix_level", &opt->surround_mix_level, - surmixlev_options, SURMIXLEV_NUM_OPTIONS, 1, 0, - &s->surround_mix_level); + if (s->has_center && + (opt->ltrt_center_mix_level >= 0 || opt->loro_center_mix_level >= 0)) { + opt->extended_bsi_1 = 1; + opt->eac3_mixing_metadata = 1; + } + if (s->has_surround && + (opt->ltrt_surround_mix_level >= 0 || opt->loro_surround_mix_level >= 0)) { + opt->extended_bsi_1 = 1; + opt->eac3_mixing_metadata = 1; } - /* set audio production info flag */ - if (opt->mixing_level >= 0 || opt->room_type >= 0) { + if (s->eac3) { + /* determine info metadata use */ + if (avctx->audio_service_type != AV_AUDIO_SERVICE_TYPE_MAIN) + opt->eac3_info_metadata = 1; + if (opt->copyright >= 0 || opt->original >= 0) + opt->eac3_info_metadata = 1; + if (s->channel_mode == AC3_CHMODE_STEREO && + (opt->dolby_headphone_mode >= 0 || opt->dolby_surround_mode >= 0)) + opt->eac3_info_metadata = 1; + if (s->channel_mode >= AC3_CHMODE_2F2R && opt->dolby_surround_ex_mode >= 0) + opt->eac3_info_metadata = 1; + if (opt->mixing_level >= 0 || opt->room_type >= 0 || opt->ad_converter_type >= 0) { + opt->audio_production_info = 1; + opt->eac3_info_metadata = 1; + } + } else { + /* determine audio production info use */ + if (opt->mixing_level >= 0 || opt->room_type >= 0) + opt->audio_production_info = 1; + + /* determine xbsi2 use */ + if (s->channel_mode >= AC3_CHMODE_2F2R && opt->dolby_surround_ex_mode >= 0) + opt->extended_bsi_2 = 1; + if (s->channel_mode == AC3_CHMODE_STEREO && opt->dolby_headphone_mode >= 0) + opt->extended_bsi_2 = 1; + if (opt->ad_converter_type >= 0) + opt->extended_bsi_2 = 1; + } + + /* validate AC-3 mixing levels */ + if (!s->eac3) { + if (s->has_center) { + validate_mix_level(avctx, "center_mix_level", &opt->center_mix_level, + cmixlev_options, CMIXLEV_NUM_OPTIONS, 1, 0, + &s->center_mix_level); + } + if (s->has_surround) { + validate_mix_level(avctx, "surround_mix_level", &opt->surround_mix_level, + surmixlev_options, SURMIXLEV_NUM_OPTIONS, 1, 0, + &s->surround_mix_level); + } + } + + /* validate extended bsi 1 / mixing metadata */ + if (opt->extended_bsi_1 || opt->eac3_mixing_metadata) { + /* default preferred stereo downmix */ + if (opt->preferred_stereo_downmix < 0) + opt->preferred_stereo_downmix = 0; + if (!s->eac3 || s->has_center) { + /* validate Lt/Rt center mix level */ + validate_mix_level(avctx, "ltrt_center_mix_level", + &opt->ltrt_center_mix_level, extmixlev_options, + EXTMIXLEV_NUM_OPTIONS, 5, 0, + &s->ltrt_center_mix_level); + /* validate Lo/Ro center mix level */ + validate_mix_level(avctx, "loro_center_mix_level", + &opt->loro_center_mix_level, extmixlev_options, + EXTMIXLEV_NUM_OPTIONS, 5, 0, + &s->loro_center_mix_level); + } + if (!s->eac3 || s->has_surround) { + /* validate Lt/Rt surround mix level */ + validate_mix_level(avctx, "ltrt_surround_mix_level", + &opt->ltrt_surround_mix_level, extmixlev_options, + EXTMIXLEV_NUM_OPTIONS, 6, 3, + &s->ltrt_surround_mix_level); + /* validate Lo/Ro surround mix level */ + validate_mix_level(avctx, "loro_surround_mix_level", + &opt->loro_surround_mix_level, extmixlev_options, + EXTMIXLEV_NUM_OPTIONS, 6, 3, + &s->loro_surround_mix_level); + } + } + + /* validate audio service type / channels combination */ + if ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_KARAOKE && + avctx->channels == 1) || + ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_COMMENTARY || + avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_EMERGENCY || + avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_VOICE_OVER) + && avctx->channels > 1)) { + av_log(avctx, AV_LOG_ERROR, "invalid audio service type for the " + "specified number of channels\n"); + return AVERROR(EINVAL); + } + + /* validate extended bsi 2 / info metadata */ + if (opt->extended_bsi_2 || opt->eac3_info_metadata) { + /* default dolby headphone mode */ + if (opt->dolby_headphone_mode < 0) + opt->dolby_headphone_mode = 0; + /* default dolby surround ex mode */ + if (opt->dolby_surround_ex_mode < 0) + opt->dolby_surround_ex_mode = 0; + /* default A/D converter type */ + if (opt->ad_converter_type < 0) + opt->ad_converter_type = 0; + } + + /* copyright & original defaults */ + if (!s->eac3 || opt->eac3_info_metadata) { + /* default copyright */ + if (opt->copyright < 0) + opt->copyright = 0; + /* default original */ + if (opt->original < 0) + opt->original = 1; + } + + /* dolby surround mode default */ + if (!s->eac3 || opt->eac3_info_metadata) { + if (opt->dolby_surround_mode < 0) + opt->dolby_surround_mode = 0; + } + + /* validate audio production info */ + if (opt->audio_production_info) { if (opt->mixing_level < 0) { av_log(avctx, AV_LOG_ERROR, "mixing_level must be set if " "room_type is set\n"); @@ -1763,66 +1912,10 @@ int ff_ac3_validate_metadata(AC3EncodeContext *s) /* default room type */ if (opt->room_type < 0) opt->room_type = 0; - opt->audio_production_info = 1; - } else { - opt->audio_production_info = 0; - } - - /* set extended bsi 1 flag */ - if ((s->has_center || s->has_surround) && - (opt->preferred_stereo_downmix >= 0 || - opt->ltrt_center_mix_level >= 0 || - opt->ltrt_surround_mix_level >= 0 || - opt->loro_center_mix_level >= 0 || - opt->loro_surround_mix_level >= 0)) { - /* default preferred stereo downmix */ - if (opt->preferred_stereo_downmix < 0) - opt->preferred_stereo_downmix = 0; - /* validate Lt/Rt center mix level */ - validate_mix_level(avctx, "ltrt_center_mix_level", - &opt->ltrt_center_mix_level, extmixlev_options, - EXTMIXLEV_NUM_OPTIONS, 5, 0, - &s->ltrt_center_mix_level); - /* validate Lt/Rt surround mix level */ - validate_mix_level(avctx, "ltrt_surround_mix_level", - &opt->ltrt_surround_mix_level, extmixlev_options, - EXTMIXLEV_NUM_OPTIONS, 6, 3, - &s->ltrt_surround_mix_level); - /* validate Lo/Ro center mix level */ - validate_mix_level(avctx, "loro_center_mix_level", - &opt->loro_center_mix_level, extmixlev_options, - EXTMIXLEV_NUM_OPTIONS, 5, 0, - &s->loro_center_mix_level); - /* validate Lo/Ro surround mix level */ - validate_mix_level(avctx, "loro_surround_mix_level", - &opt->loro_surround_mix_level, extmixlev_options, - EXTMIXLEV_NUM_OPTIONS, 6, 3, - &s->loro_surround_mix_level); - opt->extended_bsi_1 = 1; - } else { - opt->extended_bsi_1 = 0; - } - - /* set extended bsi 2 flag */ - if (opt->dolby_surround_ex_mode >= 0 || - opt->dolby_headphone_mode >= 0 || - opt->ad_converter_type >= 0) { - /* default dolby surround ex mode */ - if (opt->dolby_surround_ex_mode < 0) - opt->dolby_surround_ex_mode = 0; - /* default dolby headphone mode */ - if (opt->dolby_headphone_mode < 0) - opt->dolby_headphone_mode = 0; - /* default A/D converter type */ - if (opt->ad_converter_type < 0) - opt->ad_converter_type = 0; - opt->extended_bsi_2 = 1; - } else { - opt->extended_bsi_2 = 0; } /* set bitstream id for alternate bitstream syntax */ - if (opt->extended_bsi_1 || opt->extended_bsi_2) { + if (!s->eac3 && (opt->extended_bsi_1 || opt->extended_bsi_2)) { if (s->bitstream_id > 8 && s->bitstream_id < 11) { static int warn_once = 1; if (warn_once) { @@ -2041,23 +2134,9 @@ static av_cold int validate_options(AC3EncodeContext *s) if (s->cutoff > (s->sample_rate >> 1)) s->cutoff = s->sample_rate >> 1; - /* validate audio service type / channels combination */ - if ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_KARAOKE && - avctx->channels == 1) || - ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_COMMENTARY || - avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_EMERGENCY || - avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_VOICE_OVER) - && avctx->channels > 1)) { - av_log(avctx, AV_LOG_ERROR, "invalid audio service type for the " - "specified number of channels\n"); - return AVERROR(EINVAL); - } - - if (!s->eac3) { ret = ff_ac3_validate_metadata(s); if (ret) return ret; - } s->rematrixing_enabled = s->options.stereo_rematrixing && (s->channel_mode == AC3_CHMODE_STEREO); diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 407e751b40..6d57143a01 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -91,6 +91,8 @@ typedef struct AC3EncOptions { int dolby_surround_ex_mode; int dolby_headphone_mode; int ad_converter_type; + int eac3_mixing_metadata; + int eac3_info_metadata; /* other encoding options */ int allow_per_frame_metadata; diff --git a/libavcodec/ac3enc_opts_template.c b/libavcodec/ac3enc_opts_template.c index 39138a1083..7c0eead011 100644 --- a/libavcodec/ac3enc_opts_template.c +++ b/libavcodec/ac3enc_opts_template.c @@ -29,12 +29,13 @@ static const AVOption ac3_options[] = { #else /* AC3ENC_TYPE_EAC3 */ static const AVOption eac3_options[] = { #endif -#if AC3ENC_TYPE != AC3ENC_TYPE_EAC3 /* Metadata Options */ {"per_frame_metadata", "Allow Changing Metadata Per-Frame", OFFSET(allow_per_frame_metadata), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, 1, AC3ENC_PARAM}, -/* downmix levels */ +#if AC3ENC_TYPE != AC3ENC_TYPE_EAC3 +/* AC-3 downmix levels */ {"center_mixlev", "Center Mix Level", OFFSET(center_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_4POINT5DB }, 0.0, 1.0, AC3ENC_PARAM}, {"surround_mixlev", "Surround Mix Level", OFFSET(surround_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_6DB }, 0.0, 1.0, AC3ENC_PARAM}, +#endif /* audio production information */ {"mixing_level", "Mixing Level", OFFSET(mixing_level), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 111, AC3ENC_PARAM}, {"room_type", "Room Type", OFFSET(room_type), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 2, AC3ENC_PARAM, "room_type"}, @@ -42,15 +43,13 @@ static const AVOption eac3_options[] = { {"large", "Large Room", 0, FF_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"}, {"small", "Small Room", 0, FF_OPT_TYPE_CONST, {.dbl = 2 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"}, /* other metadata options */ -{"copyright", "Copyright Bit", OFFSET(copyright), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, 1, AC3ENC_PARAM}, -#endif +{"copyright", "Copyright Bit", OFFSET(copyright), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 1, AC3ENC_PARAM}, {"dialnorm", "Dialogue Level (dB)", OFFSET(dialogue_level), FF_OPT_TYPE_INT, {.dbl = -31 }, -31, -1, AC3ENC_PARAM}, -#if AC3ENC_TYPE != AC3ENC_TYPE_EAC3 -{"dsur_mode", "Dolby Surround Mode", OFFSET(dolby_surround_mode), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, 2, AC3ENC_PARAM, "dsur_mode"}, +{"dsur_mode", "Dolby Surround Mode", OFFSET(dolby_surround_mode), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 2, AC3ENC_PARAM, "dsur_mode"}, {"notindicated", "Not Indicated (default)", 0, FF_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"}, {"on", "Dolby Surround Encoded", 0, FF_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"}, {"off", "Not Dolby Surround Encoded", 0, FF_OPT_TYPE_CONST, {.dbl = 2 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"}, -{"original", "Original Bit Stream", OFFSET(original), FF_OPT_TYPE_INT, {.dbl = 1 }, 0, 1, AC3ENC_PARAM}, +{"original", "Original Bit Stream", OFFSET(original), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 1, AC3ENC_PARAM}, /* extended bitstream information */ {"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 2, AC3ENC_PARAM, "dmix_mode"}, {"notindicated", "Not Indicated (default)", 0, FF_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"}, @@ -71,7 +70,6 @@ static const AVOption eac3_options[] = { {"ad_conv_type", "A/D Converter Type", OFFSET(ad_converter_type), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 1, AC3ENC_PARAM, "ad_conv_type"}, {"standard", "Standard (default)", 0, FF_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"}, {"hdcd", "HDCD", 0, FF_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"}, -#endif /* Other Encoding Options */ {"stereo_rematrixing", "Stereo Rematrixing", OFFSET(stereo_rematrixing), FF_OPT_TYPE_INT, {.dbl = 1 }, 0, 1, AC3ENC_PARAM}, #if AC3ENC_TYPE != AC3ENC_TYPE_AC3_FIXED diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index c4e2a121bf..103e7b1a96 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -423,7 +423,7 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame, const SampleType *samples = data; int ret; - if (!s->eac3 && s->options.allow_per_frame_metadata) { + if (s->options.allow_per_frame_metadata) { ret = ff_ac3_validate_metadata(s); if (ret) return ret; diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 038aa2a234..75113b272f 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -142,10 +142,48 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) put_bits(&s->pb, 5, s->bitstream_id); /* bitstream id (EAC3=16) */ put_bits(&s->pb, 5, -opt->dialogue_level); /* dialogue normalization level */ put_bits(&s->pb, 1, 0); /* no compression gain */ - put_bits(&s->pb, 1, 0); /* no mixing metadata */ - /* TODO: mixing metadata */ - put_bits(&s->pb, 1, 0); /* no info metadata */ - /* TODO: info metadata */ + /* mixing metadata*/ + put_bits(&s->pb, 1, opt->eac3_mixing_metadata); + if (opt->eac3_mixing_metadata) { + if (s->channel_mode > AC3_CHMODE_STEREO) + put_bits(&s->pb, 2, opt->preferred_stereo_downmix); + if (s->has_center) { + put_bits(&s->pb, 3, s->ltrt_center_mix_level); + put_bits(&s->pb, 3, s->loro_center_mix_level); + } + if (s->has_surround) { + put_bits(&s->pb, 3, s->ltrt_surround_mix_level); + put_bits(&s->pb, 3, s->loro_surround_mix_level); + } + if (s->lfe_on) + put_bits(&s->pb, 1, 0); + put_bits(&s->pb, 1, 0); /* no program scale */ + put_bits(&s->pb, 1, 0); /* no ext program scale */ + put_bits(&s->pb, 2, 0); /* no mixing parameters */ + if (s->channel_mode < AC3_CHMODE_STEREO) + put_bits(&s->pb, 1, 0); /* no pan info */ + put_bits(&s->pb, 1, 0); /* no frame mix config info */ + } + /* info metadata*/ + put_bits(&s->pb, 1, opt->eac3_info_metadata); + if (opt->eac3_info_metadata) { + put_bits(&s->pb, 3, s->bitstream_mode); + put_bits(&s->pb, 1, opt->copyright); + put_bits(&s->pb, 1, opt->original); + if (s->channel_mode == AC3_CHMODE_STEREO) { + put_bits(&s->pb, 2, opt->dolby_surround_mode); + put_bits(&s->pb, 2, opt->dolby_headphone_mode); + } + if (s->channel_mode >= AC3_CHMODE_2F2R) + put_bits(&s->pb, 2, opt->dolby_surround_ex_mode); + put_bits(&s->pb, 1, opt->audio_production_info); + if (opt->audio_production_info) { + put_bits(&s->pb, 5, opt->mixing_level - 80); + put_bits(&s->pb, 2, opt->room_type); + put_bits(&s->pb, 1, opt->ad_converter_type); + } + put_bits(&s->pb, 1, 0); + } if (s->num_blocks != 6) put_bits(&s->pb, 1, !(s->avctx->frame_number % 6)); /* converter sync flag */ put_bits(&s->pb, 1, 0); /* no additional bit stream info */ From 093ee8e199d758d3f8576354fc4783a5e54eb970 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 25 Jul 2011 12:54:25 -0400 Subject: [PATCH 685/780] cosmetics: reindent --- libavcodec/ac3enc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index a3b77ec6ed..c138f99207 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2134,9 +2134,9 @@ static av_cold int validate_options(AC3EncodeContext *s) if (s->cutoff > (s->sample_rate >> 1)) s->cutoff = s->sample_rate >> 1; - ret = ff_ac3_validate_metadata(s); - if (ret) - return ret; + ret = ff_ac3_validate_metadata(s); + if (ret) + return ret; s->rematrixing_enabled = s->options.stereo_rematrixing && (s->channel_mode == AC3_CHMODE_STEREO); From c3027b4d2f9d14906387ced6f73008d4fa2c2dfb Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 25 Jul 2011 15:51:36 +0100 Subject: [PATCH 686/780] mpegvideo: initialise DSPContext in ff_dct_common_init() The functions and tables initialised in this function rely on an initialised DSPContext. Make sure they always have one. Signed-off-by: Mans Rullgard --- libavcodec/mpegvideo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index d422e12bc1..365a0d4736 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -155,6 +155,8 @@ const uint8_t *ff_find_start_code(const uint8_t * restrict p, const uint8_t *end /* init common dct for both encoder and decoder */ av_cold int ff_dct_common_init(MpegEncContext *s) { + dsputil_init(&s->dsp, s->avctx); + s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c; s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c; s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c; @@ -603,7 +605,6 @@ av_cold int MPV_common_init(MpegEncContext *s) if((s->width || s->height) && av_image_check_size(s->width, s->height, 0, s->avctx)) return -1; - dsputil_init(&s->dsp, s->avctx); ff_dct_common_init(s); s->flags= s->avctx->flags; From ca6a90465634152c7abe2f10112fd06dc778122f Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 25 Jul 2011 16:18:17 +0100 Subject: [PATCH 687/780] ppc: remove redundant setting of Altivec IDCT This is already set by dsputil_init_ppc() and is best done in only one place. Signed-off-by: Mans Rullgard --- libavcodec/ppc/mpegvideo_altivec.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libavcodec/ppc/mpegvideo_altivec.c b/libavcodec/ppc/mpegvideo_altivec.c index 673b11d0c9..2d3bf892a0 100644 --- a/libavcodec/ppc/mpegvideo_altivec.c +++ b/libavcodec/ppc/mpegvideo_altivec.c @@ -558,15 +558,6 @@ void MPV_common_init_altivec(MpegEncContext *s) { if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; - if (s->avctx->lowres==0) { - if ((s->avctx->idct_algo == FF_IDCT_AUTO) || - (s->avctx->idct_algo == FF_IDCT_ALTIVEC)) { - s->dsp.idct_put = idct_put_altivec; - s->dsp.idct_add = idct_add_altivec; - s->dsp.idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; - } - } - // Test to make sure that the dct required alignments are met. if ((((long)(s->q_intra_matrix) & 0x0f) != 0) || (((long)(s->q_inter_matrix) & 0x0f) != 0)) { From f234cd0f37311454de996c35837e8e6698fabcbd Mon Sep 17 00:00:00 2001 From: Lou Logan Date: Mon, 11 Jul 2011 12:34:08 -0800 Subject: [PATCH 688/780] Remove libx264 baseline ffpreset Made redundant by "-profile baseline". Signed-off-by: Michael Niedermayer --- ffpresets/libx264-baseline.ffpreset | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 ffpresets/libx264-baseline.ffpreset diff --git a/ffpresets/libx264-baseline.ffpreset b/ffpresets/libx264-baseline.ffpreset deleted file mode 100644 index ee7654bdec..0000000000 --- a/ffpresets/libx264-baseline.ffpreset +++ /dev/null @@ -1,4 +0,0 @@ -coder=0 -bf=0 -flags2=-wpred-dct8x8 -wpredp=0 From faa338183ba44051e05019411956b41c257c2510 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Thu, 14 Jul 2011 22:31:37 +0200 Subject: [PATCH 689/780] yadif must copy buffer properties like aspect for second frame as well --- libavfilter/vf_yadif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 56e4489986..6fc9f479e7 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -201,9 +201,12 @@ static void return_frame(AVFilterContext *ctx, int is_second) tff = yadif->parity^1; } - if (is_second) + if (is_second) { yadif->out = avfilter_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE | AV_PERM_REUSE, link->w, link->h); + avfilter_copy_buffer_ref_props(yadif->out, yadif->cur); + yadif->out->video->interlaced = 0; + } if (!yadif->csp) yadif->csp = &av_pix_fmt_descriptors[link->format]; From e2affa8ce7491253810117a8f0b22aada1f5cea6 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 27 Jul 2011 18:41:09 +0200 Subject: [PATCH 690/780] audioconvert: define unique strings for AV_CH_LAYOUT_5POINT{0,1}_BACK Previously the string for AV_CH_LAYOUT_5POINT{0,1}_BACK was the same of the string for AV_CH_LAYOUT_5POINT{0,1}. This is required for discerning the two channel layouts, given a channel layout string. --- libavutil/audioconvert.c | 4 ++-- libavutil/avutil.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c index 60743de22a..6e8649d56c 100644 --- a/libavutil/audioconvert.c +++ b/libavutil/audioconvert.c @@ -52,9 +52,9 @@ static const struct { { "4.0", 4, AV_CH_LAYOUT_4POINT0 }, { "quad", 4, AV_CH_LAYOUT_QUAD }, { "5.0", 5, AV_CH_LAYOUT_5POINT0 }, - { "5.0", 5, AV_CH_LAYOUT_5POINT0_BACK }, + { "5.0(back)", 5, AV_CH_LAYOUT_5POINT0_BACK }, { "5.1", 6, AV_CH_LAYOUT_5POINT1 }, - { "5.1", 6, AV_CH_LAYOUT_5POINT1_BACK }, + { "5.1(back)", 6, AV_CH_LAYOUT_5POINT1_BACK }, { "5.1+downmix", 8, AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, }, { "7.1", 8, AV_CH_LAYOUT_7POINT1 }, { "7.1(wide)", 8, AV_CH_LAYOUT_7POINT1_WIDE }, diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 568f66b989..ffcac1c152 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -41,7 +41,7 @@ #define LIBAVUTIL_VERSION_MAJOR 51 #define LIBAVUTIL_VERSION_MINOR 11 -#define LIBAVUTIL_VERSION_MICRO 0 +#define LIBAVUTIL_VERSION_MICRO 1 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ From 9c484d294483241b4d066530b1eee06d94cfefdc Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Jul 2011 21:29:05 +0200 Subject: [PATCH 691/780] lavfi-showfiltfmts: extend output format for specifying audio data This is required for extending lavfi tests to audio filtering. --- tests/lavfi-regression.sh | 4 +-- tools/lavfi-showfiltfmts.c | 66 +++++++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/tests/lavfi-regression.sh b/tests/lavfi-regression.sh index 5def09c2c9..e1666c263c 100755 --- a/tests/lavfi-regression.sh +++ b/tests/lavfi-regression.sh @@ -50,9 +50,9 @@ do_lavfi_pixfmts(){ # exclude pixel formats which are not supported as input $ffmpeg -pix_fmts list 2>/dev/null | sed -ne '9,$p' | grep '^\..\.' | cut -d' ' -f2 | sort >$exclude_fmts - $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ print $3 }' | sort | comm -23 - $exclude_fmts >$out_fmts + $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort | comm -23 - $exclude_fmts >$out_fmts - pix_fmts=$($showfiltfmts $filter $filter_args | awk -F '[ \r]' '/^INPUT/{ print $3 }' | sort | comm -12 - $out_fmts) + pix_fmts=$($showfiltfmts $filter $filter_args | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort | comm -12 - $out_fmts) for pix_fmt in $pix_fmts; do do_video_filter $pix_fmt "slicify=random,format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt done diff --git a/tools/lavfi-showfiltfmts.c b/tools/lavfi-showfiltfmts.c index cc19e00a8c..a4541bac82 100644 --- a/tools/lavfi-showfiltfmts.c +++ b/tools/lavfi-showfiltfmts.c @@ -20,15 +20,61 @@ #include "libavformat/avformat.h" #include "libavutil/pixdesc.h" +#include "libavutil/samplefmt.h" #include "libavfilter/avfilter.h" +static void print_formats(AVFilterContext *filter_ctx) +{ + int i, j; + +#define PRINT_FMTS(inout, outin, INOUT) \ + for (i = 0; i < filter_ctx->input_count; i++) { \ + if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) { \ + AVFilterFormats *fmts = \ + filter_ctx->inout##puts[i]->outin##_formats; \ + for (j = 0; j < fmts->format_count; j++) \ + printf(#INOUT "PUT[%d] %s: fmt:%s\n", \ + i, filter_ctx->filter->inout##puts[i].name, \ + av_get_pix_fmt_name(fmts->formats[j])); \ + } else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \ + AVFilterFormats *fmts; \ + \ + fmts = filter_ctx->inout##puts[i]->outin##_formats; \ + for (j = 0; j < fmts->format_count; j++) \ + printf(#INOUT "PUT[%d] %s: fmt:%s\n", \ + i, filter_ctx->filter->inout##puts[i].name, \ + av_get_sample_fmt_name(fmts->formats[j])); \ + \ + fmts = filter_ctx->inout##puts[i]->outin##_chlayouts; \ + for (j = 0; j < fmts->format_count; j++) { \ + char buf[256]; \ + av_get_channel_layout_string(buf, sizeof(buf), -1, \ + fmts->formats[j]); \ + printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \ + i, filter_ctx->filter->inout##puts[i].name, buf); \ + } \ + \ + fmts = filter_ctx->inout##puts[i]->outin##_packing; \ + for (j = 0; j < fmts->format_count; j++) { \ + printf(#INOUT "PUT[%d] %s: packing:%s\n", \ + i, filter_ctx->filter->inout##puts[i].name, \ + fmts->formats[j] == AVFILTER_PACKED ? \ + "packed" : "planar"); \ + } \ + } \ + } \ + + PRINT_FMTS(in, out, IN); + PRINT_FMTS(out, in, OUT); +} + int main(int argc, char **argv) { AVFilter *filter; AVFilterContext *filter_ctx; const char *filter_name; const char *filter_args = NULL; - int i, j; + int i; av_log_set_level(AV_LOG_DEBUG); @@ -75,23 +121,7 @@ int main(int argc, char **argv) else avfilter_default_query_formats(filter_ctx); - /* print the supported formats in input */ - for (i = 0; i < filter_ctx->input_count; i++) { - AVFilterFormats *fmts = filter_ctx->inputs[i]->out_formats; - for (j = 0; j < fmts->format_count; j++) - printf("INPUT[%d] %s: %s\n", - i, filter_ctx->filter->inputs[i].name, - av_get_pix_fmt_name(fmts->formats[j])); - } - - /* print the supported formats in output */ - for (i = 0; i < filter_ctx->output_count; i++) { - AVFilterFormats *fmts = filter_ctx->outputs[i]->in_formats; - for (j = 0; j < fmts->format_count; j++) - printf("OUTPUT[%d] %s: %s\n", - i, filter_ctx->filter->outputs[i].name, - av_get_pix_fmt_name(fmts->formats[j])); - } + print_formats(filter_ctx); avfilter_free(filter_ctx); fflush(stdout); From fdd130a2131912133c72b5ff532726784aaa70a2 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 27 Jul 2011 10:35:08 +0200 Subject: [PATCH 692/780] prefer "SAR" over "PAR" in av_dump_format() "SAR" (Sample Aspect Ratio) is globally preferred over "PAR" (Pixel Aspect Ratio), although the two terms share the same semantics. For example the corresponding AVStream field is called sample_aspect_ratio, and libavfilter has a filter named setsar. Therefore prefer the term "SAR" over "PAR" in the libavformat/utils.c:dump_stream_format() and avcodec_string() output for avoiding confusion. --- libavcodec/utils.c | 2 +- libavformat/utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 301e33e86c..49891ad04c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1053,7 +1053,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) enc->height*enc->sample_aspect_ratio.den, 1024*1024); snprintf(buf + strlen(buf), buf_size - strlen(buf), - " [PAR %d:%d DAR %d:%d]", + " [SAR %d:%d DAR %d:%d]", enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den, display_aspect_ratio.num, display_aspect_ratio.den); } diff --git a/libavformat/utils.c b/libavformat/utils.c index 38407b9d4b..74891049ae 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3402,7 +3402,7 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out st->codec->width*st->sample_aspect_ratio.num, st->codec->height*st->sample_aspect_ratio.den, 1024*1024); - av_log(NULL, AV_LOG_INFO, ", PAR %d:%d DAR %d:%d", + av_log(NULL, AV_LOG_INFO, ", SAR %d:%d DAR %d:%d", st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, display_aspect_ratio.num, display_aspect_ratio.den); } From 539940d42fd1df29db2e9393e868816824c821cf Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 25 Jul 2011 11:47:32 +0200 Subject: [PATCH 693/780] imgconvert: remove unused and inconsistent PixFmtInfo.depth field --- libavcodec/imgconvert.c | 55 ----------------------------------------- 1 file changed, 55 deletions(-) diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index c48478cafc..9efed50955 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -58,7 +58,6 @@ typedef struct PixFmtInfo { uint8_t color_type; /**< color type (see FF_COLOR_xxx constants) */ uint8_t is_alpha : 1; /**< true if alpha can be specified */ - uint8_t depth; /**< bit depth of the color components */ uint8_t padded_size; /**< padded size in bits if different from the non-padded size */ } PixFmtInfo; @@ -67,247 +66,193 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { /* YUV formats */ [PIX_FMT_YUV420P] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_YUV422P] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_YUV444P] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_YUYV422] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_UYVY422] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_YUV410P] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_YUV411P] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_YUV440P] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_YUV420P16LE] = { .color_type = FF_COLOR_YUV, - .depth = 16, }, [PIX_FMT_YUV422P16LE] = { .color_type = FF_COLOR_YUV, - .depth = 16, }, [PIX_FMT_YUV444P16LE] = { .color_type = FF_COLOR_YUV, - .depth = 16, }, [PIX_FMT_YUV420P16BE] = { .color_type = FF_COLOR_YUV, - .depth = 16, }, [PIX_FMT_YUV422P16BE] = { .color_type = FF_COLOR_YUV, - .depth = 16, }, [PIX_FMT_YUV444P16BE] = { .color_type = FF_COLOR_YUV, - .depth = 16, }, /* YUV formats with alpha plane */ [PIX_FMT_YUVA420P] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, /* JPEG YUV */ [PIX_FMT_YUVJ420P] = { .color_type = FF_COLOR_YUV_JPEG, - .depth = 8, }, [PIX_FMT_YUVJ422P] = { .color_type = FF_COLOR_YUV_JPEG, - .depth = 8, }, [PIX_FMT_YUVJ444P] = { .color_type = FF_COLOR_YUV_JPEG, - .depth = 8, }, [PIX_FMT_YUVJ440P] = { .color_type = FF_COLOR_YUV_JPEG, - .depth = 8, }, /* RGB formats */ [PIX_FMT_RGB24] = { .color_type = FF_COLOR_RGB, - .depth = 8, }, [PIX_FMT_BGR24] = { .color_type = FF_COLOR_RGB, - .depth = 8, }, [PIX_FMT_ARGB] = { .is_alpha = 1, .color_type = FF_COLOR_RGB, - .depth = 8, }, [PIX_FMT_RGB48BE] = { .color_type = FF_COLOR_RGB, - .depth = 16, }, [PIX_FMT_RGB48LE] = { .color_type = FF_COLOR_RGB, - .depth = 16, }, [PIX_FMT_RGB565BE] = { .color_type = FF_COLOR_RGB, - .depth = 5, }, [PIX_FMT_RGB565LE] = { .color_type = FF_COLOR_RGB, - .depth = 5, }, [PIX_FMT_RGB555BE] = { .color_type = FF_COLOR_RGB, - .depth = 5, .padded_size = 16, }, [PIX_FMT_RGB555LE] = { .color_type = FF_COLOR_RGB, - .depth = 5, .padded_size = 16, }, [PIX_FMT_RGB444BE] = { .color_type = FF_COLOR_RGB, - .depth = 4, .padded_size = 16, }, [PIX_FMT_RGB444LE] = { .color_type = FF_COLOR_RGB, - .depth = 4, .padded_size = 16, }, /* gray / mono formats */ [PIX_FMT_GRAY16BE] = { .color_type = FF_COLOR_GRAY, - .depth = 16, }, [PIX_FMT_GRAY16LE] = { .color_type = FF_COLOR_GRAY, - .depth = 16, }, [PIX_FMT_GRAY8] = { .color_type = FF_COLOR_GRAY, - .depth = 8, }, [PIX_FMT_MONOWHITE] = { .color_type = FF_COLOR_GRAY, - .depth = 1, }, [PIX_FMT_MONOBLACK] = { .color_type = FF_COLOR_GRAY, - .depth = 1, }, /* paletted formats */ [PIX_FMT_PAL8] = { .is_alpha = 1, .color_type = FF_COLOR_RGB, - .depth = 8, }, [PIX_FMT_UYYVYY411] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_ABGR] = { .is_alpha = 1, .color_type = FF_COLOR_RGB, - .depth = 8, }, [PIX_FMT_BGR565BE] = { .color_type = FF_COLOR_RGB, - .depth = 5, .padded_size = 16, }, [PIX_FMT_BGR565LE] = { .color_type = FF_COLOR_RGB, - .depth = 5, .padded_size = 16, }, [PIX_FMT_BGR555BE] = { .color_type = FF_COLOR_RGB, - .depth = 5, .padded_size = 16, }, [PIX_FMT_BGR555LE] = { .color_type = FF_COLOR_RGB, - .depth = 5, .padded_size = 16, }, [PIX_FMT_BGR444BE] = { .color_type = FF_COLOR_RGB, - .depth = 4, .padded_size = 16, }, [PIX_FMT_BGR444LE] = { .color_type = FF_COLOR_RGB, - .depth = 4, .padded_size = 16, }, [PIX_FMT_RGB8] = { .color_type = FF_COLOR_RGB, - .depth = 8, }, [PIX_FMT_RGB4] = { .color_type = FF_COLOR_RGB, - .depth = 4, }, [PIX_FMT_RGB4_BYTE] = { .color_type = FF_COLOR_RGB, - .depth = 8, .padded_size = 8, }, [PIX_FMT_BGR8] = { .color_type = FF_COLOR_RGB, - .depth = 8, }, [PIX_FMT_BGR4] = { .color_type = FF_COLOR_RGB, - .depth = 4, }, [PIX_FMT_BGR4_BYTE] = { .color_type = FF_COLOR_RGB, - .depth = 8, .padded_size = 8, }, [PIX_FMT_NV12] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_NV21] = { .color_type = FF_COLOR_YUV, - .depth = 8, }, [PIX_FMT_BGRA] = { .is_alpha = 1, .color_type = FF_COLOR_RGB, - .depth = 8, }, [PIX_FMT_RGBA] = { .is_alpha = 1, .color_type = FF_COLOR_RGB, - .depth = 8, }, }; From 25a53c54d146edd3cf21358505d3cd5d5b55bc3b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 26 Jul 2011 00:03:50 +0200 Subject: [PATCH 694/780] lsws: apply logging factorization in sws_scale_init() --- libswscale/utils.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 7e8d9719fd..afae13388c 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1078,12 +1078,9 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) flags & SWS_FAST_BILINEAR ? "FAST_BILINEAR C" : "C"); } if (isPlanarYUV(dstFormat)) { - if (c->vLumFilterSize==1) - av_log(c, AV_LOG_VERBOSE, "using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", - (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) ? "MMX" : "C"); - else - av_log(c, AV_LOG_VERBOSE, "using n-tap %s scaler for vertical scaling (YV12 like)\n", - (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) ? "MMX" : "C"); + av_log(c, AV_LOG_VERBOSE, "using %s-tap %s \"scaler\" for vertical scaling (YV12 like)\n", + c->vLumFilterSize == 1 ? "1" : "n", + HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX ? "MMX" : "C"); } else { if (c->vLumFilterSize==1 && c->vChrFilterSize==2) av_log(c, AV_LOG_VERBOSE, "using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n" From 2fb9fc0f6c033c1fabe5c0314d9c7536ef160e01 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 28 Jul 2011 11:30:44 +0200 Subject: [PATCH 695/780] h264: improve max slices error message Signed-off-by: Michael Niedermayer --- libavcodec/h264.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 83d81c95f1..1f417a860a 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2946,7 +2946,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ h0->last_slice_type = slice_type; h->slice_num = ++h0->current_slice; if(h->slice_num >= MAX_SLICES){ - av_log(s->avctx, AV_LOG_ERROR, "Too many slices (%d >= %d), increase MAX_SLICES and recompile\n", h->slice_num, MAX_SLICES); + av_log(s->avctx, AV_LOG_WARNING, "Possibly too many slices (%d >= %d), increase MAX_SLICES and recompile if there are artifacts\n", h->slice_num, MAX_SLICES); } for(j=0; j<2; j++){ From 956c901c68eff78288f40e3c8f41ee2fa081d4a8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 28 Jul 2011 14:59:54 +0200 Subject: [PATCH 696/780] Fix several security issues in matroskadec.c (MSVR-11-0080). Whitespace of the patch cleaned up by Aurel Some of the issues have been reported by Steve Manzuik / Microsoft Vulnerability Research (MSVR) Signed-off-by: Michael Niedermayer --- libavformat/matroskadec.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index cc8b016e8f..d4f41c224e 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -829,11 +829,15 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska, uint32_t id = syntax->id; uint64_t length; int res; + void *newelem; data = (char *)data + syntax->data_offset; if (syntax->list_elem_size) { EbmlList *list = data; - list->elem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size); + newelem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size); + if (!newelem) + return AVERROR(ENOMEM); + list->elem = newelem; data = (char*)list->elem + list->nb_elem*syntax->list_elem_size; memset(data, 0, syntax->list_elem_size); list->nb_elem++; @@ -995,7 +999,10 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size, pkt_data = av_realloc(pkt_data, pkt_size); zstream.avail_out = pkt_size - zstream.total_out; zstream.next_out = pkt_data + zstream.total_out; - result = inflate(&zstream, Z_NO_FLUSH); + if (pkt_data) { + result = inflate(&zstream, Z_NO_FLUSH); + } else + result = Z_MEM_ERROR; } while (result==Z_OK && pkt_size<10000000); pkt_size = zstream.total_out; inflateEnd(&zstream); @@ -1016,7 +1023,10 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size, pkt_data = av_realloc(pkt_data, pkt_size); bzstream.avail_out = pkt_size - bzstream.total_out_lo32; bzstream.next_out = pkt_data + bzstream.total_out_lo32; - result = BZ2_bzDecompress(&bzstream); + if (pkt_data) { + result = BZ2_bzDecompress(&bzstream); + } else + result = BZ_MEM_ERROR; } while (result==BZ_OK && pkt_size<10000000); pkt_size = bzstream.total_out_lo32; BZ2_bzDecompressEnd(&bzstream); @@ -1069,13 +1079,17 @@ static void matroska_fix_ass_packet(MatroskaDemuxContext *matroska, } } -static void matroska_merge_packets(AVPacket *out, AVPacket *in) +static int matroska_merge_packets(AVPacket *out, AVPacket *in) { - out->data = av_realloc(out->data, out->size+in->size); + void *newdata = av_realloc(out->data, out->size+in->size); + if (!newdata) + return AVERROR(ENOMEM); + out->data = newdata; memcpy(out->data+out->size, in->data, in->size); out->size += in->size; av_destruct_packet(in); av_free(in); + return 0; } static void matroska_convert_tag(AVFormatContext *s, EbmlList *list, @@ -1661,11 +1675,13 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska, memcpy(pkt, matroska->packets[0], sizeof(AVPacket)); av_free(matroska->packets[0]); if (matroska->num_packets > 1) { + void *newpackets; memmove(&matroska->packets[0], &matroska->packets[1], (matroska->num_packets - 1) * sizeof(AVPacket *)); - matroska->packets = - av_realloc(matroska->packets, (matroska->num_packets - 1) * - sizeof(AVPacket *)); + newpackets = av_realloc(matroska->packets, + (matroska->num_packets - 1) * sizeof(AVPacket *)); + if (newpackets) + matroska->packets = newpackets; } else { av_freep(&matroska->packets); } From 3c7fa664af5b3c2abbedd489142a0f9b6690b364 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 17 Jul 2011 13:59:04 +0200 Subject: [PATCH 697/780] lavf: add forgotten attribute_deprecated to av_find_stream_info() --- libavformat/avformat.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 38bb86592e..cfdbd11b36 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1114,6 +1114,7 @@ AVFormatContext *avformat_alloc_context(void); * * @deprecated use avformat_find_stream_info. */ +attribute_deprecated int av_find_stream_info(AVFormatContext *ic); #endif From 7cea06d135c91bf21f3d2a095c2f610594bed7df Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 17 Jul 2011 01:30:43 +0200 Subject: [PATCH 698/780] cmdutils: clarify documentation for setup_find_stream_info_opts() Signed-off-by: Anton Khirnov --- cmdutils.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmdutils.h b/cmdutils.h index a47f15785d..90e0a25850 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -153,8 +153,16 @@ void parse_options(int argc, char **argv, const OptionDef *options, */ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, int encoder); -/* - * Setup AVCodecContext options for avformat_find_stream_info. +/** + * Setup AVCodecContext options for avformat_find_stream_info(). + * + * Create an array of dictionaries, one dictionary for each stream + * contained in s. + * Each dictionary will contain the options from codec_opts which can + * be applied to the corresponding stream codec context. + * + * @return pointer to the created array of dictionaries, NULL if it + * cannot be created */ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s); From ce23ca814b0fa6327b21e03be09b81f9b0d7113d Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 17 Jul 2011 01:20:50 +0200 Subject: [PATCH 699/780] cmdutils: clarify documentation for filter_codec_opts() Signed-off-by: Anton Khirnov --- cmdutils.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmdutils.h b/cmdutils.h index 90e0a25850..dcd0b79a1f 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -150,6 +150,12 @@ void parse_options(int argc, char **argv, const OptionDef *options, /** * Filter out options for given codec. + * + * Create a new options dictionary containing only the options from + * opts which apply to the codec with ID codec_id. + * + * @param encoder if non-zero the codec is an encoder, otherwise is a decoder + * @return a pointer to the created dictionary */ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, int encoder); From 8ec19f84e12283dd79c16782ab55dd3b4e1ded66 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 17 Jul 2011 16:19:28 +0200 Subject: [PATCH 700/780] cmdutils: add codec_opts parameter to setup_find_stream_info_opts() Avoid brittle and obfuscating reference to a global. Signed-off-by: Anton Khirnov --- cmdutils.c | 2 +- cmdutils.h | 2 +- ffmpeg.c | 2 +- ffplay.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 19c5d72857..f6e50fa534 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -806,7 +806,7 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, int e return ret; } -AVDictionary **setup_find_stream_info_opts(AVFormatContext *s) +AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts) { int i; AVDictionary **opts; diff --git a/cmdutils.h b/cmdutils.h index dcd0b79a1f..7769194b9c 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -170,7 +170,7 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, int e * @return pointer to the created array of dictionaries, NULL if it * cannot be created */ -AVDictionary **setup_find_stream_info_opts(AVFormatContext *s); +AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts); /** * Print an error message to stderr, indicating filename and a human diff --git a/ffmpeg.c b/ffmpeg.c index 776cfabacd..c76aeacbe6 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3252,7 +3252,7 @@ static int opt_input_file(const char *opt, const char *filename) } /* Set AVCodecContext options for avformat_find_stream_info */ - opts = setup_find_stream_info_opts(ic); + opts = setup_find_stream_info_opts(ic, codec_opts); orig_nb_streams = ic->nb_streams; /* If not enough info to get the stream parameters, we decode the diff --git a/ffplay.c b/ffplay.c index 77c9d4b2f3..bef75fe574 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2343,7 +2343,7 @@ static int decode_thread(void *arg) if(genpts) ic->flags |= AVFMT_FLAG_GENPTS; - opts = setup_find_stream_info_opts(ic); + opts = setup_find_stream_info_opts(ic, codec_opts); orig_nb_streams = ic->nb_streams; err = avformat_find_stream_info(ic, opts); From 22b203baf81f8efcf134d2d27732ee6e842fdcb6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 17 Jul 2011 14:54:20 +0200 Subject: [PATCH 701/780] doc: document using AVOptions in fftools. --- doc/fftools-common-opts.texi | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi index 3a1cb3b23c..fec61cf8c9 100644 --- a/doc/fftools-common-opts.texi +++ b/doc/fftools-common-opts.texi @@ -91,3 +91,28 @@ The use of the environment variable @env{NO_COLOR} is deprecated and will be dropped in a following Libav version. @end table + +@section AVOptions + +These options are provided directly by the libavformat and libavcodec +libraries. To see the list of available AVOptions, use the +@option{-help} option. They are separated into two categories: +@table @option +@item generic +Can be set for any container or codec. Generic options are listed under +AVFormatContext options for containers and under AVCodecContext options +for codecs. +@item private +Are specific to the given container or codec. Private options are listed +under their corresponding containers/codecs. +@end table + +For example to write an ID3v2.3 header instead of a default ID3v2.4 to +an MP3 file, use the @option{id3v2_version} private option of the MP3 +muxer: +@example +ffmpeg -i input.flac -id3v2_version 3 out.mp3 +@end example + +Note -nooption syntax cannot be used for boolean AVOptions, use -option +0/-option 1. From e0e65ddb883427aafbcef1ae52248f4d1e087963 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 28 Jul 2011 17:43:24 +0200 Subject: [PATCH 702/780] doc/fftools-common-opts: wording fixes missing from the previous commit. --- doc/fftools-common-opts.texi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi index fec61cf8c9..ba91b87e72 100644 --- a/doc/fftools-common-opts.texi +++ b/doc/fftools-common-opts.texi @@ -94,17 +94,17 @@ will be dropped in a following Libav version. @section AVOptions -These options are provided directly by the libavformat and libavcodec -libraries. To see the list of available AVOptions, use the +These options are provided directly by the libavformat, libavdevice and +libavcodec libraries. To see the list of available AVOptions, use the @option{-help} option. They are separated into two categories: @table @option @item generic -Can be set for any container or codec. Generic options are listed under -AVFormatContext options for containers and under AVCodecContext options -for codecs. +These options can be set for any container, codec or device. Generic options are +listed under AVFormatContext options for containers/devices and under +AVCodecContext options for codecs. @item private -Are specific to the given container or codec. Private options are listed -under their corresponding containers/codecs. +These options are specific to the given container, device or codec. Private +options are listed under their corresponding containers/devices/codecs. @end table For example to write an ID3v2.3 header instead of a default ID3v2.4 to From 188694b2f50b125b31cf5d287751ee85af937c2b Mon Sep 17 00:00:00 2001 From: Jeff Downs Date: Tue, 5 Jul 2011 13:20:06 -0400 Subject: [PATCH 703/780] h264 - Fix PCM intra coded blocks in monochrome case --- libavcodec/h264.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 1f417a860a..57711141ae 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1809,8 +1809,8 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i } if (!simple && IS_INTRA_PCM(mb_type)) { + const int bit_depth = h->sps.bit_depth_luma; if (pixel_shift) { - const int bit_depth = h->sps.bit_depth_luma; int j; GetBitContext gb; init_get_bits(&gb, (uint8_t*)h->mb, 384*bit_depth); @@ -1821,6 +1821,15 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i tmp_y[j] = get_bits(&gb, bit_depth); } if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ + if (!h->sps.chroma_format_idc) { + for (i = 0; i < 8; i++) { + uint16_t *tmp_cb = (uint16_t*)(dest_cb + i*uvlinesize); + uint16_t *tmp_cr = (uint16_t*)(dest_cr + i*uvlinesize); + for (j = 0; j < 8; j++) { + tmp_cb[j] = tmp_cr[j] = 1 << (bit_depth - 1); + } + } + } else { for (i = 0; i < 8; i++) { uint16_t *tmp_cb = (uint16_t*)(dest_cb + i*uvlinesize); for (j = 0; j < 8; j++) @@ -1831,16 +1840,24 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i for (j = 0; j < 8; j++) tmp_cr[j] = get_bits(&gb, bit_depth); } + } } } else { for (i=0; i<16; i++) { memcpy(dest_y + i* linesize, h->mb + i*8, 16); } if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ + if (!h->sps.chroma_format_idc) { + for (i=0; i<8; i++) { + memset(dest_cb+ i*uvlinesize, 1 << (bit_depth - 1), 8); + memset(dest_cr+ i*uvlinesize, 1 << (bit_depth - 1), 8); + } + } else { for (i=0; i<8; i++) { memcpy(dest_cb+ i*uvlinesize, h->mb + 128 + i*4, 8); memcpy(dest_cr+ i*uvlinesize, h->mb + 160 + i*4, 8); } + } } } } else { From e80e2d5ba1d8c699fa1cf0c329feb6e237362505 Mon Sep 17 00:00:00 2001 From: Jeff Downs Date: Tue, 5 Jul 2011 14:21:54 -0400 Subject: [PATCH 704/780] h264 - correct the check for invalid long term frame index in MMCO decode The current checks on MMCO parameters prohibits a "max long term frame index plus 1" of 16 (frame idx of 15) for the "set max long term frame index" MMCO. Fix this off-by-one error to allow the full range of legal values. --- libavcodec/h264_refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index 2c952537e3..6794bf3c9f 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -680,7 +680,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb){ } if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){ unsigned int long_arg= get_ue_golomb_31(gb); - if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){ + if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG && long_arg == 16) && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){ av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode); return -1; } From 4105443872be75a8d1141facc43b54641304c722 Mon Sep 17 00:00:00 2001 From: Jeff Downs Date: Wed, 6 Jul 2011 11:54:36 -0400 Subject: [PATCH 705/780] h264 - Correct implicit weight table computation for long ref pics Correct computation of implicit weight tables when referencing pictures that are marked for long reference. --- libavcodec/h264.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 57711141ae..8dfb2b263e 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2174,9 +2174,10 @@ static void implicit_weight_table(H264Context *h, int field){ for(ref0=ref_start; ref0 < ref_count0; ref0++){ int poc0 = h->ref_list[0][ref0].poc; for(ref1=ref_start; ref1 < ref_count1; ref1++){ + int w= 32; + if (!h->ref_list[0][ref0].long_ref && !h->ref_list[1][ref1].long_ref){ int poc1 = h->ref_list[1][ref1].poc; int td = av_clip(poc1 - poc0, -128, 127); - int w= 32; if(td){ int tb = av_clip(cur_poc - poc0, -128, 127); int tx = (16384 + (FFABS(td) >> 1)) / td; @@ -2184,6 +2185,7 @@ static void implicit_weight_table(H264Context *h, int field){ if(dist_scale_factor >= -64 && dist_scale_factor <= 128) w = 64 - dist_scale_factor; } + } if(field<0){ h->implicit_weight[ref0][ref1][0]= h->implicit_weight[ref0][ref1][1]= w; From 8dcf5184307f072d55fb29373be05ef8b0fd02df Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 26 Jul 2011 10:58:29 -0700 Subject: [PATCH 706/780] vp3/theora: flush after seek. --- libavcodec/vp3.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index c3dff7f89f..c117a64084 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -2321,6 +2321,26 @@ static av_cold int theora_decode_init(AVCodecContext *avctx) return vp3_decode_init(avctx); } +static void vp3_decode_flush(AVCodecContext *avctx) +{ + Vp3DecodeContext *s = avctx->priv_data; + + if (s->golden_frame.data[0]) { + if (s->golden_frame.data[0] == s->last_frame.data[0]) + memset(&s->last_frame, 0, sizeof(AVFrame)); + if (s->current_frame.data[0] == s->golden_frame.data[0]) + memset(&s->current_frame, 0, sizeof(AVFrame)); + ff_thread_release_buffer(avctx, &s->golden_frame); + } + if (s->last_frame.data[0]) { + if (s->current_frame.data[0] == s->last_frame.data[0]) + memset(&s->current_frame, 0, sizeof(AVFrame)); + ff_thread_release_buffer(avctx, &s->last_frame); + } + if (s->current_frame.data[0]) + ff_thread_release_buffer(avctx, &s->current_frame); +} + AVCodec ff_theora_decoder = { "theora", AVMEDIA_TYPE_VIDEO, @@ -2332,6 +2352,7 @@ AVCodec ff_theora_decoder = { vp3_decode_frame, CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, NULL, + .flush = vp3_decode_flush, .long_name = NULL_IF_CONFIG_SMALL("Theora"), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) }; @@ -2348,6 +2369,7 @@ AVCodec ff_vp3_decoder = { vp3_decode_frame, CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, NULL, + .flush = vp3_decode_flush, .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) }; From 6c3257654801d525aa61e6fb46022a2a3b12c074 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Tue, 26 Jul 2011 19:08:05 -0700 Subject: [PATCH 707/780] H.264: optimize CABAC x86 asm for Atom --- libavcodec/h264_cabac.c | 2 +- libavcodec/x86/cabac.h | 15 +++++++-------- libavcodec/x86/h264_i386.h | 11 ++++------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index f7cec5d03e..065b6e85e1 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1649,7 +1649,7 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD]; #if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, - last_coeff_ctx_base-significant_coeff_ctx_base, sig_off); + last_coeff_ctx_base, sig_off); } else { coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index, last_coeff_ctx_base-significant_coeff_ctx_base); diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index 52bea9c53d..1ad74ff3e0 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -34,8 +34,8 @@ "cmova %%ecx , "range" \n\t"\ "sbb %%ecx , %%ecx \n\t"\ "and %%ecx , "tmp" \n\t"\ - "sub "tmp" , "low" \n\t"\ - "xor %%ecx , "ret" \n\t" + "xor %%ecx , "ret" \n\t"\ + "sub "tmp" , "low" \n\t" #else /* HAVE_FAST_CMOV */ #define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\ "mov "tmp" , %%ecx \n\t"\ @@ -62,21 +62,20 @@ "movzbl " MANGLE(ff_h264_norm_shift) "("range"), %%ecx \n\t"\ "shl %%cl , "range" \n\t"\ "movzbl "MANGLE(ff_h264_mlps_state)"+128("ret"), "tmp" \n\t"\ - "mov "tmpbyte" , "statep" \n\t"\ "shl %%cl , "low" \n\t"\ + "mov "tmpbyte" , "statep" \n\t"\ "test "lowword" , "lowword" \n\t"\ " jnz 1f \n\t"\ "mov "byte"("cabac"), %%"REG_c" \n\t"\ + "add $2 , "byte "("cabac") \n\t"\ "movzwl (%%"REG_c") , "tmp" \n\t"\ - "bswap "tmp" \n\t"\ - "shr $15 , "tmp" \n\t"\ - "sub $0xFFFF , "tmp" \n\t"\ - "add $2 , %%"REG_c" \n\t"\ - "mov %%"REG_c" , "byte "("cabac") \n\t"\ "lea -1("low") , %%ecx \n\t"\ "xor "low" , %%ecx \n\t"\ "shr $15 , %%ecx \n\t"\ + "bswap "tmp" \n\t"\ + "shr $15 , "tmp" \n\t"\ "movzbl " MANGLE(ff_h264_norm_shift) "(%%ecx), %%ecx \n\t"\ + "sub $0xFFFF , "tmp" \n\t"\ "neg %%ecx \n\t"\ "add $7 , %%ecx \n\t"\ "shl %%cl , "tmp" \n\t"\ diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index 9c86210371..0151cd59a8 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -72,8 +72,7 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "test $1, %4 \n\t" " jnz 4f \n\t" - "add $4, %0 \n\t" - "mov %0, %2 \n\t" + "add $4, %2 \n\t" "3: \n\t" "add $1, %1 \n\t" @@ -101,7 +100,7 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, static int decode_significance_8x8_x86(CABACContext *c, uint8_t *significant_coeff_ctx_base, - int *index, x86_reg last_off, const uint8_t *sig_off){ + int *index, uint8_t *last_coeff_ctx_base, const uint8_t *sig_off){ int minusindex= 4-(intptr_t)index; int bit; x86_reg coeff_count; @@ -128,7 +127,6 @@ static int decode_significance_8x8_x86(CABACContext *c, " jz 3f \n\t" "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t" - "add %9, %6 \n\t" "add %11, %6 \n\t" BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3", @@ -141,8 +139,7 @@ static int decode_significance_8x8_x86(CABACContext *c, "test $1, %4 \n\t" " jnz 4f \n\t" - "add $4, %0 \n\t" - "mov %0, %2 \n\t" + "add $4, %2 \n\t" "3: \n\t" "addl $1, %k6 \n\t" @@ -159,7 +156,7 @@ static int decode_significance_8x8_x86(CABACContext *c, "movl %3, %a13(%7) \n\t" :"=&q"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit), "=&r"(range), "=&r"(state) - :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off), + :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_coeff_ctx_base), "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "memory" From f5f004bc5a40e5a5de62bd5e2818ab5de7f6bf21 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 28 Jul 2011 20:21:33 +0100 Subject: [PATCH 708/780] x86: cabac: don't load/store context values in asm Inspection of compiled code shows gcc handles these fine on its own. Benchmarking also shows no measurable speed difference. Removing the remaining cases in get_cabac_bypass_sign_x86() does cause more substantial changes to the compiled code with uncertain impact. Signed-off-by: Mans Rullgard --- libavcodec/x86/cabac.h | 12 +++--------- libavcodec/x86/h264_i386.h | 32 +++++++------------------------- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index 1ad74ff3e0..ae3f4b6e9e 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -87,19 +87,13 @@ static av_always_inline int get_cabac_inline_x86(CABACContext *c, uint8_t *const state) { - int bit, low, range, tmp; + int bit, tmp; __asm__ volatile( - "movl %a6(%5), %2 \n\t" - "movl %a7(%5), %1 \n\t" BRANCHLESS_GET_CABAC("%0", "%5", "(%4)", "%1", "%w1", "%2", - "%3", "%b3", "%a8") - "movl %2, %a6(%5) \n\t" - "movl %1, %a7(%5) \n\t" - - :"=&r"(bit), "=&r"(low), "=&r"(range), "=&q"(tmp) + "%3", "%b3", "%a6") + :"=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp) :"r"(state), "r"(c), - "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "memory" ); diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index 0151cd59a8..eb77002ce0 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -45,23 +45,18 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, int minusindex= 4-(intptr_t)index; int bit; x86_reg coeff_count; - int low; - int range; __asm__ volatile( - "movl %a11(%6), %5 \n\t" - "movl %a12(%6), %3 \n\t" - "2: \n\t" BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3", - "%w3", "%5", "%k0", "%b0", "%a13") + "%w3", "%5", "%k0", "%b0", "%a11") "test $1, %4 \n\t" " jz 3f \n\t" "add %10, %1 \n\t" BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3", - "%w3", "%5", "%k0", "%b0", "%a13") + "%w3", "%5", "%k0", "%b0", "%a11") "sub %10, %1 \n\t" "mov %2, %0 \n\t" @@ -85,13 +80,9 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "4: \n\t" "add %9, %k0 \n\t" "shr $2, %k0 \n\t" - - "movl %5, %a11(%6) \n\t" - "movl %3, %a12(%6) \n\t" :"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), - "=&r"(low), "=&r"(bit), "=&r"(range) + "+&r"(c->low), "=&r"(bit), "+&r"(c->range) :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), - "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "memory" ); @@ -104,14 +95,9 @@ static int decode_significance_8x8_x86(CABACContext *c, int minusindex= 4-(intptr_t)index; int bit; x86_reg coeff_count; - int low; - int range; x86_reg last=0; x86_reg state; __asm__ volatile( - "movl %a12(%7), %5 \n\t" - "movl %a13(%7), %3 \n\t" - "mov %1, %6 \n\t" "2: \n\t" @@ -120,7 +106,7 @@ static int decode_significance_8x8_x86(CABACContext *c, "add %9, %6 \n\t" BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3", - "%w3", "%5", "%k0", "%b0", "%a14") + "%w3", "%5", "%k0", "%b0", "%a12") "mov %1, %k6 \n\t" "test $1, %4 \n\t" @@ -130,7 +116,7 @@ static int decode_significance_8x8_x86(CABACContext *c, "add %11, %6 \n\t" BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3", - "%w3", "%5", "%k0", "%b0", "%a14") + "%w3", "%5", "%k0", "%b0", "%a12") "mov %2, %0 \n\t" "mov %1, %k6 \n\t" @@ -151,13 +137,9 @@ static int decode_significance_8x8_x86(CABACContext *c, "4: \n\t" "addl %8, %k0 \n\t" "shr $2, %k0 \n\t" - - "movl %5, %a12(%7) \n\t" - "movl %3, %a13(%7) \n\t" - :"=&q"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit), - "=&r"(range), "=&r"(state) + :"=&q"(coeff_count),"+m"(last), "+m"(index), "+&r"(c->low), "=&r"(bit), + "+&r"(c->range), "=&r"(state) :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_coeff_ctx_base), - "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "memory" ); From 2a11952f457658d58303c8e5b4e10fb4599eef4f Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Wed, 27 Jul 2011 19:09:45 -0400 Subject: [PATCH 709/780] h263dec: Propagate AV_LOG_ERRORs from slice decoding through frame decoding with sufficient error recognition Signed-off-by: Ronald S. Bultje --- doc/ffmpeg.texi | 2 ++ libavcodec/avcodec.h | 1 + libavcodec/h263dec.c | 6 +++--- libavcodec/options.c | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 5a783e3c15..4dca5d8991 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -470,6 +470,8 @@ FF_ER_COMPLIANT FF_ER_AGGRESSIVE @item 4 FF_ER_VERY_AGGRESSIVE +@item 5 +FF_ER_EXPLODE @end table @item -ec @var{bit_mask} diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index b6cac7c77d..75c107c159 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1446,6 +1446,7 @@ typedef struct AVCodecContext { #define FF_ER_COMPLIANT 2 #define FF_ER_AGGRESSIVE 3 #define FF_ER_VERY_AGGRESSIVE 4 +#define FF_ER_EXPLODE 5 /** * Called at the beginning of each frame to get a buffer for it. diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 6eea8def11..a19e55c6ac 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -638,7 +638,7 @@ retry: s->mb_x=0; s->mb_y=0; - decode_slice(s); + ret = decode_slice(s); while(s->mb_ymb_height){ if(s->msmpeg4_version){ if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits) @@ -654,7 +654,7 @@ retry: if(s->msmpeg4_version<4 && s->h263_pred) ff_mpeg4_clean_buffers(s); - decode_slice(s); + if (decode_slice(s) < 0) ret = AVERROR_INVALIDDATA; } if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I) @@ -722,7 +722,7 @@ assert(s->current_picture.pict_type == s->pict_type); av_log(avctx, AV_LOG_DEBUG, "%"PRId64"\n", rdtsc()-time); #endif - return get_consumed_bytes(s, buf_size); + return (ret && avctx->error_recognition >= FF_ER_EXPLODE)?ret:get_consumed_bytes(s, buf_size); } AVCodec ff_h263_decoder = { diff --git a/libavcodec/options.c b/libavcodec/options.c index 4869046665..0f0ca2aaa3 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -184,6 +184,7 @@ static const AVOption options[]={ {"compliant", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_COMPLIANT }, INT_MIN, INT_MAX, V|D, "er"}, {"aggressive", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, {"very_aggressive", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_VERY_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, +{"explode", "abort decoding on error recognition", 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, V|D, "er"}, {"has_b_frames", NULL, OFFSET(has_b_frames), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, {"block_align", NULL, OFFSET(block_align), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, {"parse_only", NULL, OFFSET(parse_only), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, From 3ad168412600e16dfaa4b41b21322a82a8535990 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 29 Jul 2011 01:55:58 +0100 Subject: [PATCH 710/780] x86: cabac: add operand size suffixes missing from 6c32576 This fixes build with clang. Signed-off-by: Mans Rullgard --- libavcodec/x86/cabac.h | 2 +- libavcodec/x86/h264_i386.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index ae3f4b6e9e..545cf7c464 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -67,7 +67,7 @@ "test "lowword" , "lowword" \n\t"\ " jnz 1f \n\t"\ "mov "byte"("cabac"), %%"REG_c" \n\t"\ - "add $2 , "byte "("cabac") \n\t"\ + "add"OPSIZE" $2 , "byte "("cabac") \n\t"\ "movzwl (%%"REG_c") , "tmp" \n\t"\ "lea -1("low") , %%ecx \n\t"\ "xor "low" , %%ecx \n\t"\ diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index eb77002ce0..f32310ca0c 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -67,7 +67,7 @@ static int decode_significance_x86(CABACContext *c, int max_coeff, "test $1, %4 \n\t" " jnz 4f \n\t" - "add $4, %2 \n\t" + "add"OPSIZE" $4, %2 \n\t" "3: \n\t" "add $1, %1 \n\t" @@ -125,7 +125,7 @@ static int decode_significance_8x8_x86(CABACContext *c, "test $1, %4 \n\t" " jnz 4f \n\t" - "add $4, %2 \n\t" + "add"OPSIZE" $4, %2 \n\t" "3: \n\t" "addl $1, %k6 \n\t" From ec6402b7c595c3ceed6d1b8c1b75c6aa8336e052 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 17 Jul 2011 12:54:31 +0200 Subject: [PATCH 711/780] lavc: use designated initialisers for all codecs. It's more readable and less prone to breakage. --- libavcodec/4xm.c | 17 +++--- libavcodec/8bps.c | 17 +++--- libavcodec/aacdec.c | 15 +++-- libavcodec/aacenc.c | 14 ++--- libavcodec/aasc.c | 17 +++--- libavcodec/ac3enc_fixed.c | 15 +++-- libavcodec/ac3enc_float.c | 15 +++-- libavcodec/adxdec.c | 14 ++--- libavcodec/adxenc.c | 15 +++-- libavcodec/alac.c | 15 +++-- libavcodec/alacenc.c | 14 ++--- libavcodec/alsdec.c | 15 +++-- libavcodec/anm.c | 17 +++--- libavcodec/apedec.c | 15 +++-- libavcodec/asv1.c | 58 +++++++++--------- libavcodec/aura.c | 18 +++--- libavcodec/avs.c | 16 +++-- libavcodec/bink.c | 15 +++-- libavcodec/binkaudio.c | 30 +++++----- libavcodec/bmp.c | 17 +++--- libavcodec/bmpenc.c | 13 ++-- libavcodec/c93.c | 17 +++--- libavcodec/cavsdec.c | 17 +++--- libavcodec/cdgraphics.c | 17 +++--- libavcodec/cinepak.c | 17 +++--- libavcodec/cljr.c | 28 ++++----- libavcodec/cscd.c | 17 +++--- libavcodec/cyuv.c | 36 +++++------ libavcodec/dfa.c | 17 +++--- libavcodec/dnxhddec.c | 17 +++--- libavcodec/dnxhdenc.c | 14 ++--- libavcodec/dpx.c | 17 +++--- libavcodec/dsicinav.c | 31 +++++----- libavcodec/dv.c | 30 +++++----- libavcodec/dvbsub.c | 11 ++-- libavcodec/dvbsubdec.c | 15 +++-- libavcodec/dvdsubdec.c | 12 ++-- libavcodec/dvdsubenc.c | 10 ++-- libavcodec/dxa.c | 17 +++--- libavcodec/eacmv.c | 17 +++--- libavcodec/eamad.c | 17 +++--- libavcodec/eatgq.c | 17 +++--- libavcodec/eatgv.c | 15 +++-- libavcodec/eatqi.c | 17 +++--- libavcodec/escape124.c | 17 +++--- libavcodec/ffv1.c | 32 +++++----- libavcodec/flacdec.c | 15 +++-- libavcodec/flacenc.c | 15 +++-- libavcodec/flicvideo.c | 21 +++---- libavcodec/flvdec.c | 17 +++--- libavcodec/flvenc.c | 14 ++--- libavcodec/fraps.c | 17 +++--- libavcodec/frwu.c | 16 +++-- libavcodec/g726.c | 30 +++++----- libavcodec/gif.c | 14 ++--- libavcodec/gifdec.c | 17 +++--- libavcodec/gsmdec.c | 28 ++++----- libavcodec/h261dec.c | 17 +++--- libavcodec/h261enc.c | 14 ++--- libavcodec/h263dec.c | 17 +++--- libavcodec/h264.c | 36 ++++++----- libavcodec/huffyuv.c | 64 ++++++++++---------- libavcodec/idcinvideo.c | 17 +++--- libavcodec/iff.c | 34 +++++------ libavcodec/indeo2.c | 17 +++--- libavcodec/indeo3.c | 18 +++--- libavcodec/intelh263dec.c | 17 +++--- libavcodec/interplayvideo.c | 17 +++--- libavcodec/jpeglsdec.c | 17 +++--- libavcodec/kgv1dec.c | 15 +++-- libavcodec/kmvc.c | 17 +++--- libavcodec/lagarith.c | 17 +++--- libavcodec/lcldec.c | 34 +++++------ libavcodec/lclenc.c | 14 ++--- libavcodec/libdiracdec.c | 17 +++--- libavcodec/libdiracenc.c | 14 ++--- libavcodec/libfaac.c | 14 ++--- libavcodec/libgsm.c | 54 ++++++++--------- libavcodec/libmp3lame.c | 14 ++--- libavcodec/libopencore-amr.c | 45 +++++++------- libavcodec/libschroedingerdec.c | 17 +++--- libavcodec/libschroedingerenc.c | 14 ++--- libavcodec/libspeexdec.c | 15 +++-- libavcodec/libvo-aacenc.c | 15 +++-- libavcodec/libvo-amrwbenc.c | 15 +++-- libavcodec/libvpxdec.c | 16 +++-- libavcodec/libvpxenc.c | 17 +++--- libavcodec/libxvidff.c | 14 ++--- libavcodec/loco.c | 17 +++--- libavcodec/mace.c | 28 ++++----- libavcodec/mdec.c | 17 +++--- libavcodec/mimic.c | 17 +++--- libavcodec/mjpegbdec.c | 18 +++--- libavcodec/mjpegdec.c | 36 +++++------ libavcodec/mjpegenc.c | 14 ++--- libavcodec/mlpdec.c | 28 ++++----- libavcodec/mmvideo.c | 17 +++--- libavcodec/motionpixels.c | 17 +++--- libavcodec/mpc7.c | 14 ++--- libavcodec/mpc8.c | 14 ++--- libavcodec/mpeg12.c | 102 +++++++++++++++----------------- libavcodec/mpeg12enc.c | 28 ++++----- libavcodec/mpeg4videodec.c | 34 +++++------ libavcodec/mpeg4videoenc.c | 14 ++--- libavcodec/mpegaudioenc.c | 15 +++-- libavcodec/mpegvideo_enc.c | 70 +++++++++++----------- libavcodec/msmpeg4.c | 68 ++++++++++----------- libavcodec/msrle.c | 17 +++--- libavcodec/msvideo1.c | 17 +++--- libavcodec/nellymoserdec.c | 15 +++-- libavcodec/nuv.c | 17 +++--- libavcodec/pamenc.c | 12 ++-- libavcodec/pcm-mpeg.c | 12 ++-- libavcodec/pcx.c | 18 +++--- libavcodec/pcxenc.c | 13 ++-- libavcodec/pgssubdec.c | 15 +++-- libavcodec/pictordec.c | 16 +++-- libavcodec/pngdec.c | 18 +++--- libavcodec/pngenc.c | 13 ++-- libavcodec/pnmdec.c | 85 +++++++++++++------------- libavcodec/pnmenc.c | 48 +++++++-------- libavcodec/ptx.c | 18 +++--- libavcodec/qdrw.c | 17 +++--- libavcodec/qpeg.c | 17 +++--- libavcodec/qtrle.c | 17 +++--- libavcodec/qtrleenc.c | 14 ++--- libavcodec/r210dec.c | 32 +++++----- libavcodec/rawdec.c | 15 +++-- libavcodec/rawenc.c | 12 ++-- libavcodec/rl2.c | 17 +++--- libavcodec/roqaudioenc.c | 15 +++-- libavcodec/roqvideodec.c | 17 +++--- libavcodec/rpza.c | 17 +++--- libavcodec/rv10.c | 34 +++++------ libavcodec/rv10enc.c | 14 ++--- libavcodec/rv20enc.c | 14 ++--- libavcodec/rv30.c | 17 +++--- libavcodec/rv40.c | 17 +++--- libavcodec/sgidec.c | 15 +++-- libavcodec/sgienc.c | 13 ++-- libavcodec/shorten.c | 15 +++-- libavcodec/sipr.c | 14 ++--- libavcodec/smacker.c | 30 ++++------ libavcodec/smc.c | 17 +++--- libavcodec/snow.c | 32 +++++----- libavcodec/sp5xdec.c | 34 +++++------ libavcodec/sunrast.c | 18 +++--- libavcodec/svq1dec.c | 17 +++--- libavcodec/svq1enc.c | 14 ++--- libavcodec/svq3.c | 17 +++--- libavcodec/targa.c | 18 +++--- libavcodec/tiertexseqv.c | 17 +++--- libavcodec/tiff.c | 18 +++--- libavcodec/tiffenc.c | 15 ++--- libavcodec/truemotion1.c | 17 +++--- libavcodec/truemotion2.c | 17 +++--- libavcodec/truespeech.c | 14 ++--- libavcodec/tscc.c | 17 +++--- libavcodec/tta.c | 15 +++-- libavcodec/txd.c | 18 +++--- libavcodec/ulti.c | 18 +++--- libavcodec/v210dec.c | 16 +++-- libavcodec/v210enc.c | 13 ++-- libavcodec/v210x.c | 16 +++-- libavcodec/vb.c | 15 +++-- libavcodec/vc1dec.c | 72 ++++++++++------------ libavcodec/vcr1.c | 29 +++++---- libavcodec/vmdav.c | 31 +++++----- libavcodec/vmnc.c | 17 +++--- libavcodec/vorbisdec.c | 15 +++-- libavcodec/vorbisenc.c | 14 ++--- libavcodec/vp3.c | 36 +++++------ libavcodec/vp5.c | 17 +++--- libavcodec/vp6.c | 51 ++++++++-------- libavcodec/vp8.c | 17 +++--- libavcodec/vqavideo.c | 17 +++--- libavcodec/wavpack.c | 15 +++-- libavcodec/wmaprodec.c | 15 +++-- libavcodec/wmavoice.c | 17 +++--- libavcodec/wmv2dec.c | 17 +++--- libavcodec/wmv2enc.c | 14 ++--- libavcodec/wnv1.c | 17 +++--- libavcodec/ws-snd1.c | 13 ++-- libavcodec/xan.c | 17 +++--- libavcodec/xl.c | 17 +++--- libavcodec/xsubdec.c | 13 ++-- libavcodec/xsubenc.c | 12 ++-- libavcodec/xxan.c | 17 +++--- libavcodec/yop.c | 15 +++-- libavcodec/zmbv.c | 17 +++--- libavcodec/zmbvenc.c | 14 ++--- 191 files changed, 1826 insertions(+), 2109 deletions(-) diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 176feb94c0..92157893dd 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -866,15 +866,14 @@ static av_cold int decode_end(AVCodecContext *avctx){ } AVCodec ff_fourxm_decoder = { - "4xm", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_4XM, - sizeof(FourXContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "4xm", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_4XM, + .priv_data_size = sizeof(FourXContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("4X Movie"), }; diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index 055715fde5..7c53432738 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -221,14 +221,13 @@ static av_cold int decode_end(AVCodecContext *avctx) AVCodec ff_eightbps_decoder = { - "8bps", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_8BPS, - sizeof(EightBpsContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "8bps", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_8BPS, + .priv_data_size = sizeof(EightBpsContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("QuickTime 8BPS video"), }; diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index dac85c229d..6bf14275f9 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -2539,14 +2539,13 @@ av_cold static int latm_decode_init(AVCodecContext *avctx) AVCodec ff_aac_decoder = { - "aac", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AAC, - sizeof(AACContext), - aac_decode_init, - NULL, - aac_decode_close, - aac_decode_frame, + .name = "aac", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_AAC, + .priv_data_size = sizeof(AACContext), + .init = aac_decode_init, + .close = aac_decode_close, + .decode = aac_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"), .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index eae933235f..9e876ff5dc 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -674,13 +674,13 @@ static const AVClass aacenc_class = { }; AVCodec ff_aac_encoder = { - "aac", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AAC, - sizeof(AACEncContext), - aac_encode_init, - aac_encode_frame, - aac_encode_end, + .name = "aac", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_AAC, + .priv_data_size = sizeof(AACEncContext), + .init = aac_encode_init, + .encode = aac_encode_frame, + .close = aac_encode_end, .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"), diff --git a/libavcodec/aasc.c b/libavcodec/aasc.c index e80e0945a1..11ea5779b1 100644 --- a/libavcodec/aasc.c +++ b/libavcodec/aasc.c @@ -110,14 +110,13 @@ static av_cold int aasc_decode_end(AVCodecContext *avctx) } AVCodec ff_aasc_decoder = { - "aasc", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_AASC, - sizeof(AascContext), - aasc_decode_init, - NULL, - aasc_decode_end, - aasc_decode_frame, - CODEC_CAP_DR1, + .name = "aasc", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_AASC, + .priv_data_size = sizeof(AascContext), + .init = aasc_decode_init, + .close = aasc_decode_end, + .decode = aasc_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Autodesk RLE"), }; diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index 508ecb1efb..951b73d69b 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -121,14 +121,13 @@ static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx) AVCodec ff_ac3_fixed_encoder = { - "ac3_fixed", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AC3, - sizeof(AC3EncodeContext), - ac3_fixed_encode_init, - ff_ac3_fixed_encode_frame, - ff_ac3_encode_close, - NULL, + .name = "ac3_fixed", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_AC3, + .priv_data_size = sizeof(AC3EncodeContext), + .init = ac3_fixed_encode_init, + .encode = ff_ac3_fixed_encode_frame, + .close = ff_ac3_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), .priv_class = &ac3enc_class, diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 9f691a1e16..8e74aaf285 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -121,14 +121,13 @@ static void clip_coefficients(DSPContext *dsp, float *coef, unsigned int len) #if CONFIG_AC3_ENCODER AVCodec ff_ac3_encoder = { - "ac3", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AC3, - sizeof(AC3EncodeContext), - ff_ac3_encode_init, - ff_ac3_float_encode_frame, - ff_ac3_encode_close, - NULL, + .name = "ac3", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_AC3, + .priv_data_size = sizeof(AC3EncodeContext), + .init = ff_ac3_encode_init, + .encode = ff_ac3_float_encode_frame, + .close = ff_ac3_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), .priv_class = &ac3enc_class, diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c index 48acc659cc..79fcf13c31 100644 --- a/libavcodec/adxdec.c +++ b/libavcodec/adxdec.c @@ -167,14 +167,12 @@ static int adx_decode_frame(AVCodecContext *avctx, } AVCodec ff_adpcm_adx_decoder = { - "adpcm_adx", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_ADPCM_ADX, - sizeof(ADXContext), - adx_decode_init, - NULL, - NULL, - adx_decode_frame, + .name = "adpcm_adx", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_ADPCM_ADX, + .priv_data_size = sizeof(ADXContext), + .init = adx_decode_init, + .decode = adx_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"), }; diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c index b0847f43ef..296ccbd58a 100644 --- a/libavcodec/adxenc.c +++ b/libavcodec/adxenc.c @@ -184,14 +184,13 @@ static int adx_encode_frame(AVCodecContext *avctx, } AVCodec ff_adpcm_adx_encoder = { - "adpcm_adx", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_ADPCM_ADX, - sizeof(ADXContext), - adx_encode_init, - adx_encode_frame, - adx_encode_close, - NULL, + .name = "adpcm_adx", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_ADPCM_ADX, + .priv_data_size = sizeof(ADXContext), + .init = adx_encode_init, + .encode = adx_encode_frame, + .close = adx_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"), }; diff --git a/libavcodec/alac.c b/libavcodec/alac.c index f8534f9a0f..3580b5096c 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -679,13 +679,12 @@ static av_cold int alac_decode_close(AVCodecContext *avctx) } AVCodec ff_alac_decoder = { - "alac", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_ALAC, - sizeof(ALACContext), - alac_decode_init, - NULL, - alac_decode_close, - alac_decode_frame, + .name = "alac", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_ALAC, + .priv_data_size = sizeof(ALACContext), + .init = alac_decode_init, + .close = alac_decode_close, + .decode = alac_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), }; diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index acaa545915..fe03bb7dad 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -524,13 +524,13 @@ static av_cold int alac_encode_close(AVCodecContext *avctx) } AVCodec ff_alac_encoder = { - "alac", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_ALAC, - sizeof(AlacEncodeContext), - alac_encode_init, - alac_encode_frame, - alac_encode_close, + .name = "alac", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_ALAC, + .priv_data_size = sizeof(AlacEncodeContext), + .init = alac_encode_init, + .encode = alac_encode_frame, + .close = alac_encode_close, .capabilities = CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 055bfd0d04..1ab72ad4dd 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -1739,14 +1739,13 @@ static av_cold void flush(AVCodecContext *avctx) AVCodec ff_als_decoder = { - "als", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP4ALS, - sizeof(ALSDecContext), - decode_init, - NULL, - decode_end, - decode_frame, + .name = "als", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP4ALS, + .priv_data_size = sizeof(ALSDecContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, .flush = flush, .capabilities = CODEC_CAP_SUBFRAMES, .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Audio Lossless Coding (ALS)"), diff --git a/libavcodec/anm.c b/libavcodec/anm.c index ef037f2468..94cac5e3ce 100644 --- a/libavcodec/anm.c +++ b/libavcodec/anm.c @@ -184,14 +184,13 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_anm_decoder = { - "anm", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ANM, - sizeof(AnmContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "anm", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ANM, + .priv_data_size = sizeof(AnmContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Deluxe Paint Animation"), }; diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index f92b37527e..a8ca44b9f7 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -885,14 +885,13 @@ static void ape_flush(AVCodecContext *avctx) } AVCodec ff_ape_decoder = { - "ape", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_APE, - sizeof(APEContext), - ape_decode_init, - NULL, - ape_decode_close, - ape_decode_frame, + .name = "ape", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_APE, + .priv_data_size = sizeof(APEContext), + .init = ape_decode_init, + .close = ape_decode_close, + .decode = ape_decode_frame, .capabilities = CODEC_CAP_SUBFRAMES, .flush = ape_flush, .long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"), diff --git a/libavcodec/asv1.c b/libavcodec/asv1.c index e8ab07b4cb..97c5e681fe 100644 --- a/libavcodec/asv1.c +++ b/libavcodec/asv1.c @@ -603,39 +603,37 @@ static av_cold int decode_end(AVCodecContext *avctx){ } AVCodec ff_asv1_decoder = { - "asv1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ASV1, - sizeof(ASV1Context), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "asv1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ASV1, + .priv_data_size = sizeof(ASV1Context), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name= NULL_IF_CONFIG_SMALL("ASUS V1"), }; AVCodec ff_asv2_decoder = { - "asv2", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ASV2, - sizeof(ASV1Context), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "asv2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ASV2, + .priv_data_size = sizeof(ASV1Context), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name= NULL_IF_CONFIG_SMALL("ASUS V2"), }; #if CONFIG_ASV1_ENCODER AVCodec ff_asv1_encoder = { - "asv1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ASV1, - sizeof(ASV1Context), - encode_init, - encode_frame, + .name = "asv1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ASV1, + .priv_data_size = sizeof(ASV1Context), + .init = encode_init, + .encode = encode_frame, //encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("ASUS V1"), @@ -644,12 +642,12 @@ AVCodec ff_asv1_encoder = { #if CONFIG_ASV2_ENCODER AVCodec ff_asv2_encoder = { - "asv2", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ASV2, - sizeof(ASV1Context), - encode_init, - encode_frame, + .name = "asv2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ASV2, + .priv_data_size = sizeof(ASV1Context), + .init = encode_init, + .encode = encode_frame, //encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("ASUS V2"), diff --git a/libavcodec/aura.c b/libavcodec/aura.c index e85e8225fd..f1fdb5ccec 100644 --- a/libavcodec/aura.c +++ b/libavcodec/aura.c @@ -123,16 +123,14 @@ static av_cold int aura_decode_end(AVCodecContext *avctx) } AVCodec ff_aura2_decoder = { - "aura2", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_AURA2, - sizeof(AuraDecodeContext), - aura_decode_init, - NULL, - aura_decode_end, - aura_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "aura2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_AURA2, + .priv_data_size = sizeof(AuraDecodeContext), + .init = aura_decode_init, + .close = aura_decode_end, + .decode = aura_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Auravision Aura 2"), }; diff --git a/libavcodec/avs.c b/libavcodec/avs.c index 1c2682b338..12fb3976d5 100644 --- a/libavcodec/avs.c +++ b/libavcodec/avs.c @@ -151,14 +151,12 @@ static av_cold int avs_decode_init(AVCodecContext * avctx) } AVCodec ff_avs_decoder = { - "avs", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_AVS, - sizeof(AvsContext), - avs_decode_init, - NULL, - NULL, - avs_decode_frame, - CODEC_CAP_DR1, + .name = "avs", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_AVS, + .priv_data_size = sizeof(AvsContext), + .init = avs_decode_init, + .decode = avs_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("AVS (Audio Video Standard) video"), }; diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 8f42ff8bea..2b5bc75078 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1318,13 +1318,12 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_bink_decoder = { - "binkvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_BINKVIDEO, - sizeof(BinkContext), - decode_init, - NULL, - decode_end, - decode_frame, + .name = "binkvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_BINKVIDEO, + .priv_data_size = sizeof(BinkContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Bink video"), }; diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c index 9722bdff3e..2ed39e9e7a 100644 --- a/libavcodec/binkaudio.c +++ b/libavcodec/binkaudio.c @@ -292,25 +292,23 @@ static int decode_frame(AVCodecContext *avctx, } AVCodec ff_binkaudio_rdft_decoder = { - "binkaudio_rdft", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_BINKAUDIO_RDFT, - sizeof(BinkAudioContext), - decode_init, - NULL, - decode_end, - decode_frame, + .name = "binkaudio_rdft", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_BINKAUDIO_RDFT, + .priv_data_size = sizeof(BinkAudioContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)") }; AVCodec ff_binkaudio_dct_decoder = { - "binkaudio_dct", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_BINKAUDIO_DCT, - sizeof(BinkAudioContext), - decode_init, - NULL, - decode_end, - decode_frame, + .name = "binkaudio_dct", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_BINKAUDIO_DCT, + .priv_data_size = sizeof(BinkAudioContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (DCT)") }; diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index b7fee130bc..21ebeec694 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -336,14 +336,13 @@ static av_cold int bmp_decode_end(AVCodecContext *avctx) } AVCodec ff_bmp_decoder = { - "bmp", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_BMP, - sizeof(BMPContext), - bmp_decode_init, - NULL, - bmp_decode_end, - bmp_decode_frame, - CODEC_CAP_DR1, + .name = "bmp", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_BMP, + .priv_data_size = sizeof(BMPContext), + .init = bmp_decode_init, + .close = bmp_decode_end, + .decode = bmp_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("BMP image"), }; diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index b3630f094c..9cd7adb390 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -150,13 +150,12 @@ static int bmp_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_s } AVCodec ff_bmp_encoder = { - "bmp", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_BMP, - sizeof(BMPContext), - bmp_encode_init, - bmp_encode_frame, - NULL, //encode_end, + .name = "bmp", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_BMP, + .priv_data_size = sizeof(BMPContext), + .init = bmp_encode_init, + .encode = bmp_encode_frame, .pix_fmts = (const enum PixelFormat[]){ PIX_FMT_BGR24, PIX_FMT_RGB555, PIX_FMT_RGB565, diff --git a/libavcodec/c93.c b/libavcodec/c93.c index 0b6eb02614..ecfd035d75 100644 --- a/libavcodec/c93.c +++ b/libavcodec/c93.c @@ -243,14 +243,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, } AVCodec ff_c93_decoder = { - "c93", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_C93, - sizeof(C93DecoderContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "c93", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_C93, + .priv_data_size = sizeof(C93DecoderContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Interplay C93"), }; diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index b2e221d627..d5a21bf2de 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -710,15 +710,14 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size, } AVCodec ff_cavs_decoder = { - "cavs", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_CAVS, - sizeof(AVSContext), - ff_cavs_init, - NULL, - ff_cavs_end, - cavs_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .name = "cavs", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_CAVS, + .priv_data_size = sizeof(AVSContext), + .init = ff_cavs_init, + .close = ff_cavs_end, + .decode = cavs_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, .flush= cavs_flush, .long_name= NULL_IF_CONFIG_SMALL("Chinese AVS video (AVS1-P2, JiZhun profile)"), }; diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index 6493709aaf..f1f474f3de 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -368,14 +368,13 @@ static av_cold int cdg_decode_end(AVCodecContext *avctx) } AVCodec ff_cdgraphics_decoder = { - "cdgraphics", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_CDGRAPHICS, - sizeof(CDGraphicsContext), - cdg_decode_init, - NULL, - cdg_decode_end, - cdg_decode_frame, - CODEC_CAP_DR1, + .name = "cdgraphics", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_CDGRAPHICS, + .priv_data_size = sizeof(CDGraphicsContext), + .init = cdg_decode_init, + .close = cdg_decode_end, + .decode = cdg_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"), }; diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c index 4bda2a74eb..1d41ba2287 100644 --- a/libavcodec/cinepak.c +++ b/libavcodec/cinepak.c @@ -459,14 +459,13 @@ static av_cold int cinepak_decode_end(AVCodecContext *avctx) } AVCodec ff_cinepak_decoder = { - "cinepak", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_CINEPAK, - sizeof(CinepakContext), - cinepak_decode_init, - NULL, - cinepak_decode_end, - cinepak_decode_frame, - CODEC_CAP_DR1, + .name = "cinepak", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_CINEPAK, + .priv_data_size = sizeof(CinepakContext), + .init = cinepak_decode_init, + .close = cinepak_decode_end, + .decode = cinepak_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Cinepak"), }; diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c index e2b01e2a6a..f79cf11bea 100644 --- a/libavcodec/cljr.c +++ b/libavcodec/cljr.c @@ -141,26 +141,24 @@ static av_cold int encode_init(AVCodecContext *avctx){ #endif AVCodec ff_cljr_decoder = { - "cljr", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_CLJR, - sizeof(CLJRContext), - decode_init, - NULL, - NULL, - decode_frame, - CODEC_CAP_DR1, + .name = "cljr", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_CLJR, + .priv_data_size = sizeof(CLJRContext), + .init = decode_init, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"), }; #if CONFIG_CLJR_ENCODER AVCodec ff_cljr_encoder = { - "cljr", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_CLJR, - sizeof(CLJRContext), - encode_init, - encode_frame, + .name = "cljr", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_CLJR, + .priv_data_size = sizeof(CLJRContext), + .init = encode_init, + .encode = encode_frame, //encode_end, .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"), }; diff --git a/libavcodec/cscd.c b/libavcodec/cscd.c index 3518929c18..00921bc47d 100644 --- a/libavcodec/cscd.c +++ b/libavcodec/cscd.c @@ -255,15 +255,14 @@ static av_cold int decode_end(AVCodecContext *avctx) { } AVCodec ff_cscd_decoder = { - "camstudio", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_CSCD, - sizeof(CamStudioContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "camstudio", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_CSCD, + .priv_data_size = sizeof(CamStudioContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("CamStudio"), }; diff --git a/libavcodec/cyuv.c b/libavcodec/cyuv.c index ecdec17439..60cce82fee 100644 --- a/libavcodec/cyuv.c +++ b/libavcodec/cyuv.c @@ -179,32 +179,28 @@ static av_cold int cyuv_decode_end(AVCodecContext *avctx) #if CONFIG_AURA_DECODER AVCodec ff_aura_decoder = { - "aura", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_AURA, - sizeof(CyuvDecodeContext), - cyuv_decode_init, - NULL, - cyuv_decode_end, - cyuv_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "aura", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_AURA, + .priv_data_size = sizeof(CyuvDecodeContext), + .init = cyuv_decode_init, + .close = cyuv_decode_end, + .decode = cyuv_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Auravision AURA"), }; #endif #if CONFIG_CYUV_DECODER AVCodec ff_cyuv_decoder = { - "cyuv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_CYUV, - sizeof(CyuvDecodeContext), - cyuv_decode_init, - NULL, - cyuv_decode_end, - cyuv_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "cyuv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_CYUV, + .priv_data_size = sizeof(CyuvDecodeContext), + .init = cyuv_decode_init, + .close = cyuv_decode_end, + .decode = cyuv_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Creative YUV (CYUV)"), }; #endif diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c index 919375baf0..08bb2a4934 100644 --- a/libavcodec/dfa.c +++ b/libavcodec/dfa.c @@ -384,14 +384,13 @@ static av_cold int dfa_decode_end(AVCodecContext *avctx) } AVCodec ff_dfa_decoder = { - "dfa", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DFA, - sizeof(DfaContext), - dfa_decode_init, - NULL, - dfa_decode_end, - dfa_decode_frame, - CODEC_CAP_DR1, + .name = "dfa", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DFA, + .priv_data_size = sizeof(DfaContext), + .init = dfa_decode_init, + .close = dfa_decode_end, + .decode = dfa_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Chronomaster DFA"), }; diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 63ccd08b48..7198a2f796 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -392,14 +392,13 @@ static av_cold int dnxhd_decode_close(AVCodecContext *avctx) } AVCodec ff_dnxhd_decoder = { - "dnxhd", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DNXHD, - sizeof(DNXHDContext), - dnxhd_decode_init, - NULL, - dnxhd_decode_close, - dnxhd_decode_frame, - CODEC_CAP_DR1, + .name = "dnxhd", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DNXHD, + .priv_data_size = sizeof(DNXHDContext), + .init = dnxhd_decode_init, + .close = dnxhd_decode_close, + .decode = dnxhd_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), }; diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 1a0c8ce02e..adf30ba7b2 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -993,13 +993,13 @@ static int dnxhd_encode_end(AVCodecContext *avctx) } AVCodec ff_dnxhd_encoder = { - "dnxhd", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DNXHD, - sizeof(DNXHDEncContext), - dnxhd_encode_init, - dnxhd_encode_picture, - dnxhd_encode_end, + .name = "dnxhd", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DNXHD, + .priv_data_size = sizeof(DNXHDEncContext), + .init = dnxhd_encode_init, + .encode = dnxhd_encode_picture, + .close = dnxhd_encode_end, .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_YUV422P10, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 0722dd07ef..156f1deaa4 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -234,15 +234,12 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_dpx_decoder = { - "dpx", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DPX, - sizeof(DPXContext), - decode_init, - NULL, - decode_end, - decode_frame, - 0, - NULL, + .name = "dpx", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DPX, + .priv_data_size = sizeof(DPXContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("DPX image"), }; diff --git a/libavcodec/dsicinav.c b/libavcodec/dsicinav.c index 643aed946b..0e0d73b68d 100644 --- a/libavcodec/dsicinav.c +++ b/libavcodec/dsicinav.c @@ -344,26 +344,23 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, AVCodec ff_dsicinvideo_decoder = { - "dsicinvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DSICINVIDEO, - sizeof(CinVideoContext), - cinvideo_decode_init, - NULL, - cinvideo_decode_end, - cinvideo_decode_frame, - CODEC_CAP_DR1, + .name = "dsicinvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DSICINVIDEO, + .priv_data_size = sizeof(CinVideoContext), + .init = cinvideo_decode_init, + .close = cinvideo_decode_end, + .decode = cinvideo_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN video"), }; AVCodec ff_dsicinaudio_decoder = { - "dsicinaudio", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_DSICINAUDIO, - sizeof(CinAudioContext), - cinaudio_decode_init, - NULL, - NULL, - cinaudio_decode_frame, + .name = "dsicinaudio", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_DSICINAUDIO, + .priv_data_size = sizeof(CinAudioContext), + .init = cinaudio_decode_init, + .decode = cinaudio_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN audio"), }; diff --git a/libavcodec/dv.c b/libavcodec/dv.c index a35bb2f2ed..976242235b 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -1279,12 +1279,12 @@ static int dvvideo_close(AVCodecContext *c) #if CONFIG_DVVIDEO_ENCODER AVCodec ff_dvvideo_encoder = { - "dvvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DVVIDEO, - sizeof(DVVideoContext), - dvvideo_init_encoder, - dvvideo_encode_frame, + .name = "dvvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DVVIDEO, + .priv_data_size = sizeof(DVVideoContext), + .init = dvvideo_init_encoder, + .encode = dvvideo_encode_frame, .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts = (const enum PixelFormat[]) {PIX_FMT_YUV411P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), @@ -1293,16 +1293,14 @@ AVCodec ff_dvvideo_encoder = { #if CONFIG_DVVIDEO_DECODER AVCodec ff_dvvideo_decoder = { - "dvvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DVVIDEO, - sizeof(DVVideoContext), - dvvideo_init, - NULL, - dvvideo_close, - dvvideo_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, - NULL, + .name = "dvvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DVVIDEO, + .priv_data_size = sizeof(DVVideoContext), + .init = dvvideo_init, + .close = dvvideo_close, + .decode = dvvideo_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), }; diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c index 206e50e1d2..713f91ed0c 100644 --- a/libavcodec/dvbsub.c +++ b/libavcodec/dvbsub.c @@ -403,11 +403,10 @@ static int dvbsub_encode(AVCodecContext *avctx, } AVCodec ff_dvbsub_encoder = { - "dvbsub", - AVMEDIA_TYPE_SUBTITLE, - CODEC_ID_DVB_SUBTITLE, - sizeof(DVBSubtitleContext), - NULL, - dvbsub_encode, + .name = "dvbsub", + .type = AVMEDIA_TYPE_SUBTITLE, + .id = CODEC_ID_DVB_SUBTITLE, + .priv_data_size = sizeof(DVBSubtitleContext), + .encode = dvbsub_encode, .long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"), }; diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 3f39a960cb..aef2c08f30 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -1464,13 +1464,12 @@ static int dvbsub_decode(AVCodecContext *avctx, AVCodec ff_dvbsub_decoder = { - "dvbsub", - AVMEDIA_TYPE_SUBTITLE, - CODEC_ID_DVB_SUBTITLE, - sizeof(DVBSubContext), - dvbsub_init_decoder, - NULL, - dvbsub_close_decoder, - dvbsub_decode, + .name = "dvbsub", + .type = AVMEDIA_TYPE_SUBTITLE, + .id = CODEC_ID_DVB_SUBTITLE, + .priv_data_size = sizeof(DVBSubContext), + .init = dvbsub_init_decoder, + .close = dvbsub_close_decoder, + .decode = dvbsub_decode, .long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"), }; diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 8f3ba63229..776cb61ea7 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -487,13 +487,9 @@ static int dvdsub_decode(AVCodecContext *avctx, } AVCodec ff_dvdsub_decoder = { - "dvdsub", - AVMEDIA_TYPE_SUBTITLE, - CODEC_ID_DVD_SUBTITLE, - 0, - NULL, - NULL, - NULL, - dvdsub_decode, + .name = "dvdsub", + .type = AVMEDIA_TYPE_SUBTITLE, + .id = CODEC_ID_DVD_SUBTITLE, + .decode = dvdsub_decode, .long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"), }; diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c index 71c5e792d0..96f4321a2f 100644 --- a/libavcodec/dvdsubenc.c +++ b/libavcodec/dvdsubenc.c @@ -216,11 +216,9 @@ static int dvdsub_encode(AVCodecContext *avctx, } AVCodec ff_dvdsub_encoder = { - "dvdsub", - AVMEDIA_TYPE_SUBTITLE, - CODEC_ID_DVD_SUBTITLE, - 0, - NULL, - dvdsub_encode, + .name = "dvdsub", + .type = AVMEDIA_TYPE_SUBTITLE, + .id = CODEC_ID_DVD_SUBTITLE, + .encode = dvdsub_encode, .long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"), }; diff --git a/libavcodec/dxa.c b/libavcodec/dxa.c index 75f3212232..97b912a61a 100644 --- a/libavcodec/dxa.c +++ b/libavcodec/dxa.c @@ -318,15 +318,14 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_dxa_decoder = { - "dxa", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DXA, - sizeof(DxaDecContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "dxa", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DXA, + .priv_data_size = sizeof(DxaDecContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Feeble Files/ScummVM DXA"), }; diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c index c968a3d403..7449f7d47b 100644 --- a/libavcodec/eacmv.c +++ b/libavcodec/eacmv.c @@ -206,14 +206,13 @@ static av_cold int cmv_decode_end(AVCodecContext *avctx){ } AVCodec ff_eacmv_decoder = { - "eacmv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_CMV, - sizeof(CmvContext), - cmv_decode_init, - NULL, - cmv_decode_end, - cmv_decode_frame, - CODEC_CAP_DR1, + .name = "eacmv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_CMV, + .priv_data_size = sizeof(CmvContext), + .init = cmv_decode_init, + .close = cmv_decode_end, + .decode = cmv_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts CMV video"), }; diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index db22781588..772fb28440 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -307,14 +307,13 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_eamad_decoder = { - "eamad", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MAD, - sizeof(MadContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "eamad", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MAD, + .priv_data_size = sizeof(MadContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts Madcow Video") }; diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index d4f8b8fb5f..ed4cbc7528 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -244,14 +244,13 @@ static av_cold int tgq_decode_end(AVCodecContext *avctx){ } AVCodec ff_eatgq_decoder = { - "eatgq", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TGQ, - sizeof(TgqContext), - tgq_decode_init, - NULL, - tgq_decode_end, - tgq_decode_frame, - CODEC_CAP_DR1, + .name = "eatgq", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TGQ, + .priv_data_size = sizeof(TgqContext), + .init = tgq_decode_init, + .close = tgq_decode_end, + .decode = tgq_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TGQ video"), }; diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index ee5c094169..917308f571 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -335,13 +335,12 @@ static av_cold int tgv_decode_end(AVCodecContext *avctx) } AVCodec ff_eatgv_decoder = { - "eatgv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TGV, - sizeof(TgvContext), - tgv_decode_init, - NULL, - tgv_decode_end, - tgv_decode_frame, + .name = "eatgv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TGV, + .priv_data_size = sizeof(TgvContext), + .init = tgv_decode_init, + .close = tgv_decode_end, + .decode = tgv_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TGV video"), }; diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index 1215fa217b..aaf704b41a 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -153,14 +153,13 @@ static av_cold int tqi_decode_end(AVCodecContext *avctx) } AVCodec ff_eatqi_decoder = { - "eatqi", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TQI, - sizeof(TqiContext), - tqi_decode_init, - NULL, - tqi_decode_end, - tqi_decode_frame, - CODEC_CAP_DR1, + .name = "eatqi", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TQI, + .priv_data_size = sizeof(TqiContext), + .init = tqi_decode_init, + .close = tqi_decode_end, + .decode = tqi_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TQI Video"), }; diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index 9d216a4c95..815cd58a9b 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -364,15 +364,14 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVCodec ff_escape124_decoder = { - "escape124", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ESCAPE124, - sizeof(Escape124Context), - escape124_decode_init, - NULL, - escape124_decode_close, - escape124_decode_frame, - CODEC_CAP_DR1, + .name = "escape124", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ESCAPE124, + .priv_data_size = sizeof(Escape124Context), + .init = escape124_decode_init, + .close = escape124_decode_close, + .decode = escape124_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Escape 124"), }; diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 1f1d4d1c62..15d9553348 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -1724,28 +1724,26 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac } AVCodec ff_ffv1_decoder = { - "ffv1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_FFV1, - sizeof(FFV1Context), - decode_init, - NULL, - common_end, - decode_frame, - CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/ | CODEC_CAP_SLICE_THREADS, - NULL, + .name = "ffv1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_FFV1, + .priv_data_size = sizeof(FFV1Context), + .init = decode_init, + .close = common_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/ | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), }; #if CONFIG_FFV1_ENCODER AVCodec ff_ffv1_encoder = { - "ffv1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_FFV1, - sizeof(FFV1Context), - encode_init, - encode_frame, - common_end, + .name = "ffv1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_FFV1, + .priv_data_size = sizeof(FFV1Context), + .init = encode_init, + .encode = encode_frame, + .close = common_end, .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index fb18c85946..f6d0abe544 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -652,13 +652,12 @@ static av_cold int flac_decode_close(AVCodecContext *avctx) } AVCodec ff_flac_decoder = { - "flac", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_FLAC, - sizeof(FLACContext), - flac_decode_init, - NULL, - flac_decode_close, - flac_decode_frame, + .name = "flac", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_FLAC, + .priv_data_size = sizeof(FLACContext), + .init = flac_decode_init, + .close = flac_decode_close, + .decode = flac_decode_frame, .long_name= NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"), }; diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index be775cabd3..c39a721642 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1357,14 +1357,13 @@ static const AVClass flac_encoder_class = { }; AVCodec ff_flac_encoder = { - "flac", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_FLAC, - sizeof(FlacEncodeContext), - flac_encode_init, - flac_encode_frame, - flac_encode_close, - NULL, + .name = "flac", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_FLAC, + .priv_data_size = sizeof(FlacEncodeContext), + .init = flac_encode_init, + .encode = flac_encode_frame, + .close = flac_encode_close, .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"), diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c index e8c0e14386..a78fe5e077 100644 --- a/libavcodec/flicvideo.c +++ b/libavcodec/flicvideo.c @@ -742,18 +742,13 @@ static av_cold int flic_decode_end(AVCodecContext *avctx) } AVCodec ff_flic_decoder = { - "flic", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_FLIC, - sizeof(FlicDecodeContext), - flic_decode_init, - NULL, - flic_decode_end, - flic_decode_frame, - CODEC_CAP_DR1, - NULL, - NULL, - NULL, - NULL, + .name = "flic", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_FLIC, + .priv_data_size = sizeof(FlicDecodeContext), + .init = flic_decode_init, + .close = flic_decode_end, + .decode = flic_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Autodesk Animator Flic video"), }; diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 9546c1c2ce..29d680849d 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -119,15 +119,14 @@ int ff_flv_decode_picture_header(MpegEncContext *s) } AVCodec ff_flv_decoder = { - "flv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_FLV1, - sizeof(MpegEncContext), - ff_h263_decode_init, - NULL, - ff_h263_decode_end, - ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .name = "flv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_FLV1, + .priv_data_size = sizeof(MpegEncContext), + .init = ff_h263_decode_init, + .close = ff_h263_decode_end, + .decode = ff_h263_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"), .pix_fmts= ff_pixfmt_list_420, diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index 28bca2ea6a..ec637dc385 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -85,13 +85,13 @@ void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, in } AVCodec ff_flv_encoder = { - "flv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_FLV1, - sizeof(MpegEncContext), - MPV_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "flv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_FLV1, + .priv_data_size = sizeof(MpegEncContext), + .init = MPV_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"), }; diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index 2bbc7b9f01..ed33c3eabf 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -356,14 +356,13 @@ static av_cold int decode_end(AVCodecContext *avctx) AVCodec ff_fraps_decoder = { - "fraps", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_FRAPS, - sizeof(FrapsContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "fraps", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_FRAPS, + .priv_data_size = sizeof(FrapsContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Fraps"), }; diff --git a/libavcodec/frwu.c b/libavcodec/frwu.c index ee3d2e47a0..061c460040 100644 --- a/libavcodec/frwu.c +++ b/libavcodec/frwu.c @@ -110,14 +110,12 @@ static av_cold int decode_close(AVCodecContext *avctx) } AVCodec ff_frwu_decoder = { - "FRWU", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_FRWU, - 0, - decode_init, - NULL, - decode_close, - decode_frame, - CODEC_CAP_DR1, + .name = "FRWU", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_FRWU, + .init = decode_init, + .close = decode_close, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Forward Uncompressed"), }; diff --git a/libavcodec/g726.c b/libavcodec/g726.c index 09df727c0f..0f8fe81fc3 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -392,14 +392,13 @@ static int g726_decode_frame(AVCodecContext *avctx, #if CONFIG_ADPCM_G726_ENCODER AVCodec ff_adpcm_g726_encoder = { - "g726", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_ADPCM_G726, - sizeof(G726Context), - g726_init, - g726_encode_frame, - g726_close, - NULL, + .name = "g726", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_ADPCM_G726, + .priv_data_size = sizeof(G726Context), + .init = g726_init, + .encode = g726_encode_frame, + .close = g726_close, .capabilities = CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), @@ -407,13 +406,12 @@ AVCodec ff_adpcm_g726_encoder = { #endif AVCodec ff_adpcm_g726_decoder = { - "g726", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_ADPCM_G726, - sizeof(G726Context), - g726_init, - NULL, - g726_close, - g726_decode_frame, + .name = "g726", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_ADPCM_G726, + .priv_data_size = sizeof(G726Context), + .init = g726_init, + .close = g726_close, + .decode = g726_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), }; diff --git a/libavcodec/gif.c b/libavcodec/gif.c index a34d710a10..c7e7bcd185 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -167,13 +167,13 @@ static int gif_encode_close(AVCodecContext *avctx) } AVCodec ff_gif_encoder = { - "gif", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_GIF, - sizeof(GIFContext), - gif_encode_init, - gif_encode_frame, - gif_encode_close, + .name = "gif", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_GIF, + .priv_data_size = sizeof(GIFContext), + .init = gif_encode_init, + .encode = gif_encode_frame, + .close = gif_encode_close, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"), }; diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index 934c944a5b..bf40da183d 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -326,14 +326,13 @@ static av_cold int gif_decode_close(AVCodecContext *avctx) } AVCodec ff_gif_decoder = { - "gif", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_GIF, - sizeof(GifState), - gif_decode_init, - NULL, - gif_decode_close, - gif_decode_frame, - CODEC_CAP_DR1, + .name = "gif", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_GIF, + .priv_data_size = sizeof(GifState), + .init = gif_decode_init, + .close = gif_decode_close, + .decode = gif_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"), }; diff --git a/libavcodec/gsmdec.c b/libavcodec/gsmdec.c index 693febd673..7c247a6b65 100644 --- a/libavcodec/gsmdec.c +++ b/libavcodec/gsmdec.c @@ -85,25 +85,21 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data, } AVCodec ff_gsm_decoder = { - "gsm", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_GSM, - sizeof(GSMContext), - gsm_init, - NULL, - NULL, - gsm_decode_frame, + .name = "gsm", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_GSM, + .priv_data_size = sizeof(GSMContext), + .init = gsm_init, + .decode = gsm_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("GSM"), }; AVCodec ff_gsm_ms_decoder = { - "gsm_ms", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_GSM_MS, - sizeof(GSMContext), - gsm_init, - NULL, - NULL, - gsm_decode_frame, + .name = "gsm_ms", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_GSM_MS, + .priv_data_size = sizeof(GSMContext), + .init = gsm_init, + .decode = gsm_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"), }; diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index e6f5cdb7cf..63a153f06d 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -640,15 +640,14 @@ static av_cold int h261_decode_end(AVCodecContext *avctx) } AVCodec ff_h261_decoder = { - "h261", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_H261, - sizeof(H261Context), - h261_decode_init, - NULL, - h261_decode_end, - h261_decode_frame, - CODEC_CAP_DR1, + .name = "h261", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_H261, + .priv_data_size = sizeof(H261Context), + .init = h261_decode_init, + .close = h261_decode_end, + .decode = h261_decode_frame, + .capabilities = CODEC_CAP_DR1, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("H.261"), }; diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 27746d5d8c..1c702de326 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -322,13 +322,13 @@ static void h261_encode_block(H261Context * h, DCTELEM * block, int n){ } AVCodec ff_h261_encoder = { - "h261", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_H261, - sizeof(H261Context), - MPV_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "h261", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_H261, + .priv_data_size = sizeof(H261Context), + .init = MPV_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("H.261"), }; diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index a19e55c6ac..7f3411b779 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -726,15 +726,14 @@ av_log(avctx, AV_LOG_DEBUG, "%"PRId64"\n", rdtsc()-time); } AVCodec ff_h263_decoder = { - "h263", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_H263, - sizeof(MpegEncContext), - ff_h263_decode_init, - NULL, - ff_h263_decode_end, - ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, + .name = "h263", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_H263, + .priv_data_size = sizeof(MpegEncContext), + .init = ff_h263_decode_init, + .close = ff_h263_decode_end, + .decode = ff_h263_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, .flush= ff_mpeg_flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 928a96ab35..e8513e8dfb 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3979,16 +3979,15 @@ static const AVProfile profiles[] = { }; AVCodec ff_h264_decoder = { - "h264", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_H264, - sizeof(H264Context), - ff_h264_decode_init, - NULL, - ff_h264_decode_end, - decode_frame, - /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY | - CODEC_CAP_SLICE_THREADS | CODEC_CAP_FRAME_THREADS, + .name = "h264", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_H264, + .priv_data_size = sizeof(H264Context), + .init = ff_h264_decode_init, + .close = ff_h264_decode_end, + .decode = decode_frame, + .capabilities = /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY | + CODEC_CAP_SLICE_THREADS | CODEC_CAP_FRAME_THREADS, .flush= flush_dpb, .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), @@ -3998,15 +3997,14 @@ AVCodec ff_h264_decoder = { #if CONFIG_H264_VDPAU_DECODER AVCodec ff_h264_vdpau_decoder = { - "h264_vdpau", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_H264, - sizeof(H264Context), - ff_h264_decode_init, - NULL, - ff_h264_decode_end, - decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, + .name = "h264_vdpau", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_H264, + .priv_data_size = sizeof(H264Context), + .init = ff_h264_decode_init, + .close = ff_h264_decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, .flush= flush_dpb, .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)"), .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_H264, PIX_FMT_NONE}, diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index a399142d59..865bc6ab5c 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -1435,16 +1435,14 @@ static av_cold int encode_end(AVCodecContext *avctx) #if CONFIG_HUFFYUV_DECODER AVCodec ff_huffyuv_decoder = { - "huffyuv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_HUFFYUV, - sizeof(HYuvContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, - NULL, + .name = "huffyuv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_HUFFYUV, + .priv_data_size = sizeof(HYuvContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), .long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"), }; @@ -1452,16 +1450,14 @@ AVCodec ff_huffyuv_decoder = { #if CONFIG_FFVHUFF_DECODER AVCodec ff_ffvhuff_decoder = { - "ffvhuff", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_FFVHUFF, - sizeof(HYuvContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, - NULL, + .name = "ffvhuff", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_FFVHUFF, + .priv_data_size = sizeof(HYuvContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), }; @@ -1469,13 +1465,13 @@ AVCodec ff_ffvhuff_decoder = { #if CONFIG_HUFFYUV_ENCODER AVCodec ff_huffyuv_encoder = { - "huffyuv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_HUFFYUV, - sizeof(HYuvContext), - encode_init, - encode_frame, - encode_end, + .name = "huffyuv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_HUFFYUV, + .priv_data_size = sizeof(HYuvContext), + .init = encode_init, + .encode = encode_frame, + .close = encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_RGB32, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"), }; @@ -1483,13 +1479,13 @@ AVCodec ff_huffyuv_encoder = { #if CONFIG_FFVHUFF_ENCODER AVCodec ff_ffvhuff_encoder = { - "ffvhuff", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_FFVHUFF, - sizeof(HYuvContext), - encode_init, - encode_frame, - encode_end, + .name = "ffvhuff", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_FFVHUFF, + .priv_data_size = sizeof(HYuvContext), + .init = encode_init, + .encode = encode_frame, + .close = encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_RGB32, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), }; diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c index ac56e19442..99c43a09a4 100644 --- a/libavcodec/idcinvideo.c +++ b/libavcodec/idcinvideo.c @@ -254,15 +254,14 @@ static av_cold int idcin_decode_end(AVCodecContext *avctx) } AVCodec ff_idcin_decoder = { - "idcinvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_IDCIN, - sizeof(IdcinContext), - idcin_decode_init, - NULL, - idcin_decode_end, - idcin_decode_frame, - CODEC_CAP_DR1, + .name = "idcinvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_IDCIN, + .priv_data_size = sizeof(IdcinContext), + .init = idcin_decode_init, + .close = idcin_decode_end, + .decode = idcin_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("id Quake II CIN video"), }; diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 63e1f31a4e..41e7b5939f 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -368,27 +368,25 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_iff_ilbm_decoder = { - "iff_ilbm", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_IFF_ILBM, - sizeof(IffContext), - decode_init, - NULL, - decode_end, - decode_frame_ilbm, - CODEC_CAP_DR1, + .name = "iff_ilbm", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_IFF_ILBM, + .priv_data_size = sizeof(IffContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame_ilbm, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("IFF ILBM"), }; AVCodec ff_iff_byterun1_decoder = { - "iff_byterun1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_IFF_BYTERUN1, - sizeof(IffContext), - decode_init, - NULL, - decode_end, - decode_frame_byterun1, - CODEC_CAP_DR1, + .name = "iff_byterun1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_IFF_BYTERUN1, + .priv_data_size = sizeof(IffContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame_byterun1, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("IFF ByteRun1"), }; diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 0e588c3966..d05998893b 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -225,14 +225,13 @@ static av_cold int ir2_decode_end(AVCodecContext *avctx){ } AVCodec ff_indeo2_decoder = { - "indeo2", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_INDEO2, - sizeof(Ir2Context), - ir2_decode_init, - NULL, - ir2_decode_end, - ir2_decode_frame, - CODEC_CAP_DR1, + .name = "indeo2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_INDEO2, + .priv_data_size = sizeof(Ir2Context), + .init = ir2_decode_init, + .close = ir2_decode_end, + .decode = ir2_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 2"), }; diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index 30b70850f8..d931f9fc45 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -1138,15 +1138,13 @@ static av_cold int indeo3_decode_end(AVCodecContext *avctx) } AVCodec ff_indeo3_decoder = { - "indeo3", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_INDEO3, - sizeof(Indeo3DecodeContext), - indeo3_decode_init, - NULL, - indeo3_decode_end, - indeo3_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "indeo3", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_INDEO3, + .priv_data_size = sizeof(Indeo3DecodeContext), + .init = indeo3_decode_init, + .close = indeo3_decode_end, + .decode = indeo3_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 3"), }; diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index 83049bcc6f..8347c79021 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -125,15 +125,14 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s) } AVCodec ff_h263i_decoder = { - "h263i", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_H263I, - sizeof(MpegEncContext), - ff_h263_decode_init, - NULL, - ff_h263_decode_end, - ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .name = "h263i", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_H263I, + .priv_data_size = sizeof(MpegEncContext), + .init = ff_h263_decode_init, + .close = ff_h263_decode_end, + .decode = ff_h263_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"), .pix_fmts= ff_pixfmt_list_420, }; diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index 3bbb464aff..d0e8f4cdc6 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -1089,14 +1089,13 @@ static av_cold int ipvideo_decode_end(AVCodecContext *avctx) } AVCodec ff_interplay_video_decoder = { - "interplayvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_INTERPLAY_VIDEO, - sizeof(IpvideoContext), - ipvideo_decode_init, - NULL, - ipvideo_decode_end, - ipvideo_decode_frame, - CODEC_CAP_DR1, + .name = "interplayvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_INTERPLAY_VIDEO, + .priv_data_size = sizeof(IpvideoContext), + .init = ipvideo_decode_init, + .close = ipvideo_decode_end, + .decode = ipvideo_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Interplay MVE video"), }; diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index 69cc1d3266..a4cfe4f9d6 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -364,14 +364,13 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor AVCodec ff_jpegls_decoder = { - "jpegls", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_JPEGLS, - sizeof(MJpegDecodeContext), - ff_mjpeg_decode_init, - NULL, - ff_mjpeg_decode_end, - ff_mjpeg_decode_frame, - CODEC_CAP_DR1, + .name = "jpegls", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_JPEGLS, + .priv_data_size = sizeof(MJpegDecodeContext), + .init = ff_mjpeg_decode_init, + .close = ff_mjpeg_decode_end, + .decode = ff_mjpeg_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"), }; diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 88c54bf817..2d6fa73fc2 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -165,13 +165,12 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_kgv1_decoder = { - "kgv1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_KGV1, - sizeof(KgvContext), - decode_init, - NULL, - decode_end, - decode_frame, + .name = "kgv1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_KGV1, + .priv_data_size = sizeof(KgvContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"), }; diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index 718cdfd932..07ca19479b 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -398,14 +398,13 @@ static av_cold int decode_end(AVCodecContext * avctx) } AVCodec ff_kmvc_decoder = { - "kmvc", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_KMVC, - sizeof(KmvcContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "kmvc", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_KMVC, + .priv_data_size = sizeof(KmvcContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Karl Morton's video codec"), }; diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c index 1c18b967e4..10cc71e0d8 100644 --- a/libavcodec/lagarith.c +++ b/libavcodec/lagarith.c @@ -509,14 +509,13 @@ static av_cold int lag_decode_end(AVCodecContext *avctx) } AVCodec ff_lagarith_decoder = { - "lagarith", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_LAGARITH, - sizeof(LagarithContext), - lag_decode_init, - NULL, - lag_decode_end, - lag_decode_frame, - CODEC_CAP_DR1, + .name = "lagarith", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_LAGARITH, + .priv_data_size = sizeof(LagarithContext), + .init = lag_decode_init, + .close = lag_decode_end, + .decode = lag_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Lagarith lossless"), }; diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index f41a88934b..b66a3ce65b 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -610,30 +610,28 @@ static av_cold int decode_end(AVCodecContext *avctx) #if CONFIG_MSZH_DECODER AVCodec ff_mszh_decoder = { - "mszh", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MSZH, - sizeof(LclDecContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "mszh", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MSZH, + .priv_data_size = sizeof(LclDecContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) MSZH"), }; #endif #if CONFIG_ZLIB_DECODER AVCodec ff_zlib_decoder = { - "zlib", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ZLIB, - sizeof(LclDecContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "zlib", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ZLIB, + .priv_data_size = sizeof(LclDecContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"), }; #endif diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c index 3285d1afba..4c902d5f17 100644 --- a/libavcodec/lclenc.c +++ b/libavcodec/lclenc.c @@ -171,13 +171,13 @@ static av_cold int encode_end(AVCodecContext *avctx) } AVCodec ff_zlib_encoder = { - "zlib", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ZLIB, - sizeof(LclEncContext), - encode_init, - encode_frame, - encode_end, + .name = "zlib", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ZLIB, + .priv_data_size = sizeof(LclEncContext), + .init = encode_init, + .encode = encode_frame, + .close = encode_end, .pix_fmts = (const enum PixelFormat[]) { PIX_FMT_BGR24, PIX_FMT_NONE }, .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"), }; diff --git a/libavcodec/libdiracdec.c b/libavcodec/libdiracdec.c index 08fec3dfec..5b3ad23c63 100644 --- a/libavcodec/libdiracdec.c +++ b/libavcodec/libdiracdec.c @@ -195,15 +195,14 @@ static void libdirac_flush(AVCodecContext *avccontext) AVCodec ff_libdirac_decoder = { - "libdirac", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DIRAC, - sizeof(FfmpegDiracDecoderParams), - libdirac_decode_init, - NULL, - libdirac_decode_close, - libdirac_decode_frame, - CODEC_CAP_DELAY, + .name = "libdirac", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DIRAC, + .priv_data_size = sizeof(FfmpegDiracDecoderParams), + .init = libdirac_decode_init, + .close = libdirac_decode_close, + .decode = libdirac_decode_frame, + .capabilities = CODEC_CAP_DELAY, .flush = libdirac_flush, .long_name = NULL_IF_CONFIG_SMALL("libdirac Dirac 2.2"), }; diff --git a/libavcodec/libdiracenc.c b/libavcodec/libdiracenc.c index ff4b92f3c0..9d02db9e4b 100644 --- a/libavcodec/libdiracenc.c +++ b/libavcodec/libdiracenc.c @@ -392,13 +392,13 @@ static av_cold int libdirac_encode_close(AVCodecContext *avccontext) AVCodec ff_libdirac_encoder = { - "libdirac", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DIRAC, - sizeof(FfmpegDiracEncoderParams), - libdirac_encode_init, - libdirac_encode_frame, - libdirac_encode_close, + .name = "libdirac", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DIRAC, + .priv_data_size = sizeof(FfmpegDiracEncoderParams), + .init = libdirac_encode_init, + .encode = libdirac_encode_frame, + .close = libdirac_encode_close, .capabilities = CODEC_CAP_DELAY, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libdirac Dirac 2.2"), diff --git a/libavcodec/libfaac.c b/libavcodec/libfaac.c index 51d965e87a..7ee1f3c3fa 100644 --- a/libavcodec/libfaac.c +++ b/libavcodec/libfaac.c @@ -155,13 +155,13 @@ static const AVProfile profiles[] = { }; AVCodec ff_libfaac_encoder = { - "libfaac", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AAC, - sizeof(FaacAudioContext), - Faac_encode_init, - Faac_encode_frame, - Faac_encode_close, + .name = "libfaac", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_AAC, + .priv_data_size = sizeof(FaacAudioContext), + .init = Faac_encode_init, + .encode = Faac_encode_frame, + .close = Faac_encode_close, .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libfaac AAC (Advanced Audio Codec)"), diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c index 0573cb33d6..8115d28d77 100644 --- a/libavcodec/libgsm.c +++ b/libavcodec/libgsm.c @@ -113,25 +113,23 @@ static int libgsm_encode_frame(AVCodecContext *avctx, AVCodec ff_libgsm_encoder = { - "libgsm", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_GSM, - 0, - libgsm_init, - libgsm_encode_frame, - libgsm_close, + .name = "libgsm", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_GSM, + .init = libgsm_init, + .encode = libgsm_encode_frame, + .close = libgsm_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"), }; AVCodec ff_libgsm_ms_encoder = { - "libgsm_ms", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_GSM_MS, - 0, - libgsm_init, - libgsm_encode_frame, - libgsm_close, + .name = "libgsm_ms", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_GSM_MS, + .init = libgsm_init, + .encode = libgsm_encode_frame, + .close = libgsm_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"), }; @@ -157,25 +155,21 @@ static int libgsm_decode_frame(AVCodecContext *avctx, } AVCodec ff_libgsm_decoder = { - "libgsm", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_GSM, - 0, - libgsm_init, - NULL, - libgsm_close, - libgsm_decode_frame, + .name = "libgsm", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_GSM, + .init = libgsm_init, + .close = libgsm_close, + .decode = libgsm_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"), }; AVCodec ff_libgsm_ms_decoder = { - "libgsm_ms", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_GSM_MS, - 0, - libgsm_init, - NULL, - libgsm_close, - libgsm_decode_frame, + .name = "libgsm_ms", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_GSM_MS, + .init = libgsm_init, + .close = libgsm_close, + .decode = libgsm_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"), }; diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 68f1bc9e2b..2eeb97d827 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -215,13 +215,13 @@ static av_cold int MP3lame_encode_close(AVCodecContext *avctx) AVCodec ff_libmp3lame_encoder = { - "libmp3lame", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP3, - sizeof(Mp3AudioContext), - MP3lame_encode_init, - MP3lame_encode_frame, - MP3lame_encode_close, + .name = "libmp3lame", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP3, + .priv_data_size = sizeof(Mp3AudioContext), + .init = MP3lame_encode_init, + .encode = MP3lame_encode_frame, + .close = MP3lame_encode_close, .capabilities= CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .supported_samplerates= sSampleRates, diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index edf372ffad..f629c95fd7 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -158,14 +158,13 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data, } AVCodec ff_libopencore_amrnb_decoder = { - "libopencore_amrnb", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AMR_NB, - sizeof(AMRContext), - amr_nb_decode_init, - NULL, - amr_nb_decode_close, - amr_nb_decode_frame, + .name = "libopencore_amrnb", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_AMR_NB, + .priv_data_size = sizeof(AMRContext), + .init = amr_nb_decode_init, + .close = amr_nb_decode_close, + .decode = amr_nb_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"), }; @@ -230,14 +229,13 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, } AVCodec ff_libopencore_amrnb_encoder = { - "libopencore_amrnb", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AMR_NB, - sizeof(AMRContext), - amr_nb_encode_init, - amr_nb_encode_frame, - amr_nb_encode_close, - NULL, + .name = "libopencore_amrnb", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_AMR_NB, + .priv_data_size = sizeof(AMRContext), + .init = amr_nb_encode_init, + .encode = amr_nb_encode_frame, + .close = amr_nb_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"), .priv_class = &class, @@ -308,14 +306,13 @@ static int amr_wb_decode_close(AVCodecContext *avctx) } AVCodec ff_libopencore_amrwb_decoder = { - "libopencore_amrwb", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AMR_WB, - sizeof(AMRWBContext), - amr_wb_decode_init, - NULL, - amr_wb_decode_close, - amr_wb_decode_frame, + .name = "libopencore_amrwb", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_AMR_WB, + .priv_data_size = sizeof(AMRWBContext), + .init = amr_wb_decode_init, + .close = amr_wb_decode_close, + .decode = amr_wb_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Wide-Band"), }; diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index 7e6846d5d1..a9c1ca40f5 100644 --- a/libavcodec/libschroedingerdec.c +++ b/libavcodec/libschroedingerdec.c @@ -345,15 +345,14 @@ static void libschroedinger_flush(AVCodecContext *avccontext) } AVCodec ff_libschroedinger_decoder = { - "libschroedinger", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DIRAC, - sizeof(FfmpegSchroDecoderParams), - libschroedinger_decode_init, - NULL, - libschroedinger_decode_close, - libschroedinger_decode_frame, - CODEC_CAP_DELAY, + .name = "libschroedinger", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DIRAC, + .priv_data_size = sizeof(FfmpegSchroDecoderParams), + .init = libschroedinger_decode_init, + .close = libschroedinger_decode_close, + .decode = libschroedinger_decode_frame, + .capabilities = CODEC_CAP_DELAY, .flush = libschroedinger_flush, .long_name = NULL_IF_CONFIG_SMALL("libschroedinger Dirac 2.2"), }; diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c index d7190d06a4..43494a17cb 100644 --- a/libavcodec/libschroedingerenc.c +++ b/libavcodec/libschroedingerenc.c @@ -423,13 +423,13 @@ static int libschroedinger_encode_close(AVCodecContext *avccontext) AVCodec ff_libschroedinger_encoder = { - "libschroedinger", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_DIRAC, - sizeof(FfmpegSchroEncoderParams), - libschroedinger_encode_init, - libschroedinger_encode_frame, - libschroedinger_encode_close, + .name = "libschroedinger", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DIRAC, + .priv_data_size = sizeof(FfmpegSchroEncoderParams), + .init = libschroedinger_encode_init, + .encode = libschroedinger_encode_frame, + .close = libschroedinger_encode_close, .capabilities = CODEC_CAP_DELAY, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libschroedinger Dirac 2.2"), diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c index 1cee71e152..cda987ca6a 100644 --- a/libavcodec/libspeexdec.c +++ b/libavcodec/libspeexdec.c @@ -139,13 +139,12 @@ static av_cold int libspeex_decode_close(AVCodecContext *avctx) } AVCodec ff_libspeex_decoder = { - "libspeex", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_SPEEX, - sizeof(LibSpeexContext), - libspeex_decode_init, - NULL, - libspeex_decode_close, - libspeex_decode_frame, + .name = "libspeex", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_SPEEX, + .priv_data_size = sizeof(LibSpeexContext), + .init = libspeex_decode_init, + .close = libspeex_decode_close, + .decode = libspeex_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"), }; diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c index 5a75bcbbb4..18aa8240d8 100644 --- a/libavcodec/libvo-aacenc.c +++ b/libavcodec/libvo-aacenc.c @@ -116,14 +116,13 @@ static int aac_encode_frame(AVCodecContext *avctx, } AVCodec ff_libvo_aacenc_encoder = { - "libvo_aacenc", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AAC, - sizeof(AACContext), - aac_encode_init, - aac_encode_frame, - aac_encode_close, - NULL, + .name = "libvo_aacenc", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_AAC, + .priv_data_size = sizeof(AACContext), + .init = aac_encode_init, + .encode = aac_encode_frame, + .close = aac_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Android VisualOn AAC"), }; diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index 201a74ed26..0d6dbd421a 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -118,14 +118,13 @@ static int amr_wb_encode_frame(AVCodecContext *avctx, } AVCodec ff_libvo_amrwbenc_encoder = { - "libvo_amrwbenc", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AMR_WB, - sizeof(AMRWBContext), - amr_wb_encode_init, - amr_wb_encode_frame, - amr_wb_encode_close, - NULL, + .name = "libvo_amrwbenc", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_AMR_WB, + .priv_data_size = sizeof(AMRWBContext), + .init = amr_wb_encode_init, + .encode = amr_wb_encode_frame, + .close = amr_wb_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Android VisualOn Adaptive Multi-Rate " "(AMR) Wide-Band"), diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index 2aa077c07a..5acd0f9eb0 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -112,14 +112,12 @@ static av_cold int vp8_free(AVCodecContext *avctx) } AVCodec ff_libvpx_decoder = { - "libvpx", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VP8, - sizeof(VP8Context), - vp8_init, - NULL, /* encode */ - vp8_free, - vp8_decode, - 0, /* capabilities */ + .name = "libvpx", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VP8, + .priv_data_size = sizeof(VP8Context), + .init = vp8_init, + .close = vp8_free, + .decode = vp8_decode, .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), }; diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index ca2e6157d5..8da5974867 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -497,15 +497,14 @@ static int vp8_encode(AVCodecContext *avctx, uint8_t *buf, int buf_size, } AVCodec ff_libvpx_encoder = { - "libvpx", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VP8, - sizeof(VP8Context), - vp8_init, - vp8_encode, - vp8_free, - NULL, - CODEC_CAP_DELAY, + .name = "libvpx", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VP8, + .priv_data_size = sizeof(VP8Context), + .init = vp8_init, + .encode = vp8_encode, + .close = vp8_free, + .capabilities = CODEC_CAP_DELAY, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), }; diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c index 3ca4d1b2ec..526969066d 100644 --- a/libavcodec/libxvidff.c +++ b/libavcodec/libxvidff.c @@ -809,13 +809,13 @@ int xvid_ff_2pass(void *ref, int cmd, void *p1, void *p2) { * Xvid codec definition for libavcodec. */ AVCodec ff_libxvid_encoder = { - "libxvid", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG4, - sizeof(struct xvid_context), - xvid_encode_init, - xvid_encode_frame, - xvid_encode_close, + .name = "libxvid", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG4, + .priv_data_size = sizeof(struct xvid_context), + .init = xvid_encode_init, + .encode = xvid_encode_frame, + .close = xvid_encode_close, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"), }; diff --git a/libavcodec/loco.c b/libavcodec/loco.c index 32b1bfc9b1..919a06b123 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -286,14 +286,13 @@ static av_cold int decode_end(AVCodecContext *avctx){ } AVCodec ff_loco_decoder = { - "loco", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_LOCO, - sizeof(LOCOContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "loco", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_LOCO, + .priv_data_size = sizeof(LOCOContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("LOCO"), }; diff --git a/libavcodec/mace.c b/libavcodec/mace.c index 53ec0560dd..bf7c3319eb 100644 --- a/libavcodec/mace.c +++ b/libavcodec/mace.c @@ -280,26 +280,22 @@ static int mace_decode_frame(AVCodecContext *avctx, } AVCodec ff_mace3_decoder = { - "mace3", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MACE3, - sizeof(MACEContext), - mace_decode_init, - NULL, - NULL, - mace_decode_frame, + .name = "mace3", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MACE3, + .priv_data_size = sizeof(MACEContext), + .init = mace_decode_init, + .decode = mace_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"), }; AVCodec ff_mace6_decoder = { - "mace6", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MACE6, - sizeof(MACEContext), - mace_decode_init, - NULL, - NULL, - mace_decode_frame, + .name = "mace6", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MACE6, + .priv_data_size = sizeof(MACEContext), + .init = mace_decode_init, + .decode = mace_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"), }; diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index 02b69d045a..3741549b22 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -265,15 +265,14 @@ static av_cold int decode_end(AVCodecContext *avctx){ } AVCodec ff_mdec_decoder = { - "mdec", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MDEC, - sizeof(MDECContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .name = "mdec", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MDEC, + .priv_data_size = sizeof(MDECContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, .long_name= NULL_IF_CONFIG_SMALL("Sony PlayStation MDEC (Motion DECoder)"), .init_thread_copy= ONLY_IF_THREADS_ENABLED(decode_init_thread_copy) }; diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 46497ec76c..c0d8546eb8 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -416,15 +416,14 @@ static av_cold int mimic_decode_end(AVCodecContext *avctx) } AVCodec ff_mimic_decoder = { - "mimic", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MIMIC, - sizeof(MimicContext), - mimic_decode_init, - NULL, - mimic_decode_end, - mimic_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .name = "mimic", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MIMIC, + .priv_data_size = sizeof(MimicContext), + .init = mimic_decode_init, + .close = mimic_decode_end, + .decode = mimic_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, .long_name = NULL_IF_CONFIG_SMALL("Mimic"), .update_thread_context = ONLY_IF_THREADS_ENABLED(mimic_decode_update_thread_context) }; diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c index 837304ea74..be5d853624 100644 --- a/libavcodec/mjpegbdec.c +++ b/libavcodec/mjpegbdec.c @@ -146,16 +146,14 @@ read_header: } AVCodec ff_mjpegb_decoder = { - "mjpegb", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MJPEGB, - sizeof(MJpegDecodeContext), - ff_mjpeg_decode_init, - NULL, - ff_mjpeg_decode_end, - mjpegb_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "mjpegb", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MJPEGB, + .priv_data_size = sizeof(MJpegDecodeContext), + .init = ff_mjpeg_decode_init, + .close = ff_mjpeg_decode_end, + .decode = mjpegb_decode_frame, + .capabilities = CODEC_CAP_DR1, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("Apple MJPEG-B"), }; diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 7eea6d78aa..c4cfd1af18 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1596,31 +1596,27 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx) } AVCodec ff_mjpeg_decoder = { - "mjpeg", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MJPEG, - sizeof(MJpegDecodeContext), - ff_mjpeg_decode_init, - NULL, - ff_mjpeg_decode_end, - ff_mjpeg_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "mjpeg", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MJPEG, + .priv_data_size = sizeof(MJpegDecodeContext), + .init = ff_mjpeg_decode_init, + .close = ff_mjpeg_decode_end, + .decode = ff_mjpeg_decode_frame, + .capabilities = CODEC_CAP_DR1, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"), }; AVCodec ff_thp_decoder = { - "thp", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_THP, - sizeof(MJpegDecodeContext), - ff_mjpeg_decode_init, - NULL, - ff_mjpeg_decode_end, - ff_mjpeg_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "thp", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_THP, + .priv_data_size = sizeof(MJpegDecodeContext), + .init = ff_mjpeg_decode_init, + .close = ff_mjpeg_decode_end, + .decode = ff_mjpeg_decode_frame, + .capabilities = CODEC_CAP_DR1, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"), }; diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 169d19e17a..d1005c8ab1 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -446,13 +446,13 @@ void ff_mjpeg_encode_mb(MpegEncContext *s, DCTELEM block[6][64]) } AVCodec ff_mjpeg_encoder = { - "mjpeg", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MJPEG, - sizeof(MpegEncContext), - MPV_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "mjpeg", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MJPEG, + .priv_data_size = sizeof(MpegEncContext), + .init = MPV_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"), }; diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 5e50eba75e..c90285af8e 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -1138,27 +1138,23 @@ error: } AVCodec ff_mlp_decoder = { - "mlp", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MLP, - sizeof(MLPDecodeContext), - mlp_decode_init, - NULL, - NULL, - read_access_unit, + .name = "mlp", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MLP, + .priv_data_size = sizeof(MLPDecodeContext), + .init = mlp_decode_init, + .decode = read_access_unit, .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"), }; #if CONFIG_TRUEHD_DECODER AVCodec ff_truehd_decoder = { - "truehd", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_TRUEHD, - sizeof(MLPDecodeContext), - mlp_decode_init, - NULL, - NULL, - read_access_unit, + .name = "truehd", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_TRUEHD, + .priv_data_size = sizeof(MLPDecodeContext), + .init = mlp_decode_init, + .decode = read_access_unit, .long_name = NULL_IF_CONFIG_SMALL("TrueHD"), }; #endif /* CONFIG_TRUEHD_DECODER */ diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c index b65335e6cb..9e82ef94f9 100644 --- a/libavcodec/mmvideo.c +++ b/libavcodec/mmvideo.c @@ -214,14 +214,13 @@ static av_cold int mm_decode_end(AVCodecContext *avctx) } AVCodec ff_mmvideo_decoder = { - "mmvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MMVIDEO, - sizeof(MmContext), - mm_decode_init, - NULL, - mm_decode_end, - mm_decode_frame, - CODEC_CAP_DR1, + .name = "mmvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MMVIDEO, + .priv_data_size = sizeof(MmContext), + .init = mm_decode_init, + .close = mm_decode_end, + .decode = mm_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("American Laser Games MM Video"), }; diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index ebc4b31201..21e1bda99c 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -303,14 +303,13 @@ static av_cold int mp_decode_end(AVCodecContext *avctx) } AVCodec ff_motionpixels_decoder = { - "motionpixels", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MOTIONPIXELS, - sizeof(MotionPixelsContext), - mp_decode_init, - NULL, - mp_decode_end, - mp_decode_frame, - CODEC_CAP_DR1, + .name = "motionpixels", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MOTIONPIXELS, + .priv_data_size = sizeof(MotionPixelsContext), + .init = mp_decode_init, + .close = mp_decode_end, + .decode = mp_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Motion Pixels video"), }; diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index dbfa3c8636..a98cb0e053 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -291,14 +291,12 @@ static void mpc7_decode_flush(AVCodecContext *avctx) } AVCodec ff_mpc7_decoder = { - "mpc7", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MUSEPACK7, - sizeof(MPCContext), - mpc7_decode_init, - NULL, - NULL, - mpc7_decode_frame, + .name = "mpc7", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MUSEPACK7, + .priv_data_size = sizeof(MPCContext), + .init = mpc7_decode_init, + .decode = mpc7_decode_frame, .flush = mpc7_decode_flush, .long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"), }; diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 3177faf1c4..0e3947b031 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -406,13 +406,11 @@ static int mpc8_decode_frame(AVCodecContext * avctx, } AVCodec ff_mpc8_decoder = { - "mpc8", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MUSEPACK8, - sizeof(MPCContext), - mpc8_decode_init, - NULL, - NULL, - mpc8_decode_frame, + .name = "mpc8", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MUSEPACK8, + .priv_data_size = sizeof(MPCContext), + .init = mpc8_decode_init, + .decode = mpc8_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"), }; diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 059083277a..cb3b815a1b 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -2531,15 +2531,14 @@ static const AVProfile mpeg2_video_profiles[] = { AVCodec ff_mpeg1video_decoder = { - "mpeg1video", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG1VIDEO, - sizeof(Mpeg1Context), - mpeg_decode_init, - NULL, - mpeg_decode_end, - mpeg_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, + .name = "mpeg1video", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG1VIDEO, + .priv_data_size = sizeof(Mpeg1Context), + .init = mpeg_decode_init, + .close = mpeg_decode_end, + .decode = mpeg_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .flush= flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), @@ -2547,15 +2546,14 @@ AVCodec ff_mpeg1video_decoder = { }; AVCodec ff_mpeg2video_decoder = { - "mpeg2video", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG2VIDEO, - sizeof(Mpeg1Context), - mpeg_decode_init, - NULL, - mpeg_decode_end, - mpeg_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, + .name = "mpeg2video", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG2VIDEO, + .priv_data_size = sizeof(Mpeg1Context), + .init = mpeg_decode_init, + .close = mpeg_decode_end, + .decode = mpeg_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .flush= flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"), @@ -2564,15 +2562,14 @@ AVCodec ff_mpeg2video_decoder = { //legacy decoder AVCodec ff_mpegvideo_decoder = { - "mpegvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG2VIDEO, - sizeof(Mpeg1Context), - mpeg_decode_init, - NULL, - mpeg_decode_end, - mpeg_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, + .name = "mpegvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG2VIDEO, + .priv_data_size = sizeof(Mpeg1Context), + .init = mpeg_decode_init, + .close = mpeg_decode_end, + .decode = mpeg_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .flush= flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), @@ -2596,15 +2593,14 @@ static av_cold int mpeg_mc_decode_init(AVCodecContext *avctx){ } AVCodec ff_mpeg_xvmc_decoder = { - "mpegvideo_xvmc", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG2VIDEO_XVMC, - sizeof(Mpeg1Context), - mpeg_mc_decode_init, - NULL, - mpeg_decode_end, - mpeg_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED| CODEC_CAP_HWACCEL | CODEC_CAP_DELAY, + .name = "mpegvideo_xvmc", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG2VIDEO_XVMC, + .priv_data_size = sizeof(Mpeg1Context), + .init = mpeg_mc_decode_init, + .close = mpeg_decode_end, + .decode = mpeg_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED| CODEC_CAP_HWACCEL | CODEC_CAP_DELAY, .flush= flush, .long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video XvMC (X-Video Motion Compensation)"), }; @@ -2613,15 +2609,14 @@ AVCodec ff_mpeg_xvmc_decoder = { #if CONFIG_MPEG_VDPAU_DECODER AVCodec ff_mpeg_vdpau_decoder = { - "mpegvideo_vdpau", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG2VIDEO, - sizeof(Mpeg1Context), - mpeg_decode_init, - NULL, - mpeg_decode_end, - mpeg_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY, + .name = "mpegvideo_vdpau", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG2VIDEO, + .priv_data_size = sizeof(Mpeg1Context), + .init = mpeg_decode_init, + .close = mpeg_decode_end, + .decode = mpeg_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY, .flush= flush, .long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video (VDPAU acceleration)"), }; @@ -2629,15 +2624,14 @@ AVCodec ff_mpeg_vdpau_decoder = { #if CONFIG_MPEG1_VDPAU_DECODER AVCodec ff_mpeg1_vdpau_decoder = { - "mpeg1video_vdpau", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG1VIDEO, - sizeof(Mpeg1Context), - mpeg_decode_init, - NULL, - mpeg_decode_end, - mpeg_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY, + .name = "mpeg1video_vdpau", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG1VIDEO, + .priv_data_size = sizeof(Mpeg1Context), + .init = mpeg_decode_init, + .close = mpeg_decode_end, + .decode = mpeg_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY, .flush= flush, .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video (VDPAU acceleration)"), }; diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 31ac515efe..6602d81f6c 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -926,13 +926,13 @@ static void mpeg1_encode_block(MpegEncContext *s, } AVCodec ff_mpeg1video_encoder = { - "mpeg1video", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG1VIDEO, - sizeof(MpegEncContext), - encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "mpeg1video", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG1VIDEO, + .priv_data_size = sizeof(MpegEncContext), + .init = encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .supported_framerates= ff_frame_rate_tab+1, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, @@ -940,13 +940,13 @@ AVCodec ff_mpeg1video_encoder = { }; AVCodec ff_mpeg2video_encoder = { - "mpeg2video", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG2VIDEO, - sizeof(MpegEncContext), - encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "mpeg2video", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG2VIDEO, + .priv_data_size = sizeof(MpegEncContext), + .init = encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .supported_framerates= ff_frame_rate_tab+1, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE}, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index b1abb618ef..57d55a1424 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -2276,15 +2276,14 @@ static const AVProfile mpeg4_video_profiles[] = { }; AVCodec ff_mpeg4_decoder = { - "mpeg4", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG4, - sizeof(MpegEncContext), - decode_init, - NULL, - ff_h263_decode_end, - ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_FRAME_THREADS, + .name = "mpeg4", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG4, + .priv_data_size = sizeof(MpegEncContext), + .init = decode_init, + .close = ff_h263_decode_end, + .decode = ff_h263_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_FRAME_THREADS, .flush= ff_mpeg_flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), @@ -2296,15 +2295,14 @@ AVCodec ff_mpeg4_decoder = { #if CONFIG_MPEG4_VDPAU_DECODER AVCodec ff_mpeg4_vdpau_decoder = { - "mpeg4_vdpau", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG4, - sizeof(MpegEncContext), - decode_init, - NULL, - ff_h263_decode_end, - ff_h263_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, + .name = "mpeg4_vdpau", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG4, + .priv_data_size = sizeof(MpegEncContext), + .init = decode_init, + .close = ff_h263_decode_end, + .decode = ff_h263_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 (VDPAU)"), .pix_fmts= (const enum PixelFormat[]){PIX_FMT_VDPAU_MPEG4, PIX_FMT_NONE}, }; diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 741c5971fb..900903779c 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1275,13 +1275,13 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext *s) } AVCodec ff_mpeg4_encoder = { - "mpeg4", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MPEG4, - sizeof(MpegEncContext), - encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "mpeg4", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MPEG4, + .priv_data_size = sizeof(MpegEncContext), + .init = encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c index 35a52ad571..96c0fec445 100644 --- a/libavcodec/mpegaudioenc.c +++ b/libavcodec/mpegaudioenc.c @@ -760,14 +760,13 @@ static av_cold int MPA_encode_close(AVCodecContext *avctx) } AVCodec ff_mp2_encoder = { - "mp2", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP2, - sizeof(MpegAudioContext), - MPA_encode_init, - MPA_encode_frame, - MPA_encode_close, - NULL, + .name = "mp2", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP2, + .priv_data_size = sizeof(MpegAudioContext), + .init = MPA_encode_init, + .encode = MPA_encode_frame, + .close = MPA_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .supported_samplerates= (const int[]){44100, 48000, 32000, 22050, 24000, 16000, 0}, .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index c4ca7b30a9..6ca48d8fb3 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -3770,62 +3770,62 @@ int dct_quantize_c(MpegEncContext *s, } AVCodec ff_h263_encoder = { - "h263", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_H263, - sizeof(MpegEncContext), - MPV_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "h263", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_H263, + .priv_data_size = sizeof(MpegEncContext), + .init = MPV_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"), }; AVCodec ff_h263p_encoder = { - "h263p", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_H263P, - sizeof(MpegEncContext), - MPV_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "h263p", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_H263P, + .priv_data_size = sizeof(MpegEncContext), + .init = MPV_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"), }; AVCodec ff_msmpeg4v2_encoder = { - "msmpeg4v2", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MSMPEG4V2, - sizeof(MpegEncContext), - MPV_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "msmpeg4v2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MSMPEG4V2, + .priv_data_size = sizeof(MpegEncContext), + .init = MPV_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"), }; AVCodec ff_msmpeg4v3_encoder = { - "msmpeg4", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MSMPEG4V3, - sizeof(MpegEncContext), - MPV_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "msmpeg4", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MSMPEG4V3, + .priv_data_size = sizeof(MpegEncContext), + .init = MPV_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"), }; AVCodec ff_wmv1_encoder = { - "wmv1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_WMV1, - sizeof(MpegEncContext), - MPV_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "wmv1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_WMV1, + .priv_data_size = sizeof(MpegEncContext), + .init = MPV_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("Windows Media Video 7"), }; diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index ee34a8917c..d773c3838b 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -1884,60 +1884,56 @@ int ff_msmpeg4_decode_motion(MpegEncContext * s, } AVCodec ff_msmpeg4v1_decoder = { - "msmpeg4v1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MSMPEG4V1, - sizeof(MpegEncContext), - ff_msmpeg4_decode_init, - NULL, - ff_h263_decode_end, - ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .name = "msmpeg4v1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MSMPEG4V1, + .priv_data_size = sizeof(MpegEncContext), + .init = ff_msmpeg4_decode_init, + .close = ff_h263_decode_end, + .decode = ff_h263_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"), .pix_fmts= ff_pixfmt_list_420, }; AVCodec ff_msmpeg4v2_decoder = { - "msmpeg4v2", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MSMPEG4V2, - sizeof(MpegEncContext), - ff_msmpeg4_decode_init, - NULL, - ff_h263_decode_end, - ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .name = "msmpeg4v2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MSMPEG4V2, + .priv_data_size = sizeof(MpegEncContext), + .init = ff_msmpeg4_decode_init, + .close = ff_h263_decode_end, + .decode = ff_h263_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"), .pix_fmts= ff_pixfmt_list_420, }; AVCodec ff_msmpeg4v3_decoder = { - "msmpeg4", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MSMPEG4V3, - sizeof(MpegEncContext), - ff_msmpeg4_decode_init, - NULL, - ff_h263_decode_end, - ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .name = "msmpeg4", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MSMPEG4V3, + .priv_data_size = sizeof(MpegEncContext), + .init = ff_msmpeg4_decode_init, + .close = ff_h263_decode_end, + .decode = ff_h263_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"), .pix_fmts= ff_pixfmt_list_420, }; AVCodec ff_wmv1_decoder = { - "wmv1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_WMV1, - sizeof(MpegEncContext), - ff_msmpeg4_decode_init, - NULL, - ff_h263_decode_end, - ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .name = "wmv1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_WMV1, + .priv_data_size = sizeof(MpegEncContext), + .init = ff_msmpeg4_decode_init, + .close = ff_h263_decode_end, + .decode = ff_h263_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("Windows Media Video 7"), .pix_fmts= ff_pixfmt_list_420, diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c index f426b058bd..11ac7be2ff 100644 --- a/libavcodec/msrle.c +++ b/libavcodec/msrle.c @@ -145,14 +145,13 @@ static av_cold int msrle_decode_end(AVCodecContext *avctx) } AVCodec ff_msrle_decoder = { - "msrle", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MSRLE, - sizeof(MsrleContext), - msrle_decode_init, - NULL, - msrle_decode_end, - msrle_decode_frame, - CODEC_CAP_DR1, + .name = "msrle", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MSRLE, + .priv_data_size = sizeof(MsrleContext), + .init = msrle_decode_init, + .close = msrle_decode_end, + .decode = msrle_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name= NULL_IF_CONFIG_SMALL("Microsoft RLE"), }; diff --git a/libavcodec/msvideo1.c b/libavcodec/msvideo1.c index a89ec6ac65..a5fef4ddf7 100644 --- a/libavcodec/msvideo1.c +++ b/libavcodec/msvideo1.c @@ -334,14 +334,13 @@ static av_cold int msvideo1_decode_end(AVCodecContext *avctx) } AVCodec ff_msvideo1_decoder = { - "msvideo1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_MSVIDEO1, - sizeof(Msvideo1Context), - msvideo1_decode_init, - NULL, - msvideo1_decode_end, - msvideo1_decode_frame, - CODEC_CAP_DR1, + .name = "msvideo1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_MSVIDEO1, + .priv_data_size = sizeof(Msvideo1Context), + .init = msvideo1_decode_init, + .close = msvideo1_decode_end, + .decode = msvideo1_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name= NULL_IF_CONFIG_SMALL("Microsoft Video 1"), }; diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c index 59c1b3bdd8..a153dc0603 100644 --- a/libavcodec/nellymoserdec.c +++ b/libavcodec/nellymoserdec.c @@ -194,14 +194,13 @@ static av_cold int decode_end(AVCodecContext * avctx) { } AVCodec ff_nellymoser_decoder = { - "nellymoser", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_NELLYMOSER, - sizeof(NellyMoserDecodeContext), - decode_init, - NULL, - decode_end, - decode_tag, + .name = "nellymoser", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_NELLYMOSER, + .priv_data_size = sizeof(NellyMoserDecodeContext), + .init = decode_init, + .close = decode_end, + .decode = decode_tag, .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"), }; diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 3bc6328a04..73aec433f3 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -273,15 +273,14 @@ static av_cold int decode_end(AVCodecContext *avctx) { } AVCodec ff_nuv_decoder = { - "nuv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_NUV, - sizeof(NuvContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "nuv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_NUV, + .priv_data_size = sizeof(NuvContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("NuppelVideo/RTJPEG"), }; diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c index fbf9fd88aa..10960d5e9c 100644 --- a/libavcodec/pamenc.c +++ b/libavcodec/pamenc.c @@ -109,12 +109,12 @@ static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, AVCodec ff_pam_encoder = { - "pam", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PAM, - sizeof(PNMContext), - ff_pnm_init, - pam_encode_frame, + .name = "pam", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PAM, + .priv_data_size = sizeof(PNMContext), + .init = ff_pnm_init, + .encode = pam_encode_frame, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), }; diff --git a/libavcodec/pcm-mpeg.c b/libavcodec/pcm-mpeg.c index a55d48cb96..de0c302f77 100644 --- a/libavcodec/pcm-mpeg.c +++ b/libavcodec/pcm-mpeg.c @@ -297,14 +297,10 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, } AVCodec ff_pcm_bluray_decoder = { - "pcm_bluray", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_PCM_BLURAY, - 0, - NULL, - NULL, - NULL, - pcm_bluray_decode_frame, + .name = "pcm_bluray", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_PCM_BLURAY, + .decode = pcm_bluray_decode_frame, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for Blu-ray media"), diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c index 35f85f94c3..7eb1daaa7a 100644 --- a/libavcodec/pcx.c +++ b/libavcodec/pcx.c @@ -248,15 +248,13 @@ static av_cold int pcx_end(AVCodecContext *avctx) { } AVCodec ff_pcx_decoder = { - "pcx", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PCX, - sizeof(PCXContext), - pcx_init, - NULL, - pcx_end, - pcx_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "pcx", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PCX, + .priv_data_size = sizeof(PCXContext), + .init = pcx_init, + .close = pcx_end, + .decode = pcx_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"), }; diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c index 6d17987d03..308456808a 100644 --- a/libavcodec/pcxenc.c +++ b/libavcodec/pcxenc.c @@ -190,13 +190,12 @@ static int pcx_encode_frame(AVCodecContext *avctx, } AVCodec ff_pcx_encoder = { - "pcx", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PCX, - sizeof(PCXContext), - pcx_encode_init, - pcx_encode_frame, - NULL, + .name = "pcx", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PCX, + .priv_data_size = sizeof(PCXContext), + .init = pcx_encode_init, + .encode = pcx_encode_frame, .pix_fmts = (const enum PixelFormat[]){ PIX_FMT_RGB24, PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8, diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 71b8242e70..bcc47f358e 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -469,13 +469,12 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, } AVCodec ff_pgssub_decoder = { - "pgssub", - AVMEDIA_TYPE_SUBTITLE, - CODEC_ID_HDMV_PGS_SUBTITLE, - sizeof(PGSSubContext), - init_decoder, - NULL, - close_decoder, - decode, + .name = "pgssub", + .type = AVMEDIA_TYPE_SUBTITLE, + .id = CODEC_ID_HDMV_PGS_SUBTITLE, + .priv_data_size = sizeof(PGSSubContext), + .init = init_decoder, + .close = close_decoder, + .decode = decode, .long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"), }; diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c index 23f299c214..732583ec46 100644 --- a/libavcodec/pictordec.c +++ b/libavcodec/pictordec.c @@ -238,14 +238,12 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_pictor_decoder = { - "pictor", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PICTOR, - sizeof(PicContext), - NULL, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "pictor", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PICTOR, + .priv_data_size = sizeof(PicContext), + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Pictor/PC Paint"), }; diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 1268c9e781..a40cebbb83 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -657,15 +657,13 @@ static av_cold int png_dec_end(AVCodecContext *avctx) } AVCodec ff_png_decoder = { - "png", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PNG, - sizeof(PNGDecContext), - png_dec_init, - NULL, - png_dec_end, - decode_frame, - CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, - NULL, + .name = "png", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PNG, + .priv_data_size = sizeof(PNGDecContext), + .init = png_dec_init, + .close = png_dec_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, .long_name = NULL_IF_CONFIG_SMALL("PNG image"), }; diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index c2ac4901d7..9325348443 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -437,13 +437,12 @@ static av_cold int png_enc_init(AVCodecContext *avctx){ } AVCodec ff_png_encoder = { - "png", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PNG, - sizeof(PNGEncContext), - png_enc_init, - encode_frame, - NULL, //encode_end, + .name = "png", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PNG, + .priv_data_size = sizeof(PNGEncContext), + .init = png_enc_init, + .encode = encode_frame, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_PAL8, PIX_FMT_GRAY8, PIX_FMT_MONOBLACK, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("PNG image"), }; diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c index 988ea0c267..e0e9f66551 100644 --- a/libavcodec/pnmdec.c +++ b/libavcodec/pnmdec.c @@ -189,15 +189,14 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, #if CONFIG_PGM_DECODER AVCodec ff_pgm_decoder = { - "pgm", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PGM, - sizeof(PNMContext), - ff_pnm_init, - NULL, - ff_pnm_end, - pnm_decode_frame, - CODEC_CAP_DR1, + .name = "pgm", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PGM, + .priv_data_size = sizeof(PNMContext), + .init = ff_pnm_init, + .close = ff_pnm_end, + .decode = pnm_decode_frame, + .capabilities = CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"), }; @@ -205,15 +204,14 @@ AVCodec ff_pgm_decoder = { #if CONFIG_PGMYUV_DECODER AVCodec ff_pgmyuv_decoder = { - "pgmyuv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PGMYUV, - sizeof(PNMContext), - ff_pnm_init, - NULL, - ff_pnm_end, - pnm_decode_frame, - CODEC_CAP_DR1, + .name = "pgmyuv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PGMYUV, + .priv_data_size = sizeof(PNMContext), + .init = ff_pnm_init, + .close = ff_pnm_end, + .decode = pnm_decode_frame, + .capabilities = CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), }; @@ -221,15 +219,14 @@ AVCodec ff_pgmyuv_decoder = { #if CONFIG_PPM_DECODER AVCodec ff_ppm_decoder = { - "ppm", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PPM, - sizeof(PNMContext), - ff_pnm_init, - NULL, - ff_pnm_end, - pnm_decode_frame, - CODEC_CAP_DR1, + .name = "ppm", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PPM, + .priv_data_size = sizeof(PNMContext), + .init = ff_pnm_init, + .close = ff_pnm_end, + .decode = pnm_decode_frame, + .capabilities = CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"), }; @@ -237,15 +234,14 @@ AVCodec ff_ppm_decoder = { #if CONFIG_PBM_DECODER AVCodec ff_pbm_decoder = { - "pbm", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PBM, - sizeof(PNMContext), - ff_pnm_init, - NULL, - ff_pnm_end, - pnm_decode_frame, - CODEC_CAP_DR1, + .name = "pbm", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PBM, + .priv_data_size = sizeof(PNMContext), + .init = ff_pnm_init, + .close = ff_pnm_end, + .decode = pnm_decode_frame, + .capabilities = CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"), }; @@ -253,15 +249,14 @@ AVCodec ff_pbm_decoder = { #if CONFIG_PAM_DECODER AVCodec ff_pam_decoder = { - "pam", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PAM, - sizeof(PNMContext), - ff_pnm_init, - NULL, - ff_pnm_end, - pnm_decode_frame, - CODEC_CAP_DR1, + .name = "pam", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PAM, + .priv_data_size = sizeof(PNMContext), + .init = ff_pnm_init, + .close = ff_pnm_end, + .decode = pnm_decode_frame, + .capabilities = CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), }; diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c index 57cb90c868..a27a278d47 100644 --- a/libavcodec/pnmenc.c +++ b/libavcodec/pnmenc.c @@ -114,12 +114,12 @@ static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, #if CONFIG_PGM_ENCODER AVCodec ff_pgm_encoder = { - "pgm", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PGM, - sizeof(PNMContext), - ff_pnm_init, - pnm_encode_frame, + .name = "pgm", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PGM, + .priv_data_size = sizeof(PNMContext), + .init = ff_pnm_init, + .encode = pnm_encode_frame, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"), }; @@ -127,12 +127,12 @@ AVCodec ff_pgm_encoder = { #if CONFIG_PGMYUV_ENCODER AVCodec ff_pgmyuv_encoder = { - "pgmyuv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PGMYUV, - sizeof(PNMContext), - ff_pnm_init, - pnm_encode_frame, + .name = "pgmyuv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PGMYUV, + .priv_data_size = sizeof(PNMContext), + .init = ff_pnm_init, + .encode = pnm_encode_frame, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), }; @@ -140,12 +140,12 @@ AVCodec ff_pgmyuv_encoder = { #if CONFIG_PPM_ENCODER AVCodec ff_ppm_encoder = { - "ppm", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PPM, - sizeof(PNMContext), - ff_pnm_init, - pnm_encode_frame, + .name = "ppm", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PPM, + .priv_data_size = sizeof(PNMContext), + .init = ff_pnm_init, + .encode = pnm_encode_frame, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"), }; @@ -153,12 +153,12 @@ AVCodec ff_ppm_encoder = { #if CONFIG_PBM_ENCODER AVCodec ff_pbm_encoder = { - "pbm", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PBM, - sizeof(PNMContext), - ff_pnm_init, - pnm_encode_frame, + .name = "pbm", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PBM, + .priv_data_size = sizeof(PNMContext), + .init = ff_pnm_init, + .encode = pnm_encode_frame, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"), }; diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c index c993f6c0f0..5dadaf6ece 100644 --- a/libavcodec/ptx.c +++ b/libavcodec/ptx.c @@ -107,15 +107,13 @@ static av_cold int ptx_end(AVCodecContext *avctx) { } AVCodec ff_ptx_decoder = { - "ptx", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_PTX, - sizeof(PTXContext), - ptx_init, - NULL, - ptx_end, - ptx_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "ptx", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PTX, + .priv_data_size = sizeof(PTXContext), + .init = ptx_init, + .close = ptx_end, + .decode = ptx_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("V.Flash PTX image"), }; diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c index 07ac9aa69d..2dc059e555 100644 --- a/libavcodec/qdrw.c +++ b/libavcodec/qdrw.c @@ -151,14 +151,13 @@ static av_cold int decode_end(AVCodecContext *avctx){ } AVCodec ff_qdraw_decoder = { - "qdraw", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_QDRAW, - sizeof(QdrawContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "qdraw", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_QDRAW, + .priv_data_size = sizeof(QdrawContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Apple QuickDraw"), }; diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 5dd2a2d5ca..9513dd0ad3 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -307,14 +307,13 @@ static av_cold int decode_end(AVCodecContext *avctx){ } AVCodec ff_qpeg_decoder = { - "qpeg", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_QPEG, - sizeof(QpegContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "qpeg", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_QPEG, + .priv_data_size = sizeof(QpegContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Q-team QPEG"), }; diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c index e14c306c6b..8854fb2b96 100644 --- a/libavcodec/qtrle.c +++ b/libavcodec/qtrle.c @@ -542,15 +542,14 @@ static av_cold int qtrle_decode_end(AVCodecContext *avctx) } AVCodec ff_qtrle_decoder = { - "qtrle", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_QTRLE, - sizeof(QtrleContext), - qtrle_decode_init, - NULL, - qtrle_decode_end, - qtrle_decode_frame, - CODEC_CAP_DR1, + .name = "qtrle", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_QTRLE, + .priv_data_size = sizeof(QtrleContext), + .init = qtrle_decode_init, + .close = qtrle_decode_end, + .decode = qtrle_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("QuickTime Animation (RLE) video"), }; diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 3cad37fd81..ede03d2f78 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -322,13 +322,13 @@ static av_cold int qtrle_encode_end(AVCodecContext *avctx) } AVCodec ff_qtrle_encoder = { - "qtrle", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_QTRLE, - sizeof(QtrleEncContext), - qtrle_encode_init, - qtrle_encode_frame, - qtrle_encode_end, + .name = "qtrle", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_QTRLE, + .priv_data_size = sizeof(QtrleEncContext), + .init = qtrle_encode_init, + .encode = qtrle_encode_frame, + .close = qtrle_encode_end, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB555BE, PIX_FMT_ARGB, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("QuickTime Animation (RLE) video"), }; diff --git a/libavcodec/r210dec.c b/libavcodec/r210dec.c index 9d5f7eee9b..0f85f5892b 100644 --- a/libavcodec/r210dec.c +++ b/libavcodec/r210dec.c @@ -98,29 +98,25 @@ static av_cold int decode_close(AVCodecContext *avctx) #if CONFIG_R210_DECODER AVCodec ff_r210_decoder = { - "r210", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_R210, - 0, - decode_init, - NULL, - decode_close, - decode_frame, - CODEC_CAP_DR1, + .name = "r210", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_R210, + .init = decode_init, + .close = decode_close, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"), }; #endif #if CONFIG_R10K_DECODER AVCodec ff_r10k_decoder = { - "r10k", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_R10K, - 0, - decode_init, - NULL, - decode_close, - decode_frame, - CODEC_CAP_DR1, + .name = "r10k", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_R10K, + .init = decode_init, + .close = decode_close, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"), }; #endif diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 5e8e6c4c43..9989a36d13 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -202,13 +202,12 @@ static av_cold int raw_close_decoder(AVCodecContext *avctx) } AVCodec ff_rawvideo_decoder = { - "rawvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_RAWVIDEO, - sizeof(RawVideoContext), - raw_init_decoder, - NULL, - raw_close_decoder, - raw_decode, + .name = "rawvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_RAWVIDEO, + .priv_data_size = sizeof(RawVideoContext), + .init = raw_init_decoder, + .close = raw_close_decoder, + .decode = raw_decode, .long_name = NULL_IF_CONFIG_SMALL("raw video"), }; diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c index 926124c54b..6640db089d 100644 --- a/libavcodec/rawenc.c +++ b/libavcodec/rawenc.c @@ -56,11 +56,11 @@ static int raw_encode(AVCodecContext *avctx, } AVCodec ff_rawvideo_encoder = { - "rawvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_RAWVIDEO, - sizeof(AVFrame), - raw_init_encoder, - raw_encode, + .name = "rawvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_RAWVIDEO, + .priv_data_size = sizeof(AVFrame), + .init = raw_init_encoder, + .encode = raw_encode, .long_name = NULL_IF_CONFIG_SMALL("raw video"), }; diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 59f9bfb134..7e3bd9cdde 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -219,15 +219,14 @@ static av_cold int rl2_decode_end(AVCodecContext *avctx) AVCodec ff_rl2_decoder = { - "rl2", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_RL2, - sizeof(Rl2Context), - rl2_decode_init, - NULL, - rl2_decode_end, - rl2_decode_frame, - CODEC_CAP_DR1, + .name = "rl2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_RL2, + .priv_data_size = sizeof(Rl2Context), + .init = rl2_decode_init, + .close = rl2_decode_end, + .decode = rl2_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("RL2 video"), }; diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c index 46aefb4bef..e540e14c24 100644 --- a/libavcodec/roqaudioenc.c +++ b/libavcodec/roqaudioenc.c @@ -154,14 +154,13 @@ static av_cold int roq_dpcm_encode_close(AVCodecContext *avctx) } AVCodec ff_roq_dpcm_encoder = { - "roq_dpcm", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_ROQ_DPCM, - sizeof(ROQDPCMContext), - roq_dpcm_encode_init, - roq_dpcm_encode_frame, - roq_dpcm_encode_close, - NULL, + .name = "roq_dpcm", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_ROQ_DPCM, + .priv_data_size = sizeof(ROQDPCMContext), + .init = roq_dpcm_encode_init, + .encode = roq_dpcm_encode_frame, + .close = roq_dpcm_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("id RoQ DPCM"), }; diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c index 06d1309d65..64a15fa23f 100644 --- a/libavcodec/roqvideodec.c +++ b/libavcodec/roqvideodec.c @@ -211,14 +211,13 @@ static av_cold int roq_decode_end(AVCodecContext *avctx) } AVCodec ff_roq_decoder = { - "roqvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ROQ, - sizeof(RoqContext), - roq_decode_init, - NULL, - roq_decode_end, - roq_decode_frame, - CODEC_CAP_DR1, + .name = "roqvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ROQ, + .priv_data_size = sizeof(RoqContext), + .init = roq_decode_init, + .close = roq_decode_end, + .decode = roq_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("id RoQ video"), }; diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c index 958f103865..3fb3dc5b95 100644 --- a/libavcodec/rpza.c +++ b/libavcodec/rpza.c @@ -276,14 +276,13 @@ static av_cold int rpza_decode_end(AVCodecContext *avctx) } AVCodec ff_rpza_decoder = { - "rpza", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_RPZA, - sizeof(RpzaContext), - rpza_decode_init, - NULL, - rpza_decode_end, - rpza_decode_frame, - CODEC_CAP_DR1, + .name = "rpza", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_RPZA, + .priv_data_size = sizeof(RpzaContext), + .init = rpza_decode_init, + .close = rpza_decode_end, + .decode = rpza_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("QuickTime video (RPZA)"), }; diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 6227dc6f6c..9a1fda1137 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -691,30 +691,28 @@ static int rv10_decode_frame(AVCodecContext *avctx, } AVCodec ff_rv10_decoder = { - "rv10", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_RV10, - sizeof(MpegEncContext), - rv10_decode_init, - NULL, - rv10_decode_end, - rv10_decode_frame, - CODEC_CAP_DR1, + .name = "rv10", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_RV10, + .priv_data_size = sizeof(MpegEncContext), + .init = rv10_decode_init, + .close = rv10_decode_end, + .decode = rv10_decode_frame, + .capabilities = CODEC_CAP_DR1, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("RealVideo 1.0"), .pix_fmts= ff_pixfmt_list_420, }; AVCodec ff_rv20_decoder = { - "rv20", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_RV20, - sizeof(MpegEncContext), - rv10_decode_init, - NULL, - rv10_decode_end, - rv10_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .name = "rv20", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_RV20, + .priv_data_size = sizeof(MpegEncContext), + .init = rv10_decode_init, + .close = rv10_decode_end, + .decode = rv10_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, .flush= ff_mpeg_flush, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("RealVideo 2.0"), diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index 1cb36fd223..6fda11486d 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -57,13 +57,13 @@ void rv10_encode_picture_header(MpegEncContext *s, int picture_number) } AVCodec ff_rv10_encoder = { - "rv10", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_RV10, - sizeof(MpegEncContext), - MPV_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "rv10", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_RV10, + .priv_data_size = sizeof(MpegEncContext), + .init = MPV_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("RealVideo 1.0"), }; diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index 8eba76b1a2..bf09d8ada4 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -58,13 +58,13 @@ void rv20_encode_picture_header(MpegEncContext *s, int picture_number){ } AVCodec ff_rv20_encoder = { - "rv20", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_RV20, - sizeof(MpegEncContext), - MPV_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "rv20", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_RV20, + .priv_data_size = sizeof(MpegEncContext), + .init = MPV_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("RealVideo 2.0"), }; diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 17ea801802..ac65cc10a4 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -268,15 +268,14 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx) } AVCodec ff_rv30_decoder = { - "rv30", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_RV30, - sizeof(RV34DecContext), - rv30_decode_init, - NULL, - ff_rv34_decode_end, - ff_rv34_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .name = "rv30", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_RV30, + .priv_data_size = sizeof(RV34DecContext), + .init = rv30_decode_init, + .close = ff_rv34_decode_end, + .decode = ff_rv34_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, .flush = ff_mpeg_flush, .long_name = NULL_IF_CONFIG_SMALL("RealVideo 3.0"), .pix_fmts= ff_pixfmt_list_420, diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index df97c3a4e5..c5cbe05ae3 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -669,15 +669,14 @@ static av_cold int rv40_decode_init(AVCodecContext *avctx) } AVCodec ff_rv40_decoder = { - "rv40", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_RV40, - sizeof(RV34DecContext), - rv40_decode_init, - NULL, - ff_rv34_decode_end, - ff_rv34_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .name = "rv40", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_RV40, + .priv_data_size = sizeof(RV34DecContext), + .init = rv40_decode_init, + .close = ff_rv34_decode_end, + .decode = ff_rv34_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, .flush = ff_mpeg_flush, .long_name = NULL_IF_CONFIG_SMALL("RealVideo 4.0"), .pix_fmts= ff_pixfmt_list_420, diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index 84cff35390..e5b3c5933c 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -260,14 +260,13 @@ static av_cold int sgi_end(AVCodecContext *avctx) } AVCodec ff_sgi_decoder = { - "sgi", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SGI, - sizeof(SgiState), - sgi_init, - NULL, - sgi_end, - decode_frame, + .name = "sgi", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SGI, + .priv_data_size = sizeof(SgiState), + .init = sgi_init, + .close = sgi_end, + .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("SGI image"), }; diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c index 202f676fc0..9d02eea136 100644 --- a/libavcodec/sgienc.c +++ b/libavcodec/sgienc.c @@ -160,13 +160,12 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, } AVCodec ff_sgi_encoder = { - "sgi", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SGI, - sizeof(SgiContext), - encode_init, - encode_frame, - NULL, + .name = "sgi", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SGI, + .priv_data_size = sizeof(SgiContext), + .init = encode_init, + .encode = encode_frame, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA, PIX_FMT_GRAY8, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("SGI image"), }; diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index e4dfa7c59f..80b1b4dba5 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -536,14 +536,13 @@ static void shorten_flush(AVCodecContext *avctx){ } AVCodec ff_shorten_decoder = { - "shorten", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_SHORTEN, - sizeof(ShortenContext), - shorten_decode_init, - NULL, - shorten_decode_close, - shorten_decode_frame, + .name = "shorten", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_SHORTEN, + .priv_data_size = sizeof(ShortenContext), + .init = shorten_decode_init, + .close = shorten_decode_close, + .decode = shorten_decode_frame, .flush= shorten_flush, .long_name= NULL_IF_CONFIG_SMALL("Shorten"), }; diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c index 2e86861706..c9fccb2d3a 100644 --- a/libavcodec/sipr.c +++ b/libavcodec/sipr.c @@ -549,13 +549,11 @@ static int sipr_decode_frame(AVCodecContext *avctx, void *datap, } AVCodec ff_sipr_decoder = { - "sipr", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_SIPR, - sizeof(SiprContext), - sipr_decoder_init, - NULL, - NULL, - sipr_decode_frame, + .name = "sipr", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_SIPR, + .priv_data_size = sizeof(SiprContext), + .init = sipr_decoder_init, + .decode = sipr_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"), }; diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 8060e1cee7..c6b0c29eaa 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -686,27 +686,23 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, } AVCodec ff_smacker_decoder = { - "smackvid", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SMACKVIDEO, - sizeof(SmackVContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "smackvid", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SMACKVIDEO, + .priv_data_size = sizeof(SmackVContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Smacker video"), }; AVCodec ff_smackaud_decoder = { - "smackaud", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_SMACKAUDIO, - 0, - smka_decode_init, - NULL, - NULL, - smka_decode_frame, + .name = "smackaud", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_SMACKAUDIO, + .init = smka_decode_init, + .decode = smka_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Smacker audio"), }; diff --git a/libavcodec/smc.c b/libavcodec/smc.c index e75203d7a5..f4a0b6a6a9 100644 --- a/libavcodec/smc.c +++ b/libavcodec/smc.c @@ -475,14 +475,13 @@ static av_cold int smc_decode_end(AVCodecContext *avctx) } AVCodec ff_smc_decoder = { - "smc", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SMC, - sizeof(SmcContext), - smc_decode_init, - NULL, - smc_decode_end, - smc_decode_frame, - CODEC_CAP_DR1, + .name = "smc", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SMC, + .priv_data_size = sizeof(SmcContext), + .init = smc_decode_init, + .close = smc_decode_end, + .decode = smc_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("QuickTime Graphics (SMC)"), }; diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 3162e5cf98..b87d8285f6 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -1930,16 +1930,14 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_snow_decoder = { - "snow", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SNOW, - sizeof(SnowContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, - NULL, + .name = "snow", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SNOW, + .priv_data_size = sizeof(SnowContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, .long_name = NULL_IF_CONFIG_SMALL("Snow"), }; @@ -3679,13 +3677,13 @@ static av_cold int encode_end(AVCodecContext *avctx) } AVCodec ff_snow_encoder = { - "snow", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SNOW, - sizeof(SnowContext), - encode_init, - encode_frame, - encode_end, + .name = "snow", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SNOW, + .priv_data_size = sizeof(SnowContext), + .init = encode_init, + .encode = encode_frame, + .close = encode_end, .long_name = NULL_IF_CONFIG_SMALL("Snow"), }; #endif diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index ae25733530..4c42ab166c 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -94,29 +94,25 @@ static int sp5x_decode_frame(AVCodecContext *avctx, } AVCodec ff_sp5x_decoder = { - "sp5x", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SP5X, - sizeof(MJpegDecodeContext), - ff_mjpeg_decode_init, - NULL, - ff_mjpeg_decode_end, - sp5x_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "sp5x", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SP5X, + .priv_data_size = sizeof(MJpegDecodeContext), + .init = ff_mjpeg_decode_init, + .close = ff_mjpeg_decode_end, + .decode = sp5x_decode_frame, + .capabilities = CODEC_CAP_DR1, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"), }; AVCodec ff_amv_decoder = { - "amv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_AMV, - sizeof(MJpegDecodeContext), - ff_mjpeg_decode_init, - NULL, - ff_mjpeg_decode_end, - sp5x_decode_frame, - 0, + .name = "amv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_AMV, + .priv_data_size = sizeof(MJpegDecodeContext), + .init = ff_mjpeg_decode_init, + .close = ff_mjpeg_decode_end, + .decode = sp5x_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("AMV Video"), }; diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index cadffdf1b8..d63fd171b8 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -185,15 +185,13 @@ static av_cold int sunrast_end(AVCodecContext *avctx) { } AVCodec ff_sunrast_decoder = { - "sunrast", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SUNRAST, - sizeof(SUNRASTContext), - sunrast_init, - NULL, - sunrast_end, - sunrast_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "sunrast", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SUNRAST, + .priv_data_size = sizeof(SUNRASTContext), + .init = sunrast_init, + .close = sunrast_end, + .decode = sunrast_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Sun Rasterfile image"), }; diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index e949b5596d..a604f1dc96 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -808,15 +808,14 @@ static av_cold int svq1_decode_end(AVCodecContext *avctx) AVCodec ff_svq1_decoder = { - "svq1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SVQ1, - sizeof(MpegEncContext), - svq1_decode_init, - NULL, - svq1_decode_end, - svq1_decode_frame, - CODEC_CAP_DR1, + .name = "svq1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SVQ1, + .priv_data_size = sizeof(MpegEncContext), + .init = svq1_decode_init, + .close = svq1_decode_end, + .decode = svq1_decode_frame, + .capabilities = CODEC_CAP_DR1, .flush= ff_mpeg_flush, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV410P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 4fdfefa664..36787cfdce 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -573,13 +573,13 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) AVCodec ff_svq1_encoder = { - "svq1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SVQ1, - sizeof(SVQ1Context), - svq1_encode_init, - svq1_encode_frame, - svq1_encode_end, + .name = "svq1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SVQ1, + .priv_data_size = sizeof(SVQ1Context), + .init = svq1_encode_init, + .encode = svq1_encode_frame, + .close = svq1_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV410P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), }; diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 5cac59c249..f6f9fc17fe 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -1091,15 +1091,14 @@ static int svq3_decode_end(AVCodecContext *avctx) } AVCodec ff_svq3_decoder = { - "svq3", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_SVQ3, - sizeof(SVQ3Context), - svq3_decode_init, - NULL, - svq3_decode_end, - svq3_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .name = "svq3", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_SVQ3, + .priv_data_size = sizeof(SVQ3Context), + .init = svq3_decode_init, + .close = svq3_decode_end, + .decode = svq3_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_DELAY, .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3"), .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_NONE}, }; diff --git a/libavcodec/targa.c b/libavcodec/targa.c index e57fd8ba65..b821d74f8d 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -254,15 +254,13 @@ static av_cold int targa_end(AVCodecContext *avctx){ } AVCodec ff_targa_decoder = { - "targa", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TARGA, - sizeof(TargaContext), - targa_init, - NULL, - targa_end, - decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "targa", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TARGA, + .priv_data_size = sizeof(TargaContext), + .init = targa_init, + .close = targa_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"), }; diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c index 4468f00df1..cdb342a30c 100644 --- a/libavcodec/tiertexseqv.c +++ b/libavcodec/tiertexseqv.c @@ -220,14 +220,13 @@ static av_cold int seqvideo_decode_end(AVCodecContext *avctx) } AVCodec ff_tiertexseqvideo_decoder = { - "tiertexseqvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TIERTEXSEQVIDEO, - sizeof(SeqVideoContext), - seqvideo_decode_init, - NULL, - seqvideo_decode_end, - seqvideo_decode_frame, - CODEC_CAP_DR1, + .name = "tiertexseqvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TIERTEXSEQVIDEO, + .priv_data_size = sizeof(SeqVideoContext), + .init = seqvideo_decode_init, + .close = seqvideo_decode_end, + .decode = seqvideo_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ video"), }; diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 7241d6f3fb..ab5f1ebd11 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -621,15 +621,13 @@ static av_cold int tiff_end(AVCodecContext *avctx) } AVCodec ff_tiff_decoder = { - "tiff", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TIFF, - sizeof(TiffContext), - tiff_init, - NULL, - tiff_end, - decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "tiff", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TIFF, + .priv_data_size = sizeof(TiffContext), + .init = tiff_init, + .close = tiff_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("TIFF image"), }; diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index 3d927eb068..a141a475b7 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -444,16 +444,11 @@ fail: } AVCodec ff_tiff_encoder = { - "tiff", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TIFF, - sizeof(TiffEncoderContext), - NULL, - encode_frame, - NULL, - NULL, - 0, - NULL, + .name = "tiff", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TIFF, + .priv_data_size = sizeof(TiffEncoderContext), + .encode = encode_frame, .pix_fmts = (const enum PixelFormat[]) {PIX_FMT_RGB24, PIX_FMT_PAL8, PIX_FMT_GRAY8, PIX_FMT_MONOBLACK, PIX_FMT_MONOWHITE, diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index 97330d1bb4..fcf6004c51 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -892,14 +892,13 @@ static av_cold int truemotion1_decode_end(AVCodecContext *avctx) } AVCodec ff_truemotion1_decoder = { - "truemotion1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TRUEMOTION1, - sizeof(TrueMotion1Context), - truemotion1_decode_init, - NULL, - truemotion1_decode_end, - truemotion1_decode_frame, - CODEC_CAP_DR1, + .name = "truemotion1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TRUEMOTION1, + .priv_data_size = sizeof(TrueMotion1Context), + .init = truemotion1_decode_init, + .close = truemotion1_decode_end, + .decode = truemotion1_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 1.0"), }; diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index 23abade214..8d72bb6df0 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -864,14 +864,13 @@ static av_cold int decode_end(AVCodecContext *avctx){ } AVCodec ff_truemotion2_decoder = { - "truemotion2", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TRUEMOTION2, - sizeof(TM2Context), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "truemotion2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TRUEMOTION2, + .priv_data_size = sizeof(TM2Context), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 2.0"), }; diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c index df9d918fd7..f8897754eb 100644 --- a/libavcodec/truespeech.c +++ b/libavcodec/truespeech.c @@ -382,13 +382,11 @@ static int truespeech_decode_frame(AVCodecContext *avctx, } AVCodec ff_truespeech_decoder = { - "truespeech", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_TRUESPEECH, - sizeof(TSContext), - truespeech_decode_init, - NULL, - NULL, - truespeech_decode_frame, + .name = "truespeech", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_TRUESPEECH, + .priv_data_size = sizeof(TSContext), + .init = truespeech_decode_init, + .decode = truespeech_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("DSP Group TrueSpeech"), }; diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index 772906aba6..b97c527c94 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -199,15 +199,14 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_tscc_decoder = { - "camtasia", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TSCC, - sizeof(CamtasiaContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "camtasia", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TSCC, + .priv_data_size = sizeof(CamtasiaContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("TechSmith Screen Capture Codec"), }; diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 96de9c3202..bd536e1a19 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -426,13 +426,12 @@ static av_cold int tta_decode_close(AVCodecContext *avctx) { } AVCodec ff_tta_decoder = { - "tta", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_TTA, - sizeof(TTAContext), - tta_decode_init, - NULL, - tta_decode_close, - tta_decode_frame, + .name = "tta", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_TTA, + .priv_data_size = sizeof(TTAContext), + .init = tta_decode_init, + .close = tta_decode_close, + .decode = tta_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("True Audio (TTA)"), }; diff --git a/libavcodec/txd.c b/libavcodec/txd.c index e91b4fbaf3..74ffff66b3 100644 --- a/libavcodec/txd.c +++ b/libavcodec/txd.c @@ -156,15 +156,13 @@ static av_cold int txd_end(AVCodecContext *avctx) { } AVCodec ff_txd_decoder = { - "txd", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_TXD, - sizeof(TXDContext), - txd_init, - NULL, - txd_end, - txd_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "txd", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_TXD, + .priv_data_size = sizeof(TXDContext), + .init = txd_init, + .close = txd_end, + .decode = txd_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Renderware TXD (TeXture Dictionary) image"), }; diff --git a/libavcodec/ulti.c b/libavcodec/ulti.c index 9a73c627a9..a2802f73a9 100644 --- a/libavcodec/ulti.c +++ b/libavcodec/ulti.c @@ -402,16 +402,14 @@ static int ulti_decode_frame(AVCodecContext *avctx, } AVCodec ff_ulti_decoder = { - "ultimotion", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ULTI, - sizeof(UltimotionDecodeContext), - ulti_decode_init, - NULL, - ulti_decode_end, - ulti_decode_frame, - CODEC_CAP_DR1, - NULL, + .name = "ultimotion", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ULTI, + .priv_data_size = sizeof(UltimotionDecodeContext), + .init = ulti_decode_init, + .close = ulti_decode_end, + .decode = ulti_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("IBM UltiMotion"), }; diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index f4ea65cb96..fa67635ed3 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -121,14 +121,12 @@ static av_cold int decode_close(AVCodecContext *avctx) } AVCodec ff_v210_decoder = { - "v210", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_V210, - 0, - decode_init, - NULL, - decode_close, - decode_frame, - CODEC_CAP_DR1, + .name = "v210", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_V210, + .init = decode_init, + .close = decode_close, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), }; diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c index 8b022fa8f8..1f621d4907 100644 --- a/libavcodec/v210enc.c +++ b/libavcodec/v210enc.c @@ -118,13 +118,12 @@ static av_cold int encode_close(AVCodecContext *avctx) } AVCodec ff_v210_encoder = { - "v210", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_V210, - 0, - encode_init, - encode_frame, - encode_close, + .name = "v210", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_V210, + .init = encode_init, + .encode = encode_frame, + .close = encode_close, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P16, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), }; diff --git a/libavcodec/v210x.c b/libavcodec/v210x.c index e3b1a3c684..959dec5f86 100644 --- a/libavcodec/v210x.c +++ b/libavcodec/v210x.c @@ -133,14 +133,12 @@ static av_cold int decode_close(AVCodecContext *avctx) } AVCodec ff_v210x_decoder = { - "v210x", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_V210X, - 0, - decode_init, - NULL, - decode_close, - decode_frame, - CODEC_CAP_DR1, + .name = "v210x", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_V210X, + .init = decode_init, + .close = decode_close, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), }; diff --git a/libavcodec/vb.c b/libavcodec/vb.c index fb37283764..96387b6d1d 100644 --- a/libavcodec/vb.c +++ b/libavcodec/vb.c @@ -288,14 +288,13 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_vb_decoder = { - "vb", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VB, - sizeof(VBDecContext), - decode_init, - NULL, - decode_end, - decode_frame, + .name = "vb", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VB, + .priv_data_size = sizeof(VBDecContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Beam Software VB"), }; diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index d20fc893d3..ae7906da3a 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -3820,16 +3820,14 @@ static const AVProfile profiles[] = { }; AVCodec ff_vc1_decoder = { - "vc1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VC1, - sizeof(VC1Context), - vc1_decode_init, - NULL, - vc1_decode_end, - vc1_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DELAY, - NULL, + .name = "vc1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VC1, + .priv_data_size = sizeof(VC1Context), + .init = vc1_decode_init, + .close = vc1_decode_end, + .decode = vc1_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"), .pix_fmts = ff_hwaccel_pixfmt_list_420, .profiles = NULL_IF_CONFIG_SMALL(profiles) @@ -3837,16 +3835,14 @@ AVCodec ff_vc1_decoder = { #if CONFIG_WMV3_DECODER AVCodec ff_wmv3_decoder = { - "wmv3", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_WMV3, - sizeof(VC1Context), - vc1_decode_init, - NULL, - vc1_decode_end, - vc1_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DELAY, - NULL, + .name = "wmv3", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_WMV3, + .priv_data_size = sizeof(VC1Context), + .init = vc1_decode_init, + .close = vc1_decode_end, + .decode = vc1_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"), .pix_fmts = ff_hwaccel_pixfmt_list_420, .profiles = NULL_IF_CONFIG_SMALL(profiles) @@ -3855,16 +3851,14 @@ AVCodec ff_wmv3_decoder = { #if CONFIG_WMV3_VDPAU_DECODER AVCodec ff_wmv3_vdpau_decoder = { - "wmv3_vdpau", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_WMV3, - sizeof(VC1Context), - vc1_decode_init, - NULL, - vc1_decode_end, - vc1_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, - NULL, + .name = "wmv3_vdpau", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_WMV3, + .priv_data_size = sizeof(VC1Context), + .init = vc1_decode_init, + .close = vc1_decode_end, + .decode = vc1_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 VDPAU"), .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_WMV3, PIX_FMT_NONE}, .profiles = NULL_IF_CONFIG_SMALL(profiles) @@ -3873,16 +3867,14 @@ AVCodec ff_wmv3_vdpau_decoder = { #if CONFIG_VC1_VDPAU_DECODER AVCodec ff_vc1_vdpau_decoder = { - "vc1_vdpau", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VC1, - sizeof(VC1Context), - vc1_decode_init, - NULL, - vc1_decode_end, - vc1_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, - NULL, + .name = "vc1_vdpau", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VC1, + .priv_data_size = sizeof(VC1Context), + .init = vc1_decode_init, + .close = vc1_decode_end, + .decode = vc1_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 VDPAU"), .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_VC1, PIX_FMT_NONE}, .profiles = NULL_IF_CONFIG_SMALL(profiles) diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c index aaf8eaebef..9eb6a72875 100644 --- a/libavcodec/vcr1.c +++ b/libavcodec/vcr1.c @@ -177,26 +177,25 @@ static av_cold int encode_init(AVCodecContext *avctx){ #endif AVCodec ff_vcr1_decoder = { - "vcr1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VCR1, - sizeof(VCR1Context), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "vcr1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VCR1, + .priv_data_size = sizeof(VCR1Context), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"), }; #if CONFIG_VCR1_ENCODER AVCodec ff_vcr1_encoder = { - "vcr1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VCR1, - sizeof(VCR1Context), - encode_init, - encode_frame, + .name = "vcr1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VCR1, + .priv_data_size = sizeof(VCR1Context), + .init = encode_init, + .encode = encode_frame, //encode_end, .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"), }; diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c index 283c2136d5..110d19cd9a 100644 --- a/libavcodec/vmdav.c +++ b/libavcodec/vmdav.c @@ -544,26 +544,23 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, */ AVCodec ff_vmdvideo_decoder = { - "vmdvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VMDVIDEO, - sizeof(VmdVideoContext), - vmdvideo_decode_init, - NULL, - vmdvideo_decode_end, - vmdvideo_decode_frame, - CODEC_CAP_DR1, + .name = "vmdvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VMDVIDEO, + .priv_data_size = sizeof(VmdVideoContext), + .init = vmdvideo_decode_init, + .close = vmdvideo_decode_end, + .decode = vmdvideo_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Sierra VMD video"), }; AVCodec ff_vmdaudio_decoder = { - "vmdaudio", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_VMDAUDIO, - sizeof(VmdAudioContext), - vmdaudio_decode_init, - NULL, - NULL, - vmdaudio_decode_frame, + .name = "vmdaudio", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_VMDAUDIO, + .priv_data_size = sizeof(VmdAudioContext), + .init = vmdaudio_decode_init, + .decode = vmdaudio_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Sierra VMD audio"), }; diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c index f95bef7e1d..a72c507c3c 100644 --- a/libavcodec/vmnc.c +++ b/libavcodec/vmnc.c @@ -509,15 +509,14 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_vmnc_decoder = { - "vmnc", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VMNC, - sizeof(VmncContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "vmnc", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VMNC, + .priv_data_size = sizeof(VmncContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("VMware Screen Codec / VMware Video"), }; diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 445e68e3f2..7c07de646a 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1665,14 +1665,13 @@ static av_cold int vorbis_decode_close(AVCodecContext *avccontext) } AVCodec ff_vorbis_decoder = { - "vorbis", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_VORBIS, - sizeof(vorbis_context), - vorbis_decode_init, - NULL, - vorbis_decode_close, - vorbis_decode_frame, + .name = "vorbis", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_VORBIS, + .priv_data_size = sizeof(vorbis_context), + .init = vorbis_decode_init, + .close = vorbis_decode_close, + .decode = vorbis_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Vorbis"), .channel_layouts = ff_vorbis_channel_layouts, .sample_fmts = (const enum AVSampleFormat[]) { diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index 67d094b37d..00fe402d3e 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -1103,13 +1103,13 @@ static av_cold int vorbis_encode_close(AVCodecContext *avccontext) } AVCodec ff_vorbis_encoder = { - "vorbis", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_VORBIS, - sizeof(vorbis_enc_context), - vorbis_encode_init, - vorbis_encode_frame, - vorbis_encode_close, + .name = "vorbis", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_VORBIS, + .priv_data_size = sizeof(vorbis_enc_context), + .init = vorbis_encode_init, + .encode = vorbis_encode_frame, + .close = vorbis_encode_close, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Vorbis"), diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index c117a64084..13a3bda4a5 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -2342,16 +2342,14 @@ static void vp3_decode_flush(AVCodecContext *avctx) } AVCodec ff_theora_decoder = { - "theora", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_THEORA, - sizeof(Vp3DecodeContext), - theora_decode_init, - NULL, - vp3_decode_end, - vp3_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, - NULL, + .name = "theora", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_THEORA, + .priv_data_size = sizeof(Vp3DecodeContext), + .init = theora_decode_init, + .close = vp3_decode_end, + .decode = vp3_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, .long_name = NULL_IF_CONFIG_SMALL("Theora"), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) @@ -2359,16 +2357,14 @@ AVCodec ff_theora_decoder = { #endif AVCodec ff_vp3_decoder = { - "vp3", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VP3, - sizeof(Vp3DecodeContext), - vp3_decode_init, - NULL, - vp3_decode_end, - vp3_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, - NULL, + .name = "vp3", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VP3, + .priv_data_size = sizeof(Vp3DecodeContext), + .init = vp3_decode_init, + .close = vp3_decode_end, + .decode = vp3_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index a057d9bbe1..7743a48508 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -269,14 +269,13 @@ static av_cold int vp5_decode_init(AVCodecContext *avctx) } AVCodec ff_vp5_decoder = { - "vp5", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VP5, - sizeof(VP56Context), - vp5_decode_init, - NULL, - ff_vp56_free, - ff_vp56_decode_frame, - CODEC_CAP_DR1, + .name = "vp5", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VP5, + .priv_data_size = sizeof(VP56Context), + .init = vp5_decode_init, + .close = ff_vp56_free, + .decode = ff_vp56_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("On2 VP5"), }; diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 42828d8e47..33cd43a1fa 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -609,42 +609,39 @@ static av_cold int vp6_decode_free(AVCodecContext *avctx) } AVCodec ff_vp6_decoder = { - "vp6", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VP6, - sizeof(VP56Context), - vp6_decode_init, - NULL, - vp6_decode_free, - ff_vp56_decode_frame, - CODEC_CAP_DR1, + .name = "vp6", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VP6, + .priv_data_size = sizeof(VP56Context), + .init = vp6_decode_init, + .close = vp6_decode_free, + .decode = ff_vp56_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("On2 VP6"), }; /* flash version, not flipped upside-down */ AVCodec ff_vp6f_decoder = { - "vp6f", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VP6F, - sizeof(VP56Context), - vp6_decode_init, - NULL, - vp6_decode_free, - ff_vp56_decode_frame, - CODEC_CAP_DR1, + .name = "vp6f", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VP6F, + .priv_data_size = sizeof(VP56Context), + .init = vp6_decode_init, + .close = vp6_decode_free, + .decode = ff_vp56_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version)"), }; /* flash version, not flipped upside-down, with alpha channel */ AVCodec ff_vp6a_decoder = { - "vp6a", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VP6A, - sizeof(VP56Context), - vp6_decode_init, - NULL, - vp6_decode_free, - ff_vp56_decode_frame, - CODEC_CAP_DR1, + .name = "vp6a", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VP6A, + .priv_data_size = sizeof(VP56Context), + .init = vp6_decode_init, + .close = vp6_decode_free, + .decode = ff_vp56_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version, with alpha channel)"), }; diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index e8d3621ea7..36c11c278d 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -1764,15 +1764,14 @@ static int vp8_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo } AVCodec ff_vp8_decoder = { - "vp8", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VP8, - sizeof(VP8Context), - vp8_decode_init, - NULL, - vp8_decode_free, - vp8_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .name = "vp8", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VP8, + .priv_data_size = sizeof(VP8Context), + .init = vp8_decode_init, + .close = vp8_decode_free, + .decode = vp8_decode_frame, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, .flush = vp8_decode_flush, .long_name = NULL_IF_CONFIG_SMALL("On2 VP8"), .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp8_decode_init_thread_copy), diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index 55b95dceba..7a6308aeb1 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -600,14 +600,13 @@ static av_cold int vqa_decode_end(AVCodecContext *avctx) } AVCodec ff_vqa_decoder = { - "vqavideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_WS_VQA, - sizeof(VqaContext), - vqa_decode_init, - NULL, - vqa_decode_end, - vqa_decode_frame, - CODEC_CAP_DR1, + .name = "vqavideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_WS_VQA, + .priv_data_size = sizeof(VqaContext), + .init = vqa_decode_init, + .close = vqa_decode_end, + .decode = vqa_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Westwood Studios VQA (Vector Quantized Animation) video"), }; diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index e4fe217f59..bd1e435d86 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -1190,14 +1190,13 @@ static int wavpack_decode_frame(AVCodecContext *avctx, } AVCodec ff_wavpack_decoder = { - "wavpack", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_WAVPACK, - sizeof(WavpackContext), - wavpack_decode_init, - NULL, - wavpack_decode_end, - wavpack_decode_frame, + .name = "wavpack", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_WAVPACK, + .priv_data_size = sizeof(WavpackContext), + .init = wavpack_decode_init, + .close = wavpack_decode_end, + .decode = wavpack_decode_frame, .capabilities = CODEC_CAP_SUBFRAMES, .long_name = NULL_IF_CONFIG_SMALL("WavPack"), }; diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 4ba8c455ab..8fd2da575a 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -1605,14 +1605,13 @@ static void flush(AVCodecContext *avctx) *@brief wmapro decoder */ AVCodec ff_wmapro_decoder = { - "wmapro", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_WMAPRO, - sizeof(WMAProDecodeCtx), - decode_init, - NULL, - decode_end, - decode_packet, + .name = "wmapro", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_WMAPRO, + .priv_data_size = sizeof(WMAProDecodeCtx), + .init = decode_init, + .close = decode_end, + .decode = decode_packet, .capabilities = CODEC_CAP_SUBFRAMES, .flush= flush, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"), diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index eb3bcb0629..c6e6e76c20 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -2022,15 +2022,14 @@ static av_cold void wmavoice_flush(AVCodecContext *ctx) } AVCodec ff_wmavoice_decoder = { - "wmavoice", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_WMAVOICE, - sizeof(WMAVoiceContext), - wmavoice_decode_init, - NULL, - wmavoice_decode_end, - wmavoice_decode_packet, - CODEC_CAP_SUBFRAMES, + .name = "wmavoice", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_WMAVOICE, + .priv_data_size = sizeof(WMAVoiceContext), + .init = wmavoice_decode_init, + .close = wmavoice_decode_end, + .decode = wmavoice_decode_packet, + .capabilities = CODEC_CAP_SUBFRAMES, .flush = wmavoice_flush, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"), }; diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index 20ffbb736e..21fc1cf82e 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -471,15 +471,14 @@ static av_cold int wmv2_decode_end(AVCodecContext *avctx) } AVCodec ff_wmv2_decoder = { - "wmv2", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_WMV2, - sizeof(Wmv2Context), - wmv2_decode_init, - NULL, - wmv2_decode_end, - ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .name = "wmv2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_WMV2, + .priv_data_size = sizeof(Wmv2Context), + .init = wmv2_decode_init, + .close = wmv2_decode_end, + .decode = ff_h263_decode_frame, + .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"), .pix_fmts= ff_pixfmt_list_420, diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index 9b7890c0f0..9879cb87e9 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -212,13 +212,13 @@ void ff_wmv2_encode_mb(MpegEncContext * s, } AVCodec ff_wmv2_encoder = { - "wmv2", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_WMV2, - sizeof(Wmv2Context), - wmv2_encode_init, - MPV_encode_picture, - MPV_encode_end, + .name = "wmv2", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_WMV2, + .priv_data_size = sizeof(Wmv2Context), + .init = wmv2_encode_init, + .encode = MPV_encode_picture, + .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("Windows Media Video 8"), }; diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index 65ad9cdd12..f6e4694df2 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -157,14 +157,13 @@ static av_cold int decode_end(AVCodecContext *avctx){ } AVCodec ff_wnv1_decoder = { - "wnv1", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_WNV1, - sizeof(WNV1Context), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "wnv1", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_WNV1, + .priv_data_size = sizeof(WNV1Context), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Winnov WNV1"), }; diff --git a/libavcodec/ws-snd1.c b/libavcodec/ws-snd1.c index 534be5661b..9bca4e41f1 100644 --- a/libavcodec/ws-snd1.c +++ b/libavcodec/ws-snd1.c @@ -147,13 +147,10 @@ static int ws_snd_decode_frame(AVCodecContext *avctx, } AVCodec ff_ws_snd1_decoder = { - "ws_snd1", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_WESTWOOD_SND1, - 0, - ws_snd_decode_init, - NULL, - NULL, - ws_snd_decode_frame, + .name = "ws_snd1", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_WESTWOOD_SND1, + .init = ws_snd_decode_init, + .decode = ws_snd_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Westwood Audio (SND1)"), }; diff --git a/libavcodec/xan.c b/libavcodec/xan.c index 876a9a5558..2e29e503b2 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -551,15 +551,14 @@ static av_cold int xan_decode_end(AVCodecContext *avctx) } AVCodec ff_xan_wc3_decoder = { - "xan_wc3", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_XAN_WC3, - sizeof(XanContext), - xan_decode_init, - NULL, - xan_decode_end, - xan_decode_frame, - CODEC_CAP_DR1, + .name = "xan_wc3", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_XAN_WC3, + .priv_data_size = sizeof(XanContext), + .init = xan_decode_init, + .close = xan_decode_end, + .decode = xan_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Wing Commander III / Xan"), }; diff --git a/libavcodec/xl.c b/libavcodec/xl.c index 4f17ae54f2..197b0c24a2 100644 --- a/libavcodec/xl.c +++ b/libavcodec/xl.c @@ -139,14 +139,13 @@ static av_cold int decode_end(AVCodecContext *avctx){ } AVCodec ff_xl_decoder = { - "xl", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_VIXL, - sizeof(VideoXLContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "xl", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_VIXL, + .priv_data_size = sizeof(VideoXLContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Miro VideoXL"), }; diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 4afefac2c4..0791fdd05c 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -134,13 +134,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, } AVCodec ff_xsub_decoder = { - "xsub", - AVMEDIA_TYPE_SUBTITLE, - CODEC_ID_XSUB, - 0, - decode_init, - NULL, - NULL, - decode_frame, + .name = "xsub", + .type = AVMEDIA_TYPE_SUBTITLE, + .id = CODEC_ID_XSUB, + .init = decode_init, + .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("XSUB"), }; diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c index 0c7d07f09d..6e3fed0cd5 100644 --- a/libavcodec/xsubenc.c +++ b/libavcodec/xsubenc.c @@ -211,12 +211,10 @@ static av_cold int xsub_encoder_init(AVCodecContext *avctx) } AVCodec ff_xsub_encoder = { - "xsub", - AVMEDIA_TYPE_SUBTITLE, - CODEC_ID_XSUB, - 0, - xsub_encoder_init, - xsub_encode, - NULL, + .name = "xsub", + .type = AVMEDIA_TYPE_SUBTITLE, + .id = CODEC_ID_XSUB, + .init = xsub_encoder_init, + .encode = xsub_encode, .long_name = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"), }; diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c index 28c868d5ba..6211ca450d 100644 --- a/libavcodec/xxan.c +++ b/libavcodec/xxan.c @@ -415,15 +415,14 @@ static av_cold int xan_decode_end(AVCodecContext *avctx) } AVCodec ff_xan_wc4_decoder = { - "xan_wc4", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_XAN_WC4, - sizeof(XanContext), - xan_decode_init, - NULL, - xan_decode_end, - xan_decode_frame, - CODEC_CAP_DR1, + .name = "xan_wc4", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_XAN_WC4, + .priv_data_size = sizeof(XanContext), + .init = xan_decode_init, + .close = xan_decode_end, + .decode = xan_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Wing Commander IV / Xxan"), }; diff --git a/libavcodec/yop.c b/libavcodec/yop.c index e0b26544be..3c2d8b8957 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -248,13 +248,12 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size, } AVCodec ff_yop_decoder = { - "yop", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_YOP, - sizeof(YopDecContext), - yop_decode_init, - NULL, - yop_decode_close, - yop_decode_frame, + .name = "yop", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_YOP, + .priv_data_size = sizeof(YopDecContext), + .init = yop_decode_init, + .close = yop_decode_close, + .decode = yop_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Psygnosis YOP Video"), }; diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index deae580d20..10fd903b98 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -651,15 +651,14 @@ static av_cold int decode_end(AVCodecContext *avctx) } AVCodec ff_zmbv_decoder = { - "zmbv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ZMBV, - sizeof(ZmbvContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, + .name = "zmbv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ZMBV, + .priv_data_size = sizeof(ZmbvContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"), }; diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c index e4f4860ea0..2230436f90 100644 --- a/libavcodec/zmbvenc.c +++ b/libavcodec/zmbvenc.c @@ -324,13 +324,13 @@ static av_cold int encode_end(AVCodecContext *avctx) } AVCodec ff_zmbv_encoder = { - "zmbv", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ZMBV, - sizeof(ZmbvEncContext), - encode_init, - encode_frame, - encode_end, + .name = "zmbv", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ZMBV, + .priv_data_size = sizeof(ZmbvEncContext), + .init = encode_init, + .encode = encode_frame, + .close = encode_end, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_PAL8, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"), }; From 8f9d3f6d9a77be68215046fde7a3e0a12fe024f9 Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Fri, 29 Jul 2011 02:36:11 -0400 Subject: [PATCH 712/780] s302m: use nondeprecated audio sample format API Signed-off-by: Anton Khirnov --- libavcodec/s302m.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c index 2e261b612e..faaa8ed2f5 100644 --- a/libavcodec/s302m.c +++ b/libavcodec/s302m.c @@ -58,9 +58,9 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf, /* Set output properties */ avctx->bits_per_coded_sample = bits; if (bits > 16) - avctx->sample_fmt = SAMPLE_FMT_S32; + avctx->sample_fmt = AV_SAMPLE_FMT_S32; else - avctx->sample_fmt = SAMPLE_FMT_S16; + avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->channels = channels; avctx->sample_rate = 48000; From 298c4e3c522a1bc43cb557efe2e443be2ee80bb5 Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Thu, 14 Jul 2011 16:49:21 -0400 Subject: [PATCH 713/780] mpegts: remove invalid error check mpegts_read_header is used by both mpegts and mpegtsraw, so this erro check is no longer valid. Signed-off-by: Mike Williams Signed-off-by: Anton Khirnov --- libavformat/mpegts.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index b8f02ab8c5..e9b984dc11 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1470,10 +1470,6 @@ static int mpegts_read_header(AVFormatContext *s, if (ap) { if (ap->mpeg2ts_compute_pcr) ts->mpeg2ts_compute_pcr = ap->mpeg2ts_compute_pcr; - if(ap->mpeg2ts_raw){ - av_log(s, AV_LOG_ERROR, "use mpegtsraw_demuxer!\n"); - return -1; - } } #endif From 5ef953e84f0a272396bf11d7b780dec6c0e3ac00 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 28 Jul 2011 18:53:19 -0700 Subject: [PATCH 714/780] probe: Fix insane flow control. A loop control variable was shadowed inside the loop and never updated. --- libavformat/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 1ecbd61ff7..c4d7623c8c 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -501,9 +501,9 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, return AVERROR(EINVAL); } - for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt && ret >= 0; + for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt; probe_size = FFMIN(probe_size<<1, FFMAX(max_probe_size, probe_size+1))) { - int ret, score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0; + int score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0; int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1; if (probe_size < offset) { From d9c23a0d5a56488b146eef17a19a9b47643be333 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 29 Jul 2011 20:19:04 +0200 Subject: [PATCH 715/780] vf_transpose: avoid multiple calls to avfilter_draw_slice() avfilter_draw_slice() is already called in the end_frame() callback, this avoids multiple calls. This is done by adding a null draw_slice() callback. In particular fix crash occurring with -vf transpose=3,hflip, fix trac issue #371. --- libavfilter/vf_transpose.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index 8b11ae8d53..f4f72b9c64 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -195,6 +195,8 @@ static void end_frame(AVFilterLink *inlink) avfilter_unref_buffer(outpic); } +static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } + AVFilter avfilter_vf_transpose = { .name = "transpose", .description = NULL_IF_CONFIG_SMALL("Transpose input video."), @@ -207,6 +209,7 @@ AVFilter avfilter_vf_transpose = { .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .start_frame = start_frame, + .draw_slice = null_draw_slice, .end_frame = end_frame, .min_perms = AV_PERM_READ, }, { .name = NULL}}, From a3bf7b864acae5921f5de53b45945770e93e6237 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 27 Jul 2011 18:09:49 -0700 Subject: [PATCH 716/780] H.264: tweak some other x86 asm for Atom --- libavcodec/x86/dsputil_mmx.c | 4 +-- libavcodec/x86/h264_chromamc.asm | 44 +++++++++++++++----------------- libavcodec/x86/h264_deblock.asm | 19 +++++++------- libavcodec/x86/h264_idct.asm | 28 ++++++++++---------- libavcodec/x86/x86util.asm | 4 +-- 5 files changed, 48 insertions(+), 51 deletions(-) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index dd318a1399..9909fdab78 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -456,12 +456,12 @@ static void put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_si "movdqu (%1,%3), %%xmm1 \n\t" "movdqu (%1,%3,2), %%xmm2 \n\t" "movdqu (%1,%4), %%xmm3 \n\t" + "lea (%1,%3,4), %1 \n\t" "movdqa %%xmm0, (%2) \n\t" "movdqa %%xmm1, (%2,%3) \n\t" "movdqa %%xmm2, (%2,%3,2) \n\t" "movdqa %%xmm3, (%2,%4) \n\t" "subl $4, %0 \n\t" - "lea (%1,%3,4), %1 \n\t" "lea (%2,%3,4), %2 \n\t" "jnz 1b \n\t" : "+g"(h), "+r" (pixels), "+r" (block) @@ -478,6 +478,7 @@ static void avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_si "movdqu (%1,%3), %%xmm1 \n\t" "movdqu (%1,%3,2), %%xmm2 \n\t" "movdqu (%1,%4), %%xmm3 \n\t" + "lea (%1,%3,4), %1 \n\t" "pavgb (%2), %%xmm0 \n\t" "pavgb (%2,%3), %%xmm1 \n\t" "pavgb (%2,%3,2), %%xmm2 \n\t" @@ -487,7 +488,6 @@ static void avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_si "movdqa %%xmm2, (%2,%3,2) \n\t" "movdqa %%xmm3, (%2,%4) \n\t" "subl $4, %0 \n\t" - "lea (%1,%3,4), %1 \n\t" "lea (%2,%3,4), %2 \n\t" "jnz 1b \n\t" : "+g"(h), "+r" (pixels), "+r" (block) diff --git a/libavcodec/x86/h264_chromamc.asm b/libavcodec/x86/h264_chromamc.asm index 0a37994fb9..16cf2ec43e 100644 --- a/libavcodec/x86/h264_chromamc.asm +++ b/libavcodec/x86/h264_chromamc.asm @@ -72,17 +72,17 @@ SECTION .text .next4rows movq mm0, [r1 ] movq mm1, [r1+r2] + add r1, r4 CHROMAMC_AVG mm0, [r0 ] CHROMAMC_AVG mm1, [r0+r2] movq [r0 ], mm0 movq [r0+r2], mm1 add r0, r4 - add r1, r4 movq mm0, [r1 ] movq mm1, [r1+r2] + add r1, r4 CHROMAMC_AVG mm0, [r0 ] CHROMAMC_AVG mm1, [r0+r2] - add r1, r4 movq [r0 ], mm0 movq [r0+r2], mm1 add r0, r4 @@ -472,8 +472,8 @@ cglobal %1_%2_chroma_mc8_%3, 6, 7, 8 mov r6d, r4d shl r4d, 8 sub r4, r6 - add r4, 8 ; x*288+8 = x<<8 | (8-x) mov r6, 8 + add r4, 8 ; x*288+8 = x<<8 | (8-x) sub r6d, r5d imul r6, r4 ; (8-y)*(x*255+8) = (8-y)*x<<8 | (8-y)*(8-x) imul r4d, r5d ; y *(x*255+8) = y *x<<8 | y *(8-x) @@ -481,24 +481,23 @@ cglobal %1_%2_chroma_mc8_%3, 6, 7, 8 movd m7, r6d movd m6, r4d movdqa m5, [rnd_2d_%2] + movq m0, [r1 ] + movq m1, [r1+1] pshuflw m7, m7, 0 pshuflw m6, m6, 0 + punpcklbw m0, m1 movlhps m7, m7 movlhps m6, m6 - movq m0, [r1 ] - movq m1, [r1 +1] - punpcklbw m0, m1 - add r1, r2 .next2rows - movq m1, [r1 ] - movq m2, [r1 +1] - movq m3, [r1+r2 ] - movq m4, [r1+r2+1] + movq m1, [r1+r2*1 ] + movq m2, [r1+r2*1+1] + movq m3, [r1+r2*2 ] + movq m4, [r1+r2*2+1] lea r1, [r1+r2*2] punpcklbw m1, m2 - punpcklbw m3, m4 movdqa m2, m1 + punpcklbw m3, m4 movdqa m4, m3 pmaddubsw m0, m7 pmaddubsw m1, m6 @@ -508,8 +507,8 @@ cglobal %1_%2_chroma_mc8_%3, 6, 7, 8 paddw m2, m5 paddw m1, m0 paddw m3, m2 - movdqa m0, m4 psrlw m1, 6 + movdqa m0, m4 psrlw m3, 6 %ifidn %1, avg movq m2, [r0 ] @@ -576,6 +575,7 @@ cglobal %1_%2_chroma_mc8_%3, 6, 7, 8 movq m1, [r1+r2 ] movdqa m2, m1 movq m3, [r1+r2*2] + lea r1, [r1+r2*2] punpcklbw m0, m1 punpcklbw m2, m3 pmaddubsw m0, m7 @@ -594,7 +594,6 @@ cglobal %1_%2_chroma_mc8_%3, 6, 7, 8 movhps [r0+r2], m0 sub r3d, 2 lea r0, [r0+r2*2] - lea r1, [r1+r2*2] jg .next2yrows REP_RET %endmacro @@ -607,8 +606,8 @@ cglobal %1_%2_chroma_mc4_%3, 6, 7, 0 mov r6, r4 shl r4d, 8 sub r4d, r6d - add r4d, 8 ; x*288+8 mov r6, 8 + add r4d, 8 ; x*288+8 sub r6d, r5d imul r6d, r4d ; (8-y)*(x*255+8) = (8-y)*x<<8 | (8-y)*(8-x) imul r4d, r5d ; y *(x*255+8) = y *x<<8 | y *(8-x) @@ -616,17 +615,16 @@ cglobal %1_%2_chroma_mc4_%3, 6, 7, 0 movd m7, r6d movd m6, r4d movq m5, [pw_32] + movd m0, [r1 ] pshufw m7, m7, 0 + punpcklbw m0, [r1+1] pshufw m6, m6, 0 - movd m0, [r1 ] - punpcklbw m0, [r1 +1] - add r1, r2 .next2rows - movd m1, [r1 ] - movd m3, [r1+r2 ] - punpcklbw m1, [r1 +1] - punpcklbw m3, [r1+r2+1] + movd m1, [r1+r2*1 ] + movd m3, [r1+r2*2 ] + punpcklbw m1, [r1+r2*1+1] + punpcklbw m3, [r1+r2*2+1] lea r1, [r1+r2*2] movq m2, m1 movq m4, m3 @@ -638,8 +636,8 @@ cglobal %1_%2_chroma_mc4_%3, 6, 7, 0 paddw m2, m5 paddw m1, m0 paddw m3, m2 - movq m0, m4 psrlw m1, 6 + movq m0, m4 psrlw m3, 6 packuswb m1, m1 packuswb m3, m3 diff --git a/libavcodec/x86/h264_deblock.asm b/libavcodec/x86/h264_deblock.asm index 9831ca2cd6..92f91acade 100644 --- a/libavcodec/x86/h264_deblock.asm +++ b/libavcodec/x86/h264_deblock.asm @@ -240,17 +240,17 @@ cextern pb_A1 ; out: m1=p0' m2=q0' ; clobbers: m0,3-6 %macro DEBLOCK_P0_Q0 0 - pxor m5, m1, m2 ; p0^q0 - pand m5, [pb_1] ; (p0^q0)&1 pcmpeqb m4, m4 + pxor m5, m1, m2 ; p0^q0 pxor m3, m4 + pand m5, [pb_1] ; (p0^q0)&1 pavgb m3, m0 ; (p1 - q1 + 256)>>1 - pavgb m3, [pb_3] ; (((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2 pxor m4, m1 + pavgb m3, [pb_3] ; (((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2 pavgb m4, m2 ; (q0 - p0 + 256)>>1 pavgb m3, m5 - paddusb m3, m4 ; d+128+33 mova m6, [pb_A1] + paddusb m3, m4 ; d+128+33 psubusb m6, m3 psubusb m3, [pb_A1] pminub m6, m7 @@ -411,16 +411,16 @@ cglobal deblock_%2_luma_8_%1, 5,5 LOAD_MASK r2, r3 mov r3, r4mp + pcmpeqb m3, m3 movd m4, [r3] ; tc0 punpcklbw m4, m4 punpcklbw m4, m4 ; tc = 4x tc0[3], 4x tc0[2], 4x tc0[1], 4x tc0[0] mova [esp+%3], m4 ; tc - pcmpeqb m3, m3 pcmpgtb m4, m3 + mova m3, [r4] ; p2 pand m4, m7 mova [esp], m4 ; mask - mova m3, [r4] ; p2 DIFF_GT2 m1, m3, m5, m6, m7 ; |p2-p0| > beta-1 pand m6, m4 pand m4, [esp+%3] ; tc @@ -430,11 +430,10 @@ cglobal deblock_%2_luma_8_%1, 5,5 mova m4, [r0+2*r1] ; q2 DIFF_GT2 m2, m4, m5, m6, m3 ; |q2-q0| > beta-1 - mova m5, [esp] ; mask - pand m6, m5 + pand m6, [esp] ; mask mova m5, [esp+%3] ; tc - pand m5, m6 psubb m7, m6 + pand m5, m6 mova m3, [r0+r1] LUMA_Q1 m3, m4, [r0+2*r1], [r0+r1], m5, m6 @@ -482,10 +481,10 @@ cglobal deblock_h_luma_8_%1, 0,5 ; transpose 16x4 -> original space (only the middle 4 rows were changed by the filter) mov r0, r0mp sub r0, 2 - lea r1, [r0+r4] movq m0, [pix_tmp+0x10] movq m1, [pix_tmp+0x20] + lea r1, [r0+r4] movq m2, [pix_tmp+0x30] movq m3, [pix_tmp+0x40] TRANSPOSE8x4B_STORE PASS8ROWS(r0, r1, r3, r4) diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm index 4788da98e0..37c2c90476 100644 --- a/libavcodec/x86/h264_idct.asm +++ b/libavcodec/x86/h264_idct.asm @@ -82,10 +82,10 @@ cglobal h264_idct_add_8_mmx, 3, 3, 0 RET %macro IDCT8_1D 2 - mova m4, m5 mova m0, m1 - psraw m4, 1 psraw m1, 1 + mova m4, m5 + psraw m4, 1 paddw m4, m5 paddw m1, m0 paddw m4, m7 @@ -95,16 +95,16 @@ cglobal h264_idct_add_8_mmx, 3, 3, 0 psubw m0, m3 psubw m5, m3 + psraw m3, 1 paddw m0, m7 psubw m5, m7 - psraw m3, 1 psraw m7, 1 psubw m0, m3 psubw m5, m7 - mova m3, m4 mova m7, m1 psraw m1, 2 + mova m3, m4 psraw m3, 2 paddw m3, m0 psraw m0, 2 @@ -113,12 +113,12 @@ cglobal h264_idct_add_8_mmx, 3, 3, 0 psubw m0, m4 psubw m7, m5 - mova m4, m2 mova m5, m6 - psraw m4, 1 psraw m6, 1 - psubw m4, m5 + mova m4, m2 + psraw m4, 1 paddw m6, m2 + psubw m4, m5 mova m2, %1 mova m5, %2 @@ -337,7 +337,7 @@ cglobal h264_idct8_add4_8_mmx, 5, 7, 0 test r6, r6 jz .skipblock mov r6d, dword [r1+r5*4] - lea r6, [r0+r6] + add r6, r0 add word [r2], 32 IDCT8_ADD_MMX_START r2 , rsp IDCT8_ADD_MMX_START r2+8, rsp+64 @@ -391,7 +391,7 @@ cglobal h264_idct_add16_8_mmx2, 5, 7, 0 REP_RET .no_dc mov r6d, dword [r1+r5*4] - lea r6, [r0+r6] + add r6, r0 IDCT4_ADD r6, r2, r3 .skipblock inc r5 @@ -414,7 +414,7 @@ cglobal h264_idct_add16intra_8_mmx, 5, 7, 0 test r6, r6 jz .skipblock mov r6d, dword [r1+r5*4] - lea r6, [r0+r6] + add r6, r0 IDCT4_ADD r6, r2, r3 .skipblock inc r5 @@ -456,7 +456,7 @@ cglobal h264_idct_add16intra_8_mmx2, 5, 7, 0 %define dst_regd r1d %endif mov dst_regd, dword [r1+r5*4] - lea dst_reg, [r0+dst_reg] + add dst_reg, r0 DC_ADD_MMX2_OP movh, dst_reg, r3, r6 %ifndef ARCH_X86_64 mov r1, r1m @@ -513,7 +513,7 @@ cglobal h264_idct8_add4_8_mmx2, 5, 7, 0 RET .no_dc mov r6d, dword [r1+r5*4] - lea r6, [r0+r6] + add r6, r0 add word [r2], 32 IDCT8_ADD_MMX_START r2 , rsp IDCT8_ADD_MMX_START r2+8, rsp+64 @@ -558,7 +558,7 @@ INIT_MMX %define dst_regd r1d %endif mov dst_regd, dword [r1+r5*4] - lea dst_reg, [r0+dst_reg] + add dst_reg, r0 DC_ADD_MMX2_OP mova, dst_reg, r3, r6 lea dst_reg, [dst_reg+r3*4] DC_ADD_MMX2_OP mova, dst_reg, r3, r6 @@ -573,7 +573,7 @@ INIT_MMX .no_dc INIT_XMM mov dst_regd, dword [r1+r5*4] - lea dst_reg, [r0+dst_reg] + add dst_reg, r0 IDCT8_ADD_SSE dst_reg, r2, r3, r6 %ifndef ARCH_X86_64 mov r1, r1m diff --git a/libavcodec/x86/x86util.asm b/libavcodec/x86/x86util.asm index 45196625fe..5f39107379 100644 --- a/libavcodec/x86/x86util.asm +++ b/libavcodec/x86/x86util.asm @@ -497,10 +497,10 @@ %macro STORE_DIFFx2 8 ; add1, add2, reg1, reg2, zero, shift, source, stride movh %3, [%7] movh %4, [%7+%8] - punpcklbw %3, %5 - punpcklbw %4, %5 psraw %1, %6 psraw %2, %6 + punpcklbw %3, %5 + punpcklbw %4, %5 paddw %3, %1 paddw %4, %2 packuswb %3, %5 From 1f6f58d5855288492fc2640a9f1035c01c75d356 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 29 Jul 2011 15:27:36 -0700 Subject: [PATCH 717/780] mxfdec: Include FF_INPUT_BUFFER_PADDING_SIZE when allocating extradata. This prevents out of bounds reads when extradata is being decoded. --- libavformat/mxfdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index e2688b1bff..8906bdd78f 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -600,7 +600,7 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int default: /* Private uid used by SONY C0023S01.mxf */ if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) { - descriptor->extradata = av_malloc(size); + descriptor->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); if (!descriptor->extradata) return -1; descriptor->extradata_size = size; From 0e29c4f761575d60c764e56ed1d07b432eaf0262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sat, 30 Jul 2011 11:22:11 +0200 Subject: [PATCH 718/780] Revert bink dequantization hack that is no longer necessary. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Reimar Döffinger --- libavcodec/bink.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 534d63b5a6..6b58f7716b 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -572,22 +572,6 @@ static inline int binkb_get_value(BinkContext *c, int bundle_num) return ret; } -static inline DCTELEM dequant(DCTELEM in, uint32_t quant, int dc) -{ - /* Note: multiplication is unsigned but we want signed shift - * otherwise clipping breaks. - * TODO: The official decoder does not use clipping at all - * but instead uses the full 32-bit result. - * However clipping at least gets rid of the case that a - * half-black half-white intra block gets black and white swapped - * and should cause at most minor differences (except for DC). */ - int32_t res = in * quant; - res >>= 11; - if (!dc) - res = av_clip_int16(res); - return res; -} - /** * Read 8x8 block of DCT coefficients. * @@ -686,10 +670,10 @@ static int read_dct_coeffs(GetBitContext *gb, int32_t block[64], const uint8_t * quant = quant_matrices[quant_idx]; - block[0] = dequant(block[0], quant[0], 1); + block[0] = (block[0] * quant[0]) >> 11; for (i = 0; i < coef_count; i++) { int idx = coef_idx[i]; - block[scan[idx]] = dequant(block[scan[idx]], quant[idx], 0); + block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11; } return 0; From 8a54bfe83f3387072fb2044096d073c973739ed1 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sat, 30 Jul 2011 11:01:17 +0200 Subject: [PATCH 719/780] build: make examples build normally The link target was missing $(EXAMPLES) --- subdir.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subdir.mak b/subdir.mak index e6d52953b5..e269b509ce 100644 --- a/subdir.mak +++ b/subdir.mak @@ -34,7 +34,7 @@ install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared define RULES -$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o +$(EXAMPLES) $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $$(LD) $(LDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS) $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR) From 61d55fda2b513caf18e37b27aba680a87840904a Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 27 Jul 2011 10:58:24 +0200 Subject: [PATCH 720/780] lavfi: tweak display aspect ratio variables in pad and scale filters Previously, "dar" and "a" were documented like "input display aspect ratio", but their actual value was "in_w/in_h". In order to avoid to break scripts which rely on the "a" variable, the patch keeps the same semantics but fixes the corresponding docs, and fixes the semantics of the recently added "dar" variable, which now correctly expresses the input Display Aspect Ratio value as "(inw_w/in_h)*sar". --- doc/filters.texi | 14 ++++++++++---- libavfilter/avfilter.h | 2 +- libavfilter/vf_pad.c | 9 ++++++--- libavfilter/vf_scale.c | 9 ++++++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 8054bffb1d..2e419a8edf 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1184,12 +1184,15 @@ same as @var{out_w} and @var{out_h} x and y offsets as specified by the @var{x} and @var{y} expressions, or NAN if not yet specified -@item dar, a -input display aspect ratio, same as @var{iw} / @var{ih} +@item a +same as @var{iw} / @var{ih} @item sar input sample aspect ratio +@item dar +input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar} + @item hsub, vsub horizontal and vertical chroma subsample values. For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. @@ -1289,12 +1292,15 @@ the output (cropped) width and heigth @item ow, oh same as @var{out_w} and @var{out_h} -@item dar, a -input display aspect ratio, same as @var{iw} / @var{ih} +@item a +same as @var{iw} / @var{ih} @item sar input sample aspect ratio +@item dar +input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar} + @item hsub, vsub horizontal and vertical chroma subsample values. For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 913a52b22f..6746176c0d 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 27 -#define LIBAVFILTER_VERSION_MICRO 3 +#define LIBAVFILTER_VERSION_MICRO 4 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index e01a750d94..c4edc23cc5 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -45,8 +45,9 @@ static const char *var_names[] = { "out_h", "oh", "x", "y", - "a", "dar", + "a", "sar", + "dar", "hsub", "vsub", NULL @@ -62,8 +63,9 @@ enum var_name { VAR_OUT_H, VAR_OH, VAR_X, VAR_Y, - VAR_A, VAR_DAR, + VAR_A, VAR_SAR, + VAR_DAR, VAR_HSUB, VAR_VSUB, VARS_NB @@ -158,9 +160,10 @@ static int config_input(AVFilterLink *inlink) var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; - var_values[VAR_DAR] = var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_A] = (float) inlink->w / inlink->h; var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? (float) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; + var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR]; var_values[VAR_HSUB] = 1<hsub; var_values[VAR_VSUB] = 1<vsub; diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 3be5d99e96..044b2843bc 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -39,8 +39,9 @@ static const char *var_names[] = { "in_h", "ih", "out_w", "ow", "out_h", "oh", - "a", "dar", + "a", "sar", + "dar", "hsub", "vsub", NULL @@ -54,8 +55,9 @@ enum var_name { VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH, - VAR_A, VAR_DAR, + VAR_A, VAR_SAR, + VAR_DAR, VAR_HSUB, VAR_VSUB, VARS_NB @@ -160,9 +162,10 @@ static int config_props(AVFilterLink *outlink) var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; - var_values[VAR_DAR] = var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_A] = (float) inlink->w / inlink->h; var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? (float) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; + var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR]; var_values[VAR_HSUB] = 1<format].log2_chroma_w; var_values[VAR_VSUB] = 1<format].log2_chroma_h; From 45f9e053d8bf15ed0417155e57d16d1fdce0446e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 4 Jul 2011 13:28:37 +0200 Subject: [PATCH 721/780] vf_crop: add support for a, dar, sar, hsub, and vsub variables Consistent with the pad and scale filters. --- doc/filters.texi | 13 +++++++++++++ libavfilter/avfilter.h | 2 +- libavfilter/vf_crop.c | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index 2e419a8edf..68a82b79e8 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -275,6 +275,19 @@ the output (cropped) width and heigth @item ow, oh same as @var{out_w} and @var{out_h} +@item a +same as @var{iw} / @var{ih} + +@item sar +input sample aspect ratio + +@item dar +input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar} + +@item hsub, vsub +horizontal and vertical chroma subsample values. For example for the +pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. + @item n the number of input frame, starting from 0 diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 6746176c0d..1f26654559 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 27 -#define LIBAVFILTER_VERSION_MICRO 4 +#define LIBAVFILTER_VERSION_MICRO 5 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index b9c60cb65b..fb084041ab 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -40,6 +40,11 @@ static const char *var_names[] = { "in_h", "ih", ///< height of the input video "out_w", "ow", ///< width of the cropped video "out_h", "oh", ///< height of the cropped video + "a", + "sar", + "dar", + "hsub", + "vsub", "x", "y", "n", ///< number of frame @@ -56,6 +61,11 @@ enum var_name { VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH, + VAR_A, + VAR_SAR, + VAR_DAR, + VAR_HSUB, + VAR_VSUB, VAR_X, VAR_Y, VAR_N, @@ -162,6 +172,11 @@ static int config_input(AVFilterLink *link) crop->var_values[VAR_PI] = M_PI; crop->var_values[VAR_IN_W] = crop->var_values[VAR_IW] = ctx->inputs[0]->w; crop->var_values[VAR_IN_H] = crop->var_values[VAR_IH] = ctx->inputs[0]->h; + crop->var_values[VAR_A] = (float) link->w / link->h; + crop->var_values[VAR_SAR] = link->sample_aspect_ratio.num ? av_q2d(link->sample_aspect_ratio) : 1; + crop->var_values[VAR_DAR] = crop->var_values[VAR_A] * crop->var_values[VAR_SAR]; + crop->var_values[VAR_HSUB] = 1<log2_chroma_w; + crop->var_values[VAR_VSUB] = 1<log2_chroma_h; crop->var_values[VAR_X] = NAN; crop->var_values[VAR_Y] = NAN; crop->var_values[VAR_OUT_W] = crop->var_values[VAR_OW] = NAN; From 9959a76782861a438f5a007086509bbc507022d8 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 30 Jul 2011 18:15:08 +0200 Subject: [PATCH 722/780] ffplay: set input link sample aspect ratio in input_config_props() Allow sample_aspect_ratio information to be correctly propagated in the filterchain. --- ffplay.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ffplay.c b/ffplay.c index 6bdf4b6a4d..eb9d81bd15 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1652,6 +1652,7 @@ static int input_config_props(AVFilterLink *link) link->w = c->width; link->h = c->height; + link->sample_aspect_ratio = priv->is->video_st->sample_aspect_ratio; link->time_base = priv->is->video_st->time_base; return 0; From 3b5ddf07c0c4ab6a0d347d92ff8d9cfbac6b66ed Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 30 Jul 2011 18:23:24 +0200 Subject: [PATCH 723/780] vf_pad: add an example employing the sar variable --- doc/filters.texi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 68a82b79e8..27474024a9 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1264,6 +1264,12 @@ pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2" # pad the input to get a final w/h ratio of 16:9 pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2" +# for anamorphic video, in order to set the output display aspect ratio, +# it is necessary to use sar in the expression, according to the relation: +# (ih * X / ih) * sar = output_dar +# X = output_dar / sar +pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2" + # double output size and put the input video in the bottom-right # corner of the output padded area pad="2*iw:2*ih:ow-iw:oh-ih" From 42ba12888b9296977237f2bca0027d8b017011db Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 29 Jul 2011 12:55:01 +0200 Subject: [PATCH 724/780] Do not convert RGB buffer at once when stride does not fit exact samples. When converting RGB format to RGB format with the same bits per sample, unscaled path performs conversion on the whole buffer at once. For non-multiple-of-16 BGR24 to RGB24 conversion it means that padding at the end of line will be converted too. Since it may be of arbitrary length (e.g. 8 bytes), operating on the whole buffer produces obviously wrong results. Signed-off-by: Ronald S. Bultje --- libswscale/swscale_unscaled.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 59f31c6f64..c0161c24e9 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -382,7 +382,7 @@ static int rgbToRgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], if ((dstFormat == PIX_FMT_RGB32_1 || dstFormat == PIX_FMT_BGR32_1) && !isRGBA32(srcFormat)) dstPtr += ALT32_CORR; - if (dstStride[0]*srcBpp == srcStride[0]*dstBpp && srcStride[0] > 0) + if (dstStride[0]*srcBpp == srcStride[0]*dstBpp && srcStride[0] > 0 && !(srcStride[0] % srcBpp)) conv(srcPtr, dstPtr + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]); else { int i; From 085791a92e239875fed560c34db87e98083f4092 Mon Sep 17 00:00:00 2001 From: Yu-Jie Lin Date: Sat, 30 Jul 2011 18:46:36 +0800 Subject: [PATCH 725/780] x11grab: add follow_mouse AVOption. -follow_mouse centered|PIXELS move grabbing region to where mouse pointer at the center; or only move when pointer reaches within PIXELS to the edge. Signed-off-by: Yu-Jie Lin Signed-off-by: Anton Khirnov --- doc/ffmpeg.texi | 17 ++++++++++-- doc/indevs.texi | 22 ++++++++++++++- libavdevice/x11grab.c | 62 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 95 insertions(+), 6 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 4dca5d8991..8d3968dbf2 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -900,8 +900,21 @@ the DISPLAY environment variable. ffmpeg -f x11grab -s cif -r 25 -i :0.0+10,20 /tmp/out.mpg @end example -0.0 is display.screen number of your X11 server, same as the DISPLAY environment -variable. 10 is the x-offset and 20 the y-offset for the grabbing. +10 is the x-offset and 20 the y-offset for the grabbing. + +@example +ffmpeg -f x11grab -follow_mouse centered -s cif -r 25 -i :0.0 /tmp/out.mpg +@end example + +The grabbing region follows the mouse pointer, which stays at the center of +region. + +@example +ffmpeg -f x11grab -follow_mouse 100 -s cif -r 25 -i :0.0 /tmp/out.mpg +@end example + +Only follows when mouse pointer reaches within 100 pixels to the edge of +region. @section Video and Audio file format conversion diff --git a/doc/indevs.texi b/doc/indevs.texi index c5e04b029e..aa001cdb63 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -248,7 +248,27 @@ For example to grab from @file{:0.0} using @file{ffmpeg}: ffmpeg -f x11grab -r 25 -s cif -i :0.0 out.mpg # Grab at position 10,20. -ffmpeg -f x11grab -25 -s cif -i :0.0+10,20 out.mpg +ffmpeg -f x11grab -r 25 -s cif -i :0.0+10,20 out.mpg +@end example + +@subsection @var{follow_mouse} AVOption + +The syntax is: +@example +-follow_mouse centered|@var{PIXELS} +@end example + +When it is specified with "centered", the grabbing region follows the mouse +pointer and keeps the pointer at the center of region; otherwise, the region +follows only when the mouse pointer reaches within @var{PIXELS} (greater than +zero) to the edge of region. + +For example: +@example +ffmpeg -f x11grab -follow_mouse centered -r 25 -s cif -i :0.0 out.mpg + +# Follows only when the mouse pointer reaches within 100 pixels to edge +ffmpeg -f x11grab -follow_mouse 100 -r 25 -s cif -i :0.0 out.mpg @end example @c man end INPUT DEVICES diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 80507abb05..0b865ad71e 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -71,6 +71,7 @@ struct x11_grab int use_shm; /**< !0 when using XShm extension */ XShmSegmentInfo shminfo; /**< When using XShm, keeps track of XShm infos */ int draw_mouse; /**< Set by a private option. */ + int follow_mouse; /**< Set by a private option. */ char *framerate; /**< Set by a private option. */ }; @@ -95,6 +96,7 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) XImage *image; int x_off = 0; int y_off = 0; + int screen; int use_shm; char *param, *offset; int ret = 0; @@ -141,6 +143,22 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) } av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ + screen = DefaultScreen(dpy); + + if (x11grab->follow_mouse) { + int screen_w, screen_h; + Window w; + + screen_w = DisplayWidth(dpy, screen); + screen_h = DisplayHeight(dpy, screen); + XQueryPointer(dpy, RootWindow(dpy, screen), &w, &w, &x_off, &y_off, &ret, &ret, &ret); + x_off -= x11grab->width / 2; + y_off -= x11grab->height / 2; + x_off = FFMIN(FFMAX(x_off, 0), screen_w - x11grab->width); + y_off = FFMIN(FFMAX(y_off, 0), screen_h - x11grab->height); + av_log(s1, AV_LOG_INFO, "followmouse is enabled, resetting grabbing region to x: %d y: %d\n", x_off, y_off); + } + use_shm = XShmQueryExtension(dpy); av_log(s1, AV_LOG_INFO, "shared memory extension %s found\n", use_shm ? "" : "not"); @@ -171,7 +189,7 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) goto out; } } else { - image = XGetImage(dpy, RootWindow(dpy, DefaultScreen(dpy)), + image = XGetImage(dpy, RootWindow(dpy, screen), x_off,y_off, x11grab->width, x11grab->height, AllPlanes, ZPixmap); @@ -374,6 +392,10 @@ x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt) int x_off = s->x_off; int y_off = s->y_off; + int screen; + Window root; + int follow_mouse = s->follow_mouse; + int64_t curtime, delay; struct timespec ts; @@ -400,12 +422,43 @@ x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt) pkt->size = s->frame_size; pkt->pts = curtime; + screen = DefaultScreen(dpy); + root = RootWindow(dpy, screen); + if (follow_mouse) { + int screen_w, screen_h; + int pointer_x, pointer_y, _; + Window w; + + screen_w = DisplayWidth(dpy, screen); + screen_h = DisplayHeight(dpy, screen); + XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_); + if (follow_mouse == -1) { + // follow the mouse, put it at center of grabbing region + x_off += pointer_x - s->width / 2 - x_off; + y_off += pointer_y - s->height / 2 - y_off; + } else { + // follow the mouse, but only move the grabbing region when mouse + // reaches within certain pixels to the edge. + if (pointer_x > x_off + s->width - follow_mouse) { + x_off += pointer_x - (x_off + s->width - follow_mouse); + } else if (pointer_x < x_off + follow_mouse) + x_off -= (x_off + follow_mouse) - pointer_x; + if (pointer_y > y_off + s->height - follow_mouse) { + y_off += pointer_y - (y_off + s->height - follow_mouse); + } else if (pointer_y < y_off + follow_mouse) + y_off -= (y_off + follow_mouse) - pointer_y; + } + // adjust grabbing region position if it goes out of screen. + s->x_off = x_off = FFMIN(FFMAX(x_off, 0), screen_w - s->width); + s->y_off = y_off = FFMIN(FFMAX(y_off, 0), screen_h - s->height); + } + if(s->use_shm) { - if (!XShmGetImage(dpy, RootWindow(dpy, DefaultScreen(dpy)), image, x_off, y_off, AllPlanes)) { + if (!XShmGetImage(dpy, root, image, x_off, y_off, AllPlanes)) { av_log (s1, AV_LOG_INFO, "XShmGetImage() failed\n"); } } else { - if (!xget_zpixmap(dpy, RootWindow(dpy, DefaultScreen(dpy)), image, x_off, y_off)) { + if (!xget_zpixmap(dpy, root, image, x_off, y_off)) { av_log (s1, AV_LOG_INFO, "XGetZPixmap() failed\n"); } } @@ -452,6 +505,9 @@ static const AVOption options[] = { { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC }, { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, { "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), FF_OPT_TYPE_INT, { 1 }, 0, 1, DEC }, + { "follow_mouse", "Move the grabbing region when the mouse pointer reaches within specified amount of pixels to the edge of region.", + OFFSET(follow_mouse), FF_OPT_TYPE_INT, { 0 }, -1, INT_MAX, DEC, "follow_mouse" }, + { "centered", "Keep the mouse pointer at the center of grabbing region when following.", 0, FF_OPT_TYPE_CONST, { -1 }, INT_MIN, INT_MAX, DEC, "follow_mouse" }, { NULL }, }; From 1442d295337dfc83fb66b20444c1b09a803ebb80 Mon Sep 17 00:00:00 2001 From: Yu-Jie Lin Date: Sat, 30 Jul 2011 19:13:43 +0800 Subject: [PATCH 726/780] x11grab: add show_region AVOption. Draw the current grabbing region for indication. Signed-off-by: Yu-Jie Lin Signed-off-by: Anton Khirnov --- doc/ffmpeg.texi | 13 +++++++ doc/indevs.texi | 19 ++++++++++ libavdevice/x11grab.c | 87 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 8d3968dbf2..f3a4689d6c 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -916,6 +916,19 @@ ffmpeg -f x11grab -follow_mouse 100 -s cif -r 25 -i :0.0 /tmp/out.mpg Only follows when mouse pointer reaches within 100 pixels to the edge of region. +@example +ffmpeg -f x11grab -show_region 1 -s cif -r 25 -i :0.0+10,20 /tmp/out.mpg +@end example + +The grabbing region will be indicated on screen. + +@example +ffmpeg -f x11grab -follow_mouse centered -show_region 1 -s cif -r 25 -i :0.0 /tmp/out.mpg +@end example + +The grabbing region indication will follow the mouse pointer. + + @section Video and Audio file format conversion Any supported file format and protocol can serve as input to ffmpeg: diff --git a/doc/indevs.texi b/doc/indevs.texi index aa001cdb63..fa21c099d5 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -271,4 +271,23 @@ ffmpeg -f x11grab -follow_mouse centered -r 25 -s cif -i :0.0 out.mpg ffmpeg -f x11grab -follow_mouse 100 -r 25 -s cif -i :0.0 out.mpg @end example +@subsection @var{show_region} AVOption + +The syntax is: +@example +-show_region 1 +@end example + +If @var{show_region} AVOption is specified with @var{1}, then the grabbing +region will be indicated on screen. With this option, it's easy to know what is +being grabbed if only a portion of the screen is grabbed. + +For example: +@example +ffmpeg -f x11grab -show_region 1 -r 25 -s cif -i :0.0+10,20 out.mpg + +# With follow_mouse +ffmpeg -f x11grab -follow_mouse centered -show_region 1 -r 25 -s cif -i :0.0 out.mpg +@end example + @c man end INPUT DEVICES diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 0b865ad71e..09f6b51161 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -72,9 +73,73 @@ struct x11_grab XShmSegmentInfo shminfo; /**< When using XShm, keeps track of XShm infos */ int draw_mouse; /**< Set by a private option. */ int follow_mouse; /**< Set by a private option. */ + int show_region; /**< set by a private option. */ char *framerate; /**< Set by a private option. */ + + Window region_win; /**< This is used by show_region option. */ }; +#define REGION_WIN_BORDER 3 +/** + * Draw grabbing region window + * + * @param s x11_grab context + */ +static void +x11grab_draw_region_win(struct x11_grab *s) +{ + Display *dpy = s->dpy; + int screen; + Window win = s->region_win; + GC gc; + + screen = DefaultScreen(dpy); + gc = XCreateGC(dpy, win, 0, 0); + XSetForeground(dpy, gc, WhitePixel(dpy, screen)); + XSetBackground(dpy, gc, BlackPixel(dpy, screen)); + XSetLineAttributes(dpy, gc, REGION_WIN_BORDER, LineDoubleDash, 0, 0); + XDrawRectangle(dpy, win, gc, + 1, 1, + (s->width + REGION_WIN_BORDER * 2) - 1 * 2 - 1, + (s->height + REGION_WIN_BORDER * 2) - 1 * 2 - 1); + XFreeGC(dpy, gc); +} + +/** + * Initialize grabbing region window + * + * @param s x11_grab context + */ +static void +x11grab_region_win_init(struct x11_grab *s) +{ + Display *dpy = s->dpy; + int screen; + XSetWindowAttributes attribs; + XRectangle rect; + + screen = DefaultScreen(dpy); + attribs.override_redirect = True; + s->region_win = XCreateWindow(dpy, RootWindow(dpy, screen), + s->x_off - REGION_WIN_BORDER, + s->y_off - REGION_WIN_BORDER, + s->width + REGION_WIN_BORDER * 2, + s->height + REGION_WIN_BORDER * 2, + 0, CopyFromParent, + InputOutput, CopyFromParent, + CWOverrideRedirect, &attribs); + rect.x = 0; + rect.y = 0; + rect.width = s->width; + rect.height = s->height; + XShapeCombineRectangles(dpy, s->region_win, + ShapeBounding, REGION_WIN_BORDER, REGION_WIN_BORDER, + &rect, 1, ShapeSubtract, 0); + XMapWindow(dpy, s->region_win); + XSelectInput(dpy, s->region_win, ExposureMask | StructureNotifyMask); + x11grab_draw_region_win(s); +} + /** * Initialize the x11 grab device demuxer (public device demuxer API). * @@ -451,6 +516,23 @@ x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt) // adjust grabbing region position if it goes out of screen. s->x_off = x_off = FFMIN(FFMAX(x_off, 0), screen_w - s->width); s->y_off = y_off = FFMIN(FFMAX(y_off, 0), screen_h - s->height); + + if (s->show_region && s->region_win) + XMoveWindow(dpy, s->region_win, + s->x_off - REGION_WIN_BORDER, + s->y_off - REGION_WIN_BORDER); + } + + if (s->show_region) { + if (s->region_win) { + XEvent evt; + // clean up the events, and do the initinal draw or redraw. + for (evt.type = NoEventMask; XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask, &evt); ); + if (evt.type) + x11grab_draw_region_win(s); + } else { + x11grab_region_win_init(s); + } } if(s->use_shm) { @@ -494,6 +576,10 @@ x11grab_read_close(AVFormatContext *s1) x11grab->image = NULL; } + if (x11grab->region_win) { + XDestroyWindow(x11grab->dpy, x11grab->region_win); + } + /* Free X11 display */ XCloseDisplay(x11grab->dpy); return 0; @@ -508,6 +594,7 @@ static const AVOption options[] = { { "follow_mouse", "Move the grabbing region when the mouse pointer reaches within specified amount of pixels to the edge of region.", OFFSET(follow_mouse), FF_OPT_TYPE_INT, { 0 }, -1, INT_MAX, DEC, "follow_mouse" }, { "centered", "Keep the mouse pointer at the center of grabbing region when following.", 0, FF_OPT_TYPE_CONST, { -1 }, INT_MIN, INT_MAX, DEC, "follow_mouse" }, + { "show_region", "Show the grabbing region.", OFFSET(show_region), FF_OPT_TYPE_INT, { 0 }, 0, 1, DEC }, { NULL }, }; From b39f872a41b92a31589052c8f914c5b52f206fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sat, 30 Jul 2011 11:45:15 +0200 Subject: [PATCH 727/780] Limit fsize before adding to pointer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids a theoretically possible pointer arithmetic overflow which would lead to a crash due to reading from NULL page. Signed-off-by: Reimar Döffinger --- libavformat/aacdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index ded11b6854..c3a5029260 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -47,6 +47,7 @@ static int adts_aac_probe(AVProbeData *p) fsize = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF; if(fsize < 7) break; + fsize = FFMIN(fsize, end - buf2); buf2 += fsize; } max_frames = FFMAX(max_frames, frames); From 18cb40f074ec7e79b20bf9b8c8f19c55784a071c Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Fri, 29 Jul 2011 03:25:34 -0400 Subject: [PATCH 728/780] lavc: Deprecate unused FF_ER_VERY_AGGRESSIVE Signed-off-by: Ronald S. Bultje --- doc/ffmpeg.texi | 2 -- libavcodec/avcodec.h | 4 ++++ libavcodec/options.c | 2 ++ libavcodec/version.h | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index f3a4689d6c..ca801d31e4 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -469,8 +469,6 @@ FF_ER_COMPLIANT @item 3 FF_ER_AGGRESSIVE @item 4 -FF_ER_VERY_AGGRESSIVE -@item 5 FF_ER_EXPLODE @end table diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 75c107c159..e1fd475ca6 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1445,8 +1445,12 @@ typedef struct AVCodecContext { #define FF_ER_CAREFUL 1 #define FF_ER_COMPLIANT 2 #define FF_ER_AGGRESSIVE 3 +#if FF_API_VERY_AGGRESSIVE #define FF_ER_VERY_AGGRESSIVE 4 #define FF_ER_EXPLODE 5 +#else +#define FF_ER_EXPLODE 4 +#endif /* FF_API_VERY_AGGRESSIVE */ /** * Called at the beginning of each frame to get a buffer for it. diff --git a/libavcodec/options.c b/libavcodec/options.c index 0f0ca2aaa3..1ee02c0417 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -183,7 +183,9 @@ static const AVOption options[]={ {"careful", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, V|D, "er"}, {"compliant", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_COMPLIANT }, INT_MIN, INT_MAX, V|D, "er"}, {"aggressive", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, +#if FF_API_VERY_AGGRESSIVE {"very_aggressive", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_VERY_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, +#endif /* FF_API_VERY_AGGRESSIVE */ {"explode", "abort decoding on error recognition", 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, V|D, "er"}, {"has_b_frames", NULL, OFFSET(has_b_frames), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, {"block_align", NULL, OFFSET(block_align), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, diff --git a/libavcodec/version.h b/libavcodec/version.h index 8d40899557..46e54990b1 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -77,5 +77,8 @@ #ifndef FF_API_DRC_SCALE #define FF_API_DRC_SCALE (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_VERY_AGGRESSIVE +#define FF_API_VERY_AGGRESSIVE (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ From 7747a091f57b1e995a524854b397925a38d82cfb Mon Sep 17 00:00:00 2001 From: Naoya OYAMA Date: Mon, 1 Aug 2011 00:17:45 +0200 Subject: [PATCH 729/780] Cosmetics: Fix indentation. --- libavformat/spdifenc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c index 04d4845bb8..84372f82da 100644 --- a/libavformat/spdifenc.c +++ b/libavformat/spdifenc.c @@ -518,13 +518,13 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt) } if (ctx->extra_bswap ^ (ctx->spdif_flags & SPDIF_FLAG_BIGENDIAN)) { - avio_write(s->pb, ctx->out_buf, ctx->out_bytes & ~1); + avio_write(s->pb, ctx->out_buf, ctx->out_bytes & ~1); } else { - av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + FF_INPUT_BUFFER_PADDING_SIZE); - if (!ctx->buffer) - return AVERROR(ENOMEM); - ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)ctx->out_buf, ctx->out_bytes >> 1); - avio_write(s->pb, ctx->buffer, ctx->out_bytes & ~1); + av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + FF_INPUT_BUFFER_PADDING_SIZE); + if (!ctx->buffer) + return AVERROR(ENOMEM); + ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)ctx->out_buf, ctx->out_bytes >> 1); + avio_write(s->pb, ctx->buffer, ctx->out_bytes & ~1); } /* a final lone byte has to be MSB aligned */ From b35477a2f203a64fddd1a3fa96d8d6682839f788 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 1 Aug 2011 00:23:07 +0200 Subject: [PATCH 730/780] Use av_get_bits_per_sample() for mBitsPerChannel in caf. --- libavformat/cafenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c index c324b8ead4..2d64beca9a 100644 --- a/libavformat/cafenc.c +++ b/libavformat/cafenc.c @@ -139,7 +139,7 @@ static int caf_write_header(AVFormatContext *s) avio_wb32(pb, enc->block_align); //< mBytesPerPacket avio_wb32(pb, samples_per_packet(enc->codec_id, enc->channels)); //< mFramesPerPacket avio_wb32(pb, enc->channels); //< mChannelsPerFrame - avio_wb32(pb, enc->bits_per_coded_sample); //< mBitsPerChannel + avio_wb32(pb, av_get_bits_per_sample(enc->codec_id)); //< mBitsPerChannel if (enc->channel_layout) { ffio_wfourcc(pb, "chan"); From c6e0332f3062efb00a8c577e11aee70821874b2e Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 1 Aug 2011 00:28:04 +0200 Subject: [PATCH 731/780] Explicitely fail for unsupported codecs when muxing caf. --- libavformat/cafenc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c index 2d64beca9a..29b1d56a9d 100644 --- a/libavformat/cafenc.c +++ b/libavformat/cafenc.c @@ -100,6 +100,17 @@ static int caf_write_header(AVFormatContext *s) CAFContext *caf = s->priv_data; unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, enc->codec_id); + switch (enc->codec_id) { + case CODEC_ID_AAC: + case CODEC_ID_AC3: + case CODEC_ID_ALAC: + case CODEC_ID_AMR_NB: + case CODEC_ID_QCELP: + case CODEC_ID_QDM2: + av_log(s, AV_LOG_ERROR, "muxing codec currently unsupported\n"); + return AVERROR_PATCHWELCOME; + } + switch (enc->codec_id) { case CODEC_ID_PCM_S8: case CODEC_ID_PCM_S16LE: From 9b60b076fb9ab5b39997f3969ac769c03d6abeaf Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 1 Aug 2011 00:30:56 +0200 Subject: [PATCH 732/780] Support muxing MP1, MP2 and MP3 in caf. --- libavformat/cafenc.c | 46 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c index 29b1d56a9d..1c77251604 100644 --- a/libavformat/cafenc.c +++ b/libavformat/cafenc.c @@ -28,6 +28,10 @@ typedef struct { int64_t data; + uint8_t *pkt_sizes; + int size_buffer_size; + int size_entries_used; + int packets; } CAFContext; static uint32_t codec_flags(enum CodecID codec_id) { @@ -133,9 +137,9 @@ static int caf_write_header(AVFormatContext *s) return AVERROR_INVALIDDATA; } - if (!enc->block_align) { - av_log(s, AV_LOG_ERROR, "muxing with unknown or variable packet size not yet supported\n"); - return AVERROR_PATCHWELCOME; + if (!enc->block_align && !pb->seekable) { + av_log(s, AV_LOG_ERROR, "Muxing variable packet size not supported on non seekable output\n"); + return AVERROR_INVALIDDATA; } ffio_wfourcc(pb, "caff"); //< mFileType @@ -169,13 +173,38 @@ static int caf_write_header(AVFormatContext *s) static int caf_write_packet(AVFormatContext *s, AVPacket *pkt) { + CAFContext *caf = s->priv_data; + avio_write(s->pb, pkt->data, pkt->size); + if (!s->streams[0]->codec->block_align) { + void *pkt_sizes = caf->pkt_sizes; + int i, alloc_size = caf->size_entries_used + 5; + if (alloc_size < 0) { + caf->pkt_sizes = NULL; + } else { + caf->pkt_sizes = av_fast_realloc(caf->pkt_sizes, + &caf->size_buffer_size, + alloc_size); + } + if (!caf->pkt_sizes) { + av_free(pkt_sizes); + return AVERROR(ENOMEM); + } + for (i = 4; i > 0; i--) { + unsigned top = pkt->size >> i * 7; + if (top) + caf->pkt_sizes[caf->size_entries_used++] = 128 | top; + } + caf->pkt_sizes[caf->size_entries_used++] = pkt->size & 127; + caf->packets++; + } return 0; } static int caf_write_trailer(AVFormatContext *s) { AVIOContext *pb = s->pb; + AVCodecContext *enc = s->streams[0]->codec; if (pb->seekable) { CAFContext *caf = s->priv_data; @@ -184,6 +213,17 @@ static int caf_write_trailer(AVFormatContext *s) avio_seek(pb, caf->data, SEEK_SET); avio_wb64(pb, file_size - caf->data - 8); avio_seek(pb, file_size, SEEK_SET); + if (!enc->block_align) { + ffio_wfourcc(pb, "pakt"); + avio_wb64(pb, caf->size_entries_used + 24); + avio_wb64(pb, caf->packets); ///< mNumberPackets + avio_wb64(pb, caf->packets * samples_per_packet(enc->codec_id, enc->channels)); ///< mNumberValidFrames + avio_wb32(pb, 0); ///< mPrimingFrames + avio_wb32(pb, 0); ///< mRemainderFrames + avio_write(pb, caf->pkt_sizes, caf->size_entries_used); + av_freep(&caf->pkt_sizes); + caf->size_buffer_size = 0; + } avio_flush(pb); } return 0; From 222b333ed5dfce06583940793cc4890cc342fe9f Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 1 Aug 2011 00:33:09 +0200 Subject: [PATCH 733/780] Cosmetics: Restore alphabetical order. --- libavformat/caf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/caf.c b/libavformat/caf.c index ce0d19b947..054533038f 100644 --- a/libavformat/caf.c +++ b/libavformat/caf.c @@ -34,22 +34,22 @@ const AVCodecTag ff_codec_caf_tags[] = { { CODEC_ID_AAC, MKTAG('a','a','c',' ') }, { CODEC_ID_AC3, MKTAG('a','c','-','3') }, - { CODEC_ID_ALAC, MKTAG('a','l','a','c') }, - /* FIXME: use DV demuxer, as done in MOV */ - /*{ CODEC_ID_DVAUDIO, MKTAG('v','d','v','a') },*/ - /*{ CODEC_ID_DVAUDIO, MKTAG('d','v','c','a') },*/ { CODEC_ID_ADPCM_IMA_QT, MKTAG('i','m','a','4') }, { CODEC_ID_ADPCM_IMA_WAV, MKTAG('m','s', 0, 17 ) }, { CODEC_ID_ADPCM_MS, MKTAG('m','s', 0, 2 ) }, + { CODEC_ID_ALAC, MKTAG('a','l','a','c') }, { CODEC_ID_AMR_NB, MKTAG('s','a','m','r') }, + /* FIXME: use DV demuxer, as done in MOV */ + /*{ CODEC_ID_DVAUDIO, MKTAG('v','d','v','a') },*/ + /*{ CODEC_ID_DVAUDIO, MKTAG('d','v','c','a') },*/ { CODEC_ID_GSM, MKTAG('a','g','s','m') }, { CODEC_ID_GSM_MS, MKTAG('m','s', 0, '1') }, { CODEC_ID_MACE3, MKTAG('M','A','C','3') }, { CODEC_ID_MACE6, MKTAG('M','A','C','6') }, + { CODEC_ID_MP1, MKTAG('.','m','p','1') }, + { CODEC_ID_MP2, MKTAG('.','m','p','2') }, { CODEC_ID_MP3, MKTAG('.','m','p','3') }, { CODEC_ID_MP3, MKTAG('m','s', 0 ,'U') }, - { CODEC_ID_MP2, MKTAG('.','m','p','2') }, - { CODEC_ID_MP1, MKTAG('.','m','p','1') }, { CODEC_ID_PCM_ALAW, MKTAG('a','l','a','w') }, { CODEC_ID_PCM_MULAW, MKTAG('u','l','a','w') }, { CODEC_ID_QCELP, MKTAG('Q','c','l','p') }, From 8460b757c2c20b57d1dd1c1989086f942a261b4b Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 1 Aug 2011 00:36:52 +0200 Subject: [PATCH 734/780] Do not ignore opt_default() return values. --- ffmpeg.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index cc8fdd2b18..2a1ee79bad 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3030,8 +3030,7 @@ static int opt_qscale(const char *opt, const char *arg) static int opt_top_field_first(const char *opt, const char *arg) { top_field_first = parse_number_or_die(opt, arg, OPT_INT, 0, 1); - opt_default(opt, arg); - return 0; + return opt_default(opt, arg); } static int opt_thread_count(const char *opt, const char *arg) @@ -3077,15 +3076,13 @@ static int opt_audio_channels(const char *opt, const char *arg) static int opt_video_channel(const char *opt, const char *arg) { av_log(NULL, AV_LOG_WARNING, "This option is deprecated, use -channel.\n"); - opt_default("channel", arg); - return 0; + return opt_default("channel", arg); } static int opt_video_standard(const char *opt, const char *arg) { av_log(NULL, AV_LOG_WARNING, "This option is deprecated, use -standard.\n"); - opt_default("standard", arg); - return 0; + return opt_default("standard", arg); } static int opt_codec(const char *opt, const char *arg) @@ -4379,8 +4376,7 @@ static void log_callback_null(void* ptr, int level, const char* fmt, va_list vl) static int opt_passlogfile(const char *opt, const char *arg) { pass_logfilename_prefix = arg; - opt_default("passlogfile", arg); - return 0; + return opt_default("passlogfile", arg); } static const OptionDef options[] = { From 940a116b1f441b90e49886bfc07e0137ae342d5a Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 1 Aug 2011 00:40:28 +0200 Subject: [PATCH 735/780] Unbreak ffplay -s and ffplay -pix_fmt. --- doc/ffplay.texi | 9 +++++---- ffplay.c | 10 ++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/doc/ffplay.texi b/doc/ffplay.texi index 44fbad1029..9390e14741 100644 --- a/doc/ffplay.texi +++ b/doc/ffplay.texi @@ -38,8 +38,9 @@ Force displayed width. @item -y @var{height} Force displayed height. @item -s @var{size} -This option has been removed. Use private format options for specifying the -input video size. +Set frame size (WxH or abbreviation), needed for videos which do +not contain a header with the frame size like raw YUV. This option +has been deprecated in favor of private options, try -video_size. @item -an Disable audio. @item -vn @@ -89,8 +90,8 @@ Read @var{input_file}. @section Advanced options @table @option @item -pix_fmt @var{format} -This option has been removed. Use private options for specifying the -input pixel format. +Set pixel format. +This option has been deprecated in favor of private options, try -pixel_format. @item -stats Show the stream duration, the codec parameters, the current position in the stream and the audio/video synchronisation drift. diff --git a/ffplay.c b/ffplay.c index eb9d81bd15..ed1bdf434d 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2811,9 +2811,8 @@ static void event_loop(void) static int opt_frame_size(const char *opt, const char *arg) { - av_log(NULL, AV_LOG_ERROR, - "Option '%s' has been removed, use private format options instead\n", opt); - return AVERROR(EINVAL); + av_log(NULL, AV_LOG_WARNING, "Option -s is deprecated, use -video_size.\n"); + return opt_default("video_size", arg); } static int opt_width(const char *opt, const char *arg) @@ -2840,9 +2839,8 @@ static int opt_format(const char *opt, const char *arg) static int opt_frame_pix_fmt(const char *opt, const char *arg) { - av_log(NULL, AV_LOG_ERROR, - "Option '%s' has been removed, use private format options instead\n", opt); - return AVERROR(EINVAL); + av_log(NULL, AV_LOG_WARNING, "Option -pix_fmt is deprecated, use -pixel_format.\n"); + return opt_default("pixel_format", arg); } static int opt_sync(const char *opt, const char *arg) From b36bd27fbeaadcf265c0851643833f6847af02a0 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 1 Aug 2011 00:55:40 +0200 Subject: [PATCH 736/780] Rm lavfi-showfiltfmts on make testclean. --- tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile b/tests/Makefile index 0a9e402c66..34094da2b7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -103,7 +103,7 @@ fate-list: clean:: testclean testclean: - $(RM) -r tests/vsynth1 tests/vsynth2 tests/data + $(RM) -r tests/vsynth1 tests/vsynth2 tests/data tools/lavfi-showfiltfmts$(EXESUF) $(RM) $(CLEANSUFFIXES:%=tests/%) $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF)) From 1c5480651efa7cb2dbec9309e1c6938f9c85fd53 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 1 Aug 2011 01:23:39 +0200 Subject: [PATCH 737/780] Support FourCC DreX as MPEG4 ASP. --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 37c292e0cd..636d05c636 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -87,6 +87,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') }, { CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') }, /* Samsung SHR-6040 */ { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'X') }, + { CODEC_ID_MPEG4, MKTAG('D', 'r', 'e', 'X') }, { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') }, From 318fd9dac2d76765b2ac68338fdedb5809bf09e6 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 1 Aug 2011 01:26:55 +0200 Subject: [PATCH 738/780] Remove non-existing fourcc " Y8". This reverts a line of r1842. --- libavcodec/raw.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index e87a9af2ba..a26dea8146 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -45,7 +45,6 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_YUVJ422P, MKTAG('Y', '4', '2', 'B') }, { PIX_FMT_YUVJ422P, MKTAG('P', '4', '2', '2') }, { PIX_FMT_GRAY8, MKTAG('Y', '8', '0', '0') }, - { PIX_FMT_GRAY8, MKTAG(' ', ' ', 'Y', '8') }, { PIX_FMT_GRAY8, MKTAG('Y', '8', ' ', ' ') }, { PIX_FMT_YUYV422, MKTAG('Y', 'U', 'Y', '2') }, /* Packed formats */ From e5fc6ab6652b39311bce0767c7e1a92942b3cc47 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 26 Jul 2011 21:57:15 +0200 Subject: [PATCH 739/780] Remove ffserver.h It's unused an serves no purpose. --- ffserver.h | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 ffserver.h diff --git a/ffserver.h b/ffserver.h deleted file mode 100644 index 43bc79c2c6..0000000000 --- a/ffserver.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Multiple format streaming server - * copyright (c) 2002 Fabrice Bellard - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef LIBAV_FFSERVER_H -#define LIBAV_FFSERVER_H - -/* interface between ffserver and modules */ - -void ffserver_module_init(void); - -#endif /* LIBAV_FFSERVER_H */ From b4ea1c5a77704eb7096bc017467b774e088ef3bd Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 27 Jul 2011 20:29:32 +0200 Subject: [PATCH 740/780] Remove the ffserver test. It doesn't work and is therefore useless. --- tests/Makefile | 9 - tests/ffserver-regression.sh | 39 ----- tests/ffserver.conf | 307 ---------------------------------- tests/ffserver.regression.ref | 10 -- 4 files changed, 365 deletions(-) delete mode 100755 tests/ffserver-regression.sh delete mode 100644 tests/ffserver.conf delete mode 100644 tests/ffserver.regression.ref diff --git a/tests/Makefile b/tests/Makefile index 0a9e402c66..7014bf5811 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,3 @@ -FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref - AREF = fate-acodec-aref VREF = fate-vsynth1-vref fate-vsynth2-vref REFS = $(AREF) $(VREF) @@ -7,13 +5,6 @@ REFS = $(AREF) $(VREF) $(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm $(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw -ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw - @echo - @echo "Unfortunately ffserver is broken and therefore its regression" - @echo "test fails randomly. Treat the results accordingly." - @echo - $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf - tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF) @mkdir -p tests/vsynth1 $(M)./$< 'tests/vsynth1/' diff --git a/tests/ffserver-regression.sh b/tests/ffserver-regression.sh deleted file mode 100755 index 11e4a5419e..0000000000 --- a/tests/ffserver-regression.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -#perl -e 'chomp($wd = `pwd`); print map { s!tests/data/!!; "\nFile $wd/tests/data/$_\n\n\n" } @ARGV' tests/data/a* >> tests/data/ffserver.conf -#perl -e 'chomp($wd = `pwd`); print map { s!tests/data/!!; "\nFile $wd/tests/data/$_\n\n\n" } @ARGV' tests/data/a* >> tests/data/ffserver.conf - -. $(dirname $0)/md5.sh - -FILES=$(sed -n 's/^[^#]*.*/\1/p' $2 | grep -v html) - -rm -f tests/feed1.ffm -./ffserver -d -f "$2" 2> /dev/null & -FFSERVER_PID=$! -echo "Waiting for feeds to startup..." -sleep 2 -( - cd tests/data || exit $? - rm -f ff-* ffserver.regression - WGET_OPTIONS="--user-agent=NSPlayer -q --proxy=off -e verbose=off -e server_response=off" - for file in $FILES; do - if [ $(expr $file : "a-*") != 0 ]; then - wget $WGET_OPTIONS -O - http://localhost:9999/$file > ff-$file - else - wget $WGET_OPTIONS -O - http://localhost:9999/$file?date=19700101T000000Z | dd bs=1 count=20000 > ff-$file 2>/dev/null - fi - do_md5sum ff-$file >>ffserver.regression - done -) -kill $FFSERVER_PID -wait > /dev/null 2>&1 -rm -f tests/feed1.ffm -if diff -u "$1" tests/data/ffserver.regression; then - echo - echo Server regression test succeeded. - exit 0 -else - echo - echo Server regression test: Error. - exit 1 -fi diff --git a/tests/ffserver.conf b/tests/ffserver.conf deleted file mode 100644 index 1e6994aa1c..0000000000 --- a/tests/ffserver.conf +++ /dev/null @@ -1,307 +0,0 @@ -# -# This is a test configuration file. You can invoke it with -# ../ffserver -f ffserver.conf -# when in the tests directory and once the vsynth1 subdirectory -# has been populated. Then point your browser at http://whatever:9999/teststat.html -# and you can look at the streams -# - -# -# Port on which the server is listening. You must select a different -# port from your standard http web server if it is running on the same -# computer. - -Port 9999 -RTSPPort 9990 - -# Address on which the server is bound. Only useful if you have -# several network interfaces. - -BindAddress 0.0.0.0 - -# Number of simultaneous requests that can be handled. Since FFServer -# is very fast, this limit is determined mainly by your Internet -# connection speed. - -MaxClients 1000 - -MaxBandwidth 100000 - -# Access Log file (uses standard Apache log file format) -# '-' is the standard output - -CustomLog - - -################################################################## -# Definition of the live feeds. Each live feed contains one video -# and/or audio sequence coming from an ffmpeg encoder or another -# ffserver. This sequence may be encoded simultaneously with several -# codecs at several resolutions. - - - -# You must use 'ffmpeg' to send a live feed to ffserver. In this -# example, you can type: -# -# ffmpeg http://localhost:8090/feed1.ffm - -# ffserver can also do time shifting. It means that it can stream any -# previously recorded live stream. The request should contain: -# "http://xxxx?date=[YYYY-MM-DDT][[HH:]MM:]SS[.m...]".You must specify -# a path where the feed is stored on disk. You also specify the -# maximum size of the feed (100M bytes here). Default: -# File=/tmp/feed_name.ffm FileMaxSize=5M - -File tests/feed1.ffm -FileMaxSize 100M - -# Fire up ffmpeg pointing at this stream - -Launch ./ffmpeg -v 0 -y -f pgmyuv -i tests/vsynth1/%02d.pgm - -ACL allow localhost - - -################################################################## -# Now you can define each stream which will be generated from the -# original audio and video stream. Each format has a filename (here -# 'test128.mpg'). FFServer will send this stream when answering a -# request containing this filename. - - -Feed feed1.ffm -Format avi -# -BitExact -DctFastint -IdctSimple -VideoFrameRate 10 -VideoSize 352x288 -VideoBitRate 100 -VideoGopSize 30 -NoAudio - -PreRoll 10 -StartSendOnKey -MaxTime 100 - - - - -Feed feed1.ffm -Format avi -# -BitExact -DctFastint -IdctSimple -VideoFrameRate 2 -VideoSize 320x240 -VideoBitRate 40 -VideoGopSize 20 -NoAudio - -PreRoll 20 -StartSendOnKey -MaxTime 100 - - - -# -#Feed feed1.ffm -# -#VideoFrameRate 10 -#VideoSize 352x288 -#VideoBitRate 100 -#VideoGopSize 30 -#NoAudio - -#PreRoll 10 -#StartSendOnKey -#MaxTime 100 -# -# -# -# -#Feed feed1.ffm -## -#VideoFrameRate 2 -#VideoSize 320x240 -#VideoBitRate 40 -#VideoGopSize 20 -#NoAudio -# -#PreRoll 20 -#StartSendOnKey -#MaxTime 100 -# -# -# - -Feed feed1.ffm -# -BitExact -DctFastint -IdctSimple -Qscale 10 -VideoFrameRate 10 -VideoSize 352x288 -VideoBitRate 100 -VideoGopSize 30 -NoAudio - -PreRoll 10 -StartSendOnKey -MaxTime 100 - - - - -Feed feed1.ffm -Format asf -# -BitExact -DctFastint -IdctSimple -Qscale 10 -VideoFrameRate 10 -VideoSize 320x240 -VideoBitRate 100 -VideoGopSize 30 -NoAudio - -PreRoll 10 -StartSendOnKey -MaxTime 100 - -Title "Test data stream" - - - - -Feed feed1.ffm -Format asf -# -BitExact -DctFastint -IdctSimple -Qscale 10 -VideoFrameRate 2 -VideoSize 320x240 -VideoBitRate 40 -VideoGopSize 20 -NoAudio - -PreRoll 20 -StartSendOnKey -MaxTime 100 - -Title "Test data stream" - - - - - -Feed feed1.ffm -Format rm - -BitExact -DctFastint -IdctSimple -Qscale 10 -VideoBitRate 100 -VideoFrameRate 10 -VideoGopSize 30 -VideoSize 320x240 -NoAudio - -PreRoll 10 -StartSendOnKey -MaxTime 100 - - - - - -Feed feed1.ffm -Format rm - -BitExact -DctFastint -IdctSimple -Qscale 10 -VideoBitRate 40 -VideoFrameRate 2 -VideoGopSize 20 -VideoSize 320x240 -NoAudio - -PreRoll 20 -StartSendOnKey -MaxTime 100 - - - - - - -Feed feed1.ffm -Format jpeg -Strict -1 - -BitExact -DctFastint -IdctSimple -VideoFrameRate 1 -VideoSize 352x288 -NoAudio - -PreRoll 2 - - - - - -Feed feed1.ffm -Format jpeg -Strict -1 - -BitExact -DctFastint -IdctSimple -VideoFrameRate 1 -VideoSize 160x128 -NoAudio - -PreRoll 2 - - - - - -Feed feed1.ffm -Format mpjpeg -Strict -1 - -BitExact -DctFastint -IdctSimple -VideoFrameRate 1 -VideoSize 320x240 -NoAudio -StartSendOnKey - -PreRoll 1 -MaxTime 100 - - - - -################################################################## -# Special stream : server status - - - -Format status - - - diff --git a/tests/ffserver.regression.ref b/tests/ffserver.regression.ref deleted file mode 100644 index 9fc749763b..0000000000 --- a/tests/ffserver.regression.ref +++ /dev/null @@ -1,10 +0,0 @@ -18c4ba0e8e7adb781216e38de61c2e39 ff-test_h.avi -f84767c7af61f360f4b443c2c73f322f ff-test_l.avi -d976848a9e4d5d8fc2659e4841cdece5 ff-test.swf -28fd87d5075b9b011aad57292f271a04 ff-test_h.asf -a31ccd3aba2551e60b9fb1c156fca2f8 ff-test_l.asf -3279d3ed0ef2d1347b5eda84db2cf3e6 ff-test_h.rm -440231fe3cf0849887390b4d67d6894a ff-test_l.rm -e0dc91430660c619e97b5c82e0f398fc ff-test.jpg -0d6c98fc8a4f00560fe34e94e26880a9 ff-test_small.jpg -e2a315d7ac0576279f8b4d917999615a ff-test.mjpg From 29d854d6c5b31f816b639eac231ce86afa42b11d Mon Sep 17 00:00:00 2001 From: Compn Date: Mon, 1 Aug 2011 09:55:54 -0400 Subject: [PATCH 741/780] correct shorthand ffmpeg-dev > ffmpeg-devel --- doc/developer.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/developer.texi b/doc/developer.texi index c7dba54fd7..6bfbbba523 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -339,7 +339,7 @@ send a reminder by email. Your patch should eventually be dealt with. @item Is the patch against latest FFmpeg git master branch? @item - Are you subscribed to ffmpeg-dev? + Are you subscribed to ffmpeg-devel? (the list is subscribers only due to spam) @item Have you checked that the changes are minimal, so that the same cannot be From e11a5fccb237b54da884e19c3f09986b780bd618 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 29 Jul 2011 14:45:04 -0700 Subject: [PATCH 742/780] bink: Eliminate unnecessary shadow declaration. --- libavcodec/bink.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 2b5bc75078..17683730d4 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -624,7 +624,6 @@ static int read_dct_coeffs(GetBitContext *gb, int32_t block[64], const uint8_t * coef_list[--list_start] = ccoef; mode_list[ list_start] = 3; } else { - int t; if (!bits) { t = 1 - (get_bits1(gb) << 1); } else { From a6c49f18abacb9bf52d4d808a2a56561a5b5445c Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 29 Jul 2011 15:49:11 -0700 Subject: [PATCH 743/780] aac: Remove some suspicious illegal memcpy()s from LTP. --- libavcodec/aacdec.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 6bf14275f9..783bf99fba 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -1789,12 +1789,10 @@ static void windowing_and_mdct_ltp(AACContext *ac, float *out, } else { memset(in, 0, 448 * sizeof(float)); ac->dsp.vector_fmul(in + 448, in + 448, swindow_prev, 128); - memcpy(in + 576, in + 576, 448 * sizeof(float)); } if (ics->window_sequence[0] != LONG_START_SEQUENCE) { ac->dsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); } else { - memcpy(in + 1024, in + 1024, 448 * sizeof(float)); ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); memset(in + 1024 + 576, 0, 448 * sizeof(float)); } From 4326f6f525063e92d40e7a8f39cf7ccd7759aea7 Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Wed, 27 Jul 2011 20:44:58 -0400 Subject: [PATCH 744/780] mpeg4videodec: remove dead code that would have detected erroneous encoding Signed-off-by: Diego Biurrun --- libavcodec/mpeg4videodec.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 57d55a1424..0d061acfb9 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -990,28 +990,6 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block, SKIP_COUNTER(re, &s->gb, 1+12+1); } -#if 0 - if(s->error_recognition >= FF_ER_COMPLIANT){ - const int abs_level= FFABS(level); - if(abs_level<=MAX_LEVEL && run<=MAX_RUN){ - const int run1= run - rl->max_run[last][abs_level] - 1; - if(abs_level <= rl->max_level[last][run]){ - av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n"); - return -1; - } - if(s->error_recognition > FF_ER_COMPLIANT){ - if(abs_level <= rl->max_level[last][run]*2){ - av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n"); - return -1; - } - if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){ - av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n"); - return -1; - } - } - } - } -#endif if (level>0) level= level * qmul + qadd; else level= level * qmul - qadd; From 9d39cbf6cfecfda88e2f822b0437ee22ffa6d745 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 1 Aug 2011 17:41:44 +0200 Subject: [PATCH 745/780] avpacket: signal possibly corrupted packets Use AV_PKT_FLAG_CORRUPT flag to mark packets that might be incomplete or have errors. Formats that have a mean to validate their packets should use this flag to deliver such information instead of silently dropping the packets. --- libavcodec/avcodec.h | 6 +++++- libavcodec/version.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index e1fd475ca6..eaf63e8dc1 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -791,6 +791,9 @@ typedef struct AVPacket { uint8_t *data; int size; int stream_index; + /** + * A combination of AV_PKT_FLAG values + */ int flags; /** * Additional packet data that can be provided by the container. @@ -831,7 +834,8 @@ typedef struct AVPacket { */ int64_t convergence_duration; } AVPacket; -#define AV_PKT_FLAG_KEY 0x0001 +#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe +#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted /** * Audio Video Frame. diff --git a/libavcodec/version.h b/libavcodec/version.h index 46e54990b1..24d2488249 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -22,7 +22,7 @@ #define LIBAVCODEC_VERSION_MAJOR 53 #define LIBAVCODEC_VERSION_MINOR 7 -#define LIBAVCODEC_VERSION_MICRO 0 +#define LIBAVCODEC_VERSION_MICRO 1 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ From 5038f9b2684c4be1d9543e34e76282c6935815ba Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 1 Aug 2011 17:46:29 +0200 Subject: [PATCH 746/780] apichange: add an entry for AV_PKT_FLAG_CORRUPT --- doc/APIchanges | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index c533818efa..09a12fe3d2 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-08-02 - 9d39cbf - lavc 53.7.1 + Add AV_PKT_FLAG_CORRUPT AVPacket flag. + 2011-07-10 - a67c061 - lavf 53.3.0 Add avformat_find_stream_info(), deprecate av_find_stream_info(). From be9c00615b5c2cb858b9905854726ebe578c007b Mon Sep 17 00:00:00 2001 From: Zohar Kelrich Date: Sun, 24 Jul 2011 11:13:50 +0300 Subject: [PATCH 747/780] mpegts: Silence "can't seek" warning on unseekable Do not try to seek when we already know we are not allowed to. Silences warning that always happens when streaming. Signed-off-by: Zohar Kelrich Signed-off-by: Luca Barbato --- libavformat/mpegts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index e9b984dc11..410507db6d 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1488,7 +1488,7 @@ static int mpegts_read_header(AVFormatContext *s, /* normal demux */ /* first do a scaning to get all the services */ - if (avio_seek(pb, pos, SEEK_SET) < 0) + if (pb->seekable && avio_seek(pb, pos, SEEK_SET) < 0) av_log(s, AV_LOG_ERROR, "Unable to seek back to the start\n"); mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); From 8b9df201dfb2fa557b5dfc4e04c927d3f13a0dd9 Mon Sep 17 00:00:00 2001 From: Zohar Kelrich Date: Sun, 24 Jul 2011 11:13:50 +0300 Subject: [PATCH 748/780] mpegts: Fix for continuity counter Make continuity counter respect discontinuity flag and null packets. Unpack the adaptation_field_control field. Signed-off-by: Zohar Kelrich Signed-off-by: Luca Barbato --- libavformat/mpegts.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 410507db6d..13b31177a5 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1248,7 +1248,8 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) { AVFormatContext *s = ts->stream; MpegTSFilter *tss; - int len, pid, cc, expected_cc, cc_ok, afc, is_start; + int len, pid, cc, expected_cc, cc_ok, afc, is_start, is_discontinuity, + has_adaptation, has_payload; const uint8_t *p, *p_end; int64_t pos; @@ -1264,20 +1265,29 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) if (!tss) return 0; - /* continuity check (currently not used) */ - cc = (packet[3] & 0xf); - expected_cc = (packet[3] & 0x10) ? (tss->last_cc + 1) & 0x0f : tss->last_cc; - cc_ok = (tss->last_cc < 0) || (expected_cc == cc); - tss->last_cc = cc; - - /* skip adaptation field */ afc = (packet[3] >> 4) & 3; - p = packet + 4; if (afc == 0) /* reserved value */ return 0; - if (afc == 2) /* adaptation field only */ + has_adaptation = afc & 2; + has_payload = afc & 1; + is_discontinuity = has_adaptation + && packet[4] != 0 /* with length > 0 */ + && (packet[5] & 0x80); /* and discontinuity indicated */ + + /* continuity check (currently not used) */ + cc = (packet[3] & 0xf); + expected_cc = has_payload ? (tss->last_cc + 1) & 0x0f : tss->last_cc; + cc_ok = pid == 0x1FFF // null packet PID + || is_discontinuity + || tss->last_cc < 0 + || expected_cc == cc; + + tss->last_cc = cc; + + if (!has_payload) return 0; - if (afc == 3) { + p = packet + 4; + if (has_adaptation) { /* skip adapation field */ p += p[0] + 1; } From c64f80b0e85ad138fca300f05278263bd713d27a Mon Sep 17 00:00:00 2001 From: Zohar Kelrich Date: Sun, 24 Jul 2011 11:13:50 +0300 Subject: [PATCH 749/780] mpegts: Reset continuity counter on seek Signed-off-by: Zohar Kelrich Signed-off-by: Luca Barbato --- libavformat/mpegts.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 13b31177a5..f3b76aa264 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1625,6 +1625,7 @@ static int mpegts_read_packet(AVFormatContext *s, if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) { PESContext *pes = ts->pids[i]->u.pes_filter.opaque; av_freep(&pes->buffer); + ts->pids[i]->last_cc = -1; pes->data_index = 0; pes->state = MPEGTS_SKIP; /* skip until pes header */ } From ce9e31655e5b8f8db3bb4f13f436fc836062a514 Mon Sep 17 00:00:00 2001 From: Zohar Kelrich Date: Sun, 24 Jul 2011 11:13:50 +0300 Subject: [PATCH 750/780] mpegts: Mark corrupted packets Signed-off-by: Zohar Kelrich Signed-off-by: Luca Barbato --- libavformat/mpegts.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index f3b76aa264..d4688aebfd 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -164,6 +164,7 @@ typedef struct PESContext { enum MpegTSState state; /* used to get the format */ int data_index; + int flags; /**< copied to the AVPacket flags */ int total_size; int pes_header_size; int extended_stream_id; @@ -635,12 +636,14 @@ static void new_pes_packet(PESContext *pes, AVPacket *pkt) pkt->dts = pes->dts; /* store position of first TS packet of this PES packet */ pkt->pos = pes->ts_packet_pos; + pkt->flags = pes->flags; /* reset pts values */ pes->pts = AV_NOPTS_VALUE; pes->dts = AV_NOPTS_VALUE; pes->buffer = NULL; pes->data_index = 0; + pes->flags = 0; } /* return non zero if a packet could be constructed */ @@ -808,6 +811,7 @@ static int mpegts_push_data(MpegTSFilter *filter, // pes packet size is < ts size packet and pes data is padded with 0xff // not sure if this is legal in ts but see issue #2392 buf_size = pes->total_size; + pes->flags |= AV_PKT_FLAG_CORRUPT; } memcpy(pes->buffer+pes->data_index, p, buf_size); pes->data_index += buf_size; @@ -1283,6 +1287,13 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) || expected_cc == cc; tss->last_cc = cc; + if (!cc_ok) { + av_log(NULL, AV_LOG_WARNING, "Continuity Check Failed\n"); + if(tss->type == MPEGTS_PES) { + PESContext *pc = tss->u.pes_filter.opaque; + pc->flags |= AV_PKT_FLAG_CORRUPT; + } + } if (!has_payload) return 0; From cdb9884a636987061d549ac23a248aabc4a91140 Mon Sep 17 00:00:00 2001 From: Zohar Kelrich Date: Sun, 24 Jul 2011 11:13:50 +0300 Subject: [PATCH 751/780] mpegts: Move scan test to handle_packets This fixes an issue where packets which start being read while reading the header stick around after a seek. Signed-off-by: Zohar Kelrich Signed-off-by: Luca Barbato --- libavformat/mpegts.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index d4688aebfd..a5a8ce2a67 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1399,7 +1399,22 @@ static int handle_packets(MpegTSContext *ts, int nb_packets) { AVFormatContext *s = ts->stream; uint8_t packet[TS_PACKET_SIZE]; - int packet_num, ret; + int packet_num, ret = 0; + + if (avio_tell(s->pb) != ts->last_pos) { + int i; + av_dlog("Skipping after seek\n"); + /* seek detected, flush pes buffer */ + for (i = 0; i < NB_PID_MAX; i++) { + if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) { + PESContext *pes = ts->pids[i]->u.pes_filter.opaque; + av_freep(&pes->buffer); + ts->pids[i]->last_cc = -1; + pes->data_index = 0; + pes->state = MPEGTS_SKIP; /* skip until pes header */ + } + } + } ts->stop_parse = 0; packet_num = 0; @@ -1411,12 +1426,13 @@ static int handle_packets(MpegTSContext *ts, int nb_packets) break; ret = read_packet(s, packet, ts->raw_packet_size); if (ret != 0) - return ret; + break; ret = handle_packet(ts, packet); if (ret != 0) - return ret; + break; } - return 0; + ts->last_pos = avio_tell(s->pb); + return ret; } static int mpegts_probe(AVProbeData *p) @@ -1630,19 +1646,6 @@ static int mpegts_read_packet(AVFormatContext *s, MpegTSContext *ts = s->priv_data; int ret, i; - if (avio_tell(s->pb) != ts->last_pos) { - /* seek detected, flush pes buffer */ - for (i = 0; i < NB_PID_MAX; i++) { - if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) { - PESContext *pes = ts->pids[i]->u.pes_filter.opaque; - av_freep(&pes->buffer); - ts->pids[i]->last_cc = -1; - pes->data_index = 0; - pes->state = MPEGTS_SKIP; /* skip until pes header */ - } - } - } - ts->pkt = pkt; ret = handle_packets(ts, 0); if (ret < 0) { @@ -1660,8 +1663,6 @@ static int mpegts_read_packet(AVFormatContext *s, } } - ts->last_pos = avio_tell(s->pb); - return ret; } From 5081514269a17809f8a8ff71e6b26e4b761e8266 Mon Sep 17 00:00:00 2001 From: Zohar Kelrich Date: Sun, 24 Jul 2011 11:13:51 +0300 Subject: [PATCH 752/780] mpegts: Mark wrongly-sized packets as corrupted Signed-off-by: Zohar Kelrich Signed-off-by: Luca Barbato --- libavformat/mpegts.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index a5a8ce2a67..2bc66ac685 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -625,6 +625,12 @@ static void new_pes_packet(PESContext *pes, AVPacket *pkt) pkt->destruct = av_destruct_packet; pkt->data = pes->buffer; pkt->size = pes->data_index; + + if(pes->total_size != MAX_PES_PAYLOAD && + pes->pes_header_size + pes->data_index != pes->total_size + 6) { + av_log(pes->ts, AV_LOG_WARNING, "PES packet size mismatch\n"); + pes->flags |= AV_PKT_FLAG_CORRUPT; + } memset(pkt->data+pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE); // Separate out the AC3 substream from an HDMV combined TrueHD/AC3 PID @@ -811,7 +817,6 @@ static int mpegts_push_data(MpegTSFilter *filter, // pes packet size is < ts size packet and pes data is padded with 0xff // not sure if this is legal in ts but see issue #2392 buf_size = pes->total_size; - pes->flags |= AV_PKT_FLAG_CORRUPT; } memcpy(pes->buffer+pes->data_index, p, buf_size); pes->data_index += buf_size; @@ -1288,7 +1293,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) tss->last_cc = cc; if (!cc_ok) { - av_log(NULL, AV_LOG_WARNING, "Continuity Check Failed\n"); + av_log(ts, AV_LOG_WARNING, "Continuity Check Failed\n"); if(tss->type == MPEGTS_PES) { PESContext *pc = tss->u.pes_filter.opaque; pc->flags |= AV_PKT_FLAG_CORRUPT; From 73e8e8dbf969b9a0bc1591abcfeba474a42e47bc Mon Sep 17 00:00:00 2001 From: Zohar Kelrich Date: Sun, 24 Jul 2011 17:28:33 +0300 Subject: [PATCH 753/780] lavf: Add an option to discard corrupted frames Signed-off-by: Zohar Kelrich Signed-off-by: Luca Barbato --- libavformat/avformat.h | 1 + libavformat/options.c | 1 + libavformat/utils.c | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index cfdbd11b36..2f68abab25 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -750,6 +750,7 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_RTP_HINT 0x0040 ///< Deprecated, use the -movflags rtphint muxer specific AVOption instead #endif #define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it. +#define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted #if FF_API_LOOP_INPUT /** diff --git a/libavformat/options.c b/libavformat/options.c index c2729b75d9..961162876f 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -79,6 +79,7 @@ static const AVOption options[]={ #if FF_API_FLAG_RTP_HINT {"rtphint", "add rtp hinting (deprecated, use the -movflags rtphint option instead)", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_RTP_HINT }, INT_MIN, INT_MAX, E, "fflags"}, #endif +{"discardcorrupt", "discard corrupted frames", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"}, {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D}, {"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D}, {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D}, diff --git a/libavformat/utils.c b/libavformat/utils.c index c4d7623c8c..b848ebb827 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -719,6 +719,15 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt) s->streams[i]->probe_packets = 0; continue; } + + if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT) && + (pkt->flags & AV_PKT_FLAG_CORRUPT)) { + av_log(s, AV_LOG_WARNING, + "Dropped corrupted packet (stream = %d)\n", + pkt->stream_index); + continue; + } + st= s->streams[pkt->stream_index]; switch(st->codec->codec_type){ From 6f7fe4723b9bfbb52341568906e6168966f486b3 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 2 Aug 2011 13:45:28 +0200 Subject: [PATCH 754/780] Correct chroma vector calculation for RealVideo 3. Old version divided it wrong, which resulted in chroma drift (visible on FATE sample too as dirty trails left by clouds). Signed-off-by: Ronald S. Bultje --- libavcodec/rv34.c | 4 ++-- tests/ref/fate/rv30 | 56 ++++++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 9162da5194..1aec571ad3 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -737,8 +737,8 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type, my = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + (3 << 24)) / 3 - (1 << 24); lx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + (3 << 24)) % 3; ly = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + (3 << 24)) % 3; - chroma_mx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + 1) >> 1; - chroma_my = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + 1) >> 1; + chroma_mx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] / 2; + chroma_my = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] / 2; umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24); umy = (chroma_my + (3 << 24)) / 3 - (1 << 24); uvmx = chroma_coeffs[(chroma_mx + (3 << 24)) % 3]; diff --git a/tests/ref/fate/rv30 b/tests/ref/fate/rv30 index 5b43588bb4..6c99871eb6 100644 --- a/tests/ref/fate/rv30 +++ b/tests/ref/fate/rv30 @@ -16,31 +16,31 @@ 0, 112500, 126720, 0xe572dfc9 0, 120000, 126720, 0xbc3cc34f 0, 127500, 126720, 0xcf8cb0e2 -0, 135000, 126720, 0x6d1c630d -0, 142500, 126720, 0x4338e469 -0, 150000, 126720, 0x9d82ea38 -0, 157500, 126720, 0x55e0b559 -0, 165000, 126720, 0x5eefb5ef -0, 172500, 126720, 0x4b10b746 -0, 180000, 126720, 0x8b07a1db -0, 187500, 126720, 0x8c639b34 -0, 195000, 126720, 0x63eb0b9f -0, 202500, 126720, 0x31c80c83 -0, 210000, 126720, 0x78495352 -0, 217500, 126720, 0x63d609c4 -0, 225000, 126720, 0xcd2a62d8 -0, 232500, 126720, 0x4aea732d -0, 240000, 126720, 0xe3bb352c -0, 247500, 126720, 0x4b9036ad -0, 255000, 126720, 0x88b66e2d -0, 262500, 126720, 0x4a8a1b16 -0, 270000, 126720, 0x2e014eac -0, 277500, 126720, 0x83212c67 -0, 285000, 126720, 0x4937e897 -0, 292500, 126720, 0x2d38babe -0, 300000, 126720, 0xbcb43c09 -0, 307500, 126720, 0x955ffaf4 -0, 315000, 126720, 0x3337d4a2 -0, 322500, 126720, 0xe8f58c33 -0, 330000, 126720, 0x3a7f771f -0, 337500, 126720, 0xb67c39b9 +0, 135000, 126720, 0x75ae61b6 +0, 142500, 126720, 0x554fe3e4 +0, 150000, 126720, 0x72ecea95 +0, 157500, 126720, 0x5d00b5fe +0, 165000, 126720, 0xe39bba0d +0, 172500, 126720, 0x9c21bad8 +0, 180000, 126720, 0x72f2a47d +0, 187500, 126720, 0x4f639ebe +0, 195000, 126720, 0x534a10cc +0, 202500, 126720, 0xfdca11d3 +0, 210000, 126720, 0x0c735615 +0, 217500, 126720, 0x0eaf0c1b +0, 225000, 126720, 0xce5e6794 +0, 232500, 126720, 0x14cf7974 +0, 240000, 126720, 0xbc513f2a +0, 247500, 126720, 0xbc303fae +0, 255000, 126720, 0xd9f67585 +0, 262500, 126720, 0x3378251f +0, 270000, 126720, 0xb3ed5911 +0, 277500, 126720, 0xc15a3577 +0, 285000, 126720, 0x0a24f256 +0, 292500, 126720, 0xfab9c45d +0, 300000, 126720, 0x45464610 +0, 307500, 126720, 0xfe2e057d +0, 315000, 126720, 0x23efdc35 +0, 322500, 126720, 0x4d888b2e +0, 330000, 126720, 0xdd0d74df +0, 337500, 126720, 0x08382b8e From 18b131de0473a3110c63966cd7c6cd2ab118d401 Mon Sep 17 00:00:00 2001 From: Vitor Sessak Date: Sat, 30 Jul 2011 18:39:25 +0200 Subject: [PATCH 755/780] dct32: Add SSE2 ASM optimizations Signed-off-by: Ronald S. Bultje --- libavcodec/x86/dct32_sse.asm | 39 +++++++++++++++++++++++++++--------- libavcodec/x86/fft.c | 2 ++ libavcodec/x86/fft.h | 1 + 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/libavcodec/x86/dct32_sse.asm b/libavcodec/x86/dct32_sse.asm index 46daa43d8c..720a061078 100644 --- a/libavcodec/x86/dct32_sse.asm +++ b/libavcodec/x86/dct32_sse.asm @@ -63,6 +63,13 @@ ps_p1p1m1m1: dd 0, 0, 0x80000000, 0x80000000, 0, 0, 0x80000000, 0x80000000 mulps %1, %3 %endmacro +%macro BUTTERFLY0_SSE2 5 + pshufd %4, %1, %5 + xorps %1, %2 + addps %1, %4 + mulps %1, %3 +%endmacro + %macro BUTTERFLY0_AVX 5 vshufps %4, %1, %1, %5 vxorps %1, %1, %2 @@ -405,18 +412,17 @@ INIT_XMM INIT_XMM +%macro DCT32_FUNC 1 ; void ff_dct32_float_sse(FFTSample *out, const FFTSample *in) -cglobal dct32_float_sse, 2,3,16, out, in, tmp +cglobal dct32_float_%1, 2,3,16, out, in, tmp ; pass 1 movaps m0, [inq+0] - movaps m1, [inq+112] - shufps m1, m1, 0x1b + LOAD_INV m1, [inq+112] BUTTERFLY m0, m1, [ps_cos_vec], m3 movaps m7, [inq+64] - movaps m4, [inq+48] - shufps m4, m4, 0x1b + LOAD_INV m4, [inq+48] BUTTERFLY m7, m4, [ps_cos_vec+32], m3 ; pass 2 @@ -427,13 +433,11 @@ cglobal dct32_float_sse, 2,3,16, out, in, tmp ; pass 1 movaps m1, [inq+16] - movaps m6, [inq+96] - shufps m6, m6, 0x1b + LOAD_INV m6, [inq+96] BUTTERFLY m1, m6, [ps_cos_vec+16], m3 movaps m4, [inq+80] - movaps m5, [inq+32] - shufps m5, m5, 0x1b + LOAD_INV m5, [inq+32] BUTTERFLY m4, m5, [ps_cos_vec+48], m3 ; pass 2 @@ -492,3 +496,20 @@ cglobal dct32_float_sse, 2,3,16, out, in, tmp PASS5 PASS6 RET +%endmacro + +%macro LOAD_INV_SSE 2 + movaps %1, %2 + shufps %1, %1, 0x1b +%endmacro + +%define LOAD_INV LOAD_INV_SSE +DCT32_FUNC sse + +%macro LOAD_INV_SSE2 2 + pshufd %1, %2, 0x1b +%endmacro + +%define LOAD_INV LOAD_INV_SSE2 +%define BUTTERFLY0 BUTTERFLY0_SSE2 +DCT32_FUNC sse2 diff --git a/libavcodec/x86/fft.c b/libavcodec/x86/fft.c index 899f0f7ad5..f7308cca32 100644 --- a/libavcodec/x86/fft.c +++ b/libavcodec/x86/fft.c @@ -60,6 +60,8 @@ av_cold void ff_dct_init_mmx(DCTContext *s) int has_vectors = av_get_cpu_flags(); if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX) s->dct32 = ff_dct32_float_avx; + else if (has_vectors & AV_CPU_FLAG_SSE2 && HAVE_SSE) + s->dct32 = ff_dct32_float_sse2; else if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) s->dct32 = ff_dct32_float_sse; #endif diff --git a/libavcodec/x86/fft.h b/libavcodec/x86/fft.h index 0ade2b2e7b..9d68d5b219 100644 --- a/libavcodec/x86/fft.h +++ b/libavcodec/x86/fft.h @@ -35,6 +35,7 @@ void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input) void ff_imdct_half_sse(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_imdct_half_avx(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_dct32_float_sse(FFTSample *out, const FFTSample *in); +void ff_dct32_float_sse2(FFTSample *out, const FFTSample *in); void ff_dct32_float_avx(FFTSample *out, const FFTSample *in); #endif /* AVCODEC_X86_FFT_H */ From ac0fb5934893be554a44d2a1eb7a3bc7bf39da4a Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Mon, 1 Aug 2011 21:04:19 -0700 Subject: [PATCH 756/780] swscale: use 15-bit intermediates for 9/10-bit scaling. --- libswscale/swscale.c | 163 ++++++++++++++++++++++++---------- libswscale/swscale_internal.h | 75 ++++++++++------ libswscale/utils.c | 12 ++- tests/ref/lavfi/pixdesc | 4 +- tests/ref/lavfi/pixfmts_copy | 4 +- tests/ref/lavfi/pixfmts_null | 4 +- tests/ref/lavfi/pixfmts_scale | 12 +-- tests/ref/lavfi/pixfmts_vflip | 4 +- 8 files changed, 190 insertions(+), 88 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index dd9f4a108f..6fc65a8b2a 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -211,17 +211,9 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, #define output_pixel(pos, val) \ if (big_endian) { \ - if (output_bits == 16) { \ - AV_WB16(pos, av_clip_uint16(val >> shift)); \ - } else { \ - AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \ - } \ + AV_WB16(pos, av_clip_uint16(val >> shift)); \ } else { \ - if (output_bits == 16) { \ - AV_WL16(pos, av_clip_uint16(val >> shift)); \ - } else { \ - AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \ - } \ + AV_WL16(pos, av_clip_uint16(val >> shift)); \ } for (i = 0; i < dstW; i++) { int val = 1 << (30-output_bits - 1); @@ -263,7 +255,67 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, #undef output_pixel } -#define yuv2NBPS(bits, BE_LE, is_be) \ +static av_always_inline void +yuv2yuvX10_c_template(const int16_t *lumFilter, const int16_t **lumSrc, + int lumFilterSize, const int16_t *chrFilter, + const int16_t **chrUSrc, const int16_t **chrVSrc, + int chrFilterSize, const int16_t **alpSrc, + uint16_t *dest[4], int dstW, int chrDstW, + int big_endian, int output_bits) +{ + //FIXME Optimize (just quickly written not optimized..) + int i; + uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], + *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; + int shift = 15 + 16 - output_bits - 1; + +#define output_pixel(pos, val) \ + if (big_endian) { \ + AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \ + } else { \ + AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \ + } + for (i = 0; i < dstW; i++) { + int val = 1 << (30-output_bits - 1); + int j; + + for (j = 0; j < lumFilterSize; j++) + val += (lumSrc[j][i] * lumFilter[j]) >> 1; + + output_pixel(&yDest[i], val); + } + + if (uDest) { + for (i = 0; i < chrDstW; i++) { + int u = 1 << (30-output_bits - 1); + int v = 1 << (30-output_bits - 1); + int j; + + for (j = 0; j < chrFilterSize; j++) { + u += (chrUSrc[j][i] * chrFilter[j]) >> 1; + v += (chrVSrc[j][i] * chrFilter[j]) >> 1; + } + + output_pixel(&uDest[i], u); + output_pixel(&vDest[i], v); + } + } + + if (CONFIG_SWSCALE_ALPHA && aDest) { + for (i = 0; i < dstW; i++) { + int val = 1 << (30-output_bits - 1); + int j; + + for (j = 0; j < lumFilterSize; j++) + val += (alpSrc[j][i] * lumFilter[j]) >> 1; + + output_pixel(&aDest[i], val); + } + } +#undef output_pixel +} + +#define yuv2NBPS(bits, BE_LE, is_be, yuv2yuvX_template_fn, typeX_t) \ static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFilter, \ const int16_t **_lumSrc, int lumFilterSize, \ const int16_t *chrFilter, const int16_t **_chrUSrc, \ @@ -271,21 +323,21 @@ static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFil int chrFilterSize, const int16_t **_alpSrc, \ uint8_t *_dest[4], int dstW, int chrDstW) \ { \ - const int32_t **lumSrc = (const int32_t **) _lumSrc, \ - **chrUSrc = (const int32_t **) _chrUSrc, \ - **chrVSrc = (const int32_t **) _chrVSrc, \ - **alpSrc = (const int32_t **) _alpSrc; \ - yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \ - chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ - alpSrc, (uint16_t **) _dest, \ - dstW, chrDstW, is_be, bits); \ + const typeX_t **lumSrc = (const typeX_t **) _lumSrc, \ + **chrUSrc = (const typeX_t **) _chrUSrc, \ + **chrVSrc = (const typeX_t **) _chrVSrc, \ + **alpSrc = (const typeX_t **) _alpSrc; \ + yuv2yuvX_template_fn(lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ + alpSrc, (uint16_t **) _dest, \ + dstW, chrDstW, is_be, bits); \ } -yuv2NBPS( 9, BE, 1); -yuv2NBPS( 9, LE, 0); -yuv2NBPS(10, BE, 1); -yuv2NBPS(10, LE, 0); -yuv2NBPS(16, BE, 1); -yuv2NBPS(16, LE, 0); +yuv2NBPS( 9, BE, 1, yuv2yuvX10_c_template, int16_t); +yuv2NBPS( 9, LE, 0, yuv2yuvX10_c_template, int16_t); +yuv2NBPS(10, BE, 1, yuv2yuvX10_c_template, int16_t); +yuv2NBPS(10, LE, 0, yuv2yuvX10_c_template, int16_t); +yuv2NBPS(16, BE, 1, yuv2yuvX16_c_template, int32_t); +yuv2NBPS(16, LE, 0, yuv2yuvX16_c_template, int32_t); static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, @@ -1880,6 +1932,27 @@ static void hScale16_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_s } } +static void hScale10_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *_src, + const int16_t *filter, + const int16_t *filterPos, int filterSize) +{ + int i; + const uint16_t *src = (const uint16_t *) _src; + int sh = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; + + for (i = 0; i < dstW; i++) { + int j; + int srcPos = filterPos[i]; + int val = 0; + + for (j = 0; j < filterSize; j++) { + val += src[srcPos + j] * filter[filterSize * i + j]; + } + // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit + dst[i] = FFMIN(val >> sh, (1 << 15) - 1); + } +} + // bilinear / bicubic scaling static void hScale_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, @@ -2025,7 +2098,7 @@ static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, if (convertRange) convertRange(dst, dstWidth); - if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 10 && c->scalingBpp == 16) { c->scale19To15Fw(dst, (int32_t *) dst, dstWidth); } } @@ -2052,7 +2125,7 @@ static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2 uint8_t *formatConvBuffer, uint32_t *pal) { if (c->chrToYV12) { - uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * c->scalingBpp >> 3, 16); + uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * FFALIGN(c->scalingBpp, 8) >> 3, 16); c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); src1= formatConvBuffer; src2= buf2; @@ -2076,7 +2149,7 @@ static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2 if (c->chrConvertRange) c->chrConvertRange(dst1, dst2, dstWidth); - if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 10 && c->scalingBpp == 16) { c->scale19To15Fw(dst1, (int32_t *) dst1, dstWidth); c->scale19To15Fw(dst2, (int32_t *) dst2, dstWidth); } @@ -2735,27 +2808,27 @@ static av_cold void sws_init_swScale_c(SwsContext *c) } if (c->scalingBpp == 8) { - c->hScale = hScale_c; - if (c->flags & SWS_FAST_BILINEAR) { - c->hyscale_fast = hyscale_fast_c; - c->hcscale_fast = hcscale_fast_c; + c->hScale = hScale_c; + if (c->flags & SWS_FAST_BILINEAR) { + c->hyscale_fast = hyscale_fast_c; + c->hcscale_fast = hcscale_fast_c; + } + } else { + c->hScale = c->scalingBpp == 16 ? hScale16_c : hScale10_c; + c->scale19To15Fw = scale19To15Fw_c; + c->scale8To16Rv = scale8To16Rv_c; } if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { - if (c->srcRange) { - c->lumConvertRange = lumRangeFromJpeg_c; - c->chrConvertRange = chrRangeFromJpeg_c; + if (c->scalingBpp <= 10) { + if (c->srcRange) { + c->lumConvertRange = lumRangeFromJpeg_c; + c->chrConvertRange = chrRangeFromJpeg_c; + } else { + c->lumConvertRange = lumRangeToJpeg_c; + c->chrConvertRange = chrRangeToJpeg_c; + } } else { - c->lumConvertRange = lumRangeToJpeg_c; - c->chrConvertRange = chrRangeToJpeg_c; - } - } - } else { - c->hScale = hScale16_c; - c->scale19To15Fw = scale19To15Fw_c; - c->scale8To16Rv = scale8To16Rv_c; - - if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { if (c->srcRange) { c->lumConvertRange = lumRangeFromJpeg16_c; c->chrConvertRange = chrRangeFromJpeg16_c; diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 9492303301..60787aed91 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -64,11 +64,16 @@ typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[], * without any additional vertical scaling (or point-scaling). * * @param c SWS scaling context - * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output - * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output - * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output - * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output - * @param dest pointer to the 4 output planes (Y/U/V/A) + * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param dest pointer to the 4 output planes (Y/U/V/A). For >8bit + * output, this is in uint16_t * @param dstW width of dest[0], dest[3], lumSrc and alpSrc in pixels * @param chrDstW width of dest[1], dest[2], chrUSrc and chrVSrc */ @@ -82,14 +87,19 @@ typedef void (*yuv2planar1_fn) (struct SwsContext *c, * * @param c SWS scaling context * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096] - * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output + * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) * @param lumFilterSize number of vertical luma/alpha input lines to scale * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096] - * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output - * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output + * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) * @param chrFilterSize number of vertical chroma input lines to scale - * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output - * @param dest pointer to the 4 output planes (Y/U/V/A) + * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param dest pointer to the 4 output planes (Y/U/V/A). For >8bit + * output, this is in uint16_t * @param dstW width of dest[0], dest[3], lumSrc and alpSrc in pixels * @param chrDstW width of dest[1], dest[2], chrUSrc and chrVSrc */ @@ -105,11 +115,16 @@ typedef void (*yuv2planarX_fn) (struct SwsContext *c, const int16_t *lumFilter, * that this function may do chroma scaling, see the "uvalpha" argument. * * @param c SWS scaling context - * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output - * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output - * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output - * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output - * @param dest pointer to the output plane + * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param dest pointer to the output plane. For 16bit output, this is + * uint16_t * @param dstW width of lumSrc and alpSrc in pixels, number of pixels * to write into dest[] * @param uvalpha chroma scaling coefficient for the second line of chroma @@ -132,11 +147,16 @@ typedef void (*yuv2packed1_fn) (struct SwsContext *c, const int16_t *lumSrc, * output by doing bilinear scaling between two input lines. * * @param c SWS scaling context - * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output - * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output - * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output - * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output - * @param dest pointer to the output plane + * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param dest pointer to the output plane. For 16bit output, this is + * uint16_t * @param dstW width of lumSrc and alpSrc in pixels, number of pixels * to write into dest[] * @param yalpha luma/alpha scaling coefficients for the second input line. @@ -160,14 +180,19 @@ typedef void (*yuv2packed2_fn) (struct SwsContext *c, const int16_t *lumSrc[2], * * @param c SWS scaling context * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096] - * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output + * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) * @param lumFilterSize number of vertical luma/alpha input lines to scale * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096] - * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output - * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output + * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) * @param chrFilterSize number of vertical chroma input lines to scale - * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output - * @param dest pointer to the output plane + * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, + * 19-bit for 16bit output (in int32_t) + * @param dest pointer to the output plane. For 16bit output, this is + * uint16_t * @param dstW width of lumSrc and alpSrc in pixels, number of pixels * to write into dest[] * @param y vertical line number for this output. This does not need diff --git a/libswscale/utils.c b/libswscale/utils.c index c6abb6b446..18d1227c83 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -896,11 +896,15 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) } } - c->scalingBpp = FFMAX(av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1, - av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1) >= 8 ? 16 : 8; + c->scalingBpp = 1 + FFMAX(av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1, + av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1); + if (c->scalingBpp <= 8) + c->scalingBpp = 8; if (c->scalingBpp == 16) dst_stride <<= 1; - FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW, 16) * 2 * c->scalingBpp >> 3, fail); + FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, + FFALIGN(srcW, 16) * 2 * FFALIGN(c->scalingBpp, 8) >> 3, + fail); if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2 && c->scalingBpp == 8) { c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0; if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) { @@ -1055,7 +1059,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) c->lumPixBuf[i] = c->lumPixBuf[i+c->vLumBufSize]; } // 64 / c->scalingBpp is the same as 16 / sizeof(scaling_intermediate) - c->uv_off_px = dst_stride_px + 64 / c->scalingBpp; + c->uv_off_px = dst_stride_px + 64 / (c->scalingBpp &~ 7); c->uv_off_byte = dst_stride + 16; for (i=0; ivChrBufSize; i++) { FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i+c->vChrBufSize], dst_stride*2+32, fail); diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc index 3730988777..0da94f861e 100644 --- a/tests/ref/lavfi/pixdesc +++ b/tests/ref/lavfi/pixdesc @@ -38,8 +38,8 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p10be 107c6e31a3d4d598bca1d8426aaa54f5 -yuv422p10le 3f478be644add24b6cc77e718a6e2afa +yuv422p10be a4a83d0811280eff7405d94a7de21596 +yuv422p10le 23717b6c73a59912c605f27877ae2fb6 yuv422p16be dc9886f2fccf87cc54b27e071a2c251e yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index 3730988777..0da94f861e 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -38,8 +38,8 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p10be 107c6e31a3d4d598bca1d8426aaa54f5 -yuv422p10le 3f478be644add24b6cc77e718a6e2afa +yuv422p10be a4a83d0811280eff7405d94a7de21596 +yuv422p10le 23717b6c73a59912c605f27877ae2fb6 yuv422p16be dc9886f2fccf87cc54b27e071a2c251e yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index 3730988777..0da94f861e 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -38,8 +38,8 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p10be 107c6e31a3d4d598bca1d8426aaa54f5 -yuv422p10le 3f478be644add24b6cc77e718a6e2afa +yuv422p10be a4a83d0811280eff7405d94a7de21596 +yuv422p10le 23717b6c73a59912c605f27877ae2fb6 yuv422p16be dc9886f2fccf87cc54b27e071a2c251e yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index 392b9ce601..d68cdd41d0 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -31,15 +31,15 @@ uyvy422 314bd486277111a95d9369b944fa0400 yuv410p 7df8f6d69b56a8dcb6c7ee908e5018b5 yuv411p 1143e7c5cc28fe0922b051b17733bc4c yuv420p fdad2d8df8985e3d17e73c71f713cb14 -yuv420p10be af5429f27b9f95bf955e795921c65cdc -yuv420p10le d0b47e6a8a44e6b5ca0fe4349a4e393b +yuv420p10be 04663d400e44692fe8a622a067f838da +yuv420p10le 6171850f66df7a727b4bed1c87ef9188 yuv420p16be 9688e33e03b8c8275ab2fb1df0f06bee yuv420p16le cba8b390ad5e7b8678e419b8ce79c008 -yuv420p9be a073b2d93b2a7dce2069ba252bc43175 -yuv420p9le b67233c3c7d93763d07d88f697c145e1 +yuv420p9be ab163dfef03c4d563aca99b24276b9fd +yuv420p9le cd56c5a76ce74e504dd59d25a5e4389c yuv422p 918e37701ee7377d16a8a6c119c56a40 -yuv422p10be 533fd21e7943c20a1026b19069b3b867 -yuv422p10le 59b20a4a8609f5da2dc54c78aea11e6c +yuv422p10be e8e80fed7121f3afac994f2afac42cd2 +yuv422p10le 370866666f4889ee0928345b16d68fb4 yuv422p16be 2cf502d7d386db1f1b3b946679d897b1 yuv422p16le 3002a4e47520731dcee5929aff49eb74 yuv440p 461503fdb9b90451020aa3b25ddf041c diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index 2b62518a28..a2b11690ab 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -38,8 +38,8 @@ yuv420p16le 0f609e588e5a258644ef85170d70e030 yuv420p9be be40ec975fb2873891643cbbbddbc3b0 yuv420p9le 7e606310d3f5ff12badf911e8f333471 yuv422p d7f5cb44d9b0210d66d6a8762640ab34 -yuv422p10be a28b051168af49435c04af5f58dce47b -yuv422p10le 35936ffff30df2697f47b9b8d2cb7dea +yuv422p10be 51d9ef13fe43ea9549b3792bfd449bf7 +yuv422p10le 4b286a243ee0e715b2961bc1b469e629 yuv422p16be 51d9aa4e78d121c226d919ce97976fe4 yuv422p16le 12965c54bda8932ca72da194419a9908 yuv440p 876385e96165acf51271b20e5d85a416 From 62ee0e6a977e1990c9853630c7dea1415b38bb28 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 2 Aug 2011 12:27:43 -0700 Subject: [PATCH 757/780] Revert "swscale: use 15-bit intermediates for 9/10-bit scaling." This reverts commit ac0fb5934893be554a44d2a1eb7a3bc7bf39da4a. It causes valgrind errors which I'll want to investigate before resubmitting this. --- libswscale/swscale.c | 163 ++++++++++------------------------ libswscale/swscale_internal.h | 75 ++++++---------- libswscale/utils.c | 12 +-- tests/ref/lavfi/pixdesc | 4 +- tests/ref/lavfi/pixfmts_copy | 4 +- tests/ref/lavfi/pixfmts_null | 4 +- tests/ref/lavfi/pixfmts_scale | 12 +-- tests/ref/lavfi/pixfmts_vflip | 4 +- 8 files changed, 88 insertions(+), 190 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 6fc65a8b2a..dd9f4a108f 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -211,9 +211,17 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, #define output_pixel(pos, val) \ if (big_endian) { \ - AV_WB16(pos, av_clip_uint16(val >> shift)); \ + if (output_bits == 16) { \ + AV_WB16(pos, av_clip_uint16(val >> shift)); \ + } else { \ + AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \ + } \ } else { \ - AV_WL16(pos, av_clip_uint16(val >> shift)); \ + if (output_bits == 16) { \ + AV_WL16(pos, av_clip_uint16(val >> shift)); \ + } else { \ + AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \ + } \ } for (i = 0; i < dstW; i++) { int val = 1 << (30-output_bits - 1); @@ -255,67 +263,7 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, #undef output_pixel } -static av_always_inline void -yuv2yuvX10_c_template(const int16_t *lumFilter, const int16_t **lumSrc, - int lumFilterSize, const int16_t *chrFilter, - const int16_t **chrUSrc, const int16_t **chrVSrc, - int chrFilterSize, const int16_t **alpSrc, - uint16_t *dest[4], int dstW, int chrDstW, - int big_endian, int output_bits) -{ - //FIXME Optimize (just quickly written not optimized..) - int i; - uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], - *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; - int shift = 15 + 16 - output_bits - 1; - -#define output_pixel(pos, val) \ - if (big_endian) { \ - AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \ - } else { \ - AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \ - } - for (i = 0; i < dstW; i++) { - int val = 1 << (30-output_bits - 1); - int j; - - for (j = 0; j < lumFilterSize; j++) - val += (lumSrc[j][i] * lumFilter[j]) >> 1; - - output_pixel(&yDest[i], val); - } - - if (uDest) { - for (i = 0; i < chrDstW; i++) { - int u = 1 << (30-output_bits - 1); - int v = 1 << (30-output_bits - 1); - int j; - - for (j = 0; j < chrFilterSize; j++) { - u += (chrUSrc[j][i] * chrFilter[j]) >> 1; - v += (chrVSrc[j][i] * chrFilter[j]) >> 1; - } - - output_pixel(&uDest[i], u); - output_pixel(&vDest[i], v); - } - } - - if (CONFIG_SWSCALE_ALPHA && aDest) { - for (i = 0; i < dstW; i++) { - int val = 1 << (30-output_bits - 1); - int j; - - for (j = 0; j < lumFilterSize; j++) - val += (alpSrc[j][i] * lumFilter[j]) >> 1; - - output_pixel(&aDest[i], val); - } - } -#undef output_pixel -} - -#define yuv2NBPS(bits, BE_LE, is_be, yuv2yuvX_template_fn, typeX_t) \ +#define yuv2NBPS(bits, BE_LE, is_be) \ static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFilter, \ const int16_t **_lumSrc, int lumFilterSize, \ const int16_t *chrFilter, const int16_t **_chrUSrc, \ @@ -323,21 +271,21 @@ static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFil int chrFilterSize, const int16_t **_alpSrc, \ uint8_t *_dest[4], int dstW, int chrDstW) \ { \ - const typeX_t **lumSrc = (const typeX_t **) _lumSrc, \ - **chrUSrc = (const typeX_t **) _chrUSrc, \ - **chrVSrc = (const typeX_t **) _chrVSrc, \ - **alpSrc = (const typeX_t **) _alpSrc; \ - yuv2yuvX_template_fn(lumFilter, lumSrc, lumFilterSize, \ - chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ - alpSrc, (uint16_t **) _dest, \ - dstW, chrDstW, is_be, bits); \ + const int32_t **lumSrc = (const int32_t **) _lumSrc, \ + **chrUSrc = (const int32_t **) _chrUSrc, \ + **chrVSrc = (const int32_t **) _chrVSrc, \ + **alpSrc = (const int32_t **) _alpSrc; \ + yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ + alpSrc, (uint16_t **) _dest, \ + dstW, chrDstW, is_be, bits); \ } -yuv2NBPS( 9, BE, 1, yuv2yuvX10_c_template, int16_t); -yuv2NBPS( 9, LE, 0, yuv2yuvX10_c_template, int16_t); -yuv2NBPS(10, BE, 1, yuv2yuvX10_c_template, int16_t); -yuv2NBPS(10, LE, 0, yuv2yuvX10_c_template, int16_t); -yuv2NBPS(16, BE, 1, yuv2yuvX16_c_template, int32_t); -yuv2NBPS(16, LE, 0, yuv2yuvX16_c_template, int32_t); +yuv2NBPS( 9, BE, 1); +yuv2NBPS( 9, LE, 0); +yuv2NBPS(10, BE, 1); +yuv2NBPS(10, LE, 0); +yuv2NBPS(16, BE, 1); +yuv2NBPS(16, LE, 0); static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, @@ -1932,27 +1880,6 @@ static void hScale16_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_s } } -static void hScale10_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *_src, - const int16_t *filter, - const int16_t *filterPos, int filterSize) -{ - int i; - const uint16_t *src = (const uint16_t *) _src; - int sh = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; - - for (i = 0; i < dstW; i++) { - int j; - int srcPos = filterPos[i]; - int val = 0; - - for (j = 0; j < filterSize; j++) { - val += src[srcPos + j] * filter[filterSize * i + j]; - } - // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit - dst[i] = FFMIN(val >> sh, (1 << 15) - 1); - } -} - // bilinear / bicubic scaling static void hScale_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, @@ -2098,7 +2025,7 @@ static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, if (convertRange) convertRange(dst, dstWidth); - if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 10 && c->scalingBpp == 16) { + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { c->scale19To15Fw(dst, (int32_t *) dst, dstWidth); } } @@ -2125,7 +2052,7 @@ static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2 uint8_t *formatConvBuffer, uint32_t *pal) { if (c->chrToYV12) { - uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * FFALIGN(c->scalingBpp, 8) >> 3, 16); + uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW * c->scalingBpp >> 3, 16); c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); src1= formatConvBuffer; src2= buf2; @@ -2149,7 +2076,7 @@ static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2 if (c->chrConvertRange) c->chrConvertRange(dst1, dst2, dstWidth); - if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 10 && c->scalingBpp == 16) { + if (av_pix_fmt_descriptors[c->dstFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) { c->scale19To15Fw(dst1, (int32_t *) dst1, dstWidth); c->scale19To15Fw(dst2, (int32_t *) dst2, dstWidth); } @@ -2808,27 +2735,27 @@ static av_cold void sws_init_swScale_c(SwsContext *c) } if (c->scalingBpp == 8) { - c->hScale = hScale_c; - if (c->flags & SWS_FAST_BILINEAR) { - c->hyscale_fast = hyscale_fast_c; - c->hcscale_fast = hcscale_fast_c; - } - } else { - c->hScale = c->scalingBpp == 16 ? hScale16_c : hScale10_c; - c->scale19To15Fw = scale19To15Fw_c; - c->scale8To16Rv = scale8To16Rv_c; + c->hScale = hScale_c; + if (c->flags & SWS_FAST_BILINEAR) { + c->hyscale_fast = hyscale_fast_c; + c->hcscale_fast = hcscale_fast_c; } if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { - if (c->scalingBpp <= 10) { - if (c->srcRange) { - c->lumConvertRange = lumRangeFromJpeg_c; - c->chrConvertRange = chrRangeFromJpeg_c; - } else { - c->lumConvertRange = lumRangeToJpeg_c; - c->chrConvertRange = chrRangeToJpeg_c; - } + if (c->srcRange) { + c->lumConvertRange = lumRangeFromJpeg_c; + c->chrConvertRange = chrRangeFromJpeg_c; } else { + c->lumConvertRange = lumRangeToJpeg_c; + c->chrConvertRange = chrRangeToJpeg_c; + } + } + } else { + c->hScale = hScale16_c; + c->scale19To15Fw = scale19To15Fw_c; + c->scale8To16Rv = scale8To16Rv_c; + + if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { if (c->srcRange) { c->lumConvertRange = lumRangeFromJpeg16_c; c->chrConvertRange = chrRangeFromJpeg16_c; diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 60787aed91..9492303301 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -64,16 +64,11 @@ typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[], * without any additional vertical scaling (or point-scaling). * * @param c SWS scaling context - * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param dest pointer to the 4 output planes (Y/U/V/A). For >8bit - * output, this is in uint16_t + * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output + * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output + * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output + * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output + * @param dest pointer to the 4 output planes (Y/U/V/A) * @param dstW width of dest[0], dest[3], lumSrc and alpSrc in pixels * @param chrDstW width of dest[1], dest[2], chrUSrc and chrVSrc */ @@ -87,19 +82,14 @@ typedef void (*yuv2planar1_fn) (struct SwsContext *c, * * @param c SWS scaling context * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096] - * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) + * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output * @param lumFilterSize number of vertical luma/alpha input lines to scale * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096] - * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) + * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output + * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output * @param chrFilterSize number of vertical chroma input lines to scale - * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param dest pointer to the 4 output planes (Y/U/V/A). For >8bit - * output, this is in uint16_t + * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output + * @param dest pointer to the 4 output planes (Y/U/V/A) * @param dstW width of dest[0], dest[3], lumSrc and alpSrc in pixels * @param chrDstW width of dest[1], dest[2], chrUSrc and chrVSrc */ @@ -115,16 +105,11 @@ typedef void (*yuv2planarX_fn) (struct SwsContext *c, const int16_t *lumFilter, * that this function may do chroma scaling, see the "uvalpha" argument. * * @param c SWS scaling context - * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param dest pointer to the output plane. For 16bit output, this is - * uint16_t + * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output + * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output + * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output + * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output + * @param dest pointer to the output plane * @param dstW width of lumSrc and alpSrc in pixels, number of pixels * to write into dest[] * @param uvalpha chroma scaling coefficient for the second line of chroma @@ -147,16 +132,11 @@ typedef void (*yuv2packed1_fn) (struct SwsContext *c, const int16_t *lumSrc, * output by doing bilinear scaling between two input lines. * * @param c SWS scaling context - * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param dest pointer to the output plane. For 16bit output, this is - * uint16_t + * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output + * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output + * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output + * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output + * @param dest pointer to the output plane * @param dstW width of lumSrc and alpSrc in pixels, number of pixels * to write into dest[] * @param yalpha luma/alpha scaling coefficients for the second input line. @@ -180,19 +160,14 @@ typedef void (*yuv2packed2_fn) (struct SwsContext *c, const int16_t *lumSrc[2], * * @param c SWS scaling context * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096] - * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) + * @param lumSrc scaled luma (Y) source data, 15bit for 8bit output * @param lumFilterSize number of vertical luma/alpha input lines to scale * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096] - * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) + * @param chrUSrc scaled chroma (U) source data, 15bit for 8bit output + * @param chrVSrc scaled chroma (V) source data, 15bit for 8bit output * @param chrFilterSize number of vertical chroma input lines to scale - * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param dest pointer to the output plane. For 16bit output, this is - * uint16_t + * @param alpSrc scaled alpha (A) source data, 15bit for 8bit output + * @param dest pointer to the output plane * @param dstW width of lumSrc and alpSrc in pixels, number of pixels * to write into dest[] * @param y vertical line number for this output. This does not need diff --git a/libswscale/utils.c b/libswscale/utils.c index 18d1227c83..c6abb6b446 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -896,15 +896,11 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) } } - c->scalingBpp = 1 + FFMAX(av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1, - av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1); - if (c->scalingBpp <= 8) - c->scalingBpp = 8; + c->scalingBpp = FFMAX(av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1, + av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1) >= 8 ? 16 : 8; if (c->scalingBpp == 16) dst_stride <<= 1; - FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, - FFALIGN(srcW, 16) * 2 * FFALIGN(c->scalingBpp, 8) >> 3, - fail); + FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW, 16) * 2 * c->scalingBpp >> 3, fail); if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2 && c->scalingBpp == 8) { c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0; if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) { @@ -1059,7 +1055,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) c->lumPixBuf[i] = c->lumPixBuf[i+c->vLumBufSize]; } // 64 / c->scalingBpp is the same as 16 / sizeof(scaling_intermediate) - c->uv_off_px = dst_stride_px + 64 / (c->scalingBpp &~ 7); + c->uv_off_px = dst_stride_px + 64 / c->scalingBpp; c->uv_off_byte = dst_stride + 16; for (i=0; ivChrBufSize; i++) { FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i+c->vChrBufSize], dst_stride*2+32, fail); diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc index 0da94f861e..3730988777 100644 --- a/tests/ref/lavfi/pixdesc +++ b/tests/ref/lavfi/pixdesc @@ -38,8 +38,8 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p10be a4a83d0811280eff7405d94a7de21596 -yuv422p10le 23717b6c73a59912c605f27877ae2fb6 +yuv422p10be 107c6e31a3d4d598bca1d8426aaa54f5 +yuv422p10le 3f478be644add24b6cc77e718a6e2afa yuv422p16be dc9886f2fccf87cc54b27e071a2c251e yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf diff --git a/tests/ref/lavfi/pixfmts_copy b/tests/ref/lavfi/pixfmts_copy index 0da94f861e..3730988777 100644 --- a/tests/ref/lavfi/pixfmts_copy +++ b/tests/ref/lavfi/pixfmts_copy @@ -38,8 +38,8 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p10be a4a83d0811280eff7405d94a7de21596 -yuv422p10le 23717b6c73a59912c605f27877ae2fb6 +yuv422p10be 107c6e31a3d4d598bca1d8426aaa54f5 +yuv422p10le 3f478be644add24b6cc77e718a6e2afa yuv422p16be dc9886f2fccf87cc54b27e071a2c251e yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf diff --git a/tests/ref/lavfi/pixfmts_null b/tests/ref/lavfi/pixfmts_null index 0da94f861e..3730988777 100644 --- a/tests/ref/lavfi/pixfmts_null +++ b/tests/ref/lavfi/pixfmts_null @@ -38,8 +38,8 @@ yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc yuv420p9be ce880fa07830e5297c22acf6e20555ce yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a -yuv422p10be a4a83d0811280eff7405d94a7de21596 -yuv422p10le 23717b6c73a59912c605f27877ae2fb6 +yuv422p10be 107c6e31a3d4d598bca1d8426aaa54f5 +yuv422p10le 3f478be644add24b6cc77e718a6e2afa yuv422p16be dc9886f2fccf87cc54b27e071a2c251e yuv422p16le f181c8d8436f1233ba566d9bc88005ec yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf diff --git a/tests/ref/lavfi/pixfmts_scale b/tests/ref/lavfi/pixfmts_scale index d68cdd41d0..392b9ce601 100644 --- a/tests/ref/lavfi/pixfmts_scale +++ b/tests/ref/lavfi/pixfmts_scale @@ -31,15 +31,15 @@ uyvy422 314bd486277111a95d9369b944fa0400 yuv410p 7df8f6d69b56a8dcb6c7ee908e5018b5 yuv411p 1143e7c5cc28fe0922b051b17733bc4c yuv420p fdad2d8df8985e3d17e73c71f713cb14 -yuv420p10be 04663d400e44692fe8a622a067f838da -yuv420p10le 6171850f66df7a727b4bed1c87ef9188 +yuv420p10be af5429f27b9f95bf955e795921c65cdc +yuv420p10le d0b47e6a8a44e6b5ca0fe4349a4e393b yuv420p16be 9688e33e03b8c8275ab2fb1df0f06bee yuv420p16le cba8b390ad5e7b8678e419b8ce79c008 -yuv420p9be ab163dfef03c4d563aca99b24276b9fd -yuv420p9le cd56c5a76ce74e504dd59d25a5e4389c +yuv420p9be a073b2d93b2a7dce2069ba252bc43175 +yuv420p9le b67233c3c7d93763d07d88f697c145e1 yuv422p 918e37701ee7377d16a8a6c119c56a40 -yuv422p10be e8e80fed7121f3afac994f2afac42cd2 -yuv422p10le 370866666f4889ee0928345b16d68fb4 +yuv422p10be 533fd21e7943c20a1026b19069b3b867 +yuv422p10le 59b20a4a8609f5da2dc54c78aea11e6c yuv422p16be 2cf502d7d386db1f1b3b946679d897b1 yuv422p16le 3002a4e47520731dcee5929aff49eb74 yuv440p 461503fdb9b90451020aa3b25ddf041c diff --git a/tests/ref/lavfi/pixfmts_vflip b/tests/ref/lavfi/pixfmts_vflip index a2b11690ab..2b62518a28 100644 --- a/tests/ref/lavfi/pixfmts_vflip +++ b/tests/ref/lavfi/pixfmts_vflip @@ -38,8 +38,8 @@ yuv420p16le 0f609e588e5a258644ef85170d70e030 yuv420p9be be40ec975fb2873891643cbbbddbc3b0 yuv420p9le 7e606310d3f5ff12badf911e8f333471 yuv422p d7f5cb44d9b0210d66d6a8762640ab34 -yuv422p10be 51d9ef13fe43ea9549b3792bfd449bf7 -yuv422p10le 4b286a243ee0e715b2961bc1b469e629 +yuv422p10be a28b051168af49435c04af5f58dce47b +yuv422p10le 35936ffff30df2697f47b9b8d2cb7dea yuv422p16be 51d9aa4e78d121c226d919ce97976fe4 yuv422p16le 12965c54bda8932ca72da194419a9908 yuv440p 876385e96165acf51271b20e5d85a416 From d0a2f0af9db7e84f1274c4ccf5d54022527664e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 1 Aug 2011 17:18:13 +0300 Subject: [PATCH 758/780] Move an int64_t down in MpegEncContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows using the same arm assembler offsets for both EABI and the mach-o ABI. Signed-off-by: Martin Storsjö --- libavcodec/arm/asm-offsets.h | 12 ++++++------ libavcodec/mpegvideo.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/arm/asm-offsets.h b/libavcodec/arm/asm-offsets.h index 110d33dbb5..89994569c1 100644 --- a/libavcodec/arm/asm-offsets.h +++ b/libavcodec/arm/asm-offsets.h @@ -29,11 +29,11 @@ #endif /* MpegEncContext */ -#define Y_DC_SCALE 0xb4 -#define C_DC_SCALE 0xb8 -#define AC_PRED 0xbc -#define BLOCK_LAST_INDEX 0xc0 -#define H263_AIC 0xf0 -#define INTER_SCANTAB_RASTER_END 0x138 +#define Y_DC_SCALE 0xa8 +#define C_DC_SCALE 0xac +#define AC_PRED 0xb0 +#define BLOCK_LAST_INDEX 0xb4 +#define H263_AIC 0xe4 +#define INTER_SCANTAB_RASTER_END 0x12c #endif /* AVCODEC_ARM_ASM_OFFSETS_H */ diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 315f319a80..00293db7c9 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -234,7 +234,6 @@ typedef struct MpegEncContext { int picture_number; //FIXME remove, unclear definition int picture_in_gop_number; ///< 0-> first pic in gop, ... int b_frames_since_non_b; ///< used for encoding, relative to not yet reordered input - int64_t user_specified_pts;///< last non zero pts from AVFrame which was passed into avcodec_encode_video() int mb_width, mb_height; ///< number of MBs horizontally & vertically int mb_stride; ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 int b8_stride; ///< 2*mb_width+1 used for some 8x8 block arrays to allow simple addressing @@ -261,6 +260,8 @@ typedef struct MpegEncContext { /* WARNING: changes above this line require updates to hardcoded * offsets used in asm. */ + int64_t user_specified_pts;///< last non zero pts from AVFrame which was passed into avcodec_encode_video() + /** bit output */ PutBitContext pb; From 9a83adaf346bc5e38183427b2bd11084c11d1c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5ns=20Rullg=C3=A5rd?= Date: Mon, 1 Aug 2011 20:21:04 +0300 Subject: [PATCH 759/780] arm: Avoid using the movw instruction needlessly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes building for ARM11 without Thumb2. Signed-off-by: Martin Storsjö --- libavcodec/arm/ac3dsp_armv6.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/arm/ac3dsp_armv6.S b/libavcodec/arm/ac3dsp_armv6.S index d3058ffcec..b6aee867b3 100644 --- a/libavcodec/arm/ac3dsp_armv6.S +++ b/libavcodec/arm/ac3dsp_armv6.S @@ -37,7 +37,7 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1 ldrb r10, [r4], #1 1: ldrsh r9, [r0], #2 @ mask[band] - movw r8, #0x1fe0 + mov r8, #0xff0 sub r9, r9, r12 @ - snr_offset mov r11, r10 ldrb r10, [r4], #1 @ band_start_tab[band++] @@ -45,7 +45,7 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1 it lt movlt r9, #0 cmp r10, r3 @ - end - and r9, r9, r8 @ & 0x1fe0 + and r9, r9, r8, lsl #1 @ & 0x1fe0 ite gt subgt r8, r3, r11 suble r8, r10, r11 From d68ba3feb80f9fbb6c80c2ede4a105062084fef8 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 2 Aug 2011 23:45:30 +0200 Subject: [PATCH 760/780] vf_boxblur: prefer the name "len" over "w" in the blur routines Make more clear the meaning of the variables. They specify the length of a (vertical or horizontal) line rather than a width. Less confusing. --- libavfilter/vf_boxblur.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c index 7fb1ec5ba2..398014a0b9 100644 --- a/libavfilter/vf_boxblur.c +++ b/libavfilter/vf_boxblur.c @@ -206,7 +206,7 @@ static int config_input(AVFilterLink *inlink) } static inline void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_step, - int w, int radius) + int len, int radius) { /* Naive boxblur would sum source pixels from x-radius .. x+radius * for destination pixel x. That would be O(radius*width). @@ -235,39 +235,39 @@ static inline void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_ dst[x*dst_step] = (sum*inv + (1<<15))>>16; } - for (; x < w-radius; x++) { + for (; x < len-radius; x++) { sum += src[(radius+x)*src_step] - src[(x-radius-1)*src_step]; dst[x*dst_step] = (sum*inv + (1<<15))>>16; } - for (; x < w; x++) { - sum += src[(2*w-radius-x-1)*src_step] - src[(x-radius-1)*src_step]; + for (; x < len; x++) { + sum += src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step]; dst[x*dst_step] = (sum*inv + (1<<15))>>16; } } static inline void blur_power(uint8_t *dst, int dst_step, const uint8_t *src, int src_step, - int w, int radius, int power, uint8_t *temp[2]) + int len, int radius, int power, uint8_t *temp[2]) { uint8_t *a = temp[0], *b = temp[1]; if (radius && power) { - blur(a, 1, src, src_step, w, radius); + blur(a, 1, src, src_step, len, radius); for (; power > 2; power--) { uint8_t *c; - blur(b, 1, a, 1, w, radius); + blur(b, 1, a, 1, len, radius); c = a; a = b; b = c; } if (power > 1) { - blur(dst, dst_step, a, 1, w, radius); + blur(dst, dst_step, a, 1, len, radius); } else { int i; - for (i = 0; i < w; i++) + for (i = 0; i < len; i++) dst[i*dst_step] = a[i]; } } else { int i; - for (i = 0; i < w; i++) + for (i = 0; i < len; i++) dst[i*dst_step] = src[i*src_step]; } } From a342517710690a8f113986e8d8e9d9ffabb701fe Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 3 Aug 2011 00:01:41 +0200 Subject: [PATCH 761/780] vf_boxblur: fix out-of-buffer access when h > w Increase size of the private temporary buffers from w to FFMAX(w, h), indeed they are used also for blurring vertical lines with length h. --- libavfilter/vf_boxblur.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c index 398014a0b9..676d2057cb 100644 --- a/libavfilter/vf_boxblur.c +++ b/libavfilter/vf_boxblur.c @@ -144,8 +144,8 @@ static int config_input(AVFilterLink *inlink) char *expr; int ret; - if (!(boxblur->temp[0] = av_malloc(w)) || - !(boxblur->temp[1] = av_malloc(w))) + if (!(boxblur->temp[0] = av_malloc(FFMAX(w, h))) || + !(boxblur->temp[1] = av_malloc(FFMAX(w, h)))) return AVERROR(ENOMEM); boxblur->hsub = desc->log2_chroma_w; From f1b7c7e697e04b5fbbc39bd282956a16d408437d Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 2 Aug 2011 23:58:19 +0200 Subject: [PATCH 762/780] vf_boxblur: call avfilter_draw_slice() at the end of draw_slice() --- libavfilter/vf_boxblur.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c index 676d2057cb..a10b630ed5 100644 --- a/libavfilter/vf_boxblur.c +++ b/libavfilter/vf_boxblur.c @@ -328,6 +328,8 @@ static void draw_slice(AVFilterLink *inlink, int y0, int h0, int slice_dir) outpicref->data[plane], outpicref->linesize[plane], w[plane], h[plane], boxblur->radius[plane], boxblur->power[plane], boxblur->temp); + + avfilter_draw_slice(outlink, y0, h0, slice_dir); } AVFilter avfilter_vf_boxblur = { From eb29649cad7c133e68f0194b9b913f039a7c623f Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 3 Aug 2011 11:42:33 +0200 Subject: [PATCH 763/780] Set bits_per_coded_sample when encoding ADPCM. --- libavcodec/adpcm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index ba312558b0..4e1299379f 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -198,6 +198,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 / (4 * avctx->channels) + 1; /* each 16 bits sample gives one nibble */ /* and we have 4 bytes per channel overhead */ avctx->block_align = BLKSIZE; + avctx->bits_per_coded_sample = 4; /* seems frame_size isn't taken into account... have to buffer the samples :-( */ break; case CODEC_ID_ADPCM_IMA_QT: @@ -208,6 +209,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2; /* each 16 bits sample gives one nibble */ /* and we have 7 bytes per channel overhead */ avctx->block_align = BLKSIZE; + avctx->bits_per_coded_sample = 4; avctx->extradata_size = 32; extradata = avctx->extradata = av_malloc(avctx->extradata_size); if (!extradata) From 08d2cee49c323715b66df0e4ff45ec0e07aaea7b Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 3 Aug 2011 11:45:02 +0200 Subject: [PATCH 764/780] Fix -loop_input. --- doc/ffmpeg.texi | 2 +- ffmpeg.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 2e1d469612..832e3d8fe2 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -732,7 +732,7 @@ Read input at native frame rate. Mainly used to simulate a grab device. @item -loop_input Loop over the input stream. Currently it works only for image streams. This option is used for automatic FFserver testing. -This option is deprecated, use -loop. +This option is deprecated, use -loop 1. @item -loop_output @var{number_of_times} Repeatedly loop output for formats that support looping such as animated GIF (0 will loop the output infinitely). diff --git a/ffmpeg.c b/ffmpeg.c index 2a1ee79bad..957abed388 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3347,6 +3347,11 @@ static int opt_input_file(const char *opt, const char *filename) find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0); ic->flags |= AVFMT_FLAG_NONBLOCK; + if (loop_input) { + av_log(NULL, AV_LOG_WARNING, "-loop_input is deprecated, use -loop 1\n"); + ic->loop_input = loop_input; + } + /* open the input file with generic libav function */ err = avformat_open_input(&ic, filename, file_iformat, &format_opts); if (err < 0) { @@ -3379,11 +3384,6 @@ static int opt_input_file(const char *opt, const char *filename) opt_programid=0; } - if (loop_input) { - av_log(NULL, AV_LOG_WARNING, "-loop_input is deprecated, use -loop 1\n"); - ic->loop_input = loop_input; - } - /* Set AVCodecContext options for avformat_find_stream_info */ opts = setup_find_stream_info_opts(ic, codec_opts); orig_nb_streams = ic->nb_streams; From 324b8adca4455cff861b6587921ce68df6cee286 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 3 Aug 2011 13:09:42 +0200 Subject: [PATCH 765/780] Fix a possible miscompilation of cabac with old (broken) compilers. --- libavcodec/x86/cabac.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h index 545cf7c464..5c46342808 100644 --- a/libavcodec/x86/cabac.h +++ b/libavcodec/x86/cabac.h @@ -87,13 +87,19 @@ static av_always_inline int get_cabac_inline_x86(CABACContext *c, uint8_t *const state) { - int bit, tmp; + int bit, low, range, tmp; __asm__ volatile( + "movl %a6(%5), %2 \n\t" + "movl %a7(%5), %1 \n\t" BRANCHLESS_GET_CABAC("%0", "%5", "(%4)", "%1", "%w1", "%2", - "%3", "%b3", "%a6") - :"=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp) + "%3", "%b3", "%a8") + "movl %2, %a6(%5) \n\t" + "movl %1, %a7(%5) \n\t" + + :"=&r"(bit), "=&r"(low), "=&r"(range), "=&q"(tmp) :"r"(state), "r"(c), + "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)), "i"(offsetof(CABACContext, bytestream)) : "%"REG_c, "memory" ); From 652c772981f18c8d1523b572a4c57606801c60e7 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 3 Aug 2011 19:01:09 +0200 Subject: [PATCH 766/780] avidec: Fix XAN DPCM demuxing. Signed-off-by: Michael Niedermayer --- libavformat/avidec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index b9da236412..2814b89d22 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -667,6 +667,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) if (st->codec->stream_codec_tag == AV_RL32("Axan")){ st->codec->codec_id = CODEC_ID_XAN_DPCM; st->codec->codec_tag = 0; + ast->dshow_block_align = 0; } if (amv_file_format){ st->codec->codec_id = CODEC_ID_ADPCM_IMA_AMV; From 46eaaad8dd12eb6c962bc0f1d528afff933dc872 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 3 Aug 2011 17:44:50 +0200 Subject: [PATCH 767/780] Detect NI-avi at playtime like mplayer. Fixes Ticket333 Signed-off-by: Michael Niedermayer --- libavformat/avidec.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 2814b89d22..5dac749fc5 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -73,6 +73,7 @@ typedef struct { int odml_depth; int use_odml; #define MAX_ODML_DEPTH 1000 + int64_t dts_max; } AVIContext; @@ -1168,6 +1169,16 @@ resync: } ast->seek_pos= 0; + if(!avi->non_interleaved && st->nb_index_entries>1){ + int64_t dts= av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q); + + if(avi->dts_max - dts > 2*AV_TIME_BASE){ + avi->non_interleaved= 1; + av_log(s, AV_LOG_INFO, "Switching to NI mode, due to poor interleaving\n"); + }else if(avi->dts_max < dts) + avi->dts_max = dts; + } + return size; } @@ -1407,6 +1418,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp /* do the seek */ avio_seek(s->pb, pos_min, SEEK_SET); avi->stream_index= -1; + avi->dts_max= INT_MIN; return 0; } From 1816addc4ebedd8d08633fbff0daf52bf4e4b77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Wed, 3 Aug 2011 20:05:59 +0200 Subject: [PATCH 768/780] Warn when falling back to unreliable UMF fps tag. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Reimar Döffinger --- libavformat/gxf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/gxf.c b/libavformat/gxf.c index 15893a44af..898dce7eb5 100644 --- a/libavformat/gxf.c +++ b/libavformat/gxf.c @@ -346,6 +346,8 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { avio_skip(pb, 0x30); // payload description fps = fps_umf2avr(avio_rl32(pb)); if (!main_timebase.num || !main_timebase.den) { + av_log(s, AV_LOG_WARNING, "No FPS track tag, using UMF fps tag." + " This might give wrong results.\n"); // this may not always be correct, but simply the best we can get main_timebase.num = fps.den; main_timebase.den = fps.num * 2; From 99c7b516414e76c90446a865ca5a02df3117f694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Wed, 3 Aug 2011 20:09:53 +0200 Subject: [PATCH 769/780] Abort if command offset decreases, avoids potential endless loop. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Reimar Döffinger --- libavcodec/dvdsubdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 27a33eaef2..1c3d75e2e3 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -344,6 +344,10 @@ static int decode_dvd_subtitles(AVSubtitle *sub_header, sub_header->rects[0]->pict.linesize[0] = w; } } + if (next_cmd_pos < cmd_pos) { + av_log(NULL, AV_LOG_ERROR, "Invalid command offset\n"); + break; + } if (next_cmd_pos == cmd_pos) break; cmd_pos = next_cmd_pos; From 933a6fd5a1a2dfe3da58b6e15b394bf05d32f2eb Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 3 Aug 2011 23:27:50 +0200 Subject: [PATCH 770/780] cosmetics: fix indentation/alignment in AVCodec declarations --- libavcodec/8bps.c | 2 +- libavcodec/tscc.c | 2 +- libavcodec/xsubdec.c | 10 +++++----- libavcodec/xsubenc.c | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index 7c53432738..de8dd8ee84 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -229,5 +229,5 @@ AVCodec ff_eightbps_decoder = { .close = decode_end, .decode = decode_frame, .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("QuickTime 8BPS video"), + .long_name = NULL_IF_CONFIG_SMALL("QuickTime 8BPS video"), }; diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index b97c527c94..df4b09b07c 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -207,6 +207,6 @@ AVCodec ff_tscc_decoder = { .close = decode_end, .decode = decode_frame, .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("TechSmith Screen Capture Codec"), + .long_name = NULL_IF_CONFIG_SMALL("TechSmith Screen Capture Codec"), }; diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 0791fdd05c..af87388928 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -134,10 +134,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, } AVCodec ff_xsub_decoder = { - .name = "xsub", - .type = AVMEDIA_TYPE_SUBTITLE, - .id = CODEC_ID_XSUB, - .init = decode_init, - .decode = decode_frame, + .name = "xsub", + .type = AVMEDIA_TYPE_SUBTITLE, + .id = CODEC_ID_XSUB, + .init = decode_init, + .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("XSUB"), }; diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c index 6e3fed0cd5..b33640dd2c 100644 --- a/libavcodec/xsubenc.c +++ b/libavcodec/xsubenc.c @@ -211,10 +211,10 @@ static av_cold int xsub_encoder_init(AVCodecContext *avctx) } AVCodec ff_xsub_encoder = { - .name = "xsub", - .type = AVMEDIA_TYPE_SUBTITLE, - .id = CODEC_ID_XSUB, - .init = xsub_encoder_init, - .encode = xsub_encode, + .name = "xsub", + .type = AVMEDIA_TYPE_SUBTITLE, + .id = CODEC_ID_XSUB, + .init = xsub_encoder_init, + .encode = xsub_encode, .long_name = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"), }; From fed6c90b68fa00ad399e0b6d51c1e41d0d3730a0 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 3 Aug 2011 23:28:26 +0200 Subject: [PATCH 771/780] cosmetics: remove some stray comments from AVCodec declarations --- libavcodec/cljr.c | 1 - libavcodec/vcr1.c | 1 - 2 files changed, 2 deletions(-) diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c index f79cf11bea..3050fe204e 100644 --- a/libavcodec/cljr.c +++ b/libavcodec/cljr.c @@ -159,7 +159,6 @@ AVCodec ff_cljr_encoder = { .priv_data_size = sizeof(CLJRContext), .init = encode_init, .encode = encode_frame, - //encode_end, .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"), }; #endif diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c index 9eb6a72875..f745089422 100644 --- a/libavcodec/vcr1.c +++ b/libavcodec/vcr1.c @@ -196,7 +196,6 @@ AVCodec ff_vcr1_encoder = { .priv_data_size = sizeof(VCR1Context), .init = encode_init, .encode = encode_frame, - //encode_end, .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"), }; #endif From 4ce0a94656591eb2a6f567e0c6778e2cc96c17b0 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 28 Jul 2011 12:30:19 +0200 Subject: [PATCH 772/780] lsws: remove deprecated and unused stuff after the 0->1 major bump --- libswscale/rgb2rgb.c | 28 ---------------------------- libswscale/rgb2rgb.h | 11 ----------- libswscale/swscale.h | 16 ---------------- libswscale/swscale_unscaled.c | 8 -------- libswscale/utils.c | 7 ------- 5 files changed, 70 deletions(-) diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 84ef43b774..9a7f698935 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -123,34 +123,6 @@ void sws_rgb2rgb_init(void) rgb2rgb_init_x86(); } -#if LIBSWSCALE_VERSION_MAJOR < 1 -void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) -{ - sws_convertPalette8ToPacked32(src, dst, num_pixels, palette); -} - -void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) -{ - sws_convertPalette8ToPacked24(src, dst, num_pixels, palette); -} - -/** - * Palette is assumed to contain BGR16, see rgb32to16 to convert the palette. - */ -void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) -{ - long i; - for (i=0; i Date: Thu, 4 Aug 2011 01:04:50 +0200 Subject: [PATCH 773/780] avidec: skip seek pos adjustment for non interleaved files. Fixes Ticket327 Signed-off-by: Michael Niedermayer --- libavformat/avidec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 5dac749fc5..d454ce56f9 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -1410,7 +1410,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp flags | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0)); if(index<0) index=0; - while(index>0 && st2->index_entries[index-1].pos >= pos_min) + while(!avi->non_interleaved && index>0 && st2->index_entries[index-1].pos >= pos_min) index--; ast2->frame_offset = st2->index_entries[index].timestamp; } From ad62507f325ae4e93690a581283eb54dcfd4fee0 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 3 Aug 2011 17:31:11 -0700 Subject: [PATCH 774/780] h263dec: Fix asserts broken by the elimination of FF_COMMON_FRAME. --- libavcodec/h263dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 7f3411b779..cba0c5a208 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -705,8 +705,8 @@ intrax8_decoded: MPV_frame_end(s); -assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); -assert(s->current_picture.pict_type == s->pict_type); + assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type); + assert(s->current_picture.f.pict_type == s->pict_type); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { *pict= *(AVFrame*)s->current_picture_ptr; } else if (s->last_picture_ptr != NULL) { From 31fe5d9825a050ca319ab9ddbe502d84ac3a576e Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Thu, 4 Aug 2011 11:06:43 +0200 Subject: [PATCH 775/780] Fix possible crash when decoding mpeg streams. This reverts 2cf8355f98681bdd726b739008acd5483f82f8d7, fixes ticket 329. --- ffmpeg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 957abed388..f23bb6ec07 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -335,6 +335,7 @@ typedef struct InputFile { int eof_reached; /* true if eof reached */ int ist_index; /* index of first stream in ist_table */ int buffer_size; /* current total buffer size */ + int nb_streams; int64_t ts_offset; } InputFile; @@ -2063,7 +2064,7 @@ static int transcode(AVFormatContext **output_files, int si = stream_maps[i].stream_index; if (fi < 0 || fi > nb_input_files - 1 || - si < 0 || si > input_files[fi].ctx->nb_streams - 1) { + si < 0 || si > input_files[fi].nb_streams - 1) { fprintf(stderr,"Could not find input stream #%d.%d\n", fi, si); ret = AVERROR(EINVAL); goto fail; @@ -2769,7 +2770,7 @@ static int transcode(AVFormatContext **output_files, } /* the following test is needed in case new streams appear dynamically in stream : we ignore them */ - if (pkt.stream_index >= input_files[file_index].ctx->nb_streams) + if (pkt.stream_index >= input_files[file_index].nb_streams) goto discard_packet; ist_index = input_files[file_index].ist_index + pkt.stream_index; ist = &input_streams[ist_index]; @@ -3490,6 +3491,7 @@ static int opt_input_file(const char *opt, const char *filename) input_files[nb_input_files - 1].ctx = ic; input_files[nb_input_files - 1].ist_index = nb_input_streams - ic->nb_streams; input_files[nb_input_files - 1].ts_offset = input_ts_offset - (copy_ts ? 0 : timestamp); + input_files[nb_input_files - 1].nb_streams = ic->nb_streams; top_field_first = -1; frame_rate = (AVRational){0, 0}; From 1bf6cb85bebe639c836cdbb4498ea5bc252a7c21 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Thu, 4 Aug 2011 01:06:58 +0200 Subject: [PATCH 776/780] applehttp: fix variant discard logic The v->ctx is always not NULL now, check for streams presence to mark the read_header state. Fixes bug #25, possibly introduced by 603b8bc --- libavformat/applehttp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index 906511ed06..10f58afde5 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -412,7 +412,7 @@ reload: c->end_of_segment = 1; c->cur_seq_no = v->cur_seq_no; - if (v->ctx) { + if (v->ctx && v->ctx->nb_streams) { v->needed = 0; for (i = v->stream_offset; i < v->stream_offset + v->ctx->nb_streams; i++) { From 9e63720b4b1241a9b17622b789c47cff6e180a4f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 4 Aug 2011 17:04:14 +0200 Subject: [PATCH 777/780] mpegvideo.h: remove the 1 line difference to qatar Signed-off-by: Michael Niedermayer --- libavcodec/mpegvideo.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index a25e8aa4c7..44a0dd671d 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -211,7 +211,6 @@ typedef struct MpegEncContext { /* the following codec id fields are deprecated in favor of codec_id */ int h263_plus; ///< h263 plus headers - int h263_msmpeg4; ///< generate MSMPEG4 compatible stream (deprecated, use msmpeg4_version instead) int h263_flv; ///< use flv h263 header enum CodecID codec_id; /* see CODEC_ID_xxx */ From 82b1516a85ad21b5455dcfef6fe49d1189565c33 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 4 Aug 2011 00:25:35 +0200 Subject: [PATCH 778/780] yadif: correct documentation on the parity parameter 0 is top-field-first, 1 is bottom-field-first, not the other way around. Fix trac issue #380. --- doc/filters.texi | 4 ++-- libavfilter/vf_yadif.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 27474024a9..33d6496b8a 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1846,9 +1846,9 @@ interlaced video, accepts one of the following values: @table @option @item 0 -assume bottom field first -@item 1 assume top field first +@item 1 +assume bottom field first @item -1 enable automatic detection @end table diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 6fc9f479e7..13186e79ad 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -36,8 +36,8 @@ typedef struct { int mode; /** - * 0: bottom field first - * 1: top field first + * 0: top field first + * 1: bottom field first * -1: auto-detection */ int parity; From 48734a54e8dc1ad7ec1c59dece6e132e97e7e79b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 4 Aug 2011 23:49:14 +0200 Subject: [PATCH 779/780] filters.texi: fix wrong references in the "Filtergraph syntax" section --- doc/filters.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 33d6496b8a..b41fce7ced 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -18,8 +18,8 @@ output pads is called a "sink". A filtergraph can be represented using a textual representation, which is recognized by the @code{-vf} and @code{-af} options of the ff* -tools, and by the @code{av_parse_graph()} function defined in -@file{libavfilter/avfiltergraph}. +tools, and by the @code{avfilter_graph_parse()} function defined in +@file{libavfilter/avfiltergraph.h}. A filterchain consists of a sequence of connected filters, each one connected to the previous one in the sequence. A filterchain is From 6e19cfb083eda83aaf4b49ae765ab2b3e578d32d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 5 Aug 2011 01:18:07 +0200 Subject: [PATCH 780/780] ffmpeg: Fix doxygen comments for MetadataMap Signed-off-by: Michael Niedermayer --- ffmpeg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index f23bb6ec07..672ad2d152 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -101,9 +101,9 @@ typedef struct StreamMap { * select an input file for an output file */ typedef struct MetadataMap { - int file; //< file index - char type; //< type of metadata to copy -- (g)lobal, (s)tream, (c)hapter or (p)rogram - int index; //< stream/chapter/program number + int file; ///< file index + char type; ///< type of metadata to copy -- (g)lobal, (s)tream, (c)hapter or (p)rogram + int index; ///< stream/chapter/program number } MetadataMap; typedef struct ChapterMap {