From 8c4aebb58d00fd613f3f684bf0f869966149ae78 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 28 Jan 2013 19:34:55 +0100 Subject: [PATCH 001/182] qdm2: increase noise_table size This prevents out of array reads. An alternative solution would be to check the index but this would require several checks in the inner loops Yet another alternative would be to change the index reset logic but this likely would introduce a difference to the binary decoder Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/qdm2_tablegen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qdm2_tablegen.h b/libavcodec/qdm2_tablegen.h index 585edfdd65..a90682f43c 100644 --- a/libavcodec/qdm2_tablegen.h +++ b/libavcodec/qdm2_tablegen.h @@ -37,7 +37,7 @@ #include "libavcodec/qdm2_tables.h" #else static uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1]; -static float noise_table[4096]; +static float noise_table[4096 + 20]; static uint8_t random_dequant_index[256][5]; static uint8_t random_dequant_type24[128][3]; static float noise_samples[128]; From 5c9cae744752932d46fd847fa4161790620daccf Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 28 Jan 2013 20:00:55 +0100 Subject: [PATCH 002/182] dirac: Only use MMX if MMX is available. Signed-off-by: Michael Niedermayer --- libavcodec/x86/diracdsp_mmx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/x86/diracdsp_mmx.c b/libavcodec/x86/diracdsp_mmx.c index ee89295c94..cb6465f950 100644 --- a/libavcodec/x86/diracdsp_mmx.c +++ b/libavcodec/x86/diracdsp_mmx.c @@ -60,6 +60,9 @@ void ff_diracdsp_init_mmx(DiracDSPContext* c) { int mm_flags = av_get_cpu_flags(); + if (!(mm_flags & AV_CPU_FLAG_MMX)) + return; + #if HAVE_YASM c->add_dirac_obmc[0] = ff_add_dirac_obmc8_mmx; #if !ARCH_X86_64 From 94ef1667bb04ed81ff10f7ba4b8d7e54bd8bc76b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 28 Jan 2013 20:40:13 +0100 Subject: [PATCH 003/182] dirac/x86: Fix handling blocksizes that are not a multiple of 4 Fixes out of array accesses Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/x86/dsputil_mmx.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 303d36d109..dcf2345954 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -1612,16 +1612,26 @@ void ff_avg_vc1_mspel_mc00_mmxext(uint8_t *dst, const uint8_t *src, #define DIRAC_PIXOP(OPNAME2, OPNAME, EXT)\ void ff_ ## OPNAME2 ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ {\ - OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\ + if (h&3)\ + ff_ ## OPNAME2 ## _dirac_pixels8_c(dst, src, stride, h);\ + else\ + OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\ }\ void ff_ ## OPNAME2 ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ {\ - OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\ + if (h&3)\ + ff_ ## OPNAME2 ## _dirac_pixels16_c(dst, src, stride, h);\ + else\ + OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\ }\ void ff_ ## OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ {\ - OPNAME ## _pixels16_ ## EXT(dst , src[0] , stride, h);\ - OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\ + if (h&3) {\ + ff_ ## OPNAME2 ## _dirac_pixels32_c(dst, src, stride, h);\ + } else {\ + OPNAME ## _pixels16_ ## EXT(dst , src[0] , stride, h);\ + OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\ + }\ } DIRAC_PIXOP(put, put, mmx) @@ -1631,21 +1641,35 @@ DIRAC_PIXOP(avg, ff_avg, mmxext) #if HAVE_YASM void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { + if (h&3) + ff_put_dirac_pixels16_c(dst, src, stride, h); + else ff_put_pixels16_sse2(dst, src[0], stride, h); } void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { + if (h&3) + ff_avg_dirac_pixels16_c(dst, src, stride, h); + else ff_avg_pixels16_sse2(dst, src[0], stride, h); } void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { + if (h&3) { + ff_put_dirac_pixels32_c(dst, src, stride, h); + } else { ff_put_pixels16_sse2(dst , src[0] , stride, h); ff_put_pixels16_sse2(dst+16, src[0]+16, stride, h); + } } void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { + if (h&3) { + ff_avg_dirac_pixels32_c(dst, src, stride, h); + } else { ff_avg_pixels16_sse2(dst , src[0] , stride, h); ff_avg_pixels16_sse2(dst+16, src[0]+16, stride, h); + } } #endif #endif From f550583c00e231b587d8ef98451cfbb6b6561eb6 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 28 Jan 2013 20:19:07 +0100 Subject: [PATCH 004/182] bfin: update VP3 idct The block must be set to 0. --- libavcodec/bfin/vp3_bfin.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/bfin/vp3_bfin.c b/libavcodec/bfin/vp3_bfin.c index 962d3832e5..267918cd6a 100644 --- a/libavcodec/bfin/vp3_bfin.c +++ b/libavcodec/bfin/vp3_bfin.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "libavcodec/avcodec.h" #include "libavcodec/dsputil.h" #include "dsputil_bfin.h" @@ -33,6 +35,8 @@ void ff_bfin_vp3_idct_put (uint8_t *dest, int line_size, int16_t *block) for (i=0;i<8;i++) for (j=0;j<8;j++) dest[line_size*i+j]=cm[block[i*8+j]]; + + memset(block, 0, 128); } /* Inter iDCT */ @@ -40,4 +44,6 @@ void ff_bfin_vp3_idct_add (uint8_t *dest, int line_size, int16_t *block) { ff_bfin_vp3_idct (block); ff_bfin_add_pixels_clamped (block, dest, line_size); + + memset(block, 0, 128); } From 438ea561ade14299f9ea22202a07020870487e09 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 28 Jan 2013 20:22:54 +0100 Subject: [PATCH 005/182] bfin: Separate VP3 initialization code --- libavcodec/bfin/Makefile | 4 ++-- libavcodec/bfin/dsputil_bfin.c | 8 +------- libavcodec/bfin/dsputil_bfin.h | 3 --- libavcodec/bfin/vp3_bfin.c | 9 ++++++++- libavcodec/vp3dsp.c | 2 ++ libavcodec/vp3dsp.h | 1 + 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/libavcodec/bfin/Makefile b/libavcodec/bfin/Makefile index be81e6c39a..d1b41bc7f4 100644 --- a/libavcodec/bfin/Makefile +++ b/libavcodec/bfin/Makefile @@ -2,7 +2,7 @@ OBJS += bfin/dsputil_bfin.o \ bfin/fdct_bfin.o \ bfin/idct_bfin.o \ bfin/pixels_bfin.o \ - bfin/vp3_bfin.o \ - bfin/vp3_idct_bfin.o \ OBJS-$(CONFIG_MPEGVIDEOENC) += bfin/mpegvideo_bfin.o +OBJS-$(CONFIG_VP3DSP) += bfin/vp3_bfin.o \ + bfin/vp3_idct_bfin.o diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c index 5d6018400c..896a3c55f6 100644 --- a/libavcodec/bfin/dsputil_bfin.c +++ b/libavcodec/bfin/dsputil_bfin.c @@ -257,13 +257,7 @@ void ff_dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) if (avctx->dct_algo == FF_DCT_AUTO) c->fdct = ff_bfin_fdct; - // FIXME convert to VP3DSPContext - if (0) { // 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) { + 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; diff --git a/libavcodec/bfin/dsputil_bfin.h b/libavcodec/bfin/dsputil_bfin.h index a7c586374f..238c73c4fd 100644 --- a/libavcodec/bfin/dsputil_bfin.h +++ b/libavcodec/bfin/dsputil_bfin.h @@ -38,9 +38,6 @@ void ff_bfin_idct (int16_t *block) attribute_l1_text; void ff_bfin_fdct (int16_t *block) attribute_l1_text; -void ff_bfin_vp3_idct (int16_t *block); -void ff_bfin_vp3_idct_put (uint8_t *dest, int line_size, int16_t *block); -void ff_bfin_vp3_idct_add (uint8_t *dest, int line_size, int16_t *block); void ff_bfin_add_pixels_clamped (const int16_t *block, uint8_t *dest, int line_size) attribute_l1_text; void ff_bfin_put_pixels_clamped (const int16_t *block, uint8_t *dest, int line_size) attribute_l1_text; void ff_bfin_diff_pixels (int16_t *block, const uint8_t *s1, const uint8_t *s2, int stride) attribute_l1_text; diff --git a/libavcodec/bfin/vp3_bfin.c b/libavcodec/bfin/vp3_bfin.c index 267918cd6a..68c17ee39f 100644 --- a/libavcodec/bfin/vp3_bfin.c +++ b/libavcodec/bfin/vp3_bfin.c @@ -21,8 +21,9 @@ #include #include "libavcodec/avcodec.h" -#include "libavcodec/dsputil.h" +#include "libavcodec/vp3dsp.h" #include "dsputil_bfin.h" +#include "vp3_bfin.h" /* Intra iDCT offset 128 */ void ff_bfin_vp3_idct_put (uint8_t *dest, int line_size, int16_t *block) @@ -47,3 +48,9 @@ void ff_bfin_vp3_idct_add (uint8_t *dest, int line_size, int16_t *block) memset(block, 0, 128); } + +void ff_vp3dsp_init_bfin(VP3DSPContext *c, int flags) +{ + c->idct_add = ff_bfin_vp3_idct_add; + c->idct_put = ff_bfin_vp3_idct_put; +} diff --git a/libavcodec/vp3dsp.c b/libavcodec/vp3dsp.c index f6d2c2a3b3..01649f0f57 100644 --- a/libavcodec/vp3dsp.c +++ b/libavcodec/vp3dsp.c @@ -310,6 +310,8 @@ av_cold void ff_vp3dsp_init(VP3DSPContext *c, int flags) if (ARCH_ARM) ff_vp3dsp_init_arm(c, flags); + if (ARCH_BFIN) + ff_vp3dsp_init_bfin(c, flags); if (ARCH_PPC) ff_vp3dsp_init_ppc(c, flags); if (ARCH_X86) diff --git a/libavcodec/vp3dsp.h b/libavcodec/vp3dsp.h index a5e25ec7bb..755271d37c 100644 --- a/libavcodec/vp3dsp.h +++ b/libavcodec/vp3dsp.h @@ -49,6 +49,7 @@ typedef struct VP3DSPContext { void ff_vp3dsp_init(VP3DSPContext *c, int flags); void ff_vp3dsp_init_arm(VP3DSPContext *c, int flags); +void ff_vp3dsp_init_bfin(VP3DSPContext *c, int flags); void ff_vp3dsp_init_ppc(VP3DSPContext *c, int flags); void ff_vp3dsp_init_x86(VP3DSPContext *c, int flags); From 1336382c6d4d45e2c3513bf79f079349580a6db1 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 28 Jan 2013 21:44:25 +0100 Subject: [PATCH 006/182] avfilter_get_audio_buffer_ref_from_frame: fix handling of >8 channels Found-by: inferno@chromium.org Reported-by: Dale Curtis Signed-off-by: Michael Niedermayer --- libavfilter/avcodec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c index 2343d19e9c..dd3c886df0 100644 --- a/libavfilter/avcodec.c +++ b/libavfilter/avcodec.c @@ -102,7 +102,7 @@ AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame } samplesref = avfilter_get_audio_buffer_ref_from_arrays_channels( - (uint8_t **)frame->data, frame->linesize[0], perms, + (uint8_t **)frame->extended_data, frame->linesize[0], perms, frame->nb_samples, frame->format, channels, layout); if (!samplesref) return NULL; From 14c8ee00ffd9d45e6e0c6f11a957ce7e56f7eb3a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 28 Jan 2013 22:43:30 +0100 Subject: [PATCH 007/182] vp3dec: move threads check out of header packet type check Prevents reconfiguration with threads which is unsupported and would bring the contexts into an inconsistent state. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/vp3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 792dbb2a61..00a77e9e78 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -1928,11 +1928,11 @@ static int vp3_decode_frame(AVCodecContext *avctx, int type = get_bits(&gb, 7); skip_bits_long(&gb, 6*8); /* "theora" */ + if (s->avctx->active_thread_type&FF_THREAD_FRAME) { + av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n"); + return AVERROR_PATCHWELCOME; + } if (type == 0) { - if (s->avctx->active_thread_type&FF_THREAD_FRAME) { - av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n"); - return AVERROR_PATCHWELCOME; - } vp3_decode_end(avctx); ret = theora_decode_header(avctx, &gb); From 3939b790f2eb1d747a1ca80c4db4e2a145812af4 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 28 Jan 2013 23:12:24 +0100 Subject: [PATCH 008/182] wmavoicedec: use the checked bitstream, reader Fixes out of array reads Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/wmavoice.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index c3b6ab3b5f..8dd3f25052 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -25,8 +25,6 @@ * @author Ronald S. Bultje */ -#define UNCHECKED_BITSTREAM_READER 1 - #include #include "libavutil/channel_layout.h" From 9efceaf1f788e997fbf9a72ee6f90c52374eaaea Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 28 Jan 2013 22:47:30 +0000 Subject: [PATCH 009/182] takdec: switch to init_get_bits8() Signed-off-by: Paul B Mahol --- libavcodec/takdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index 86c1a7dda5..af6454304c 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -693,7 +693,8 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, if (pkt->size < TAK_MIN_FRAME_HEADER_BYTES) return AVERROR_INVALIDDATA; - init_get_bits(gb, pkt->data, pkt->size * 8); + if ((ret = init_get_bits8(gb, pkt->data, pkt->size)) < 0) + return ret; if ((ret = ff_tak_decode_frame_header(avctx, gb, &s->ti, 0)) < 0) return ret; From c59211b437aaaf2592bc20bd26c6cf526fd4fb64 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 26 Jan 2013 12:19:34 +0100 Subject: [PATCH 010/182] x86: Simplify some arch conditionals --- libavcodec/x86/h264_qpel.c | 2 +- libavcodec/x86/idct_sse2_xvid.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c index 64af8fe17c..be4eaa98b4 100644 --- a/libavcodec/x86/h264_qpel.c +++ b/libavcodec/x86/h264_qpel.c @@ -544,7 +544,7 @@ void ff_h264qpel_init_x86(H264QpelContext *c, int bit_depth) SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmxext, ); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmxext, ); } else if (bit_depth == 10) { -#if !ARCH_X86_64 +#if ARCH_X86_32 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_); diff --git a/libavcodec/x86/idct_sse2_xvid.c b/libavcodec/x86/idct_sse2_xvid.c index fe2478e55e..f083a2cbaa 100644 --- a/libavcodec/x86/idct_sse2_xvid.c +++ b/libavcodec/x86/idct_sse2_xvid.c @@ -377,7 +377,7 @@ inline void ff_idct_xvid_sse2(short *block) JZ("%%esi", "1f") "5: \n\t" iMTX_MULT("7*16(%0)", MANGLE(iTab2), ROUND(walkenIdctRounders+5*16), PUT_ODD(ROW7)) -#if !ARCH_X86_64 +#if ARCH_X86_32 iLLM_HEAD #endif iLLM_PASS("%0") From f9a8eeb08c4ccfd0678047e64b0f616ae1379c27 Mon Sep 17 00:00:00 2001 From: Piotr Bandurski Date: Tue, 29 Jan 2013 11:01:13 +1100 Subject: [PATCH 011/182] iff/deep: fix rle32 on big-endian Fixes ticket #2197. Signed-off-by: Peter Ross --- libavcodec/iff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 6b1fd89d6b..8e7f8cae46 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -576,7 +576,7 @@ static void decode_deep_rle32(uint8_t *dst, const uint8_t *src, int src_size, in } } else { int size = -opcode + 1; - uint32_t pixel = AV_RL32(src); + uint32_t pixel = AV_RN32(src); for (i = 0; i < size; i++) { *(uint32_t *)(dst + y*linesize + x * 4) = pixel; x += 1; From 11c99c78bafa77f679a1a3ba06ad00984b9a4cae Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 04:17:48 +0100 Subject: [PATCH 012/182] h264: check the pixel format directly and force a reinit on mismatches. The existing checks are insufficient to detect a pixel format changes in case of some damaged streams. Fixes inconsistency and later out of array accesses Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/h264.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 8436032b18..a3f8db294c 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2776,7 +2776,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0) || s->avctx->bits_per_raw_sample != h->sps.bit_depth_luma || h->cur_chroma_format_idc != h->sps.chroma_format_idc || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))); - + if (h0->s.avctx->pix_fmt != get_pixel_format(h0)) + must_reinit = 1; s->mb_width = h->sps.mb_width; s->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag); From f1c395944ce9c80ab0104570691462589c078eb2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 21 Nov 2012 14:55:05 +0100 Subject: [PATCH 013/182] eatgv: use fixed-width types where appropriate. --- libavcodec/eatgv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index a40ea839d6..792eaf708e 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -42,10 +42,10 @@ typedef struct TgvContext { AVFrame frame; AVFrame last_frame; int width,height; - unsigned int palette[AVPALETTE_COUNT]; + uint32_t palette[AVPALETTE_COUNT]; int (*mv_codebook)[2]; - unsigned char (*block_codebook)[16]; + uint8_t (*block_codebook)[16]; int num_mvs; ///< current length of mv_codebook int num_blocks_packed; ///< current length of block_codebook } TgvContext; @@ -64,11 +64,11 @@ static av_cold int tgv_decode_init(AVCodecContext *avctx) * @return 0 on success, -1 on critical buffer underflow */ static int unpack(const uint8_t *src, const uint8_t *src_end, - unsigned char *dst, int width, int height) + uint8_t *dst, int width, int height) { - unsigned char *dst_end = dst + width*height; + uint8_t *dst_end = dst + width*height; int size, size1, size2, offset, run; - unsigned char *dst_start = dst; + uint8_t *dst_start = dst; if (src[0] & 0x01) src += 5; @@ -148,7 +148,7 @@ static int tgv_decode_inter(TgvContext *s, const uint8_t *buf, int i,j,x,y; GetBitContext gb; int mvbits; - const unsigned char *blocks_raw; + const uint8_t *blocks_raw; if (buf + 12 > buf_end) return AVERROR_INVALIDDATA; @@ -172,7 +172,7 @@ static int tgv_decode_inter(TgvContext *s, const uint8_t *buf, } if (num_blocks_packed > s->num_blocks_packed) { - s->block_codebook = av_realloc(s->block_codebook, num_blocks_packed*16*sizeof(unsigned char)); + s->block_codebook = av_realloc(s->block_codebook, num_blocks_packed*16); s->num_blocks_packed = num_blocks_packed; } @@ -211,7 +211,7 @@ static int tgv_decode_inter(TgvContext *s, const uint8_t *buf, for (y = 0; y < s->avctx->height / 4; y++) for (x = 0; x < s->avctx->width / 4; x++) { unsigned int vector = get_bits(&gb, vector_bits); - const unsigned char *src; + const uint8_t *src; int src_stride; if (vector < num_mvs) { From 098eed95bc1a6b2c8ac97f126f62bb74699670cf Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 9 Dec 2012 18:44:44 +0100 Subject: [PATCH 014/182] mdec: merge mdec_common_init() into decode_init(). There is no point in keeping those two functions separate. --- libavcodec/mdec.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index 2f74cdcd01..ec09124ffc 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -211,23 +211,17 @@ static int decode_frame(AVCodecContext *avctx, return (get_bits_count(&a->gb)+31)/32*4; } -static av_cold void mdec_common_init(AVCodecContext *avctx){ +static av_cold int decode_init(AVCodecContext *avctx){ MDECContext * const a = avctx->priv_data; - - ff_dsputil_init(&a->dsp, avctx); + AVFrame *p= &a->picture; a->mb_width = (avctx->coded_width + 15) / 16; a->mb_height = (avctx->coded_height + 15) / 16; avctx->coded_frame= &a->picture; a->avctx= avctx; -} -static av_cold int decode_init(AVCodecContext *avctx){ - MDECContext * const a = avctx->priv_data; - AVFrame *p= &a->picture; - - mdec_common_init(avctx); + ff_dsputil_init(&a->dsp, avctx); ff_mpeg12_init_vlcs(); ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_zigzag_direct); From f713411d4cfbd9c467aeda77b16ca6bc4db55d10 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 9 Dec 2012 18:52:55 +0100 Subject: [PATCH 015/182] mdec: cosmetics, reformat --- libavcodec/mdec.c | 163 +++++++++++++++++++++++----------------------- 1 file changed, 83 insertions(+), 80 deletions(-) diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index ec09124ffc..b5ea84c8a9 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -33,7 +33,7 @@ #include "mpeg12.h" #include "thread.h" -typedef struct MDECContext{ +typedef struct MDECContext { AVCodecContext *avctx; DSPContext dsp; AVFrame picture; @@ -57,36 +57,36 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) int level, diff, i, j, run; int component; RLTable *rl = &ff_rl_mpeg1; - uint8_t * const scantable= a->scantable.permutated; - const uint16_t *quant_matrix= ff_mpeg1_default_intra_matrix; - const int qscale= a->qscale; + uint8_t * const scantable = a->scantable.permutated; + const uint16_t *quant_matrix = ff_mpeg1_default_intra_matrix; + const int qscale = a->qscale; /* DC coefficient */ - if(a->version==2){ - block[0]= 2*get_sbits(&a->gb, 10) + 1024; - }else{ + if (a->version == 2) { + block[0] = 2 * get_sbits(&a->gb, 10) + 1024; + } else { component = (n <= 3 ? 0 : n - 4 + 1); diff = decode_dc(&a->gb, component); if (diff >= 0xffff) return -1; - a->last_dc[component]+= diff; - block[0] = a->last_dc[component]<<3; + a->last_dc[component] += diff; + block[0] = a->last_dc[component] << 3; } i = 0; { OPEN_READER(re, &a->gb); /* now quantify & encode AC coefficients */ - for(;;) { + for (;;) { UPDATE_CACHE(re, &a->gb); GET_RL_VLC(level, run, re, &a->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); - if(level == 127){ + if (level == 127) { break; - } else if(level != 0) { - i += run; - j = scantable[i]; - level= (level*qscale*quant_matrix[j])>>3; + } else if (level != 0) { + i += run; + j = scantable[i]; + level = (level * qscale * quant_matrix[j]) >> 3; level = (level ^ SHOW_SBITS(re, &a->gb, 1)) - SHOW_SBITS(re, &a->gb, 1); LAST_SKIP_BITS(re, &a->gb, 1); } else { @@ -94,19 +94,19 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) run = SHOW_UBITS(re, &a->gb, 6)+1; LAST_SKIP_BITS(re, &a->gb, 6); UPDATE_CACHE(re, &a->gb); level = SHOW_SBITS(re, &a->gb, 10); SKIP_BITS(re, &a->gb, 10); - i += run; - j = scantable[i]; - if(level<0){ - level= -level; - level= (level*qscale*quant_matrix[j])>>3; - level= (level-1)|1; - level= -level; - }else{ - level= (level*qscale*quant_matrix[j])>>3; - level= (level-1)|1; + i += run; + j = scantable[i]; + if (level < 0) { + level = -level; + level = (level * qscale * quant_matrix[j]) >> 3; + level = (level - 1) | 1; + level = -level; + } else { + level = (level * qscale * quant_matrix[j]) >> 3; + level = (level - 1) | 1; } } - if (i > 63){ + if (i > 63) { av_log(a->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y); return -1; } @@ -119,34 +119,36 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) return 0; } -static inline int decode_mb(MDECContext *a, int16_t block[6][64]){ +static inline int decode_mb(MDECContext *a, int16_t block[6][64]) +{ int i; - const int block_index[6]= {5,4,0,1,2,3}; + const int block_index[6] = { 5, 4, 0, 1, 2, 3 }; a->dsp.clear_blocks(block[0]); - for(i=0; i<6; i++){ - if( mdec_decode_block_intra(a, block[ block_index[i] ], block_index[i]) < 0 || + for (i = 0; i < 6; i++) { + if (mdec_decode_block_intra(a, block[block_index[i]], block_index[i]) < 0 || get_bits_left(&a->gb) < 0) return -1; } return 0; } -static inline void idct_put(MDECContext *a, int mb_x, int mb_y){ - int16_t (*block)[64]= a->block; - int linesize= a->picture.linesize[0]; +static inline void idct_put(MDECContext *a, int mb_x, int mb_y) +{ + int16_t (*block)[64] = a->block; + int linesize = a->picture.linesize[0]; - uint8_t *dest_y = a->picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16; - uint8_t *dest_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8; - uint8_t *dest_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8; + uint8_t *dest_y = a->picture.data[0] + (mb_y * 16 * linesize ) + mb_x * 16; + uint8_t *dest_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8; + uint8_t *dest_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8; - a->dsp.idct_put(dest_y , linesize, block[0]); - a->dsp.idct_put(dest_y + 8, linesize, block[1]); - a->dsp.idct_put(dest_y + 8*linesize , linesize, block[2]); - a->dsp.idct_put(dest_y + 8*linesize + 8, linesize, block[3]); + a->dsp.idct_put(dest_y, linesize, block[0]); + a->dsp.idct_put(dest_y + 8, linesize, block[1]); + a->dsp.idct_put(dest_y + 8 * linesize, linesize, block[2]); + a->dsp.idct_put(dest_y + 8 * linesize + 8, linesize, block[3]); - if(!(a->avctx->flags&CODEC_FLAG_GRAY)){ + if (!(a->avctx->flags & CODEC_FLAG_GRAY)) { a->dsp.idct_put(dest_cb, a->picture.linesize[1], block[4]); a->dsp.idct_put(dest_cr, a->picture.linesize[2], block[5]); } @@ -156,104 +158,105 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; MDECContext * const a = avctx->priv_data; - AVFrame *picture = data; - AVFrame * const p= &a->picture; + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + AVFrame *picture = data; + AVFrame * const p = &a->picture; int i; - if(p->data[0]) + if (p->data[0]) ff_thread_release_buffer(avctx, p); - p->reference= 0; - if(ff_thread_get_buffer(avctx, p) < 0){ + p->reference = 0; + if (ff_thread_get_buffer(avctx, p) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } - p->pict_type= AV_PICTURE_TYPE_I; - p->key_frame= 1; + p->pict_type = AV_PICTURE_TYPE_I; + p->key_frame = 1; av_fast_malloc(&a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!a->bitstream_buffer) return AVERROR(ENOMEM); - for(i=0; ibitstream_buffer[i] = buf[i+1]; - a->bitstream_buffer[i+1]= buf[i ]; + for (i = 0; i < buf_size; i += 2) { + a->bitstream_buffer[i] = buf[i + 1]; + a->bitstream_buffer[i + 1] = buf[i]; } - init_get_bits(&a->gb, a->bitstream_buffer, buf_size*8); + init_get_bits(&a->gb, a->bitstream_buffer, buf_size * 8); /* skip over 4 preamble bytes in stream (typically 0xXX 0xXX 0x00 0x38) */ skip_bits(&a->gb, 32); - a->qscale= get_bits(&a->gb, 16); - a->version= get_bits(&a->gb, 16); + a->qscale = get_bits(&a->gb, 16); + a->version = get_bits(&a->gb, 16); - a->last_dc[0]= - a->last_dc[1]= - a->last_dc[2]= 128; + a->last_dc[0] = a->last_dc[1] = a->last_dc[2] = 128; - for(a->mb_x=0; a->mb_xmb_width; a->mb_x++){ - for(a->mb_y=0; a->mb_ymb_height; a->mb_y++){ - if( decode_mb(a, a->block) <0) + for (a->mb_x = 0; a->mb_x < a->mb_width; a->mb_x++) { + for (a->mb_y = 0; a->mb_y < a->mb_height; a->mb_y++) { + if (decode_mb(a, a->block) < 0) return -1; idct_put(a, a->mb_x, a->mb_y); } } - p->quality= a->qscale * FF_QP2LAMBDA; + p->quality = a->qscale * FF_QP2LAMBDA; memset(p->qscale_table, a->qscale, a->mb_width); *picture = a->picture; *got_frame = 1; - return (get_bits_count(&a->gb)+31)/32*4; + return (get_bits_count(&a->gb) + 31) / 32 * 4; } -static av_cold int decode_init(AVCodecContext *avctx){ +static av_cold int decode_init(AVCodecContext *avctx) +{ MDECContext * const a = avctx->priv_data; - AVFrame *p= &a->picture; + AVFrame *p = &a->picture; - a->mb_width = (avctx->coded_width + 15) / 16; - a->mb_height = (avctx->coded_height + 15) / 16; + a->mb_width = (avctx->coded_width + 15) / 16; + a->mb_height = (avctx->coded_height + 15) / 16; - avctx->coded_frame= &a->picture; - a->avctx= avctx; + avctx->coded_frame = &a->picture; + a->avctx = avctx; ff_dsputil_init(&a->dsp, avctx); ff_mpeg12_init_vlcs(); ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_zigzag_direct); - if( avctx->idct_algo == FF_IDCT_AUTO ) + if (avctx->idct_algo == FF_IDCT_AUTO) avctx->idct_algo = FF_IDCT_SIMPLE; - p->qstride= 0; - p->qscale_table= av_mallocz(a->mb_width); - avctx->pix_fmt= AV_PIX_FMT_YUVJ420P; + p->qstride = 0; + p->qscale_table = av_mallocz(a->mb_width); + avctx->pix_fmt = AV_PIX_FMT_YUVJ420P; return 0; } -static av_cold int decode_init_thread_copy(AVCodecContext *avctx){ +static av_cold int decode_init_thread_copy(AVCodecContext *avctx) +{ MDECContext * const a = avctx->priv_data; - AVFrame *p = &a->picture; + AVFrame *p = &a->picture; avctx->coded_frame = p; - a->avctx= avctx; + a->avctx = avctx; p->qscale_table = av_mallocz( a->mb_width); return 0; } -static av_cold int decode_end(AVCodecContext *avctx){ +static av_cold int decode_end(AVCodecContext *avctx) +{ MDECContext * const a = avctx->priv_data; - if(a->picture.data[0]) + if (a->picture.data[0]) avctx->release_buffer(avctx, &a->picture); av_freep(&a->bitstream_buffer); av_freep(&a->picture.qscale_table); - a->bitstream_buffer_size=0; + a->bitstream_buffer_size = 0; return 0; } From 30d62507cd9cc2e5d312af476036c9bce2f2bd00 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 9 Dec 2012 18:55:53 +0100 Subject: [PATCH 016/182] mdec: return meaningful error codes. --- libavcodec/mdec.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index b5ea84c8a9..59bb6bee54 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -68,7 +68,7 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) component = (n <= 3 ? 0 : n - 4 + 1); diff = decode_dc(&a->gb, component); if (diff >= 0xffff) - return -1; + return AVERROR_INVALIDDATA; a->last_dc[component] += diff; block[0] = a->last_dc[component] << 3; } @@ -108,7 +108,7 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) } if (i > 63) { av_log(a->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y); - return -1; + return AVERROR_INVALIDDATA; } block[j] = level; @@ -121,15 +121,17 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) static inline int decode_mb(MDECContext *a, int16_t block[6][64]) { - int i; + int i, ret; const int block_index[6] = { 5, 4, 0, 1, 2, 3 }; a->dsp.clear_blocks(block[0]); for (i = 0; i < 6; i++) { - if (mdec_decode_block_intra(a, block[block_index[i]], block_index[i]) < 0 || - get_bits_left(&a->gb) < 0) - return -1; + if ((ret = mdec_decode_block_intra(a, block[block_index[i]], + block_index[i])) < 0) + return ret; + if (get_bits_left(&a->gb) < 0) + return AVERROR_INVALIDDATA; } return 0; } @@ -163,15 +165,15 @@ static int decode_frame(AVCodecContext *avctx, int buf_size = avpkt->size; AVFrame *picture = data; AVFrame * const p = &a->picture; - int i; + int i, ret; if (p->data[0]) ff_thread_release_buffer(avctx, p); p->reference = 0; - if (ff_thread_get_buffer(avctx, p) < 0) { + if ((ret = ff_thread_get_buffer(avctx, p)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); - return -1; + return ret; } p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; @@ -195,8 +197,8 @@ static int decode_frame(AVCodecContext *avctx, for (a->mb_x = 0; a->mb_x < a->mb_width; a->mb_x++) { for (a->mb_y = 0; a->mb_y < a->mb_height; a->mb_y++) { - if (decode_mb(a, a->block) < 0) - return -1; + if ((ret = decode_mb(a, a->block)) < 0) + return ret; idct_put(a, a->mb_x, a->mb_y); } From e6da5d215b1f2267bfdbb83028f2c1b63434edad Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 27 Dec 2012 09:01:38 +0100 Subject: [PATCH 017/182] mimic: remove a pointless cast. --- libavcodec/mimic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 9a4aa3dc53..8ab1c9e985 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -297,7 +297,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs, * Flip the buffer upside-down and put it in the YVU order to match the * way Mimic encodes frames. */ -static void prepare_avpic(MimicContext *ctx, AVPicture *dst, AVPicture *src) +static void prepare_avpic(MimicContext *ctx, AVPicture *dst, AVFrame *src) { int i; dst->data[0] = src->data[0] + ( ctx->avctx->height - 1) * src->linesize[0]; @@ -374,7 +374,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, ctx->next_cur_index = (ctx->cur_index - 1) & 15; prepare_avpic(ctx, &ctx->flipped_ptrs[ctx->cur_index], - (AVPicture*) &ctx->buf_ptrs[ctx->cur_index]); + &ctx->buf_ptrs[ctx->cur_index]); ff_thread_finish_setup(avctx); From aec50f79e7460340a148a3096fe212d67edc2c64 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Jan 2013 17:19:01 +0100 Subject: [PATCH 018/182] rawdec: use AVPALETTE_SIZE instead of magic constants. --- libavcodec/rawdec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 2751f34974..ab93d49e07 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -138,14 +138,15 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, frame->reordered_opaque = avctx->reordered_opaque; frame->pkt_pts = avctx->pkt->pts; - if (buf_size < context->length - (avctx->pix_fmt == AV_PIX_FMT_PAL8 ? 256 * 4 : 0)) + if (buf_size < context->length - (avctx->pix_fmt == AV_PIX_FMT_PAL8 ? + AVPALETTE_SIZE : 0)) return -1; //2bpp and 4bpp raw in avi and mov (yes this is ugly ...) if (context->buffer) { int i; uint8_t *dst = context->buffer; - buf_size = context->length - 256 * 4; + buf_size = context->length - AVPALETTE_SIZE; if (avctx->bits_per_coded_sample == 4) { for (i = 0; 2 * i + 1 < buf_size; i++) { dst[2 * i + 0] = buf[i] >> 4; From 729b37149c9cbef77d5ad75d91017af3b9084577 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 5 Jan 2013 11:45:51 +0100 Subject: [PATCH 019/182] mvi: set framerate This container does not store timestamps and thus supports CFR only. --- libavformat/mvi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mvi.c b/libavformat/mvi.c index 10ec8bbb20..7fb163bea3 100644 --- a/libavformat/mvi.c +++ b/libavformat/mvi.c @@ -87,6 +87,7 @@ static int read_header(AVFormatContext *s) ast->codec->bit_rate = ast->codec->sample_rate * 8; avpriv_set_pts_info(vst, 64, msecs_per_frame, 1000000); + vst->avg_frame_rate = av_inv_q(vst->time_base); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = AV_CODEC_ID_MOTIONPIXELS; From e6b1c3bbe7082c71ea8ee8ac83698c156c9e4838 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 28 Dec 2012 09:54:29 +0100 Subject: [PATCH 020/182] pthread: make ff_thread_release_buffer idempotent. I.e. don't do anything on already released frames. --- libavcodec/pthread.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 73d9da3f1c..cd44b8c73b 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -975,6 +975,9 @@ void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f) PerThreadContext *p = avctx->thread_opaque; FrameThreadContext *fctx; + if (!f->data[0]) + return; + if (!(avctx->active_thread_type&FF_THREAD_FRAME)) { avctx->release_buffer(avctx, f); return; From 231fd1ed3932909a259da6df52fa3f756646aa3e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 7 Jan 2013 11:39:56 +0100 Subject: [PATCH 021/182] utvideoenc/v410enc: do not set AVFrame.reference. That field will be deprecated. --- libavcodec/utvideoenc.c | 1 - libavcodec/v410enc.c | 1 - 2 files changed, 2 deletions(-) diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index 085c415caa..0df3fb75d1 100644 --- a/libavcodec/utvideoenc.c +++ b/libavcodec/utvideoenc.c @@ -598,7 +598,6 @@ static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt, * At least currently Ut Video is IDR only. * Set flags accordingly. */ - avctx->coded_frame->reference = 0; avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c index cc7cef7ea2..7bb70fd56a 100644 --- a/libavcodec/v410enc.c +++ b/libavcodec/v410enc.c @@ -56,7 +56,6 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } dst = pkt->data; - avctx->coded_frame->reference = 0; avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; From 47318953ddfe8aa7dd00ad90bd21ea3a995e35d0 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 13 Jan 2013 17:54:50 +0100 Subject: [PATCH 022/182] mpegvideo: remove some unused variables from Picture. --- libavcodec/motion_est.c | 2 -- libavcodec/mpegvideo.h | 5 ----- 2 files changed, 7 deletions(-) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 9cf1203be0..3244ac06b9 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1077,7 +1077,6 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, vard = s->dsp.sse[0](NULL, pix, ppix, s->linesize, 16); pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8; -// pic->mb_cmp_score[s->mb_stride * mb_y + mb_x] = dmin; c->mc_mb_var_sum_temp += (vard+128)>>8; if(mb_type){ @@ -1156,7 +1155,6 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, } } -// pic->mb_cmp_score[s->mb_stride * mb_y + mb_x] = dmin; set_p_mv_tables(s, mx, my, mb_type!=CANDIDATE_MB_TYPE_INTER4V); /* get intra luma score */ diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 567319c27b..a2a5d7b876 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -94,10 +94,6 @@ struct MpegEncContext; typedef struct Picture{ struct AVFrame f; - /** - * halfpel luma planes. - */ - uint8_t *interpolated[3]; int8_t *qscale_table_base; int16_t (*motion_val_base[2])[2]; uint32_t *mb_type_base; @@ -143,7 +139,6 @@ typedef struct Picture{ uint16_t *mb_var; ///< Table for MB variances uint16_t *mc_mb_var; ///< Table for motion compensated MB variances uint8_t *mb_mean; ///< Table for MB luminance - int32_t *mb_cmp_score; ///< Table for MB cmp scores, for mb decision FIXME remove int b_frame_score; /* */ struct MpegEncContext *owner2; ///< pointer to the MpegEncContext that allocated this picture int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change) From 76e74e4831f08876f1f3d30a1640b0d084bed64a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 19 Jan 2013 09:15:37 +0100 Subject: [PATCH 023/182] h264: remove obsolete comment. --- libavcodec/h264.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index ffe7586ad8..a903b7b93b 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1415,7 +1415,6 @@ static void decode_postinit(H264Context *h, int setup_finished) cur->f.repeat_pict = 1; break; case SEI_PIC_STRUCT_FRAME_DOUBLING: - // Force progressive here, doubling interlaced frame is a bad idea. cur->f.repeat_pict = 2; break; case SEI_PIC_STRUCT_FRAME_TRIPLING: From f81c37e40fe3236d54da12aef9cdba48ba70ec31 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Jan 2013 21:10:54 +0100 Subject: [PATCH 024/182] vf_delogo: fix an uninitialized read. CC:libav-stable@libav.org --- libavfilter/vf_delogo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 76848c3198..5d56444e20 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -223,7 +223,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in) AVFilterBufferRef *out; int hsub0 = desc->log2_chroma_w; int vsub0 = desc->log2_chroma_h; - int direct; + int direct = 0; int plane; if ((in->perms & AV_PERM_WRITE) && !(in->perms & AV_PERM_PRESERVE)) { From 7194330bcd6db8dc5c22e0c162a0992d519307f9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Jan 2013 21:48:49 +0100 Subject: [PATCH 025/182] vf_delogo: fix copying the input frame. CC:libav-stable@libav.org --- libavfilter/vf_delogo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 5d56444e20..af479c2b12 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -80,12 +80,12 @@ static void apply_delogo(uint8_t *dst, int dst_linesize, topright = src+logo_y1 * src_linesize+logo_x2-1; botleft = src+(logo_y2-1) * src_linesize+logo_x1; - dst += (logo_y1+1)*dst_linesize; - src += (logo_y1+1)*src_linesize; - if (!direct) av_image_copy_plane(dst, dst_linesize, src, src_linesize, w, h); + dst += (logo_y1 + 1) * dst_linesize; + src += (logo_y1 + 1) * src_linesize; + for (y = logo_y1+1; y < logo_y2-1; y++) { for (x = logo_x1+1, xdst = dst+logo_x1+1, From 8a6ae87b9915ad82de4d20a056fe67bc17e16de7 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 28 Jan 2013 22:59:15 +0000 Subject: [PATCH 026/182] lavc: move deprecated audio_resample* bellow Signed-off-by: Paul B Mahol --- libavcodec/libavcodec.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v index f3e6db446a..195485e63f 100644 --- a/libavcodec/libavcodec.v +++ b/libavcodec/libavcodec.v @@ -1,8 +1,8 @@ LIBAVCODEC_$MAJOR { global: av*; + #deprecated, remove after next bump audio_resample; audio_resample_close; - #deprecated, remove after next bump dsputil_init; ff_find_pix_fmt; ff_framenum_to_drop_timecode; From 4e0bc996d9955a86c7949584bfbec386517ac795 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Tue, 29 Jan 2013 14:34:30 +0100 Subject: [PATCH 027/182] bfin: unbreak compilation Added a missing header file. --- libavcodec/bfin/vp3_bfin.c | 1 + libavcodec/bfin/vp3_bfin.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 libavcodec/bfin/vp3_bfin.h diff --git a/libavcodec/bfin/vp3_bfin.c b/libavcodec/bfin/vp3_bfin.c index 68c17ee39f..5c64a94e09 100644 --- a/libavcodec/bfin/vp3_bfin.c +++ b/libavcodec/bfin/vp3_bfin.c @@ -22,6 +22,7 @@ #include "libavcodec/avcodec.h" #include "libavcodec/vp3dsp.h" +#include "libavcodec/dsputil.h" #include "dsputil_bfin.h" #include "vp3_bfin.h" diff --git a/libavcodec/bfin/vp3_bfin.h b/libavcodec/bfin/vp3_bfin.h new file mode 100644 index 0000000000..08b050e4c0 --- /dev/null +++ b/libavcodec/bfin/vp3_bfin.h @@ -0,0 +1,29 @@ +/* + * 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_BFIN_VP3_BFIN_H +#define AVCODEC_BFIN_VP3_BFIN_H + +#include + +void ff_bfin_vp3_idct(int16_t *block); +void ff_bfin_vp3_idct_put(uint8_t *dest, int line_size, int16_t *block); +void ff_bfin_vp3_idct_add(uint8_t *dest, int line_size, int16_t *block); + +#endif /* AVCODEC_BFIN_VP3_BFIN_H */ From 036b9ee1c959d88d5ae7f1df21b2d36ab286b3cc Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 15:57:15 +0100 Subject: [PATCH 028/182] oggenc: fix "oggstream may be used uninitialized in this function" warning Signed-off-by: Michael Niedermayer --- libavformat/oggenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index 31e28413e9..3d4519c1ac 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -402,7 +402,7 @@ static int ogg_build_opus_headers(AVCodecContext *avctx, static int ogg_write_header(AVFormatContext *s) { OGGContext *ogg = s->priv_data; - OGGStreamContext *oggstream; + OGGStreamContext *oggstream = NULL; int i, j; if (ogg->pref_size) From ebe368d5d82c368fec81ec4ddf216200e5008999 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 16:15:02 +0100 Subject: [PATCH 029/182] ac3enc: fix 'warning: block0 may be used uninitialized in this function' The pointer is also initialized to NULL for safety. Signed-off-by: Michael Niedermayer --- libavcodec/ac3enc_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index 904e0bb9ef..b1174dc219 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -336,7 +336,7 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s) { int nb_coefs; int blk, bnd; - AC3Block *block, *block0; + AC3Block *block, *block0 = NULL; if (s->channel_mode != AC3_CHMODE_STEREO) return; From 3cd9849d9c24b0808e6e55cd7568250acaae2b91 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 16:33:32 +0100 Subject: [PATCH 030/182] eval: fix 'warning: ignoring return value of strtod, declared with attribute warn_unused_result' Signed-off-by: Michael Niedermayer --- libavutil/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/eval.c b/libavutil/eval.c index 22b491fef3..712d2f2678 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -467,7 +467,7 @@ static int parse_dB(AVExpr **e, Parser *p, int *sign) for example, -3dB is not the same as -(3dB) */ if (*p->s == '-') { char *next; - strtod(p->s, &next); + double av_unused v = strtod(p->s, &next); if (next != p->s && next[0] == 'd' && next[1] == 'B') { *sign = 0; return parse_primary(e, p); From df92ac18528bac4566fc4f5ba4d607c1265791ea Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 16:57:22 +0100 Subject: [PATCH 031/182] r3d: fix division by 0 with 0 sample rate Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavformat/r3d.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/r3d.c b/libavformat/r3d.c index 35da81eff1..5ee0b93686 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -312,7 +312,8 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom) pkt->stream_index = 1; pkt->dts = dts; - pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate); + if (st->codec->sample_rate) + pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate); av_dlog(s, "pkt dts %"PRId64" duration %d samples %d sample rate %d\n", pkt->dts, pkt->duration, samples, st->codec->sample_rate); From 99b1b2b1c65969ee324d754ea47e04a0a3f685a8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 17:13:45 +0100 Subject: [PATCH 032/182] r3d: check that sampling rate is non negative. Signed-off-by: Michael Niedermayer --- libavformat/r3d.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/r3d.c b/libavformat/r3d.c index 5ee0b93686..3b3ecce3d9 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -285,6 +285,10 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom) dts = avio_rb32(s->pb); st->codec->sample_rate = avio_rb32(s->pb); + if (st->codec->sample_rate < 0) { + av_log(s, AV_LOG_ERROR, "negative sample rate\n"); + return AVERROR_INVALIDDATA; + } samples = avio_rb32(s->pb); From f67a0d115254461649470452058fa3c28c0df294 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 17:56:19 +0100 Subject: [PATCH 033/182] huffyuvdec: Check init_vlc() return codes. Prevents out of array writes Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/huffyuvdec.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 9c92bf3875..0bdd143dd2 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -124,6 +124,7 @@ static void generate_joint_tables(HYuvContext *s) int len1 = s->len[p][u]; if (len1 > limit) continue; + av_assert0(i < (1 << VLC_BITS)); len[i] = len0 + len1; bits[i] = (s->bits[0][y] << len1) + s->bits[p][u]; symbols[i] = (y << 8) + u; @@ -158,6 +159,7 @@ static void generate_joint_tables(HYuvContext *s) int len2 = s->len[2][r & 255]; if (len2 > limit1) continue; + av_assert0(i < (1 << VLC_BITS)); len[i] = len0 + len1 + len2; bits[i] = (code << len2) + s->bits[2][r & 255]; if (s->decorrelate) { @@ -182,6 +184,7 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) { GetBitContext gb; int i; + int ret; init_get_bits(&gb, src, length * 8); @@ -192,8 +195,9 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) return -1; } ff_free_vlc(&s->vlc[i]); - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, - s->bits[i], 4, 4, 0); + if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, + s->bits[i], 4, 4, 0)) < 0) + return ret; } generate_joint_tables(s); @@ -205,6 +209,7 @@ static int read_old_huffman_tables(HYuvContext *s) { GetBitContext gb; int i; + int ret; init_get_bits(&gb, classic_shift_luma, classic_shift_luma_table_size * 8); @@ -228,8 +233,9 @@ static int read_old_huffman_tables(HYuvContext *s) for (i = 0; i < 3; i++) { ff_free_vlc(&s->vlc[i]); - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, - s->bits[i], 4, 4, 0); + if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, + s->bits[i], 4, 4, 0)) < 0) + return ret; } generate_joint_tables(s); From 4420b414420ecd67e63820c556c8cadee0cc13c8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 18:05:10 +0100 Subject: [PATCH 034/182] huffyuvdec: check for and propagate failures from inside generate_joint_tables() Signed-off-by: Michael Niedermayer --- libavcodec/huffyuvdec.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 0bdd143dd2..d11dab7d28 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -107,11 +107,13 @@ static int read_len_table(uint8_t *dst, GetBitContext *gb) return 0; } -static void generate_joint_tables(HYuvContext *s) +static int generate_joint_tables(HYuvContext *s) { uint16_t symbols[1 << VLC_BITS]; uint16_t bits[1 << VLC_BITS]; uint8_t len[1 << VLC_BITS]; + int ret; + if (s->bitstream_bpp < 24) { int p, i, y, u; for (p = 0; p < 3; p++) { @@ -133,8 +135,9 @@ static void generate_joint_tables(HYuvContext *s) } } ff_free_vlc(&s->vlc[3 + p]); - ff_init_vlc_sparse(&s->vlc[3 + p], VLC_BITS, i, len, 1, 1, - bits, 2, 2, symbols, 2, 2, 0); + if ((ret = ff_init_vlc_sparse(&s->vlc[3 + p], VLC_BITS, i, len, 1, 1, + bits, 2, 2, symbols, 2, 2, 0)) < 0) + return ret; } } else { uint8_t (*map)[4] = (uint8_t(*)[4])s->pix_bgr_map; @@ -176,8 +179,10 @@ static void generate_joint_tables(HYuvContext *s) } } ff_free_vlc(&s->vlc[3]); - init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0); + if ((ret = init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0)) < 0) + return ret; } + return 0; } static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) @@ -200,7 +205,8 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) return ret; } - generate_joint_tables(s); + if ((ret = generate_joint_tables(s)) < 0) + return ret; return (get_bits_count(&gb) + 7) / 8; } @@ -238,7 +244,8 @@ static int read_old_huffman_tables(HYuvContext *s) return ret; } - generate_joint_tables(s); + if ((ret = generate_joint_tables(s)) < 0) + return ret; return 0; } From 0dfc01c2bbf4b71bb56201bc4a393321e15d1b31 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 19:10:07 +0100 Subject: [PATCH 035/182] huffyuvdec: Skip len==0 cases Fixes vlc decoding for hypothetical files that would contain such cases. Signed-off-by: Michael Niedermayer --- libavcodec/huffyuvdec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index d11dab7d28..2c56bfa493 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -120,11 +120,11 @@ static int generate_joint_tables(HYuvContext *s) for (i = y = 0; y < 256; y++) { int len0 = s->len[0][y]; int limit = VLC_BITS - len0; - if(limit <= 0) + if(limit <= 0 || !len0) continue; for (u = 0; u < 256; u++) { int len1 = s->len[p][u]; - if (len1 > limit) + if (len1 > limit || !len1) continue; av_assert0(i < (1 << VLC_BITS)); len[i] = len0 + len1; @@ -150,17 +150,17 @@ static int generate_joint_tables(HYuvContext *s) for (i = 0, g = -16; g < 16; g++) { int len0 = s->len[p0][g & 255]; int limit0 = VLC_BITS - len0; - if (limit0 < 2) + if (limit0 < 2 || !len0) continue; for (b = -16; b < 16; b++) { int len1 = s->len[p1][b & 255]; int limit1 = limit0 - len1; - if (limit1 < 1) + if (limit1 < 1 || !len1) continue; code = (s->bits[p0][g & 255] << len1) + s->bits[p1][b & 255]; for (r = -16; r < 16; r++) { int len2 = s->len[2][r & 255]; - if (len2 > limit1) + if (len2 > limit1 || !len2) continue; av_assert0(i < (1 << VLC_BITS)); len[i] = len0 + len1 + len2; From 1d81f7448c8aa7df4aaed612fcd032dbccbd1a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Hajdan=2C=20Jr?= Date: Tue, 29 Jan 2013 11:41:10 +0000 Subject: [PATCH 036/182] dict.c: use av_mallocz instead of av_realloc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Memory passed to av_realloc must come from malloc, calloc or realloc, and not e.g. memalign. realloc(3): The realloc() function changes the size of the memory block pointed to by ptr to size bytes. (...) Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc() or realloc(). The issue has been found by debugallocation, a part of google-perftools: http://code.google.com/p/gperftools/ . This makes fate pass when using LD_PRELOAD-ed debugallocation. See also earlier discussion http://ffmpeg.org/pipermail/ffmpeg-devel/2013-January/137234.html Signed-off-by: Paweł Hajdan, Jr Signed-off-by: Michael Niedermayer --- libavutil/dict.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index 06f963cf62..23816e8f55 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -94,10 +94,12 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags m->elems[m->count].value = (char*)(intptr_t)value; } else if (oldval && flags & AV_DICT_APPEND) { int len = strlen(oldval) + strlen(value) + 1; - if (!(oldval = av_realloc(oldval, len))) + char *newval = av_mallocz(len); + if (!newval) return AVERROR(ENOMEM); - av_strlcat(oldval, value, len); - m->elems[m->count].value = oldval; + av_strlcat(newval, oldval, len); + av_strlcat(newval, value, len); + m->elems[m->count].value = newval; } else m->elems[m->count].value = av_strdup(value); m->count++; From dc8dd2f6e972985f3ed237019bc7c70731af8148 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Jan 2013 22:35:37 +0100 Subject: [PATCH 037/182] sanm: Check MV before using them. Fixes out of array reads Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/sanm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index 70ad1f8fed..c9284920b6 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -29,6 +29,7 @@ #include "libavutil/imgutils.h" #include "libavcodec/dsputil.h" #include "sanm_data.h" +#include "libavutil/avassert.h" #define NGLYPHS 256 @@ -613,6 +614,16 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1, } else { int mx = motion_vectors[code][0]; int my = motion_vectors[code][1]; + int index = prev2 - (const uint8_t*)ctx->frm2; + + av_assert2(index >= 0 && index < (ctx->buf_size>>1)); + + if (index < - mx - my*stride || + (ctx->buf_size>>1) - index < mx + size + (my + size - 1)*stride) { + av_log(ctx->avctx, AV_LOG_ERROR, "MV is invalid \n"); + return AVERROR_INVALIDDATA; + } + for (k = 0; k < size; k++) memcpy(dst + k * stride, prev2 + mx + (my + k) * stride, size); } From 3c3d68a97677647c4d002231d0d3f7cd7e0636cf Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 30 Jan 2013 00:49:16 +0100 Subject: [PATCH 038/182] Fix 1bpp palettized png with width not a multiple of 8. Fixes ticket #2204. --- libavcodec/pngdec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 593df60294..97c0ad19b6 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -765,10 +765,14 @@ static int decode_frame(AVCodecContext *avctx, exit_loop: if (s->bits_per_pixel == 1 && s->color_type == PNG_COLOR_TYPE_PALETTE){ - int i, j; + int i, j, k; uint8_t *pd = s->current_picture->data[0]; for (j = 0; j < s->height; j++) { - for (i = s->width/8-1; i >= 0; i--) { + i = s->width / 8; + for (k = 7; k >= 1; k--) + if ((s->width&7) >= k) + pd[8*i + k - 1] = (pd[i]>>8-k) & 1; + for (i--; i >= 0; i--) { pd[8*i + 7]= pd[i] & 1; pd[8*i + 6]= (pd[i]>>1) & 1; pd[8*i + 5]= (pd[i]>>2) & 1; From 4d3d3625495915c45d63d1d72d332159d9d29baa Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 02:41:31 +0100 Subject: [PATCH 039/182] dirac/x86: fix compile without inline asm Signed-off-by: Michael Niedermayer --- 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 dcf2345954..d1e7bea42e 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -1634,8 +1634,10 @@ void ff_ ## OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[ }\ } +#if HAVE_MMX_INLINE DIRAC_PIXOP(put, put, mmx) DIRAC_PIXOP(avg, avg, mmx) +#endif DIRAC_PIXOP(avg, ff_avg, mmxext) #if HAVE_YASM From 71f8d7045638eb668f2395986de59821134fb1a1 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 06:47:09 +0100 Subject: [PATCH 040/182] dirac/x86: fix compile without yasm Signed-off-by: Michael Niedermayer --- libavcodec/x86/dsputil_mmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index d1e7bea42e..2e8300a788 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -1638,9 +1638,10 @@ void ff_ ## OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[ DIRAC_PIXOP(put, put, mmx) DIRAC_PIXOP(avg, avg, mmx) #endif -DIRAC_PIXOP(avg, ff_avg, mmxext) #if HAVE_YASM +DIRAC_PIXOP(avg, ff_avg, mmxext) + void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { if (h&3) From 91f359292a52b7acf3785ea4c399b20d8fbd24e5 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 30 Jan 2013 10:28:53 +0100 Subject: [PATCH 041/182] Correctly mark non-default streams when muxing matroska. Fixes ticket #1815. Reviewed-by: Hendrik Leppkes --- libavformat/matroskaenc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c167c015fe..204d1b2394 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -530,12 +530,16 @@ static int mkv_write_tracks(AVFormatContext *s) MatroskaMuxContext *mkv = s->priv_data; AVIOContext *pb = s->pb; ebml_master tracks; - int i, j, ret; + int i, j, ret, default_stream_exists = 0; ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, avio_tell(pb)); if (ret < 0) return ret; tracks = start_ebml_master(pb, MATROSKA_ID_TRACKS, 0); + for (i = 0; i < s->nb_streams; i++) { + AVStream *st = s->streams[i]; + default_stream_exists |= st->disposition & AV_DISPOSITION_DEFAULT; + } for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; AVCodecContext *codec = st->codec; @@ -570,8 +574,9 @@ static int mkv_write_tracks(AVFormatContext *s) tag = av_dict_get(st->metadata, "language", NULL, 0); put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag ? tag->value:"und"); - if (st->disposition) + if (default_stream_exists) { put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT)); + } if (st->disposition & AV_DISPOSITION_FORCED) put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGFORCED, 1); From 61d36761efda663c5ce07a5ec13659431b08f3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 29 Jan 2013 19:10:04 +0200 Subject: [PATCH 042/182] movenc: Simplify code by using avio_wb24 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/movenc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 39495203df..496158c10a 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -305,8 +305,7 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic else avio_w8(pb, 0x11); // flags (= Visualstream) - avio_w8(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits) - avio_wb16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB + avio_wb24(pb, track->enc->rc_buffer_size >> 3); // Buffersize DB avio_wb32(pb, FFMAX(track->enc->bit_rate, track->enc->rc_max_rate)); // maxbitrate (FIXME should be max rate in any 1 sec window) if(track->enc->rc_max_rate != track->enc->rc_min_rate || track->enc->rc_min_rate==0) From a5ba798c16d0614d982a76755fdd72b37d437170 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Mon, 28 Jan 2013 19:56:55 -0800 Subject: [PATCH 043/182] dsputil: remove unused functions copy_block{2, 4, 8, 16}. --- libavcodec/dsputil_template.c | 48 ----------------------------------- 1 file changed, 48 deletions(-) diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index 42f2b7b6c9..62edd90e8c 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -29,54 +29,6 @@ #include "bit_depth_template.c" -static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h) -{ - int i; - for(i=0; i Date: Wed, 30 Jan 2013 16:24:33 +0100 Subject: [PATCH 044/182] mpegvideo_enc: factor expression out Fixes "warning: dc[0..5] may be used uninitialized in this function" Signed-off-by: Michael Niedermayer --- libavcodec/mpegvideo_enc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 11607d22c8..87531d7cd9 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2844,6 +2844,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ int16_t ac[6][16]; const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0; static const int dquant_tab[4]={-1,1,-2,2}; + int storecoefs = s->mb_intra && s->dc_val[0]; av_assert2(backup_s.dquant == 0); @@ -2863,7 +2864,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ if(qp < s->avctx->qmin || qp > s->avctx->qmax) continue; backup_s.dquant= dquant; - if(s->mb_intra && s->dc_val[0]){ + if(storecoefs){ for(i=0; i<6; i++){ dc[i]= s->dc_val[0][ s->block_index[i] ]; memcpy(ac[i], s->ac_val[0][s->block_index[i]], sizeof(int16_t)*16); @@ -2873,7 +2874,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb, &dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]); if(best_s.qscale != qp){ - if(s->mb_intra && s->dc_val[0]){ + if(storecoefs){ for(i=0; i<6; i++){ s->dc_val[0][ s->block_index[i] ]= dc[i]; memcpy(s->ac_val[0][s->block_index[i]], ac[i], sizeof(int16_t)*16); From c2992b705381e082e33633e62e151887da67b285 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 16:33:45 +0100 Subject: [PATCH 045/182] msrledec: move output pointer test up Signed-off-by: Michael Niedermayer --- libavcodec/msrledec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c index 36a46b5978..6596cecf4c 100644 --- a/libavcodec/msrledec.c +++ b/libavcodec/msrledec.c @@ -203,6 +203,9 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, pos += p2; } else { //run of pixels uint8_t pix[3]; //original pixel + if ((pic->linesize[0] > 0 && output + p1 * (depth >> 3) > output_end) || + (pic->linesize[0] < 0 && output + p1 * (depth >> 3) < output_end)) + continue; switch(depth){ case 8: pix[0] = bytestream2_get_byte(gb); break; @@ -215,9 +218,6 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, case 32: pix32 = bytestream2_get_le32(gb); break; } - if ((pic->linesize[0] > 0 && output + p1 * (depth >> 3) > output_end) || - (pic->linesize[0] < 0 && output + p1 * (depth >> 3) < output_end)) - continue; for(i = 0; i < p1; i++) { switch(depth){ case 8: *output++ = pix[0]; From dbaae33c2c71862b8eaea978ed6dccc5ec03db89 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 16:39:35 +0100 Subject: [PATCH 046/182] msrledec: move loop into switch speeds up code and allows more simplifications Signed-off-by: Michael Niedermayer --- libavcodec/msrledec.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c index 6596cecf4c..cc69af8ec1 100644 --- a/libavcodec/msrledec.c +++ b/libavcodec/msrledec.c @@ -218,21 +218,30 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, case 32: pix32 = bytestream2_get_le32(gb); break; } - for(i = 0; i < p1; i++) { - switch(depth){ - case 8: *output++ = pix[0]; - break; - case 16: *(uint16_t*)output = pix16; - output += 2; - break; - case 24: *output++ = pix[0]; - *output++ = pix[1]; - *output++ = pix[2]; - break; - case 32: *(uint32_t*)output = pix32; - output += 4; - break; + switch(depth){ + case 8: + for(i = 0; i < p1; i++) + *output++ = pix[0]; + break; + case 16: + for(i = 0; i < p1; i++) { + *(uint16_t*)output = pix16; + output += 2; } + break; + case 24: + for(i = 0; i < p1; i++) { + *output++ = pix[0]; + *output++ = pix[1]; + *output++ = pix[2]; + } + break; + case 32: + for(i = 0; i < p1; i++) { + *(uint32_t*)output = pix32; + output += 4; + } + break; } pos += p1; } From d2e0a276d593ded94401e687f60bee266f3e725e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 16:41:33 +0100 Subject: [PATCH 047/182] msrledec: merge switches More speedup and fixes 'may be used uninitialized in this function' warnings Signed-off-by: Michael Niedermayer --- libavcodec/msrledec.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c index cc69af8ec1..e969994875 100644 --- a/libavcodec/msrledec.c +++ b/libavcodec/msrledec.c @@ -206,30 +206,24 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, if ((pic->linesize[0] > 0 && output + p1 * (depth >> 3) > output_end) || (pic->linesize[0] < 0 && output + p1 * (depth >> 3) < output_end)) continue; - switch(depth){ - case 8: pix[0] = bytestream2_get_byte(gb); - break; - case 16: pix16 = bytestream2_get_le16(gb); - break; - case 24: pix[0] = bytestream2_get_byte(gb); - pix[1] = bytestream2_get_byte(gb); - pix[2] = bytestream2_get_byte(gb); - break; - case 32: pix32 = bytestream2_get_le32(gb); - break; - } + switch(depth){ case 8: + pix[0] = bytestream2_get_byte(gb); for(i = 0; i < p1; i++) *output++ = pix[0]; break; case 16: + pix16 = bytestream2_get_le16(gb); for(i = 0; i < p1; i++) { *(uint16_t*)output = pix16; output += 2; } break; case 24: + pix[0] = bytestream2_get_byte(gb); + pix[1] = bytestream2_get_byte(gb); + pix[2] = bytestream2_get_byte(gb); for(i = 0; i < p1; i++) { *output++ = pix[0]; *output++ = pix[1]; @@ -237,6 +231,7 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, } break; case 32: + pix32 = bytestream2_get_le32(gb); for(i = 0; i < p1; i++) { *(uint32_t*)output = pix32; output += 4; From 32de2831036ae0ecdfa7bfdb3d59c1ae2095bbc8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 16:54:15 +0100 Subject: [PATCH 048/182] avstring: fix "warning: return discards const qualifier from pointer target type" Signed-off-by: Michael Niedermayer --- libavutil/avstring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 2f00374176..e2422c0a59 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -69,11 +69,11 @@ char *av_strnstr(const char *haystack, const char *needle, size_t hay_length) { size_t needle_len = strlen(needle); if (!needle_len) - return haystack; + return (char*)haystack; while (hay_length >= needle_len) { hay_length--; if (!memcmp(haystack, needle, needle_len)) - return haystack; + return (char*)haystack; haystack++; } return NULL; From b926cc7834d5bc998775528097831c0fbcf3730a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 18:12:42 +0100 Subject: [PATCH 049/182] mss3: prevent AC state from becoming invalid in rac_normalise() Fixes division by zero Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/mss3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c index 545fefc47a..d5bb2d4e35 100644 --- a/libavcodec/mss3.c +++ b/libavcodec/mss3.c @@ -295,7 +295,7 @@ static void rac_normalise(RangeCoder *c) c->low |= *c->src++; } else if (!c->low) { c->got_error = 1; - return; + c->low = 1; } if (c->range >= RAC_BOTTOM) return; From 4a2da83a787b24c4027aa963d9db9b453e91f413 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 19:31:45 +0100 Subject: [PATCH 050/182] dnxhddec: fix integer overflow / index check Fixes out of array read Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/dnxhddec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 6e94d32ecc..0af685e28b 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -180,7 +180,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si for (i = 0; i < ctx->mb_height; i++) { ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i<<2)); av_dlog(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]); - if (buf_size < ctx->mb_scan_index[i] + 0x280) { + if (buf_size < ctx->mb_scan_index[i] + 0x280LL) { av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n"); return -1; } From 0451ff295a9f5194c2dee87a9a704b6dcd144ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Hajdan=2C=20Jr?= Date: Thu, 10 Jan 2013 10:24:01 -0800 Subject: [PATCH 051/182] oggparsevorbis: use av_realloc consistently MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Memory passed to av_realloc cannot be allocated using memalign. From realloc(3): The realloc() function changes the size of the memory block pointed to by ptr to size bytes. (...) Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc() or realloc(). The issue has been found by debugallocation, a part of google-perftools: http://code.google.com/p/gperftools/ . Signed-off-by: Paweł Hajdan, Jr Signed-off-by: Michael Niedermayer --- libavformat/oggparsevorbis.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 16bcaefd4d..452d8565c1 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -173,11 +173,13 @@ static unsigned int fixup_vorbis_headers(AVFormatContext * as, struct oggvorbis_private *priv, uint8_t **buf) { - int i,offset, len; + int i,offset, len, buf_len; unsigned char *ptr; len = priv->len[0] + priv->len[1] + priv->len[2]; - ptr = *buf = av_mallocz(len + len/255 + 64); + buf_len = len + len/255 + 64; + ptr = *buf = av_realloc(NULL, buf_len); + memset(*buf, '\0', buf_len); ptr[0] = 2; offset = 1; From 033f1644b59abd755bb529afa5db394d18d9c30b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 19:58:25 +0100 Subject: [PATCH 052/182] fixup_vorbis_headers: add missing malloc failure check Signed-off-by: Michael Niedermayer --- libavformat/oggparsevorbis.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 452d8565c1..0b52bc7c17 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -179,6 +179,8 @@ fixup_vorbis_headers(AVFormatContext * as, struct oggvorbis_private *priv, len = priv->len[0] + priv->len[1] + priv->len[2]; buf_len = len + len/255 + 64; ptr = *buf = av_realloc(NULL, buf_len); + if (!*buf) + return 0; memset(*buf, '\0', buf_len); ptr[0] = 2; From 984add64a41c3296a8a82051cc90bff2eb449609 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 22:56:45 +0100 Subject: [PATCH 053/182] wma: check byte_offset_bits Fixes assertion failure Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/wma.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/wma.c b/libavcodec/wma.c index 5af20739a5..1e6ca61047 100644 --- a/libavcodec/wma.c +++ b/libavcodec/wma.c @@ -134,6 +134,10 @@ int ff_wma_init(AVCodecContext *avctx, int flags2) bps = (float)avctx->bit_rate / (float)(avctx->channels * avctx->sample_rate); s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0 + 0.5)) + 2; + if (s->byte_offset_bits + 3 > MIN_CACHE_BITS) { + av_log(avctx, AV_LOG_ERROR, "byte_offset_bits %d is too large\n", s->byte_offset_bits); + return AVERROR_PATCHWELCOME; + } /* compute high frequency value and choose if noise coding should be activated */ From 10e4905dd9b741a109c26341e2e5850852518604 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 30 Jan 2013 22:10:33 +0000 Subject: [PATCH 054/182] auenc: remove put_au_header() and merge its code into au_write_header Such level of abstraction is pointless. Signed-off-by: Paul B Mahol --- libavformat/au.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/libavformat/au.c b/libavformat/au.c index b3a793d7ff..f887162110 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -151,9 +151,11 @@ AVInputFormat ff_au_demuxer = { #include "rawenc.h" -/* AUDIO_FILE header */ -static int put_au_header(AVIOContext *pb, AVCodecContext *enc) +static int au_write_header(AVFormatContext *s) { + AVIOContext *pb = s->pb; + AVCodecContext *enc = s->streams[0]->codec; + if (!enc->codec_tag) return AVERROR(EINVAL); @@ -164,18 +166,6 @@ static int put_au_header(AVIOContext *pb, AVCodecContext *enc) avio_wb32(pb, enc->sample_rate); avio_wb32(pb, enc->channels); avio_wb64(pb, 0); /* annotation field */ - - return 0; -} - -static int au_write_header(AVFormatContext *s) -{ - AVIOContext *pb = s->pb; - int ret; - - if ((ret = put_au_header(pb, s->streams[0]->codec)) < 0) - return ret; - avio_flush(pb); return 0; From 0dcfccaa691bf533b0f144b6d98b49eb59f1f3ab Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Tue, 29 Jan 2013 10:54:02 +0000 Subject: [PATCH 055/182] auenc: strict check for supported codec Also check number of streams and give error message why muxing failed. This prevents muxing unsupported codec with known and supported tag. Signed-off-by: Paul B Mahol --- libavformat/au.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavformat/au.c b/libavformat/au.c index f887162110..db2ab27558 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -156,8 +156,16 @@ static int au_write_header(AVFormatContext *s) AVIOContext *pb = s->pb; AVCodecContext *enc = s->streams[0]->codec; - if (!enc->codec_tag) + if (s->nb_streams != 1) { + av_log(s, AV_LOG_ERROR, "only one stream is supported\n"); return AVERROR(EINVAL); + } + + enc->codec_tag = ff_codec_get_tag(codec_au_tags, enc->codec_id); + if (!enc->codec_tag) { + av_log(s, AV_LOG_ERROR, "unsupported codec\n"); + return AVERROR(EINVAL); + } ffio_wfourcc(pb, ".snd"); /* magic number */ avio_wb32(pb, AU_HEADER_SIZE); /* header size */ From a084884b628fd9cbfe965b7ac37e59202d708c26 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 30 Jan 2013 23:45:01 +0100 Subject: [PATCH 056/182] flashsv: clear blocks array on reallocation Fixes use of uninitialized data Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/flashsv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 7855416567..21464ed6b4 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -245,6 +245,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, FlashSVContext *s = avctx->priv_data; int h_blocks, v_blocks, h_part, v_part, i, j; GetBitContext gb; + int last_blockwidth = s->block_width; + int last_blockheight= s->block_height; /* no supplementary picture */ if (buf_size == 0) @@ -260,6 +262,10 @@ 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 ( last_blockwidth != s->block_width + || last_blockheight!= s->block_height) + av_freep(&s->blocks); + if (s->ver == 2) { skip_bits(&gb, 6); if (get_bits1(&gb)) { @@ -323,9 +329,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->keyframedata = av_realloc(s->keyframedata, avpkt->size); memcpy(s->keyframedata, avpkt->data, avpkt->size); } - if(s->ver == 2) - s->blocks = av_realloc(s->blocks, - (v_blocks + !!v_part) * (h_blocks + !!h_part) + if(s->ver == 2 && !s->blocks) + s->blocks = av_mallocz((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", From 9c50e69385e88ec632adf90ea2dd66fe2f24feb2 Mon Sep 17 00:00:00 2001 From: Piotr Bandurski Date: Wed, 30 Jan 2013 22:22:58 +0100 Subject: [PATCH 057/182] loco: fix rgba on big-endian Signed-off-by: Michael Niedermayer --- libavcodec/loco.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/loco.c b/libavcodec/loco.c index 93377e2220..9958c148c7 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -287,7 +287,7 @@ static av_cold int decode_init(AVCodecContext *avctx) break; case LOCO_CRGBA: case LOCO_RGBA: - avctx->pix_fmt = AV_PIX_FMT_RGB32; + avctx->pix_fmt = AV_PIX_FMT_BGRA; break; default: av_log(avctx, AV_LOG_INFO, "Unknown colorspace, index = %i\n", l->mode); From 9df9420dea0fc4c523dabc1bb6186c98885bdd9f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 31 Jan 2013 00:45:24 +0100 Subject: [PATCH 058/182] interplayvideo: Free previous frames on resolution changes. Fixes out of array reads Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/interplayvideo.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index 3285578a70..e0550a702b 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -969,6 +969,13 @@ static int ipvideo_decode_frame(AVCodecContext *avctx, if (buf_size < s->decoding_map_size) return buf_size; + if (s->last_frame.data[0] && av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, NULL)) { + if (s->last_frame.data[0]) + avctx->release_buffer(avctx, &s->last_frame); + if (s->second_last_frame.data[0]) + avctx->release_buffer(avctx, &s->second_last_frame); + } + s->decoding_map = buf; bytestream2_init(&s->stream_ptr, buf + s->decoding_map_size, buf_size - s->decoding_map_size); From 2b6a8187a6ae7407498888298e8d59f90cf94f9d Mon Sep 17 00:00:00 2001 From: Mirjana Vulin Date: Mon, 28 Jan 2013 17:47:53 +0100 Subject: [PATCH 059/182] mips: optimization for float aac decoder (core module) Signed-off-by: Mirjana Vulin Signed-off-by: Michael Niedermayer --- libavcodec/aac.h | 18 +- libavcodec/aacdec.c | 37 +- libavcodec/mips/Makefile | 1 + libavcodec/mips/aacdec_mips.c | 831 ++++++++++++++++++++++++++++++++ libavcodec/mips/aacdec_mips.h | 249 ++++++++++ libavutil/mips/float_dsp_mips.c | 117 +++++ 6 files changed, 1241 insertions(+), 12 deletions(-) create mode 100644 libavcodec/mips/aacdec_mips.c create mode 100644 libavcodec/mips/aacdec_mips.h diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 5b98856e67..d17366c8ee 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -257,10 +257,12 @@ typedef struct ChannelElement { SpectralBandReplication sbr; } ChannelElement; +typedef struct AACContext AACContext; + /** * main AAC context */ -typedef struct AACContext { +struct AACContext { AVClass *class; AVCodecContext *avctx; AVFrame frame; @@ -317,6 +319,18 @@ typedef struct AACContext { OutputConfiguration oc[2]; int warned_num_aac_frames; -} AACContext; + + /* aacdec functions pointers */ + void (*imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce); + void (*apply_ltp)(AACContext *ac, SingleChannelElement *sce); + void (*apply_tns)(float coef[1024], TemporalNoiseShaping *tns, + IndividualChannelStream *ics, int decode); + void (*windowing_and_mdct_ltp)(AACContext *ac, float *out, + float *in, IndividualChannelStream *ics); + void (*update_ltp)(AACContext *ac, SingleChannelElement *sce); + +}; + +void ff_aacdec_init_mips(AACContext *c); #endif /* AVCODEC_AAC_H */ diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 2538948edd..d4ea115cd5 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -108,6 +108,8 @@ #if ARCH_ARM # include "arm/aac.h" +#elif ARCH_MIPS +# include "mips/aacdec_mips.h" #endif static VLC vlc_scalefactors; @@ -872,6 +874,8 @@ static void reset_predictor_group(PredictorState *ps, int group_num) ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \ size); +static void aacdec_init(AACContext *ac); + static av_cold int aac_decode_init(AVCodecContext *avctx) { AACContext *ac = avctx->priv_data; @@ -879,6 +883,8 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) ac->avctx = avctx; ac->oc[1].m4ac.sample_rate = avctx->sample_rate; + aacdec_init(ac); + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; if (avctx->extradata_size > 0) { @@ -2165,10 +2171,10 @@ static void apply_ltp(AACContext *ac, SingleChannelElement *sce) predTime[i] = sce->ltp_state[i + 2048 - ltp->lag] * ltp->coef; memset(&predTime[i], 0, (2048 - i) * sizeof(float)); - windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); + ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); if (sce->tns.present) - apply_tns(predFreq, &sce->tns, &sce->ics, 0); + ac->apply_tns(predFreq, &sce->tns, &sce->ics, 0); for (sfb = 0; sfb < FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); sfb++) if (ltp->used[sfb]) @@ -2380,25 +2386,25 @@ static void spectral_to_sample(AACContext *ac) if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) { if (che->ch[0].ics.predictor_present) { if (che->ch[0].ics.ltp.present) - apply_ltp(ac, &che->ch[0]); + ac->apply_ltp(ac, &che->ch[0]); if (che->ch[1].ics.ltp.present && type == TYPE_CPE) - apply_ltp(ac, &che->ch[1]); + ac->apply_ltp(ac, &che->ch[1]); } } if (che->ch[0].tns.present) - apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1); + ac->apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1); if (che->ch[1].tns.present) - apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1); + ac->apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1); if (type <= TYPE_CPE) apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling); if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) { - imdct_and_windowing(ac, &che->ch[0]); + ac->imdct_and_windowing(ac, &che->ch[0]); if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) - update_ltp(ac, &che->ch[0]); + ac->update_ltp(ac, &che->ch[0]); if (type == TYPE_CPE) { - imdct_and_windowing(ac, &che->ch[1]); + ac->imdct_and_windowing(ac, &che->ch[1]); if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) - update_ltp(ac, &che->ch[1]); + ac->update_ltp(ac, &che->ch[1]); } if (ac->oc[1].m4ac.sbr > 0) { ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret); @@ -2979,6 +2985,17 @@ static av_cold int latm_decode_init(AVCodecContext *avctx) return ret; } +static void aacdec_init(AACContext *c) +{ + c->imdct_and_windowing = imdct_and_windowing; + c->apply_ltp = apply_ltp; + c->apply_tns = apply_tns; + c->windowing_and_mdct_ltp = windowing_and_mdct_ltp; + c->update_ltp = update_ltp; + + if(ARCH_MIPS) + ff_aacdec_init_mips(c); +} /** * AVOptions for Japanese DTV specific extensions (ADTS only) */ diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile index 01811975c6..609939ded7 100644 --- a/libavcodec/mips/Makefile +++ b/libavcodec/mips/Makefile @@ -13,3 +13,4 @@ OBJS-$(CONFIG_FFT) += mips/fft_init_table.o MIPSFPU-OBJS-$(CONFIG_FFT) += mips/fft_mips.o MIPSFPU-OBJS += mips/fmtconvert_mips.o OBJS-$(CONFIG_AC3DSP) += mips/ac3dsp_mips.o +OBJS-$(CONFIG_AAC_DECODER) += mips/aacdec_mips.o diff --git a/libavcodec/mips/aacdec_mips.c b/libavcodec/mips/aacdec_mips.c new file mode 100644 index 0000000000..e4033668da --- /dev/null +++ b/libavcodec/mips/aacdec_mips.c @@ -0,0 +1,831 @@ +/* + * Copyright (c) 2012 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Authors: Darko Laus (darko@mips.com) + * Djordje Pesut (djordje@mips.com) + * Mirjana Vulin (mvulin@mips.com) + * + * 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 + * Reference: libavcodec/aacdec.c + */ + +#include "libavcodec/aac.h" +#include "aacdec_mips.h" +#include "libavcodec/aactab.h" +#include "libavcodec/sinewin.h" + +#if HAVE_INLINE_ASM +static av_always_inline int lcg_random(unsigned previous_val) +{ + union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 }; + return v.s; +} + +static void imdct_and_windowing_mips(AACContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + float *in = sce->coeffs; + float *out = sce->ret; + float *saved = sce->saved; + const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; + const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; + const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; + float *buf = ac->buf_mdct; + int i; + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + for (i = 0; i < 1024; i += 128) + ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i); + } else + ac->mdct.imdct_half(&ac->mdct, buf, in); + + /* window overlapping + * NOTE: To simplify the overlapping code, all 'meaningless' short to long + * and long to short transitions are considered to be short to short + * transitions. This leaves just two cases (long to long and short to short) + * with a little special sauce for EIGHT_SHORT_SEQUENCE. + */ + if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && + (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { + ac->fdsp.vector_fmul_window( out, saved, buf, lwindow_prev, 512); + } else { + { + float *buf1 = saved; + float *buf2 = out; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 1792 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + } + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + { + float wi; + float wj; + int i; + float temp0, temp1, temp2, temp3; + float *dst0 = out + 448 + 0*128; + float *dst1 = dst0 + 64 + 63; + float *dst2 = saved + 63; + float *win0 = (float*)swindow; + float *win1 = win0 + 64 + 63; + float *win0_prev = (float*)swindow_prev; + float *win1_prev = win0_prev + 64 + 63; + float *src0_prev = saved + 448; + float *src1_prev = buf + 0*128 + 63; + float *src0 = buf + 0*128 + 64; + float *src1 = buf + 1*128 + 63; + + for(i = 0; i < 64; i++) + { + temp0 = src0_prev[0]; + temp1 = src1_prev[0]; + wi = *win0_prev; + wj = *win1_prev; + temp2 = src0[0]; + temp3 = src1[0]; + dst0[0] = temp0 * wj - temp1 * wi; + dst1[0] = temp0 * wi + temp1 * wj; + + wi = *win0; + wj = *win1; + + temp0 = src0[128]; + temp1 = src1[128]; + dst0[128] = temp2 * wj - temp3 * wi; + dst1[128] = temp2 * wi + temp3 * wj; + + temp2 = src0[256]; + temp3 = src1[256]; + dst0[256] = temp0 * wj - temp1 * wi; + dst1[256] = temp0 * wi + temp1 * wj; + dst0[384] = temp2 * wj - temp3 * wi; + dst1[384] = temp2 * wi + temp3 * wj; + + temp0 = src0[384]; + temp1 = src1[384]; + dst0[512] = temp0 * wj - temp1 * wi; + dst2[0] = temp0 * wi + temp1 * wj; + + src0++; + src1--; + src0_prev++; + src1_prev--; + win0++; + win1--; + win0_prev++; + win1_prev--; + dst0++; + dst1--; + dst2--; + } + } + } else { + ac->fdsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64); + { + float *buf1 = buf + 64; + float *buf2 = out + 576; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 1792 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + } + } + } + + // buffer update + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + ac->fdsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64); + ac->fdsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64); + ac->fdsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64); + { + float *buf1 = buf + 7*128 + 64; + float *buf2 = saved + 448; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 256 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + } + } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { + float *buf1 = buf + 512; + float *buf2 = saved; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 1792 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + { + float *buf1 = buf + 7*128 + 64; + float *buf2 = saved + 448; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 256 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + } + } else { // LONG_STOP or ONLY_LONG + float *buf1 = buf + 512; + float *buf2 = saved; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 2048 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + } +} + +static void apply_ltp_mips(AACContext *ac, SingleChannelElement *sce) +{ + const LongTermPrediction *ltp = &sce->ics.ltp; + const uint16_t *offsets = sce->ics.swb_offset; + int i, sfb; + int j, k; + + if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { + float *predTime = sce->ret; + float *predFreq = ac->buf_mdct; + float *p_predTime; + int16_t num_samples = 2048; + + if (ltp->lag < 1024) + num_samples = ltp->lag + 1024; + j = (2048 - num_samples) >> 2; + k = (2048 - num_samples) & 3; + p_predTime = &predTime[num_samples]; + + for (i = 0; i < num_samples; i++) + predTime[i] = sce->ltp_state[i + 2048 - ltp->lag] * ltp->coef; + for (i = 0; i < j; i++) { + + /* loop unrolled 4 times */ + __asm__ volatile ( + "sw $0, 0(%[p_predTime]) \n\t" + "sw $0, 4(%[p_predTime]) \n\t" + "sw $0, 8(%[p_predTime]) \n\t" + "sw $0, 12(%[p_predTime]) \n\t" + "addiu %[p_predTime], %[p_predTime], 16 \n\t" + + : [p_predTime]"+r"(p_predTime) + : + : "memory" + ); + } + for (i = 0; i < k; i++) { + + __asm__ volatile ( + "sw $0, 0(%[p_predTime]) \n\t" + "addiu %[p_predTime], %[p_predTime], 4 \n\t" + + : [p_predTime]"+r"(p_predTime) + : + : "memory" + ); + } + + ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); + + if (sce->tns.present) + ac->apply_tns(predFreq, &sce->tns, &sce->ics, 0); + + for (sfb = 0; sfb < FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); sfb++) + if (ltp->used[sfb]) + for (i = offsets[sfb]; i < offsets[sfb + 1]; i++) + sce->coeffs[i] += predFreq[i]; + } +} + +#if HAVE_MIPSFPU +static void update_ltp_mips(AACContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + float *saved = sce->saved; + float *saved_ltp = sce->coeffs; + const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; + const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; + int i; + int loop_end, loop_end1, loop_end2; + float temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9, temp10, temp11; + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + float *buf = saved; + float *buf0 = saved_ltp; + float *p_saved_ltp = saved_ltp + 576; + float *ptr1 = &saved_ltp[512]; + float *ptr2 = &ac->buf_mdct[1023]; + float *ptr3 = (float*)&swindow[63]; + loop_end1 = (int)(p_saved_ltp + 448); + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 2048 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf), + [dst]"+r"(buf0) + : + : "memory" + ); + + /* loop unrolled 8 times */ + __asm__ volatile ( + "1: \n\t" + "sw $0, 0(%[p_saved_ltp]) \n\t" + "sw $0, 4(%[p_saved_ltp]) \n\t" + "sw $0, 8(%[p_saved_ltp]) \n\t" + "sw $0, 12(%[p_saved_ltp]) \n\t" + "sw $0, 16(%[p_saved_ltp]) \n\t" + "sw $0, 20(%[p_saved_ltp]) \n\t" + "sw $0, 24(%[p_saved_ltp]) \n\t" + "sw $0, 28(%[p_saved_ltp]) \n\t" + "addiu %[p_saved_ltp], %[p_saved_ltp], 32 \n\t" + "bne %[p_saved_ltp], %[loop_end1], 1b \n\t" + + : [p_saved_ltp]"+r"(p_saved_ltp) + : [loop_end1]"r"(loop_end1) + : "memory" + ); + + ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); + for (i = 0; i < 16; i++){ + /* loop unrolled 4 times */ + __asm__ volatile ( + "lwc1 %[temp0], 0(%[ptr2]) \n\t" + "lwc1 %[temp1], -4(%[ptr2]) \n\t" + "lwc1 %[temp2], -8(%[ptr2]) \n\t" + "lwc1 %[temp3], -12(%[ptr2]) \n\t" + "lwc1 %[temp4], 0(%[ptr3]) \n\t" + "lwc1 %[temp5], -4(%[ptr3]) \n\t" + "lwc1 %[temp6], -8(%[ptr3]) \n\t" + "lwc1 %[temp7], -12(%[ptr3]) \n\t" + "mul.s %[temp8], %[temp0], %[temp4] \n\t" + "mul.s %[temp9], %[temp1], %[temp5] \n\t" + "mul.s %[temp10], %[temp2], %[temp6] \n\t" + "mul.s %[temp11], %[temp3], %[temp7] \n\t" + "swc1 %[temp8], 0(%[ptr1]) \n\t" + "swc1 %[temp9], 4(%[ptr1]) \n\t" + "swc1 %[temp10], 8(%[ptr1]) \n\t" + "swc1 %[temp11], 12(%[ptr1]) \n\t" + "addiu %[ptr1], %[ptr1], 16 \n\t" + "addiu %[ptr2], %[ptr2], -16 \n\t" + "addiu %[ptr3], %[ptr3], -16 \n\t" + + : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), + [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), + [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), + [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), + [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), + [temp10]"=&f"(temp10), [temp11]"=&f"(temp11), + [ptr1]"+r"(ptr1), [ptr2]"+r"(ptr2), [ptr3]"+r"(ptr3) + : + : "memory" + ); + } + } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { + float *buff0 = saved; + float *buff1 = saved_ltp; + float *ptr1 = &saved_ltp[512]; + float *ptr2 = &ac->buf_mdct[1023]; + float *ptr3 = (float*)&swindow[63]; + loop_end = (int)(saved + 448); + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "sw $0, 2304(%[dst]) \n\t" + "sw $0, 2308(%[dst]) \n\t" + "sw $0, 2312(%[dst]) \n\t" + "sw $0, 2316(%[dst]) \n\t" + "sw $0, 2320(%[dst]) \n\t" + "sw $0, 2324(%[dst]) \n\t" + "sw $0, 2328(%[dst]) \n\t" + "sw $0, 2332(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [src]"+r"(buff0), [dst]"+r"(buff1) + : [loop_end]"r"(loop_end) + : "memory" + ); + ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); + for (i = 0; i < 16; i++){ + /* loop unrolled 8 times */ + __asm__ volatile ( + "lwc1 %[temp0], 0(%[ptr2]) \n\t" + "lwc1 %[temp1], -4(%[ptr2]) \n\t" + "lwc1 %[temp2], -8(%[ptr2]) \n\t" + "lwc1 %[temp3], -12(%[ptr2]) \n\t" + "lwc1 %[temp4], 0(%[ptr3]) \n\t" + "lwc1 %[temp5], -4(%[ptr3]) \n\t" + "lwc1 %[temp6], -8(%[ptr3]) \n\t" + "lwc1 %[temp7], -12(%[ptr3]) \n\t" + "mul.s %[temp8], %[temp0], %[temp4] \n\t" + "mul.s %[temp9], %[temp1], %[temp5] \n\t" + "mul.s %[temp10], %[temp2], %[temp6] \n\t" + "mul.s %[temp11], %[temp3], %[temp7] \n\t" + "swc1 %[temp8], 0(%[ptr1]) \n\t" + "swc1 %[temp9], 4(%[ptr1]) \n\t" + "swc1 %[temp10], 8(%[ptr1]) \n\t" + "swc1 %[temp11], 12(%[ptr1]) \n\t" + "addiu %[ptr1], %[ptr1], 16 \n\t" + "addiu %[ptr2], %[ptr2], -16 \n\t" + "addiu %[ptr3], %[ptr3], -16 \n\t" + + : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), + [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), + [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), + [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), + [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), + [temp10]"=&f"(temp10), [temp11]"=&f"(temp11), + [ptr1]"+r"(ptr1), [ptr2]"+r"(ptr2), [ptr3]"+r"(ptr3) + : + : "memory" + ); + } + } else { // LONG_STOP or ONLY_LONG + float *ptr1, *ptr2, *ptr3; + ac->fdsp.vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512); + + ptr1 = &saved_ltp[512]; + ptr2 = &ac->buf_mdct[1023]; + ptr3 = (float*)&lwindow[511]; + + for (i = 0; i < 512; i+=4){ + /* loop unrolled 4 times */ + __asm__ volatile ( + "lwc1 %[temp0], 0(%[ptr2]) \n\t" + "lwc1 %[temp1], -4(%[ptr2]) \n\t" + "lwc1 %[temp2], -8(%[ptr2]) \n\t" + "lwc1 %[temp3], -12(%[ptr2]) \n\t" + "lwc1 %[temp4], 0(%[ptr3]) \n\t" + "lwc1 %[temp5], -4(%[ptr3]) \n\t" + "lwc1 %[temp6], -8(%[ptr3]) \n\t" + "lwc1 %[temp7], -12(%[ptr3]) \n\t" + "mul.s %[temp8], %[temp0], %[temp4] \n\t" + "mul.s %[temp9], %[temp1], %[temp5] \n\t" + "mul.s %[temp10], %[temp2], %[temp6] \n\t" + "mul.s %[temp11], %[temp3], %[temp7] \n\t" + "swc1 %[temp8], 0(%[ptr1]) \n\t" + "swc1 %[temp9], 4(%[ptr1]) \n\t" + "swc1 %[temp10], 8(%[ptr1]) \n\t" + "swc1 %[temp11], 12(%[ptr1]) \n\t" + "addiu %[ptr1], %[ptr1], 16 \n\t" + "addiu %[ptr2], %[ptr2], -16 \n\t" + "addiu %[ptr3], %[ptr3], -16 \n\t" + + : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), + [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), + [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), + [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), + [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), + [temp10]"=&f"(temp10), [temp11]"=&f"(temp11), + [ptr1]"+r"(ptr1), [ptr2]"+r"(ptr2), + [ptr3]"+r"(ptr3) + : + : "memory" + ); + } + } + + { + float *buf1 = sce->ltp_state+1024; + float *buf2 = sce->ltp_state; + float *buf3 = sce->ret; + float *buf4 = sce->ltp_state+1024; + float *buf5 = saved_ltp; + float *buf6 = sce->ltp_state+2048; + + /* loops unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 4096 \n\t" + "addiu %[loop_end1], %[src1], 4096 \n\t" + "addiu %[loop_end2], %[src2], 4096 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + "2: \n\t" + "lw %[temp0], 0(%[src1]) \n\t" + "lw %[temp1], 4(%[src1]) \n\t" + "lw %[temp2], 8(%[src1]) \n\t" + "lw %[temp3], 12(%[src1]) \n\t" + "lw %[temp4], 16(%[src1]) \n\t" + "lw %[temp5], 20(%[src1]) \n\t" + "lw %[temp6], 24(%[src1]) \n\t" + "lw %[temp7], 28(%[src1]) \n\t" + "addiu %[src1], %[src1], 32 \n\t" + "sw %[temp0], 0(%[dst1]) \n\t" + "sw %[temp1], 4(%[dst1]) \n\t" + "sw %[temp2], 8(%[dst1]) \n\t" + "sw %[temp3], 12(%[dst1]) \n\t" + "sw %[temp4], 16(%[dst1]) \n\t" + "sw %[temp5], 20(%[dst1]) \n\t" + "sw %[temp6], 24(%[dst1]) \n\t" + "sw %[temp7], 28(%[dst1]) \n\t" + "bne %[src1], %[loop_end1], 2b \n\t" + " addiu %[dst1], %[dst1], 32 \n\t" + "3: \n\t" + "lw %[temp0], 0(%[src2]) \n\t" + "lw %[temp1], 4(%[src2]) \n\t" + "lw %[temp2], 8(%[src2]) \n\t" + "lw %[temp3], 12(%[src2]) \n\t" + "lw %[temp4], 16(%[src2]) \n\t" + "lw %[temp5], 20(%[src2]) \n\t" + "lw %[temp6], 24(%[src2]) \n\t" + "lw %[temp7], 28(%[src2]) \n\t" + "addiu %[src2], %[src2], 32 \n\t" + "sw %[temp0], 0(%[dst2]) \n\t" + "sw %[temp1], 4(%[dst2]) \n\t" + "sw %[temp2], 8(%[dst2]) \n\t" + "sw %[temp3], 12(%[dst2]) \n\t" + "sw %[temp4], 16(%[dst2]) \n\t" + "sw %[temp5], 20(%[dst2]) \n\t" + "sw %[temp6], 24(%[dst2]) \n\t" + "sw %[temp7], 28(%[dst2]) \n\t" + "bne %[src2], %[loop_end2], 3b \n\t" + " addiu %[dst2], %[dst2], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [loop_end1]"=&r"(loop_end1), + [loop_end2]"=&r"(loop_end2), [src]"+r"(buf1), + [dst]"+r"(buf2), [src1]"+r"(buf3), [dst1]"+r"(buf4), + [src2]"+r"(buf5), [dst2]"+r"(buf6) + : + : "memory" + ); + } +} +#endif /* HAVE_MIPSFPU */ +#endif /* HAVE_INLINE_ASM */ + +void ff_aacdec_init_mips(AACContext *c) +{ +#if HAVE_INLINE_ASM + c->imdct_and_windowing = imdct_and_windowing_mips; + c->apply_ltp = apply_ltp_mips; +#if HAVE_MIPSFPU + c->update_ltp = update_ltp_mips; +#endif /* HAVE_MIPSFPU */ +#endif /* HAVE_INLINE_ASM */ +} diff --git a/libavcodec/mips/aacdec_mips.h b/libavcodec/mips/aacdec_mips.h new file mode 100644 index 0000000000..9ba307962f --- /dev/null +++ b/libavcodec/mips/aacdec_mips.h @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2012 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Authors: Darko Laus (darko@mips.com) + * Djordje Pesut (djordje@mips.com) + * Mirjana Vulin (mvulin@mips.com) + * + * AAC Spectral Band Replication decoding functions optimized for MIPS + * + * 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 + * Reference: libavcodec/aacdec.c + */ + +#ifndef AVCODEC_MIPS_AACDEC_FLOAT_H +#define AVCODEC_MIPS_AACDEC_FLOAT_H + +#include "libavcodec/aac.h" + +#if HAVE_INLINE_ASM && HAVE_MIPSFPU +static inline float *VMUL2_mips(float *dst, const float *v, unsigned idx, + const float *scale) +{ + float temp0, temp1, temp2; + int temp3, temp4; + float *ret; + + __asm__ volatile( + "andi %[temp3], %[idx], 15 \n\t" + "ext %[temp4], %[idx], 4, 4 \n\t" + "sll %[temp3], %[temp3], 2 \n\t" + "sll %[temp4], %[temp4], 2 \n\t" + "lwc1 %[temp2], 0(%[scale]) \n\t" + "lwxc1 %[temp0], %[temp3](%[v]) \n\t" + "lwxc1 %[temp1], %[temp4](%[v]) \n\t" + "mul.s %[temp0], %[temp0], %[temp2] \n\t" + "mul.s %[temp1], %[temp1], %[temp2] \n\t" + "addiu %[ret], %[dst], 8 \n\t" + "swc1 %[temp0], 0(%[dst]) \n\t" + "swc1 %[temp1], 4(%[dst]) \n\t" + + : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), + [temp2]"=&f"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [ret]"=&r"(ret) + : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), + [dst]"r"(dst) + : "memory" + ); + return ret; +} + +static inline float *VMUL4_mips(float *dst, const float *v, unsigned idx, + const float *scale) +{ + int temp0, temp1, temp2, temp3; + float temp4, temp5, temp6, temp7, temp8; + float *ret; + + __asm__ volatile( + "andi %[temp0], %[idx], 3 \n\t" + "ext %[temp1], %[idx], 2, 2 \n\t" + "ext %[temp2], %[idx], 4, 2 \n\t" + "ext %[temp3], %[idx], 6, 2 \n\t" + "sll %[temp0], %[temp0], 2 \n\t" + "sll %[temp1], %[temp1], 2 \n\t" + "sll %[temp2], %[temp2], 2 \n\t" + "sll %[temp3], %[temp3], 2 \n\t" + "lwc1 %[temp4], 0(%[scale]) \n\t" + "lwxc1 %[temp5], %[temp0](%[v]) \n\t" + "lwxc1 %[temp6], %[temp1](%[v]) \n\t" + "lwxc1 %[temp7], %[temp2](%[v]) \n\t" + "lwxc1 %[temp8], %[temp3](%[v]) \n\t" + "mul.s %[temp5], %[temp5], %[temp4] \n\t" + "mul.s %[temp6], %[temp6], %[temp4] \n\t" + "mul.s %[temp7], %[temp7], %[temp4] \n\t" + "mul.s %[temp8], %[temp8], %[temp4] \n\t" + "addiu %[ret], %[dst], 16 \n\t" + "swc1 %[temp5], 0(%[dst]) \n\t" + "swc1 %[temp6], 4(%[dst]) \n\t" + "swc1 %[temp7], 8(%[dst]) \n\t" + "swc1 %[temp8], 12(%[dst]) \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), + [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), + [temp8]"=&f"(temp8), [ret]"=&r"(ret) + : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), + [dst]"r"(dst) + : "memory" + ); + return ret; +} + +static inline float *VMUL2S_mips(float *dst, const float *v, unsigned idx, + unsigned sign, const float *scale) +{ + int temp0, temp1, temp2, temp3, temp4, temp5; + float temp6, temp7, temp8, temp9; + float *ret; + + __asm__ volatile( + "andi %[temp0], %[idx], 15 \n\t" + "ext %[temp1], %[idx], 4, 4 \n\t" + "lw %[temp4], 0(%[scale]) \n\t" + "srl %[temp2], %[sign], 1 \n\t" + "sll %[temp3], %[sign], 31 \n\t" + "sll %[temp2], %[temp2], 31 \n\t" + "sll %[temp0], %[temp0], 2 \n\t" + "sll %[temp1], %[temp1], 2 \n\t" + "lwxc1 %[temp8], %[temp0](%[v]) \n\t" + "lwxc1 %[temp9], %[temp1](%[v]) \n\t" + "xor %[temp5], %[temp4], %[temp2] \n\t" + "xor %[temp4], %[temp4], %[temp3] \n\t" + "mtc1 %[temp5], %[temp6] \n\t" + "mtc1 %[temp4], %[temp7] \n\t" + "mul.s %[temp8], %[temp8], %[temp6] \n\t" + "mul.s %[temp9], %[temp9], %[temp7] \n\t" + "addiu %[ret], %[dst], 8 \n\t" + "swc1 %[temp8], 0(%[dst]) \n\t" + "swc1 %[temp9], 4(%[dst]) \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), + [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), + [ret]"=&r"(ret) + : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), + [dst]"r"(dst), [sign]"r"(sign) + : "memory" + ); + return ret; +} + +static inline float *VMUL4S_mips(float *dst, const float *v, unsigned idx, + unsigned sign, const float *scale) +{ + int temp0, temp1, temp2, temp3, temp4; + float temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17; + float *ret; + unsigned int mask = 1U << 31; + + __asm__ volatile( + "lw %[temp0], 0(%[scale]) \n\t" + "and %[temp1], %[idx], 3 \n\t" + "ext %[temp2], %[idx], 2, 2 \n\t" + "ext %[temp3], %[idx], 4, 2 \n\t" + "ext %[temp4], %[idx], 6, 2 \n\t" + "sll %[temp1], %[temp1], 2 \n\t" + "sll %[temp2], %[temp2], 2 \n\t" + "sll %[temp3], %[temp3], 2 \n\t" + "sll %[temp4], %[temp4], 2 \n\t" + "lwxc1 %[temp10], %[temp1](%[v]) \n\t" + "lwxc1 %[temp11], %[temp2](%[v]) \n\t" + "lwxc1 %[temp12], %[temp3](%[v]) \n\t" + "lwxc1 %[temp13], %[temp4](%[v]) \n\t" + "and %[temp1], %[sign], %[mask] \n\t" + "ext %[temp2], %[idx], 12, 1 \n\t" + "ext %[temp3], %[idx], 13, 1 \n\t" + "ext %[temp4], %[idx], 14, 1 \n\t" + "sllv %[sign], %[sign], %[temp2] \n\t" + "xor %[temp1], %[temp0], %[temp1] \n\t" + "and %[temp2], %[sign], %[mask] \n\t" + "mtc1 %[temp1], %[temp14] \n\t" + "xor %[temp2], %[temp0], %[temp2] \n\t" + "sllv %[sign], %[sign], %[temp3] \n\t" + "mtc1 %[temp2], %[temp15] \n\t" + "and %[temp3], %[sign], %[mask] \n\t" + "sllv %[sign], %[sign], %[temp4] \n\t" + "xor %[temp3], %[temp0], %[temp3] \n\t" + "and %[temp4], %[sign], %[mask] \n\t" + "mtc1 %[temp3], %[temp16] \n\t" + "xor %[temp4], %[temp0], %[temp4] \n\t" + "mtc1 %[temp4], %[temp17] \n\t" + "mul.s %[temp10], %[temp10], %[temp14] \n\t" + "mul.s %[temp11], %[temp11], %[temp15] \n\t" + "mul.s %[temp12], %[temp12], %[temp16] \n\t" + "mul.s %[temp13], %[temp13], %[temp17] \n\t" + "addiu %[ret], %[dst], 16 \n\t" + "swc1 %[temp10], 0(%[dst]) \n\t" + "swc1 %[temp11], 4(%[dst]) \n\t" + "swc1 %[temp12], 8(%[dst]) \n\t" + "swc1 %[temp13], 12(%[dst]) \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp10]"=&f"(temp10), + [temp11]"=&f"(temp11), [temp12]"=&f"(temp12), + [temp13]"=&f"(temp13), [temp14]"=&f"(temp14), + [temp15]"=&f"(temp15), [temp16]"=&f"(temp16), + [temp17]"=&f"(temp17), [ret]"=&r"(ret), + [sign]"+r"(sign) + : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), + [dst]"r"(dst), [mask]"r"(mask) + : "memory" + ); + return ret; +} + +#define VMUL2 VMUL2_mips +#define VMUL4 VMUL4_mips +#define VMUL2S VMUL2S_mips +#define VMUL4S VMUL4S_mips +#endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */ + +#endif /* AVCODEC_MIPS_AACDEC_FLOAT_H */ diff --git a/libavutil/mips/float_dsp_mips.c b/libavutil/mips/float_dsp_mips.c index e39a4bf2bb..5211a265d4 100644 --- a/libavutil/mips/float_dsp_mips.c +++ b/libavutil/mips/float_dsp_mips.c @@ -106,6 +106,43 @@ static void vector_fmul_mips(float *dst, const float *src0, const float *src1, } } +static void vector_fmul_scalar_mips(float *dst, const float *src, float mul, + int len) +{ + float temp0, temp1, temp2, temp3; + float *local_src = (float*)src; + float *end = local_src + len; + + /* loop unrolled 4 times */ + __asm__ volatile( + ".set push \n\t" + ".set noreorder \n\t" + "1: \n\t" + "lwc1 %[temp0], 0(%[src]) \n\t" + "lwc1 %[temp1], 4(%[src]) \n\t" + "lwc1 %[temp2], 8(%[src]) \n\t" + "lwc1 %[temp3], 12(%[src]) \n\t" + "addiu %[dst], %[dst], 16 \n\t" + "mul.s %[temp0], %[temp0], %[mul] \n\t" + "mul.s %[temp1], %[temp1], %[mul] \n\t" + "mul.s %[temp2], %[temp2], %[mul] \n\t" + "mul.s %[temp3], %[temp3], %[mul] \n\t" + "addiu %[src], %[src], 16 \n\t" + "swc1 %[temp0], -16(%[dst]) \n\t" + "swc1 %[temp1], -12(%[dst]) \n\t" + "swc1 %[temp2], -8(%[dst]) \n\t" + "bne %[src], %[end], 1b \n\t" + " swc1 %[temp3], -4(%[dst]) \n\t" + ".set pop \n\t" + + : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), + [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), + [dst]"+r"(dst), [src]"+r"(local_src) + : [end]"r"(end), [mul]"f"(mul) + : "memory" + ); +} + static void vector_fmul_window_mips(float *dst, const float *src0, const float *src1, const float *win, int len) { @@ -216,11 +253,91 @@ static void vector_fmul_window_mips(float *dst, const float *src0, ); } } + +static void butterflies_float_mips(float *av_restrict v1, float *av_restrict v2, + int len) +{ + float temp0, temp1, temp2, temp3, temp4; + float temp5, temp6, temp7, temp8, temp9; + float temp10, temp11, temp12, temp13, temp14, temp15; + int pom; + pom = (len >> 2)-1; + + /* loop unrolled 4 times */ + __asm__ volatile ( + "lwc1 %[temp0], 0(%[v1]) \n\t" + "lwc1 %[temp1], 4(%[v1]) \n\t" + "lwc1 %[temp2], 8(%[v1]) \n\t" + "lwc1 %[temp3], 12(%[v1]) \n\t" + "lwc1 %[temp4], 0(%[v2]) \n\t" + "lwc1 %[temp5], 4(%[v2]) \n\t" + "lwc1 %[temp6], 8(%[v2]) \n\t" + "lwc1 %[temp7], 12(%[v2]) \n\t" + "beq %[pom], $zero, 2f \n\t" + "1: \n\t" + "sub.s %[temp8], %[temp0], %[temp4] \n\t" + "add.s %[temp9], %[temp0], %[temp4] \n\t" + "sub.s %[temp10], %[temp1], %[temp5] \n\t" + "add.s %[temp11], %[temp1], %[temp5] \n\t" + "sub.s %[temp12], %[temp2], %[temp6] \n\t" + "add.s %[temp13], %[temp2], %[temp6] \n\t" + "sub.s %[temp14], %[temp3], %[temp7] \n\t" + "add.s %[temp15], %[temp3], %[temp7] \n\t" + "addiu %[v1], %[v1], 16 \n\t" + "addiu %[v2], %[v2], 16 \n\t" + "addiu %[pom], %[pom], -1 \n\t" + "lwc1 %[temp0], 0(%[v1]) \n\t" + "lwc1 %[temp1], 4(%[v1]) \n\t" + "lwc1 %[temp2], 8(%[v1]) \n\t" + "lwc1 %[temp3], 12(%[v1]) \n\t" + "lwc1 %[temp4], 0(%[v2]) \n\t" + "lwc1 %[temp5], 4(%[v2]) \n\t" + "lwc1 %[temp6], 8(%[v2]) \n\t" + "lwc1 %[temp7], 12(%[v2]) \n\t" + "swc1 %[temp9], -16(%[v1]) \n\t" + "swc1 %[temp8], -16(%[v2]) \n\t" + "swc1 %[temp11], -12(%[v1]) \n\t" + "swc1 %[temp10], -12(%[v2]) \n\t" + "swc1 %[temp13], -8(%[v1]) \n\t" + "swc1 %[temp12], -8(%[v2]) \n\t" + "swc1 %[temp15], -4(%[v1]) \n\t" + "swc1 %[temp14], -4(%[v2]) \n\t" + "bgtz %[pom], 1b \n\t" + "2: \n\t" + "sub.s %[temp8], %[temp0], %[temp4] \n\t" + "add.s %[temp9], %[temp0], %[temp4] \n\t" + "sub.s %[temp10], %[temp1], %[temp5] \n\t" + "add.s %[temp11], %[temp1], %[temp5] \n\t" + "sub.s %[temp12], %[temp2], %[temp6] \n\t" + "add.s %[temp13], %[temp2], %[temp6] \n\t" + "sub.s %[temp14], %[temp3], %[temp7] \n\t" + "add.s %[temp15], %[temp3], %[temp7] \n\t" + "swc1 %[temp9], 0(%[v1]) \n\t" + "swc1 %[temp8], 0(%[v2]) \n\t" + "swc1 %[temp11], 4(%[v1]) \n\t" + "swc1 %[temp10], 4(%[v2]) \n\t" + "swc1 %[temp13], 8(%[v1]) \n\t" + "swc1 %[temp12], 8(%[v2]) \n\t" + "swc1 %[temp15], 12(%[v1]) \n\t" + "swc1 %[temp14], 12(%[v2]) \n\t" + + : [v1]"+r"(v1), [v2]"+r"(v2), [pom]"+r"(pom), [temp0] "=&f" (temp0), + [temp1]"=&f"(temp1), [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), + [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), [temp6]"=&f"(temp6), + [temp7]"=&f"(temp7), [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), + [temp10]"=&f"(temp10), [temp11]"=&f"(temp11), [temp12]"=&f"(temp12), + [temp13]"=&f"(temp13), [temp14]"=&f"(temp14), [temp15]"=&f"(temp15) + : + : "memory" + ); +} #endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */ void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp) { #if HAVE_INLINE_ASM && HAVE_MIPSFPU fdsp->vector_fmul = vector_fmul_mips; + fdsp->vector_fmul_scalar = vector_fmul_scalar_mips; fdsp->vector_fmul_window = vector_fmul_window_mips; + fdsp->butterflies_float = butterflies_float_mips; #endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */ } From fe6767f849d9cfe51f422de9d807137d756de7aa Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 31 Jan 2013 03:36:59 +0100 Subject: [PATCH 060/182] asfdec: fix integer overflow in packet_replic_size check Fixes assertion failure Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavformat/asfdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 5c2cf8b9b0..465d9e5792 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -943,7 +943,7 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){ av_dlog(asf, "key:%d stream:%d seq:%d offset:%d replic_size:%d\n", asf->packet_key_frame, asf->stream_index, asf->packet_seq, asf->packet_frag_offset, asf->packet_replic_size); - if (rsize+asf->packet_replic_size > asf->packet_size_left) { + if (rsize+(int64_t)asf->packet_replic_size > asf->packet_size_left) { av_log(s, AV_LOG_ERROR, "packet_replic_size %d is invalid\n", asf->packet_replic_size); return AVERROR_INVALIDDATA; } From cdf0877bc341684c56ac1fe057397adbadf329ee Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 31 Jan 2013 04:20:24 +0100 Subject: [PATCH 061/182] h264/cabac: check loop index fix out of array read Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/h264_cabac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index bbca26ab4d..54b3775761 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1712,7 +1712,7 @@ decode_cabac_residual_internal(H264Context *h, int16_t *block, \ if( coeff_abs >= 15 ) { \ int j = 0; \ - while( get_cabac_bypass( CC ) ) { \ + while(get_cabac_bypass( CC ) && j<30) { \ j++; \ } \ \ From a65f965c04bfa27adedc0409c14cc05903f483d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 31 Jan 2013 10:19:57 +0200 Subject: [PATCH 062/182] mpegvideo: Do REBASE_PICTURE with byte pointers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit REBASE_PICTURE (more specifically, this half of it) takes a Picture pointer that points into one larger struct, finds the offset of that Picture within the struct and finds the corresponding field within another instance of a similar struct. The pointer difference "pic - (Picture*)old_ctx" is a value given in sizeof(Picture) units, and when applied back on (Picture*)new_ctx gets multiplied back with sizeof(Picture). Many compilers seem to optimize out this division/multiplication, but not all do. GCC 4.2 on OS X doesn't seem to remove the division/multiplication, therefore the new pointer didn't turn out to point to exactly the right place in the new struct since it only had sizeof(Picture) granularity (and the Picture is not aligned on a sizeof(Picture) boundary within the encompassing struct). This bug has been present before 47318953d as well - with H264, pointers to h->ref_list[0][0] pointed to 88 bytes before h->ref_list[0][0] after the rebase. After shrinking Picture, the difference ended up even larger, making writes via such a Picture pointer overwrite other fields at random in H264Context, ending up in crashes later. This fixes H264 multithreaded decoding on OS X with GCC 4.2. Signed-off-by: Martin Storsjö --- libavcodec/mpegvideo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index a2a5d7b876..51e422bf61 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -714,7 +714,7 @@ typedef struct MpegEncContext { #define REBASE_PICTURE(pic, new_ctx, old_ctx) (pic ? \ (pic >= old_ctx->picture && pic < old_ctx->picture+old_ctx->picture_count ?\ - &new_ctx->picture[pic - old_ctx->picture] : pic - (Picture*)old_ctx + (Picture*)new_ctx)\ + &new_ctx->picture[pic - old_ctx->picture] : (Picture*) ((uint8_t*)pic - (uint8_t*)old_ctx + (uint8_t*)new_ctx))\ : NULL) /* mpegvideo_enc common options */ From 0f5b0b4178b844fcab82222109d0be00ab73c185 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 29 Jan 2013 18:00:34 +0100 Subject: [PATCH 063/182] avisynth: Change demuxer name to avoid conflicts with AVS --- libavformat/avisynth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index d31c427646..eb5e7adffd 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -219,7 +219,7 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t pts, } AVInputFormat ff_avisynth_demuxer = { - .name = "avs", + .name = "avisynth", .long_name = NULL_IF_CONFIG_SMALL("AVISynth"), .priv_data_size = sizeof(AVISynthContext), .read_header = avisynth_read_header, From 197252f1c58b1d53f97c10201990a471dd46d31c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 31 Jan 2013 00:50:51 +0100 Subject: [PATCH 064/182] configure: Add a comment indicating why uclibc is checked before glibc --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index c41a396f3e..ebeea83edf 100755 --- a/configure +++ b/configure @@ -3035,6 +3035,7 @@ esac # determine libc flavour +# uclibc defines __GLIBC__, so it needs to be checked before glibc. if check_cpp_condition features.h "defined __UCLIBC__"; then libc_type=uclibc add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 From 29f1fa74225e9fdbab6d590857edbecb51cf74da Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 31 Jan 2013 00:43:18 +0100 Subject: [PATCH 065/182] configure: Move newlib libc check before mingw libc check On Cygwin systems MinGW headers can be present if the corresponding packages have been installed. Since the MinGW libc is checked for first, this results in newlib getting misdetected as MinGW libc. --- configure | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 77600ef2b5..c41a396f3e 100755 --- a/configure +++ b/configure @@ -3041,15 +3041,16 @@ if check_cpp_condition features.h "defined __UCLIBC__"; then elif check_cpp_condition features.h "defined __GLIBC__"; then libc_type=glibc add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 +# MinGW headers can be installed on Cygwin, so check for newlib first. +elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then + libc_type=newlib + add_cppflags -U__STRICT_ANSI__ elif check_header _mingw.h; then libc_type=mingw check_cpp_condition _mingw.h \ "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) || \ (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" || die "ERROR: MinGW runtime version must be >= 3.15." -elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then - libc_type=newlib - add_cppflags -U__STRICT_ANSI__ elif check_func_headers stdlib.h _get_doserrno; then libc_type=msvcrt add_compat strtod.o strtod=avpriv_strtod From 52acd79165e70799871a2feeb02b4fdc0d38a956 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 29 Jan 2013 19:28:07 +0100 Subject: [PATCH 066/182] x86: hpel: Move {avg,put}_pixels16_sse2 to hpeldsp --- libavcodec/x86/dsputil.asm | 43 -------------------------------------- libavcodec/x86/hpeldsp.asm | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/libavcodec/x86/dsputil.asm b/libavcodec/x86/dsputil.asm index 351376d743..8002779a2e 100644 --- a/libavcodec/x86/dsputil.asm +++ b/libavcodec/x86/dsputil.asm @@ -648,46 +648,3 @@ BSWAP32_BUF INIT_XMM ssse3 BSWAP32_BUF - -INIT_XMM sse2 -; void put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_size, int h) -cglobal put_pixels16, 4,5,4 - movsxdifnidn r2, r2d - lea r4, [r2*3] -.loop: - movu m0, [r1] - movu m1, [r1+r2] - movu m2, [r1+r2*2] - movu m3, [r1+r4] - lea r1, [r1+r2*4] - mova [r0], m0 - mova [r0+r2], m1 - mova [r0+r2*2], m2 - mova [r0+r4], m3 - sub r3d, 4 - lea r0, [r0+r2*4] - jnz .loop - REP_RET - -; void avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_size, int h) -cglobal avg_pixels16, 4,5,4 - movsxdifnidn r2, r2d - lea r4, [r2*3] -.loop: - movu m0, [r1] - movu m1, [r1+r2] - movu m2, [r1+r2*2] - movu m3, [r1+r4] - lea r1, [r1+r2*4] - pavgb m0, [r0] - pavgb m1, [r0+r2] - pavgb m2, [r0+r2*2] - pavgb m3, [r0+r4] - mova [r0], m0 - mova [r0+r2], m1 - mova [r0+r2*2], m2 - mova [r0+r4], m3 - sub r3d, 4 - lea r0, [r0+r2*4] - jnz .loop - REP_RET diff --git a/libavcodec/x86/hpeldsp.asm b/libavcodec/x86/hpeldsp.asm index ee5d56293e..920ae67630 100644 --- a/libavcodec/x86/hpeldsp.asm +++ b/libavcodec/x86/hpeldsp.asm @@ -463,3 +463,46 @@ INIT_MMX mmxext AVG_PIXELS8_XY2 INIT_MMX 3dnow AVG_PIXELS8_XY2 + +INIT_XMM sse2 +; void put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_size, int h) +cglobal put_pixels16, 4,5,4 + movsxdifnidn r2, r2d + lea r4, [r2*3] +.loop: + movu m0, [r1] + movu m1, [r1+r2] + movu m2, [r1+r2*2] + movu m3, [r1+r4] + lea r1, [r1+r2*4] + mova [r0], m0 + mova [r0+r2], m1 + mova [r0+r2*2], m2 + mova [r0+r4], m3 + sub r3d, 4 + lea r0, [r0+r2*4] + jnz .loop + REP_RET + +; void avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_size, int h) +cglobal avg_pixels16, 4,5,4 + movsxdifnidn r2, r2d + lea r4, [r2*3] +.loop: + movu m0, [r1] + movu m1, [r1+r2] + movu m2, [r1+r2*2] + movu m3, [r1+r4] + lea r1, [r1+r2*4] + pavgb m0, [r0] + pavgb m1, [r0+r2] + pavgb m2, [r0+r2*2] + pavgb m3, [r0+r4] + mova [r0], m0 + mova [r0+r2], m1 + mova [r0+r2*2], m2 + mova [r0+r4], m3 + sub r3d, 4 + lea r0, [r0+r2*4] + jnz .loop + REP_RET From d99bc8475232ef7f72042c7a7328b77cc3771fa4 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 23 Jan 2013 11:45:31 +0100 Subject: [PATCH 067/182] doc/eval: fix/extend documentation for root() function --- doc/eval.texi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/eval.texi b/doc/eval.texi index f77b87deac..37ca137b96 100644 --- a/doc/eval.texi +++ b/doc/eval.texi @@ -175,8 +175,17 @@ When the series does not converge the results are undefined. Return the current (wallclock) time in seconds. @item root(expr, max) -Finds x where f(x)=0 in the interval 0..max. -f() must be continuous or the result is undefined. +Find an input value for which the function represented by @var{expr} +with argument @var{ld(0)} is 0 in the interval 0..@var{max}. + +The expression in @var{expr} must denote a continuous function or the +result is undefined. + +@var{ld(0)} is used to represent the function input value, which means +that the given expression will be evaluated multiple times with +various input values that the expression can access through +@code{ld(0)}. When the expression evaluates to 0 then the +corresponding input value will be returned. @end table The following constants are available: From 41e5e28daf0a0f7ba258e054ab7e76c8a94c305e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 22 Jan 2013 23:53:39 +0100 Subject: [PATCH 068/182] doc/eval: fix/extend documentation for taylor() function --- doc/eval.texi | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/doc/eval.texi b/doc/eval.texi index 37ca137b96..bf4274ca4c 100644 --- a/doc/eval.texi +++ b/doc/eval.texi @@ -163,13 +163,20 @@ evaluation of @var{y}, return 0 otherwise. Evaluate @var{x}, and if the result is zero return the evaluation result of @var{y}, otherwise the evaluation result of @var{z}. -@item taylor(expr, x) taylor(expr, x, id) -Evaluate a taylor series at x. -expr represents the LD(id)-th derivates of f(x) at 0. If id is not specified -then 0 is assumed. -note, when you have the derivatives at y instead of 0 -taylor(expr, x-y) can be used -When the series does not converge the results are undefined. +@item taylor(expr, x) +@item taylor(expr, x, id) +Evaluate a Taylor series at @var{x}, given an expression representing +the @code{ld(id)}-th derivative of a function at 0. + +When the series does not converge the result is undefined. + +@var{ld(id)} is used to represent the derivative order in @var{expr}, +which means that the given expression will be evaluated multiple times +with various input values that the expression can access through +@code{ld(id)}. If @var{id} is not specified then 0 is assumed. + +Note, when you have the derivatives at y instead of 0, +@code{taylor(expr, x-y)} can be used. @item time(0) Return the current (wallclock) time in seconds. From dcfbe1e0b67bfdaf0827a0c54f3c736cdb7c9c1c Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 26 Jan 2013 15:25:39 +0100 Subject: [PATCH 069/182] doc/eval: sort functions by name --- doc/eval.texi | 228 +++++++++++++++++++++++++------------------------- 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/doc/eval.texi b/doc/eval.texi index bf4274ca4c..9b98c18cdf 100644 --- a/doc/eval.texi +++ b/doc/eval.texi @@ -20,122 +20,51 @@ The following unary operators are available: @code{+}, @code{-}. The following functions are available: @table @option -@item sinh(x) -Compute hyperbolic sine of @var{x}. - -@item cosh(x) -Compute hyperbolic cosine of @var{x}. - -@item tanh(x) -Compute hyperbolic tangent of @var{x}. - -@item sin(x) -Compute sine of @var{x}. - -@item cos(x) -Compute cosine of @var{x}. - -@item tan(x) -Compute tangent of @var{x}. - -@item atan(x) -Compute arctangent of @var{x}. - -@item asin(x) -Compute arcsine of @var{x}. +@item abs(x) +Compute absolute value of @var{x}. @item acos(x) Compute arccosine of @var{x}. -@item exp(x) -Compute exponential of @var{x} (with base @code{e}, the Euler's number). +@item asin(x) +Compute arcsine of @var{x}. -@item log(x) -Compute natural logarithm of @var{x}. - -@item abs(x) -Compute absolute value of @var{x}. - -@item squish(x) -Compute expression @code{1/(1 + exp(4*x))}. - -@item gauss(x) -Compute Gauss function of @var{x}, corresponding to -@code{exp(-x*x/2) / sqrt(2*PI)}. - -@item isinf(x) -Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise. - -@item isnan(x) -Return 1.0 if @var{x} is NAN, 0.0 otherwise. - -@item mod(x, y) -Compute the remainder of division of @var{x} by @var{y}. - -@item max(x, y) -Return the maximum between @var{x} and @var{y}. - -@item min(x, y) -Return the maximum between @var{x} and @var{y}. - -@item eq(x, y) -Return 1 if @var{x} and @var{y} are equivalent, 0 otherwise. - -@item gte(x, y) -Return 1 if @var{x} is greater than or equal to @var{y}, 0 otherwise. - -@item gt(x, y) -Return 1 if @var{x} is greater than @var{y}, 0 otherwise. - -@item lte(x, y) -Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise. - -@item lt(x, y) -Return 1 if @var{x} is lesser than @var{y}, 0 otherwise. - -@item st(var, expr) -Allow to store the value of the expression @var{expr} in an internal -variable. @var{var} specifies the number of the variable where to -store the value, and it is a value ranging from 0 to 9. The function -returns the value stored in the internal variable. -Note, Variables are currently not shared between expressions. - -@item ld(var) -Allow to load the value of the internal variable with number -@var{var}, which was previously stored with st(@var{var}, @var{expr}). -The function returns the loaded value. - -@item while(cond, expr) -Evaluate expression @var{expr} while the expression @var{cond} is -non-zero, and returns the value of the last @var{expr} evaluation, or -NAN if @var{cond} was always false. +@item atan(x) +Compute arctangent of @var{x}. @item ceil(expr) Round the value of expression @var{expr} upwards to the nearest integer. For example, "ceil(1.5)" is "2.0". +@item cos(x) +Compute cosine of @var{x}. + +@item cosh(x) +Compute hyperbolic cosine of @var{x}. + +@item eq(x, y) +Return 1 if @var{x} and @var{y} are equivalent, 0 otherwise. + +@item exp(x) +Compute exponential of @var{x} (with base @code{e}, the Euler's number). + @item floor(expr) Round the value of expression @var{expr} downwards to the nearest integer. For example, "floor(-1.5)" is "-2.0". -@item trunc(expr) -Round the value of expression @var{expr} towards zero to the nearest -integer. For example, "trunc(-1.5)" is "-1.0". +@item gauss(x) +Compute Gauss function of @var{x}, corresponding to +@code{exp(-x*x/2) / sqrt(2*PI)}. -@item sqrt(expr) -Compute the square root of @var{expr}. This is equivalent to -"(@var{expr})^.5". +@item gcd(x, y) +Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and +@var{y} are 0 or either or both are less than zero then behavior is undefined. -@item not(expr) -Return 1.0 if @var{expr} is zero, 0.0 otherwise. +@item gt(x, y) +Return 1 if @var{x} is greater than @var{y}, 0 otherwise. -@item pow(x, y) -Compute the power of @var{x} elevated @var{y}, it is equivalent to -"(@var{x})^(@var{y})". - -@item random(x) -Return a pseudo random value between 0.0 and 1.0. @var{x} is the index of the -internal variable which will be used to save the seed/state. +@item gte(x, y) +Return 1 if @var{x} is greater than or equal to @var{y}, 0 otherwise. @item hypot(x, y) This function is similar to the C function with the same name; it returns @@ -143,10 +72,6 @@ This function is similar to the C function with the same name; it returns right triangle with sides of length @var{x} and @var{y}, or the distance of the point (@var{x}, @var{y}) from the origin. -@item gcd(x, y) -Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and -@var{y} are 0 or either or both are less than zero then behavior is undefined. - @item if(x, y) Evaluate @var{x}, and if the result is non-zero return the result of the evaluation of @var{y}, return 0 otherwise. @@ -163,6 +88,85 @@ evaluation of @var{y}, return 0 otherwise. Evaluate @var{x}, and if the result is zero return the evaluation result of @var{y}, otherwise the evaluation result of @var{z}. +@item isinf(x) +Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise. + +@item isnan(x) +Return 1.0 if @var{x} is NAN, 0.0 otherwise. + +@item ld(var) +Allow to load the value of the internal variable with number +@var{var}, which was previously stored with st(@var{var}, @var{expr}). +The function returns the loaded value. + +@item log(x) +Compute natural logarithm of @var{x}. + +@item lt(x, y) +Return 1 if @var{x} is lesser than @var{y}, 0 otherwise. + +@item lte(x, y) +Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise. + +@item max(x, y) +Return the maximum between @var{x} and @var{y}. + +@item min(x, y) +Return the maximum between @var{x} and @var{y}. + +@item mod(x, y) +Compute the remainder of division of @var{x} by @var{y}. + +@item not(expr) +Return 1.0 if @var{expr} is zero, 0.0 otherwise. + +@item pow(x, y) +Compute the power of @var{x} elevated @var{y}, it is equivalent to +"(@var{x})^(@var{y})". + +@item random(x) +Return a pseudo random value between 0.0 and 1.0. @var{x} is the index of the +internal variable which will be used to save the seed/state. + +@item root(expr, max) +Find an input value for which the function represented by @var{expr} +with argument @var{ld(0)} is 0 in the interval 0..@var{max}. + +The expression in @var{expr} must denote a continuous function or the +result is undefined. + +@var{ld(0)} is used to represent the function input value, which means +that the given expression will be evaluated multiple times with +various input values that the expression can access through +@code{ld(0)}. When the expression evaluates to 0 then the +corresponding input value will be returned. + +@item sin(x) +Compute sine of @var{x}. + +@item sinh(x) +Compute hyperbolic sine of @var{x}. + +@item sqrt(expr) +Compute the square root of @var{expr}. This is equivalent to +"(@var{expr})^.5". + +@item squish(x) +Compute expression @code{1/(1 + exp(4*x))}. + +@item st(var, expr) +Allow to store the value of the expression @var{expr} in an internal +variable. @var{var} specifies the number of the variable where to +store the value, and it is a value ranging from 0 to 9. The function +returns the value stored in the internal variable. +Note, Variables are currently not shared between expressions. + +@item tan(x) +Compute tangent of @var{x}. + +@item tanh(x) +Compute hyperbolic tangent of @var{x}. + @item taylor(expr, x) @item taylor(expr, x, id) Evaluate a Taylor series at @var{x}, given an expression representing @@ -181,18 +185,14 @@ Note, when you have the derivatives at y instead of 0, @item time(0) Return the current (wallclock) time in seconds. -@item root(expr, max) -Find an input value for which the function represented by @var{expr} -with argument @var{ld(0)} is 0 in the interval 0..@var{max}. +@item trunc(expr) +Round the value of expression @var{expr} towards zero to the nearest +integer. For example, "trunc(-1.5)" is "-1.0". -The expression in @var{expr} must denote a continuous function or the -result is undefined. - -@var{ld(0)} is used to represent the function input value, which means -that the given expression will be evaluated multiple times with -various input values that the expression can access through -@code{ld(0)}. When the expression evaluates to 0 then the -corresponding input value will be returned. +@item while(cond, expr) +Evaluate expression @var{expr} while the expression @var{cond} is +non-zero, and returns the value of the last @var{expr} evaluation, or +NAN if @var{cond} was always false. @end table The following constants are available: From ff23b76899b289855bb5a7e074673f3e07e5a7cf Mon Sep 17 00:00:00 2001 From: Giorgio Vazzana Date: Wed, 30 Jan 2013 13:17:02 +0100 Subject: [PATCH 070/182] lavd/v4l2: add list_standards option Since the user is expected to choose the standard by name (with -standard option), add the possibility to list all the supported standards. Signed-off-by: Stefano Sabatini --- doc/indevs.texi | 2 ++ libavdevice/v4l2.c | 33 +++++++++++++++++++++++++++++++++ libavdevice/version.h | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index 621e1de978..82d500dff8 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -596,6 +596,8 @@ the device. Video4Linux2 devices usually support a limited set of @var{width}x@var{height} sizes and framerates. You can check which are supported using @command{-list_formats all} for Video4Linux2 devices. +Some devices, like TV cards, support one or more standards. It is possible +to list all the supported standards using @command{-list_standards all}. Some usage examples of the video4linux2 devices with ffmpeg and ffplay: diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 5f0102746d..76b6d64717 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -116,6 +116,7 @@ struct video_data { int channel; char *pixel_format; /**< Set by a private option. */ int list_format; /**< Set by a private option. */ + int list_standard; /**< Set by a private option. */ char *framerate; /**< Set by a private option. */ }; @@ -381,6 +382,30 @@ static void list_formats(AVFormatContext *ctx, int fd, int type) } } +static void list_standards(AVFormatContext *ctx) +{ + int ret; + struct video_data *s = ctx->priv_data; + struct v4l2_standard standard; + + if (s->std_id == 0) + return; + + for (standard.index = 0; ; standard.index++) { + ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); + if (ret < 0) { + if (errno == EINVAL) + break; + else { + av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMSTD): %s\n", strerror(errno)); + return; + } + } + av_log(ctx, AV_LOG_INFO, "%2d, %16llx, %s\n", + standard.index, standard.id, standard.name); + } +} + static int mmap_init(AVFormatContext *ctx) { int i, res; @@ -824,6 +849,11 @@ static int v4l2_read_header(AVFormatContext *s1) return AVERROR_EXIT; } + if (s->list_standard) { + list_standards(s1); + return AVERROR_EXIT; + } + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ if (s->pixel_format) { @@ -952,6 +982,9 @@ static const AVOption options[] = { { "raw", "show only non-compressed formats", OFFSET(list_format), AV_OPT_TYPE_CONST, {.i64 = V4L_RAWFORMATS }, 0, INT_MAX, DEC, "list_formats" }, { "compressed", "show only compressed formats", OFFSET(list_format), AV_OPT_TYPE_CONST, {.i64 = V4L_COMPFORMATS }, 0, INT_MAX, DEC, "list_formats" }, + { "list_standards", "list supported standards and exit", OFFSET(list_standard), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, DEC, "list_standards" }, + { "all", "show all supported standards", OFFSET(list_standard), AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, DEC, "list_standards" }, + { "timestamps", "set type of timestamps for grabbed frames", OFFSET(ts_mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, DEC, "timestamps" }, { "ts", "set type of timestamps for grabbed frames", OFFSET(ts_mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, DEC, "timestamps" }, { "default", "use timestamps from the kernel", OFFSET(ts_mode), AV_OPT_TYPE_CONST, {.i64 = V4L_TS_DEFAULT }, 0, 2, DEC, "timestamps" }, diff --git a/libavdevice/version.h b/libavdevice/version.h index 5eed4f5e1a..9e0c0ae940 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -29,7 +29,7 @@ #define LIBAVDEVICE_VERSION_MAJOR 54 #define LIBAVDEVICE_VERSION_MINOR 3 -#define LIBAVDEVICE_VERSION_MICRO 102 +#define LIBAVDEVICE_VERSION_MICRO 103 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ LIBAVDEVICE_VERSION_MINOR, \ From b70ea49ca32cbff8be5c6f85a94600bb5fcc8ac8 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 24 Jan 2013 17:20:05 +0000 Subject: [PATCH 071/182] Port biquads filters from SoX Adds allpass, bass, bandpass, bandreject, biquad, equalizer, highpass, lowpass and treble filter. Signed-off-by: Paul B Mahol --- Changelog | 2 + doc/filters.texi | 268 ++++++++++++++++++ libavfilter/Makefile | 9 + libavfilter/af_biquads.c | 599 +++++++++++++++++++++++++++++++++++++++ libavfilter/allfilters.c | 9 + libavfilter/version.h | 4 +- 6 files changed, 889 insertions(+), 2 deletions(-) create mode 100644 libavfilter/af_biquads.c diff --git a/Changelog b/Changelog index c509c4cf68..01bb42ecc7 100644 --- a/Changelog +++ b/Changelog @@ -10,6 +10,8 @@ version : - EVRC decoder - audio fade filter - filtering audio with unknown channel layout +- allpass, bass, bandpass, bandreject, biquad, equalizer, highpass, lowpass + and treble audio filter version 1.1: diff --git a/doc/filters.texi b/doc/filters.texi index 21e2cff680..401be93040 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -282,6 +282,274 @@ aconvert=u8:auto @end example @end itemize +@section allpass + +Apply a two-pole all-pass filter with central frequency (in Hz) +@var{frequency}, and filter-width @var{width}. +An all-pass filter changes the audio's frequency to phase relationship +without changing its frequency to amplitude relationship. + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set frequency in Hz. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item @var{h} (Hz) +@item @var{q} (Q-Factor) +@item @var{o} (octave) +@item @var{s} (slope) +@end table + +@item width, w +Specify the band-width of a filter in width_type units. +@end table + +@section highpass + +Apply a high-pass filter with 3dB point frequency. +The filter can be either single-pole, or double-pole (the default). +The filter roll off at 6dB per pole per octave (20dB per pole per decade). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set frequency in Hz. Default is 3000. + +@item poles, p +Set number of poles. Default is 2. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item @var{h} (Hz) +@item @var{q} (Q-Factor) +@item @var{o} (octave) +@item @var{s} (slope) +@end table + +@item width, w +Specify the band-width of a filter in width_type units. +Applies only to double-pole filter. +The default is 0.707q and gives a Butterworth response. +@end table + +@section lowpass + +Apply a low-pass filter with 3dB point frequency. +The filter can be either single-pole or double-pole (the default). +The filter roll off at 6dB per pole per octave (20dB per pole per decade). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set frequency in Hz. Default is 500. + +@item poles, p +Set number of poles. Default is 2. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item @var{h} (Hz) +@item @var{q} (Q-Factor) +@item @var{o} (octave) +@item @var{s} (slope) +@end table + +@item width, w +Specify the band-width of a filter in width_type units. +Applies only to double-pole filter. +The default is 0.707q and gives a Butterworth response. +@end table + +@section bass + +Boost or cut the bass (lower) frequencies of the audio using a two-pole +shelving filter with a response similar to that of a standard +hi-fi's tone-controls. This is also known as shelving equalisation (EQ). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item gain, g +Give the gain at 0 Hz. Its useful range is about -20 +(for a large cut) to +20 (for a large boost). +Beware of clipping when using a positive gain. + +@item frequency, f +Set the filter's central frequency and so can be used +to extend or reduce the frequency range to be boosted or cut. +The default value is @code{100} Hz. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item @var{h} (Hz) +@item @var{q} (Q-Factor) +@item @var{o} (octave) +@item @var{s} (slope) +@end table + +@item width, w +Determine how steep is the filter's shelf transition. +@end table + +@section treble + +Boost or cut treble (upper) frequencies of the audio using a two-pole +shelving filter with a response similar to that of a standard +hi-fi's tone-controls. This is also known as shelving equalisation (EQ). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item gain, g +Give the gain at whichever is the lower of ~22 kHz and the +Nyquist frequency. Its useful range is about -20 (for a large cut) +to +20 (for a large boost). Beware of clipping when using a positive gain. + +@item frequency, f +Set the filter's central frequency and so can be used +to extend or reduce the frequency range to be boosted or cut. +The default value is @code{3000} Hz. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item @var{h} (Hz) +@item @var{q} (Q-Factor) +@item @var{o} (octave) +@item @var{s} (slope) +@end table + +@item width, w +Determine how steep is the filter's shelf transition. +@end table + +@section bandpass + +Apply a two-pole Butterworth band-pass filter with central +frequency @var{frequency}, and (3dB-point) band-width width. +The @var{csg} option selects a constant skirt gain (peak gain = Q) +instead of the default: constant 0dB peak gain. +The filter roll off at 6dB per octave (20dB per decade). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set the filter's central frequency. Default is @code{3000}. + +@item csg +Constant skirt gain if set to 1. Defaults to 0. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item @var{h} (Hz) +@item @var{q} (Q-Factor) +@item @var{o} (octave) +@item @var{s} (slope) +@end table + +@item width, w +Specify the band-width of a filter in width_type units. +@end table + +@section bandreject + +Apply a two-pole Butterworth band-reject filter with central +frequency @var{frequency}, and (3dB-point) band-width @var{width}. +The filter roll off at 6dB per octave (20dB per decade). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set the filter's central frequency. Default is @code{3000}. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item @var{h} (Hz) +@item @var{q} (Q-Factor) +@item @var{o} (octave) +@item @var{s} (slope) +@end table + +@item width, w +Specify the band-width of a filter in width_type units. +@end table + +@section biquad + +Apply a biquad IIR filter with the given coefficients. +Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2} +are the numerator and denominator coefficients respectively. + +@section equalizer + +Apply a two-pole peaking equalisation (EQ) filter. With this +filter, the signal-level at and around a selected frequency can +be increased or decreased, whilst (unlike bandpass and bandreject +filters) that at all other frequencies is unchanged. + +In order to produce complex equalisation curves, this filter can +be given several times, each with a different central frequency. + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set the filter's central frequency in Hz. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item @var{h} (Hz) +@item @var{q} (Q-Factor) +@item @var{o} (octave) +@item @var{s} (slope) +@end table + +@item width, w +Specify the band-width of a filter in width_type units. + +@item gain, g +Set the required gain or attenuation in dB. +Beware of clipping when using a positive gain. +@end table + @section afade Apply fade-in/out effect to input audio. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 5835a7ed5e..938b183316 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -53,6 +53,7 @@ OBJS-$(CONFIG_SWSCALE) += lswsutils.o OBJS-$(CONFIG_ACONVERT_FILTER) += af_aconvert.o OBJS-$(CONFIG_AFADE_FILTER) += af_afade.o OBJS-$(CONFIG_AFORMAT_FILTER) += af_aformat.o +OBJS-$(CONFIG_ALLPASS_FILTER) += af_biquads.o OBJS-$(CONFIG_AMERGE_FILTER) += af_amerge.o OBJS-$(CONFIG_AMIX_FILTER) += af_amix.o OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o @@ -68,14 +69,22 @@ OBJS-$(CONFIG_ASPLIT_FILTER) += split.o OBJS-$(CONFIG_ASTREAMSYNC_FILTER) += af_astreamsync.o OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o OBJS-$(CONFIG_ATEMPO_FILTER) += af_atempo.o +OBJS-$(CONFIG_BANDPASS_FILTER) += af_biquads.o +OBJS-$(CONFIG_BANDREJECT_FILTER) += af_biquads.o +OBJS-$(CONFIG_BASS_FILTER) += af_biquads.o +OBJS-$(CONFIG_BIQUAD_FILTER) += af_biquads.o OBJS-$(CONFIG_CHANNELMAP_FILTER) += af_channelmap.o OBJS-$(CONFIG_CHANNELSPLIT_FILTER) += af_channelsplit.o OBJS-$(CONFIG_EARWAX_FILTER) += af_earwax.o OBJS-$(CONFIG_EBUR128_FILTER) += f_ebur128.o +OBJS-$(CONFIG_EQUALIZER_FILTER) += af_biquads.o +OBJS-$(CONFIG_HIGHPASS_FILTER) += af_biquads.o OBJS-$(CONFIG_JOIN_FILTER) += af_join.o +OBJS-$(CONFIG_LOWPASS_FILTER) += af_biquads.o OBJS-$(CONFIG_PAN_FILTER) += af_pan.o OBJS-$(CONFIG_RESAMPLE_FILTER) += af_resample.o OBJS-$(CONFIG_SILENCEDETECT_FILTER) += af_silencedetect.o +OBJS-$(CONFIG_TREBLE_FILTER) += af_biquads.o OBJS-$(CONFIG_VOLUME_FILTER) += af_volume.o OBJS-$(CONFIG_VOLUMEDETECT_FILTER) += af_volumedetect.o diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c new file mode 100644 index 0000000000..375e9d2525 --- /dev/null +++ b/libavfilter/af_biquads.c @@ -0,0 +1,599 @@ +/* + * Copyright (c) 2013 Paul B Mahol + * Copyright (c) 2006-2008 Rob Sykes + * + * 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 + */ + +/* + * 2-pole filters designed by Robert Bristow-Johnson + * see http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt + * + * 1-pole filters based on code (c) 2000 Chris Bagwell + * Algorithms: Recursive single pole low/high pass filter + * Reference: The Scientist and Engineer's Guide to Digital Signal Processing + * + * low-pass: output[N] = input[N] * A + output[N-1] * B + * X = exp(-2.0 * pi * Fc) + * A = 1 - X + * B = X + * Fc = cutoff freq / sample rate + * + * Mimics an RC low-pass filter: + * + * ---/\/\/\/\-----------> + * | + * --- C + * --- + * | + * | + * V + * + * high-pass: output[N] = A0 * input[N] + A1 * input[N-1] + B1 * output[N-1] + * X = exp(-2.0 * pi * Fc) + * A0 = (1 + X) / 2 + * A1 = -(1 + X) / 2 + * B1 = X + * Fc = cutoff freq / sample rate + * + * Mimics an RC high-pass filter: + * + * || C + * ----||---------> + * || | + * < + * > R + * < + * | + * V + */ + +#include "libavutil/opt.h" +#include "libavutil/avassert.h" +#include "audio.h" +#include "avfilter.h" +#include "internal.h" + +enum FilterType { + biquad, + equalizer, + bass, + treble, + band, + bandpass, + bandreject, + allpass, + highpass, + lowpass, +}; + +enum WidthType { + NONE, + HZ, + OCTAVE, + QFACTOR, + SLOPE, +}; + +typedef struct ChanCache { + double i1, i2; + double o1, o2; +} ChanCache; + +typedef struct { + const AVClass *class; + + enum FilterType filter_type; + enum WidthType width_type; + int poles; + int csg; + + double gain; + double frequency; + double width; + + double a0, a1, a2; + double b0, b1, b2; + + ChanCache *cache; + + void (*filter)(const void *ibuf, void *obuf, int len, + double *i1, double *i2, double *o1, double *o2, + double b0, double b1, double b2, double a1, double a2); +} BiquadsContext; + +static av_cold int init(AVFilterContext *ctx, const char *args) +{ + BiquadsContext *p = ctx->priv; + int ret; + + av_opt_set_defaults(p); + + if ((ret = av_set_options_string(p, args, "=", ":")) < 0) + return ret; + + if (p->filter_type != biquad) { + if (p->frequency <= 0 || p->width <= 0) { + av_log(ctx, AV_LOG_ERROR, "Invalid frequency %f and/or width %f <= 0\n", + p->frequency, p->width); + return AVERROR(EINVAL); + } + } + + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + AVFilterFormats *formats; + AVFilterChannelLayouts *layouts; + static const enum AVSampleFormat sample_fmts[] = { + AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_S32P, + AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_DBLP, + AV_SAMPLE_FMT_NONE + }; + + layouts = ff_all_channel_layouts(); + if (!layouts) + return AVERROR(ENOMEM); + ff_set_common_channel_layouts(ctx, layouts); + + formats = ff_make_format_list(sample_fmts); + if (!formats) + return AVERROR(ENOMEM); + ff_set_common_formats(ctx, formats); + + formats = ff_all_samplerates(); + if (!formats) + return AVERROR(ENOMEM); + ff_set_common_samplerates(ctx, formats); + + return 0; +} + +#define BIQUAD_FILTER(name, type, min, max) \ +static void biquad_## name (const void *input, void *output, int len, \ + double *in1, double *in2, \ + double *out1, double *out2, \ + double b0, double b1, double b2, \ + double a1, double a2) \ +{ \ + const type *ibuf = input; \ + type *obuf = output; \ + double i1 = *in1; \ + double i2 = *in2; \ + double o1 = *out1; \ + double o2 = *out2; \ + int i; \ + \ + for (i = 0; i < len; i++) { \ + double o0 = ibuf[i] * b0 + i1 * b1 + i2 * b2 - o1 * a1 - o2 * a2; \ + i2 = i1; \ + i1 = ibuf[i]; \ + o2 = o1; \ + o1 = o0; \ + if (o0 < min) { \ + av_log(NULL, AV_LOG_WARNING, "clipping\n"); \ + obuf[i] = min; \ + } else if (o0 > max) { \ + av_log(NULL, AV_LOG_WARNING, "clipping\n"); \ + obuf[i] = max; \ + } else { \ + obuf[i] = o0; \ + } \ + } \ + *in1 = i1; \ + *in2 = i2; \ + *out1 = o1; \ + *out2 = o2; \ +} + +BIQUAD_FILTER(s16, int16_t, INT16_MIN, INT16_MAX) +BIQUAD_FILTER(s32, int32_t, INT32_MIN, INT32_MAX) +BIQUAD_FILTER(flt, float, -1., 1.) +BIQUAD_FILTER(dbl, double, -1., 1.) + +static int config_output(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + BiquadsContext *p = ctx->priv; + AVFilterLink *inlink = ctx->inputs[0]; + double A = exp(p->gain / 40 * log(10.)); + double w0 = 2 * M_PI * p->frequency / inlink->sample_rate; + double alpha; + + if (w0 > M_PI) { + av_log(ctx, AV_LOG_ERROR, + "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n", + p->frequency, inlink->sample_rate); + return AVERROR(EINVAL); + } + + switch (p->width_type) { + case NONE: + alpha = 0.0; + break; + case HZ: + alpha = sin(w0) / (2 * p->frequency / p->width); + break; + case OCTAVE: + alpha = sin(w0) * sinh(log(2.) / 2 * p->width * w0 / sin(w0)); + break; + case QFACTOR: + alpha = sin(w0) / (2 * p->width); + break; + case SLOPE: + alpha = sin(w0) / 2 * sqrt((A + 1 / A) * (1 / p->width - 1) + 2); + break; + default: + av_assert0(0); + } + + switch (p->filter_type) { + case biquad: + break; + case equalizer: + p->a0 = 1 + alpha / A; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha / A; + p->b0 = 1 + alpha * A; + p->b1 = -2 * cos(w0); + p->b2 = 1 - alpha * A; + break; + case bass: + p->a0 = (A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha; + p->a1 = -2 * ((A - 1) + (A + 1) * cos(w0)); + p->a2 = (A + 1) + (A - 1) * cos(w0) - 2 * sqrt(A) * alpha; + p->b0 = A * ((A + 1) - (A - 1) * cos(w0) + 2 * sqrt(A) * alpha); + p->b1 = 2 * A * ((A - 1) - (A + 1) * cos(w0)); + p->b2 = A * ((A + 1) - (A - 1) * cos(w0) - 2 * sqrt(A) * alpha); + break; + case treble: + p->a0 = (A + 1) - (A - 1) * cos(w0) + 2 * sqrt(A) * alpha; + p->a1 = 2 * ((A - 1) - (A + 1) * cos(w0)); + p->a2 = (A + 1) - (A - 1) * cos(w0) - 2 * sqrt(A) * alpha; + p->b0 = A * ((A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha); + p->b1 =-2 * A * ((A - 1) + (A + 1) * cos(w0)); + p->b2 = A * ((A + 1) + (A - 1) * cos(w0) - 2 * sqrt(A) * alpha); + break; + case bandpass: + if (p->csg) { + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = sin(w0) / 2; + p->b1 = 0; + p->b2 = -sin(w0) / 2; + } else { + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = alpha; + p->b1 = 0; + p->b2 = -alpha; + } + break; + case bandreject: + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = 1; + p->b1 = -2 * cos(w0); + p->b2 = 1; + break; + case lowpass: + if (p->poles == 1) { + p->a0 = 1; + p->a1 = -exp(-w0); + p->a2 = 0; + p->b0 = 1 + p->a1; + p->b1 = 0; + p->b2 = 0; + } else { + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = (1 - cos(w0)) / 2; + p->b1 = 1 - cos(w0); + p->b2 = (1 - cos(w0)) / 2; + } + break; + case highpass: + if (p->poles == 1) { + p->a0 = 1; + p->a1 = -exp(-w0); + p->a2 = 0; + p->b0 = (1 - p->a1) / 2; + p->b1 = -p->b0; + p->b2 = 0; + } else { + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = (1 + cos(w0)) / 2; + p->b1 = -(1 + cos(w0)); + p->b2 = (1 + cos(w0)) / 2; + } + break; + case allpass: + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = 1 - alpha; + p->b1 = -2 * cos(w0); + p->b2 = 1 + alpha; + break; + default: + av_assert0(0); + } + + p->a1 /= p->a0; + p->a2 /= p->a0; + p->b0 /= p->a0; + p->b1 /= p->a0; + p->b2 /= p->a0; + + p->cache = av_realloc_f(p->cache, sizeof(ChanCache), inlink->channels); + if (!p->cache) + return AVERROR(ENOMEM); + + switch (inlink->format) { + case AV_SAMPLE_FMT_S16P: p->filter = biquad_s16; break; + case AV_SAMPLE_FMT_S32P: p->filter = biquad_s32; break; + case AV_SAMPLE_FMT_FLTP: p->filter = biquad_flt; break; + case AV_SAMPLE_FMT_DBLP: p->filter = biquad_dbl; break; + default: av_assert0(0); + } + + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf) +{ + BiquadsContext *p = inlink->dst->priv; + AVFilterLink *outlink = inlink->dst->outputs[0]; + AVFilterBufferRef *out_buf; + int nb_samples = buf->audio->nb_samples; + int ch; + + if (buf->perms & AV_PERM_WRITE) { + out_buf = buf; + } else { + out_buf = ff_get_audio_buffer(inlink, AV_PERM_WRITE, nb_samples); + if (!out_buf) + return AVERROR(ENOMEM); + out_buf->pts = buf->pts; + } + + for (ch = 0; ch < buf->audio->channels; ch++) + p->filter((const float *)buf->extended_data[ch], + (float *)out_buf->extended_data[ch], nb_samples, + &p->cache[ch].i1, &p->cache[ch].i2, + &p->cache[ch].o1, &p->cache[ch].o2, + p->b0, p->b1, p->b2, p->a1, p->a2); + + if (buf != out_buf) + avfilter_unref_buffer(buf); + + return ff_filter_frame(outlink, out_buf); +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + BiquadsContext *p = ctx->priv; + + av_freep(&p->cache); + av_opt_free(p); +} + +static const AVFilterPad inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .config_props = config_output, + }, + { NULL } +}; + +#define OFFSET(x) offsetof(BiquadsContext, x) +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +#define DEFINE_BIQUAD_FILTER(name_, description_) \ +AVFILTER_DEFINE_CLASS(name_); \ +static av_cold int name_##_init(AVFilterContext *ctx, const char *args) \ +{ \ + BiquadsContext *p = ctx->priv; \ + p->class = &name_##_class; \ + p->filter_type = name_; \ + return init(ctx, args); \ +} \ + \ +AVFilter avfilter_af_##name_ = { \ + .name = #name_, \ + .description = NULL_IF_CONFIG_SMALL(description_), \ + .priv_size = sizeof(BiquadsContext), \ + .init = name_##_init, \ + .uninit = uninit, \ + .query_formats = query_formats, \ + .inputs = inputs, \ + .outputs = outputs, \ + .priv_class = &name_##_class, \ +} + +#if CONFIG_EQUALIZER_FILTER +static const AVOption equalizer_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 999, FLAGS}, + {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 999, FLAGS}, + {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(equalizer, "Apply two-pole peaking equalization (EQ) filter."); +#endif /* CONFIG_EQUALIZER_FILTER */ +#if CONFIG_BASS_FILTER +static const AVOption bass_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS}, + {"w", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS}, + {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(bass, "Boost or cut lower frequencies."); +#endif /* CONFIG_BASS_FILTER */ +#if CONFIG_TREBLE_FILTER +static const AVOption treble_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS}, + {"w", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS}, + {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(treble, "Boost or cut upper frequencies."); +#endif /* CONFIG_TREBLE_FILTER */ +#if CONFIG_BANDPASS_FILTER +static const AVOption bandpass_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS}, + {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS}, + {"csg", "use constant skirt gain", OFFSET(csg), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(bandpass, "Apply a two-pole Butterworth band-pass filter."); +#endif /* CONFIG_BANDPASS_FILTER */ +#if CONFIG_BANDREJECT_FILTER +static const AVOption bandreject_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS}, + {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(bandreject, "Apply a two-pole Butterworth band-reject filter."); +#endif /* CONFIG_BANDREJECT_FILTER */ +#if CONFIG_LOWPASS_FILTER +static const AVOption lowpass_options[] = { + {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS}, + {"f", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS}, + {"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS}, + {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS}, + {"p", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(lowpass, "Apply a low-pass filter with 3dB point frequency."); +#endif /* CONFIG_LOWPASS_FILTER */ +#if CONFIG_HIGHPASS_FILTER +static const AVOption highpass_options[] = { + {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"f", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS}, + {"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS}, + {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS}, + {"p", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(highpass, "Apply a high-pass filter with 3dB point frequency."); +#endif /* CONFIG_HIGHPASS_FILTER */ +#if CONFIG_ALLPASS_FILTER +static const AVOption allpass_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=HZ}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS}, + {"w", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(allpass, "Apply a two-pole all-pass filter."); +#endif /* CONFIG_ALLPASS_FILTER */ +#if CONFIG_BIQUAD_FILTER +static const AVOption biquad_options[] = { + {"a0", NULL, OFFSET(a0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {"a1", NULL, OFFSET(a1), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {"a2", NULL, OFFSET(a2), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {"b0", NULL, OFFSET(b0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {"b1", NULL, OFFSET(b1), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {"b2", NULL, OFFSET(b2), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(biquad, "Apply a biquad IIR filter with the given coefficients."); +#endif /* CONFIG_BIQUAD_FILTER */ diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 24df56193a..47158f9737 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -47,6 +47,7 @@ void avfilter_register_all(void) REGISTER_FILTER(ACONVERT, aconvert, af); REGISTER_FILTER(AFADE, afade, af); REGISTER_FILTER(AFORMAT, aformat, af); + REGISTER_FILTER(ALLPASS, allpass, af); REGISTER_FILTER(AMERGE, amerge, af); REGISTER_FILTER(AMIX, amix, af); REGISTER_FILTER(ANULL, anull, af); @@ -62,14 +63,22 @@ void avfilter_register_all(void) REGISTER_FILTER(ASTREAMSYNC, astreamsync, af); REGISTER_FILTER(ASYNCTS, asyncts, af); REGISTER_FILTER(ATEMPO, atempo, af); + REGISTER_FILTER(BANDPASS, bandpass, af); + REGISTER_FILTER(BANDREJECT, bandreject, af); + REGISTER_FILTER(BASS, bass, af); + REGISTER_FILTER(BIQUAD, biquad, af); REGISTER_FILTER(CHANNELMAP, channelmap, af); REGISTER_FILTER(CHANNELSPLIT, channelsplit, af); REGISTER_FILTER(EARWAX, earwax, af); REGISTER_FILTER(EBUR128, ebur128, af); + REGISTER_FILTER(EQUALIZER, equalizer, af); + REGISTER_FILTER(HIGHPASS, highpass, af); REGISTER_FILTER(JOIN, join, af); + REGISTER_FILTER(LOWPASS, lowpass, af); REGISTER_FILTER(PAN, pan, af); REGISTER_FILTER(RESAMPLE, resample, af); REGISTER_FILTER(SILENCEDETECT, silencedetect, af); + REGISTER_FILTER(TREBLE, treble, af); REGISTER_FILTER(VOLUME, volume, af); REGISTER_FILTER(VOLUMEDETECT, volumedetect, af); diff --git a/libavfilter/version.h b/libavfilter/version.h index d73fd3bba6..b6f7992e11 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -29,8 +29,8 @@ #include "libavutil/avutil.h" #define LIBAVFILTER_VERSION_MAJOR 3 -#define LIBAVFILTER_VERSION_MINOR 34 -#define LIBAVFILTER_VERSION_MICRO 101 +#define LIBAVFILTER_VERSION_MINOR 35 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ From 402ea625ab7be2fed10c8728029ffbe1ff4bf2d7 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 31 Jan 2013 13:16:32 +0000 Subject: [PATCH 072/182] lavfi/biquads: remove pointless casts Signed-off-by: Paul B Mahol --- libavfilter/af_biquads.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c index 375e9d2525..123d7a2eee 100644 --- a/libavfilter/af_biquads.c +++ b/libavfilter/af_biquads.c @@ -382,11 +382,11 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf) } for (ch = 0; ch < buf->audio->channels; ch++) - p->filter((const float *)buf->extended_data[ch], - (float *)out_buf->extended_data[ch], nb_samples, - &p->cache[ch].i1, &p->cache[ch].i2, - &p->cache[ch].o1, &p->cache[ch].o2, - p->b0, p->b1, p->b2, p->a1, p->a2); + p->filter(buf->extended_data[ch], + out_buf->extended_data[ch], nb_samples, + &p->cache[ch].i1, &p->cache[ch].i2, + &p->cache[ch].o1, &p->cache[ch].o2, + p->b0, p->b1, p->b2, p->a1, p->a2); if (buf != out_buf) avfilter_unref_buffer(buf); From 514216d8a928cf80980ca8dc5daea46e9d41cad9 Mon Sep 17 00:00:00 2001 From: Giorgio Vazzana Date: Wed, 30 Jan 2013 15:08:04 +0100 Subject: [PATCH 073/182] lavd/v4l2: read the correct time per frame from devices that support a standard Generally speaking, there are two types of v4l2 devices [1]: 1) devices that support a standard, like PAL or NTFS (tv cards, for example). For this class of devices the framerate is fixed by the standard (for example PAL uses 25 fps) and the v4l2 driver cannot usually negotiate a different framerate (unless it can skip frames on the driver side, to save I/O bandwidth). 2) devices for which the notion of standard does not make sense (webcams, for example). For these devices it is usually possibile to request a desidered framerate. In either case, the desidered frame rate can be requested when the VIDIOC_G_PARM ioctl returns the V4L2_CAP_TIMEPERFRAME flag in the capability field. Currently the code does not check for V4L2_CAP_TIMEPERFRAME and supports only the second category of devices, returning a time per frame of 0/0 for devices in the first group that do not permit to negotiate the framerate. This patch adds support to read the correct framerate in all cases. [1] http://linuxtv.org/downloads/v4l-dvb-apis/standard.html Signed-off-by: Stefano Sabatini --- libavdevice/v4l2.c | 124 +++++++++++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 48 deletions(-) diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 76b6d64717..2e4b395505 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -683,12 +683,10 @@ static int v4l2_set_parameters(AVFormatContext *s1) struct video_data *s = s1->priv_data; struct v4l2_standard standard = { 0 }; struct v4l2_streamparm streamparm = { 0 }; - struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; + struct v4l2_fract *tpf; AVRational framerate_q = { 0 }; int i, ret; - 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, "Could not parse framerate '%s'.\n", @@ -697,57 +695,87 @@ static int v4l2_set_parameters(AVFormatContext *s1) } if (s->standard) { - av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n", - s->standard); - /* set tv standard */ - for(i=0;;i++) { - standard.index = i; - ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); - if (ret < 0 || !av_strcasecmp(standard.name, s->standard)) - break; - } - if (ret < 0) { - av_log(s1, AV_LOG_ERROR, "Unknown standard '%s'\n", s->standard); - return ret; - } + if (s->std_id) { + av_log(s1, AV_LOG_DEBUG, "Setting standard: %s\n", s->standard); + /* set tv standard */ + for (i = 0; ; i++) { + standard.index = i; + ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); + if (ret < 0 || !av_strcasecmp(standard.name, s->standard)) + break; + } + if (ret < 0) { + ret = errno; + av_log(s1, AV_LOG_ERROR, "Unknown or unsupported standard '%s'\n", s->standard); + return AVERROR(ret); + } - av_log(s1, AV_LOG_DEBUG, - "The V4L2 driver set standard: %s, id: %"PRIu64"\n", - s->standard, (uint64_t)standard.id); - if (v4l2_ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) { - av_log(s1, AV_LOG_ERROR, - "The V4L2 driver ioctl set standard(%s) failed\n", - s->standard); - return AVERROR(EIO); + if (v4l2_ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) { + ret = errno; + av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_S_STD): %s\n", strerror(errno)); + return AVERROR(ret); + } + } else { + av_log(s1, AV_LOG_WARNING, + "This device does not support any standard\n"); } } - if (framerate_q.num && framerate_q.den) { - av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", - framerate_q.den, framerate_q.num); - tpf->numerator = framerate_q.den; - tpf->denominator = framerate_q.num; - - if (v4l2_ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) { - av_log(s1, AV_LOG_ERROR, - "ioctl set time per frame(%d/%d) failed\n", - framerate_q.den, framerate_q.num); - return AVERROR(EIO); - } - - 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", - framerate_q.den, framerate_q.num, - tpf->numerator, tpf->denominator); + /* get standard */ + if (v4l2_ioctl(s->fd, VIDIOC_G_STD, &s->std_id) == 0) { + tpf = &standard.frameperiod; + for (i = 0; ; i++) { + standard.index = i; + ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); + if (ret < 0) { + ret = errno; + av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMSTD): %s\n", strerror(errno)); + return AVERROR(ret); + } + if (standard.id == s->std_id) { + av_log(s1, AV_LOG_DEBUG, + "Current standard: %s, id: %"PRIu64", frameperiod: %d/%d\n", + standard.name, (uint64_t)standard.id, tpf->numerator, tpf->denominator); + break; + } } } else { - if (v4l2_ioctl(s->fd, VIDIOC_G_PARM, &streamparm) != 0) { - av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", - strerror(errno)); - return AVERROR(errno); + tpf = &streamparm.parm.capture.timeperframe; + } + + streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (v4l2_ioctl(s->fd, VIDIOC_G_PARM, &streamparm) < 0) { + ret = errno; + av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", strerror(errno)); + return AVERROR(ret); + } + + if (framerate_q.num && framerate_q.den) { + if (streamparm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) { + tpf = &streamparm.parm.capture.timeperframe; + + av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", + framerate_q.den, framerate_q.num); + tpf->numerator = framerate_q.den; + tpf->denominator = framerate_q.num; + + if (v4l2_ioctl(s->fd, VIDIOC_S_PARM, &streamparm) < 0) { + ret = errno; + av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_S_PARM): %s\n", strerror(errno)); + return AVERROR(ret); + } + + 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", + framerate_q.den, framerate_q.num, + tpf->numerator, tpf->denominator); + } + } else { + av_log(s1, AV_LOG_WARNING, + "The driver does not allow to change time per frame\n"); } } s1->streams[0]->avg_frame_rate.num = tpf->denominator; From a842dc632ecaee437bac10e37c9d9d234089517d Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 31 Jan 2013 12:53:50 +0100 Subject: [PATCH 074/182] doc/indevs: apply misc fixes to the v4l2 documentation Reviewed-by: Giorgio Vazzana --- doc/indevs.texi | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index 82d500dff8..39204d80c0 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -583,10 +583,16 @@ command: ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav @end example -@section video4linux2 +@section video4linux2, v4l2 Video4Linux2 input video device. +"v4l2" can be used as alias for "video4linux2". + +If FFmpeg is built with v4l-utils support (by using the +@code{--enable-libv4l2} configure option), the device will always rely +on libv4l2. + The name of the device to grab is a file device node, usually Linux systems tend to automatically create such nodes when the device (e.g. an USB webcam) is plugged into the system, and has a name of the @@ -599,8 +605,6 @@ supported using @command{-list_formats all} for Video4Linux2 devices. Some devices, like TV cards, support one or more standards. It is possible to list all the supported standards using @command{-list_standards all}. -Some usage examples of the video4linux2 devices with ffmpeg and ffplay: - The time base for the timestamps is 1 microsecond. Depending on the kernel version and configuration, the timestamps may be derived from the real time clock (origin at the Unix Epoch) or the monotonic clock (origin usually at @@ -608,8 +612,8 @@ boot time, unaffected by NTP or manual changes to the clock). The @option{-timestamps abs} or @option{-ts abs} option can be used to force conversion into the real time clock. -Note that if FFmpeg is build with v4l-utils support ("--enable-libv4l2" -option), it will always be used. +Some usage examples of the video4linux2 devices with @command{ffmpeg} +and @command{ffplay}: @example # Grab and show the input of a video4linux2 device. ffplay -f video4linux2 -framerate 30 -video_size hd720 /dev/video0 @@ -619,8 +623,7 @@ framerate and size as previously set. ffmpeg -f video4linux2 -input_format mjpeg -i /dev/video0 out.mpeg @end example -"v4l" and "v4l2" can be used as aliases for the respective "video4linux" and -"video4linux2". +For more information about Video4Linux, check @url{http://linuxtv.org/}. @section vfwcap From e47114d5459adfe6153dc56c9a35ad9983b33bce Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 31 Jan 2013 16:47:37 +0100 Subject: [PATCH 075/182] lavfi: increment max number of registered filters from 128 to 256 The total number of implemented filters is already over 128. --- libavfilter/avfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 4759d13c5f..7c0bee68f4 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -391,7 +391,7 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha return AVERROR(ENOSYS); } -#define MAX_REGISTERED_AVFILTERS_NB 128 +#define MAX_REGISTERED_AVFILTERS_NB 256 static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; From 22fad4e2b8c7a270090f284bb13faf6089e73043 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 31 Jan 2013 16:18:50 +0000 Subject: [PATCH 076/182] doc/filters: fix afade cuve types listing Signed-off-by: Paul B Mahol --- doc/filters.texi | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 401be93040..3e9babbd68 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -589,26 +589,16 @@ If set this option is used instead of @var{nb_samples} one. @item curve Set cuve for fade transition. @table @option -@item @var{triangular, linear slope (default)} -@code{tri} -@item @var{quarter of sine wave} -@code{qsin} -@item @var{half of sine wave} -@code{esin} -@item @var{exponential sine wave} -@code{hsin} -@item @var{logarithmic} -@code{log} -@item @var{inverted parabola} -@code{par} -@item @var{quadratic} -@code{qua} -@item @var{cubic} -@code{cub} -@item @var{square root} -@code{squ} -@item @var{cubic root} -@code{cbr} +@item @var{tri} (triangular, linear slope (default)) +@item @var{qsin} (quarter of sine wave) +@item @var{hsin} (half of sine wave) +@item @var{esin} (exponential sine wave) +@item @var{log} (logarithmic) +@item @var{par} (inverted parabola) +@item @var{qua} (quadratic) +@item @var{cub} (cubic) +@item @var{squ} (square root) +@item @var{cbr} (cubic root) @end table @end table From 7e0fc1a24fa6fb773725bad8085ea4790ba9c5dc Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 19 Jan 2013 01:34:27 +0100 Subject: [PATCH 077/182] CREDITS: redirect to Git log, remove current outdated content All the removed names are already mentioned in the commit log, or are listed as copyright holders in the contributed files. Amongst the removed names, the following ones were not listed in the commit log: Mario Brito (Xan DPCM decoder) Brian Foley (DSP utils optimizations) Vladimir Gneushev (lavf/lavc) Juan J. Sierralta (H.263) Ewald Snel (qdm2, cinepak) Lionel Ulmer (DSP utils optimizations) --- CREDITS | 59 +++++---------------------------------------------------- 1 file changed, 5 insertions(+), 54 deletions(-) diff --git a/CREDITS b/CREDITS index 1d0666b6df..e29f0b853c 100644 --- a/CREDITS +++ b/CREDITS @@ -1,55 +1,6 @@ -This file contains the names of some of the people who have contributed to -FFmpeg. The names are sorted alphabetically by last name. As this file is -currently quite outdated and git serves as a much better tool for determining -authorship, it remains here for historical reasons only. +See the Git history of the project (git://source.ffmpeg.org/ffmpeg) to +get the names of people who have contributed to FFmpeg. -Dénes Balatoni -Michel Bardiaux -Fabrice Bellard -Patrice Bensoussan -Alex Beregszaszi -BERO -Thilo Borgmann -Mario Brito -Ronald Bultje -Alex Converse -Maarten Daniels -Reimar Doeffinger -Tim Ferguson -Brian Foley -Arpad Gereoffy -Philip Gladstone -Vladimir Gneushev -Roine Gustafsson -David Hammerton -Wolfgang Hesseler -Marc Hoffman -Falk Hueffner -Aurélien Jacobs -Steven Johnson -Zdenek Kabelac -Robin Kay -Todd Kirby -Nick Kurshev -Benjamin Larsson -Loïc Le Loarer -Daniel Maas -Mike Melanson -Loren Merritt -Jeff Muizelaar -Michael Niedermayer -François Revol -Peter Ross -Måns Rullgård -Stefano Sabatini -Roman Shaposhnik -Oded Shimon -Dieter Shirley -Konstantin Shishkov -Juan J. Sierralta -Ewald Snel -Sascha Sommer -Leon van Stuivenberg -Roberto Togni -Lionel Ulmer -Reynaldo Verdejo +To check the log, you can type the command "git log" in the FFmpeg +source directory, or browse the online repository at +http://source.ffmpeg.org. From 6560625f0aeca470ac936542fcc24ed2da8eff5e Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 31 Jan 2013 14:24:08 +0100 Subject: [PATCH 078/182] lavfi/bufferqueue: add ff_bufqueue_is_full(). --- libavfilter/bufferqueue.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavfilter/bufferqueue.h b/libavfilter/bufferqueue.h index a27fb86112..34c4c0f08b 100644 --- a/libavfilter/bufferqueue.h +++ b/libavfilter/bufferqueue.h @@ -54,6 +54,14 @@ struct FFBufQueue { #define BUCKET(i) queue->queue[(queue->head + (i)) % FF_BUFQUEUE_SIZE] +/** + * Test if a buffer queue is full. + */ +static inline int ff_bufqueue_is_full(struct FFBufQueue *queue) +{ + return queue->available == FF_BUFQUEUE_SIZE; +} + /** * Add a buffer to the queue. * @@ -63,7 +71,7 @@ struct FFBufQueue { static inline void ff_bufqueue_add(void *log, struct FFBufQueue *queue, AVFilterBufferRef *buf) { - if (queue->available == FF_BUFQUEUE_SIZE) { + if (ff_bufqueue_is_full(queue)) { av_log(log, AV_LOG_WARNING, "Buffer queue overflow, dropping.\n"); avfilter_unref_buffer(BUCKET(--queue->available)); } From ae14887ee7f2a2c02957845b84afd711cf702b9b Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 31 Jan 2013 14:24:57 +0100 Subject: [PATCH 079/182] lavfi/af_amerge: check for buffer queue overflows. Without that test, ff_bufqueue_add silently discards the oldest buffer, that leaves in[i].nb_samples inconsistent, and causes later a segfault. --- libavfilter/af_amerge.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c index 44b71e4acb..e55268259e 100644 --- a/libavfilter/af_amerge.c +++ b/libavfilter/af_amerge.c @@ -231,6 +231,11 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples) if (inlink == ctx->inputs[input_number]) break; av_assert1(input_number < am->nb_inputs); + if (ff_bufqueue_is_full(&am->in[input_number].queue)) { + av_log(ctx, AV_LOG_ERROR, "Buffer queue overflow\n"); + avfilter_unref_buffer(insamples); + return AVERROR(ENOMEM); + } ff_bufqueue_add(ctx, &am->in[input_number].queue, insamples); am->in[input_number].nb_samples += insamples->audio->nb_samples; nb_samples = am->in[0].nb_samples; From dcce43340f454626c0462ec18fa911dc8280a8c2 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 31 Jan 2013 14:26:15 +0100 Subject: [PATCH 080/182] lavfi/af_amerge: set outbuf->audio->channels. The value is lost because of avfilter_copy_buffer_ref_props(). Fix trac ticket #2217. --- libavfilter/af_amerge.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c index e55268259e..f67a7a8c1b 100644 --- a/libavfilter/af_amerge.c +++ b/libavfilter/af_amerge.c @@ -260,6 +260,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples) outbuf->audio->nb_samples = nb_samples; outbuf->audio->channel_layout = outlink->channel_layout; + outbuf->audio->channels = outlink->channels; while (nb_samples) { ns = nb_samples; From d2ccab5f8a5f9121200b85c2fd8ef35916b1bf62 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 31 Jan 2013 14:49:43 +0100 Subject: [PATCH 081/182] lavfi/buffersrc: forward filter_frame errors. Note: The ret variable was unused. --- libavfilter/buffersrc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index 074d43a674..3fdf8d3fe3 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -384,7 +384,6 @@ static int request_frame(AVFilterLink *link) { BufferSourceContext *c = link->src->priv; AVFilterBufferRef *buf; - int ret = 0; if (!av_fifo_size(c->fifo)) { if (c->eof) @@ -394,9 +393,7 @@ static int request_frame(AVFilterLink *link) } av_fifo_generic_read(c->fifo, &buf, sizeof(buf), NULL); - ff_filter_frame(link, buf); - - return ret; + return ff_filter_frame(link, buf); } static int poll_frame(AVFilterLink *link) From 349e7f423f19be98cd8b6f808e3c5174054ebedc Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 31 Jan 2013 16:21:47 +0100 Subject: [PATCH 082/182] doc/indevs: itemize examples for the v4l2 device --- doc/indevs.texi | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index 39204d80c0..00996461a2 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -612,16 +612,22 @@ boot time, unaffected by NTP or manual changes to the clock). The @option{-timestamps abs} or @option{-ts abs} option can be used to force conversion into the real time clock. -Some usage examples of the video4linux2 devices with @command{ffmpeg} +Some usage examples of the video4linux2 device with @command{ffmpeg} and @command{ffplay}: +@itemize +@item +Grab and show the input of a video4linux2 device: @example -# Grab and show the input of a video4linux2 device. ffplay -f video4linux2 -framerate 30 -video_size hd720 /dev/video0 +@end example -# Grab and record the input of a video4linux2 device, leave the -framerate and size as previously set. +@item +Grab and record the input of a video4linux2 device, leave the +framerate and size as previously set: +@example ffmpeg -f video4linux2 -input_format mjpeg -i /dev/video0 out.mpeg @end example +@end itemize For more information about Video4Linux, check @url{http://linuxtv.org/}. From b999774f0b11a402ad6b346fc8418e8bde7140d4 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 31 Jan 2013 16:38:06 +0100 Subject: [PATCH 083/182] doc/indevs: document v4l2 options Reviewed-By: Giorgio Vazzana --- doc/indevs.texi | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/doc/indevs.texi b/doc/indevs.texi index 00996461a2..9deb214eb2 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -631,6 +631,75 @@ ffmpeg -f video4linux2 -input_format mjpeg -i /dev/video0 out.mpeg For more information about Video4Linux, check @url{http://linuxtv.org/}. +@subsection Options + +@table @option +@item standard +Set the standard. Must be the name of a supported standard. To get a +list of the supported standards, use the @option{list_standards} +option. + +@item channel +Set the input channel number. Default to 0. + +@item video_size +Set the video frame size. The argument must be a string in the form +@var{WIDTH}x@var{HEIGHT} or a valid size abbreviation. + +@item pixel_format +Select the pixel format (only valid for raw video input). + +@item input_format +Set the preferred pixel format (for raw video) or a codec name. +This option allows to select the input format, when several are +available. + +@item framerate +Set the preferred video framerate. + +@item list_formats +List available formats (supported pixel formats, codecs, and frame +sizes) and exit. + +Available values are: +@table @samp +@item all +Show all available (compressed and non-compressed) formats. + +@item raw +Show only raw video (non-compressed) formats. + +@item compressed +Show only compressed formats. +@end table + +@item list_standards +List supported standards and exit. + +Available values are: +@table @samp +@item all +Show all supported standards. +@end table + +@item timestamps, ts +Set type of timestamps for grabbed frames. + +Available values are: +@table @samp +@item default +Use timestamps from the kernel. + +@item abs +Use absolute timestamps (wall clock). + +@item mono2abs +Force conversion from monotonic to absolute timestamps +@end table + +Default value is @code{default}. +@end table + @section vfwcap VfW (Video for Windows) capture input device. From 131fac1c12edacec254fcaed70dbf50f36603b3c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 31 Jan 2013 23:20:15 +0100 Subject: [PATCH 084/182] vc1dec: fix block_off Fixes corruption of motion_val Signed-off-by: Michael Niedermayer --- libavcodec/vc1dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index e056ffb525..01fe1ec848 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -5672,7 +5672,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, continue; } v->second_field = 1; - v->blocks_off = s->mb_width * s->mb_height << 1; + v->blocks_off = s->b8_stride * (s->mb_height&~1); v->mb_off = s->mb_stride * s->mb_height >> 1; } else { v->second_field = 0; From c58c67398d03ba7386feb179695165f94ca2b6f2 Mon Sep 17 00:00:00 2001 From: Michael Bradshaw Date: Thu, 31 Jan 2013 07:24:11 -0700 Subject: [PATCH 085/182] libopenjpegenc: add support for pix fmt gbrp (8-16 bit) Signed-off-by: Michael Bradshaw --- libavcodec/libopenjpegenc.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c index 13e8ef914c..51a60165eb 100644 --- a/libavcodec/libopenjpegenc.c +++ b/libavcodec/libopenjpegenc.c @@ -100,6 +100,12 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p case AV_PIX_FMT_RGBA: case AV_PIX_FMT_RGB48: case AV_PIX_FMT_RGBA64: + case AV_PIX_FMT_GBR24P: + case AV_PIX_FMT_GBRP9: + case AV_PIX_FMT_GBRP10: + case AV_PIX_FMT_GBRP12: + case AV_PIX_FMT_GBRP14: + case AV_PIX_FMT_GBRP16: color_space = CLRSPC_SRGB; break; case AV_PIX_FMT_YUV410P: @@ -351,6 +357,7 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, opj_cio_t *stream; int cpyresult = 0; int ret, len; + AVFrame gbrframe; // x0, y0 is the top left corner of the image // x1, y1 is the width, height of the reference grid @@ -369,6 +376,30 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, case AV_PIX_FMT_RGBA64: cpyresult = libopenjpeg_copy_packed16(avctx, frame, image); break; + case AV_PIX_FMT_GBR24P: + gbrframe = *frame; + gbrframe.data[0] = frame->data[2]; // swap to be rgb + gbrframe.data[1] = frame->data[0]; + gbrframe.data[2] = frame->data[1]; + gbrframe.linesize[0] = frame->linesize[2]; + gbrframe.linesize[1] = frame->linesize[0]; + gbrframe.linesize[2] = frame->linesize[1]; + cpyresult = libopenjpeg_copy_unpacked8(avctx, &gbrframe, image); + break; + case AV_PIX_FMT_GBRP9: + case AV_PIX_FMT_GBRP10: + case AV_PIX_FMT_GBRP12: + case AV_PIX_FMT_GBRP14: + case AV_PIX_FMT_GBRP16: + gbrframe = *frame; + gbrframe.data[0] = frame->data[2]; // swap to be rgb + gbrframe.data[1] = frame->data[0]; + gbrframe.data[2] = frame->data[1]; + gbrframe.linesize[0] = frame->linesize[2]; + gbrframe.linesize[1] = frame->linesize[0]; + gbrframe.linesize[2] = frame->linesize[1]; + cpyresult = libopenjpeg_copy_unpacked16(avctx, &gbrframe, image); + break; case AV_PIX_FMT_GRAY8: case AV_PIX_FMT_YUV410P: case AV_PIX_FMT_YUV411P: @@ -505,6 +536,8 @@ AVCodec ff_libopenjpeg_encoder = { .capabilities = 0, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64, + AV_PIX_FMT_GBR24P, + AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16, AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8A, AV_PIX_FMT_GRAY16, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA422P, From 28f36dce3e5c6be6b7f208362fca3531ed3cb50d Mon Sep 17 00:00:00 2001 From: Michael Bradshaw Date: Thu, 31 Jan 2013 16:03:58 -0700 Subject: [PATCH 086/182] libopenjpegenc: simplify switch statement Signed-off-by: Michael Bradshaw --- libavcodec/libopenjpegenc.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c index 51a60165eb..2bbbae902a 100644 --- a/libavcodec/libopenjpegenc.c +++ b/libavcodec/libopenjpegenc.c @@ -377,15 +377,6 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, cpyresult = libopenjpeg_copy_packed16(avctx, frame, image); break; case AV_PIX_FMT_GBR24P: - gbrframe = *frame; - gbrframe.data[0] = frame->data[2]; // swap to be rgb - gbrframe.data[1] = frame->data[0]; - gbrframe.data[2] = frame->data[1]; - gbrframe.linesize[0] = frame->linesize[2]; - gbrframe.linesize[1] = frame->linesize[0]; - gbrframe.linesize[2] = frame->linesize[1]; - cpyresult = libopenjpeg_copy_unpacked8(avctx, &gbrframe, image); - break; case AV_PIX_FMT_GBRP9: case AV_PIX_FMT_GBRP10: case AV_PIX_FMT_GBRP12: @@ -398,7 +389,11 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, gbrframe.linesize[0] = frame->linesize[2]; gbrframe.linesize[1] = frame->linesize[0]; gbrframe.linesize[2] = frame->linesize[1]; - cpyresult = libopenjpeg_copy_unpacked16(avctx, &gbrframe, image); + if (avctx->pix_fmt == AV_PIX_FMT_GBR24P) { + cpyresult = libopenjpeg_copy_unpacked8(avctx, &gbrframe, image); + } else { + cpyresult = libopenjpeg_copy_unpacked16(avctx, &gbrframe, image); + } break; case AV_PIX_FMT_GRAY8: case AV_PIX_FMT_YUV410P: From c6779c513117a347214a47f7bda0a3b0b93a5884 Mon Sep 17 00:00:00 2001 From: Sebastian Sandberg Date: Thu, 31 Jan 2013 18:04:21 +0100 Subject: [PATCH 087/182] vc1dec: fieldtx is only valid for interlaced frames the fieldtx_plane is not cleared for interlaced fields Signed-off-by: Michael Niedermayer --- libavcodec/vc1dec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 01fe1ec848..05307c1342 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -80,7 +80,7 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) { MpegEncContext *s = &v->s; int topleft_mb_pos, top_mb_pos; - int stride_y, fieldtx; + int stride_y, fieldtx = 0; int v_dist; /* The put pixels loop is always one MB row behind the decoding loop, @@ -93,7 +93,8 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) if (!s->first_slice_line) { if (s->mb_x) { topleft_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x - 1; - fieldtx = v->fieldtx_plane[topleft_mb_pos]; + if (v->fcm == ILACE_FRAME) + fieldtx = v->fieldtx_plane[topleft_mb_pos]; stride_y = s->linesize << fieldtx; v_dist = (16 - fieldtx) >> (fieldtx == 0); s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0], @@ -117,7 +118,8 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) } if (s->mb_x == s->mb_width - 1) { top_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x; - fieldtx = v->fieldtx_plane[top_mb_pos]; + if (v->fcm == ILACE_FRAME) + fieldtx = v->fieldtx_plane[top_mb_pos]; stride_y = s->linesize << fieldtx; v_dist = fieldtx ? 15 : 8; s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0], From 4789c25d83c4a90e8ef81d2cc05be6d2f12dfa68 Mon Sep 17 00:00:00 2001 From: Allan Kristensen Date: Fri, 21 Dec 2012 21:04:18 +0100 Subject: [PATCH 088/182] matroska: fixed missing S_DVBSUB subtitles --- libavformat/matroska.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/matroska.c b/libavformat/matroska.c index 394a62f9d3..519f881e89 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -66,6 +66,7 @@ const CodecTags ff_mkv_codec_tags[]={ {"S_ASS" , AV_CODEC_ID_SSA}, {"S_SSA" , AV_CODEC_ID_SSA}, {"S_VOBSUB" , AV_CODEC_ID_DVD_SUBTITLE}, + {"S_DVBSUB" , AV_CODEC_ID_DVB_SUBTITLE}, {"S_HDMV/PGS" , AV_CODEC_ID_HDMV_PGS_SUBTITLE}, {"V_DIRAC" , AV_CODEC_ID_DIRAC}, From 086566a557eedc0cf70851b95f1cd7d691d3e41f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 1 Feb 2013 03:56:51 +0100 Subject: [PATCH 089/182] dict: fix memleak Signed-off-by: Michael Niedermayer --- libavutil/dict.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/dict.c b/libavutil/dict.c index 23816e8f55..967c9e2fff 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -98,6 +98,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags if (!newval) return AVERROR(ENOMEM); av_strlcat(newval, oldval, len); + av_freep(&oldval); av_strlcat(newval, value, len); m->elems[m->count].value = newval; } else From cb30bf7f03ac1e2d8ae70e28cfe16beb9243604a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 31 Jan 2013 19:34:37 +0100 Subject: [PATCH 090/182] doc/developer: Add web links for all suggested licenses --- doc/developer.texi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index f24b4fe41c..7c14f97cb1 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -248,8 +248,11 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}: @enumerate @item - Contributions should be licensed under the LGPL 2.1, including an - "or any later version" clause, or the MIT license. GPL 2 including + Contributions should be licensed under the + @uref{http://www.gnu.org/licenses/lgpl-2.1.html, LGPL 2.1}, + including an "or any later version" clause, or the + @uref{http://mit-license.org/, MIT license}. + @uref{http://www.gnu.org/licenses/gpl-2.0.html, GPL 2} including an "or any later version" clause is also acceptable, but LGPL is preferred. @item From 8b0fda180e99bf64d485d3e1f1e3a13ee20d053a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 31 Jan 2013 19:37:08 +0100 Subject: [PATCH 091/182] doc/developer: Add ISC license to list of acceptable licenses --- doc/developer.texi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index 7c14f97cb1..3f2c24da6c 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -250,8 +250,10 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}: @item Contributions should be licensed under the @uref{http://www.gnu.org/licenses/lgpl-2.1.html, LGPL 2.1}, - including an "or any later version" clause, or the - @uref{http://mit-license.org/, MIT license}. + including an "or any later version" clause, or, if you prefer + a gift-style license, the + @uref{http://www.isc.org/software/license/, ISC} or + @uref{http://mit-license.org/, MIT} license. @uref{http://www.gnu.org/licenses/gpl-2.0.html, GPL 2} including an "or any later version" clause is also acceptable, but LGPL is preferred. From 8787847dc6b3e07020ca6f063d5e3fcbe2e93f0f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 31 Jan 2013 19:47:22 +0100 Subject: [PATCH 092/182] doc/developer: Drop obsolete MPlayer reference --- doc/developer.texi | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index 3f2c24da6c..a377ed1188 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -351,8 +351,6 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}: We think our rules are not too hard. If you have comments, contact us. -Note, some rules were borrowed from the MPlayer project. - @section Submitting patches First, read the @ref{Coding Rules} above if you did not yet, in particular From f2960097e42ddf9a356bab6547f87906f6999e0a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 31 Jan 2013 20:58:27 +0100 Subject: [PATCH 093/182] bink: fix a check for the first frame. Packet pts is a very unreliable indicator, use AVCodecContext.frame_number instead. --- libavcodec/bink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 7b81d052f3..3a74cf9d7f 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1200,7 +1200,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac if ((ret = bink_decode_plane(c, &gb, plane_idx, !!plane)) < 0) return ret; } else { - if ((ret = binkb_decode_plane(c, &gb, plane_idx, !pkt->pts, !!plane)) < 0) + if ((ret = binkb_decode_plane(c, &gb, plane_idx, + !avctx->frame_number, !!plane)) < 0) return ret; } if (get_bits_count(&gb) >= bits_count) From 1730ca2eca42974af0c29f38a0770997cba2f0da Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 31 Jan 2013 21:02:06 +0100 Subject: [PATCH 094/182] bink demuxer: check malloc return value --- libavformat/bink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/bink.c b/libavformat/bink.c index 5d3de14567..62c377dfff 100644 --- a/libavformat/bink.c +++ b/libavformat/bink.c @@ -116,6 +116,8 @@ static int read_header(AVFormatContext *s) vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = AV_CODEC_ID_BINKVIDEO; vst->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE); + if (!vst->codec->extradata) + return AVERROR(ENOMEM); vst->codec->extradata_size = 4; avio_read(pb, vst->codec->extradata, 4); From 9ec8971060a00f249f387a2baef949ec59de26a7 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 31 Jan 2013 21:07:34 +0100 Subject: [PATCH 095/182] bink demuxer: set framerate. --- libavformat/bink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/bink.c b/libavformat/bink.c index 62c377dfff..f093e7c3e2 100644 --- a/libavformat/bink.c +++ b/libavformat/bink.c @@ -112,6 +112,7 @@ static int read_header(AVFormatContext *s) return AVERROR(EIO); } avpriv_set_pts_info(vst, 64, fps_den, fps_num); + vst->avg_frame_rate = av_inv_q(vst->time_base); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = AV_CODEC_ID_BINKVIDEO; From 4eef2ed707444fd1fac2bd25cefae912a179762f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 1 Feb 2013 01:54:19 +0100 Subject: [PATCH 096/182] ppc: fmtconvert: Drop two unused variables. --- libavcodec/ppc/fmtconvert_altivec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/ppc/fmtconvert_altivec.c b/libavcodec/ppc/fmtconvert_altivec.c index 68e5e0079e..694e9306f0 100644 --- a/libavcodec/ppc/fmtconvert_altivec.c +++ b/libavcodec/ppc/fmtconvert_altivec.c @@ -92,8 +92,8 @@ static void float_to_int16_altivec(int16_t *dst, const float *src, long len) static void float_to_int16_stride_altivec(int16_t *dst, const float *src, long len, int stride) { - int i, j; - vector signed short d, s; + int i; + vector signed short d; for (i = 0; i < len - 7; i += 8) { d = float_to_int16_one_altivec(src + i); From 6c1a7d07eb41b4cf36e48ebb560fecd9504fd968 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 1 Feb 2013 10:27:45 +0100 Subject: [PATCH 097/182] Use proper "" quotes for local header #includes --- libavcodec/arm/videodsp_init_armv5te.c | 2 +- libavcodec/kbdwin.c | 2 +- libavformat/rtp.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/arm/videodsp_init_armv5te.c b/libavcodec/arm/videodsp_init_armv5te.c index a7b8b23119..5830f4b8cc 100644 --- a/libavcodec/arm/videodsp_init_armv5te.c +++ b/libavcodec/arm/videodsp_init_armv5te.c @@ -19,7 +19,7 @@ */ #include "libavutil/arm/cpu.h" -#include +#include "libavcodec/videodsp.h" #include "videodsp_arm.h" void ff_prefetch_arm(uint8_t *mem, ptrdiff_t stride, int h); diff --git a/libavcodec/kbdwin.c b/libavcodec/kbdwin.c index 3b590b38ef..1b7313d1dc 100644 --- a/libavcodec/kbdwin.c +++ b/libavcodec/kbdwin.c @@ -17,7 +17,7 @@ */ #include -#include +#include "libavutil/mathematics.h" #include "libavutil/attributes.h" #include "kbdwin.h" diff --git a/libavformat/rtp.c b/libavformat/rtp.c index e827c2e0ab..0a3c411f51 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include "libavutil/opt.h" #include "avformat.h" #include "rtp.h" From 76d90125cdc09a029f7fe87f1c272aaa1a8a808e Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 22 Jan 2013 01:39:37 +0100 Subject: [PATCH 098/182] vf_hqdn3d: x86: Add proper arch optimization initialization --- libavfilter/vf_hqdn3d.c | 25 ++++---------------- libavfilter/vf_hqdn3d.h | 37 ++++++++++++++++++++++++++++++ libavfilter/x86/Makefile | 1 + libavfilter/x86/vf_hqdn3d_init.c | 39 ++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 21 deletions(-) create mode 100644 libavfilter/vf_hqdn3d.h create mode 100644 libavfilter/x86/vf_hqdn3d_init.c diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c index 085900fbce..6161b5e6f4 100644 --- a/libavfilter/vf_hqdn3d.c +++ b/libavfilter/vf_hqdn3d.c @@ -26,6 +26,7 @@ * libmpcodecs/vf_hqdn3d.c. */ +#include "config.h" #include "libavutil/common.h" #include "libavutil/pixdesc.h" #include "libavutil/intreadwrite.h" @@ -33,21 +34,7 @@ #include "formats.h" #include "internal.h" #include "video.h" - -typedef struct { - int16_t *coefs[4]; - uint16_t *line; - uint16_t *frame_prev[3]; - double strength[4]; - int hsub, vsub; - int depth; - void (*denoise_row[17])(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); -} HQDN3DContext; - -void ff_hqdn3d_row_8_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); -void ff_hqdn3d_row_9_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); -void ff_hqdn3d_row_10_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); -void ff_hqdn3d_row_16_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); +#include "vf_hqdn3d.h" #define LUT_BITS (depth==16 ? 8 : 4) #define RIGHTSHIFT(a,b) (((a)+(((1<<(b))-1)>>1))>>(b)) @@ -312,12 +299,8 @@ static int config_input(AVFilterLink *inlink) return AVERROR(ENOMEM); } -#if HAVE_YASM - hqdn3d->denoise_row[ 8] = ff_hqdn3d_row_8_x86; - hqdn3d->denoise_row[ 9] = ff_hqdn3d_row_9_x86; - hqdn3d->denoise_row[10] = ff_hqdn3d_row_10_x86; - hqdn3d->denoise_row[16] = ff_hqdn3d_row_16_x86; -#endif + if (ARCH_X86) + ff_hqdn3d_init_x86(hqdn3d); return 0; } diff --git a/libavfilter/vf_hqdn3d.h b/libavfilter/vf_hqdn3d.h new file mode 100644 index 0000000000..7350f745c0 --- /dev/null +++ b/libavfilter/vf_hqdn3d.h @@ -0,0 +1,37 @@ +/* + * 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 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 Libav; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef AVFILTER_VF_HQDN3D_H +#define AVFILTER_VF_HQDN3D_H + +#include +#include + +typedef struct { + int16_t *coefs[4]; + uint16_t *line; + uint16_t *frame_prev[3]; + double strength[4]; + int hsub, vsub; + int depth; + void (*denoise_row[17])(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); +} HQDN3DContext; + +void ff_hqdn3d_init_x86(HQDN3DContext *hqdn3d); + +#endif /* AVFILTER_VF_HQDN3D_H */ diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile index 47569cf642..af5a9998b5 100644 --- a/libavfilter/x86/Makefile +++ b/libavfilter/x86/Makefile @@ -1,4 +1,5 @@ OBJS-$(CONFIG_GRADFUN_FILTER) += x86/gradfun.o +OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d_init.o OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume_init.o OBJS-$(CONFIG_YADIF_FILTER) += x86/yadif_init.o diff --git a/libavfilter/x86/vf_hqdn3d_init.c b/libavfilter/x86/vf_hqdn3d_init.c new file mode 100644 index 0000000000..2893a54c15 --- /dev/null +++ b/libavfilter/x86/vf_hqdn3d_init.c @@ -0,0 +1,39 @@ +/* + * 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 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 Libav; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include + +#include "libavutil/attributes.h" +#include "libavfilter/vf_hqdn3d.h" +#include "config.h" + +void ff_hqdn3d_row_8_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); +void ff_hqdn3d_row_9_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); +void ff_hqdn3d_row_10_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); +void ff_hqdn3d_row_16_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); + +av_cold void ff_hqdn3d_init_x86(HQDN3DContext *hqdn3d) +{ +#if HAVE_YASM + hqdn3d->denoise_row[ 8] = ff_hqdn3d_row_8_x86; + hqdn3d->denoise_row[ 9] = ff_hqdn3d_row_9_x86; + hqdn3d->denoise_row[10] = ff_hqdn3d_row_10_x86; + hqdn3d->denoise_row[16] = ff_hqdn3d_row_16_x86; +#endif +} From 99eedfc40086972987aa27df8b1259c8bf15b20c Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 1 Feb 2013 17:54:48 +0100 Subject: [PATCH 099/182] doc/muxers.texi: Fix mp3 picture attachment documentation. --- doc/muxers.texi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 965a4bb124..a5323bc6f7 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -727,10 +727,11 @@ Write an mp3 with an ID3v2.3 header and an ID3v1 footer: ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3 @end example -Attach a picture to an mp3: +To attach a picture to an mp3 file select both the audio and the picture stream +with @code{map}: @example -ffmpeg -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover" --metadata:s:v comment="Cover (Front)" out.mp3 +ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1 +-metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3 @end example @section ogg From b868275ddbec4e047f82c79ad323cd319636f84d Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 1 Feb 2013 18:12:54 +0100 Subject: [PATCH 100/182] doc/muxers: fix level for the segment options subsection Properly declare it like a @subsection, rather than as a @section. --- doc/muxers.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index a5323bc6f7..0aea87b4e7 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -645,7 +645,7 @@ of the generated segments. May not work with some combinations of muxers/codecs. It is set to @code{0} by default. @end table -@section Examples +@subsection Examples @itemize @item From 902fa77fd716260ec3de59b4df87a7870c81a4e1 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 1 Feb 2013 18:32:21 +0100 Subject: [PATCH 101/182] doc/filters: fix syntax and description for the lut* options --- doc/filters.texi | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 3e9babbd68..3334787fc7 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3272,10 +3272,14 @@ corresponding pixel component values. The @var{lut} filter requires either YUV or RGB pixel formats in input, and accepts the options: @table @option -@item @var{c0} (first pixel component) -@item @var{c1} (second pixel component) -@item @var{c2} (third pixel component) -@item @var{c3} (fourth pixel component, corresponds to the alpha component) +@item c0 +set first pixel component expression +@item c1 +set second pixel component expression +@item c2 +set third pixel component expression +@item c3 +set fourth pixel component expression, corresponds to the alpha component @end table The exact component associated to each option depends on the format in @@ -3284,19 +3288,27 @@ input. The @var{lutrgb} filter requires RGB pixel formats in input, and accepts the options: @table @option -@item @var{r} (red component) -@item @var{g} (green component) -@item @var{b} (blue component) -@item @var{a} (alpha component) +@item r +set red component expression +@item g +set green component expression +@item b +set blue component expression +@item a +alpha component expression @end table The @var{lutyuv} filter requires YUV pixel formats in input, and accepts the options: @table @option -@item @var{y} (Y/luminance component) -@item @var{u} (U/Cb component) -@item @var{v} (V/Cr component) -@item @var{a} (alpha component) +@item y +set Y/luminance component expression +@item u +set U/Cb component expression +@item v +set V/Cr component expression +@item a +set alpha component expression @end table The expressions can contain the following constants and functions: From 986540b65f6eb6d9fed40d7da9e58b9bbcee35ae Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 1 Feb 2013 18:35:15 +0100 Subject: [PATCH 102/182] doc/filters: create a dedicated examples section for lut*, and itemize --- doc/filters.texi | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 3334787fc7..c6f0d249d1 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3348,34 +3348,58 @@ expression All expressions default to "val". -Some examples follow: +@subsection Examples + +@itemize +@item +Negate input video: @example -# negate input video lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val" lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val" +@end example -# the above is the same as +The above is the same as: +@example lutrgb="r=negval:g=negval:b=negval" lutyuv="y=negval:u=negval:v=negval" +@end example -# negate luminance +@item +Negate luminance: +@example lutyuv=y=negval +@end example -# remove chroma components, turns the video into a graytone image +@item +Remove chroma components, turns the video into a graytone image: +@example lutyuv="u=128:v=128" +@end example -# apply a luma burning effect +@item +Apply a luma burning effect: +@example lutyuv="y=2*val" +@end example -# remove green and blue components +@item +Remove green and blue components: +@example lutrgb="g=0:b=0" +@end example -# set a constant alpha channel value on input +@item +Set a constant alpha channel value on input: +@example format=rgba,lutrgb=a="maxval-minval/2" +@end example -# correct luminance gamma by a 0.5 factor +@item +Correct luminance gamma by a 0.5 factor: +@example lutyuv=y=gammaval(0.5) @end example +@end itemize @section mp From 423856c4ae850d50f389245b97039023adfd1b3e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 1 Feb 2013 18:52:42 +0100 Subject: [PATCH 103/182] doc/filters: fix syntax and typo for the afade curve option --- doc/filters.texi | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c6f0d249d1..5718d100b7 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -587,18 +587,30 @@ the output audio will be silence. Default is 0. If set this option is used instead of @var{nb_samples} one. @item curve -Set cuve for fade transition. +Set curve for fade transition. + +It accepts the following values: @table @option -@item @var{tri} (triangular, linear slope (default)) -@item @var{qsin} (quarter of sine wave) -@item @var{hsin} (half of sine wave) -@item @var{esin} (exponential sine wave) -@item @var{log} (logarithmic) -@item @var{par} (inverted parabola) -@item @var{qua} (quadratic) -@item @var{cub} (cubic) -@item @var{squ} (square root) -@item @var{cbr} (cubic root) +@item tri +select triangular, linear slope (default) +@item qsin +select quarter of sine wave +@item hsin +select half of sine wave +@item esin +select exponential sine wave +@item log +select logarithmic +@item par +select inverted parabola +@item qua +select quadratic +@item cub +select cubic +@item squ +select square root +@item cbr +select cubic root @end table @end table From 5a67e30b1c71dc0a84779b543d95ca20faa8cbed Mon Sep 17 00:00:00 2001 From: Matthieu Bouron Date: Fri, 1 Feb 2013 18:58:14 +0100 Subject: [PATCH 104/182] ffmpeg: fix broken channel_layout option Fixes ticket #2163. Signed-off-by: Michael Niedermayer --- ffmpeg_opt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index b285f4ce88..a418e86167 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -2140,7 +2140,7 @@ static int opt_channel_layout(void *optctx, const char *opt, const char *arg) return AVERROR(EINVAL); } snprintf(layout_str, sizeof(layout_str), "%"PRIu64, layout); - ret = opt_default(NULL, opt, layout_str); + ret = opt_default_new(o, opt, layout_str); if (ret < 0) return ret; From 6a50e8a190bc1329fd3e76e8497bb7f870b6e69b Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 1 Feb 2013 23:27:15 +0100 Subject: [PATCH 105/182] Do not change codec in flv streams if the user has forced a codec. Fixes ticket #2218. --- libavformat/flvdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 09a77c4852..b57929eda1 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -713,13 +713,13 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) st = s->streams[i]; if (stream_type == FLV_STREAM_TYPE_AUDIO) { if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && - flv_same_audio_codec(st->codec, flags)) { + (s->audio_codec_id || flv_same_audio_codec(st->codec, flags))) { break; } } else if (stream_type == FLV_STREAM_TYPE_VIDEO) { if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && - flv_same_video_codec(st->codec, flags)) { + (s->video_codec_id || flv_same_video_codec(st->codec, flags))) { break; } } else if (stream_type == FLV_STREAM_TYPE_DATA) { From 8af915c21b03187ebe11823676081f6311fdbe5e Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 1 Feb 2013 11:04:50 -0800 Subject: [PATCH 106/182] vp56: remove clear_blocks call, and clear alpha plane U/V DC only. The non-alpha and alpha-Y planes are cleared in the idct_put/add() calls. For the alpha U/V planes, we only care about the DC for entropy context prediction purposes, the rest of the data is unused. Signed-off-by: Michael Niedermayer --- libavcodec/vp56.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index 7df5adade3..6cc377036c 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -394,8 +394,6 @@ static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha) mb_type = vp56_decode_mv(s, row, col); ref_frame = vp56_reference_frame[mb_type]; - s->dsp.clear_blocks(*s->block_coeff); - s->parse_coeff(s); vp56_add_predictors_dc(s, ref_frame); @@ -448,6 +446,11 @@ static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha) } break; } + + if (is_alpha) { + s->block_coeff[4][0] = 0; + s->block_coeff[5][0] = 0; + } } static int vp56_size_changed(VP56Context *s) From 985e93a86518f05cbed873b891011290096b013b Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 1 Feb 2013 23:55:54 +0100 Subject: [PATCH 107/182] Do not fail for mixed interlaced / non-interlaced YUV4MPEG streams. --- libavformat/yuv4mpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c index ff039bd37a..e2ab8e35cd 100644 --- a/libavformat/yuv4mpeg.c +++ b/libavformat/yuv4mpeg.c @@ -442,7 +442,7 @@ static int yuv4_read_header(AVFormatContext *s) case 'm': av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed " "interlaced and non-interlaced frames.\n"); - return -1; + break; default: av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n"); return -1; From 6289a8296a89b91e4f4a50cb4933dd8569b3b0c8 Mon Sep 17 00:00:00 2001 From: Steven Boswell II Date: Sat, 26 Jan 2013 13:08:47 -0800 Subject: [PATCH 108/182] build-sys: Fix pkgconfig files when ffmpeg is built with --build-suffix Tested-on: Fedora Core 14, 16, and 17. Tested-on: Ubuntu by commiter Signed-off-by: Michael Niedermayer --- configure | 33 +++++++++++++++++---------------- library.mak | 4 ++-- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/configure b/configure index b61359c7a7..913e3ba25a 100755 --- a/configure +++ b/configure @@ -4340,6 +4340,7 @@ ifndef FFMPEG_CONFIG_MAK FFMPEG_CONFIG_MAK=1 FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION prefix=$prefix +build_suffix=${build_suffix} LIBDIR=\$(DESTDIR)$libdir SHLIBDIR=\$(DESTDIR)$shlibdir INCDIR=\$(DESTDIR)$incdir @@ -4525,7 +4526,7 @@ pkgconfig_generate(){ requires=$5 enabled ${name#lib} || return 0 mkdir -p $name - cat < $name/$name.pc + cat < $name/$name${build_suffix}.pc prefix=$prefix exec_prefix=\${prefix} libdir=$libdir @@ -4561,27 +4562,27 @@ Cflags: -I\${includedir} EOF } -libavfilter_pc_deps="libavutil = $LIBAVUTIL_VERSION" -enabled libavfilter_deps_avcodec && prepend libavfilter_pc_deps "libavcodec = $LIBAVCODEC_VERSION," -enabled libavfilter_deps_avformat && prepend libavfilter_pc_deps "libavformat = $LIBAVFORMAT_VERSION," -enabled libavfilter_deps_avresample && prepend libavfilter_pc_deps "libavresample = $LIBAVRESAMPLE_VERSION," -enabled libavfilter_deps_swscale && prepend libavfilter_pc_deps "libswscale = $LIBSWSCALE_VERSION," -enabled libavfilter_deps_swresample && prepend libavfilter_pc_deps "libswresample = $LIBSWRESAMPLE_VERSION," -enabled libavfilter_deps_postproc && prepend libavfilter_pc_deps "libpostproc = $LIBPOSTPROC_VERSION," +libavfilter_pc_deps="libavutil${build_suffix} = $LIBAVUTIL_VERSION" +enabled libavfilter_deps_avcodec && prepend libavfilter_pc_deps "libavcodec${build_suffix} = $LIBAVCODEC_VERSION," +enabled libavfilter_deps_avformat && prepend libavfilter_pc_deps "libavformat${build_suffix} = $LIBAVFORMAT_VERSION," +enabled libavfilter_deps_avresample && prepend libavfilter_pc_deps "libavresample${build_suffix} = $LIBAVRESAMPLE_VERSION," +enabled libavfilter_deps_swscale && prepend libavfilter_pc_deps "libswscale${build_suffix} = $LIBSWSCALE_VERSION," +enabled libavfilter_deps_swresample && prepend libavfilter_pc_deps "libswresample${build_suffix} = $LIBSWRESAMPLE_VERSION," +enabled libavfilter_deps_postproc && prepend libavfilter_pc_deps "libpostproc${build_suffix} = $LIBPOSTPROC_VERSION," libavfilter_pc_deps=${libavfilter_pc_deps%, } -libavdevice_pc_deps="libavformat = $LIBAVFORMAT_VERSION" -enabled lavfi_indev && prepend libavdevice_pc_deps "libavfilter = $LIBAVFILTER_VERSION," +libavdevice_pc_deps="libavformat${build_suffix} = $LIBAVFORMAT_VERSION" +enabled lavfi_indev && prepend libavdevice_pc_deps "libavfilter${build_suffix} = $LIBAVFILTER_VERSION," pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" "$LIBM" -pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION" -pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION" +pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil${build_suffix} = $LIBAVUTIL_VERSION" +pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec${build_suffix} = $LIBAVCODEC_VERSION" pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$libavdevice_pc_deps" pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$libavfilter_pc_deps" -pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION" -pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION" -pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION" -pkgconfig_generate libswresample "FFmpeg audio resampling library" "$LIBSWRESAMPLE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION" +pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" "" "libavutil${build_suffix} = $LIBAVUTIL_VERSION" +pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$extralibs" "libavutil${build_suffix} = $LIBAVUTIL_VERSION" +pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil${build_suffix} = $LIBAVUTIL_VERSION" +pkgconfig_generate libswresample "FFmpeg audio resampling library" "$LIBSWRESAMPLE_VERSION" "$LIBM" "libavutil${build_suffix} = $LIBAVUTIL_VERSION" fix_ffmpeg_remote(){ git_remote_from=$1 diff --git a/library.mak b/library.mak index b0d4151dbd..362b76ddab 100644 --- a/library.mak +++ b/library.mak @@ -85,7 +85,7 @@ install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS)) $(Q)mkdir -p "$(INCINSTDIR)" $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)" -install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME).pc +install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME)${build_suffix}.pc $(Q)mkdir -p "$(LIBDIR)/pkgconfig" $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig" @@ -99,7 +99,7 @@ uninstall-libs:: uninstall-headers:: $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS)) - $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc" + $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME)${build_suffix}.pc" -rmdir "$(INCINSTDIR)" endef From b45a3e167f497d82effbf8ada453ea47b0ee21da Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 2 Feb 2013 12:29:58 +0100 Subject: [PATCH 109/182] Map the interlaced flag of yuv4mpeg streams to AVCodecContext->field_order. Fixes a part of ticket #2190. --- libavformat/yuv4mpeg.c | 68 +++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c index e2ab8e35cd..f34a4afce1 100644 --- a/libavformat/yuv4mpeg.c +++ b/libavformat/yuv4mpeg.c @@ -28,11 +28,6 @@ #define Y4M_FRAME_MAGIC "FRAME" #define Y4M_LINE_MAX 256 -struct frame_attributes { - int interlaced_frame; - int top_field_first; -}; - #if CONFIG_YUV4MPEGPIPE_MUXER static int yuv4_generate_header(AVFormatContext *s, char* buf) { @@ -58,6 +53,13 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) inter = 'p'; /* progressive is the default */ if (st->codec->coded_frame && st->codec->coded_frame->interlaced_frame) inter = st->codec->coded_frame->top_field_first ? 't' : 'b'; + if (st->codec->field_order == AV_FIELD_PROGRESSIVE) { + inter = 'p'; + } else if (st->codec->field_order == AV_FIELD_TB || st->codec->field_order == AV_FIELD_TT) { + inter = 't'; + } else if (st->codec->field_order == AV_FIELD_BT || st->codec->field_order == AV_FIELD_BB) { + inter = 'b'; + } switch (st->codec->pix_fmt) { case AV_PIX_FMT_GRAY8: @@ -319,7 +321,7 @@ static int yuv4_read_header(AVFormatContext *s) { char header[MAX_YUV4_HEADER + 10]; // Include headroom for // the longest option - char *tokstart, *tokend, *header_end; + char *tokstart, *tokend, *header_end, interlaced = '?'; int i; AVIOContext *pb = s->pb; int width = -1, height = -1, raten = 0, @@ -327,7 +329,6 @@ static int yuv4_read_header(AVFormatContext *s) enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE, alt_pix_fmt = AV_PIX_FMT_NONE; enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED; AVStream *st; - struct frame_attributes *s1 = s->priv_data; for (i = 0; i < MAX_YUV4_HEADER; i++) { header[i] = avio_r8(pb); @@ -343,8 +344,6 @@ static int yuv4_read_header(AVFormatContext *s) if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC))) return -1; - s1->interlaced_frame = 0; - s1->top_field_first = 0; header_end = &header[i + 1]; // Include space for (tokstart = &header[strlen(Y4M_MAGIC) + 1]; tokstart < header_end; tokstart++) { @@ -425,28 +424,7 @@ static int yuv4_read_header(AVFormatContext *s) tokstart++; break; case 'I': // Interlace type - switch (*tokstart++){ - case '?': - break; - case 'p': - s1->interlaced_frame = 0; - break; - case 't': - s1->interlaced_frame = 1; - s1->top_field_first = 1; - break; - case 'b': - s1->interlaced_frame = 1; - s1->top_field_first = 0; - break; - case 'm': - av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed " - "interlaced and non-interlaced frames.\n"); - break; - default: - av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n"); - return -1; - } + interlaced = *tokstart++; break; case 'F': // Frame rate sscanf(tokstart, "%d:%d", &raten, &rated); // 0:0 if unknown @@ -547,6 +525,27 @@ static int yuv4_read_header(AVFormatContext *s) st->sample_aspect_ratio = (AVRational){ aspectn, aspectd }; st->codec->chroma_sample_location = chroma_sample_location; + switch (interlaced){ + case 'p': + st->codec->field_order = AV_FIELD_PROGRESSIVE; + break; + case 't': + st->codec->field_order = AV_FIELD_TB; + break; + case 'b': + st->codec->field_order = AV_FIELD_BT; + break; + case 'm': + av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed " + "interlaced and non-interlaced frames.\n"); + case '?': + st->codec->field_order = AV_FIELD_UNKNOWN; + break; + default: + av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n"); + return AVERROR(EINVAL); + } + return 0; } @@ -556,7 +555,6 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) char header[MAX_FRAME_HEADER+1]; int packet_size, width, height, ret; AVStream *st = s->streams[0]; - struct frame_attributes *s1 = s->priv_data; for (i = 0; i < MAX_FRAME_HEADER; i++) { header[i] = avio_r8(s->pb); @@ -588,11 +586,6 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) else if (ret != packet_size) return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO); - if (st->codec->coded_frame) { - st->codec->coded_frame->interlaced_frame = s1->interlaced_frame; - st->codec->coded_frame->top_field_first = s1->top_field_first; - } - pkt->stream_index = 0; return 0; } @@ -610,7 +603,6 @@ static int yuv4_probe(AVProbeData *pd) AVInputFormat ff_yuv4mpegpipe_demuxer = { .name = "yuv4mpegpipe", .long_name = NULL_IF_CONFIG_SMALL("YUV4MPEG pipe"), - .priv_data_size = sizeof(struct frame_attributes), .read_probe = yuv4_probe, .read_header = yuv4_read_header, .read_packet = yuv4_read_packet, From 571ef42dd4eb260b213464ed15d288a887b6679a Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sat, 26 Jan 2013 22:32:39 +0100 Subject: [PATCH 110/182] ffplay: dynamically allocate audio buffer We simply remove the fixed length VideoState->audio_buf2 and use the previously unused VideoState->audio_buf1. Fixes ticket #2191. Signed-off-by: Marton Balint --- ffplay.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ffplay.c b/ffplay.c index 93090ad60b..96a2ee1304 100644 --- a/ffplay.c +++ b/ffplay.c @@ -181,11 +181,11 @@ typedef struct VideoState { AVStream *audio_st; PacketQueue audioq; int audio_hw_buf_size; - DECLARE_ALIGNED(16,uint8_t,audio_buf2)[AVCODEC_MAX_AUDIO_FRAME_SIZE * 4]; uint8_t silence_buf[SDL_AUDIO_BUFFER_SIZE]; uint8_t *audio_buf; uint8_t *audio_buf1; unsigned int audio_buf_size; /* in bytes */ + unsigned int audio_buf1_size; int audio_buf_index; /* in bytes */ int audio_write_buf_size; AVPacket audio_pkt_temp; @@ -2143,8 +2143,9 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) if (is->swr_ctx) { const uint8_t **in = (const uint8_t **)is->frame->extended_data; - uint8_t *out[] = {is->audio_buf2}; - int out_count = sizeof(is->audio_buf2) / is->audio_tgt.channels / av_get_bytes_per_sample(is->audio_tgt.fmt); + uint8_t **out = &is->audio_buf1; + int out_count = (int64_t)wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate + 256; + int out_size = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, out_count, is->audio_tgt.fmt, 0); if (wanted_nb_samples != is->frame->nb_samples) { if (swr_set_compensation(is->swr_ctx, (wanted_nb_samples - is->frame->nb_samples) * is->audio_tgt.freq / is->frame->sample_rate, wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate) < 0) { @@ -2152,6 +2153,9 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) break; } } + av_fast_malloc(&is->audio_buf1, &is->audio_buf1_size, out_size); + if (!is->audio_buf1) + return AVERROR(ENOMEM); len2 = swr_convert(is->swr_ctx, out, out_count, in, is->frame->nb_samples); if (len2 < 0) { fprintf(stderr, "swr_convert() failed\n"); @@ -2161,7 +2165,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) fprintf(stderr, "warning: audio buffer is probably too small\n"); swr_init(is->swr_ctx); } - is->audio_buf = is->audio_buf2; + is->audio_buf = is->audio_buf1; resampled_data_size = len2 * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt); } else { is->audio_buf = is->frame->data[0]; @@ -2437,6 +2441,7 @@ static void stream_component_close(VideoState *is, int stream_index) av_free_packet(&is->audio_pkt); swr_free(&is->swr_ctx); av_freep(&is->audio_buf1); + is->audio_buf1_size = 0; is->audio_buf = NULL; avcodec_free_frame(&is->frame); From 4fd6e5af1e334875eca4f803bbcfac9219b0524a Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 27 Jan 2013 00:45:47 +0100 Subject: [PATCH 111/182] ffplay: fix order of setting show_mode Without the fix the refresh event may have got called with unset show mode. Fixes ticket #2174. Signed-off-by: Marton Balint --- ffplay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index 96a2ee1304..6cdbafe68c 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2641,10 +2641,11 @@ static int read_thread(void *arg) if (st_index[AVMEDIA_TYPE_VIDEO] >= 0) { ret = stream_component_open(is, st_index[AVMEDIA_TYPE_VIDEO]); } - is->refresh_tid = SDL_CreateThread(refresh_thread, is); if (is->show_mode == SHOW_MODE_NONE) is->show_mode = ret >= 0 ? SHOW_MODE_VIDEO : SHOW_MODE_RDFT; + is->refresh_tid = SDL_CreateThread(refresh_thread, is); + if (st_index[AVMEDIA_TYPE_SUBTITLE] >= 0) { stream_component_open(is, st_index[AVMEDIA_TYPE_SUBTITLE]); } From 5de3f724f1524ee01843f0d9c0033253b65c69ec Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 27 Jan 2013 14:03:15 +0100 Subject: [PATCH 112/182] ffplay: remember last window dimensions After this change the dimensions of single image videos will be remembered when coming back from full screen. The issue was mentioned in ticket #2174. Signed-off-by: Marton Balint --- ffplay.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ffplay.c b/ffplay.c index 6cdbafe68c..c9750bf834 100644 --- a/ffplay.c +++ b/ffplay.c @@ -268,6 +268,8 @@ static const char *input_filename; static const char *window_title; static int fs_screen_width; static int fs_screen_height; +static int default_width = 640; +static int default_height = 480; static int screen_width = 0; static int screen_height = 0; static int audio_disable; @@ -1022,29 +1024,30 @@ static void sigterm_handler(int sig) exit(123); } -static int video_open(VideoState *is, int force_set_video_mode) +static int video_open(VideoState *is, int force_set_video_mode, VideoPicture *vp) { int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL; int w,h; - VideoPicture *vp = &is->pictq[is->pictq_rindex]; SDL_Rect rect; if (is_full_screen) flags |= SDL_FULLSCREEN; else flags |= SDL_RESIZABLE; + if (vp && vp->width) { + calculate_display_rect(&rect, 0, 0, INT_MAX, vp->height, vp); + default_width = rect.w; + default_height = rect.h; + } + if (is_full_screen && fs_screen_width) { w = fs_screen_width; h = fs_screen_height; } else if (!is_full_screen && screen_width) { w = screen_width; h = screen_height; - } else if (vp->width) { - calculate_display_rect(&rect, 0, 0, INT_MAX, vp->height, vp); - w = rect.w; - h = rect.h; } else { - w = 640; - h = 480; + w = default_width; + h = default_height; } if (screen && is->width == screen->w && screen->w == w && is->height== screen->h && screen->h == h && !force_set_video_mode) @@ -1068,7 +1071,7 @@ static int video_open(VideoState *is, int force_set_video_mode) static void video_display(VideoState *is) { if (!screen) - video_open(is, 0); + video_open(is, 0, NULL); if (is->audio_st && is->show_mode != SHOW_MODE_VIDEO) video_audio_display(is); else if (is->video_st) @@ -1458,7 +1461,7 @@ static void alloc_picture(VideoState *is) avfilter_unref_bufferp(&vp->picref); #endif - video_open(is, 0); + video_open(is, 0, vp); vp->bmp = SDL_CreateYUVOverlay(vp->width, vp->height, SDL_YV12_OVERLAY, @@ -2919,7 +2922,7 @@ static void toggle_full_screen(VideoState *is) is->pictq[i].reallocate = 1; #endif is_full_screen = !is_full_screen; - video_open(is, 1); + video_open(is, 1, NULL); } static void toggle_pause(VideoState *is) From c5eab4bb70cc9884ff1e0e11cb2f980bb3b40937 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sat, 19 Jan 2013 01:44:38 +0100 Subject: [PATCH 113/182] ffplay: move up pause functions No change in functionality. Signed-off-by: Marton Balint --- ffplay.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ffplay.c b/ffplay.c index c9750bf834..c723b74a19 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1220,6 +1220,20 @@ static void stream_toggle_pause(VideoState *is) is->paused = !is->paused; } +static void toggle_pause(VideoState *is) +{ + stream_toggle_pause(is); + is->step = 0; +} + +static void step_to_next_frame(VideoState *is) +{ + /* if the stream is paused unpause it, then step */ + if (is->paused) + stream_toggle_pause(is); + is->step = 1; +} + static double compute_target_delay(double delay, VideoState *is) { double sync_threshold, diff; @@ -2925,20 +2939,6 @@ static void toggle_full_screen(VideoState *is) video_open(is, 1, NULL); } -static void toggle_pause(VideoState *is) -{ - stream_toggle_pause(is); - is->step = 0; -} - -static void step_to_next_frame(VideoState *is) -{ - /* if the stream is paused unpause it, then step */ - if (is->paused) - stream_toggle_pause(is); - is->step = 1; -} - static void toggle_audio_display(VideoState *is) { int bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); From 4ea7fbb2ec1a8833b6683655b98f4bf42f817102 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sat, 19 Jan 2013 01:57:50 +0100 Subject: [PATCH 114/182] ffplay: step to next frame if paused when seeking Signed-off-by: Marton Balint --- ffplay.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ffplay.c b/ffplay.c index c723b74a19..58ff99d4ce 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2728,6 +2728,8 @@ static int read_thread(void *arg) } is->seek_req = 0; eof = 0; + if (is->paused) + step_to_next_frame(is); } if (is->queue_attachments_req) { avformat_queue_attached_pictures(ic); From d593f2b2416fa8bc8c7b6bc55b47d456b75e0b2a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 2 Feb 2013 12:38:44 +0100 Subject: [PATCH 115/182] avfilter/x86/vf_hqdn3d_init: fix author attribution & project name Reference: 7a1944b907179212e7073b821fdc60e27d536e4a Signed-off-by: Michael Niedermayer --- libavfilter/x86/vf_hqdn3d_init.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavfilter/x86/vf_hqdn3d_init.c b/libavfilter/x86/vf_hqdn3d_init.c index 2893a54c15..4abb87888e 100644 --- a/libavfilter/x86/vf_hqdn3d_init.c +++ b/libavfilter/x86/vf_hqdn3d_init.c @@ -1,18 +1,20 @@ /* - * This file is part of Libav. + * Copyright (c) 2012 Loren Merritt * - * Libav is free software; you can redistribute it and/or modify + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software Foundation, Inc., + * with FFmpeg; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ From 6726fb653320cf7a7906c93d094d119a2f290339 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 2 Feb 2013 12:44:26 +0100 Subject: [PATCH 116/182] avfilter/vf_hqdn3d.h: restore author attribution, history and project name See git blame of pre split avfilter/vf_hqdn3d.c Signed-off-by: Michael Niedermayer --- libavfilter/vf_hqdn3d.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_hqdn3d.h b/libavfilter/vf_hqdn3d.h index 7350f745c0..dfc69e140f 100644 --- a/libavfilter/vf_hqdn3d.h +++ b/libavfilter/vf_hqdn3d.h @@ -1,18 +1,22 @@ /* - * This file is part of Libav. + * Copyright (c) 2003 Daniel Moreno + * Copyright (c) 2010 Baptiste Coudurier + * Copyright (c) 2012 Loren Merritt * - * Libav is free software; you can redistribute it and/or modify + * This file is part of FFmpeg, ported from MPlayer. + * + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software Foundation, Inc., + * with FFmpeg; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ From 55910e18948dcf3efb251887ec92449850929892 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Sat, 2 Feb 2013 14:13:11 +0100 Subject: [PATCH 117/182] lavd/alsa: simplify reordering functions definition. --- libavdevice/alsa-audio-common.c | 73 ++++++++++++--------------------- 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index afe67510d7..4e63397380 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -62,48 +62,45 @@ 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) { \ +#define MAKE_REORDER_FUNC(NAME, TYPE, CHANNELS, LAYOUT, MAP) \ +static void alsa_reorder_ ## NAME ## _ ## LAYOUT(const void *in_v, \ + void *out_v, \ + int n) \ +{ \ + const TYPE *in = in_v; \ + TYPE *out = out_v; \ + \ + while (n-- > 0) { \ + MAP \ + in += CHANNELS; \ + out += CHANNELS; \ + } \ +} + +#define MAKE_REORDER_FUNCS(CHANNELS, LAYOUT, MAP) \ + MAKE_REORDER_FUNC(int8, int8_t, CHANNELS, LAYOUT, MAP) \ + MAKE_REORDER_FUNC(int16, int16_t, CHANNELS, LAYOUT, MAP) \ + MAKE_REORDER_FUNC(int32, int32_t, CHANNELS, LAYOUT, MAP) \ + MAKE_REORDER_FUNC(f32, float, CHANNELS, LAYOUT, MAP) + +MAKE_REORDER_FUNCS(5, out_50, \ 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) { \ +MAKE_REORDER_FUNCS(6, out_51, \ 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) { \ +MAKE_REORDER_FUNCS(8, out_71, \ out[0] = in[0]; \ out[1] = in[1]; \ out[2] = in[4]; \ @@ -112,23 +109,7 @@ static void alsa_reorder_ ## NAME ## _out_71(const void *in_v, void *out_v, int 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 From 6032a1c977cc266cc49e1768024dfc87180dbea2 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 28 Jun 2012 23:46:20 +0200 Subject: [PATCH 118/182] ffplay: extend doxy for audio_decode_frame() --- ffplay.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index 93090ad60b..0f7b984576 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2066,7 +2066,13 @@ static int synchronize_audio(VideoState *is, int nb_samples) return wanted_nb_samples; } -/* decode one audio frame and returns its uncompressed size */ +/** + * Decode one audio frame and return its uncompressed size. + * + * The processed audio frame is decoded, converted if required, and + * stored in is->audio_buf, with size in bytes given by the return + * value. + */ static int audio_decode_frame(VideoState *is, double *pts_ptr) { AVPacket *pkt_temp = &is->audio_pkt_temp; From fd6b6efbd212fc235c7a511ae37161869c1fa79f Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Feb 2013 00:41:24 +0100 Subject: [PATCH 119/182] lavfi/crop: fix help message for the keep_aspect option --- libavfilter/vf_crop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index 1ff949327a..8df9595550 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -102,7 +102,7 @@ static const AVOption crop_options[] = { { "w", "set the width crop area expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, CHAR_MIN, CHAR_MAX, FLAGS }, { "out_h", "set the height crop area expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS }, { "h", "set the height crop area expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS }, - { "keep_aspect", "force packed RGB in input and output", OFFSET(keep_aspect), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS }, + { "keep_aspect", "keep aspect ratio", OFFSET(keep_aspect), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS }, {NULL} }; From 6d9c21dc0e82130bcd57f77c5ba11d260075a004 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Feb 2013 00:54:40 +0100 Subject: [PATCH 120/182] doc/indevs: add missing final dot in v4l2 option value description Fix inconsistency. --- doc/indevs.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index 9deb214eb2..cc5d66622c 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -694,7 +694,7 @@ Use timestamps from the kernel. Use absolute timestamps (wall clock). @item mono2abs -Force conversion from monotonic to absolute timestamps +Force conversion from monotonic to absolute timestamps. @end table Default value is @code{default}. From cdc48860a8cbb0080acc0732b2e1c689cea03777 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 2 Feb 2013 16:20:19 +0100 Subject: [PATCH 121/182] h264: silence warning about array index being out of bounds The index is not out of bounds, adding an assert makes gcc realize this. Signed-off-by: Michael Niedermayer --- libavcodec/h264.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 3d759cc4f6..50839bd83c 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3906,6 +3906,7 @@ static int execute_decode_slices(H264Context *h, int context_count) if (context_count == 1) { return decode_slice(avctx, &h); } else { + av_assert0(context_count > 0); for (i = 1; i < context_count; i++) { hx = h->thread_context[i]; hx->s.err_recognition = avctx->err_recognition; From 23686c72e5aed9778562ccb12fb064b21a0b81fa Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 29 Nov 2012 17:40:42 +0100 Subject: [PATCH 122/182] doc: update filter_design.txt to API changes. --- doc/filter_design.txt | 82 ++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/doc/filter_design.txt b/doc/filter_design.txt index 362fce4146..772ca9dfb0 100644 --- a/doc/filter_design.txt +++ b/doc/filter_design.txt @@ -15,13 +15,13 @@ Format negotiation the list of supported formats. For video links, that means pixel format. For audio links, that means - channel layout, and sample format (the sample packing is implied by the - sample format). + channel layout, sample format (the sample packing is implied by the sample + format) and sample rate. The lists are not just lists, they are references to shared objects. When the negotiation mechanism computes the intersection of the formats - supported at each ends of a link, all references to both lists are - replaced with a reference to the intersection. And when a single format is + supported at each end of a link, all references to both lists are replaced + with a reference to the intersection. And when a single format is eventually chosen for a link amongst the remaining list, again, all references to the list are updated. @@ -68,15 +68,15 @@ Buffer references ownership and permissions Here are the (fairly obvious) rules for reference ownership: - * A reference received by the start_frame or filter_frame method - belong to the corresponding filter. + * A reference received by the filter_frame method (or its start_frame + deprecated version) belongs to the corresponding filter. Special exception: for video references: the reference may be used internally for automatic copying and must not be destroyed before end_frame; it can be given away to ff_start_frame. - * A reference passed to ff_start_frame or ff_filter_frame is given - away and must no longer be used. + * A reference passed to ff_filter_frame (or the deprecated + ff_start_frame) is given away and must no longer be used. * A reference created with avfilter_ref_buffer belongs to the code that created it. @@ -90,27 +90,11 @@ Buffer references ownership and permissions Link reference fields --------------------- - The AVFilterLink structure has a few AVFilterBufferRef fields. Here are - the rules to handle them: - - * cur_buf is set before the start_frame and filter_frame methods to - the same reference given as argument to the methods and belongs to the - destination filter of the link. If it has not been cleared after - end_frame or filter_frame, libavfilter will automatically destroy - the reference; therefore, any filter that needs to keep the reference - for longer must set cur_buf to NULL. - - * out_buf belongs to the source filter of the link and can be used to - store a reference to the buffer that has been sent to the destination. - If it is not NULL after end_frame or filter_frame, libavfilter will - automatically destroy the reference. - - If a video input pad does not have a start_frame method, the default - method will request a buffer on the first output of the filter, store - the reference in out_buf and push a second reference to the output. - - * src_buf, cur_buf_copy and partial_buf are used by libavfilter - internally and must not be accessed by filters. + The AVFilterLink structure has a few AVFilterBufferRef fields. The + cur_buf and out_buf were used with the deprecated + start_frame/draw_slice/end_frame API and should no longer be used. + src_buf, cur_buf_copy and partial_buf are used by libavfilter internally + and must not be accessed by filters. Reference permissions --------------------- @@ -119,8 +103,10 @@ Buffer references ownership and permissions the code that owns the reference is allowed to do to the buffer data. Different references for the same buffer can have different permissions. - For video filters, the permissions only apply to the parts of the buffer - that have already been covered by the draw_slice method. + For video filters that implement the deprecated + start_frame/draw_slice/end_frame API, the permissions only apply to the + parts of the buffer that have already been covered by the draw_slice + method. The value is a binary OR of the following constants: @@ -179,9 +165,9 @@ Buffer references ownership and permissions with the WRITE permission. * Filters that intend to keep a reference after the filtering process - is finished (after end_frame or filter_frame returns) must have the - PRESERVE permission on it and remove the WRITE permission if they - create a new reference to give it away. + is finished (after filter_frame returns) must have the PRESERVE + permission on it and remove the WRITE permission if they create a new + reference to give it away. * Filters that intend to modify a reference they have kept after the end of the filtering process need the REUSE2 permission and must remove @@ -198,11 +184,11 @@ Frame scheduling Simple filters that output one frame for each input frame should not have to worry about it. - start_frame / filter_frame - ---------------------------- + filter_frame + ------------ - These methods are called when a frame is pushed to the filter's input. - They can be called at any time except in a reentrant way. + This method is called when a frame is pushed to the filter's input. It + can be called at any time except in a reentrant way. If the input frame is enough to produce output, then the filter should push the output frames on the output link immediately. @@ -213,7 +199,7 @@ Frame scheduling filter; these buffered frames must be flushed immediately if a new input produces new output. - (Example: framerate-doubling filter: start_frame must (1) flush the + (Example: framerate-doubling filter: filter_frame must (1) flush the second copy of the previous frame, if it is still there, (2) push the first copy of the incoming frame, (3) keep the second copy for later.) @@ -233,8 +219,8 @@ Frame scheduling This method is called when a frame is wanted on an output. - For an input, it should directly call start_frame or filter_frame on - the corresponding output. + For an input, it should directly call filter_frame on the corresponding + output. For a filter, if there are queued frames already ready, one of these frames should be pushed. If not, the filter should request a frame on @@ -255,7 +241,7 @@ Frame scheduling } while (!frame_pushed) { input = input_where_a_frame_is_most_needed(); - ret = avfilter_request_frame(input); + ret = ff_request_frame(input); if (ret == AVERROR_EOF) { process_eof_on_input(); } else if (ret < 0) { @@ -266,4 +252,14 @@ Frame scheduling Note that, except for filters that can have queued frames, request_frame does not push frames: it requests them to its input, and as a reaction, - the start_frame / filter_frame method will be called and do the work. + the filter_frame method will be called and do the work. + +Legacy API +========== + + Until libavfilter 3.23, the filter_frame method was split: + + - for video filters, it was made of start_frame, draw_slice (that could be + called several times on distinct parts of the frame) and end_frame; + + - for audio filters, it was called filter_samples. From 0e9b9a6748aa67c8f272e5eab2b5f7ad6e13d5c9 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 2 Feb 2013 19:17:25 +0100 Subject: [PATCH 123/182] flacdec: skip in stream header packets This prevents warning messages on chained oggs with some demuxers Signed-off-by: Michael Niedermayer --- libavcodec/flacdec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 9d5ecd04cf..eb75729964 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -505,6 +505,16 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data, FLAC_MAX_CHANNELS, 32); } + if (buf_size > 5 && !memcmp(buf, "\177FLAC", 5)) { + av_log(s->avctx, AV_LOG_DEBUG, "skiping flac header packet 1\n"); + return buf_size; + } + + if (buf_size > 0 && (*buf & 0x7F) == FLAC_METADATA_TYPE_VORBIS_COMMENT) { + av_log(s->avctx, AV_LOG_DEBUG, "skiping vorbis comment\n"); + return buf_size; + } + /* check that there is at least the smallest decodable amount of data. this amount corresponds to the smallest valid FLAC frame possible. FF F8 69 02 00 00 9A 00 00 34 46 */ From 695af8eed642ff0104834495652d1ee784a4c14d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 2 Feb 2013 21:11:54 +0100 Subject: [PATCH 124/182] h264: skip error concealment when SPS and slices are mismatching Fixes out of array accesses Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind 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 50839bd83c..34cd8c0658 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2367,7 +2367,7 @@ static int field_end(H264Context *h, int in_setup) * past end by one (callers fault) and resync_mb_y != 0 * causes problems for the first MB line, too. */ - if (!FIELD_PICTURE && h->current_slice) + if (!FIELD_PICTURE && h->current_slice && !h->sps.new) ff_er_frame_end(s); ff_MPV_frame_end(s); From a60530e3ee1d9532c026a52b03661f88e163d647 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 2 Feb 2013 22:36:25 +0100 Subject: [PATCH 125/182] Require at least three frames to autodetect loas. --- libavformat/loasdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c index 2a06fe12a7..d3a8dbd6cd 100644 --- a/libavformat/loasdec.c +++ b/libavformat/loasdec.c @@ -55,7 +55,6 @@ static int loas_probe(AVProbeData *p) if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1; else if(max_frames>100)return AVPROBE_SCORE_MAX/2; else if(max_frames>=3) return AVPROBE_SCORE_MAX/4; - else if(max_frames>=1) return 1; else return 0; } From 0cecaa9e2edfa4fb198a70a175a039d0b6b2f845 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 Feb 2013 02:45:41 +0100 Subject: [PATCH 126/182] ffmpeg: free attachments, fix memleak Signed-off-by: Michael Niedermayer --- ffmpeg_opt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index a418e86167..4f320b9b29 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -126,6 +126,7 @@ static void uninit_options(OptionsContext *o, int is_input) av_freep(&o->stream_maps); av_freep(&o->audio_channel_maps); av_freep(&o->streamid_map); + av_freep(&o->attachments); if (is_input) recording_time = o->recording_time; From c91f1f3f926d4ba36ab051adc447ff56391210c3 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Feb 2013 16:31:57 +0100 Subject: [PATCH 127/182] ffplay: drop redundant NULL sws_freeContext() check in stream_close() sws_freeContext() already checks for NULL, simplify. --- ffplay.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ffplay.c b/ffplay.c index efb5468307..7e65a179b4 100644 --- a/ffplay.c +++ b/ffplay.c @@ -994,8 +994,7 @@ static void stream_close(VideoState *is) SDL_DestroyCond(is->subpq_cond); SDL_DestroyCond(is->continue_read_thread); #if !CONFIG_AVFILTER - if (is->img_convert_ctx) - sws_freeContext(is->img_convert_ctx); + sws_freeContext(is->img_convert_ctx); #endif av_free(is); } From 90020d7f4bf2f0f18fca6ba731152886d8c923fd Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 3 Feb 2013 11:12:49 +0100 Subject: [PATCH 128/182] lavf/segment: use correct spelling and value for EXT-X-ALLOW-CACHE tag Replace wrong "EXT-X-ALLOWCACHE" with "EXT-X-ALLOW-CACHE", and value 1/0 with YES/NO, as per spec. Fix trac ticket #2228. Signed-off-by: Stefano Sabatini --- libavformat/segment.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/segment.c b/libavformat/segment.c index 7d7222922c..9c271eb3a8 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -219,8 +219,8 @@ static int segment_list_open(AVFormatContext *s) avio_printf(seg->list_pb, "#EXTM3U\n"); avio_printf(seg->list_pb, "#EXT-X-VERSION:3\n"); avio_printf(seg->list_pb, "#EXT-X-MEDIA-SEQUENCE:%d\n", seg->segment_list_entries->index); - avio_printf(seg->list_pb, "#EXT-X-ALLOWCACHE:%d\n", - !!(seg->list_flags & SEGMENT_LIST_FLAG_CACHE)); + avio_printf(seg->list_pb, "#EXT-X-ALLOW-CACHE:%s\n", + seg->list_flags & SEGMENT_LIST_FLAG_CACHE ? "YES" : "NO"); for (entry = seg->segment_list_entries; entry; entry = entry->next) max_duration = FFMAX(max_duration, entry->end_time - entry->start_time); From d1511c02f49e2a7faddb727e9b19da8ec6189703 Mon Sep 17 00:00:00 2001 From: James Almer Date: Sun, 3 Feb 2013 06:01:35 -0300 Subject: [PATCH 129/182] proresdsp: Fix checkheaders It's been broken since commit ac89875 Signed-off-by: James Almer Signed-off-by: Michael Niedermayer --- libavcodec/proresdsp.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/proresdsp.h b/libavcodec/proresdsp.h index a9df91851f..706162af52 100644 --- a/libavcodec/proresdsp.h +++ b/libavcodec/proresdsp.h @@ -24,6 +24,7 @@ #define AVCODEC_PRORESDSP_H #include +#include "dsputil.h" #define PRORES_BITS_PER_SAMPLE 10 ///< output precision of prores decoder From 13eb9fcf5686142c8b43f6a540d0ea5e40dda651 Mon Sep 17 00:00:00 2001 From: James Almer Date: Sat, 2 Feb 2013 23:32:56 -0300 Subject: [PATCH 130/182] build: Remove superfluous MAKE variable for the build suffix Use BUILDSUF instead. Signed-off-by: James Almer Signed-off-by: Michael Niedermayer --- configure | 1 - library.mak | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 913e3ba25a..1f652465dd 100755 --- a/configure +++ b/configure @@ -4340,7 +4340,6 @@ ifndef FFMPEG_CONFIG_MAK FFMPEG_CONFIG_MAK=1 FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION prefix=$prefix -build_suffix=${build_suffix} LIBDIR=\$(DESTDIR)$libdir SHLIBDIR=\$(DESTDIR)$shlibdir INCDIR=\$(DESTDIR)$incdir diff --git a/library.mak b/library.mak index 362b76ddab..273b3d6e89 100644 --- a/library.mak +++ b/library.mak @@ -85,7 +85,7 @@ install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS)) $(Q)mkdir -p "$(INCINSTDIR)" $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)" -install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME)${build_suffix}.pc +install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(FULLNAME).pc $(Q)mkdir -p "$(LIBDIR)/pkgconfig" $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig" @@ -99,7 +99,7 @@ uninstall-libs:: uninstall-headers:: $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS)) - $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME)${build_suffix}.pc" + $(RM) "$(LIBDIR)/pkgconfig/lib$(FULLNAME).pc" -rmdir "$(INCINSTDIR)" endef From cb573f7fbca15169382098ed315daf359ba981fc Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 Feb 2013 13:50:44 +0100 Subject: [PATCH 131/182] avcodec/x86: Add daniels copyright to the recent gcc->yasm convertions he did. Signed-off-by: Michael Niedermayer --- libavcodec/x86/hpeldsp.asm | 1 + libavcodec/x86/mpeg4qpel.asm | 1 + 2 files changed, 2 insertions(+) diff --git a/libavcodec/x86/hpeldsp.asm b/libavcodec/x86/hpeldsp.asm index 0f6f9e9ad2..7f0c285fa3 100644 --- a/libavcodec/x86/hpeldsp.asm +++ b/libavcodec/x86/hpeldsp.asm @@ -4,6 +4,7 @@ ;* Copyright (c) Nick Kurshev ;* Copyright (c) 2002 Michael Niedermayer ;* Copyright (c) 2002 Zdenek Kabelac +;* Copyright (c) 2013 Daniel Kang ;* ;* MMX optimized hpel functions ;* diff --git a/libavcodec/x86/mpeg4qpel.asm b/libavcodec/x86/mpeg4qpel.asm index fe47bf302e..afbdf351c7 100644 --- a/libavcodec/x86/mpeg4qpel.asm +++ b/libavcodec/x86/mpeg4qpel.asm @@ -2,6 +2,7 @@ ;* mpeg4 qpel ;* Copyright (c) 2003 Michael Niedermayer ;* Copyright (c) 2008 Loren Merritt +;* Copyright (c) 2013 Daniel Kang ;* ;* This file is part of FFmpeg. ;* From 6e32b377bbb590fa024e0ffe1bc3911033133c59 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Feb 2013 16:09:24 +0100 Subject: [PATCH 132/182] ffplay: remove pts_ptr argument from audio_decode_frame() The argument is no longer used outside the function. Simplify. --- ffplay.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ffplay.c b/ffplay.c index 7e65a179b4..183523ced5 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2089,7 +2089,7 @@ static int synchronize_audio(VideoState *is, int nb_samples) * stored in is->audio_buf, with size in bytes given by the return * value. */ -static int audio_decode_frame(VideoState *is, double *pts_ptr) +static int audio_decode_frame(VideoState *is) { AVPacket *pkt_temp = &is->audio_pkt_temp; AVPacket *pkt = &is->audio_pkt; @@ -2097,7 +2097,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) int len1, len2, data_size, resampled_data_size; int64_t dec_channel_layout; int got_frame; - double pts; + av_unused double pts; int new_packet = 0; int flush_complete = 0; int wanted_nb_samples; @@ -2196,7 +2196,6 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) /* if no pts, then compute it */ pts = is->audio_clock; - *pts_ptr = pts; is->audio_clock += (double)data_size / (is->frame->channels * is->frame->sample_rate * av_get_bytes_per_sample(is->frame->format)); #ifdef DEBUG @@ -2248,13 +2247,12 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len) int audio_size, len1; int bytes_per_sec; int frame_size = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, 1, is->audio_tgt.fmt, 1); - double pts; audio_callback_time = av_gettime(); while (len > 0) { if (is->audio_buf_index >= is->audio_buf_size) { - audio_size = audio_decode_frame(is, &pts); + audio_size = audio_decode_frame(is); if (audio_size < 0) { /* if error, just output silence */ is->audio_buf = is->silence_buf; From 02af4e9a97ccde619e2123793b11d46f60d6b606 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 3 Feb 2013 12:29:46 +0100 Subject: [PATCH 133/182] ffplay: rename audio_decode_frame() variable "pts" to "audio_clock0" The new name better expresses what the variable is. --- ffplay.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ffplay.c b/ffplay.c index 183523ced5..040ddc8489 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2097,7 +2097,7 @@ static int audio_decode_frame(VideoState *is) int len1, len2, data_size, resampled_data_size; int64_t dec_channel_layout; int got_frame; - av_unused double pts; + av_unused double audio_clock0; int new_packet = 0; int flush_complete = 0; int wanted_nb_samples; @@ -2195,15 +2195,15 @@ static int audio_decode_frame(VideoState *is) } /* if no pts, then compute it */ - pts = is->audio_clock; + audio_clock0 = is->audio_clock; is->audio_clock += (double)data_size / (is->frame->channels * is->frame->sample_rate * av_get_bytes_per_sample(is->frame->format)); #ifdef DEBUG { static double last_clock; - printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n", + printf("audio: delay=%0.3f clock=%0.3f clock0=%0.3f\n", is->audio_clock - last_clock, - is->audio_clock, pts); + is->audio_clock, audio_clock0); last_clock = is->audio_clock; } #endif From c44281906a87b0cee4035ca3f2bddfd2ab1f797b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 3 Feb 2013 12:30:44 +0100 Subject: [PATCH 134/182] ffplay: remove misleading comment from audio_decode_frame() --- ffplay.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index 040ddc8489..2dbe8b965c 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2194,7 +2194,6 @@ static int audio_decode_frame(VideoState *is) resampled_data_size = data_size; } - /* if no pts, then compute it */ audio_clock0 = is->audio_clock; is->audio_clock += (double)data_size / (is->frame->channels * is->frame->sample_rate * av_get_bytes_per_sample(is->frame->format)); From 1897109c00a04373248e401d192ed26b1b74dd03 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 2 Feb 2013 00:51:14 +0100 Subject: [PATCH 135/182] lavfi/pad: add support to named options --- doc/filters.texi | 82 ++++++++++++++++++++++++------------------- libavfilter/version.h | 2 +- libavfilter/vf_pad.c | 52 +++++++++++++++++++-------- 3 files changed, 84 insertions(+), 52 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 5718d100b7..442fe35466 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3725,14 +3725,50 @@ testsrc=s=100x100, split=4 [in0][in1][in2][in3]; @section pad -Add paddings to the input image, and places the original input at the +Add paddings to the input image, and place the original input at the given coordinates @var{x}, @var{y}. -It accepts the following parameters: +The filter accepts parameters as a list of @var{key}=@var{value} pairs, +separated by ":". + +If the key of the first options is omitted, the arguments are +interpreted according to the syntax @var{width}:@var{height}:@var{x}:@var{y}:@var{color}. -The parameters @var{width}, @var{height}, @var{x}, and @var{y} are -expressions containing the following constants: +A description of the accepted options follows. + +@table @option +@item width, w +@item height, h +Specify an expression for the size of the output image with the +paddings added. If the value for @var{width} or @var{height} is 0, the +corresponding input size is used for the output. + +The @var{width} expression can reference the value set by the +@var{height} expression, and vice versa. + +The default value of @var{width} and @var{height} is 0. + +@item x +@item y +Specify an expression for the offsets where to place the input image +in the padded area with respect to the top/left border of the output +image. + +The @var{x} expression can reference the value set by the @var{y} +expression, and vice versa. + +The default value of @var{x} and @var{y} is 0. + +@item color +Specify the color of the padded area, it can be the name of a color +(case insensitive match) or a 0xRRGGBB[AA] sequence. + +The default value of @var{color} is "black". +@end table + +The value for the @var{width}, @var{height}, @var{x}, and @var{y} +options are expressions containing the following constants: @table @option @item in_w, in_h @@ -3766,39 +3802,6 @@ horizontal and vertical chroma subsample values. For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. @end table -Follows the description of the accepted parameters. - -@table @option -@item width, height - -Specify the size of the output image with the paddings added. If the -value for @var{width} or @var{height} is 0, the corresponding input size -is used for the output. - -The @var{width} expression can reference the value set by the -@var{height} expression, and vice versa. - -The default value of @var{width} and @var{height} is 0. - -@item x, y - -Specify the offsets where to place the input image in the padded area -with respect to the top/left border of the output image. - -The @var{x} expression can reference the value set by the @var{y} -expression, and vice versa. - -The default value of @var{x} and @var{y} is 0. - -@item color - -Specify the color of the padded area, it can be the name of a color -(case insensitive match) or a 0xRRGGBB[AA] sequence. - -The default value of @var{color} is "black". - -@end table - @subsection Examples @itemize @@ -3810,6 +3813,11 @@ column 0, row 40: pad=640:480:0:40:violet @end example +The example above is equivalent to the following command: +@example +pad=width=640:height=480:x=0:y=40:color=violet +@end example + @item Pad the input to get an output with dimensions increased by 3/2, and put the input video at the center of the padded area: diff --git a/libavfilter/version.h b/libavfilter/version.h index b6f7992e11..f90d3f2018 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 3 #define LIBAVFILTER_VERSION_MINOR 35 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #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 bbd37b160c..5c146f208f 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -35,6 +35,7 @@ #include "libavutil/colorspace.h" #include "libavutil/avassert.h" #include "libavutil/imgutils.h" +#include "libavutil/opt.h" #include "libavutil/parseutils.h" #include "libavutil/mathematics.h" #include "drawutils.h" @@ -76,40 +77,61 @@ static int query_formats(AVFilterContext *ctx) } typedef struct { + const AVClass *class; int w, h; ///< output dimensions, a value of 0 will result in the input size int x, y; ///< offsets of the input area with respect to the padded area int in_w, in_h; ///< width and height for the padded input video, which has to be aligned to the chroma values in order to avoid chroma issues - char w_expr[256]; ///< width expression string - char h_expr[256]; ///< height expression string - char x_expr[256]; ///< width expression string - char y_expr[256]; ///< height expression string - + char *w_expr; ///< width expression string + char *h_expr; ///< height expression string + char *x_expr; ///< width expression string + char *y_expr; ///< height expression string + char *color_str; uint8_t rgba_color[4]; ///< color for the padding area FFDrawContext draw; FFDrawColor color; } PadContext; +#define OFFSET(x) offsetof(PadContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM + +static const AVOption pad_options[] = { + { "width", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "w", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "height", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "h", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "x", "set the x offset expression for the input image position", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "y", "set the y offset expression for the input image position", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "color", "set the color of the padded area border", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, .flags = FLAGS }, + {NULL} +}; + +AVFILTER_DEFINE_CLASS(pad); + static av_cold int init(AVFilterContext *ctx, const char *args) { PadContext *pad = ctx->priv; - char color_string[128] = "black"; + static const char *shorthand[] = { "width", "height", "x", "y", "color", NULL }; + int ret; - av_strlcpy(pad->w_expr, "iw", sizeof(pad->w_expr)); - av_strlcpy(pad->h_expr, "ih", sizeof(pad->h_expr)); - av_strlcpy(pad->x_expr, "0" , sizeof(pad->w_expr)); - av_strlcpy(pad->y_expr, "0" , sizeof(pad->h_expr)); + pad->class = &pad_class; + av_opt_set_defaults(pad); - if (args) - sscanf(args, "%255[^:]:%255[^:]:%255[^:]:%255[^:]:%127s", - pad->w_expr, pad->h_expr, pad->x_expr, pad->y_expr, color_string); + if ((ret = av_opt_set_from_string(pad, args, shorthand, "=", ":")) < 0) + return ret; - if (av_parse_color(pad->rgba_color, color_string, -1, ctx) < 0) + if (av_parse_color(pad->rgba_color, pad->color_str, -1, ctx) < 0) return AVERROR(EINVAL); return 0; } +static av_cold void uninit(AVFilterContext *ctx) +{ + PadContext *pad = ctx->priv; + av_opt_free(pad); +} + static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; @@ -368,9 +390,11 @@ AVFilter avfilter_vf_pad = { .priv_size = sizeof(PadContext), .init = init, + .uninit = uninit, .query_formats = query_formats, .inputs = avfilter_vf_pad_inputs, .outputs = avfilter_vf_pad_outputs, + .priv_class = &pad_class, }; From 3bba91d32d86cd2446213792fd364ac4daac725c Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Fri, 1 Feb 2013 21:07:59 -0500 Subject: [PATCH 136/182] doc/syntax: fix frame rate documentation This patch corrects a mistake in the documentation and aligns the documentation of frame rates to the values that exist in parseutils.c. Signed-off-by: Stefano Sabatini --- doc/syntax.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/syntax.texi b/doc/syntax.texi index a3aabce1e9..233dd140f7 100644 --- a/doc/syntax.texi +++ b/doc/syntax.texi @@ -187,17 +187,17 @@ The following abbreviations are recognized: @item pal 25/1 @item qntsc -30000/1 +30000/1001 @item qpal 25/1 @item sntsc -30000/1 +30000/1001 @item spal 25/1 @item film 24/1 @item ntsc-film -24000/1 +24000/1001 @end table @anchor{ratio syntax} From fe63f3d301cc2c1537f756a13ae9fdbeafe6bfc9 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Fri, 1 Feb 2013 21:11:34 -0500 Subject: [PATCH 137/182] doc/syntax: add missing frame sizes Adding missing frame sizes used in parseutils.c to the documentation. Signed-off-by: Stefano Sabatini --- doc/syntax.texi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/syntax.texi b/doc/syntax.texi index 233dd140f7..9d3afa3f3d 100644 --- a/doc/syntax.texi +++ b/doc/syntax.texi @@ -112,6 +112,22 @@ Specify the size of the sourced video, it may be a string of the form The following abbreviations are recognized: @table @samp +@item ntsc +720x480 +@item pal +720x576 +@item qntsc +352x240 +@item qpal +352x288 +@item sntsc +640x480 +@item spal +768x576 +@item film +352x240 +@item ntsc-film +352x240 @item sqcif 128x96 @item qcif From 4d37d2bfc53cf8b3eb9a8a2d3b8ab0d4277e5e55 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 Feb 2013 17:20:39 +0100 Subject: [PATCH 138/182] put_vp_no_rnd_pixels8_l2_mmx: fix type Signed-off-by: Michael Niedermayer --- libavcodec/x86/vp3dsp_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/x86/vp3dsp_init.c b/libavcodec/x86/vp3dsp_init.c index 1df570ec0b..288dbcc6f3 100644 --- a/libavcodec/x86/vp3dsp_init.c +++ b/libavcodec/x86/vp3dsp_init.c @@ -64,7 +64,7 @@ void ff_vp3_h_loop_filter_mmxext(uint8_t *src, int stride, "paddb "#regb", "#regr" \n\t" \ "paddb "#regd", "#regp" \n\t" -static void put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h) +static void put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h) { // START_TIMER MOVQ_BFE(mm6); From 773fc6e0c7122740c3dd6530df6406282ced34da Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sun, 3 Feb 2013 17:03:39 +0000 Subject: [PATCH 139/182] lavfi/showspectrum: set default height to 512 Only power-of-two FFTs are supported; so to get a full spectrum (that is, one up to Nyquist), the height must be a power of two. Therefore, change the default height from 480 to 512. Signed-off-by: Rudolf Polzer --- doc/filters.texi | 2 +- libavfilter/avf_showspectrum.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 442fe35466..fdbe3b7671 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6019,7 +6019,7 @@ spectrum. The filter accepts the following named parameters: @table @option @item size, s -Specify the video size for the output. Default value is @code{640x480}. +Specify the video size for the output. Default value is @code{640x512}. @item slide Specify if the spectrum should slide along the window. Default value is @code{0}. diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 977fca92a6..d8aed0d773 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -51,8 +51,8 @@ typedef struct { #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM static const AVOption showspectrum_options[] = { - { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x480"}, 0, 0, FLAGS }, - { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x480"}, 0, 0, FLAGS }, + { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x512"}, 0, 0, FLAGS }, + { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x512"}, 0, 0, FLAGS }, { "slide", "set sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS }, { NULL }, }; From ccfd8cffe867d534447dbc5beb96ff39e65e2791 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 30 Dec 2012 03:13:30 +0100 Subject: [PATCH 140/182] qdm2: Fix data type used in multiplication. Avoid unintended truncation. Fixes CID700555 Signed-off-by: Michael Niedermayer --- libavcodec/qdm2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index ca2aab7b56..9bc0720140 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -685,7 +685,7 @@ static void fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_arra for (j = 0; j < 64; j++) acc += tone_level_idx_temp[ch][sb][j]; - multres = 0x66666667 * (acc * 10); + multres = 0x66666667LL * (acc * 10); esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31); for (ch = 0; ch < nb_channels; ch++) for (sb = 0; sb < 30; sb++) From d106679fb5261914ef92ad8aa01baa80e9911a57 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 30 Dec 2012 03:18:46 +0100 Subject: [PATCH 141/182] qdm2: disable superblocktype_2_3==0 code The code is untested and contained bugs, we need a sample if any files use this branch. Suggested-by: Roberto Togni Signed-off-by: Michael Niedermayer --- libavcodec/qdm2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 9bc0720140..4deea07baf 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -649,7 +649,8 @@ static void fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_arra if (!superblocktype_2_3) { /* This case is untested, no samples available */ - SAMPLES_NEEDED + av_log_ask_for_sample(NULL, "!superblocktype_2_3"); + return; for (ch = 0; ch < nb_channels; ch++) for (sb = 0; sb < 30; sb++) { for (j = 1; j < 63; j++) { // The loop only iterates to 63 so the code doesn't overflow the buffer From 71956371a7bb911dee4b206cd991bbdca2e0fb62 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sun, 3 Feb 2013 22:57:04 +0100 Subject: [PATCH 142/182] lavu/parseutils: add digital cinema frame sizes Signed-off-by: Stefano Sabatini --- doc/syntax.texi | 12 ++++++++++++ libavutil/parseutils.c | 6 ++++++ libavutil/version.h | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/syntax.texi b/doc/syntax.texi index 9d3afa3f3d..4dddc3cbc2 100644 --- a/doc/syntax.texi +++ b/doc/syntax.texi @@ -186,6 +186,18 @@ The following abbreviations are recognized: 1280x720 @item hd1080 1920x1080 +@item 2k +2048x1080 +@item 2kflat +1998x1080 +@item 2kscope +2048x858 +@item 4k +4096x2160 +@item 4kflat +3996x2160 +@item 4kscope +4096x1716 @end table @anchor{video rate syntax} diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index ca40569e6a..73e400ac62 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -109,6 +109,12 @@ static const VideoSizeAbbr video_size_abbrs[] = { { "hd480", 852, 480 }, { "hd720", 1280, 720 }, { "hd1080", 1920,1080 }, + { "2k", 2048,1080 }, /* Digital Cinema System Specification */ + { "2kflat", 1998,1080 }, + { "2kscope", 2048, 858 }, + { "4k", 4096,2160 }, /* Digital Cinema System Specification */ + { "4kflat", 3996,2160 }, + { "4kscope", 4096,1716 }, }; static const VideoRateAbbr video_rate_abbrs[]= { diff --git a/libavutil/version.h b/libavutil/version.h index 2b574f57ff..3d53261291 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -76,7 +76,7 @@ #define LIBAVUTIL_VERSION_MAJOR 52 #define LIBAVUTIL_VERSION_MINOR 17 -#define LIBAVUTIL_VERSION_MICRO 100 +#define LIBAVUTIL_VERSION_MICRO 101 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ From cf7b71b0b812ba5d2b5f0a307b9a427a3db4df0a Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 3 Feb 2013 23:16:20 +0100 Subject: [PATCH 143/182] doc/filters: reformat various filter tables items Improve overall consistency. --- doc/filters.texi | 96 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 32 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index fdbe3b7671..baa344d93d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -301,10 +301,14 @@ Set frequency in Hz. @item width_type Set method to specify band-width of filter. @table @option -@item @var{h} (Hz) -@item @var{q} (Q-Factor) -@item @var{o} (octave) -@item @var{s} (slope) +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope @end table @item width, w @@ -332,10 +336,14 @@ Set number of poles. Default is 2. @item width_type Set method to specify band-width of filter. @table @option -@item @var{h} (Hz) -@item @var{q} (Q-Factor) -@item @var{o} (octave) -@item @var{s} (slope) +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope @end table @item width, w @@ -365,10 +373,14 @@ Set number of poles. Default is 2. @item width_type Set method to specify band-width of filter. @table @option -@item @var{h} (Hz) -@item @var{q} (Q-Factor) -@item @var{o} (octave) -@item @var{s} (slope) +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope @end table @item width, w @@ -402,10 +414,14 @@ The default value is @code{100} Hz. @item width_type Set method to specify band-width of filter. @table @option -@item @var{h} (Hz) -@item @var{q} (Q-Factor) -@item @var{o} (octave) -@item @var{s} (slope) +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope @end table @item width, w @@ -437,10 +453,14 @@ The default value is @code{3000} Hz. @item width_type Set method to specify band-width of filter. @table @option -@item @var{h} (Hz) -@item @var{q} (Q-Factor) -@item @var{o} (octave) -@item @var{s} (slope) +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope @end table @item width, w @@ -470,10 +490,14 @@ Constant skirt gain if set to 1. Defaults to 0. @item width_type Set method to specify band-width of filter. @table @option -@item @var{h} (Hz) -@item @var{q} (Q-Factor) -@item @var{o} (octave) -@item @var{s} (slope) +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope @end table @item width, w @@ -498,10 +522,14 @@ Set the filter's central frequency. Default is @code{3000}. @item width_type Set method to specify band-width of filter. @table @option -@item @var{h} (Hz) -@item @var{q} (Q-Factor) -@item @var{o} (octave) -@item @var{s} (slope) +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope @end table @item width, w @@ -536,10 +564,14 @@ Set the filter's central frequency in Hz. @item width_type Set method to specify band-width of filter. @table @option -@item @var{h} (Hz) -@item @var{q} (Q-Factor) -@item @var{o} (octave) -@item @var{s} (slope) +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope @end table @item width, w From 91debec976d2535e402c8f6326e70589a2776a38 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 4 Feb 2013 03:25:07 +0100 Subject: [PATCH 144/182] swr/resample: fix filter rounding and cliping for s32 Signed-off-by: Michael Niedermayer --- libswresample/resample.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswresample/resample.c b/libswresample/resample.c index d3fe1a7479..fb9da7c354 100644 --- a/libswresample/resample.c +++ b/libswresample/resample.c @@ -142,7 +142,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap break; case AV_SAMPLE_FMT_S32P: for(i=0;i Date: Mon, 4 Feb 2013 03:53:10 +0100 Subject: [PATCH 145/182] swr/resample: fix integer overflow, add missing cast The effects of this are limited to numeric errors in the output Signed-off-by: Michael Niedermayer --- libswresample/resample_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c index b62901d69d..5bc12bcb71 100644 --- a/libswresample/resample_template.c +++ b/libswresample/resample_template.c @@ -151,7 +151,7 @@ int RENAME(swri_resample)(ResampleContext *c, DELEM *dst, const DELEM *src, int break; }else if(sample_index < 0){ for(i=0; ifilter_length; i++) - val += src[FFABS(sample_index + i)] * filter[i]; + val += src[FFABS(sample_index + i)] * (FELEM2)filter[i]; }else if(c->linear){ FELEM2 v2=0; for(i=0; ifilter_length; i++){ From 24244cec2fdd3d3ade79a32d5f0b3ccf5eae01ff Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 4 Feb 2013 03:55:56 +0100 Subject: [PATCH 146/182] swr-test: Fix clip to 32bit Signed-off-by: Michael Niedermayer --- libswresample/swresample-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswresample/swresample-test.c b/libswresample/swresample-test.c index 7f50cb48d0..379d385315 100644 --- a/libswresample/swresample-test.c +++ b/libswresample/swresample-test.c @@ -65,7 +65,7 @@ static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFor switch(f){ case AV_SAMPLE_FMT_U8 : ((uint8_t*)p)[index]= av_clip_uint8 (lrint((v+1.0)*127)); break; case AV_SAMPLE_FMT_S16: ((int16_t*)p)[index]= av_clip_int16 (lrint(v*32767)); break; - case AV_SAMPLE_FMT_S32: ((int32_t*)p)[index]= av_clipl_int32(lrint(v*2147483647)); break; + case AV_SAMPLE_FMT_S32: ((int32_t*)p)[index]= av_clipl_int32(llrint(v*2147483647)); break; case AV_SAMPLE_FMT_FLT: ((float *)p)[index]= v; break; case AV_SAMPLE_FMT_DBL: ((double *)p)[index]= v; break; default: av_assert2(0); From be989f92367839201456c95356f1c4dc13223671 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 4 Feb 2013 04:00:12 +0100 Subject: [PATCH 147/182] swr: reorder init code to make rematrix status available earlier This also makes some other fields available earlier which may be usefull one day Signed-off-by: Michael Niedermayer --- libswresample/swresample.c | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/libswresample/swresample.c b/libswresample/swresample.c index e55f9be150..bb2bf05fbd 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -265,6 +265,33 @@ av_cold int swr_init(struct SwrContext *s){ return AVERROR(EINVAL); } + switch(s->engine){ +#if CONFIG_LIBSOXR + extern struct Resampler const soxr_resampler; + case SWR_ENGINE_SOXR: s->resampler = &soxr_resampler; break; +#endif + case SWR_ENGINE_SWR : s->resampler = &swri_resampler; break; + default: + av_log(s, AV_LOG_ERROR, "Requested resampling engine is unavailable\n"); + return AVERROR(EINVAL); + } + + if(!s->used_ch_count) + s->used_ch_count= s->in.ch_count; + + if(s->used_ch_count && s-> in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){ + av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than the number of used channels, ignoring layout\n"); + s-> in_ch_layout= 0; + } + + if(!s-> in_ch_layout) + s-> in_ch_layout= av_get_default_channel_layout(s->used_ch_count); + if(!s->out_ch_layout) + s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count); + + s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0 || + s->rematrix_custom; + if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){ if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P){ s->int_sample_fmt= AV_SAMPLE_FMT_S16P; @@ -284,17 +311,6 @@ av_cold int swr_init(struct SwrContext *s){ return AVERROR(EINVAL); } - switch(s->engine){ -#if CONFIG_LIBSOXR - extern struct Resampler const soxr_resampler; - case SWR_ENGINE_SOXR: s->resampler = &soxr_resampler; break; -#endif - case SWR_ENGINE_SWR : s->resampler = &swri_resampler; break; - default: - av_log(s, AV_LOG_ERROR, "Requested resampling engine is unavailable\n"); - return AVERROR(EINVAL); - } - set_audiodata_fmt(&s-> in, s-> in_sample_fmt); set_audiodata_fmt(&s->out, s->out_sample_fmt); @@ -326,22 +342,6 @@ av_cold int swr_init(struct SwrContext *s){ return -1; } - if(!s->used_ch_count) - s->used_ch_count= s->in.ch_count; - - if(s->used_ch_count && s-> in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){ - av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than the number of used channels, ignoring layout\n"); - s-> in_ch_layout= 0; - } - - if(!s-> in_ch_layout) - s-> in_ch_layout= av_get_default_channel_layout(s->used_ch_count); - if(!s->out_ch_layout) - s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count); - - s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0 || - s->rematrix_custom; - #define RSC 1 //FIXME finetune if(!s-> in.ch_count) s-> in.ch_count= av_get_channel_layout_nb_channels(s-> in_ch_layout); From b5f544a0f9981ee1676128cb6c3711a2ec80fe1b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 4 Feb 2013 02:36:33 +0100 Subject: [PATCH 148/182] swr: Dont use floats for S32->S32 when possible Signed-off-by: Michael Niedermayer --- libswresample/swresample.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libswresample/swresample.c b/libswresample/swresample.c index bb2bf05fbd..b192bfdfa9 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -295,6 +295,11 @@ av_cold int swr_init(struct SwrContext *s){ if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){ if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P){ s->int_sample_fmt= AV_SAMPLE_FMT_S16P; + }else if( av_get_planar_sample_fmt(s-> in_sample_fmt) == AV_SAMPLE_FMT_S32P + && av_get_planar_sample_fmt(s->out_sample_fmt) == AV_SAMPLE_FMT_S32P + && !s->rematrix + && s->engine != SWR_ENGINE_SOXR){ + s->int_sample_fmt= AV_SAMPLE_FMT_S32P; }else if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_FLTP){ s->int_sample_fmt= AV_SAMPLE_FMT_FLTP; }else{ From d9df93efbf59b1dc8b013d174ca4ad9c634c28f7 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 31 Jan 2013 20:24:06 +0100 Subject: [PATCH 149/182] mpegvideo: simplify REBASE_PICTURE Always evaluate to NULL when the source Picture is not located in the MpegEncContext.picture array. That will only happen for next/last_picture_ptr when updating the thread context during h264 frame threaded decoding, where they will point to elements of ref_list. Since ref_list is not copied during updating the context and is invalid until it is constructed for the current slice, there is no point in doing anything complicated with next/last_picture_ptr, as they will get updated when the ref_list is filled. --- libavcodec/mpegvideo.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 51e422bf61..1294d0c924 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -712,10 +712,10 @@ typedef struct MpegEncContext { int context_reinit; } MpegEncContext; -#define REBASE_PICTURE(pic, new_ctx, old_ctx) (pic ? \ - (pic >= old_ctx->picture && pic < old_ctx->picture+old_ctx->picture_count ?\ - &new_ctx->picture[pic - old_ctx->picture] : (Picture*) ((uint8_t*)pic - (uint8_t*)old_ctx + (uint8_t*)new_ctx))\ - : NULL) +#define REBASE_PICTURE(pic, new_ctx, old_ctx) \ + ((pic && pic >= old_ctx->picture && \ + pic < old_ctx->picture + old_ctx->picture_count) ? \ + &new_ctx->picture[pic - old_ctx->picture] : NULL) /* mpegvideo_enc common options */ #define FF_MPV_FLAG_SKIP_RD 0x0001 From 60f06f986f81c5aa0497c4fa189f50a504896c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Cinquin?= Date: Sun, 3 Feb 2013 23:53:39 -0700 Subject: [PATCH 150/182] libopenjpegenc: make dci compliant j2c Signed-off-by: Michael Bradshaw --- libavcodec/libopenjpegenc.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c index 2bbbae902a..c35508376b 100644 --- a/libavcodec/libopenjpegenc.c +++ b/libavcodec/libopenjpegenc.c @@ -188,6 +188,35 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx) ctx->enc_params.tcp_numlayers = ctx->numlayers; ctx->enc_params.tcp_rates[0] = FFMAX(avctx->compression_level, 0) * 2; + if (ctx->cinema_mode > 0) { + ctx->enc_params.irreversible = 1; + ctx->enc_params.tcp_mct = 1; + ctx->enc_params.tile_size_on = 0; + /* no subsampling */ + ctx->enc_params.cp_tdx=1; + ctx->enc_params.cp_tdy=1; + ctx->enc_params.subsampling_dx = 1; + ctx->enc_params.subsampling_dy = 1; + /* Tile and Image shall be at (0,0) */ + ctx->enc_params.cp_tx0 = 0; + ctx->enc_params.cp_ty0 = 0; + ctx->enc_params.image_offset_x0 = 0; + ctx->enc_params.image_offset_y0 = 0; + /* Codeblock size= 32*32 */ + ctx->enc_params.cblockw_init = 32; + ctx->enc_params.cblockh_init = 32; + ctx->enc_params.csty |= 0x01; + /* No ROI */ + ctx->enc_params.roi_compno = -1; + + if (ctx->enc_params.prog_order != CPRL) { + av_log(avctx, AV_LOG_ERROR, "prog_order forced to CPRL\n"); + ctx->enc_params.prog_order = CPRL; + } + ctx->enc_params.tp_flag = 'C'; + ctx->enc_params.tp_on = 1; + } + ctx->compress = opj_create_compress(ctx->format); if (!ctx->compress) { av_log(avctx, AV_LOG_ERROR, "Error creating the compressor\n"); From 63c61f0be03624fbd9e352d8393122beb3ddcc1a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 4 Feb 2013 14:30:40 +0100 Subject: [PATCH 151/182] vc1dec: Fix 2 "warning: may be used uninitialized in this function" Initialize pointers to NULL for safety Signed-off-by: Michael Niedermayer --- libavcodec/vc1dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 05307c1342..ef763fa675 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -2728,7 +2728,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, MpegEncContext *s = &v->s; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; - int16_t *dc_val; + int16_t *dc_val = NULL; int16_t *ac_val, *ac_val2; int dcdiff; int a_avail = v->a_avail, c_avail = v->c_avail; @@ -2940,7 +2940,7 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, MpegEncContext *s = &v->s; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; - int16_t *dc_val; + int16_t *dc_val = NULL; int16_t *ac_val, *ac_val2; int dcdiff; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; From 353bd158f5d497c9acab98c22d10b99ca92f45d6 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 Feb 2013 20:36:58 +0100 Subject: [PATCH 152/182] sws: Fix "warning: comparison of distinct pointer types lacks a cast" Signed-off-by: Michael Niedermayer --- libswscale/swscale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 4d9bd89ce5..bb908191dc 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -632,8 +632,8 @@ static int swScale(SwsContext *c, const uint8_t *src[], } } } else if (yuv2packedX) { - av_assert1(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize * 2); - av_assert1(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize * 2); + av_assert1(lumSrcPtr + vLumFilterSize - 1 < (const int16_t **)lumPixBuf + vLumBufSize * 2); + av_assert1(chrUSrcPtr + vChrFilterSize - 1 < (const int16_t **)chrUPixBuf + vChrBufSize * 2); if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize <= 2) { // unscaled RGB int chrAlpha = vChrFilterSize == 1 ? 0 : vChrFilter[2 * dstY + 1]; From 81f2549ec9ab236727abe5dfe19d5dfd1478c2b2 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 1 Feb 2013 16:33:17 +0100 Subject: [PATCH 153/182] lavfi/showspectrum: display multiple channels in separate row The showspectrum filter gets multiple channel (any count) support. Signed-off-by: Rudolf Polzer --- Changelog | 1 + doc/filters.texi | 28 ++++ libavfilter/avf_showspectrum.c | 250 ++++++++++++++++++++++++++++----- 3 files changed, 245 insertions(+), 34 deletions(-) diff --git a/Changelog b/Changelog index 01bb42ecc7..5ee9200bca 100644 --- a/Changelog +++ b/Changelog @@ -12,6 +12,7 @@ version : - filtering audio with unknown channel layout - allpass, bass, bandpass, bandreject, biquad, equalizer, highpass, lowpass and treble audio filter +- improved showspectrum filter, with multichannel support and sox-like colors version 1.1: diff --git a/doc/filters.texi b/doc/filters.texi index baa344d93d..37b7a46a9c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6055,6 +6055,34 @@ Specify the video size for the output. Default value is @code{640x512}. @item slide Specify if the spectrum should slide along the window. Default value is @code{0}. +@item mode +Specify display mode. Can be either @code{combined}: all channels are +displayed in the same row, or @code{separate}: all channels are displayed +in separate rows. Default value is @code{combined}. +@item color +Specify display color mode. Can be either @code{channel}: each channel +is displayed in a separate color, or @code{intensity}: each channel is +displayed using the same color scheme. Default value is @code{channel}. +@item scale +Specify scale used for calculating intensity color values. + +It accepts the following values: +@table @option +@item{lin} +linear +@item{sqrt} +square root, default +@item{cbrt} +cubic root +@item{log} +logarithmic +@end table + +@item saturation +Set saturation modifier for displayed colors. Negative values provide +alternative color scheme. @code{0} is no saturation at all. +Saturation must be in [-10.0, 10.0] range. +Default value is @code{1}. @end table The usage is very similar to the showwaves filter; see the examples in that diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index d8aed0d773..4eb973169a 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -27,24 +27,36 @@ #include #include "libavcodec/avfft.h" +#include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavutil/opt.h" #include "avfilter.h" #include "internal.h" +enum DisplayMode { COMBINED, SEPARATE, NB_MODES }; +enum DisplayScale { LINEAR, SQRT, CBRT, LOG, NB_SCALES }; +enum ColorMode { CHANNEL, INTENSITY, NB_CLMODES }; + typedef struct { const AVClass *class; int w, h; AVFilterBufferRef *outpicref; int req_fullfilled; + int nb_display_channels; + int channel_height; int sliding; ///< 1 if sliding mode, 0 otherwise + enum DisplayMode mode; ///< channel display mode + enum ColorMode color_mode; ///< display color scheme + enum DisplayScale scale; + float saturation; ///< color saturation multiplier int xpos; ///< x position (current column) RDFTContext *rdft; ///< Real Discrete Fourier Transform context int rdft_bits; ///< number of bits (RDFT window size = 1<priv; @@ -76,8 +115,12 @@ static av_cold int init(AVFilterContext *ctx, const char *args) static av_cold void uninit(AVFilterContext *ctx) { ShowSpectrumContext *showspectrum = ctx->priv; + int i; + av_freep(&showspectrum->combine_buffer); av_rdft_end(showspectrum->rdft); + for (i = 0; i < showspectrum->nb_display_channels; i++) + av_freep(&showspectrum->rdft_data[i]); av_freep(&showspectrum->rdft_data); av_freep(&showspectrum->window_func_lut); avfilter_unref_bufferp(&showspectrum->outpicref); @@ -90,7 +133,7 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }; - static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE }; + static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_NONE }; /* set input audio formats */ formats = ff_make_format_list(sample_fmts); @@ -120,19 +163,23 @@ static int query_formats(AVFilterContext *ctx) static int config_output(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; + AVFilterLink *inlink = ctx->inputs[0]; ShowSpectrumContext *showspectrum = ctx->priv; - int i, rdft_bits, win_size; + int i, rdft_bits, win_size, h; outlink->w = showspectrum->w; outlink->h = showspectrum->h; + h = (showspectrum->mode == COMBINED) ? outlink->h : outlink->h / inlink->channels; + showspectrum->channel_height = h; + /* RDFT window size (precision) according to the requested output frame height */ - for (rdft_bits = 1; 1<h; rdft_bits++); + for (rdft_bits = 1; 1 << rdft_bits < 2 * h; rdft_bits++); win_size = 1 << rdft_bits; /* (re-)configuration if the video output changed (or first init) */ if (rdft_bits != showspectrum->rdft_bits) { - size_t rdft_size; + size_t rdft_size, rdft_listsize; AVFilterBufferRef *outpicref; av_rdft_end(showspectrum->rdft); @@ -142,12 +189,25 @@ static int config_output(AVFilterLink *outlink) /* RDFT buffers: x2 for each (display) channel buffer. * Note: we use free and malloc instead of a realloc-like function to * make sure the buffer is aligned in memory for the FFT functions. */ + for (i = 0; i < showspectrum->nb_display_channels; i++) + av_freep(&showspectrum->rdft_data[i]); av_freep(&showspectrum->rdft_data); - if (av_size_mult(sizeof(*showspectrum->rdft_data), 2 * win_size, &rdft_size) < 0) + showspectrum->nb_display_channels = inlink->channels; + + if (av_size_mult(sizeof(*showspectrum->rdft_data), + showspectrum->nb_display_channels, &rdft_listsize) < 0) return AVERROR(EINVAL); - showspectrum->rdft_data = av_malloc(rdft_size); + if (av_size_mult(sizeof(**showspectrum->rdft_data), + win_size, &rdft_size) < 0) + return AVERROR(EINVAL); + showspectrum->rdft_data = av_malloc(rdft_listsize); if (!showspectrum->rdft_data) return AVERROR(ENOMEM); + for (i = 0; i < showspectrum->nb_display_channels; i++) { + showspectrum->rdft_data[i] = av_malloc(rdft_size); + if (!showspectrum->rdft_data[i]) + return AVERROR(ENOMEM); + } showspectrum->filled = 0; /* pre-calc windowing function (hann here) */ @@ -173,6 +233,10 @@ static int config_output(AVFilterLink *outlink) if (showspectrum->xpos >= outlink->w) showspectrum->xpos = 0; + showspectrum->combine_buffer = + av_realloc_f(showspectrum->combine_buffer, outlink->h * 3, + sizeof(*showspectrum->combine_buffer)); + av_log(ctx, AV_LOG_VERBOSE, "s:%dx%d RDFT window size:%d\n", showspectrum->w, showspectrum->h, win_size); return 0; @@ -213,62 +277,180 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFilterBufferRef *insampl AVFilterLink *outlink = ctx->outputs[0]; ShowSpectrumContext *showspectrum = ctx->priv; AVFilterBufferRef *outpicref = showspectrum->outpicref; - const int nb_channels = av_get_channel_layout_nb_channels(insamples->audio->channel_layout); /* nb_freq contains the power of two superior or equal to the output image * height (or half the RDFT window size) */ const int nb_freq = 1 << (showspectrum->rdft_bits - 1); const int win_size = nb_freq << 1; + const double w = 1. / (sqrt(nb_freq) * 32768.); - int ch, n, y; - FFTSample *data[2]; - const int nb_display_channels = FFMIN(nb_channels, 2); + int ch, plane, n, y; const int start = showspectrum->filled; const int add_samples = FFMIN(win_size - start, nb_samples); /* fill RDFT input with the number of samples available */ - for (ch = 0; ch < nb_display_channels; ch++) { + for (ch = 0; ch < showspectrum->nb_display_channels; ch++) { const int16_t *p = (int16_t *)insamples->extended_data[ch]; p += showspectrum->consumed; - data[ch] = showspectrum->rdft_data + win_size * ch; // select channel buffer for (n = 0; n < add_samples; n++) - data[ch][start + n] = p[n] * showspectrum->window_func_lut[start + n]; + showspectrum->rdft_data[ch][start + n] = p[n] * showspectrum->window_func_lut[start + n]; } showspectrum->filled += add_samples; /* complete RDFT window size? */ if (showspectrum->filled == win_size) { + /* channel height */ + int h = showspectrum->channel_height; + /* run RDFT on each samples set */ - for (ch = 0; ch < nb_display_channels; ch++) - av_rdft_calc(showspectrum->rdft, data[ch]); + for (ch = 0; ch < showspectrum->nb_display_channels; ch++) + av_rdft_calc(showspectrum->rdft, showspectrum->rdft_data[ch]); /* fill a new spectrum column */ -#define RE(ch) data[ch][2*y + 0] -#define IM(ch) data[ch][2*y + 1] -#define MAGNITUDE(re, im) sqrt((re)*(re) + (im)*(im)) +#define RE(y, ch) showspectrum->rdft_data[ch][2 * y + 0] +#define IM(y, ch) showspectrum->rdft_data[ch][2 * y + 1] +#define MAGNITUDE(y, ch) hypot(RE(y, ch), IM(y, ch)) + /* initialize buffer for combining to black */ for (y = 0; y < outlink->h; y++) { - // FIXME: bin[0] contains first and last bins - uint8_t *p = outpicref->data[0] + (outlink->h - y - 1) * outpicref->linesize[0]; - const double w = 1. / sqrt(nb_freq); - int a = sqrt(w * MAGNITUDE(RE(0), IM(0))); - int b = nb_display_channels > 1 ? sqrt(w * MAGNITUDE(RE(1), IM(1))) : a; + showspectrum->combine_buffer[3 * y ] = 0; + showspectrum->combine_buffer[3 * y + 1] = 127.5; + showspectrum->combine_buffer[3 * y + 2] = 127.5; + } - if (showspectrum->sliding) { - memmove(p, p + 3, (outlink->w - 1) * 3); - p += (outlink->w - 1) * 3; - } else { - p += showspectrum->xpos * 3; + for (ch = 0; ch < showspectrum->nb_display_channels; ch++) { + float yf, uf, vf; + + /* decide color range */ + switch (showspectrum->mode) { + case COMBINED: + // reduce range by channel count + yf = 256.0f / showspectrum->nb_display_channels; + switch (showspectrum->color_mode) { + case INTENSITY: + uf = yf; + vf = yf; + break; + case CHANNEL: + /* adjust saturation for mixed UV coloring */ + /* this factor is correct for infinite channels, an approximation otherwise */ + uf = yf * M_PI; + vf = yf * M_PI; + break; + default: + av_assert0(0); + } + break; + case SEPARATE: + // full range + yf = 256.0f; + uf = 256.0f; + vf = 256.0f; + break; + default: + av_assert0(0); } - a = FFMIN(a, 255); - b = FFMIN(b, 255); - p[0] = a; - p[1] = b; - p[2] = (a + b) / 2; + if (showspectrum->color_mode == CHANNEL) { + if (showspectrum->nb_display_channels > 1) { + uf *= 0.5 * sin((2 * M_PI * ch) / showspectrum->nb_display_channels); + vf *= 0.5 * cos((2 * M_PI * ch) / showspectrum->nb_display_channels); + } else { + uf = 0.0f; + vf = 0.0f; + } + } + uf *= showspectrum->saturation; + vf *= showspectrum->saturation; + + /* draw the channel */ + for (y = 0; y < h; y++) { + int row = (showspectrum->mode == COMBINED) ? y : ch * h + y; + float *out = &showspectrum->combine_buffer[3 * row]; + + /* get magnitude */ + float a = w * MAGNITUDE(y, ch); + + /* apply scale */ + switch (showspectrum->scale) { + case LINEAR: + break; + case SQRT: + a = sqrt(a); + break; + case CBRT: + a = cbrt(a); + break; + case LOG: + a = 1 - log(FFMAX(FFMIN(1, a), 1e-6)) / log(1e-6); // zero = -120dBFS + break; + default: + av_assert0(0); + } + + if (showspectrum->color_mode == INTENSITY) { + float y, u, v; + int i; + + for (i = 1; i < sizeof(intensity_color_table) / sizeof(*intensity_color_table) - 1; i++) + if (intensity_color_table[i].a >= a) + break; + // i now is the first item >= the color + // now we know to interpolate between item i - 1 and i + if (a <= intensity_color_table[i - 1].a) { + y = intensity_color_table[i - 1].y; + u = intensity_color_table[i - 1].u; + v = intensity_color_table[i - 1].v; + } else if (a >= intensity_color_table[i].a) { + y = intensity_color_table[i].y; + u = intensity_color_table[i].u; + v = intensity_color_table[i].v; + } else { + float start = intensity_color_table[i - 1].a; + float end = intensity_color_table[i].a; + float lerpfrac = (a - start) / (end - start); + y = intensity_color_table[i - 1].y * (1.0f - lerpfrac) + + intensity_color_table[i].y * lerpfrac; + u = intensity_color_table[i - 1].u * (1.0f - lerpfrac) + + intensity_color_table[i].u * lerpfrac; + v = intensity_color_table[i - 1].v * (1.0f - lerpfrac) + + intensity_color_table[i].v * lerpfrac; + } + + out[0] += y * yf; + out[1] += u * uf; + out[2] += v * vf; + } else { + out[0] += a * yf; + out[1] += a * uf; + out[2] += a * vf; + } + } } + + /* copy to output */ + if (showspectrum->sliding) { + for (plane = 0; plane < 3; plane++) { + for (y = 0; y < outlink->h; y++) { + uint8_t *p = outpicref->data[plane] + + y * outpicref->linesize[plane]; + memmove(p, p + 1, outlink->w - 1); + } + } + showspectrum->xpos = outlink->w - 1; + } + for (plane = 0; plane < 3; plane++) { + uint8_t *p = outpicref->data[plane] + + (outlink->h - 1) * outpicref->linesize[plane] + + showspectrum->xpos; + for (y = 0; y < outlink->h; y++) { + *p = rint(FFMAX(0, FFMIN(showspectrum->combine_buffer[3 * y + plane], 255))); + p -= outpicref->linesize[plane]; + } + } + outpicref->pts = insamples->pts + av_rescale_q(showspectrum->consumed, (AVRational){ 1, inlink->sample_rate }, From e66240f22e240b0f0d970d1b138db80ceb517097 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 1 Feb 2013 13:14:31 +0100 Subject: [PATCH 154/182] avfilter: x86: consistent filenames for filter optimizations --- libavfilter/x86/Makefile | 8 ++++---- libavfilter/x86/{gradfun.c => vf_gradfun.c} | 0 libavfilter/x86/{hqdn3d.asm => vf_hqdn3d.asm} | 0 libavfilter/x86/{yadif.asm => vf_yadif.asm} | 0 libavfilter/x86/{yadif_init.c => vf_yadif_init.c} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename libavfilter/x86/{gradfun.c => vf_gradfun.c} (100%) rename libavfilter/x86/{hqdn3d.asm => vf_hqdn3d.asm} (100%) rename libavfilter/x86/{yadif.asm => vf_yadif.asm} (100%) rename libavfilter/x86/{yadif_init.c => vf_yadif_init.c} (100%) diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile index af5a9998b5..59cefe8988 100644 --- a/libavfilter/x86/Makefile +++ b/libavfilter/x86/Makefile @@ -1,8 +1,8 @@ -OBJS-$(CONFIG_GRADFUN_FILTER) += x86/gradfun.o +OBJS-$(CONFIG_GRADFUN_FILTER) += x86/vf_gradfun.o OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d_init.o OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume_init.o -OBJS-$(CONFIG_YADIF_FILTER) += x86/yadif_init.o +OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif_init.o -YASM-OBJS-$(CONFIG_HQDN3D_FILTER) += x86/hqdn3d.o +YASM-OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d.o YASM-OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume.o -YASM-OBJS-$(CONFIG_YADIF_FILTER) += x86/yadif.o +YASM-OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif.o diff --git a/libavfilter/x86/gradfun.c b/libavfilter/x86/vf_gradfun.c similarity index 100% rename from libavfilter/x86/gradfun.c rename to libavfilter/x86/vf_gradfun.c diff --git a/libavfilter/x86/hqdn3d.asm b/libavfilter/x86/vf_hqdn3d.asm similarity index 100% rename from libavfilter/x86/hqdn3d.asm rename to libavfilter/x86/vf_hqdn3d.asm diff --git a/libavfilter/x86/yadif.asm b/libavfilter/x86/vf_yadif.asm similarity index 100% rename from libavfilter/x86/yadif.asm rename to libavfilter/x86/vf_yadif.asm diff --git a/libavfilter/x86/yadif_init.c b/libavfilter/x86/vf_yadif_init.c similarity index 100% rename from libavfilter/x86/yadif_init.c rename to libavfilter/x86/vf_yadif_init.c From 96a08d8627301dae41a7697ea4346cc9981df17c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 4 Feb 2013 22:45:47 +0100 Subject: [PATCH 155/182] wmavoice: silence may be used uninitialized warnings Signed-off-by: Michael Niedermayer --- libavcodec/wmavoice.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 8dd3f25052..7ddc434d78 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -1440,8 +1440,8 @@ static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx, float *excitation, float *synth) { WMAVoiceContext *s = ctx->priv_data; - int n, n_blocks_x2, log_n_blocks_x2, cur_pitch_val; - int pitch[MAX_BLOCKS], last_block_pitch; + int n, n_blocks_x2, log_n_blocks_x2, av_uninit(cur_pitch_val); + int pitch[MAX_BLOCKS], av_uninit(last_block_pitch); /* Parse frame type ("frame header"), see frame_descs */ int bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)], block_nsamples; From fc0d069feb690db8d36cb7bcec62891f160d250a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 4 Feb 2013 22:50:16 +0100 Subject: [PATCH 156/182] flacdec: silence several "warning: X may be used uninitialized in this function" Signed-off-by: Michael Niedermayer --- libavcodec/flacdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index eb75729964..0e887e6f89 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -254,7 +254,7 @@ static int decode_subframe_fixed(FLACContext *s, int32_t *decoded, int pred_order, int bps) { const int blocksize = s->blocksize; - int a, b, c, d, i; + int av_uninit(a), av_uninit(b), av_uninit(c), av_uninit(d), i; /* warm up samples */ for (i = 0; i < pred_order; i++) { From 2d22e97f6d7322f964d33ec5c96114b1b3a48922 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 5 Feb 2013 00:01:03 +0100 Subject: [PATCH 157/182] doc/filters: fix @item syntax in showspectrum docs In particular, fix warnings: ** Unknown command with braces `@item' (in doc/filters.texi l. 60XX) --- doc/filters.texi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 37b7a46a9c..c04930f70d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6068,13 +6068,13 @@ Specify scale used for calculating intensity color values. It accepts the following values: @table @option -@item{lin} +@item lin linear -@item{sqrt} +@item sqrt square root, default -@item{cbrt} +@item cbrt cubic root -@item{log} +@item log logarithmic @end table From 0e2b0033f161e9630904221628a1575807851b92 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 5 Feb 2013 00:10:31 +0100 Subject: [PATCH 158/182] doc/filters: apply various rendering changes to the showspectrum docs In particular: always use @table @samp for showing constant tables, add a few empty lines for improving readability, and specify default value when missing. --- doc/filters.texi | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c04930f70d..76a73e6dad 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6052,22 +6052,42 @@ The filter accepts the following named parameters: @table @option @item size, s Specify the video size for the output. Default value is @code{640x512}. + @item slide Specify if the spectrum should slide along the window. Default value is @code{0}. + @item mode -Specify display mode. Can be either @code{combined}: all channels are -displayed in the same row, or @code{separate}: all channels are displayed -in separate rows. Default value is @code{combined}. +Specify display mode. + +It accepts the following values: +@table @samp +@item combined +all channels are displayed in the same row +@item separate +all channels are displayed in separate rows +@end table + +Default value is @samp{combined}. + @item color -Specify display color mode. Can be either @code{channel}: each channel -is displayed in a separate color, or @code{intensity}: each channel is -displayed using the same color scheme. Default value is @code{channel}. +Specify display color mode. + +It accepts the following values: +@table @samp +@item channel +each channel is displayed in a separate color +@item intensity +each channel is is displayed using the same color scheme +@end table + +Default value is @samp{channel}. + @item scale Specify scale used for calculating intensity color values. It accepts the following values: -@table @option +@table @samp @item lin linear @item sqrt @@ -6078,6 +6098,8 @@ cubic root logarithmic @end table +Default value is @samp{sqrt}. + @item saturation Set saturation modifier for displayed colors. Negative values provide alternative color scheme. @code{0} is no saturation at all. From b77d94dc6cc60a8bc512897dc0e55dea78a5c390 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 5 Feb 2013 00:20:58 +0100 Subject: [PATCH 159/182] ffv1enc: check for malloc failure Signed-off-by: Michael Niedermayer --- libavcodec/ffv1enc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 78beb9a47e..a012df334f 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -896,6 +896,8 @@ slices_ok: #define STATS_OUT_SIZE 1024 * 1024 * 6 if (avctx->flags & CODEC_FLAG_PASS1) { avctx->stats_out = av_mallocz(STATS_OUT_SIZE); + if (!avctx->stats_out) + return AVERROR(ENOMEM); for (i = 0; i < s->quant_table_count; i++) for (j = 0; j < s->slice_count; j++) { FFV1Context *sf = s->slice_context[j]; From 5a8311513091ea7277578fbaf189e460dd1d4c7d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 5 Feb 2013 00:22:29 +0100 Subject: [PATCH 160/182] ffv1: check for malloc failure Signed-off-by: Michael Niedermayer --- libavcodec/ffv1.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 074be4cfbb..29d76ed62e 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -123,6 +123,10 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f) int sxe = f->avctx->width * (sx + 1) / f->num_h_slices; int sys = f->avctx->height * sy / f->num_v_slices; int sye = f->avctx->height * (sy + 1) / f->num_v_slices; + + if (!fs) + return AVERROR(ENOMEM); + f->slice_context[i] = fs; memcpy(fs, f, sizeof(*fs)); memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2)); From 708ed15d8ccd5ae3d073cbd4dc69dafccec3fcc7 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 02:48:01 +0100 Subject: [PATCH 161/182] libmpcodecs/vf_stereo3d: update to latest version from mplayer Merged commits: commit 9a2978f37bcdf7a28235c9322e9e5a4fe15e2ff2 Author: cehoyos Date: Thu Jan 31 12:12:36 2013 +0000 Add more vf_stereo3d output formats. Adds high quality green-magenta and yellow-blue dubois anaglyph 3D output support. Patch by thomas schorpp, thomas.schorpp gmail git-svn-id: svn://svn.mplayerhq.hu:/mplayer/trunk@35906 b3059339-0415-0410-9bf9-f77b7e298cf2 commit 2c50e66460d8d3ec460cbf9425f252f75ea1022d Author: reimar Date: Sun Aug 12 17:31:47 2012 +0000 Add another anaglyph color variant. Patch by Bob [mpbob ezpi net]. git-svn-id: svn://svn.mplayerhq.hu:/mplayer/trunk@35080 b3059339-0415-0410-9bf9-f77b7e298cf2 commit 71c5261c2ac63e6e29a5a899b52d1ec4bdb62c4e Author: reimar Date: Sun Aug 12 17:25:30 2012 +0000 Convert comments into designated initializers. That is a simple way to ensure they always correspond to what the compiler actually does. git-svn-id: svn://svn.mplayerhq.hu:/mplayer/trunk@35079 b3059339-0415-0410-9bf9-f77b7e298cf2 commit d7164c5e1ba524c2a6983d979ef57e193b2c8a9f Author: reimar Date: Sun Aug 12 17:20:24 2012 +0000 Make compiler give the ana_coeff array automatically the right size. Makes adding more colour schemes easier. git-svn-id: svn://svn.mplayerhq.hu:/mplayer/trunk@35078 b3059339-0415-0410-9bf9-f77b7e298cf2 Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_stereo3d.c | 54 ++++++++++++++++++++------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/libavfilter/libmpcodecs/vf_stereo3d.c b/libavfilter/libmpcodecs/vf_stereo3d.c index 3dd1df9a66..fe75bd0cc4 100644 --- a/libavfilter/libmpcodecs/vf_stereo3d.c +++ b/libavfilter/libmpcodecs/vf_stereo3d.c @@ -43,9 +43,11 @@ typedef enum stereo_code { ANAGLYPH_GM_GRAY, //anaglyph green/magenta gray ANAGLYPH_GM_HALF, //anaglyph green/magenta half colored ANAGLYPH_GM_COLOR, //anaglyph green/magenta colored + ANAGLYPH_GM_DUBOIS, //anaglyph green/magenta dubois ANAGLYPH_YB_GRAY, //anaglyph yellow/blue gray ANAGLYPH_YB_HALF, //anaglyph yellow/blue half colored ANAGLYPH_YB_COLOR, //anaglyph yellow/blue colored + ANAGLYPH_YB_DUBOIS, //anaglyph yellow/blue dubois MONO_L, //mono output for debugging (left eye only) MONO_R, //mono output for debugging (right eye only) SIDE_BY_SIDE_LR, //side by side parallel (left eye left, right eye right) @@ -72,37 +74,55 @@ typedef struct component { } component; //==global variables==// -static const int ana_coeff[10][3][6] = { - {{19595, 38470, 7471, 0, 0, 0}, //ANAGLYPH_RC_GRAY +static const int ana_coeff[][3][6] = { + [ANAGLYPH_RC_GRAY] = + {{19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 19595, 38470, 7471}, { 0, 0, 0, 19595, 38470, 7471}}, - {{19595, 38470, 7471, 0, 0, 0}, //ANAGLYPH_RC_HALF + [ANAGLYPH_RC_HALF] = + {{19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 0, 65536, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{65536, 0, 0, 0, 0, 0}, //ANAGLYPH_RC_COLOR + [ANAGLYPH_RC_COLOR] = + {{65536, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 65536, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{29891, 32800, 11559, -2849, -5763, -102}, //ANAGLYPH_RC_DUBOIS + [ANAGLYPH_RC_DUBOIS] = + {{29891, 32800, 11559, -2849, -5763, -102}, {-2627, -2479, -1033, 24804, 48080, -1209}, { -997, -1350, -358, -4729, -7403, 80373}}, - {{ 0, 0, 0, 19595, 38470, 7471}, //ANAGLYPH_GM_GRAY + [ANAGLYPH_GM_GRAY] = + {{ 0, 0, 0, 19595, 38470, 7471}, {19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 19595, 38470, 7471}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_GM_HALF + [ANAGLYPH_GM_HALF] = + {{ 0, 0, 0, 65536, 0, 0}, {19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_GM_COLOR + [ANAGLYPH_GM_COLOR] = + {{ 0, 0, 0, 65536, 0, 0}, { 0, 65536, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{ 0, 0, 0, 19595, 38470, 7471}, //ANAGLYPH_YB_GRAY + [ANAGLYPH_GM_DUBOIS] = + {{-4063,-10354, -2556, 34669, 46203, 1573}, + {18612, 43778, 9372, -1049, -983, -4260}, + { -983, -1769, 1376, 590, 4915, 61407}}, + [ANAGLYPH_YB_GRAY] = + {{ 0, 0, 0, 19595, 38470, 7471}, { 0, 0, 0, 19595, 38470, 7471}, {19595, 38470, 7471, 0, 0, 0}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_YB_HALF + [ANAGLYPH_YB_HALF] = + {{ 0, 0, 0, 65536, 0, 0}, { 0, 0, 0, 0, 65536, 0}, {19595, 38470, 7471, 0, 0, 0}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_YB_COLOR + [ANAGLYPH_YB_COLOR] = + {{ 0, 0, 0, 65536, 0, 0}, { 0, 0, 0, 0, 65536, 0}, - { 0, 0, 65536, 0, 0, 0}} + { 0, 0, 65536, 0, 0, 0}}, + [ANAGLYPH_YB_DUBOIS] = + {{65535,-12650,18451, -987, -7590, -1049}, + {-1604, 56032, 4196, 370, 3826, -1049}, + {-2345,-10676, 1358, 5801, 11416, 56217}}, }; struct vf_priv_s { @@ -195,9 +215,11 @@ static int config(struct vf_instance *vf, int width, int height, int d_width, case ANAGLYPH_GM_GRAY: case ANAGLYPH_GM_HALF: case ANAGLYPH_GM_COLOR: + case ANAGLYPH_GM_DUBOIS: case ANAGLYPH_YB_GRAY: case ANAGLYPH_YB_HALF: case ANAGLYPH_YB_COLOR: + case ANAGLYPH_YB_DUBOIS: memcpy(vf->priv->ana_matrix, ana_coeff[vf->priv->out.fmt], sizeof(vf->priv->ana_matrix)); break; @@ -322,9 +344,11 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) case ANAGLYPH_GM_GRAY: case ANAGLYPH_GM_HALF: case ANAGLYPH_GM_COLOR: + case ANAGLYPH_GM_DUBOIS: case ANAGLYPH_YB_GRAY: case ANAGLYPH_YB_HALF: - case ANAGLYPH_YB_COLOR: { + case ANAGLYPH_YB_COLOR: + case ANAGLYPH_YB_DUBOIS: { int i,x,y,il,ir,o; unsigned char *source = mpi->planes[0]; unsigned char *dest = dmpi->planes[0]; @@ -410,12 +434,16 @@ static const struct format_preset { {"anaglyph_green_magenta_half_color",ANAGLYPH_GM_HALF}, {"agmc", ANAGLYPH_GM_COLOR}, {"anaglyph_green_magenta_color", ANAGLYPH_GM_COLOR}, + {"agmd", ANAGLYPH_GM_DUBOIS}, + {"anaglyph_green_magenta_dubois", ANAGLYPH_GM_DUBOIS}, {"aybg", ANAGLYPH_YB_GRAY}, {"anaglyph_yellow_blue_gray", ANAGLYPH_YB_GRAY}, {"aybh", ANAGLYPH_YB_HALF}, {"anaglyph_yellow_blue_half_color", ANAGLYPH_YB_HALF}, {"aybc", ANAGLYPH_YB_COLOR}, {"anaglyph_yellow_blue_color", ANAGLYPH_YB_COLOR}, + {"aybd", ANAGLYPH_YB_DUBOIS}, + {"anaglyph_yellow_blue_dubois", ANAGLYPH_YB_DUBOIS}, {"ml", MONO_L}, {"mono_left", MONO_L}, {"mr", MONO_R}, From 103a2c2b1757ac89c48cb76e5f8b5272d0329521 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 03:23:43 +0100 Subject: [PATCH 162/182] libmpcodecs: update img_format.* & mp_image.* to latest from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/img_format.c | 203 ++++++++++++++++++--------- libavfilter/libmpcodecs/img_format.h | 162 ++++++++++++++++----- libavfilter/libmpcodecs/mp_image.c | 52 ++++++- libavfilter/libmpcodecs/mp_image.h | 9 +- 4 files changed, 314 insertions(+), 112 deletions(-) diff --git a/libavfilter/libmpcodecs/img_format.c b/libavfilter/libmpcodecs/img_format.c index 380f3b0328..61bf898801 100644 --- a/libavfilter/libmpcodecs/img_format.c +++ b/libavfilter/libmpcodecs/img_format.c @@ -19,53 +19,88 @@ #include "config.h" #include "img_format.h" #include "stdio.h" +#include "libavutil/bswap.h" const char *ff_vo_format_name(int format) { static char unknown_format[20]; switch(format) { - case IMGFMT_RGB1: return "RGB 1-bit"; - case IMGFMT_RGB4: return "RGB 4-bit"; - case IMGFMT_RG4B: return "RGB 4-bit per byte"; - case IMGFMT_RGB8: return "RGB 8-bit"; - case IMGFMT_RGB12: return "RGB 12-bit"; - case IMGFMT_RGB15: return "RGB 15-bit"; - case IMGFMT_RGB16: return "RGB 16-bit"; - case IMGFMT_RGB24: return "RGB 24-bit"; -// case IMGFMT_RGB32: return "RGB 32-bit"; + case IMGFMT_RGB1: return "RGB 1-bit"; + case IMGFMT_RGB4: return "RGB 4-bit"; + case IMGFMT_RG4B: return "RGB 4-bit per byte"; + case IMGFMT_RGB8: return "RGB 8-bit"; + case IMGFMT_RGB12: return "RGB 12-bit"; + case IMGFMT_RGB15: return "RGB 15-bit"; + case IMGFMT_RGB16: return "RGB 16-bit"; + case IMGFMT_RGB24: return "RGB 24-bit"; +// case IMGFMT_RGB32: return "RGB 32-bit"; case IMGFMT_RGB48LE: return "RGB 48-bit LE"; case IMGFMT_RGB48BE: return "RGB 48-bit BE"; - case IMGFMT_BGR1: return "BGR 1-bit"; - case IMGFMT_BGR4: return "BGR 4-bit"; - case IMGFMT_BG4B: return "BGR 4-bit per byte"; - case IMGFMT_BGR8: return "BGR 8-bit"; - case IMGFMT_BGR12: return "BGR 12-bit"; - case IMGFMT_BGR15: return "BGR 15-bit"; - case IMGFMT_BGR16: return "BGR 16-bit"; - case IMGFMT_BGR24: return "BGR 24-bit"; -// case IMGFMT_BGR32: return "BGR 32-bit"; - case IMGFMT_ABGR: return "ABGR"; - case IMGFMT_BGRA: return "BGRA"; - case IMGFMT_ARGB: return "ARGB"; - case IMGFMT_RGBA: return "RGBA"; - case IMGFMT_YVU9: return "Planar YVU9"; - case IMGFMT_IF09: return "Planar IF09"; - case IMGFMT_YV12: return "Planar YV12"; - case IMGFMT_I420: return "Planar I420"; - case IMGFMT_IYUV: return "Planar IYUV"; - case IMGFMT_CLPL: return "Planar CLPL"; - case IMGFMT_Y800: return "Planar Y800"; - case IMGFMT_Y8: return "Planar Y8"; + case IMGFMT_RGB64LE: return "RGB 64-bit LE"; + case IMGFMT_RGB64BE: return "RGB 64-bit BE"; + case IMGFMT_BGR1: return "BGR 1-bit"; + case IMGFMT_BGR4: return "BGR 4-bit"; + case IMGFMT_BG4B: return "BGR 4-bit per byte"; + case IMGFMT_BGR8: return "BGR 8-bit"; + case IMGFMT_BGR12: return "BGR 12-bit"; + case IMGFMT_BGR15: return "BGR 15-bit"; + case IMGFMT_BGR16: return "BGR 16-bit"; + case IMGFMT_BGR24: return "BGR 24-bit"; +// case IMGFMT_BGR32: return "BGR 32-bit"; + case IMGFMT_ABGR: return "ABGR"; + case IMGFMT_BGRA: return "BGRA"; + case IMGFMT_ARGB: return "ARGB"; + case IMGFMT_RGBA: return "RGBA"; + case IMGFMT_GBR24P: return "Planar GBR 24-bit"; + case IMGFMT_GBR12P: return "Planar GBR 36-bit"; + case IMGFMT_GBR14P: return "Planar GBR 42-bit"; + case IMGFMT_YVU9: return "Planar YVU9"; + case IMGFMT_IF09: return "Planar IF09"; + case IMGFMT_YV12: return "Planar YV12"; + case IMGFMT_I420: return "Planar I420"; + case IMGFMT_IYUV: return "Planar IYUV"; + case IMGFMT_CLPL: return "Planar CLPL"; + case IMGFMT_Y800: return "Planar Y800"; + case IMGFMT_Y8: return "Planar Y8"; + case IMGFMT_Y8A: return "Planar Y8 with alpha"; + case IMGFMT_Y16_LE: return "Planar Y16 little-endian"; + case IMGFMT_Y16_BE: return "Planar Y16 big-endian"; case IMGFMT_420P16_LE: return "Planar 420P 16-bit little-endian"; case IMGFMT_420P16_BE: return "Planar 420P 16-bit big-endian"; + case IMGFMT_420P14_LE: return "Planar 420P 14-bit little-endian"; + case IMGFMT_420P14_BE: return "Planar 420P 14-bit big-endian"; + case IMGFMT_420P12_LE: return "Planar 420P 12-bit little-endian"; + case IMGFMT_420P12_BE: return "Planar 420P 12-bit big-endian"; + case IMGFMT_420P10_LE: return "Planar 420P 10-bit little-endian"; + case IMGFMT_420P10_BE: return "Planar 420P 10-bit big-endian"; + case IMGFMT_420P9_LE: return "Planar 420P 9-bit little-endian"; + case IMGFMT_420P9_BE: return "Planar 420P 9-bit big-endian"; case IMGFMT_422P16_LE: return "Planar 422P 16-bit little-endian"; case IMGFMT_422P16_BE: return "Planar 422P 16-bit big-endian"; + case IMGFMT_422P14_LE: return "Planar 422P 14-bit little-endian"; + case IMGFMT_422P14_BE: return "Planar 422P 14-bit big-endian"; + case IMGFMT_422P12_LE: return "Planar 422P 12-bit little-endian"; + case IMGFMT_422P12_BE: return "Planar 422P 12-bit big-endian"; + case IMGFMT_422P10_LE: return "Planar 422P 10-bit little-endian"; + case IMGFMT_422P10_BE: return "Planar 422P 10-bit big-endian"; + case IMGFMT_422P9_LE: return "Planar 422P 9-bit little-endian"; + case IMGFMT_422P9_BE: return "Planar 422P 9-bit big-endian"; case IMGFMT_444P16_LE: return "Planar 444P 16-bit little-endian"; case IMGFMT_444P16_BE: return "Planar 444P 16-bit big-endian"; + case IMGFMT_444P14_LE: return "Planar 444P 14-bit little-endian"; + case IMGFMT_444P14_BE: return "Planar 444P 14-bit big-endian"; + case IMGFMT_444P12_LE: return "Planar 444P 12-bit little-endian"; + case IMGFMT_444P12_BE: return "Planar 444P 12-bit big-endian"; + case IMGFMT_444P10_LE: return "Planar 444P 10-bit little-endian"; + case IMGFMT_444P10_BE: return "Planar 444P 10-bit big-endian"; + case IMGFMT_444P9_LE: return "Planar 444P 9-bit little-endian"; + case IMGFMT_444P9_BE: return "Planar 444P 9-bit big-endian"; case IMGFMT_420A: return "Planar 420P with alpha"; case IMGFMT_444P: return "Planar 444P"; + case IMGFMT_444A: return "Planar 444P with alpha"; case IMGFMT_422P: return "Planar 422P"; + case IMGFMT_422A: return "Planar 422P with alpha"; case IMGFMT_411P: return "Planar 411P"; case IMGFMT_NV12: return "Planar NV12"; case IMGFMT_NV21: return "Planar NV21"; @@ -90,33 +125,82 @@ const char *ff_vo_format_name(int format) case IMGFMT_CLJR: return "Packed CLJR"; case IMGFMT_YUVP: return "Packed YUVP"; case IMGFMT_UYVP: return "Packed UYVP"; - case IMGFMT_MPEGPES: return "Mpeg PES"; - case IMGFMT_ZRMJPEGNI: return "Zoran MJPEG non-interlaced"; - case IMGFMT_ZRMJPEGIT: return "Zoran MJPEG top field first"; - case IMGFMT_ZRMJPEGIB: return "Zoran MJPEG bottom field first"; + case IMGFMT_MPEGPES: return "Mpeg PES"; + case IMGFMT_ZRMJPEGNI: return "Zoran MJPEG non-interlaced"; + case IMGFMT_ZRMJPEGIT: return "Zoran MJPEG top field first"; + case IMGFMT_ZRMJPEGIB: return "Zoran MJPEG bottom field first"; case IMGFMT_XVMC_MOCO_MPEG2: return "MPEG1/2 Motion Compensation"; case IMGFMT_XVMC_IDCT_MPEG2: return "MPEG1/2 Motion Compensation and IDCT"; - case IMGFMT_VDPAU_MPEG1: return "MPEG1 VDPAU acceleration"; - case IMGFMT_VDPAU_MPEG2: return "MPEG2 VDPAU acceleration"; - case IMGFMT_VDPAU_H264: return "H.264 VDPAU acceleration"; - case IMGFMT_VDPAU_MPEG4: return "MPEG-4 Part 2 VDPAU acceleration"; - case IMGFMT_VDPAU_WMV3: return "WMV3 VDPAU acceleration"; - case IMGFMT_VDPAU_VC1: return "VC1 VDPAU acceleration"; + case IMGFMT_VDPAU_MPEG1: return "MPEG1 VDPAU acceleration"; + case IMGFMT_VDPAU_MPEG2: return "MPEG2 VDPAU acceleration"; + case IMGFMT_VDPAU_H264: return "H.264 VDPAU acceleration"; + case IMGFMT_VDPAU_MPEG4: return "MPEG-4 Part 2 VDPAU acceleration"; + case IMGFMT_VDPAU_WMV3: return "WMV3 VDPAU acceleration"; + case IMGFMT_VDPAU_VC1: return "VC1 VDPAU acceleration"; } snprintf(unknown_format,20,"Unknown 0x%04x",format); return unknown_format; } -int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift) +int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift, int *component_bits) { int xs = 0, ys = 0; int bpp; - int bpp_factor = 1; int err = 0; - switch (format) { - case IMGFMT_420P16_LE: - case IMGFMT_420P16_BE: - bpp_factor = 2; + int bits = 8; + if ((format & 0xff0000f0) == 0x34000050) + format = av_bswap32(format); + if ((format & 0xf00000ff) == 0x50000034) { + switch (format >> 24) { + case 0x50: + break; + case 0x51: + bits = 16; + break; + case 0x52: + bits = 10; + break; + case 0x53: + bits = 9; + break; + default: + err = 1; + break; + } + switch (format & 0x00ffffff) { + case 0x00343434: // 444 + xs = 0; + ys = 0; + break; + case 0x00323234: // 422 + xs = 1; + ys = 0; + break; + case 0x00303234: // 420 + xs = 1; + ys = 1; + break; + case 0x00313134: // 411 + xs = 2; + ys = 0; + break; + case 0x00303434: // 440 + xs = 0; + ys = 1; + break; + default: + err = 1; + break; + } + } else switch (format) { + case IMGFMT_444A: + xs = 0; + ys = 0; + break; + case IMGFMT_422A: + xs = 1; + ys = 0; + break; case IMGFMT_420A: case IMGFMT_I420: case IMGFMT_IYUV: @@ -129,28 +213,6 @@ int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift) xs = 2; ys = 2; break; - case IMGFMT_444P16_LE: - case IMGFMT_444P16_BE: - bpp_factor = 2; - case IMGFMT_444P: - xs = 0; - ys = 0; - break; - case IMGFMT_422P16_LE: - case IMGFMT_422P16_BE: - bpp_factor = 2; - case IMGFMT_422P: - xs = 1; - ys = 0; - break; - case IMGFMT_411P: - xs = 2; - ys = 0; - break; - case IMGFMT_440P: - xs = 0; - ys = 1; - break; case IMGFMT_Y8: case IMGFMT_Y800: xs = 31; @@ -162,9 +224,10 @@ int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift) } if (x_shift) *x_shift = xs; if (y_shift) *y_shift = ys; + if (component_bits) *component_bits = bits; bpp = 8 + ((16 >> xs) >> ys); - if (format == IMGFMT_420A) + if (format == IMGFMT_420A || format == IMGFMT_422A || format == IMGFMT_444A) bpp += 8; - bpp *= bpp_factor; + bpp *= (bits + 7) >> 3; return err ? 0 : bpp; } diff --git a/libavfilter/libmpcodecs/img_format.h b/libavfilter/libmpcodecs/img_format.h index 6f972b560d..d4d64d8d35 100644 --- a/libavfilter/libmpcodecs/img_format.h +++ b/libavfilter/libmpcodecs/img_format.h @@ -36,55 +36,69 @@ #define IMGFMT_RGB32 (IMGFMT_RGB|32) #define IMGFMT_RGB48LE (IMGFMT_RGB|48) #define IMGFMT_RGB48BE (IMGFMT_RGB|48|128) +#define IMGFMT_RGB64LE (IMGFMT_RGB|64) +#define IMGFMT_RGB64BE (IMGFMT_RGB|64|128) #define IMGFMT_BGR_MASK 0xFFFFFF00 #define IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8)) -#define IMGFMT_BGR1 (IMGFMT_BGR|1) -#define IMGFMT_BGR4 (IMGFMT_BGR|4) +#define IMGFMT_BGR1 (IMGFMT_BGR|1) +#define IMGFMT_BGR4 (IMGFMT_BGR|4) #define IMGFMT_BGR4_CHAR (IMGFMT_BGR|4|128) // BGR4 with 1 pixel per byte -#define IMGFMT_BGR8 (IMGFMT_BGR|8) +#define IMGFMT_BGR8 (IMGFMT_BGR|8) #define IMGFMT_BGR12 (IMGFMT_BGR|12) #define IMGFMT_BGR15 (IMGFMT_BGR|15) #define IMGFMT_BGR16 (IMGFMT_BGR|16) #define IMGFMT_BGR24 (IMGFMT_BGR|24) #define IMGFMT_BGR32 (IMGFMT_BGR|32) +#define IMGFMT_GBR24P (('G'<<24)|('B'<<16)|('R'<<8)|24) +#define IMGFMT_GBR12PLE (('G'<<24)|('B'<<16)|('R'<<8)|36) +#define IMGFMT_GBR12PBE (('G'<<24)|('B'<<16)|('R'<<8)|36|128) +#define IMGFMT_GBR14PLE (('G'<<24)|('B'<<16)|('R'<<8)|42) +#define IMGFMT_GBR14PBE (('G'<<24)|('B'<<16)|('R'<<8)|42|128) + #if HAVE_BIGENDIAN -#define IMGFMT_ABGR IMGFMT_RGB32 -#define IMGFMT_BGRA (IMGFMT_RGB32|64) -#define IMGFMT_ARGB IMGFMT_BGR32 -#define IMGFMT_RGBA (IMGFMT_BGR32|64) +#define IMGFMT_ABGR IMGFMT_RGB32 +#define IMGFMT_BGRA (IMGFMT_RGB32|128) +#define IMGFMT_ARGB IMGFMT_BGR32 +#define IMGFMT_RGBA (IMGFMT_BGR32|128) +#define IMGFMT_RGB64NE IMGFMT_RGB64BE #define IMGFMT_RGB48NE IMGFMT_RGB48BE #define IMGFMT_RGB12BE IMGFMT_RGB12 -#define IMGFMT_RGB12LE (IMGFMT_RGB12|64) +#define IMGFMT_RGB12LE (IMGFMT_RGB12|128) #define IMGFMT_RGB15BE IMGFMT_RGB15 -#define IMGFMT_RGB15LE (IMGFMT_RGB15|64) +#define IMGFMT_RGB15LE (IMGFMT_RGB15|128) #define IMGFMT_RGB16BE IMGFMT_RGB16 -#define IMGFMT_RGB16LE (IMGFMT_RGB16|64) +#define IMGFMT_RGB16LE (IMGFMT_RGB16|128) #define IMGFMT_BGR12BE IMGFMT_BGR12 -#define IMGFMT_BGR12LE (IMGFMT_BGR12|64) +#define IMGFMT_BGR12LE (IMGFMT_BGR12|128) #define IMGFMT_BGR15BE IMGFMT_BGR15 -#define IMGFMT_BGR15LE (IMGFMT_BGR15|64) +#define IMGFMT_BGR15LE (IMGFMT_BGR15|128) #define IMGFMT_BGR16BE IMGFMT_BGR16 -#define IMGFMT_BGR16LE (IMGFMT_BGR16|64) +#define IMGFMT_BGR16LE (IMGFMT_BGR16|128) +#define IMGFMT_GBR12P IMGFMT_GBR12PBE +#define IMGFMT_GBR14P IMGFMT_GBR14PBE #else -#define IMGFMT_ABGR (IMGFMT_BGR32|64) +#define IMGFMT_ABGR (IMGFMT_BGR32|128) #define IMGFMT_BGRA IMGFMT_BGR32 -#define IMGFMT_ARGB (IMGFMT_RGB32|64) +#define IMGFMT_ARGB (IMGFMT_RGB32|128) #define IMGFMT_RGBA IMGFMT_RGB32 +#define IMGFMT_RGB64NE IMGFMT_RGB64LE #define IMGFMT_RGB48NE IMGFMT_RGB48LE -#define IMGFMT_RGB12BE (IMGFMT_RGB12|64) +#define IMGFMT_RGB12BE (IMGFMT_RGB12|128) #define IMGFMT_RGB12LE IMGFMT_RGB12 -#define IMGFMT_RGB15BE (IMGFMT_RGB15|64) +#define IMGFMT_RGB15BE (IMGFMT_RGB15|128) #define IMGFMT_RGB15LE IMGFMT_RGB15 -#define IMGFMT_RGB16BE (IMGFMT_RGB16|64) +#define IMGFMT_RGB16BE (IMGFMT_RGB16|128) #define IMGFMT_RGB16LE IMGFMT_RGB16 -#define IMGFMT_BGR12BE (IMGFMT_BGR12|64) +#define IMGFMT_BGR12BE (IMGFMT_BGR12|128) #define IMGFMT_BGR12LE IMGFMT_BGR12 -#define IMGFMT_BGR15BE (IMGFMT_BGR15|64) +#define IMGFMT_BGR15BE (IMGFMT_BGR15|128) #define IMGFMT_BGR15LE IMGFMT_BGR15 -#define IMGFMT_BGR16BE (IMGFMT_BGR16|64) +#define IMGFMT_BGR16BE (IMGFMT_BGR16|128) #define IMGFMT_BGR16LE IMGFMT_BGR16 +#define IMGFMT_GBR12P IMGFMT_GBR12PLE +#define IMGFMT_GBR14P IMGFMT_GBR14PLE #endif /* old names for compatibility */ @@ -94,8 +108,8 @@ #define IMGFMT_IS_RGB(fmt) (((fmt)&IMGFMT_RGB_MASK)==IMGFMT_RGB) #define IMGFMT_IS_BGR(fmt) (((fmt)&IMGFMT_BGR_MASK)==IMGFMT_BGR) -#define IMGFMT_RGB_DEPTH(fmt) ((fmt)&0x3F) -#define IMGFMT_BGR_DEPTH(fmt) ((fmt)&0x3F) +#define IMGFMT_RGB_DEPTH(fmt) ((fmt)&0x7F) +#define IMGFMT_BGR_DEPTH(fmt) ((fmt)&0x7F) /* Planar YUV Formats */ @@ -110,6 +124,7 @@ #define IMGFMT_Y8 0x20203859 #define IMGFMT_NV12 0x3231564E #define IMGFMT_NV21 0x3132564E +#define IMGFMT_Y16_LE 0x20363159 /* unofficial Planar Formats, FIXME if official 4CC exists */ #define IMGFMT_444P 0x50343434 @@ -117,53 +132,123 @@ #define IMGFMT_411P 0x50313134 #define IMGFMT_440P 0x50303434 #define IMGFMT_HM12 0x32314D48 +#define IMGFMT_Y16_BE 0x59313620 +// Gray with alpha +#define IMGFMT_Y8A 0x59320008 // 4:2:0 planar with alpha #define IMGFMT_420A 0x41303234 +// 4:2:2 planar with alpha +#define IMGFMT_422A 0x41323234 +// 4:4:4 planar with alpha +#define IMGFMT_444A 0x41343434 #define IMGFMT_444P16_LE 0x51343434 #define IMGFMT_444P16_BE 0x34343451 +#define IMGFMT_444P14_LE 0x54343434 +#define IMGFMT_444P14_BE 0x34343454 +#define IMGFMT_444P12_LE 0x55343434 +#define IMGFMT_444P12_BE 0x34343455 +#define IMGFMT_444P10_LE 0x52343434 +#define IMGFMT_444P10_BE 0x34343452 +#define IMGFMT_444P9_LE 0x53343434 +#define IMGFMT_444P9_BE 0x34343453 #define IMGFMT_422P16_LE 0x51323234 #define IMGFMT_422P16_BE 0x34323251 +#define IMGFMT_422P14_LE 0x54323234 +#define IMGFMT_422P14_BE 0x34323254 +#define IMGFMT_422P12_LE 0x55323234 +#define IMGFMT_422P12_BE 0x34323255 +#define IMGFMT_422P10_LE 0x52323234 +#define IMGFMT_422P10_BE 0x34323252 +#define IMGFMT_422P9_LE 0x53323234 +#define IMGFMT_422P9_BE 0x34323253 #define IMGFMT_420P16_LE 0x51303234 #define IMGFMT_420P16_BE 0x34323051 +#define IMGFMT_420P14_LE 0x54303234 +#define IMGFMT_420P14_BE 0x34323054 +#define IMGFMT_420P12_LE 0x55303234 +#define IMGFMT_420P12_BE 0x34323055 +#define IMGFMT_420P10_LE 0x52303234 +#define IMGFMT_420P10_BE 0x34323052 +#define IMGFMT_420P9_LE 0x53303234 +#define IMGFMT_420P9_BE 0x34323053 #if HAVE_BIGENDIAN #define IMGFMT_444P16 IMGFMT_444P16_BE +#define IMGFMT_444P14 IMGFMT_444P14_BE +#define IMGFMT_444P12 IMGFMT_444P12_BE +#define IMGFMT_444P10 IMGFMT_444P10_BE +#define IMGFMT_444P9 IMGFMT_444P9_BE #define IMGFMT_422P16 IMGFMT_422P16_BE +#define IMGFMT_422P14 IMGFMT_422P14_BE +#define IMGFMT_422P12 IMGFMT_422P12_BE +#define IMGFMT_422P10 IMGFMT_422P10_BE +#define IMGFMT_422P9 IMGFMT_422P9_BE #define IMGFMT_420P16 IMGFMT_420P16_BE +#define IMGFMT_420P14 IMGFMT_420P14_BE +#define IMGFMT_420P12 IMGFMT_420P12_BE +#define IMGFMT_420P10 IMGFMT_420P10_BE +#define IMGFMT_420P9 IMGFMT_420P9_BE +#define IMGFMT_Y16 IMGFMT_Y16_BE +#define IMGFMT_IS_YUVP16_NE(fmt) IMGFMT_IS_YUVP16_BE(fmt) #else #define IMGFMT_444P16 IMGFMT_444P16_LE +#define IMGFMT_444P14 IMGFMT_444P14_LE +#define IMGFMT_444P12 IMGFMT_444P12_LE +#define IMGFMT_444P10 IMGFMT_444P10_LE +#define IMGFMT_444P9 IMGFMT_444P9_LE #define IMGFMT_422P16 IMGFMT_422P16_LE +#define IMGFMT_422P14 IMGFMT_422P14_LE +#define IMGFMT_422P12 IMGFMT_422P12_LE +#define IMGFMT_422P10 IMGFMT_422P10_LE +#define IMGFMT_422P9 IMGFMT_422P9_LE #define IMGFMT_420P16 IMGFMT_420P16_LE +#define IMGFMT_420P14 IMGFMT_420P14_LE +#define IMGFMT_420P12 IMGFMT_420P12_LE +#define IMGFMT_420P10 IMGFMT_420P10_LE +#define IMGFMT_420P9 IMGFMT_420P9_LE +#define IMGFMT_Y16 IMGFMT_Y16_LE +#define IMGFMT_IS_YUVP16_NE(fmt) IMGFMT_IS_YUVP16_LE(fmt) #endif -#define IMGFMT_IS_YUVP16_LE(fmt) (((fmt ^ IMGFMT_420P16_LE) & 0xff0000ff) == 0) -#define IMGFMT_IS_YUVP16_BE(fmt) (((fmt ^ IMGFMT_420P16_BE) & 0xff0000ff) == 0) -#define IMGFMT_IS_YUVP16_NE(fmt) (((fmt ^ IMGFMT_420P16 ) & 0xff0000ff) == 0) +#define IMGFMT_IS_YUVP16_LE(fmt) (((fmt - 0x51000034) & 0xfc0000ff) == 0) +#define IMGFMT_IS_YUVP16_BE(fmt) (((fmt - 0x34000051) & 0xff0000fc) == 0) #define IMGFMT_IS_YUVP16(fmt) (IMGFMT_IS_YUVP16_LE(fmt) || IMGFMT_IS_YUVP16_BE(fmt)) +/** + * \brief Find the corresponding full 16 bit format, i.e. IMGFMT_420P10_LE -> IMGFMT_420P16_LE + * \return normalized format ID or 0 if none exists. + */ +static inline int normalize_yuvp16(int fmt) { + if (IMGFMT_IS_YUVP16_LE(fmt)) + return (fmt & 0x00ffffff) | 0x51000000; + if (IMGFMT_IS_YUVP16_BE(fmt)) + return (fmt & 0xffffff00) | 0x00000051; + return 0; +} + /* Packed YUV Formats */ -#define IMGFMT_IUYV 0x56595549 -#define IMGFMT_IY41 0x31435949 +#define IMGFMT_IUYV 0x56595549 // Interlaced UYVY +#define IMGFMT_IY41 0x31435949 // Interlaced Y41P #define IMGFMT_IYU1 0x31555949 #define IMGFMT_IYU2 0x32555949 #define IMGFMT_UYVY 0x59565955 -#define IMGFMT_UYNV 0x564E5955 -#define IMGFMT_cyuv 0x76757963 -#define IMGFMT_Y422 0x32323459 +#define IMGFMT_UYNV 0x564E5955 // Exactly same as UYVY +#define IMGFMT_cyuv 0x76757963 // upside-down UYVY +#define IMGFMT_Y422 0x32323459 // Exactly same as UYVY #define IMGFMT_YUY2 0x32595559 -#define IMGFMT_YUNV 0x564E5559 +#define IMGFMT_YUNV 0x564E5559 // Exactly same as YUY2 #define IMGFMT_YVYU 0x55595659 #define IMGFMT_Y41P 0x50313459 #define IMGFMT_Y211 0x31313259 -#define IMGFMT_Y41T 0x54313459 -#define IMGFMT_Y42T 0x54323459 -#define IMGFMT_V422 0x32323456 +#define IMGFMT_Y41T 0x54313459 // Y41P, Y lsb = transparency +#define IMGFMT_Y42T 0x54323459 // UYVY, Y lsb = transparency +#define IMGFMT_V422 0x32323456 // upside-down UYVY? #define IMGFMT_V655 0x35353656 #define IMGFMT_CLJR 0x524A4C43 -#define IMGFMT_YUVP 0x50565559 -#define IMGFMT_UYVP 0x50565955 +#define IMGFMT_YUVP 0x50565559 // 10-bit YUYV +#define IMGFMT_UYVP 0x50565955 // 10-bit UYVY /* Compressed Formats */ #define IMGFMT_MPEGPES (('M'<<24)|('P'<<16)|('E'<<8)|('S')) @@ -207,8 +292,9 @@ const char *ff_vo_format_name(int format); /** * Calculates the scale shifts for the chroma planes for planar YUV * + * \param component_bits bits per component * \return bits-per-pixel for format if successful (i.e. format is 3 or 4-planes planar YUV), 0 otherwise */ -int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift); +int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift, int *component_bits); #endif /* MPLAYER_IMG_FORMAT_H */ diff --git a/libavfilter/libmpcodecs/mp_image.c b/libavfilter/libmpcodecs/mp_image.c index 1ef5cbd55b..33d5c07730 100644 --- a/libavfilter/libmpcodecs/mp_image.c +++ b/libavfilter/libmpcodecs/mp_image.c @@ -121,11 +121,24 @@ void ff_mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ mpi->flags|=MP_IMGFLAG_SWAPPED; return; } - mpi->flags|=MP_IMGFLAG_YUV; mpi->num_planes=3; - if (ff_mp_get_chroma_shift(out_fmt, NULL, NULL)) { + if (out_fmt == IMGFMT_GBR24P) { + mpi->bpp=24; mpi->flags|=MP_IMGFLAG_PLANAR; - mpi->bpp = ff_mp_get_chroma_shift(out_fmt, &mpi->chroma_x_shift, &mpi->chroma_y_shift); + return; + } else if (out_fmt == IMGFMT_GBR12P) { + mpi->bpp=36; + mpi->flags|=MP_IMGFLAG_PLANAR; + return; + } else if (out_fmt == IMGFMT_GBR14P) { + mpi->bpp=42; + mpi->flags|=MP_IMGFLAG_PLANAR; + return; + } + mpi->flags|=MP_IMGFLAG_YUV; + if (ff_mp_get_chroma_shift(out_fmt, NULL, NULL, NULL)) { + mpi->flags|=MP_IMGFLAG_PLANAR; + mpi->bpp = ff_mp_get_chroma_shift(out_fmt, &mpi->chroma_x_shift, &mpi->chroma_y_shift, NULL); mpi->chroma_width = mpi->width >> mpi->chroma_x_shift; mpi->chroma_height = mpi->height >> mpi->chroma_y_shift; } @@ -136,6 +149,8 @@ void ff_mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ case IMGFMT_YV12: return; case IMGFMT_420A: + case IMGFMT_422A: + case IMGFMT_444A: case IMGFMT_IF09: mpi->num_planes=4; case IMGFMT_YVU9: @@ -145,20 +160,51 @@ void ff_mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ case IMGFMT_440P: case IMGFMT_444P16_LE: case IMGFMT_444P16_BE: + case IMGFMT_444P14_LE: + case IMGFMT_444P14_BE: + case IMGFMT_444P12_LE: + case IMGFMT_444P12_BE: + case IMGFMT_444P10_LE: + case IMGFMT_444P10_BE: + case IMGFMT_444P9_LE: + case IMGFMT_444P9_BE: case IMGFMT_422P16_LE: case IMGFMT_422P16_BE: + case IMGFMT_422P14_LE: + case IMGFMT_422P14_BE: + case IMGFMT_422P12_LE: + case IMGFMT_422P12_BE: + case IMGFMT_422P10_LE: + case IMGFMT_422P10_BE: + case IMGFMT_422P9_LE: + case IMGFMT_422P9_BE: case IMGFMT_420P16_LE: case IMGFMT_420P16_BE: + case IMGFMT_420P14_LE: + case IMGFMT_420P14_BE: + case IMGFMT_420P12_LE: + case IMGFMT_420P12_BE: + case IMGFMT_420P10_LE: + case IMGFMT_420P10_BE: + case IMGFMT_420P9_LE: + case IMGFMT_420P9_BE: return; + case IMGFMT_Y16_LE: + case IMGFMT_Y16_BE: + mpi->bpp=16; case IMGFMT_Y800: case IMGFMT_Y8: /* they're planar ones, but for easier handling use them as packed */ mpi->flags&=~MP_IMGFLAG_PLANAR; mpi->num_planes=1; return; + case IMGFMT_Y8A: + mpi->num_planes=2; + return; case IMGFMT_UYVY: mpi->flags|=MP_IMGFLAG_SWAPPED; case IMGFMT_YUY2: + mpi->chroma_x_shift = 1; mpi->bpp=16; mpi->num_planes=1; return; diff --git a/libavfilter/libmpcodecs/mp_image.h b/libavfilter/libmpcodecs/mp_image.h index d658ab03f1..35b50a60f1 100644 --- a/libavfilter/libmpcodecs/mp_image.h +++ b/libavfilter/libmpcodecs/mp_image.h @@ -42,7 +42,14 @@ //--- buffer content restrictions: // set if buffer content shouldn't be modified: #define MP_IMGFLAG_PRESERVE 0x01 -// set if buffer content will be READ for next frame's MC: (I/P mpeg frames) +// set if buffer content will be READ. +// This can be e.g. for next frame's MC: (I/P mpeg frames) - +// then in combination with MP_IMGFLAG_PRESERVE - or it +// can be because a video filter or codec will read a significant +// amount of data while processing that frame (e.g. blending something +// onto the frame, MV based intra prediction). +// A frame marked like this should not be placed in to uncachable +// video RAM for example. #define MP_IMGFLAG_READABLE 0x02 //--- buffer width/stride/plane restrictions: (used for direct rendering) From a54737f7ead000c6e7f97e176652724437ba8aa1 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 12:54:15 +0100 Subject: [PATCH 163/182] libmpcodecs/cpudetect: update to latest from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/cpudetect.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavfilter/libmpcodecs/cpudetect.h b/libavfilter/libmpcodecs/cpudetect.h index c0bb7b763b..710f6e6513 100644 --- a/libavfilter/libmpcodecs/cpudetect.h +++ b/libavfilter/libmpcodecs/cpudetect.h @@ -19,8 +19,6 @@ #ifndef MPLAYER_CPUDETECT_H #define MPLAYER_CPUDETECT_H -//#include "config.h" - #define CPUTYPE_I386 3 #define CPUTYPE_I486 4 #define CPUTYPE_I586 5 @@ -40,7 +38,10 @@ typedef struct cpucaps_s { int hasSSE2; int hasSSE3; int hasSSSE3; + int hasSSE4; + int hasSSE42; int hasSSE4a; + int hasAVX; int isX86; unsigned cl_size; /* size of cache line */ int hasAltiVec; From 745cb39d05580c046b1b12c4f9fb84a42eeec1f4 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 12:58:20 +0100 Subject: [PATCH 164/182] libmpcodecs/help_mp: update to latest from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/help_mp.h | 304 +++++++++++++++--------------- 1 file changed, 147 insertions(+), 157 deletions(-) diff --git a/libavfilter/libmpcodecs/help_mp.h b/libavfilter/libmpcodecs/help_mp.h index 87b828d933..6ceb6301f3 100644 --- a/libavfilter/libmpcodecs/help_mp.h +++ b/libavfilter/libmpcodecs/help_mp.h @@ -70,12 +70,14 @@ static const char help_text[]= #define MSGTR_NoHomeDir "Cannot find HOME directory.\n" #define MSGTR_GetpathProblem "get_path(\"config\") problem\n" #define MSGTR_CreatingCfgFile "Creating config file: %s\n" -#define MSGTR_BuiltinCodecsConf "Using built-in default codecs.conf.\n" -#define MSGTR_CantLoadFont "Cannot load bitmap font: %s\n" -#define MSGTR_CantLoadSub "Cannot load subtitles: %s\n" +#define MSGTR_CantLoadFont "Cannot load bitmap font '%s'.\n" +#define MSGTR_CantLoadSub "Cannot load subtitles '%s'.\n" #define MSGTR_DumpSelectedStreamMissing "dump: FATAL: Selected stream missing!\n" #define MSGTR_CantOpenDumpfile "Cannot open dump file.\n" #define MSGTR_CoreDumped "Core dumped ;)\n" +#define MSGTR_DumpBytesWrittenPercent "dump: %"PRIu64" bytes written (~%.1f%%)\r" +#define MSGTR_DumpBytesWritten "dump: %"PRIu64" bytes written\r" +#define MSGTR_DumpBytesWrittenTo "dump: %"PRIu64" bytes written to '%s'.\n" #define MSGTR_FPSnotspecified "FPS not specified in the header or invalid, use the -fps option.\n" #define MSGTR_TryForceAudioFmtStr "Trying to force audio codec driver family %s...\n" #define MSGTR_CantFindAudioCodec "Cannot find codec for audio format 0x%X.\n" @@ -112,8 +114,6 @@ static const char help_text[]= #define MSGTR_Playing "\nPlaying %s.\n" #define MSGTR_NoSound "Audio: no sound\n" #define MSGTR_FPSforced "FPS forced to be %5.3f (ftime: %5.3f).\n" -#define MSGTR_CompiledWithRuntimeDetection "Compiled with runtime CPU detection.\n" -#define MSGTR_CompiledWithCPUExtensions "Compiled for x86 CPU with extensions:" #define MSGTR_AvailableVideoOutputDrivers "Available video output drivers:\n" #define MSGTR_AvailableAudioOutputDrivers "Available audio output drivers:\n" #define MSGTR_AvailableAudioCodecs "Available audio codecs:\n" @@ -121,7 +121,6 @@ static const char help_text[]= #define MSGTR_AvailableAudioFm "Available (compiled-in) audio codec families/drivers:\n" #define MSGTR_AvailableVideoFm "Available (compiled-in) video codec families/drivers:\n" #define MSGTR_AvailableFsType "Available fullscreen layer change modes:\n" -#define MSGTR_UsingRTCTiming "Using Linux hardware RTC timing (%ldHz).\n" #define MSGTR_CannotReadVideoProperties "Video: Cannot read properties.\n" #define MSGTR_NoStreamFound "No stream found.\n" #define MSGTR_ErrorInitializingVODevice "Error opening/initializing the selected video_out (-vo) device.\n" @@ -129,7 +128,7 @@ static const char help_text[]= #define MSGTR_ForcedAudioCodec "Forced audio codec: %s\n" #define MSGTR_Video_NoVideo "Video: no video\n" #define MSGTR_NotInitializeVOPorVO "\nFATAL: Could not initialize video filters (-vf) or video output (-vo).\n" -#define MSGTR_Paused "\n ===== PAUSE =====\r" // no more than 23 characters (status line for audio files) +#define MSGTR_Paused " ===== PAUSE =====" // no more than 23 characters (status line for audio files) #define MSGTR_PlaylistLoadUnable "\nUnable to load playlist %s.\n" #define MSGTR_Exit_SIGILL_RTCpuSel \ "- MPlayer crashed by an 'Illegal Instruction'.\n"\ @@ -156,15 +155,11 @@ static const char help_text[]= #define MSGTR_AddedSubtitleFile "SUB: Added subtitle file (%d): %s\n" #define MSGTR_RemovedSubtitleFile "SUB: Removed subtitle file (%d): %s\n" #define MSGTR_ErrorOpeningOutputFile "Error opening file [%s] for writing!\n" -#define MSGTR_CommandLine "CommandLine:" #define MSGTR_RTCDeviceNotOpenable "Failed to open %s: %s (it should be readable by the user.)\n" #define MSGTR_LinuxRTCInitErrorIrqpSet "Linux RTC init error in ioctl (rtc_irqp_set %lu): %s\n" #define MSGTR_IncreaseRTCMaxUserFreq "Try adding \"echo %lu > /proc/sys/dev/rtc/max-user-freq\" to your system startup scripts.\n" #define MSGTR_LinuxRTCInitErrorPieOn "Linux RTC init error in ioctl (rtc_pie_on): %s\n" #define MSGTR_UsingTimingType "Using %s timing.\n" -#define MSGTR_NoIdleAndGui "The -idle option cannot be used with GMPlayer.\n" -#define MSGTR_MenuInitialized "Menu initialized: %s\n" -#define MSGTR_MenuInitFailed "Menu init failed.\n" #define MSGTR_Getch2InitializedTwice "WARNING: getch2_init called twice!\n" #define MSGTR_DumpstreamFdUnavailable "Cannot dump this stream - no file descriptor available.\n" #define MSGTR_CantOpenLibmenuFilterWithThisRootMenu "Can't open libmenu video filter with root menu %s.\n" @@ -188,6 +183,17 @@ static const char help_text[]= #define MSGTR_MenuCall "Menu call\n" #define MSGTR_MasterQuit "Option -udp-slave: exiting because master exited\n" #define MSGTR_InvalidIP "Option -udp-ip: invalid IP address\n" +#define MSGTR_Forking "Forking...\n" +#define MSGTR_Forked "Forked...\n" +#define MSGTR_CouldntStartGdb "Couldn't start gdb\n" +#define MSGTR_CouldntFork "Couldn't fork\n" +#define MSGTR_FilenameTooLong "Filename is too long, can not load file or directory specific config files\n" +#define MSGTR_AudioDeviceStuck "Audio device got stuck!\n" +#define MSGTR_AudioOutputTruncated "Audio output truncated at end.\n" +#define MSGTR_ASSCannotAddVideoFilter "ASS: cannot add video filter\n" +#define MSGTR_PtsAfterFiltersMissing "pts after filters MISSING\n" +#define MSGTR_CommandLine "CommandLine:" +#define MSGTR_MenuInitFailed "Menu init failed.\n" // --- edit decision lists #define MSGTR_EdlOutOfMem "Can't allocate enough memory to hold EDL data.\n" @@ -205,7 +211,6 @@ static const char help_text[]= #define MSGTR_EdloutBadStop "EDL skip canceled, last start > stop\n" #define MSGTR_EdloutStartSkip "EDL skip start, press 'i' again to end block.\n" #define MSGTR_EdloutEndSkip "EDL skip end, line written.\n" -#define MSGTR_MPEndposNoSizeBased "Option -endpos in MPlayer does not yet support size units.\n" // mplayer.c OSD #define MSGTR_OSDenabled "enabled" @@ -219,6 +224,8 @@ static const char help_text[]= #define MSGTR_OSDChapter "Chapter: (%d) %s" #define MSGTR_OSDAngle "Angle: %d/%d" #define MSGTR_OSDDeinterlace "Deinterlace: %s" +#define MSGTR_OSDCapturing "Capturing: %s" +#define MSGTR_OSDCapturingFailure "Capturing failed" // property values #define MSGTR_Enabled "enabled" @@ -298,12 +305,9 @@ static const char help_text[]= #define MSGTR_CannotAllocateBytes "Couldn't allocate %d bytes.\n" #define MSGTR_SettingAudioDelay "Setting audio delay to %5.3fs.\n" #define MSGTR_SettingVideoDelay "Setting video delay to %5.3fs.\n" -#define MSGTR_SettingAudioInputGain "Setting audio input gain to %f.\n" -#define MSGTR_LamePresetEquals "\npreset=%s\n\n" #define MSGTR_LimitingAudioPreload "Limiting audio preload to 0.4s.\n" #define MSGTR_IncreasingAudioDensity "Increasing audio density to 4.\n" #define MSGTR_ZeroingAudioPreloadAndMaxPtsCorrection "Forcing audio preload to 0, max pts correction to 0.\n" -#define MSGTR_CBRAudioByterate "\n\nCBR audio: %d bytes/sec, %d bytes/block\n" #define MSGTR_LameVersion "LAME version %s (%s)\n\n" #define MSGTR_InvalidBitrateForLamePreset "Error: The bitrate specified is out of the valid range for this preset.\n"\ "\n"\ @@ -411,7 +415,7 @@ static const char help_text[]= "Cannot set LAME options, check bitrate/samplerate, some very low bitrates\n"\ "(<32) need lower samplerates (i.e. -srate 8000).\n"\ "If everything else fails, try a preset." -#define MSGTR_ConfigFileError "config file error" +#define MSGTR_ConfigFileError "Config file error" #define MSGTR_ErrorParsingCommandLine "error parsing command line" #define MSGTR_VideoStreamRequired "Video stream is mandatory!\n" #define MSGTR_ForcingInputFPS "Input fps will be interpreted as %5.3f instead.\n" @@ -490,8 +494,6 @@ static const char help_text[]= #define MSGTR_CodecNeedsOutfmt "\ncodec(%s) needs an 'outfmt'!\n" #define MSGTR_CantAllocateComment "Can't allocate memory for comment. " #define MSGTR_GetTokenMaxNotLessThanMAX_NR_TOKEN "get_token(): max >= MAX_MR_TOKEN!" -#define MSGTR_ReadingFile "Reading %s: " -#define MSGTR_CantOpenFileError "Can't open '%s': %s\n" #define MSGTR_CantGetMemoryForLine "Can't get memory for 'line': %s\n" #define MSGTR_CantReallocCodecsp "Can't realloc '*codecsp': %s\n" #define MSGTR_CodecNameNotUnique "Codec name '%s' isn't unique." @@ -557,10 +559,40 @@ static const char help_text[]= #define MSGTR_Preferences "Preferences" #define MSGTR_AudioPreferences "Audio driver configuration" #define MSGTR_NoMediaOpened "No media opened." -#define MSGTR_VCDTrack "VCD track %d" +#define MSGTR_Title "Title %d" #define MSGTR_NoChapter "No chapter" #define MSGTR_Chapter "Chapter %d" #define MSGTR_NoFileLoaded "No file loaded." +#define MSGTR_Filter_UTF8Subtitles "UTF-8 encoded subtitles (*.utf, *.utf-8, *.utf8)" +#define MSGTR_Filter_AllSubtitles "All subtitles" +#define MSGTR_Filter_AllFiles "All files" +#define MSGTR_Filter_TTF "True Type fonts (*.ttf)" +#define MSGTR_Filter_Type1 "Type1 fonts (*.pfb)" +#define MSGTR_Filter_AllFonts "All fonts" +#define MSGTR_Filter_FontFiles "Font files (*.desc)" +#define MSGTR_Filter_DDRawAudio "Dolby Digital / PCM (*.ac3, *.pcm)" +#define MSGTR_Filter_MPEGAudio "MPEG audio (*.mp2, *.mp3, *.mpga, *.m4a, *.aac, *.f4a)" +#define MSGTR_Filter_MatroskaAudio "Matroska audio (*.mka)" +#define MSGTR_Filter_OGGAudio "Ogg audio (*.oga, *.ogg, *.spx)" +#define MSGTR_Filter_WAVAudio "WAV audio (*.wav)" +#define MSGTR_Filter_WMAAudio "Windows Media audio (*.wma)" +#define MSGTR_Filter_AllAudioFiles "All audio files" +#define MSGTR_Filter_AllVideoFiles "All video files" +#define MSGTR_Filter_AVIFiles "AVI files" +#define MSGTR_Filter_DivXFiles "DivX files" +#define MSGTR_Filter_FlashVideo "Flash Video" +#define MSGTR_Filter_MP3Files "MP3 files" +#define MSGTR_Filter_MP4Files "MP4 files" +#define MSGTR_Filter_MPEGFiles "MPEG files" +#define MSGTR_Filter_MP2TS "MPEG-2 transport streams" +#define MSGTR_Filter_MatroskaMedia "Matroska media" +#define MSGTR_Filter_OGGMedia "Ogg media" +#define MSGTR_Filter_QTMedia "QuickTime media" +#define MSGTR_Filter_RNMedia "RealNetworks media" +#define MSGTR_Filter_VideoCDImages "VCD/SVCD images" +#define MSGTR_Filter_WAVFiles "WAV files" +#define MSGTR_Filter_WindowsMedia "Windows media" +#define MSGTR_Filter_Playlists "Playlists" // --- buttons --- #define MSGTR_Ok "OK" @@ -573,43 +605,43 @@ static const char help_text[]= #define MSGTR_Browse "Browse" // --- error messages --- -#define MSGTR_NEMDB "Sorry, not enough memory to draw buffer." +#define MSGTR_NEMDB "Sorry, not enough memory to draw buffer.\n" #define MSGTR_NEMFMR "Sorry, not enough memory for menu rendering." -#define MSGTR_IDFGCVD "Sorry, I did not find a GUI-compatible video output driver." +#define MSGTR_IDFGCVD "Sorry, no GUI-compatible video output driver found.\n" #define MSGTR_NEEDLAVC "Sorry, you cannot play non-MPEG files with your DXR3/H+ device without reencoding.\nPlease enable lavc in the DXR3/H+ configuration box." -#define MSGTR_UNKNOWNWINDOWTYPE "Unknown window type found ..." +#define MSGTR_ICONERROR "Icon '%s' (size %d) not found or unsupported format.\n" // --- skin loader error messages -#define MSGTR_SKIN_ERRORMESSAGE "[skin] error in skin config file on line %d: %s" -#define MSGTR_SKIN_WARNING1 "[skin] warning: in config file line %d:\nwidget (%s) found but no \"section\" found before" -#define MSGTR_SKIN_WARNING2 "[skin] warning: in config file line %d:\nwidget (%s) found but no \"subsection\" found before" -#define MSGTR_SKIN_WARNING3 "[skin] warning: in config file line %d:\nthis subsection is not supported by widget (%s)" -#define MSGTR_SKIN_SkinFileNotFound "[skin] file ( %s ) not found.\n" -#define MSGTR_SKIN_SkinFileNotReadable "[skin] file ( %s ) not readable.\n" -#define MSGTR_SKIN_BITMAP_16bit "Bitmaps of 16 bits or less depth not supported (%s).\n" -#define MSGTR_SKIN_BITMAP_FileNotFound "File not found (%s)\n" -#define MSGTR_SKIN_BITMAP_BMPReadError "BMP read error (%s)\n" -#define MSGTR_SKIN_BITMAP_TGAReadError "TGA read error (%s)\n" -#define MSGTR_SKIN_BITMAP_PNGReadError "PNG read error (%s)\n" -#define MSGTR_SKIN_BITMAP_RLENotSupported "RLE packed TGA not supported (%s)\n" -#define MSGTR_SKIN_BITMAP_UnknownFileType "unknown file type (%s)\n" -#define MSGTR_SKIN_BITMAP_ConversionError "24 bit to 32 bit conversion error (%s)\n" -#define MSGTR_SKIN_BITMAP_UnknownMessage "unknown message: %s\n" -#define MSGTR_SKIN_FONT_NotEnoughtMemory "not enough memory\n" +#define MSGTR_SKIN_ERRORMESSAGE "Error in skin config file on line %d: %s" +#define MSGTR_SKIN_ERROR_SECTION "No section specified for '%s'.\n" +#define MSGTR_SKIN_ERROR_WINDOW "No window specified for '%s'.\n" +#define MSGTR_SKIN_ERROR_ITEM "This item is not supported by '%s'.\n" +#define MSGTR_SKIN_UNKNOWN_ITEM "Unknown item '%s'\n" +#define MSGTR_SKIN_UNKNOWN_NAME "Unknown name '%s'\n" +#define MSGTR_SKIN_SkinFileNotFound "Skin file %s not found.\n" +#define MSGTR_SKIN_SkinFileNotReadable "Skin file %s not readable.\n" +#define MSGTR_SKIN_BITMAP_16bit "Color depth of bitmap %s is 16 bits or less which is not supported.\n" +#define MSGTR_SKIN_BITMAP_FileNotFound "Bitmap %s not found.\n" +#define MSGTR_SKIN_BITMAP_PNGReadError "PNG read error in %s\n" +#define MSGTR_SKIN_BITMAP_ConversionError "24 bit to 32 bit conversion error in %s\n" +#define MSGTR_SKIN_UnknownMessage "Unknown message '%s'\n" +#define MSGTR_SKIN_NotEnoughMemory "Not enough memory\n" +#define MSGTR_SKIN_TooManyItemsDeclared "Too many items declared.\n" #define MSGTR_SKIN_FONT_TooManyFontsDeclared "Too many fonts declared.\n" -#define MSGTR_SKIN_FONT_FontFileNotFound "Font file not found.\n" +#define MSGTR_SKIN_FONT_FontFileNotFound "Font description file not found.\n" #define MSGTR_SKIN_FONT_FontImageNotFound "Font image file not found.\n" -#define MSGTR_SKIN_FONT_NonExistentFontID "non-existent font identifier (%s)\n" -#define MSGTR_SKIN_UnknownParameter "unknown parameter (%s)\n" -#define MSGTR_SKIN_SKINCFG_SkinNotFound "Skin not found (%s).\n" -#define MSGTR_SKIN_SKINCFG_SelectedSkinNotFound "Selected skin ( %s ) not found, trying 'default'...\n" -#define MSGTR_SKIN_SKINCFG_SkinCfgReadError "skin config file read error (%s)\n" +#define MSGTR_SKIN_FONT_NonExistentFont "Font '%s' not found.\n" +#define MSGTR_SKIN_UnknownParameter "Unknown parameter '%s'\n" +#define MSGTR_SKIN_SKINCFG_SkinNotFound "Skin '%s' not found.\n" +#define MSGTR_SKIN_SKINCFG_SelectedSkinNotFound "Selected skin '%s' not found, trying skin 'default'...\n" +#define MSGTR_SKIN_SKINCFG_SkinCfgError "Config file processing error with skin '%s'\n" #define MSGTR_SKIN_LABEL "Skins:" // --- GTK menus #define MSGTR_MENU_AboutMPlayer "About MPlayer" #define MSGTR_MENU_Open "Open..." #define MSGTR_MENU_PlayFile "Play file..." +#define MSGTR_MENU_PlayCD "Play CD..." #define MSGTR_MENU_PlayVCD "Play VCD..." #define MSGTR_MENU_PlayDVD "Play DVD..." #define MSGTR_MENU_PlayURL "Play URL..." @@ -627,6 +659,7 @@ static const char help_text[]= #define MSGTR_MENU_NormalSize "Normal size" #define MSGTR_MENU_DoubleSize "Double size" #define MSGTR_MENU_FullScreen "Fullscreen" +#define MSGTR_MENU_CD "CD" #define MSGTR_MENU_DVD "DVD" #define MSGTR_MENU_VCD "VCD" #define MSGTR_MENU_PlayDisc "Open disc..." @@ -641,7 +674,7 @@ static const char help_text[]= #define MSGTR_MENU_PlayList MSGTR_PlayList #define MSGTR_MENU_SkinBrowser "Skin browser" #define MSGTR_MENU_Preferences MSGTR_Preferences -#define MSGTR_MENU_Exit "Exit..." +#define MSGTR_MENU_Exit "Exit" #define MSGTR_MENU_Mute "Mute" #define MSGTR_MENU_Original "Original" #define MSGTR_MENU_AspectRatio "Aspect ratio" @@ -702,9 +735,10 @@ static const char help_text[]= #define MSGTR_PREFERENCES_HFrameDrop "Enable HARD frame dropping (dangerous)" #define MSGTR_PREFERENCES_Flip "Flip image upside down" #define MSGTR_PREFERENCES_Panscan "Panscan: " -#define MSGTR_PREFERENCES_OSDTimer "Timer and indicators" -#define MSGTR_PREFERENCES_OSDProgress "Progressbars only" -#define MSGTR_PREFERENCES_OSDTimerPercentageTotalTime "Timer, percentage and total time" +#define MSGTR_PREFERENCES_OSD_LEVEL0 "Subtitles only" +#define MSGTR_PREFERENCES_OSD_LEVEL1 "Volume and seek" +#define MSGTR_PREFERENCES_OSD_LEVEL2 "Volume, seek, timer and percentage" +#define MSGTR_PREFERENCES_OSD_LEVEL3 "Volume, seek, timer, percentage and total time" #define MSGTR_PREFERENCES_Subtitle "Subtitle:" #define MSGTR_PREFERENCES_SUB_Delay "Delay: " #define MSGTR_PREFERENCES_SUB_FPS "FPS:" @@ -777,6 +811,7 @@ static const char help_text[]= #define MSGTR_PREFERENCES_SaveWinPos "Save window position" #define MSGTR_PREFERENCES_XSCREENSAVER "Stop XScreenSaver" #define MSGTR_PREFERENCES_PlayBar "Enable playbar" +#define MSGTR_PREFERENCES_NoIdle "Quit after playing" #define MSGTR_PREFERENCES_AutoSync "AutoSync on/off" #define MSGTR_PREFERENCES_AutoSyncValue "Autosync: " #define MSGTR_PREFERENCES_CDROMDevice "CD-ROM device:" @@ -798,39 +833,62 @@ static const char help_text[]= #define MSGTR_MSGBOX_LABEL_Error "Error!" #define MSGTR_MSGBOX_LABEL_Warning "Warning!" -// bitmap.c -#define MSGTR_NotEnoughMemoryC32To1 "[c32to1] not enough memory for image\n" -#define MSGTR_NotEnoughMemoryC1To32 "[c1to32] not enough memory for image\n" - // cfg.c -#define MSGTR_ConfigFileReadError "[cfg] config file read error ...\n" -#define MSGTR_UnableToSaveOption "[cfg] Unable to save the '%s' option.\n" +#define MSGTR_UnableToSaveOption "Unable to save option '%s'.\n" // interface.c -#define MSGTR_DeletingSubtitles "[GUI] Deleting subtitles.\n" -#define MSGTR_LoadingSubtitles "[GUI] Loading subtitles: %s\n" -#define MSGTR_AddingVideoFilter "[GUI] Adding video filter: %s\n" -#define MSGTR_RemovingVideoFilter "[GUI] Removing video filter: %s\n" +#define MSGTR_DeletingSubtitles "Deleting subtitles.\n" +#define MSGTR_LoadingSubtitles "Loading subtitles '%s'.\n" +#define MSGTR_AddingVideoFilter "Adding video filter '%s'.\n" // mw.c #define MSGTR_NotAFile "This does not seem to be a file: %s !\n" // ws.c -#define MSGTR_WS_CouldNotOpenDisplay "[ws] Could not open the display.\n" -#define MSGTR_WS_RemoteDisplay "[ws] Remote display, disabling XMITSHM.\n" -#define MSGTR_WS_NoXshm "[ws] Sorry, your system does not support the X shared memory extension.\n" -#define MSGTR_WS_NoXshape "[ws] Sorry, your system does not support the XShape extension.\n" -#define MSGTR_WS_ColorDepthTooLow "[ws] Sorry, the color depth is too low.\n" -#define MSGTR_WS_TooManyOpenWindows "[ws] There are too many open windows.\n" -#define MSGTR_WS_ShmError "[ws] shared memory extension error\n" -#define MSGTR_WS_NotEnoughMemoryDrawBuffer "[ws] Sorry, not enough memory to draw buffer.\n" +#define MSGTR_WS_RemoteDisplay "Remote display, disabling XMITSHM.\n" +#define MSGTR_WS_NoXshm "Sorry, your system does not support the X shared memory extension.\n" +#define MSGTR_WS_NoXshape "Sorry, your system does not support the XShape extension.\n" +#define MSGTR_WS_ColorDepthTooLow "Sorry, the color depth is too low.\n" +#define MSGTR_WS_TooManyOpenWindows "There are too many open windows.\n" +#define MSGTR_WS_ShmError "shared memory extension error\n" +#define MSGTR_WS_NotEnoughMemoryDrawBuffer "Sorry, not enough memory to draw buffer.\n" #define MSGTR_WS_DpmsUnavailable "DPMS not available?\n" #define MSGTR_WS_DpmsNotEnabled "Could not enable DPMS.\n" +#define MSGTR_WS_XError "An X11 Error has occurred!\n" // wsxdnd.c #define MSGTR_WS_NotAFile "This does not seem to be a file...\n" #define MSGTR_WS_DDNothing "D&D: Nothing returned!\n" +// Win32 GUI +#define MSGTR_Close "Close" +#define MSGTR_Default "Defaults" +#define MSGTR_Down "Down" +#define MSGTR_Load "Load" +#define MSGTR_Save "Save" +#define MSGTR_Up "Up" +#define MSGTR_DirectorySelect "Select directory..." +#define MSGTR_PlaylistSave "Save playlist..." +#define MSGTR_PlaylistSelect "Select playlist..." +#define MSGTR_SelectTitleChapter "Select title/chapter..." +#define MSGTR_MENU_DebugConsole "Debug Console" +#define MSGTR_MENU_OnlineHelp "Online Help" +#define MSGTR_MENU_PlayDirectory "Play directory..." +#define MSGTR_MENU_SeekBack "Seek Backwards" +#define MSGTR_MENU_SeekForw "Seek Forwards" +#define MSGTR_MENU_ShowHide "Show/Hide" +#define MSGTR_MENU_SubtitlesOnOff "Subtitle Visibility On/Off" +#define MSGTR_PLAYLIST_AddFile "Add File..." +#define MSGTR_PLAYLIST_AddURL "Add URL..." +#define MSGTR_PREFERENCES_Priority "Priority:" +#define MSGTR_PREFERENCES_PriorityHigh "high" +#define MSGTR_PREFERENCES_PriorityLow "low" +#define MSGTR_PREFERENCES_PriorityNormal "normal" +#define MSGTR_PREFERENCES_PriorityNormalAbove "above normal" +#define MSGTR_PREFERENCES_PriorityNormalBelow "below normal" +#define MSGTR_PREFERENCES_ShowInVideoWin "Display in the video window (DirectX only)" + + // ======================= video output drivers ======================== #define MSGTR_VOincompCodec "The selected video_out device is incompatible with this codec.\n"\ @@ -984,7 +1042,6 @@ static const char help_text[]= // vo_sdl.c #define MSGTR_LIBVO_SDL_CouldntGetAnyAcceptableSDLModeForOutput "[VO_SDL] Couldn't get any acceptable SDL Mode for output.\n" #define MSGTR_LIBVO_SDL_SetVideoModeFailed "[VO_SDL] set_video_mode: SDL_SetVideoMode failed: %s.\n" -#define MSGTR_LIBVO_SDL_SetVideoModeFailedFull "[VO_SDL] Set_fullmode: SDL_SetVideoMode failed: %s.\n" #define MSGTR_LIBVO_SDL_MappingI420ToIYUV "[VO_SDL] Mapping I420 to IYUV.\n" #define MSGTR_LIBVO_SDL_UnsupportedImageFormat "[VO_SDL] Unsupported image format (0x%X).\n" #define MSGTR_LIBVO_SDL_InfoPleaseUseVmOrZoom "[VO_SDL] Info - please use -vm or -zoom to switch to the best resolution.\n" @@ -1151,16 +1208,15 @@ static const char help_text[]= // old vo drivers that have been replaced #define MSGTR_VO_PGM_HasBeenReplaced "The pgm video output driver has been replaced by -vo pnm:pgmyuv.\n" #define MSGTR_VO_MD5_HasBeenReplaced "The md5 video output driver has been replaced by -vo md5sum.\n" +#define MSGTR_VO_GL2_HasBeenRenamed "The gl2 video output driver has been renamed to -vo gl_tiled, but you really should be using -vo gl instead.\n" // ======================= audio output drivers ======================== // audio_out.c #define MSGTR_AO_ALSA9_1x_Removed "audio_out: alsa9 and alsa1x modules were removed, use -ao alsa instead.\n" -#define MSGTR_AO_TryingPreferredAudioDriver "Trying preferred audio driver '%.*s', options '%s'\n" #define MSGTR_AO_NoSuchDriver "No such audio driver '%.*s'\n" #define MSGTR_AO_FailedInit "Failed to initialize audio driver '%s'\n" -#define MSGTR_AO_TryingEveryKnown "Trying every known audio driver...\n" // ao_oss.c #define MSGTR_AO_OSS_CantOpenMixer "[AO OSS] audio_setup: Can't open mixer device %s: %s\n" @@ -1196,7 +1252,7 @@ static const char help_text[]= // ao_pcm.c #define MSGTR_AO_PCM_FileInfo "[AO PCM] File: %s (%s)\nPCM: Samplerate: %iHz Channels: %s Format %s\n" -#define MSGTR_AO_PCM_HintInfo "[AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast\n[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).\n" +#define MSGTR_AO_PCM_HintInfo "[AO PCM] Info: Faster dumping is achieved with -benchmark -vc null -vo null -ao pcm:fast\n[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).\n" #define MSGTR_AO_PCM_CantOpenOutputFile "[AO PCM] Failed to open %s for writing!\n" // ao_sdl.c @@ -1213,7 +1269,7 @@ static const char help_text[]= #define MSGTR_AO_SGI_CantSetParms_Samplerate "[AO SGI] init: setparams failed: %s\nCould not set desired samplerate.\n" #define MSGTR_AO_SGI_CantSetAlRate "[AO SGI] init: AL_RATE was not accepted on the given resource.\n" #define MSGTR_AO_SGI_CantGetParms "[AO SGI] init: getparams failed: %s\n" -#define MSGTR_AO_SGI_SampleRateInfo "[AO SGI] init: samplerate is now %lf (desired rate is %lf)\n" +#define MSGTR_AO_SGI_SampleRateInfo "[AO SGI] init: samplerate is now %f (desired rate is %f)\n" #define MSGTR_AO_SGI_InitConfigError "[AO SGI] init: %s\n" #define MSGTR_AO_SGI_InitOpenAudioFailed "[AO SGI] init: Unable to open audio channel: %s\n" #define MSGTR_AO_SGI_Uninit "[AO SGI] uninit: ...\n" @@ -1229,31 +1285,6 @@ static const char help_text[]= #define MSGTR_AO_SUN_CantUseSelect "[AO SUN]\n *** Your audio driver DOES NOT support select() ***\nRecompile MPlayer with #undef HAVE_AUDIO_SELECT in config.h !\n\n" #define MSGTR_AO_SUN_CantReopenReset "[AO SUN]\nFatal error: *** CANNOT REOPEN / RESET AUDIO DEVICE (%s) ***\n" -// ao_alsa5.c -#define MSGTR_AO_ALSA5_InitInfo "[AO ALSA5] alsa-init: requested format: %d Hz, %d channels, %s\n" -#define MSGTR_AO_ALSA5_SoundCardNotFound "[AO ALSA5] alsa-init: no soundcards found.\n" -#define MSGTR_AO_ALSA5_InvalidFormatReq "[AO ALSA5] alsa-init: invalid format (%s) requested - output disabled.\n" -#define MSGTR_AO_ALSA5_PlayBackError "[AO ALSA5] alsa-init: playback open error: %s\n" -#define MSGTR_AO_ALSA5_PcmInfoError "[AO ALSA5] alsa-init: PCM info error: %s\n" -#define MSGTR_AO_ALSA5_SoundcardsFound "[AO ALSA5] alsa-init: %d soundcard(s) found, using: %s\n" -#define MSGTR_AO_ALSA5_PcmChanInfoError "[AO ALSA5] alsa-init: PCM channel info error: %s\n" -#define MSGTR_AO_ALSA5_CantSetParms "[AO ALSA5] alsa-init: error setting parameters: %s\n" -#define MSGTR_AO_ALSA5_CantSetChan "[AO ALSA5] alsa-init: error setting up channel: %s\n" -#define MSGTR_AO_ALSA5_ChanPrepareError "[AO ALSA5] alsa-init: channel prepare error: %s\n" -#define MSGTR_AO_ALSA5_DrainError "[AO ALSA5] alsa-uninit: playback drain error: %s\n" -#define MSGTR_AO_ALSA5_FlushError "[AO ALSA5] alsa-uninit: playback flush error: %s\n" -#define MSGTR_AO_ALSA5_PcmCloseError "[AO ALSA5] alsa-uninit: PCM close error: %s\n" -#define MSGTR_AO_ALSA5_ResetDrainError "[AO ALSA5] alsa-reset: playback drain error: %s\n" -#define MSGTR_AO_ALSA5_ResetFlushError "[AO ALSA5] alsa-reset: playback flush error: %s\n" -#define MSGTR_AO_ALSA5_ResetChanPrepareError "[AO ALSA5] alsa-reset: channel prepare error: %s\n" -#define MSGTR_AO_ALSA5_PauseDrainError "[AO ALSA5] alsa-pause: playback drain error: %s\n" -#define MSGTR_AO_ALSA5_PauseFlushError "[AO ALSA5] alsa-pause: playback flush error: %s\n" -#define MSGTR_AO_ALSA5_ResumePrepareError "[AO ALSA5] alsa-resume: channel prepare error: %s\n" -#define MSGTR_AO_ALSA5_Underrun "[AO ALSA5] alsa-play: alsa underrun, resetting stream.\n" -#define MSGTR_AO_ALSA5_PlaybackPrepareError "[AO ALSA5] alsa-play: playback prepare error: %s\n" -#define MSGTR_AO_ALSA5_WriteErrorAfterReset "[AO ALSA5] alsa-play: write error after reset: %s - giving up.\n" -#define MSGTR_AO_ALSA5_OutPutError "[AO ALSA5] alsa-play: output error: %s\n" - // ao_alsa.c #define MSGTR_AO_ALSA_InvalidMixerIndexDefaultingToZero "[AO_ALSA] Invalid mixer index. Defaulting to 0.\n" #define MSGTR_AO_ALSA_MixerOpenError "[AO_ALSA] Mixer open error: %s\n" @@ -1337,7 +1368,6 @@ static const char help_text[]= // ========================== INPUT ========================================= // joystick.c -#define MSGTR_INPUT_JOYSTICK_Opening "Opening joystick device %s\n" #define MSGTR_INPUT_JOYSTICK_CantOpen "Can't open joystick device %s: %s\n" #define MSGTR_INPUT_JOYSTICK_ErrReading "Error while reading joystick device: %s\n" #define MSGTR_INPUT_JOYSTICK_LoosingBytes "Joystick: We lose %d bytes of data\n" @@ -1345,8 +1375,6 @@ static const char help_text[]= #define MSGTR_INPUT_JOYSTICK_WarnUnknownEvent "Joystick warning unknown event type %d\n" // appleir.c -#define MSGTR_INPUT_APPLE_IR_Init "Initializing Apple IR on %s\n" -#define MSGTR_INPUT_APPLE_IR_Detect "Detected Apple IR on %s\n" #define MSGTR_INPUT_APPLE_IR_CantOpen "Can't open Apple IR device: %s\n" // input.c @@ -1373,12 +1401,10 @@ static const char help_text[]= #define MSGTR_INPUT_INPUT_ErrBuffer2SmallForCmd "Buffer is too small for command %s\n" #define MSGTR_INPUT_INPUT_ErrWhyHere "What are we doing here?\n" #define MSGTR_INPUT_INPUT_ErrCantInitJoystick "Can't init input joystick\n" -#define MSGTR_INPUT_INPUT_ErrCantStatFile "Can't stat %s: %s\n" #define MSGTR_INPUT_INPUT_ErrCantOpenFile "Can't open %s: %s\n" #define MSGTR_INPUT_INPUT_ErrCantInitAppleRemote "Can't init Apple Remote.\n" // lirc.c -#define MSGTR_SettingUpLIRC "Setting up LIRC support...\n" #define MSGTR_LIRCopenfailed "Failed to open LIRC support. You will not be able to use your remote control.\n" #define MSGTR_LIRCcfgerr "Failed to read LIRC config file %s.\n" @@ -1393,7 +1419,6 @@ static const char help_text[]= #define MSGTR_WarningLenIsntDivisible "Warning, len isn't divisible by samplesize!\n" #define MSGTR_MuxbufMallocErr "Muxer frame buffer cannot allocate memory!\n" #define MSGTR_MuxbufReallocErr "Muxer frame buffer cannot reallocate memory!\n" -#define MSGTR_MuxbufSending "Muxer frame buffer sending %d frame(s) to the muxer.\n" #define MSGTR_WritingHeader "Writing header...\n" #define MSGTR_WritingTrailer "Writing index...\n" @@ -1411,7 +1436,6 @@ static const char help_text[]= #define MSGTR_ON2AviFormat "ON2 AVI format" #define MSGTR_Detected_XXX_FileFormat "%s file format detected.\n" #define MSGTR_DetectedAudiofile "Audio file detected.\n" -#define MSGTR_NotSystemStream "Not MPEG System Stream format... (maybe Transport Stream?)\n" #define MSGTR_InvalidMPEGES "Invalid MPEG-ES stream??? Contact the author, it may be a bug :(\n" #define MSGTR_FormatNotRecognized "============ Sorry, this file format is not recognized/supported =============\n"\ "=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===\n" @@ -1436,11 +1460,8 @@ static const char help_text[]= #define MSGTR_MOVcomprhdr "MOV: Compressed headers support requires ZLIB!\n" #define MSGTR_MOVvariableFourCC "MOV: WARNING: Variable FourCC detected!?\n" #define MSGTR_MOVtooManyTrk "MOV: WARNING: too many tracks" -#define MSGTR_FoundAudioStream "==> Found audio stream: %d\n" -#define MSGTR_FoundVideoStream "==> Found video stream: %d\n" #define MSGTR_DetectedTV "TV detected! ;-)\n" #define MSGTR_ErrorOpeningOGGDemuxer "Unable to open the Ogg demuxer.\n" -#define MSGTR_ASFSearchingForAudioStream "ASF: Searching for audio stream (id:%d).\n" #define MSGTR_CannotOpenAudioStream "Cannot open audio stream: %s\n" #define MSGTR_CannotOpenSubtitlesStream "Cannot open subtitle stream: %s\n" #define MSGTR_OpeningAudioDemuxerFailed "Failed to open audio demuxer: %s\n" @@ -1453,7 +1474,7 @@ static const char help_text[]= #define MSGTR_EnterTelecineMode "\ndemux_mpg: 24000/1001fps progressive NTSC content detected, switching framerate.\n" #define MSGTR_CacheFill "\rCache fill: %5.2f%% (%"PRId64" bytes) " -#define MSGTR_NoBindFound "No bind found for key '%s'." +#define MSGTR_NoBindFound "No bind found for key '%s'.\n" #define MSGTR_FailedToOpen "Failed to open %s.\n" #define MSGTR_VideoID "[%s] Video stream found, -vid %d\n" @@ -1473,17 +1494,7 @@ static const char help_text[]= // aviheader.c #define MSGTR_MPDEMUX_AVIHDR_EmptyList "** empty list?!\n" -#define MSGTR_MPDEMUX_AVIHDR_FoundMovieAt "Found movie at 0x%X - 0x%X\n" -#define MSGTR_MPDEMUX_AVIHDR_FoundBitmapInfoHeader "Found 'bih', %u bytes of %d\n" -#define MSGTR_MPDEMUX_AVIHDR_RegeneratingKeyfTableForMPG4V1 "Regenerating keyframe table for M$ mpg4v1 video.\n" -#define MSGTR_MPDEMUX_AVIHDR_RegeneratingKeyfTableForDIVX3 "Regenerating keyframe table for DIVX3 video.\n" -#define MSGTR_MPDEMUX_AVIHDR_RegeneratingKeyfTableForMPEG4 "Regenerating keyframe table for MPEG-4 video.\n" -#define MSGTR_MPDEMUX_AVIHDR_FoundWaveFmt "Found 'wf', %d bytes of %d\n" -#define MSGTR_MPDEMUX_AVIHDR_FoundAVIV2Header "AVI: dmlh found (size=%d) (total_frames=%d)\n" -#define MSGTR_MPDEMUX_AVIHDR_ReadingIndexBlockChunksForFrames "Reading INDEX block, %d chunks for %d frames (fpos=%"PRId64").\n" -#define MSGTR_MPDEMUX_AVIHDR_AdditionalRIFFHdr "Additional RIFF header...\n" #define MSGTR_MPDEMUX_AVIHDR_WarnNotExtendedAVIHdr "** Warning: this is no extended AVI header..\n" -#define MSGTR_MPDEMUX_AVIHDR_BrokenChunk "Broken chunk? chunksize=%d (id=%.4s)\n" #define MSGTR_MPDEMUX_AVIHDR_BuildingODMLidx "AVI: ODML: Building ODML index (%d superindexchunks).\n" #define MSGTR_MPDEMUX_AVIHDR_BrokenODMLfile "AVI: ODML: Broken (incomplete?) file detected. Will use traditional index.\n" #define MSGTR_MPDEMUX_AVIHDR_CantReadIdxFile "Can't read index file %s: %s\n" @@ -1497,6 +1508,8 @@ static const char help_text[]= #define MSGTR_MPDEMUX_AVIHDR_IdxFileSaved "Saved index file: %s\n" // demux_audio.c +#define MSGTR_MPDEMUX_AUDIO_BadID3v2TagSize "Audio demuxer: bad ID3v2 tag size: larger than stream (%u).\n" +#define MSGTR_MPDEMUX_AUDIO_DamagedAppendedID3v2Tag "Audio demuxer: damaged appended ID3v2 tag detected.\n" #define MSGTR_MPDEMUX_AUDIO_UnknownFormat "Audio demuxer: unknown format %d.\n" // demux_demuxers.c @@ -1615,21 +1628,15 @@ static const char help_text[]= #define MSGTR_UsingExternalPP "[PP] Using external postprocessing filter, max q = %d.\n" #define MSGTR_UsingCodecPP "[PP] Using codec's postprocessing, max q = %d.\n" -#define MSGTR_VideoAttributeNotSupportedByVO_VD "Video attribute '%s' is not supported by selected vo & vd.\n" #define MSGTR_VideoCodecFamilyNotAvailableStr "Requested video codec family [%s] (vfm=%s) not available.\nEnable it at compilation.\n" #define MSGTR_AudioCodecFamilyNotAvailableStr "Requested audio codec family [%s] (afm=%s) not available.\nEnable it at compilation.\n" #define MSGTR_OpeningVideoDecoder "Opening video decoder: [%s] %s\n" #define MSGTR_SelectedVideoCodec "Selected video codec: [%s] vfm: %s (%s)\n" #define MSGTR_OpeningAudioDecoder "Opening audio decoder: [%s] %s\n" #define MSGTR_SelectedAudioCodec "Selected audio codec: [%s] afm: %s (%s)\n" -#define MSGTR_BuildingAudioFilterChain "Building audio filter chain for %dHz/%dch/%s -> %dHz/%dch/%s...\n" -#define MSGTR_UninitVideoStr "Uninit video: %s\n" -#define MSGTR_UninitAudioStr "Uninit audio: %s\n" #define MSGTR_VDecoderInitFailed "VDecoder init failed :(\n" #define MSGTR_ADecoderInitFailed "ADecoder init failed :(\n" #define MSGTR_ADecoderPreinitFailed "ADecoder preinit failed :(\n" -#define MSGTR_AllocatingBytesForInputBuffer "dec_audio: Allocating %d bytes for input buffer.\n" -#define MSGTR_AllocatingBytesForOutputBuffer "dec_audio: Allocating %d + %d = %d bytes for output buffer.\n" // ad_dvdpcm.c: #define MSGTR_SamplesWanted "Samples of this format are needed to improve support. Please contact the developers.\n" @@ -1645,8 +1652,6 @@ static const char help_text[]= // vd_dshow.c, vd_dmo.c #define MSGTR_DownloadCodecPackage "You need to upgrade/install the binary codecs package.\nGo to http://www.mplayerhq.hu/dload.html\n" -#define MSGTR_DShowInitOK "INFO: Win32/DShow video codec init OK.\n" -#define MSGTR_DMOInitOK "INFO: Win32/DMO video codec init OK.\n" // libmpcodecs/vd_dmo.c vd_dshow.c vd_vfw.c #define MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec "[VD_DMO] Couldn't allocate image for cinepak codec.\n" @@ -1774,12 +1779,12 @@ static const char help_text[]= // ================================== stream ==================================== -// ai_alsa1x.c -#define MSGTR_MPDEMUX_AIALSA1X_CannotSetSamplerate "Cannot set samplerate.\n" -#define MSGTR_MPDEMUX_AIALSA1X_CannotSetBufferTime "Cannot set buffer time.\n" -#define MSGTR_MPDEMUX_AIALSA1X_CannotSetPeriodTime "Cannot set period time.\n" +// ai_alsa.c +#define MSGTR_MPDEMUX_AIALSA_CannotSetSamplerate "Cannot set samplerate.\n" +#define MSGTR_MPDEMUX_AIALSA_CannotSetBufferTime "Cannot set buffer time.\n" +#define MSGTR_MPDEMUX_AIALSA_CannotSetPeriodTime "Cannot set period time.\n" -// ai_alsa1x.c / ai_alsa.c +// ai_alsa.c #define MSGTR_MPDEMUX_AIALSA_PcmBrokenConfig "Broken configuration for this PCM: no configurations available.\n" #define MSGTR_MPDEMUX_AIALSA_UnavailableAccessType "Access type not available.\n" #define MSGTR_MPDEMUX_AIALSA_UnavailableSampleFmt "Sample format not available.\n" @@ -1790,7 +1795,6 @@ static const char help_text[]= #define MSGTR_MPDEMUX_AIALSA_ErrorOpeningAudio "Error opening audio: %s\n" #define MSGTR_MPDEMUX_AIALSA_AlsaStatusError "ALSA status error: %s" #define MSGTR_MPDEMUX_AIALSA_AlsaXRUN "ALSA xrun!!! (at least %.3f ms long)\n" -#define MSGTR_MPDEMUX_AIALSA_AlsaStatus "ALSA Status:\n" #define MSGTR_MPDEMUX_AIALSA_AlsaXRUNPrepareError "ALSA xrun: prepare error: %s" #define MSGTR_MPDEMUX_AIALSA_AlsaReadWriteError "ALSA read/write error" @@ -1850,7 +1854,7 @@ static const char help_text[]= #define MSGTR_MPDEMUX_ASF_UnknownASFStreamType "unknown ASF stream type\n" #define MSGTR_MPDEMUX_ASF_Failed2ParseHTTPResponse "Failed to parse HTTP response.\n" #define MSGTR_MPDEMUX_ASF_ServerReturn "Server returned %d:%s\n" -#define MSGTR_MPDEMUX_ASF_ASFHTTPParseWarnCuttedPragma "ASF HTTP PARSE WARNING : Pragma %s cut from %zd bytes to %d\n" +#define MSGTR_MPDEMUX_ASF_ASFHTTPParseWarnCuttedPragma "ASF HTTP PARSE WARNING : Pragma %s cut from %zu bytes to %zu\n" #define MSGTR_MPDEMUX_ASF_SocketWriteError "socket write error: %s\n" #define MSGTR_MPDEMUX_ASF_HeaderParseFailed "Failed to parse header.\n" #define MSGTR_MPDEMUX_ASF_NoStreamFound "No stream found.\n" @@ -1907,6 +1911,17 @@ static const char help_text[]= #define MSGTR_CantOpenBluray "Couldn't open Blu-ray device: %s\n" #define MSGTR_CantOpenDVD "Couldn't open DVD device: %s (%s)\n" +#define MSGTR_URLParsingFailed "URL parsing failed on url %s\n" +#define MSGTR_FailedSetStreamOption "Failed to set stream option %s=%s\n" +#define MSGTR_StreamNeedType "Streams need a type!\n" +#define MSGTR_StreamProtocolNULL "Stream type %s has protocols == NULL, it's a bug\n" +#define MSGTR_StreamCantHandleURL "No stream found to handle url %s\n" +#define MSGTR_StreamNULLFilename "open_output_stream(), NULL filename, report this bug\n" +#define MSGTR_StreamErrorWritingCapture "Error writing capture file: %s\n" +#define MSGTR_StreamSeekFailed "Seek failed\n" +#define MSGTR_StreamNotSeekable "Stream not seekable!\n" +#define MSGTR_StreamCannotSeekBackward "Cannot seek backward in linear streams!\n" + // stream_cdda.c #define MSGTR_MPDEMUX_CDDA_CantOpenCDDADevice "Can't open CDDA device.\n" #define MSGTR_MPDEMUX_CDDA_CantOpenDisc "Can't open disc.\n" @@ -1979,21 +1994,16 @@ static const char help_text[]= // stream_bluray.c #define MSGTR_BlurayNoDevice "No Blu-ray device/location was specified ...\n" #define MSGTR_BlurayNoTitles "Can't find any Blu-ray-compatible title here.\n" -#define MSGTR_BlurayOK "Blu-ray successfully opened.\n" // stream_radio.c #define MSGTR_RADIO_ChannelNamesDetected "[radio] Radio channel names detected.\n" -#define MSGTR_RADIO_FreqRange "[radio] Allowed frequency range is %.2f-%.2f MHz.\n" #define MSGTR_RADIO_WrongFreqForChannel "[radio] Wrong frequency for channel %s\n" #define MSGTR_RADIO_WrongChannelNumberFloat "[radio] Wrong channel number: %.2f\n" #define MSGTR_RADIO_WrongChannelNumberInt "[radio] Wrong channel number: %d\n" #define MSGTR_RADIO_WrongChannelName "[radio] Wrong channel name: %s\n" #define MSGTR_RADIO_FreqParameterDetected "[radio] Radio frequency parameter detected.\n" -#define MSGTR_RADIO_DoneParsingChannels "[radio] Done parsing channels.\n" #define MSGTR_RADIO_GetTunerFailed "[radio] Warning: ioctl get tuner failed: %s. Setting frac to %d.\n" #define MSGTR_RADIO_NotRadioDevice "[radio] %s is no radio device!\n" -#define MSGTR_RADIO_TunerCapLowYes "[radio] tuner is low:yes frac=%d\n" -#define MSGTR_RADIO_TunerCapLowNo "[radio] tuner is low:no frac=%d\n" #define MSGTR_RADIO_SetFreqFailed "[radio] ioctl set frequency 0x%x (%.2f) failed: %s\n" #define MSGTR_RADIO_GetFreqFailed "[radio] ioctl get frequency failed: %s\n" #define MSGTR_RADIO_SetMuteFailed "[radio] ioctl set mute failed: %s\n" @@ -2003,27 +2013,22 @@ static const char help_text[]= #define MSGTR_RADIO_DroppingFrame "\n[radio] too bad - dropping audio frame (%d bytes)!\n" #define MSGTR_RADIO_BufferEmpty "[radio] grab_audio_frame: buffer empty, waiting for %d data bytes.\n" #define MSGTR_RADIO_AudioInitFailed "[radio] audio_in_init failed: %s\n" -#define MSGTR_RADIO_AudioBuffer "[radio] Audio capture - buffer=%d bytes (block=%d bytes).\n" #define MSGTR_RADIO_AllocateBufferFailed "[radio] cannot allocate audio buffer (block=%d,buf=%d): %s\n" #define MSGTR_RADIO_CurrentFreq "[radio] Current frequency: %.2f\n" #define MSGTR_RADIO_SelectedChannel "[radio] Selected channel: %d - %s (freq: %.2f)\n" #define MSGTR_RADIO_ChangeChannelNoChannelList "[radio] Can not change channel: no channel list given.\n" #define MSGTR_RADIO_UnableOpenDevice "[radio] Unable to open '%s': %s\n" -#define MSGTR_RADIO_RadioDevice "[radio] Radio fd: %d, %s\n" #define MSGTR_RADIO_InitFracFailed "[radio] init_frac failed.\n" #define MSGTR_RADIO_WrongFreq "[radio] Wrong frequency: %.2f\n" #define MSGTR_RADIO_UsingFreq "[radio] Using frequency: %.2f.\n" #define MSGTR_RADIO_AudioInInitFailed "[radio] audio_in_init failed.\n" -#define MSGTR_RADIO_BufferString "[radio] %s: in buffer=%d dropped=%d\n" #define MSGTR_RADIO_AudioInSetupFailed "[radio] audio_in_setup call failed: %s\n" -#define MSGTR_RADIO_CaptureStarting "[radio] Starting capture stuff.\n" #define MSGTR_RADIO_ClearBufferFailed "[radio] Clearing buffer failed: %s\n" #define MSGTR_RADIO_StreamEnableCacheFailed "[radio] Call to stream_enable_cache failed: %s\n" #define MSGTR_RADIO_DriverUnknownStr "[radio] Unknown driver name: %s\n" #define MSGTR_RADIO_DriverV4L2 "[radio] Using V4Lv2 radio interface.\n" #define MSGTR_RADIO_DriverV4L "[radio] Using V4Lv1 radio interface.\n" #define MSGTR_RADIO_DriverBSDBT848 "[radio] Using *BSD BT848 radio interface.\n" -#define MSGTR_RADIO_AvailableDrivers "[radio] Available drivers: " //tv.c #define MSGTR_TV_BogusNormParameter "tv.c: norm_from_string(%s): Bogus norm parameter, setting %s.\n" @@ -2035,30 +2040,23 @@ static const char help_text[]= " be ignored! You should try again with YV12 (which is the default\n"\ " colorspace) and read the documentation!\n"\ "==================================================================\n" -#define MSGTR_TV_SelectedNormId "Selected norm id: %d\n" -#define MSGTR_TV_SelectedNorm "Selected norm : %s\n" #define MSGTR_TV_CannotSetNorm "Error: Cannot set norm!\n" #define MSGTR_TV_MJP_WidthHeight " MJP: width %d height %d\n" #define MSGTR_TV_UnableToSetWidth "Unable to set requested width: %d\n" #define MSGTR_TV_UnableToSetHeight "Unable to set requested height: %d\n" #define MSGTR_TV_NoTuner "Selected input hasn't got a tuner!\n" #define MSGTR_TV_UnableFindChanlist "Unable to find selected channel list! (%s)\n" -#define MSGTR_TV_SelectedChanlist "Selected channel list: %s (including %d channels)\n" #define MSGTR_TV_ChannelFreqParamConflict "You can't set frequency and channel simultaneously!\n" #define MSGTR_TV_ChannelNamesDetected "TV channel names detected.\n" #define MSGTR_TV_NoFreqForChannel "Couldn't find frequency for channel %s (%s)\n" #define MSGTR_TV_SelectedChannel3 "Selected channel: %s - %s (freq: %.3f)\n" #define MSGTR_TV_SelectedChannel2 "Selected channel: %s (freq: %.3f)\n" -#define MSGTR_TV_SelectedFrequency "Selected frequency: %lu (%.3f)\n" -#define MSGTR_TV_RequestedChannel "Requested channel: %s\n" #define MSGTR_TV_UnsupportedAudioType "Audio type '%s (%x)' unsupported!\n" -#define MSGTR_TV_AudioFormat " TV audio: %d channels, %d bits, %d Hz\n" #define MSGTR_TV_AvailableDrivers "Available drivers:\n" #define MSGTR_TV_DriverInfo "Selected driver: %s\n name: %s\n author: %s\n comment: %s\n" #define MSGTR_TV_NoSuchDriver "No such driver: %s\n" #define MSGTR_TV_DriverAutoDetectionFailed "TV driver autodetection failed.\n" #define MSGTR_TV_UnknownColorOption "Unknown color option (%d) specified!\n" -#define MSGTR_TV_CurrentFrequency "Current frequency: %lu (%.3f)\n" #define MSGTR_TV_NoTeletext "No teletext" #define MSGTR_TV_Bt848IoctlFailed "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n" #define MSGTR_TV_Bt848InvalidAudioRate "tvi_bsdbt848: Invalid audio rate. Error: %s\n" @@ -2086,14 +2084,7 @@ static const char help_text[]= #define MSGTR_TVI_DS_DeviceNotFound "tvi_dshow: Device #%d not found\n" #define MSGTR_TVI_DS_UnableGetDeviceName "tvi_dshow: Unable to get name for device #%d\n" #define MSGTR_TVI_DS_UsingDevice "tvi_dshow: Using device #%d: %s\n" -#define MSGTR_TVI_DS_DeviceName "tvi_dshow: Device #%d: %s\n" #define MSGTR_TVI_DS_DirectGetFreqFailed "tvi_dshow: Unable to get frequency directly. OS built-in channels table will be used.\n" -#define MSGTR_TVI_DS_DirectSetFreqFailed "tvi_dshow: Unable to set frequency directly. OS built-in channels table will be used.\n" -#define MSGTR_TVI_DS_SupportedNorms "tvi_dshow: supported norms:" -#define MSGTR_TVI_DS_AvailableVideoInputs "tvi_dshow: available video inputs:" -#define MSGTR_TVI_DS_AvailableAudioInputs "tvi_dshow: available audio inputs:" -//following phrase will be printed near the selected audio/video input -#define MSGTR_TVI_DS_InputSelected "(selected)" #define MSGTR_TVI_DS_UnableExtractFreqTable "tvi_dshow: Unable to load frequency table from kstvtune.ax\n" #define MSGTR_TVI_DS_WrongDeviceParam "tvi_dshow: Wrong device parameter: %s\n" #define MSGTR_TVI_DS_WrongDeviceIndex "tvi_dshow: Wrong device index: %d\n" @@ -2105,7 +2096,6 @@ static const char help_text[]= #define MSGTR_TVI_DS_ChangingWidthHeightNotSupported "tvi_dshow: Changing video width/height is not supported by device.\n" #define MSGTR_TVI_DS_SelectingInputNotSupported "tvi_dshow: Selection of capture source is not supported by device\n" -#define MSGTR_TVI_DS_FreqTableLoaded "tvi_dshow: loaded system (%s) frequency table for country id=%d (channels:%d).\n" #define MSGTR_TVI_DS_ErrorParsingAudioFormatStruct "tvi_dshow: Unable to parse audio format structure.\n" #define MSGTR_TVI_DS_ErrorParsingVideoFormatStruct "tvi_dshow: Unable to parse video format structure.\n" #define MSGTR_TVI_DS_UnableSetAudioMode "tvi_dshow: Unable to set audio mode %d. Error:0x%x\n" From 99a0813a7e0b2666510db07296ada11598004ff0 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 13:02:00 +0100 Subject: [PATCH 165/182] libhmpcodec/mp_msg: update to latest from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/mp_msg.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavfilter/libmpcodecs/mp_msg.h b/libavfilter/libmpcodecs/mp_msg.h index 250bfb2752..51cdff3cef 100644 --- a/libavfilter/libmpcodecs/mp_msg.h +++ b/libavfilter/libmpcodecs/mp_msg.h @@ -148,14 +148,16 @@ void ff_mp_msg(int mod, int lev, const char *format, ... ) __attribute__ ((forma # ifdef MP_DEBUG # define mp_dbg(mod,lev, args... ) ff_mp_msg(mod, lev, ## args ) # else -# define mp_dbg(mod,lev, args... ) /* only useful for developers */ + // only useful for developers, disable but check syntax +# define mp_dbg(mod,lev, args... ) do { if (0) ff_mp_msg(mod, lev, ## args ); } while (0) # endif #else // not GNU C void ff_mp_msg(int mod, int lev, const char *format, ... ); # ifdef MP_DEBUG # define mp_dbg(mod,lev, ... ) ff_mp_msg(mod, lev, __VA_ARGS__) # else -# define mp_dbg(mod,lev, ... ) /* only useful for developers */ + // only useful for developers, disable but check syntax +# define mp_dbg(mod,lev, ... ) do { if (0) ff_mp_msg(mod, lev, __VA_ARGS__); } while (0) # endif #endif /* __GNUC__ */ From 5d0115118df4a17462dabcc2cd40af92db512310 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 13:39:24 +0100 Subject: [PATCH 166/182] libmpcodecs/vf_divtc: update to latest version in mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_divtc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/libmpcodecs/vf_divtc.c b/libavfilter/libmpcodecs/vf_divtc.c index 0e023f3fcf..61f6e35f09 100644 --- a/libavfilter/libmpcodecs/vf_divtc.c +++ b/libavfilter/libmpcodecs/vf_divtc.c @@ -26,6 +26,7 @@ #include "mp_msg.h" #include "cpudetect.h" #include "libavutil/common.h" +#include "libavutil/x86/asm.h" #include "mpbswap.h" #include "img_format.h" From e02c713fb1498a570c9d55f34e0dccfd8b71ad49 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 13:40:08 +0100 Subject: [PATCH 167/182] libmpcodecs/vf_filmdint: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_filmdint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/libmpcodecs/vf_filmdint.c b/libavfilter/libmpcodecs/vf_filmdint.c index db31f426e9..93354e2ec0 100644 --- a/libavfilter/libmpcodecs/vf_filmdint.c +++ b/libavfilter/libmpcodecs/vf_filmdint.c @@ -30,7 +30,7 @@ #include "vd.h" #include "vf.h" #include "cmmx.h" - +#include "libavutil/x86/asm.h" #include "libvo/fastmemcpy.h" #define NUM_STORED 4 From 2b9eb6167b3255a338e3a18079f6d1c5a051d1b9 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 13:42:14 +0100 Subject: [PATCH 168/182] libmpcodecs/av_helpers: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/av_helpers.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 libavfilter/libmpcodecs/av_helpers.h diff --git a/libavfilter/libmpcodecs/av_helpers.h b/libavfilter/libmpcodecs/av_helpers.h new file mode 100644 index 0000000000..90b67d5a0f --- /dev/null +++ b/libavfilter/libmpcodecs/av_helpers.h @@ -0,0 +1,27 @@ +/* + * Generic libav* helpers + * + * 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. + */ + +#ifndef MPLAYER_AV_HELPERS_H +#define MPLAYER_AV_HELPERS_H + +void ff_init_avcodec(void); +void ff_init_avformat(void); + +#endif /* MPLAYER_AV_HELPERS_H */ From 0b36a05c17527b3d3cdcd53cb1e7f27306e68f71 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 13:43:51 +0100 Subject: [PATCH 169/182] libmpcodecs/vf_fspp: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_fspp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/libmpcodecs/vf_fspp.c b/libavfilter/libmpcodecs/vf_fspp.c index 6090c9aeab..a8a33e2644 100644 --- a/libavfilter/libmpcodecs/vf_fspp.c +++ b/libavfilter/libmpcodecs/vf_fspp.c @@ -45,12 +45,13 @@ #include "img_format.h" #include "mp_image.h" #include "vf.h" -#include "vd_ffmpeg.h" +#include "av_helpers.h" #include "libvo/fastmemcpy.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/mem.h" +#include "libavutil/x86/asm.h" #include "libavcodec/avcodec.h" #include "libavcodec/dsputil.h" From 011702f5a93451752980658f8fa69d28dd48b8b6 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 13:59:10 +0100 Subject: [PATCH 170/182] libmpcodecs/vf_ivtc: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_ivtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/libmpcodecs/vf_ivtc.c b/libavfilter/libmpcodecs/vf_ivtc.c index 2418358a3b..8a47a57748 100644 --- a/libavfilter/libmpcodecs/vf_ivtc.c +++ b/libavfilter/libmpcodecs/vf_ivtc.c @@ -27,7 +27,7 @@ #include "img_format.h" #include "mp_image.h" #include "vf.h" - +#include "libavutil/x86/asm.h" #include "libvo/fastmemcpy.h" From 25ed6e99d789cdf0bcb4ad5d00efc8ea5387c7a6 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 13:59:47 +0100 Subject: [PATCH 171/182] libmpcodecs/vf_ilpack: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_ilpack.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/libmpcodecs/vf_ilpack.c b/libavfilter/libmpcodecs/vf_ilpack.c index 17d6ae4450..4db6c0a8b7 100644 --- a/libavfilter/libmpcodecs/vf_ilpack.c +++ b/libavfilter/libmpcodecs/vf_ilpack.c @@ -29,6 +29,7 @@ #include "mp_image.h" #include "vf.h" #include "libavutil/attributes.h" +#include "libavutil/x86/asm.h" typedef void (pack_func_t)(unsigned char *dst, unsigned char *y, unsigned char *u, unsigned char *v, int w, int us, int vs); From b7e6622971eb2945450e0380ad349f93fbb77bf5 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 14:00:20 +0100 Subject: [PATCH 172/182] libmpcodecs/vf_mcdeint: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_mcdeint.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavfilter/libmpcodecs/vf_mcdeint.c b/libavfilter/libmpcodecs/vf_mcdeint.c index 6ae255dde3..b9ffaf21ca 100644 --- a/libavfilter/libmpcodecs/vf_mcdeint.c +++ b/libavfilter/libmpcodecs/vf_mcdeint.c @@ -54,6 +54,7 @@ Known Issues: #include "mp_msg.h" #include "cpudetect.h" +#include "libavutil/common.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavcodec/avcodec.h" @@ -66,7 +67,7 @@ Known Issues: #include "img_format.h" #include "mp_image.h" #include "vf.h" -#include "vd_ffmpeg.h" +#include "av_helpers.h" #define MIN(a,b) ((a) > (b) ? (b) : (a)) #define MAX(a,b) ((a) < (b) ? (b) : (a)) @@ -186,6 +187,7 @@ static int config(struct vf_instance *vf, for(i=0; i<3; i++){ AVCodecContext *avctx_enc; + AVDictionary *opts = NULL; #if 0 int is_chroma= !!i; int w= ((width + 31) & (~31))>>is_chroma; @@ -196,7 +198,7 @@ static int config(struct vf_instance *vf, vf->priv->src [i]= malloc(vf->priv->temp_stride[i]*h*sizeof(uint8_t)); #endif avctx_enc= - vf->priv->avctx_enc= avcodec_alloc_context(); + vf->priv->avctx_enc= avcodec_alloc_context3(enc); avctx_enc->width = width; avctx_enc->height = height; avctx_enc->time_base= (AVRational){1,25}; // meaningless @@ -206,7 +208,7 @@ static int config(struct vf_instance *vf, avctx_enc->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; avctx_enc->global_quality= 1; - avctx_enc->flags2= CODEC_FLAG2_MEMC_ONLY; + av_dict_set(&opts, "memc_only", "1", 0); avctx_enc->me_cmp= avctx_enc->me_sub_cmp= FF_CMP_SAD; //SSE; avctx_enc->mb_cmp= FF_CMP_SSE; @@ -224,7 +226,8 @@ static int config(struct vf_instance *vf, avctx_enc->flags |= CODEC_FLAG_QPEL; } - avcodec_open(avctx_enc, enc); + avcodec_open2(avctx_enc, enc, &opts); + av_dict_free(&opts); } vf->priv->frame= avcodec_alloc_frame(); From fdd574ed3f60cac30fcb13730563d7ff03c6de53 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 14:16:47 +0100 Subject: [PATCH 173/182] libmpcodecs/vf_qp: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_qp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/libmpcodecs/vf_qp.c b/libavfilter/libmpcodecs/vf_qp.c index e8740d0a30..579ec1c98f 100644 --- a/libavfilter/libmpcodecs/vf_qp.c +++ b/libavfilter/libmpcodecs/vf_qp.c @@ -33,6 +33,7 @@ #include "libavcodec/avcodec.h" #include "libavutil/eval.h" +#include "libavutil/mem.h" struct vf_priv_s { From 3ca46d0c10aa4ccb063ea60e5cd1cab188418ad5 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 14:17:28 +0100 Subject: [PATCH 174/182] libmpcodecs/vf_pp7:update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_pp7.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavfilter/libmpcodecs/vf_pp7.c b/libavfilter/libmpcodecs/vf_pp7.c index 14bd863525..30f95307bb 100644 --- a/libavfilter/libmpcodecs/vf_pp7.c +++ b/libavfilter/libmpcodecs/vf_pp7.c @@ -44,8 +44,6 @@ #define XMIN(a,b) ((a) < (b) ? (a) : (b)) #define XMAX(a,b) ((a) > (b) ? (a) : (b)) -typedef short int16_t; - //===========================================================================// static const uint8_t __attribute__((aligned(8))) dither[8][8]={ { 0, 48, 12, 60, 3, 51, 15, 63, }, From 8f7e3e678b5864017e52f1a965f221379feed118 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 14:17:54 +0100 Subject: [PATCH 175/182] libmpcodecs/vf_noise: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_noise.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/libmpcodecs/vf_noise.c b/libavfilter/libmpcodecs/vf_noise.c index e141e6b022..3b946e99bb 100644 --- a/libavfilter/libmpcodecs/vf_noise.c +++ b/libavfilter/libmpcodecs/vf_noise.c @@ -37,6 +37,7 @@ #include "vf.h" #include "libvo/fastmemcpy.h" #include "libavutil/mem.h" +#include "libavutil/x86/asm.h" #define MAX_NOISE 4096 #define MAX_SHIFT 1024 From fe8bc6ddfcd2273d781390913ddeb394113b5283 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 14:17:54 +0100 Subject: [PATCH 176/182] libmpcodecs/pullup: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/pullup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/libmpcodecs/pullup.c b/libavfilter/libmpcodecs/pullup.c index a28b8cfc27..b5fae9ba61 100644 --- a/libavfilter/libmpcodecs/pullup.c +++ b/libavfilter/libmpcodecs/pullup.c @@ -19,9 +19,10 @@ #include #include #include + +#include "libavutil/x86/asm.h" #include "config.h" #include "pullup.h" -#include "cpudetect.h" From 14132599a3729b85edd55c9aab09bf4594e4d885 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 14:17:54 +0100 Subject: [PATCH 177/182] libmpcodecs/vf_sab: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_sab.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/libmpcodecs/vf_sab.c b/libavfilter/libmpcodecs/vf_sab.c index a5ad17c5ee..2928a858d3 100644 --- a/libavfilter/libmpcodecs/vf_sab.c +++ b/libavfilter/libmpcodecs/vf_sab.c @@ -32,6 +32,7 @@ #endif #include "libavutil/avutil.h" +#include "libavutil/mem.h" #include "img_format.h" #include "mp_image.h" #include "vf.h" From 7a4885600ff049d3ea70671facdbd37f92e7789e Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 14:17:54 +0100 Subject: [PATCH 178/182] libmpcodecs/vf_spp: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavcodec/libavcodec.v | 1 + libavfilter/libmpcodecs/vf_spp.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v index 195485e63f..826a547565 100644 --- a/libavcodec/libavcodec.v +++ b/libavcodec/libavcodec.v @@ -4,6 +4,7 @@ LIBAVCODEC_$MAJOR { audio_resample; audio_resample_close; dsputil_init; + ff_dsputil_init; ff_find_pix_fmt; ff_framenum_to_drop_timecode; ff_framenum_to_smtpe_timecode; diff --git a/libavfilter/libmpcodecs/vf_spp.c b/libavfilter/libmpcodecs/vf_spp.c index f821374e06..75ede23ccb 100644 --- a/libavfilter/libmpcodecs/vf_spp.c +++ b/libavfilter/libmpcodecs/vf_spp.c @@ -37,6 +37,7 @@ #include "mp_msg.h" #include "cpudetect.h" +#include "libavutil/common.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavcodec/avcodec.h" @@ -49,7 +50,7 @@ #include "img_format.h" #include "mp_image.h" #include "vf.h" -#include "vd_ffmpeg.h" +#include "av_helpers.h" #include "libvo/fastmemcpy.h" #define XMIN(a,b) ((a) < (b) ? (a) : (b)) @@ -578,8 +579,8 @@ static int vf_open(vf_instance_t *vf, char *args){ ff_init_avcodec(); - vf->priv->avctx= avcodec_alloc_context(); - dsputil_init(&vf->priv->dsp, vf->priv->avctx); + vf->priv->avctx= avcodec_alloc_context3(NULL); + ff_dsputil_init(&vf->priv->dsp, vf->priv->avctx); vf->priv->log2_count= 3; From 3ce3d4cc3c0a088e7dd337aa9d46be17c918197b Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 14:17:54 +0100 Subject: [PATCH 179/182] libmpcodecs/vf_unsharp: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_unsharp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavfilter/libmpcodecs/vf_unsharp.c b/libavfilter/libmpcodecs/vf_unsharp.c index b947769fc2..89eddecc8b 100644 --- a/libavfilter/libmpcodecs/vf_unsharp.c +++ b/libavfilter/libmpcodecs/vf_unsharp.c @@ -165,7 +165,8 @@ static void get_image( struct vf_instance *vf, mp_image_t *mpi ) { if( mpi->imgfmt!=vf->priv->outfmt ) return; // colorspace differ - vf->dmpi = ff_vf_get_image( vf->next, mpi->imgfmt, mpi->type, mpi->flags, mpi->w, mpi->h ); + mpi->priv = + vf->dmpi = ff_vf_get_image( vf->next, mpi->imgfmt, mpi->type, mpi->flags, mpi->width, mpi->height ); mpi->planes[0] = vf->dmpi->planes[0]; mpi->stride[0] = vf->dmpi->stride[0]; mpi->width = vf->dmpi->width; @@ -179,12 +180,12 @@ static void get_image( struct vf_instance *vf, mp_image_t *mpi ) { } static int put_image( struct vf_instance *vf, mp_image_t *mpi, double pts) { - mp_image_t *dmpi; + mp_image_t *dmpi = mpi->priv; + mpi->priv = NULL; if( !(mpi->flags & MP_IMGFLAG_DIRECT) ) // no DR, so get a new image! hope we'll get DR buffer: - vf->dmpi = ff_vf_get_image( vf->next,vf->priv->outfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->w, mpi->h); - dmpi= vf->dmpi; + dmpi = vf->dmpi = ff_vf_get_image( vf->next,vf->priv->outfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->width, mpi->height); unsharp( dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, &vf->priv->lumaParam ); unsharp( dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, &vf->priv->chromaParam ); From 13afcdd00eec89538e62d0802c52cc57999caf98 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 14:17:54 +0100 Subject: [PATCH 180/182] libmpcodecs/vf_uspp: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_uspp.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libavfilter/libmpcodecs/vf_uspp.c b/libavfilter/libmpcodecs/vf_uspp.c index 7444e03328..54cc0f9e11 100644 --- a/libavfilter/libmpcodecs/vf_uspp.c +++ b/libavfilter/libmpcodecs/vf_uspp.c @@ -30,12 +30,13 @@ #include "mp_msg.h" #include "cpudetect.h" +#include "libavutil/mem.h" #include "libavcodec/avcodec.h" #include "img_format.h" #include "mp_image.h" #include "vf.h" -#include "vd_ffmpeg.h" +#include "av_helpers.h" #include "libvo/fastmemcpy.h" #define XMIN(a,b) ((a) < (b) ? (a) : (b)) @@ -94,7 +95,9 @@ static const uint8_t offset[511][2]= { { 7, 1}, {15, 1}, { 7, 9}, {15, 9}, { 7, 3}, {15, 3}, { 7,11}, {15,11}, { 7, 5}, {15, 5}, { 7,13}, {15,13}, { 7, 7}, {15, 7}, { 7,15}, {15,15}, -{ 0, 0}, { 8, 0}, { 0, 8}, { 8, 8}, { 4, 4}, {12, 4}, { 4,12}, {12,12}, { 0, 4}, { 8, 4}, { 0,12}, { 8,12}, { 4, 0}, {12, 0}, { 4, 8}, {12, 8}, { 2, 2}, {10, 2}, { 2,10}, {10,10}, { 6, 6}, {14, 6}, { 6,14}, {14,14}, { 2, 6}, {10, 6}, { 2,14}, {10,14}, { 6, 2}, {14, 2}, { 6,10}, {14,10}, { 0, 2}, { 8, 2}, { 0,10}, { 8,10}, { 4, 6}, {12, 6}, { 4,14}, {12,14}, { 0, 6}, { 8, 6}, { 0,14}, { 8,14}, { 4, 2}, {12, 2}, { 4,10}, {12,10}, { 2, 0}, {10, 0}, { 2, 8}, {10, 8}, { 6, 4}, {14, 4}, { 6,12}, {14,12}, { 2, 4}, {10, 4}, { 2,12}, {10,12}, { 6, 0}, {14, 0}, { 6, 8}, {14, 8}, { 1, 1}, { 9, 1}, { 1, 9}, { 9, 9}, { 5, 5}, {13, 5}, { 5,13}, {13,13}, { 1, 5}, { 9, 5}, { 1,13}, { 9,13}, { 5, 1}, {13, 1}, { 5, 9}, {13, 9}, { 3, 3}, {11, 3}, { 3,11}, {11,11}, { 7, 7}, {15, 7}, { 7,15}, {15,15}, { 3, 7}, {11, 7}, { 3,15}, {11,15}, { 7, 3}, {15, 3}, { 7,11}, {15,11}, { 1, 3}, { 9, 3}, { 1,11}, { 9,11}, { 5, 7}, {13, 7}, { 5,15}, {13,15}, { 1, 7}, { 9, 7}, { 1,15}, { 9,15}, { 5, 3}, {13, 3}, { 5,11}, {13,11}, { 3, 1}, {11,1}, { 3, 9}, {11, 9}, { 7, 5}, {15, 5}, { 7,13}, {15,13}, { 3, 5}, {11, 5}, { 3,13}, {11,13}, { 7, 1}, {15, 1}, { 7, 9}, {15, 9}, { 0, 1}, { 8, 1}, { 0, 9}, { 8, 9}, { 4, 5}, {12, 5}, { 4,13}, {12,13}, { 0, 5}, { 8, 5}, { 0,13}, { 8,13}, { 4, 1}, {12, 1}, { 4, 9}, {12, 9}, { 2, 3}, {10, 3}, { 2,11}, {10,11}, { 6, 7}, {14, 7}, { 6,15}, {14,15}, { 2, 7}, {10, 7}, { 2,15}, {10,15}, { 6, 3}, {14, 3}, { 6,11}, {14,11}, { 0, 3}, { 8, 3}, { 0,11}, { 8,11}, { 4, 7}, {12, 7}, { 4,15}, {12,15}, { 0, 7}, { 8, 7}, { 0,15}, { 8,15}, { 4, 3}, {12, 3}, { 4,11}, {12,11}, { 2, 1}, {10, 1}, { 2, 9}, {10, 9}, { 6, 5}, {14, 5}, { 6,13}, {14,13}, { 2, 5}, {10, 5}, { 2,13}, {10,13}, { 6, 1}, {14, 1}, { 6, 9}, {14, 9}, { 1, 0}, { 9, 0}, { 1, 8}, { 9, 8}, { 5, 4}, {13, 4}, { 5,12}, {13,12}, { 1, 4}, { 9, 4}, { 1,12}, { 9,12}, { 5, 0}, {13, 0}, { 5, 8}, {13, 8}, { 3, 2}, {11, 2}, { 3,10}, {11,10}, { 7, 6}, {15, 6}, { 7,14}, {15,14}, { 3, 6}, {11, 6}, { 3,14}, {11,14}, { 7, 2}, {15, 2}, { 7,10}, {15,10}, { 1, 2}, { 9, 2}, { 1,10}, {9,10}, { 5, 6}, {13, 6}, { 5,14}, {13,14}, { 1, 6}, { 9, 6}, { 1,14}, { 9,14}, { 5, 2}, {13, 2}, { 5,10}, {13,10}, { 3, 0}, {11, 0}, { 3, 8}, {11, 8}, { 7, 4}, {15, 4}, { 7,12}, {15,12}, { 3, 4}, {11, 4}, { 3,12}, {11,12}, { 7, 0}, {15, 0}, { 7, 8}, {15, 8}, +{ 0, 0}, { 8, 0}, { 0, 8}, { 8, 8}, { 4, 4}, {12, 4}, { 4,12}, {12,12}, { 0, 4}, { 8, 4}, { 0,12}, { 8,12}, { 4, 0}, {12, 0}, { 4, 8}, {12, 8}, { 2, 2}, {10, 2}, { 2,10}, {10,10}, { 6, 6}, {14, 6}, { 6,14}, {14,14}, { 2, 6}, {10, 6}, { 2,14}, {10,14}, { 6, 2}, {14, 2}, { 6,10}, {14,10}, { 0, 2}, { 8, 2}, { 0,10}, { 8,10}, { 4, 6}, {12, 6}, { 4,14}, {12,14}, { 0, 6}, { 8, 6}, { 0,14}, { 8,14}, { 4, 2}, {12, 2}, { 4,10}, {12,10}, { 2, 0}, {10, 0}, { 2, 8}, {10, 8}, { 6, 4}, {14, 4}, { 6,12}, {14,12}, { 2, 4}, {10, 4}, { 2,12}, {10,12}, { 6, 0}, {14, 0}, { 6, 8}, {14, 8}, { 1, 1}, { 9, 1}, { 1, 9}, { 9, 9}, { 5, 5}, {13, 5}, { 5,13}, {13,13}, { 1, 5}, { 9, 5}, { 1,13}, { 9,13}, { 5, 1}, {13, 1}, { 5, 9}, {13, 9}, { 3, 3}, {11, 3}, { 3,11}, {11,11}, { 7, 7}, {15, 7}, { 7,15}, {15,15}, { 3, 7}, {11, 7}, { 3,15}, {11,15}, { 7, 3}, {15, 3}, { 7,11}, {15,11}, { 1, 3}, { 9, 3}, { 1,11}, { 9,11}, { 5, 7}, {13, 7}, { 5,15}, {13,15}, { 1, 7}, { 9, 7}, { 1,15}, { 9,15}, { 5, 3}, {13, 3}, { 5,11}, {13,11}, { 3, 1}, {11, 1} +, { 3, 9}, {11, 9}, { 7, 5}, {15, 5}, { 7,13}, {15,13}, { 3, 5}, {11, 5}, { 3,13}, {11,13}, { 7, 1}, {15, 1}, { 7, 9}, {15, 9}, { 0, 1}, { 8, 1}, { 0, 9}, { 8, 9}, { 4, 5}, {12, 5}, { 4,13}, {12,13}, { 0, 5}, { 8, 5}, { 0,13}, { 8,13}, { 4, 1}, {12, 1}, { 4, 9}, {12, 9}, { 2, 3}, {10, 3}, { 2,11}, {10,11}, { 6, 7}, {14, 7}, { 6,15}, {14,15}, { 2, 7}, {10, 7}, { 2,15}, {10,15}, { 6, 3}, {14, 3}, { 6,11}, {14,11}, { 0, 3}, { 8, 3}, { 0,11}, { 8,11}, { 4, 7}, {12, 7}, { 4,15}, {12,15}, { 0, 7}, { 8, 7}, { 0,15}, { 8,15}, { 4, 3}, {12, 3}, { 4,11}, {12,11}, { 2, 1}, {10, 1}, { 2, 9}, {10, 9}, { 6, 5}, {14, 5}, { 6,13}, {14,13}, { 2, 5}, {10, 5}, { 2,13}, {10,13}, { 6, 1}, {14, 1}, { 6, 9}, {14, 9}, { 1, 0}, { 9, 0}, { 1, 8}, { 9, 8}, { 5, 4}, {13, 4}, { 5,12}, {13,12}, { 1, 4}, { 9, 4}, { 1,12}, { 9,12}, { 5, 0}, {13, 0}, { 5, 8}, {13, 8}, { 3, 2}, {11, 2}, { 3,10}, {11,10}, { 7, 6}, {15, 6}, { 7,14}, {15,14}, { 3, 6}, {11, 6}, { 3,14}, {11,14}, { 7, 2}, {15, 2}, { 7,10}, {15,10}, { 1, 2}, { 9, 2}, { 1,10}, { 9, +10}, { 5, 6}, {13, 6}, { 5,14}, {13,14}, { 1, 6}, { 9, 6}, { 1,14}, { 9,14}, { 5, 2}, {13, 2}, { 5,10}, {13,10}, { 3, 0}, {11, 0}, { 3, 8}, {11, 8}, { 7, 4}, {15, 4}, { 7,12}, {15,12}, { 3, 4}, {11, 4}, { 3,12}, {11,12}, { 7, 0}, {15, 0}, { 7, 8}, {15, 8}, }; struct vf_priv_s { @@ -201,6 +204,8 @@ static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int ds for(j=0; j<3; j++){ int is_chroma= !!j; + if (!dst[j]) + continue; // HACK avoid crash for Y8 colourspace store_slice_c(dst[j], p->temp[j], dst_stride[j], p->temp_stride[j], width>>is_chroma, height>>is_chroma, 8-p->log2_count); } } @@ -222,9 +227,10 @@ static int config(struct vf_instance *vf, } for(i=0; i< (1<priv->log2_count); i++){ AVCodecContext *avctx_enc; + AVDictionary *opts = NULL; avctx_enc= - vf->priv->avctx_enc[i]= avcodec_alloc_context(); + vf->priv->avctx_enc[i]= avcodec_alloc_context3(NULL); avctx_enc->width = width + BLOCK; avctx_enc->height = height + BLOCK; avctx_enc->time_base= (AVRational){1,25}; // meaningless @@ -234,7 +240,9 @@ static int config(struct vf_instance *vf, avctx_enc->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; avctx_enc->global_quality= 123; - avcodec_open(avctx_enc, enc); + av_dict_set(&opts, "no_bitstream", "1", 0); + avcodec_open2(avctx_enc, enc, &opts); + av_dict_free(&opts); assert(avctx_enc->codec); } vf->priv->frame= avcodec_alloc_frame(); From 81e357db625939afec36c7c92a3a0fcf5e21f2e0 Mon Sep 17 00:00:00 2001 From: multiple authors Date: Tue, 5 Feb 2013 14:17:54 +0100 Subject: [PATCH 181/182] libmpcodecs/vf_pullup: update to latest version from mplayer Please see mplayer svn for authorship and individual commits Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vf_pullup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavfilter/libmpcodecs/vf_pullup.c b/libavfilter/libmpcodecs/vf_pullup.c index 1a0de7c480..e4a28c46d5 100644 --- a/libavfilter/libmpcodecs/vf_pullup.c +++ b/libavfilter/libmpcodecs/vf_pullup.c @@ -270,7 +270,10 @@ static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { - if (height&3) return 0; + if (height&3) { + ff_mp_msg(MSGT_VFILTER, MSGL_ERR, "height must be divisible by four\n"); + return 0; + } return ff_vf_next_config(vf, width, height, d_width, d_height, flags, outfmt); } From 2b20397e1fbe52db800ef5deb810f7bc2602f248 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 5 Feb 2013 15:49:34 +0100 Subject: [PATCH 182/182] libmpcodecs/vd_ffmpeg.h: remove, its unused and removed upstream Signed-off-by: Michael Niedermayer --- libavfilter/libmpcodecs/vd_ffmpeg.h | 24 ------------------------ libavfilter/vf_mp.c | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 libavfilter/libmpcodecs/vd_ffmpeg.h diff --git a/libavfilter/libmpcodecs/vd_ffmpeg.h b/libavfilter/libmpcodecs/vd_ffmpeg.h deleted file mode 100644 index 081d6ee545..0000000000 --- a/libavfilter/libmpcodecs/vd_ffmpeg.h +++ /dev/null @@ -1,24 +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. - */ - -#ifndef MPLAYER_VD_FFMPEG_H -#define MPLAYER_VD_FFMPEG_H - -void ff_init_avcodec(void); - -#endif /* MPLAYER_VD_FFMPEG_H */ diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c index 6c87b3a8f0..e057d628ad 100644 --- a/libavfilter/vf_mp.c +++ b/libavfilter/vf_mp.c @@ -36,7 +36,7 @@ #include "libmpcodecs/vf.h" #include "libmpcodecs/img_format.h" #include "libmpcodecs/cpudetect.h" -#include "libmpcodecs/vd_ffmpeg.h" +#include "libmpcodecs/av_helpers.h" #include "libmpcodecs/vf_scale.h" #include "libmpcodecs/libvo/fastmemcpy.h"