From 3715d841a619f1cbc4776d9b00575dae6fb6534a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 29 Jan 2012 20:55:10 +0000 Subject: [PATCH 01/26] Fix non-C89 declarations in for loops Some compilers still do not support this syntax. Signed-off-by: Mans Rullgard --- avconv.c | 4 ++-- libavcodec/aacenc.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/avconv.c b/avconv.c index 77d6648a53..a6f0838a96 100644 --- a/avconv.c +++ b/avconv.c @@ -421,7 +421,7 @@ static int alloc_buffer(InputStream *ist, FrameBuffer **pbuf) { AVCodecContext *s = ist->st->codec; FrameBuffer *buf = av_mallocz(sizeof(*buf)); - int ret; + int i, ret; const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1; int h_chroma_shift, v_chroma_shift; int edge = 32; // XXX should be avcodec_get_edge_width(), but that fails on svq1 @@ -449,7 +449,7 @@ static int alloc_buffer(InputStream *ist, FrameBuffer **pbuf) memset(buf->base[0], 128, ret); avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); - for (int i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) { + for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) { const int h_shift = i==0 ? 0 : h_chroma_shift; const int v_shift = i==0 ? 0 : v_chroma_shift; if (s->flags & CODEC_FLAG_EMU_EDGE) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index e610a8006f..1957420d00 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -223,8 +223,9 @@ WINDOW_FUNC(eight_short) const float *pwindow = sce->ics.use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; const float *in = audio + 448; float *out = sce->ret; + int w; - for (int w = 0; w < 8; w++) { + for (w = 0; w < 8; w++) { dsp->vector_fmul (out, in, w ? pwindow : swindow, 128); out += 128; in += 128; @@ -686,11 +687,12 @@ static av_cold int dsp_init(AVCodecContext *avctx, AACEncContext *s) static av_cold int alloc_buffers(AVCodecContext *avctx, AACEncContext *s) { + int ch; FF_ALLOCZ_OR_GOTO(avctx, s->buffer.samples, 3 * 1024 * s->channels * sizeof(s->buffer.samples[0]), alloc_fail); FF_ALLOCZ_OR_GOTO(avctx, s->cpe, sizeof(ChannelElement) * s->chan_map[0], alloc_fail); FF_ALLOCZ_OR_GOTO(avctx, avctx->extradata, 5 + FF_INPUT_BUFFER_PADDING_SIZE, alloc_fail); - for(int ch = 0; ch < s->channels; ch++) + for(ch = 0; ch < s->channels; ch++) s->planar_samples[ch] = s->buffer.samples + 3 * 1024 * ch; return 0; From 59f474b49dce5032d2d446d687eef3228e941192 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 27 Jan 2012 23:21:55 +0800 Subject: [PATCH 02/26] png: convert DSP functions to yasm. --- libavcodec/x86/Makefile | 1 + libavcodec/x86/pngdsp-init.c | 116 ++++------------------------ libavcodec/x86/pngdsp.asm | 142 +++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+), 103 deletions(-) create mode 100644 libavcodec/x86/pngdsp.asm diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 7b76aabed3..0576c3ad08 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -42,6 +42,7 @@ MMX-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o YASM-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_yasm.o MMX-OBJS-$(CONFIG_GPL) += x86/idct_mmx.o MMX-OBJS-$(CONFIG_LPC) += x86/lpc_mmx.o +YASM-OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp.o MMX-OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp-init.o YASM-OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp.o MMX-OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp-init.o diff --git a/libavcodec/x86/pngdsp-init.c b/libavcodec/x86/pngdsp-init.c index dfae9b347a..9c7d696aa0 100644 --- a/libavcodec/x86/pngdsp-init.c +++ b/libavcodec/x86/pngdsp-init.c @@ -19,117 +19,27 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/common.h" #include "libavutil/cpu.h" -#include "libavutil/x86_cpu.h" #include "libavcodec/pngdsp.h" -#include "dsputil_mmx.h" -#define PAETH(cpu, abs3)\ -static void add_png_paeth_prediction_##cpu(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)\ -{\ - x86_reg i = -bpp;\ - x86_reg end = w-3;\ - __asm__ volatile(\ - "pxor %%mm7, %%mm7 \n"\ - "movd (%1,%0), %%mm0 \n"\ - "movd (%2,%0), %%mm1 \n"\ - "punpcklbw %%mm7, %%mm0 \n"\ - "punpcklbw %%mm7, %%mm1 \n"\ - "add %4, %0 \n"\ - "1: \n"\ - "movq %%mm1, %%mm2 \n"\ - "movd (%2,%0), %%mm1 \n"\ - "movq %%mm2, %%mm3 \n"\ - "punpcklbw %%mm7, %%mm1 \n"\ - "movq %%mm2, %%mm4 \n"\ - "psubw %%mm1, %%mm3 \n"\ - "psubw %%mm0, %%mm4 \n"\ - "movq %%mm3, %%mm5 \n"\ - "paddw %%mm4, %%mm5 \n"\ - abs3\ - "movq %%mm4, %%mm6 \n"\ - "pminsw %%mm5, %%mm6 \n"\ - "pcmpgtw %%mm6, %%mm3 \n"\ - "pcmpgtw %%mm5, %%mm4 \n"\ - "movq %%mm4, %%mm6 \n"\ - "pand %%mm3, %%mm4 \n"\ - "pandn %%mm3, %%mm6 \n"\ - "pandn %%mm0, %%mm3 \n"\ - "movd (%3,%0), %%mm0 \n"\ - "pand %%mm1, %%mm6 \n"\ - "pand %%mm4, %%mm2 \n"\ - "punpcklbw %%mm7, %%mm0 \n"\ - "movq %6, %%mm5 \n"\ - "paddw %%mm6, %%mm0 \n"\ - "paddw %%mm2, %%mm3 \n"\ - "paddw %%mm3, %%mm0 \n"\ - "pand %%mm5, %%mm0 \n"\ - "movq %%mm0, %%mm3 \n"\ - "packuswb %%mm3, %%mm3 \n"\ - "movd %%mm3, (%1,%0) \n"\ - "add %4, %0 \n"\ - "cmp %5, %0 \n"\ - "jle 1b \n"\ - :"+r"(i)\ - :"r"(dst), "r"(top), "r"(src), "r"((x86_reg)bpp), "g"(end),\ - "m"(ff_pw_255)\ - :"memory"\ - );\ -} - -#define ABS3_MMX2\ - "psubw %%mm5, %%mm7 \n"\ - "pmaxsw %%mm7, %%mm5 \n"\ - "pxor %%mm6, %%mm6 \n"\ - "pxor %%mm7, %%mm7 \n"\ - "psubw %%mm3, %%mm6 \n"\ - "psubw %%mm4, %%mm7 \n"\ - "pmaxsw %%mm6, %%mm3 \n"\ - "pmaxsw %%mm7, %%mm4 \n"\ - "pxor %%mm7, %%mm7 \n" - -#define ABS3_SSSE3\ - "pabsw %%mm3, %%mm3 \n"\ - "pabsw %%mm4, %%mm4 \n"\ - "pabsw %%mm5, %%mm5 \n" - -PAETH(mmx2, ABS3_MMX2) -#if HAVE_SSSE3 -PAETH(ssse3, ABS3_SSSE3) -#endif - -static void add_bytes_l2_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w) -{ - x86_reg i=0; - - __asm__ volatile( - "jmp 2f \n\t" - "1: \n\t" - "movq (%2, %0), %%mm0 \n\t" - "movq 8(%2, %0), %%mm1 \n\t" - "paddb (%3, %0), %%mm0 \n\t" - "paddb 8(%3, %0), %%mm1 \n\t" - "movq %%mm0, (%1, %0) \n\t" - "movq %%mm1, 8(%1, %0) \n\t" - "add $16, %0 \n\t" - "2: \n\t" - "cmp %4, %0 \n\t" - " js 1b \n\t" - : "+r" (i) - : "r"(dst), "r"(src1), "r"(src2), "r"((x86_reg) w - 15) - ); - for (; i < w; i++) - dst[i] = src1[i] + src2[i]; -} +void ff_add_png_paeth_prediction_mmx2 (uint8_t *dst, uint8_t *src, + uint8_t *top, int w, int bpp); +void ff_add_png_paeth_prediction_ssse3(uint8_t *dst, uint8_t *src, + uint8_t *top, int w, int bpp); +void ff_add_bytes_l2_mmx (uint8_t *dst, uint8_t *src1, + uint8_t *src2, int w); void ff_pngdsp_init_x86(PNGDSPContext *dsp) { +#if HAVE_YASM int flags = av_get_cpu_flags(); if (flags & AV_CPU_FLAG_MMX) - dsp->add_bytes_l2 = add_bytes_l2_mmx; + dsp->add_bytes_l2 = ff_add_bytes_l2_mmx; if (flags & AV_CPU_FLAG_MMX2) - dsp->add_paeth_prediction = add_png_paeth_prediction_mmx2; - if (HAVE_SSSE3 && flags & AV_CPU_FLAG_SSSE3) - dsp->add_paeth_prediction = add_png_paeth_prediction_ssse3; + dsp->add_paeth_prediction = ff_add_png_paeth_prediction_mmx2; + if (flags & AV_CPU_FLAG_SSSE3) + dsp->add_paeth_prediction = ff_add_png_paeth_prediction_ssse3; +#endif } diff --git a/libavcodec/x86/pngdsp.asm b/libavcodec/x86/pngdsp.asm new file mode 100644 index 0000000000..92425ad099 --- /dev/null +++ b/libavcodec/x86/pngdsp.asm @@ -0,0 +1,142 @@ +;****************************************************************************** +;* x86 optimizations for PNG decoding +;* +;* Copyright (c) 2008 Loren Merritt +;* +;* This file is part of Libav. +;* +;* Libav is free software; you can redistribute it and/or +;* modify it under the terms of the GNU 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 +;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" +%include "x86util.asm" + +SECTION_RODATA + +cextern pw_255 + +section .text align=16 + +; %1 = nr. of xmm registers used +%macro ADD_BYTES_FN 1 +cglobal add_bytes_l2, 4, 6, %1, dst, src1, src2, wa, w, i +%if ARCH_X86_64 + movsxd waq, wad +%endif + xor iq, iq + + ; vector loop + mov wq, waq + and waq, ~(mmsize*2-1) + jmp .end_v +.loop_v: + mova m0, [src1q+iq] + mova m1, [src1q+iq+mmsize] + paddb m0, [src2q+iq] + paddb m1, [src2q+iq+mmsize] + mova [dstq+iq ], m0 + mova [dstq+iq+mmsize], m1 + add iq, mmsize*2 +.end_v: + cmp iq, waq + jl .loop_v + + ; scalar loop for leftover + jmp .end_s +.loop_s: + mov wab, [src1q+iq] + add wab, [src2q+iq] + mov [dstq+iq], wab + inc iq +.end_s: + cmp iq, wq + jl .loop_s + REP_RET +%endmacro + +INIT_MMX mmx +ADD_BYTES_FN 0 + +%macro ADD_PAETH_PRED_FN 1 +cglobal add_png_paeth_prediction, 5, 7, %1, dst, src, top, w, bpp, end, cntr +%if ARCH_X86_64 + movsxd bppq, bppd + movsxd wq, wd +%endif + lea endq, [dstq+wq-(mmsize/2-1)] + sub topq, dstq + sub srcq, dstq + sub dstq, bppq + pxor m7, m7 + movh m0, [dstq] + movh m1, [topq+dstq] + punpcklbw m0, m7 + punpcklbw m1, m7 + add dstq, bppq +.loop: + mova m2, m1 + movh m1, [topq+dstq] + mova m3, m2 + punpcklbw m1, m7 + mova m4, m2 + psubw m3, m1 + psubw m4, m0 + mova m5, m3 + paddw m5, m4 +%if cpuflag(ssse3) + pabsw m3, m3 + pabsw m4, m4 + pabsw m5, m5 +%else ; !cpuflag(ssse3) + psubw m7, m5 + pmaxsw m5, m7 + pxor m6, m6 + pxor m7, m7 + psubw m6, m3 + psubw m7, m4 + pmaxsw m3, m6 + pmaxsw m4, m7 + pxor m7, m7 +%endif ; cpuflag(ssse3) + mova m6, m4 + pminsw m6, m5 + pcmpgtw m3, m6 + pcmpgtw m4, m5 + mova m6, m4 + pand m4, m3 + pandn m6, m3 + pandn m3, m0 + movh m0, [srcq+dstq] + pand m6, m1 + pand m2, m4 + punpcklbw m0, m7 + paddw m0, m6 + paddw m3, m2 + paddw m0, m3 + pand m0, [pw_255] + mova m3, m0 + packuswb m3, m3 + movh [dstq], m3 + add dstq, bppq + cmp dstq, endq + jle .loop + REP_RET +%endmacro + +INIT_MMX mmx2 +ADD_PAETH_PRED_FN 0 + +INIT_MMX ssse3 +ADD_PAETH_PRED_FN 0 From f91c4b7824a558b472bb0acd610c772cd9904003 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 27 Jan 2012 23:23:05 +0800 Subject: [PATCH 03/26] png: add SSE2 version for add_bytes_l2. --- libavcodec/x86/pngdsp-init.c | 6 ++++++ libavcodec/x86/pngdsp.asm | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/libavcodec/x86/pngdsp-init.c b/libavcodec/x86/pngdsp-init.c index 9c7d696aa0..136e92eed0 100644 --- a/libavcodec/x86/pngdsp-init.c +++ b/libavcodec/x86/pngdsp-init.c @@ -29,16 +29,22 @@ void ff_add_png_paeth_prediction_ssse3(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp); void ff_add_bytes_l2_mmx (uint8_t *dst, uint8_t *src1, uint8_t *src2, int w); +void ff_add_bytes_l2_sse2(uint8_t *dst, uint8_t *src1, + uint8_t *src2, int w); void ff_pngdsp_init_x86(PNGDSPContext *dsp) { #if HAVE_YASM int flags = av_get_cpu_flags(); +#if ARCH_X86_32 if (flags & AV_CPU_FLAG_MMX) dsp->add_bytes_l2 = ff_add_bytes_l2_mmx; +#endif if (flags & AV_CPU_FLAG_MMX2) dsp->add_paeth_prediction = ff_add_png_paeth_prediction_mmx2; + if (flags & AV_CPU_FLAG_SSE2) + dsp->add_bytes_l2 = ff_add_bytes_l2_sse2; if (flags & AV_CPU_FLAG_SSSE3) dsp->add_paeth_prediction = ff_add_png_paeth_prediction_ssse3; #endif diff --git a/libavcodec/x86/pngdsp.asm b/libavcodec/x86/pngdsp.asm index 92425ad099..bff76e0c0d 100644 --- a/libavcodec/x86/pngdsp.asm +++ b/libavcodec/x86/pngdsp.asm @@ -53,6 +53,21 @@ cglobal add_bytes_l2, 4, 6, %1, dst, src1, src2, wa, w, i cmp iq, waq jl .loop_v +%if mmsize == 16 + ; vector loop + mov wq, waq + and waq, ~7 + jmp .end_l +.loop_l: + movq mm0, [src1q+iq] + paddb mm0, [src2q+iq] + movq [dstq+iq ], mm0 + add iq, 8 +.end_l: + cmp iq, waq + jl .loop_l +%endif + ; scalar loop for leftover jmp .end_s .loop_s: @@ -66,8 +81,13 @@ cglobal add_bytes_l2, 4, 6, %1, dst, src1, src2, wa, w, i REP_RET %endmacro +%if ARCH_X86_32 INIT_MMX mmx ADD_BYTES_FN 0 +%endif + +INIT_XMM sse2 +ADD_BYTES_FN 2 %macro ADD_PAETH_PRED_FN 1 cglobal add_png_paeth_prediction, 5, 7, %1, dst, src, top, w, bpp, end, cntr From af79a0c48a41fd99b674b39ac509ae442974715d Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 27 Jan 2012 23:28:28 +0800 Subject: [PATCH 04/26] png: add support for bpp>4 to paeth x86 SIMD code. This fixes playback of e.g. RGB48 (bpp=6) content on x86 CPUs. Fixes bug 214. --- libavcodec/x86/pngdsp.asm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libavcodec/x86/pngdsp.asm b/libavcodec/x86/pngdsp.asm index bff76e0c0d..8c4cb19da0 100644 --- a/libavcodec/x86/pngdsp.asm +++ b/libavcodec/x86/pngdsp.asm @@ -2,6 +2,7 @@ ;* x86 optimizations for PNG decoding ;* ;* Copyright (c) 2008 Loren Merritt +;* Copyright (c) 2012 Ronald S. Bultje ;* ;* This file is part of Libav. ;* @@ -100,6 +101,12 @@ cglobal add_png_paeth_prediction, 5, 7, %1, dst, src, top, w, bpp, end, cntr sub srcq, dstq sub dstq, bppq pxor m7, m7 + + PUSH dstq + lea cntrq, [bppq-1] + shr cntrq, 2 + mmsize/16 +.bpp_loop: + lea dstq, [dstq+cntrq*(mmsize/2)] movh m0, [dstq] movh m1, [topq+dstq] punpcklbw m0, m7 @@ -152,7 +159,12 @@ cglobal add_png_paeth_prediction, 5, 7, %1, dst, src, top, w, bpp, end, cntr add dstq, bppq cmp dstq, endq jle .loop - REP_RET + + mov dstq, [rsp] + dec cntrq + jge .bpp_loop + POP dstq + RET %endmacro INIT_MMX mmx2 From b864b38397a2962d265ad39005265bac4fb001ef Mon Sep 17 00:00:00 2001 From: Mike Melanson Date: Sun, 29 Jan 2012 21:24:41 -0800 Subject: [PATCH 05/26] yuv4mpeg: allow YUV4MPEG2 demuxer to recognize 'C420' colorspace. Current demuxer recognizes several colorspace formats that begin with 'C420' but does not yet recognize plain 'C420'. GStreamer's y4menc component generates .y4m files with a 'C420' colorspace. This new comparison is placed after the other 'C420' checks so that it doesn't interfere with them. Signed-off-by: Anton Khirnov --- libavformat/yuv4mpeg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c index afb5bfaab2..df0fc8f1a5 100644 --- a/libavformat/yuv4mpeg.c +++ b/libavformat/yuv4mpeg.c @@ -244,6 +244,9 @@ static int yuv4_read_header(AVFormatContext *s) } else if (strncmp("420paldv", tokstart, 8) == 0) { pix_fmt = PIX_FMT_YUV420P; chroma_sample_location = AVCHROMA_LOC_TOPLEFT; + } else if (strncmp("420", tokstart, 3) == 0) { + pix_fmt = PIX_FMT_YUV420P; + chroma_sample_location = AVCHROMA_LOC_CENTER; } else if (strncmp("411", tokstart, 3) == 0) pix_fmt = PIX_FMT_YUV411P; else if (strncmp("422", tokstart, 3) == 0) From cc09dc7863e4ffdf5d7c18472721c5ce739f26b0 Mon Sep 17 00:00:00 2001 From: Mike Melanson Date: Sun, 29 Jan 2012 21:29:25 -0800 Subject: [PATCH 06/26] s/vbsf/bsf/ -vbsf doesn't exist anymore. It got renamed to -bsf somewhere along the line. Update print statement accordingly. Signed-off-by: Anton Khirnov --- libavformat/mpegtsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index c05f7f690e..8232cbc76d 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -956,7 +956,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) { av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, " - "no startcode found, use -vbsf h264_mp4toannexb\n"); + "no startcode found, use -bsf h264_mp4toannexb\n"); return -1; } From 420df8b7c414cfd0cae29930344889651825f9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Sat, 28 Jan 2012 23:29:26 -0500 Subject: [PATCH 07/26] avformat_write_header(): detail error message Give the exact aspect ratios when there is a mismatch between encoder and muxer. Signed-off-by: Anton Khirnov --- libavformat/utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 41450971af..9c59947fb7 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2782,7 +2782,11 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) goto fail; } if(av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)){ - av_log(s, AV_LOG_ERROR, "Aspect ratio mismatch between encoder and muxer layer\n"); + av_log(s, AV_LOG_ERROR, "Aspect ratio mismatch between encoder " + "(%d/%d) and muxer layer (%d/%d)\n", + st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, + st->codec->sample_aspect_ratio.num, + st->codec->sample_aspect_ratio.den); ret = AVERROR(EINVAL); goto fail; } From 8b933129b932f523a746e921a0a20b8dd8816971 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 29 Jan 2012 20:09:22 +0000 Subject: [PATCH 08/26] avutil: make intfloat api public The functions are already av_ prefixed and intfloat header is already provided. Install libavutil/intfloat.h Signed-off-by: Paul B Mahol Signed-off-by: Anton Khirnov --- doc/APIchanges | 4 ++++ libavutil/Makefile | 1 + libavutil/avutil.h | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7cac096a3c..39f1a3eed4 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,10 @@ libavutil: 2011-04-18 API changes, most recent first: +2012-01-30 - xxxxxxx - lavu 51.22.0 - intfloat.h + Add a new installed header libavutil/intfloat.h with int/float punning + functions. + 2012-01-25 - lavf 53.22.0 f1caf01 Allow doing av_write_frame(ctx, NULL) for flushing possible buffered data within a muxer. Added AVFMT_ALLOW_FLUSH for diff --git a/libavutil/Makefile b/libavutil/Makefile index 63d848a343..626b60aa92 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -17,6 +17,7 @@ HEADERS = adler32.h \ fifo.h \ file.h \ imgutils.h \ + intfloat.h \ intfloat_readwrite.h \ intreadwrite.h \ lfg.h \ diff --git a/libavutil/avutil.h b/libavutil/avutil.h index f0be5c110a..0e62b4a13f 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -154,7 +154,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 21 +#define LIBAVUTIL_VERSION_MINOR 22 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From a846202343af7c56bf444ec47d4bb26a5d2b83ce Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 30 Jan 2012 09:38:41 +0100 Subject: [PATCH 09/26] rtsp: Remove some unused variables from ff_rtsp_connect(). --- libavformat/rtsp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index cdcda7eb67..1fb7b2bcda 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1357,7 +1357,6 @@ int ff_rtsp_connect(AVFormatContext *s) { RTSPState *rt = s->priv_data; char host[1024], path[1024], tcpname[1024], cmd[2048], auth[128]; - char *option_list, *option, *filename; int port, err, tcp_fd; RTSPMessageHeader reply1 = {0}, *reply = &reply1; int lower_transport_mask = 0; From 6b039003822a03add20c7ba91fc857dca52b0a03 Mon Sep 17 00:00:00 2001 From: Christophe Gisquet Date: Thu, 19 Jan 2012 21:48:39 +0100 Subject: [PATCH 10/26] x86 dsputil: provide SSE2/SSSE3 versions of bswap_buf While pshufb allows emulating bswap on XMM registers for SSSE3, more shuffling is needed for SSE2. Alignment is critical, so specific codepaths are provided for this case. For the huffyuv sequence "angels_480-huffyuvcompress.avi": C (using bswap instruction): ~ 55k cycles SSE2: ~ 40k cycles SSSE3 using unaligned loads: ~ 35k cycles SSSE3 using aligned loads: ~ 30k cycles Signed-off-by: Diego Biurrun --- libavcodec/x86/dsputil_mmx.c | 5 ++ libavcodec/x86/dsputil_yasm.asm | 123 ++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 7cc16c0f82..c40cab51f0 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2313,6 +2313,9 @@ void ff_apply_window_int16_ssse3 (int16_t *output, const int16_t *input, void ff_apply_window_int16_ssse3_atom(int16_t *output, const int16_t *input, const int16_t *window, unsigned int len); +void ff_bswap32_buf_ssse3(uint32_t *dst, const uint32_t *src, int w); +void ff_bswap32_buf_sse2(uint32_t *dst, const uint32_t *src, int w); + void ff_add_hfyu_median_prediction_mmx2(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top); int ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src, int w, int left); int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src, int w, int left); @@ -2798,6 +2801,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->apply_window_int16 = ff_apply_window_int16_sse2; } } + c->bswap_buf = ff_bswap32_buf_sse2; #endif } if (mm_flags & AV_CPU_FLAG_SSSE3) { @@ -2810,6 +2814,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) if (!(mm_flags & (AV_CPU_FLAG_SSE42|AV_CPU_FLAG_3DNOW))) { // cachesplit c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_ssse3; } + c->bswap_buf = ff_bswap32_buf_ssse3; #endif } diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm index 4607ff15d7..611f5c8a72 100644 --- a/libavcodec/x86/dsputil_yasm.asm +++ b/libavcodec/x86/dsputil_yasm.asm @@ -30,6 +30,7 @@ pb_zzzz3333zzzzbbbb: db -1,-1,-1,-1,3,3,3,3,-1,-1,-1,-1,11,11,11,11 pb_zz11zz55zz99zzdd: db -1,-1,1,1,-1,-1,5,5,-1,-1,9,9,-1,-1,13,13 pb_revwords: db 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1 pd_16384: times 4 dd 16384 +pb_bswap32: db 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 SECTION_TEXT @@ -1178,3 +1179,125 @@ INIT_XMM sse BUTTERFLIES_FLOAT_INTERLEAVE INIT_YMM avx BUTTERFLIES_FLOAT_INTERLEAVE + +INIT_XMM sse2 +; %1 = aligned/unaligned +%macro BSWAP_LOOPS_SSE2 1 + mov r3, r2 + sar r2, 3 + jz .left4_%1 +.loop8_%1: + mov%1 m0, [r1 + 0] + mov%1 m1, [r1 + 16] + pshuflw m0, m0, 10110001b + pshuflw m1, m1, 10110001b + pshufhw m0, m0, 10110001b + pshufhw m1, m1, 10110001b + mova m2, m0 + mova m3, m1 + psllw m0, 8 + psllw m1, 8 + psrlw m2, 8 + psrlw m3, 8 + por m2, m0 + por m3, m1 + mova [r0 + 0], m2 + mova [r0 + 16], m3 + add r1, 32 + add r0, 32 + dec r2 + jnz .loop8_%1 +.left4_%1: + mov r2, r3 + and r3, 4 + jz .left + mov%1 m0, [r1] + pshuflw m0, m0, 10110001b + pshufhw m0, m0, 10110001b + mova m2, m0 + psllw m0, 8 + psrlw m2, 8 + por m2, m0 + mova [r0], m2 + add r1, 16 + add r0, 16 +%endmacro + +; void bswap_buf(uint32_t *dst, const uint32_t *src, int w); +cglobal bswap32_buf, 3,4,5 + mov r3, r1 + and r3, 15 + jz .start_align + BSWAP_LOOPS_SSE2 u + jmp .left +.start_align: + BSWAP_LOOPS_SSE2 a +.left: + and r2, 3 + jz .end +.loop2: + mov r3d, [r1] + bswap r3d + mov [r0], r3d + add r1, 4 + add r0, 4 + dec r2 + jnz .loop2 +.end + RET + +; %1 = aligned/unaligned +%macro BSWAP_LOOPS_SSSE3 1 + mov r3, r2 + sar r2, 3 + jz .left4_%1 +.loop8_%1: + mov%1 m0, [r1 + 0] + mov%1 m1, [r1 + 16] + pshufb m0, m2 + pshufb m1, m2 + mova [r0 + 0], m0 + mova [r0 + 16], m1 + add r0, 32 + add r1, 32 + dec r2 + jnz .loop8_%1 +.left4_%1: + mov r2, r3 + and r3, 4 + jz .left2 + mov%1 m0, [r1] + pshufb m0, m2 + mova [r0], m0 + add r1, 16 + add r0, 16 +%endmacro + +INIT_XMM ssse3 +; void bswap_buf(uint32_t *dst, const uint32_t *src, int w); +cglobal bswap32_buf, 3,4,3 + mov r3, r1 + mova m2, [pb_bswap32] + and r3, 15 + jz .start_align + BSWAP_LOOPS_SSSE3 u + jmp .left2 +.start_align: + BSWAP_LOOPS_SSSE3 a +.left2: + mov r3, r2 + and r2, 2 + jz .left1 + movq m0, [r1] + pshufb m0, m2 + movq [r0], m0 + add r1, 8 + add r0, 8 +.left1: + and r3, 1 + jz .end + mov r2d, [r1] + bswap r2d + mov [r0], r2d +.end: + RET From e9ba6b3704a3e119a819ccd4236ed9a7c1180b82 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 29 Jan 2012 22:08:58 +0100 Subject: [PATCH 11/26] build: Use order-only prerequisites for creating FATE reference file dirs. --- tests/Makefile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index dba9e83688..85665d9dbc 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -5,20 +5,18 @@ REFS = $(AREF) $(VREF) $(VREF): avconv$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm $(AREF): avconv$(EXESUF) tests/data/asynth1.sw -tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF) - @mkdir -p tests/vsynth1 +OBJDIRS += tests/data tests/vsynth1 tests/vsynth2 + +tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF) | tests/vsynth1 $(M)./$< 'tests/vsynth1/' -tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF) - @mkdir -p tests/vsynth2 +tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF) | tests/vsynth2 $(M)./$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm -tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF) - @mkdir -p tests/data +tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF) | tests/data $(M)./$< $@ -tests/data/asynth-16000-1.sw: tests/audiogen$(HOSTEXESUF) - @mkdir -p tests/data +tests/data/asynth-16000-1.sw: tests/audiogen$(HOSTEXESUF) | tests/data $(M)./$< $@ 16000 1 tests/data/asynth%.sw tests/vsynth%/00.pgm: TAG = GEN From fe47ea8f7a5575ce9bb63907c1f0a996de4a7b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 20 Jan 2012 20:33:13 +0200 Subject: [PATCH 12/26] doc: Document mov/mp4 fragmentation options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- doc/muxers.texi | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/doc/muxers.texi b/doc/muxers.texi index 5a609c8b9a..aab3b6a638 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -142,6 +142,67 @@ Note also that the pattern must not necessarily contain "%d" or avconv -i in.avi -f image2 -frames:v 1 img.jpeg @end example +@section MOV/MP4/ISMV + +The mov/mp4/ismv muxer supports fragmentation. Normally, a MOV/MP4 +file has all the metadata about all packets stored in one location +(written at the end of the file, it can be moved to the start for +better playback using the @command{qt-faststart} tool). A fragmented +file consists of a number of fragments, where packets and metadata +about these packets are stored together. Writing a fragmented +file has the advantage that the file is decodable even if the +writing is interrupted (while a normal MOV/MP4 is undecodable if +it is not properly finished), and it requires less memory when writing +very long files (since writing normal MOV/MP4 files stores info about +every single packet in memory until the file is closed). The downside +is that it is less compatible with other applications. + +Fragmentation is enabled by setting one of the AVOptions that define +how to cut the file into fragments: + +@table @option +@item -movflags frag_keyframe +Start a new fragment at each video keyframe. +@item -frag_duration @var{duration} +Create fragments that are @var{duration} microseconds long. +@item -frag_size @var{size} +Create fragments that contain up to @var{size} bytes of payload data. +@item -movflags frag_custom +Allow the caller to manually choose when to cut fragments, by +calling @code{av_write_frame(ctx, NULL)} to write a fragment with +the packets written so far. (This is only useful with other +applications integrating libavformat, not from @command{avconv}.) +@end table + +Additionally, the way the output file is written can be adjusted +through a few other options: + +@table @option +@item -movflags empty_moov +Write an initial moov atom directly at the start of the file, without +describing any samples in it. Generally, an mdat/moov pair is written +at the start of the file, as a normal MOV/MP4 file, containing only +a short portion of the file. With this option set, there is no initial +mdat atom, and the moov atom only describes the tracks but has +a zero duration. + +Files written with this option set do not work in QuickTime. +This option is implicitly set when writing ismv (Smooth Streaming) files. +@item -movflags separate_moof +Write a separate moof (movie fragment) atom for each track. Normally, +packets for all tracks are written in a moof atom (which is slightly +more efficient), but with this option set, the muxer writes one moof/mdat +pair for each track, making it easier to separate tracks. + +This option is implicitly set when writing ismv (Smooth Streaming) files. +@end table + +Smooth Streaming content can be pushed in real time to a publishing +point on IIS with this muxer. Example: +@example +avconv -re @var{} -movflags isml+frag_keyframe -f ismv http://server/publishingpoint.isml/Streams(Encoder1) +@end example + @section mpegts MPEG transport stream muxer. From 08d8029ea89a3a4ae3e1fa509a35d4b7a8a406a2 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 30 Jan 2012 13:58:50 +0000 Subject: [PATCH 13/26] swscale: more generic check for planar destination formats with alpha Signed-off-by: Paul B Mahol Signed-off-by: Ronald S. Bultje --- libswscale/swscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 05ee8a4d91..eaec1dd82c 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2672,7 +2672,7 @@ static int swScale(SwsContext *c, const uint8_t* src[], } } - if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf) + if (isPlanar(dstFormat) && isALPHA(dstFormat) && !alpPixBuf) fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255); #if HAVE_MMX2 From b7d3dd907f51c1b86c5aad7e2ec4870da53e095e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 30 Jan 2012 16:19:15 +0200 Subject: [PATCH 14/26] movenc: cosmetics: Get rid of camelCase identifiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also add spacing around operators on touched lines, and split one line to match the common style. Signed-off-by: Martin Storsjö --- libavformat/movenc.c | 287 ++++++++++++++++++++++--------------------- libavformat/movenc.h | 16 +-- 2 files changed, 152 insertions(+), 151 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 22e8d842f4..ee0d96e534 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -69,7 +69,7 @@ static const AVClass flavor ## _muxer_class = {\ }; //FIXME support 64 bit variant with wide placeholders -static int64_t updateSize(AVIOContext *pb, int64_t pos) +static int64_t update_size(AVIOContext *pb, int64_t pos) { int64_t curpos = avio_tell(pb); avio_seek(pb, pos, SEEK_SET); @@ -99,7 +99,7 @@ static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track) else avio_wb32(pb, track->cluster[i].pos); } - return updateSize(pb, pos); + return update_size(pb, pos); } /* Sample size atom */ @@ -137,7 +137,7 @@ static int mov_write_stsz_tag(AVIOContext *pb, MOVTrack *track) } } } - return updateSize(pb, pos); + return update_size(pb, pos); } /* Sample to chunk atom */ @@ -153,12 +153,12 @@ static int mov_write_stsc_tag(AVIOContext *pb, MOVTrack *track) entryPos = avio_tell(pb); avio_wb32(pb, track->entry); // entry count for (i=0; ientry; i++) { - if(oldval != track->cluster[i].samplesInChunk) + if (oldval != track->cluster[i].samples_in_chunk) { avio_wb32(pb, i+1); // first chunk - avio_wb32(pb, track->cluster[i].samplesInChunk); // samples per chunk + avio_wb32(pb, track->cluster[i].samples_in_chunk); // samples per chunk avio_wb32(pb, 0x1); // sample description index - oldval = track->cluster[i].samplesInChunk; + oldval = track->cluster[i].samples_in_chunk; index++; } } @@ -167,7 +167,7 @@ static int mov_write_stsc_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, index); // rewrite size avio_seek(pb, curpos, SEEK_SET); - return updateSize(pb, pos); + return update_size(pb, pos); } /* Sync sample atom */ @@ -191,7 +191,7 @@ static int mov_write_stss_tag(AVIOContext *pb, MOVTrack *track, uint32_t flag) avio_seek(pb, entryPos, SEEK_SET); avio_wb32(pb, index); // rewrite size avio_seek(pb, curpos, SEEK_SET); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_amr_tag(AVIOContext *pb, MOVTrack *track) @@ -215,13 +215,13 @@ static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track) uint8_t buf[3]; int fscod, bsid, bsmod, acmod, lfeon, frmsizecod; - if (track->vosLen < 7) + if (track->vos_len < 7) return -1; avio_wb32(pb, 11); ffio_wfourcc(pb, "dac3"); - init_get_bits(&gbc, track->vosData+4, (track->vosLen-4) * 8); + init_get_bits(&gbc, track->vos_data + 4, (track->vos_len - 4) * 8); fscod = get_bits(&gbc, 2); frmsizecod = get_bits(&gbc, 6); bsid = get_bits(&gbc, 5); @@ -270,7 +270,7 @@ static int mov_write_enda_tag(AVIOContext *pb) return 10; } -static void putDescr(AVIOContext *pb, int tag, unsigned int size) +static void put_descr(AVIOContext *pb, int tag, unsigned int size) { int i = 3; avio_w8(pb, tag); @@ -282,19 +282,19 @@ static void putDescr(AVIOContext *pb, int tag, unsigned int size) static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic { int64_t pos = avio_tell(pb); - int decoderSpecificInfoLen = track->vosLen ? 5+track->vosLen : 0; + int decoder_specific_info_len = track->vos_len ? 5 + track->vos_len : 0; avio_wb32(pb, 0); // size ffio_wfourcc(pb, "esds"); avio_wb32(pb, 0); // Version // ES descriptor - putDescr(pb, 0x03, 3 + 5+13 + decoderSpecificInfoLen + 5+1); - avio_wb16(pb, track->trackID); + put_descr(pb, 0x03, 3 + 5+13 + decoder_specific_info_len + 5+1); + avio_wb16(pb, track->track_id); avio_w8(pb, 0x00); // flags (= no flags) // DecoderConfig descriptor - putDescr(pb, 0x04, 13 + decoderSpecificInfoLen); + put_descr(pb, 0x04, 13 + decoder_specific_info_len); // Object type indication if ((track->enc->codec_id == CODEC_ID_MP2 || @@ -320,16 +320,16 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic else avio_wb32(pb, track->enc->rc_max_rate); // avg bitrate - if (track->vosLen) { + if (track->vos_len) { // DecoderSpecific info descriptor - putDescr(pb, 0x05, track->vosLen); - avio_write(pb, track->vosData, track->vosLen); + put_descr(pb, 0x05, track->vos_len); + avio_write(pb, track->vos_data, track->vos_len); } // SL descriptor - putDescr(pb, 0x06, 1); + put_descr(pb, 0x06, 1); avio_w8(pb, 0x02); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_pcm_le_gt16(enum CodecID codec_id) @@ -347,7 +347,7 @@ static int mov_write_ms_tag(AVIOContext *pb, MOVTrack *track) avio_wl32(pb, track->tag); // store it byteswapped track->enc->codec_tag = av_bswap16(track->tag >> 16); ff_put_wav_header(pb, track->enc); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_chan_tag(AVIOContext *pb, MOVTrack *track) @@ -372,7 +372,7 @@ static int mov_write_chan_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, bitmap); // mChannelBitmap avio_wb32(pb, 0); // mNumberChannelDescriptions - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track) @@ -409,15 +409,15 @@ static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, 8); /* size */ avio_wb32(pb, 0); /* null tag */ - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_glbl_tag(AVIOContext *pb, MOVTrack *track) { - avio_wb32(pb, track->vosLen+8); + avio_wb32(pb, track->vos_len + 8); ffio_wfourcc(pb, "glbl"); - avio_write(pb, track->vosData, track->vosLen); - return 8+track->vosLen; + avio_write(pb, track->vos_data, track->vos_len); + return 8 + track->vos_len; } /** @@ -484,7 +484,7 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, 0x7F000000); avio_wb32(pb, av_get_bits_per_sample(track->enc->codec_id)); avio_wb32(pb, mov_get_lpcm_flags(track->enc->codec_id)); - avio_wb32(pb, track->sampleSize); + avio_wb32(pb, track->sample_size); avio_wb32(pb, track->audio_vbr ? track->enc->frame_size : 1); } else { /* reserved for mp4/3gp */ @@ -514,10 +514,10 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track) mov_write_ac3_tag(pb, track); else if(track->enc->codec_id == CODEC_ID_ALAC) mov_write_extradata_tag(pb, track); - else if(track->vosLen > 0) + else if (track->vos_len > 0) mov_write_glbl_tag(pb, track); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_d263_tag(AVIOContext *pb) @@ -551,8 +551,8 @@ static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, 0); ffio_wfourcc(pb, "avcC"); - ff_isom_write_avcc(pb, track->vosData, track->vosLen); - return updateSize(pb, pos); + ff_isom_write_avcc(pb, track->vos_data, track->vos_len); + return update_size(pb, pos); } /* also used by all avid codecs (dv, imx, meridien) and their variants */ @@ -577,10 +577,10 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track) ffio_wfourcc(pb, "ARES"); ffio_wfourcc(pb, "ARES"); ffio_wfourcc(pb, "0001"); - avio_wb32(pb, AV_RB32(track->vosData + 0x28)); /* dnxhd cid, some id ? */ + avio_wb32(pb, AV_RB32(track->vos_data + 0x28)); /* dnxhd cid, some id ? */ avio_wb32(pb, track->enc->width); /* values below are based on samples created with quicktime and avid codecs */ - if (track->vosData[5] & 2) { // interlaced + if (track->vos_data[5] & 2) { // interlaced avio_wb32(pb, track->enc->height/2); avio_wb32(pb, 2); /* unknown */ avio_wb32(pb, 0); /* unknown */ @@ -820,7 +820,7 @@ static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track) if (track->enc->extradata_size) avio_write(pb, track->enc->extradata, track->enc->extradata_size); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack *track) @@ -896,7 +896,7 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) mov_write_uuid_tag_ipod(pb); } else if (track->enc->field_order != AV_FIELD_UNKNOWN) mov_write_fiel_tag(pb, track); - else if(track->vosLen > 0) + else if (track->vos_len > 0) mov_write_glbl_tag(pb, track); if (track->enc->sample_aspect_ratio.den && track->enc->sample_aspect_ratio.num && @@ -904,7 +904,7 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) mov_write_pasp_tag(pb, track); } - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track) @@ -924,7 +924,7 @@ static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track) ffio_wfourcc(pb, "tims"); avio_wb32(pb, track->timescale); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_stsd_tag(AVIOContext *pb, MOVTrack *track) @@ -942,7 +942,7 @@ static int mov_write_stsd_tag(AVIOContext *pb, MOVTrack *track) mov_write_subtitle_tag(pb, track); else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) mov_write_rtp_tag(pb, track); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_ctts_tag(AVIOContext *pb, MOVTrack *track) @@ -988,7 +988,7 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track) if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) { stts_entries = av_malloc(sizeof(*stts_entries)); /* one entry */ - stts_entries[0].count = track->sampleCount; + stts_entries[0].count = track->sample_count; stts_entries[0].duration = 1; entries = 1; } else { @@ -997,7 +997,7 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track) NULL; for (i=0; ientry; i++) { int64_t duration = i + 1 == track->entry ? - track->trackDuration - track->cluster[i].dts + track->start_dts : /* readjusting */ + track->track_duration - track->cluster[i].dts + track->start_dts : /* readjusting */ track->cluster[i+1].dts - track->cluster[i].dts; if (i && duration == stts_entries[entries].duration) { stts_entries[entries].count++; /* compress */ @@ -1045,7 +1045,7 @@ static int mov_write_stbl_tag(AVIOContext *pb, MOVTrack *track) mov_write_stts_tag(pb, track); if ((track->enc->codec_type == AVMEDIA_TYPE_VIDEO || track->enc->codec_tag == MKTAG('r','t','p',' ')) && - track->hasKeyframes && track->hasKeyframes < track->entry) + track->has_keyframes && track->has_keyframes < track->entry) mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE); if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS) mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE); @@ -1055,7 +1055,7 @@ static int mov_write_stbl_tag(AVIOContext *pb, MOVTrack *track) mov_write_stsc_tag(pb, track); mov_write_stsz_tag(pb, track); mov_write_stco_tag(pb, track); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_dinf_tag(AVIOContext *pb) @@ -1064,7 +1064,7 @@ static int mov_write_dinf_tag(AVIOContext *pb) avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "dinf"); mov_write_dref_tag(pb); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_nmhd_tag(AVIOContext *pb) @@ -1150,7 +1150,7 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track) avio_write(pb, descr, strlen(descr)); /* handler description */ if (track && track->mode != MODE_MOV) avio_w8(pb, 0); /* c string */ - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_hmhd_tag(AVIOContext *pb) @@ -1187,12 +1187,12 @@ static int mov_write_minf_tag(AVIOContext *pb, MOVTrack *track) mov_write_hdlr_tag(pb, NULL); mov_write_dinf_tag(pb); mov_write_stbl_tag(pb, track); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track) { - int version = track->trackDuration < INT32_MAX ? 0 : 1; + int version = track->track_duration < INT32_MAX ? 0 : 1; (version == 1) ? avio_wb32(pb, 44) : avio_wb32(pb, 32); /* size */ ffio_wfourcc(pb, "mdhd"); @@ -1206,7 +1206,7 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, track->time); /* modification time */ } avio_wb32(pb, track->timescale); /* time scale (sample rate for audio) */ - (version == 1) ? avio_wb64(pb, track->trackDuration) : avio_wb32(pb, track->trackDuration); /* duration */ + (version == 1) ? avio_wb64(pb, track->track_duration) : avio_wb32(pb, track->track_duration); /* duration */ avio_wb16(pb, track->language); /* language */ avio_wb16(pb, 0); /* reserved (quality) */ @@ -1228,12 +1228,12 @@ static int mov_write_mdia_tag(AVIOContext *pb, MOVTrack *track) mov_write_mdhd_tag(pb, track); mov_write_hdlr_tag(pb, track); mov_write_minf_tag(pb, track); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st) { - int64_t duration = av_rescale_rnd(track->trackDuration, MOV_TIMESCALE, + int64_t duration = av_rescale_rnd(track->track_duration, MOV_TIMESCALE, track->timescale, AV_ROUND_UP); int version = duration < INT32_MAX ? 0 : 1; @@ -1248,7 +1248,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st) avio_wb32(pb, track->time); /* creation time */ avio_wb32(pb, track->time); /* modification time */ } - avio_wb32(pb, track->trackID); /* track-id */ + avio_wb32(pb, track->track_id); /* track-id */ avio_wb32(pb, 0); /* reserved */ (version == 1) ? avio_wb64(pb, duration) : avio_wb32(pb, duration); @@ -1317,13 +1317,13 @@ static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, track->enc->width << 16); avio_wb32(pb, track->enc->height << 16); - return updateSize(pb, pos); + return update_size(pb, pos); } // This box seems important for the psp playback ... without it the movie seems to hang static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track) { - int64_t duration = av_rescale_rnd(track->trackDuration, MOV_TIMESCALE, + int64_t duration = av_rescale_rnd(track->track_duration, MOV_TIMESCALE, track->timescale, AV_ROUND_UP); int version = duration < INT32_MAX ? 0 : 1; int entry_size, entry_count, size; @@ -1434,13 +1434,13 @@ static int mov_write_trak_tag(AVIOContext *pb, MOVMuxContext *mov, if (track->mode == MODE_PSP) mov_write_uuid_tag_psp(pb,track); // PSP Movies require this uuid box if (track->tag == MKTAG('r','t','p',' ')) - mov_write_udta_sdp(pb, track->rtp_ctx, track->trackID); + mov_write_udta_sdp(pb, track->rtp_ctx, track->track_id); if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO && track->mode == MODE_MOV) { double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio); if (0.0 != sample_aspect_ratio && 1.0 != sample_aspect_ratio) mov_write_tapt_tag(pb, track); }; - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_iods_tag(AVIOContext *pb, MOVMuxContext *mov) @@ -1462,14 +1462,14 @@ static int mov_write_iods_tag(AVIOContext *pb, MOVMuxContext *mov) avio_wb32(pb, 0x0); /* size */ ffio_wfourcc(pb, "iods"); avio_wb32(pb, 0); /* version & flags */ - putDescr(pb, 0x10, 7); + put_descr(pb, 0x10, 7); avio_wb16(pb, 0x004f); avio_w8(pb, 0xff); avio_w8(pb, 0xff); avio_w8(pb, audio_profile); avio_w8(pb, video_profile); avio_w8(pb, 0xff); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_trex_tag(AVIOContext *pb, MOVTrack *track) @@ -1477,7 +1477,7 @@ static int mov_write_trex_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, 0x20); /* size */ ffio_wfourcc(pb, "trex"); avio_wb32(pb, 0); /* version & flags */ - avio_wb32(pb, track->trackID); /* track ID */ + avio_wb32(pb, track->track_id); /* track ID */ avio_wb32(pb, 1); /* default sample description index */ avio_wb32(pb, 0); /* default sample duration */ avio_wb32(pb, 0); /* default sample size */ @@ -1493,29 +1493,29 @@ static int mov_write_mvex_tag(AVIOContext *pb, MOVMuxContext *mov) ffio_wfourcc(pb, "mvex"); for (i = 0; i < mov->nb_streams; i++) mov_write_trex_tag(pb, &mov->tracks[i]); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov) { - int maxTrackID = 1, i; - int64_t maxTrackLenTemp, maxTrackLen = 0; + int max_track_id = 1, i; + int64_t max_track_len_temp, max_track_len = 0; int version; for (i=0; inb_streams; i++) { if(mov->tracks[i].entry > 0) { - maxTrackLenTemp = av_rescale_rnd(mov->tracks[i].trackDuration, - MOV_TIMESCALE, - mov->tracks[i].timescale, - AV_ROUND_UP); - if(maxTrackLen < maxTrackLenTemp) - maxTrackLen = maxTrackLenTemp; - if(maxTrackID < mov->tracks[i].trackID) - maxTrackID = mov->tracks[i].trackID; + max_track_len_temp = av_rescale_rnd(mov->tracks[i].track_duration, + MOV_TIMESCALE, + mov->tracks[i].timescale, + AV_ROUND_UP); + if (max_track_len < max_track_len_temp) + max_track_len = max_track_len_temp; + if (max_track_id < mov->tracks[i].track_id) + max_track_id = mov->tracks[i].track_id; } } - version = maxTrackLen < UINT32_MAX ? 0 : 1; + version = max_track_len < UINT32_MAX ? 0 : 1; (version == 1) ? avio_wb32(pb, 120) : avio_wb32(pb, 108); /* size */ ffio_wfourcc(pb, "mvhd"); avio_w8(pb, version); @@ -1528,7 +1528,7 @@ static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov) avio_wb32(pb, mov->time); /* modification time */ } avio_wb32(pb, MOV_TIMESCALE); - (version == 1) ? avio_wb64(pb, maxTrackLen) : avio_wb32(pb, maxTrackLen); /* duration of longest track */ + (version == 1) ? avio_wb64(pb, max_track_len) : avio_wb32(pb, max_track_len); /* duration of longest track */ avio_wb32(pb, 0x00010000); /* reserved (preferred rate) 1.0 = normal */ avio_wb16(pb, 0x0100); /* reserved (preferred volume) 1.0 = normal */ @@ -1553,7 +1553,7 @@ static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov) avio_wb32(pb, 0); /* reserved (selection time) */ avio_wb32(pb, 0); /* reserved (selection duration) */ avio_wb32(pb, 0); /* reserved (current time) */ - avio_wb32(pb, maxTrackID+1); /* Next track id */ + avio_wb32(pb, max_track_id + 1); /* Next track id */ return 0x6c; } @@ -1600,7 +1600,7 @@ static int mov_write_string_tag(AVIOContext *pb, const char *name, const char *v avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, name); mov_write_string_data_tag(pb, value, lang, long_style); - size= updateSize(pb, pos); + size = update_size(pb, pos); } return size; } @@ -1676,7 +1676,7 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, mov_write_string_metadata(s, pb, "tven", "episode_id",1); mov_write_string_metadata(s, pb, "tvnn", "network" , 1); mov_write_trkn_tag(pb, mov, s); - return updateSize(pb, pos); + return update_size(pb, pos); } /* iTunes meta data tag */ @@ -1690,7 +1690,7 @@ static int mov_write_meta_tag(AVIOContext *pb, MOVMuxContext *mov, avio_wb32(pb, 0); mov_write_itunes_hdlr_tag(pb, mov, s); mov_write_ilst_tag(pb, mov, s); - size = updateSize(pb, pos); + size = update_size(pb, pos); return size; } @@ -1740,7 +1740,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s, (t = av_dict_get(s->metadata, "track", NULL, 0))) avio_w8(pb, atoi(t->value)); } - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s) @@ -1766,7 +1766,7 @@ static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s) } else avio_w8(pb, 0); } - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov, @@ -1866,8 +1866,8 @@ static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s) // snprintf(dt,32,"%04d/%02d/%02d %02d:%02d:%02d",t_st->tm_year+1900,t_st->tm_mon+1,t_st->tm_mday,t_st->tm_hour,t_st->tm_min,t_st->tm_sec); mov_write_psp_udta_tag(pb, "2006/04/01 11:11:11", "und", 0x03); - updateSize(pb, pos2); - return updateSize(pb, pos); + update_size(pb, pos2); + return update_size(pb, pos); } return 0; @@ -1886,19 +1886,19 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, continue; mov->tracks[i].time = mov->time; - mov->tracks[i].trackID = i+1; + mov->tracks[i].track_id = i+1; } if (mov->chapter_track) for (i=0; inb_streams; i++) { mov->tracks[i].tref_tag = MKTAG('c','h','a','p'); - mov->tracks[i].tref_id = mov->tracks[mov->chapter_track].trackID; + mov->tracks[i].tref_id = mov->tracks[mov->chapter_track].track_id; } for (i = 0; i < mov->nb_streams; i++) { if (mov->tracks[i].tag == MKTAG('r','t','p',' ')) { mov->tracks[i].tref_tag = MKTAG('h','i','n','t'); mov->tracks[i].tref_id = - mov->tracks[mov->tracks[i].src_track].trackID; + mov->tracks[mov->tracks[i].src_track].track_id; } } @@ -1918,7 +1918,7 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, else mov_write_udta_tag(pb, mov, s); - return updateSize(pb, pos); + return update_size(pb, pos); } static void param_write_int(AVIOContext *pb, const char *name, int value) @@ -1985,7 +1985,7 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov) for (i = 0; i < mov->nb_streams; i++) { MOVTrack *track = &mov->tracks[i]; const char *type; - /* track->trackID is initialized in write_moov, and thus isn't known + /* track->track_id is initialized in write_moov, and thus isn't known * here yet */ int track_id = i + 1; @@ -2040,7 +2040,7 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov) avio_printf(pb, "\n"); avio_printf(pb, "\n"); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_mfhd_tag(AVIOContext *pb, MOVMuxContext *mov) @@ -2074,7 +2074,7 @@ static int mov_write_tfhd_tag(AVIOContext *pb, MOVTrack *track, avio_w8(pb, 0); /* version */ avio_wb24(pb, flags); - avio_wb32(pb, track->trackID); /* track-id */ + avio_wb32(pb, track->track_id); /* track-id */ if (flags & 0x01) avio_wb64(pb, moof_offset); if (flags & 0x08) { @@ -2094,7 +2094,7 @@ static int mov_write_tfhd_tag(AVIOContext *pb, MOVTrack *track, avio_wb32(pb, track->default_sample_flags); } - return updateSize(pb, pos); + return update_size(pb, pos); } static uint32_t get_sample_flags(MOVTrack *track, MOVIentry *entry) @@ -2110,7 +2110,7 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVTrack *track) for (i = 0; i < track->entry; i++) { int64_t duration = i + 1 == track->entry ? - track->trackDuration - track->cluster[i].dts + track->start_dts : + track->track_duration - track->cluster[i].dts + track->start_dts : track->cluster[i + 1].dts - track->cluster[i].dts; if (duration != track->default_duration) flags |= 0x100; /* sample-duration-present */ @@ -2137,7 +2137,7 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVTrack *track) for (i = 0; i < track->entry; i++) { int64_t duration = i + 1 == track->entry ? - track->trackDuration - track->cluster[i].dts + track->start_dts : + track->track_duration - track->cluster[i].dts + track->start_dts : track->cluster[i + 1].dts - track->cluster[i].dts; if (flags & 0x100) avio_wb32(pb, duration); @@ -2149,7 +2149,7 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, track->cluster[i].cts); } - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_tfxd_tag(AVIOContext *pb, MOVTrack *track) @@ -2166,10 +2166,10 @@ static int mov_write_tfxd_tag(AVIOContext *pb, MOVTrack *track) avio_w8(pb, 1); avio_wb24(pb, 0); avio_wb64(pb, track->frag_start); - avio_wb64(pb, track->start_dts + track->trackDuration - + avio_wb64(pb, track->start_dts + track->track_duration - track->cluster[0].dts); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_tfrf_tag(AVIOContext *pb, MOVMuxContext *mov, @@ -2245,7 +2245,7 @@ static int mov_write_traf_tag(AVIOContext *pb, MOVMuxContext *mov, } } - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks) @@ -2279,7 +2279,7 @@ static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks) } avio_seek(pb, end, SEEK_SET); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) @@ -2292,7 +2292,7 @@ static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) avio_w8(pb, 1); /* version */ avio_wb24(pb, 0); - avio_wb32(pb, track->trackID); + avio_wb32(pb, track->track_id); avio_wb32(pb, 0); /* length of traf/trun/sample num */ avio_wb32(pb, track->nb_frag_info); for (i = 0; i < track->nb_frag_info; i++) { @@ -2303,7 +2303,7 @@ static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) avio_w8(pb, 1); /* sample number */ } - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_mfra_tag(AVIOContext *pb, MOVMuxContext *mov) @@ -2316,7 +2316,7 @@ static int mov_write_mfra_tag(AVIOContext *pb, MOVMuxContext *mov) /* An empty mfra atom is enough to indicate to the publishing point that * the stream has ended. */ if (mov->flags & FF_MOV_FLAG_ISML) - return updateSize(pb, pos); + return update_size(pb, pos); for (i = 0; i < mov->nb_streams; i++) { MOVTrack *track = &mov->tracks[i]; @@ -2329,7 +2329,7 @@ static int mov_write_mfra_tag(AVIOContext *pb, MOVMuxContext *mov) avio_wb32(pb, 0); /* version + flags */ avio_wb32(pb, avio_tell(pb) + 4 - pos); - return updateSize(pb, pos); + return update_size(pb, pos); } static int mov_write_mdat_tag(AVIOContext *pb, MOVMuxContext *mov) @@ -2402,17 +2402,17 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) ffio_wfourcc(pb, "MSNV"); else if (mov->mode == MODE_MP4) ffio_wfourcc(pb, "mp41"); - return updateSize(pb, pos); + return update_size(pb, pos); } static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s) { - AVCodecContext *VideoCodec = s->streams[0]->codec; - AVCodecContext *AudioCodec = s->streams[1]->codec; - int AudioRate = AudioCodec->sample_rate; - int FrameRate = ((VideoCodec->time_base.den) * (0x10000))/ (VideoCodec->time_base.num); - int audio_kbitrate= AudioCodec->bit_rate / 1000; - int video_kbitrate= FFMIN(VideoCodec->bit_rate / 1000, 800 - audio_kbitrate); + AVCodecContext *video_codec = s->streams[0]->codec; + AVCodecContext *audio_codec = s->streams[1]->codec; + int audio_rate = audio_codec->sample_rate; + int frame_rate = ((video_codec->time_base.den) * (0x10000))/ (video_codec->time_base.num); + int audio_kbitrate = audio_codec->bit_rate / 1000; + int video_kbitrate = FFMIN(video_codec->bit_rate / 1000, 800 - audio_kbitrate); avio_wb32(pb, 0x94); /* size */ ffio_wfourcc(pb, "uuid"); @@ -2440,14 +2440,14 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s) avio_wb32(pb, 0x0); avio_wb32(pb, audio_kbitrate); avio_wb32(pb, audio_kbitrate); - avio_wb32(pb, AudioRate); - avio_wb32(pb, AudioCodec->channels); + avio_wb32(pb, audio_rate); + avio_wb32(pb, audio_codec->channels); avio_wb32(pb, 0x34); /* size */ ffio_wfourcc(pb, "VPRF"); /* video */ avio_wb32(pb, 0x0); avio_wb32(pb, 0x1); /* TrackID */ - if (VideoCodec->codec_id == CODEC_ID_H264) { + if (video_codec->codec_id == CODEC_ID_H264) { ffio_wfourcc(pb, "avc1"); avio_wb16(pb, 0x014D); avio_wb16(pb, 0x0015); @@ -2459,10 +2459,10 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s) avio_wb32(pb, 0x0); avio_wb32(pb, video_kbitrate); avio_wb32(pb, video_kbitrate); - avio_wb32(pb, FrameRate); - avio_wb32(pb, FrameRate); - avio_wb16(pb, VideoCodec->width); - avio_wb16(pb, VideoCodec->height); + avio_wb32(pb, frame_rate); + avio_wb32(pb, frame_rate); + avio_wb16(pb, video_codec->width); + avio_wb16(pb, video_codec->height); avio_wb32(pb, 0x010001); /* ? */ } @@ -2514,7 +2514,7 @@ static int mov_flush_fragment(AVFormatContext *s) for (i = 0; i < mov->nb_streams; i++) { if (mov->tracks[i].entry) mov->tracks[i].frag_start += mov->tracks[i].start_dts + - mov->tracks[i].trackDuration - + mov->tracks[i].track_duration - mov->tracks[i].cluster[0].dts; mov->tracks[i].entry = 0; } @@ -2545,7 +2545,7 @@ static int mov_flush_fragment(AVFormatContext *s) int64_t duration = 0; if (track->entry) - duration = track->start_dts + track->trackDuration - + duration = track->start_dts + track->track_duration - track->cluster[0].dts; if (mov->flags & FF_MOV_FLAG_SEPARATE_MOOF) { if (!track->mdat_buf) @@ -2601,7 +2601,7 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt) AVIOContext *pb = s->pb; MOVTrack *trk = &mov->tracks[pkt->stream_index]; AVCodecContext *enc = trk->enc; - unsigned int samplesInChunk = 0; + unsigned int samples_in_chunk = 0; int size= pkt->size; uint8_t *reformatted_data = NULL; @@ -2636,27 +2636,27 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt) {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1}; int len = 0; - while (len < size && samplesInChunk < 100) { + while (len < size && samples_in_chunk < 100) { len += packed_size[(pkt->data[len] >> 3) & 0x0F]; - samplesInChunk++; + samples_in_chunk++; } - if(samplesInChunk > 1){ + if (samples_in_chunk > 1) { av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n"); return -1; } - } else if (trk->sampleSize) - samplesInChunk = size/trk->sampleSize; + } else if (trk->sample_size) + samples_in_chunk = size / trk->sample_size; else - samplesInChunk = 1; + samples_in_chunk = 1; /* copy extradata if it exists */ - if (trk->vosLen == 0 && enc->extradata_size > 0) { - trk->vosLen = enc->extradata_size; - trk->vosData = av_malloc(trk->vosLen); - memcpy(trk->vosData, enc->extradata, trk->vosLen); + if (trk->vos_len == 0 && enc->extradata_size > 0) { + trk->vos_len = enc->extradata_size; + trk->vos_data = av_malloc(trk->vos_len); + memcpy(trk->vos_data, enc->extradata, trk->vos_len); } - if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) { + if (enc->codec_id == CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t *)trk->vos_data != 1) { /* from x264 or from bytestream h264 */ /* nal reformating needed */ if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) { @@ -2671,13 +2671,13 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt) } if ((enc->codec_id == CODEC_ID_DNXHD || - enc->codec_id == CODEC_ID_AC3) && !trk->vosLen) { + enc->codec_id == CODEC_ID_AC3) && !trk->vos_len) { /* copy frame to create needed atoms */ - trk->vosLen = size; - trk->vosData = av_malloc(size); - if (!trk->vosData) + trk->vos_len = size; + trk->vos_data = av_malloc(size); + if (!trk->vos_data) return AVERROR(ENOMEM); - memcpy(trk->vosData, pkt->data, size); + memcpy(trk->vos_data, pkt->data, size); } if (!(trk->entry % MOV_INDEX_CLUSTER_SIZE)) { @@ -2687,20 +2687,20 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt) } trk->cluster[trk->entry].pos = avio_tell(pb) - size; - trk->cluster[trk->entry].samplesInChunk = samplesInChunk; + trk->cluster[trk->entry].samples_in_chunk = samples_in_chunk; trk->cluster[trk->entry].size = size; - trk->cluster[trk->entry].entries = samplesInChunk; + trk->cluster[trk->entry].entries = samples_in_chunk; trk->cluster[trk->entry].dts = pkt->dts; if (!trk->entry && trk->start_dts != AV_NOPTS_VALUE) { /* First packet of a new fragment. We already wrote the duration - * of the last packet of the previous fragment based on trackDuration, + * of the last packet of the previous fragment based on track_duration, * which might not exactly match our dts. Therefore adjust the dts * of this packet to be what the previous packets duration implies. */ - trk->cluster[trk->entry].dts = trk->start_dts + trk->trackDuration; + trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration; } if (trk->start_dts == AV_NOPTS_VALUE) trk->start_dts = pkt->dts; - trk->trackDuration = pkt->dts - trk->start_dts + pkt->duration; + trk->track_duration = pkt->dts - trk->start_dts + pkt->duration; if (pkt->pts == AV_NOPTS_VALUE) { av_log(s, AV_LOG_WARNING, "pts has no value\n"); @@ -2720,10 +2720,10 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt) trk->cluster[trk->entry].flags = MOV_SYNC_SAMPLE; } if (trk->cluster[trk->entry].flags & MOV_SYNC_SAMPLE) - trk->hasKeyframes++; + trk->has_keyframes++; } trk->entry++; - trk->sampleCount += samplesInChunk; + trk->sample_count += samples_in_chunk; mov->mdat_size += size; avio_flush(pb); @@ -2877,13 +2877,13 @@ static int mov_write_header(AVFormatContext *s) "or choose different container.\n"); }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){ track->timescale = st->codec->sample_rate; - /* set sampleSize for PCM and ADPCM */ + /* set sample_size for PCM and ADPCM */ if (av_get_bits_per_sample(st->codec->codec_id)) { if (!st->codec->block_align) { av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set\n", i); goto error; } - track->sampleSize = st->codec->block_align; + track->sample_size = st->codec->block_align; } /* set audio_vbr for compressed audio */ if (av_get_bits_per_sample(st->codec->codec_id) < 8) { @@ -2919,9 +2919,9 @@ static int mov_write_header(AVFormatContext *s) /* copy extradata if it exists */ if (st->codec->extradata_size) { - track->vosLen = st->codec->extradata_size; - track->vosData = av_malloc(track->vosLen); - memcpy(track->vosData, st->codec->extradata, track->vosLen); + track->vos_len = st->codec->extradata_size; + track->vos_data = av_malloc(track->vos_len); + memcpy(track->vos_data, st->codec->extradata, track->vos_len); } } @@ -3021,7 +3021,8 @@ static int mov_write_trailer(AVFormatContext *s) av_freep(&mov->tracks[i].cluster); av_freep(&mov->tracks[i].frag_info); - if(mov->tracks[i].vosLen) av_free(mov->tracks[i].vosData); + if (mov->tracks[i].vos_len) + av_free(mov->tracks[i].vos_data); } diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 0b74a61d06..5fc71fb99d 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -44,7 +44,7 @@ typedef struct MOVIentry { uint64_t pos; int64_t dts; unsigned int size; - unsigned int samplesInChunk; + unsigned int samples_in_chunk; unsigned int entries; int cts; #define MOV_SYNC_SAMPLE 0x0001 @@ -78,20 +78,20 @@ typedef struct MOVIndex { int entry; unsigned timescale; uint64_t time; - int64_t trackDuration; - long sampleCount; - long sampleSize; - int hasKeyframes; + int64_t track_duration; + long sample_count; + long sample_size; + int has_keyframes; #define MOV_TRACK_CTTS 0x0001 #define MOV_TRACK_STPS 0x0002 uint32_t flags; int language; - int trackID; + int track_id; int tag; ///< stsd fourcc AVCodecContext *enc; - int vosLen; - uint8_t *vosData; + int vos_len; + uint8_t *vos_data; MOVIentry *cluster; int audio_vbr; int height; ///< active picture (w/o VBI) height for D-10/IMX From 6a89b41d9780325ba6d89a37f2aeb925aa68e6a3 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 24 Jan 2012 22:20:26 +0100 Subject: [PATCH 15/26] nsvdec: Fix use of uninitialized streams. Fixes CVE-2011-3940 (Out of bounds read resulting in out of bounds write) Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer (cherry picked from commit 5c011706bc752d34bc6ada31d7df2ca0c9af7c6b) Signed-off-by: Alex Converse --- libavformat/nsvdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index b5bc87aa8c..aa114db097 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -605,12 +605,12 @@ null_chunk_retry: } /* map back streams to v,a */ - if (s->streams[0]) + if (s->nb_streams > 0) st[s->streams[0]->id] = s->streams[0]; - if (s->streams[1]) + if (s->nb_streams > 1) st[s->streams[1]->id] = s->streams[1]; - if (vsize/* && st[NSV_ST_VIDEO]*/) { + if (vsize && st[NSV_ST_VIDEO]) { nst = st[NSV_ST_VIDEO]->priv_data; pkt = &nsv->ahead[NSV_ST_VIDEO]; av_get_packet(pb, pkt, vsize); @@ -623,7 +623,7 @@ null_chunk_retry: if(st[NSV_ST_VIDEO]) ((NSVStream*)st[NSV_ST_VIDEO]->priv_data)->frame_offset++; - if (asize/*st[NSV_ST_AUDIO]*/) { + if (asize && st[NSV_ST_AUDIO]) { nst = st[NSV_ST_AUDIO]->priv_data; pkt = &nsv->ahead[NSV_ST_AUDIO]; /* read raw audio specific header on the first audio chunk... */ From 8fd8a48263ff1437f9d02d7e78dc63efb9b5ed3a Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 26 Jan 2012 17:21:46 -0800 Subject: [PATCH 16/26] nsvdec: Be more careful with av_malloc(). Check results for av_malloc() and fix an overflow in one call. Related to CVE-2011-3940. Based in part on work from Michael Niedermayer. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind --- libavformat/nsvdec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index aa114db097..7e32e439ea 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -314,7 +314,9 @@ static int nsv_parse_NSVf_header(AVFormatContext *s) char *token, *value; char quote; - p = strings = av_mallocz(strings_size + 1); + p = strings = av_mallocz((size_t)strings_size + 1); + if (!p) + return AVERROR(ENOMEM); endp = strings + strings_size; avio_read(pb, strings, strings_size); while (p < endp) { @@ -349,6 +351,8 @@ static int nsv_parse_NSVf_header(AVFormatContext *s) if((unsigned)table_entries_used >= UINT_MAX / sizeof(uint32_t)) return -1; nsv->nsvs_file_offset = av_malloc((unsigned)table_entries_used * sizeof(uint32_t)); + if (!nsv->nsvs_file_offset) + return AVERROR(ENOMEM); for(i=0;insvs_file_offset[i] = avio_rl32(pb) + size; @@ -356,6 +360,8 @@ static int nsv_parse_NSVf_header(AVFormatContext *s) if(table_entries > table_entries_used && avio_rl32(pb) == MKTAG('T','O','C','2')) { nsv->nsvs_timestamps = av_malloc((unsigned)table_entries_used*sizeof(uint32_t)); + if (!nsv->nsvs_timestamps) + return AVERROR(ENOMEM); for(i=0;insvs_timestamps[i] = avio_rl32(pb); } From c898431ca5ef2a997fe9388b650f658fb60783e5 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 26 Jan 2012 17:23:09 -0800 Subject: [PATCH 17/26] nsvdec: Propagate errors Related to CVE-2011-3940. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind --- libavformat/nsvdec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index 7e32e439ea..2ad8cb3a8b 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -532,11 +532,16 @@ static int nsv_read_header(AVFormatContext *s) for (i = 0; i < NSV_MAX_RESYNC_TRIES; i++) { if (nsv_resync(s) < 0) return -1; - if (nsv->state == NSV_FOUND_NSVF) + if (nsv->state == NSV_FOUND_NSVF) { err = nsv_parse_NSVf_header(s); + if (err < 0) + return err; + } /* we need the first NSVs also... */ if (nsv->state == NSV_FOUND_NSVS) { err = nsv_parse_NSVs_header(s); + if (err < 0) + return err; break; /* we just want the first one */ } } From 386741f887714d3e46c9e8fe577e326a7964037b Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 26 Jan 2012 17:30:49 +0100 Subject: [PATCH 18/26] kmvc: Check palsize. Fixes: CVE-2011-3952 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Based on fix by Michael Niedermayer --- libavcodec/kmvc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index 2b54b84e99..a6bb13b95a 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -33,6 +33,7 @@ #define KMVC_KEYFRAME 0x80 #define KMVC_PALETTE 0x40 #define KMVC_METHOD 0x0F +#define MAX_PALSIZE 256 /* * Decoder context @@ -43,7 +44,7 @@ typedef struct KmvcContext { int setpal; int palsize; - uint32_t pal[256]; + uint32_t pal[MAX_PALSIZE]; uint8_t *cur, *prev; uint8_t *frm0, *frm1; GetByteContext g; @@ -380,6 +381,10 @@ static av_cold int decode_init(AVCodecContext * avctx) c->palsize = 127; } else { c->palsize = AV_RL16(avctx->extradata + 10); + if (c->palsize >= MAX_PALSIZE) { + av_log(avctx, AV_LOG_ERROR, "KMVC palette too large\n"); + return AVERROR_INVALIDDATA; + } } if (avctx->extradata_size == 1036) { // palette in extradata From a02e8df973f5478ec82f4c507f5b5b191a5ecb6b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 25 Jan 2012 23:23:35 +0100 Subject: [PATCH 19/26] kgv1dec: Increase offsets array size so it is large enough. Fixes CVE-2011-3945 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer (cherry picked from commit 807a045ab7f51993a2c1b3116016cbbd4f3d20d6) Signed-off-by: Alex Converse --- libavcodec/kgv1dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 2d6fa73fc2..f3ffd8f09e 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -39,7 +39,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac const uint8_t *buf = avpkt->data; const uint8_t *buf_end = buf + avpkt->size; KgvContext * const c = avctx->priv_data; - int offsets[7]; + int offsets[8]; uint16_t *out, *prev; int outcnt = 0, maxcnt; int w, h, i; @@ -69,7 +69,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac return -1; c->prev = prev; - for (i = 0; i < 7; i++) + for (i = 0; i < 8; i++) offsets[i] = -1; while (outcnt < maxcnt && buf_end - 2 > buf) { From dfa37fe8a3d9243dd339d94befa065e2c90b29e6 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 27 Jan 2012 15:50:24 -0800 Subject: [PATCH 20/26] mpeg12: Pad framerate tab to 16 entries. There are many places where we read an unchecked 4-bit index into it. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind --- libavcodec/mpeg12data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpeg12data.c b/libavcodec/mpeg12data.c index 5ac8c243a5..a0dd6e5784 100644 --- a/libavcodec/mpeg12data.c +++ b/libavcodec/mpeg12data.c @@ -305,7 +305,7 @@ const uint8_t ff_mpeg12_mbMotionVectorTable[17][2] = { { 0xc, 10 }, }; -const AVRational avpriv_frame_rate_tab[] = { +const AVRational avpriv_frame_rate_tab[16] = { { 0, 0}, {24000, 1001}, { 24, 1}, From ae35210a5d201e5ca7da83f46226681ceb3d5ad9 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Mon, 30 Jan 2012 10:27:50 -0800 Subject: [PATCH 21/26] kmvc: Log into a context at a log level constant. --- libavcodec/kmvc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index a6bb13b95a..f862154b05 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -377,7 +377,8 @@ static av_cold int decode_init(AVCodecContext * avctx) } if (avctx->extradata_size < 12) { - av_log(NULL, 0, "Extradata missing, decoding may not work properly...\n"); + av_log(avctx, AV_LOG_WARNING, + "Extradata missing, decoding may not work properly...\n"); c->palsize = 127; } else { c->palsize = AV_RL16(avctx->extradata + 10); From 48f1e5212c90b511c90fa0449655abb06a9edda2 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 27 Jan 2012 14:24:07 -0800 Subject: [PATCH 22/26] wmadec: Verify bitstream size makes sense before calling init_get_bits. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind --- libavcodec/wmadec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index 5600f9ba90..41b2a8e7a7 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -873,6 +873,8 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, /* read each frame starting from bit_offset */ pos = bit_offset + 4 + 4 + s->byte_offset_bits + 3; + if (pos >= MAX_CODED_SUPERFRAME_SIZE * 8) + return AVERROR_INVALIDDATA; init_get_bits(&s->gb, buf + (pos >> 3), (MAX_CODED_SUPERFRAME_SIZE - (pos >> 3))*8); len = pos & 7; if (len > 0) From f44005b610abc5b1aca5b3191b64a0a0ba65a03f Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sat, 28 Jan 2012 17:18:18 -0500 Subject: [PATCH 23/26] aacenc: only use the number of input samples provided by the user. Fixes handling of CODEC_CAP_SMALL_LAST_FRAME. --- libavcodec/aacenc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 1957420d00..5125bd62a1 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -477,7 +477,7 @@ static void put_bitstream_info(AVCodecContext *avctx, AACEncContext *s, * Channels are reordered from Libav's default order to AAC order. */ static void deinterleave_input_samples(AACEncContext *s, - const float *samples) + const float *samples, int nb_samples) { int ch, i; const int sinc = s->channels; @@ -491,10 +491,12 @@ static void deinterleave_input_samples(AACEncContext *s, memcpy(&s->planar_samples[ch][1024], &s->planar_samples[ch][2048], 1024 * sizeof(s->planar_samples[0][0])); /* deinterleave */ - for (i = 2048; i < 3072; i++) { + for (i = 2048; i < 2048 + nb_samples; i++) { s->planar_samples[ch][i] = *sptr; sptr += sinc; } + memset(&s->planar_samples[ch][i], 0, + (3072 - i) * sizeof(s->planar_samples[0][0])); } } @@ -512,7 +514,7 @@ static int aac_encode_frame(AVCodecContext *avctx, return 0; if (data) { - deinterleave_input_samples(s, data); + deinterleave_input_samples(s, data, avctx->frame_size); if (s->psypp) ff_psy_preprocess(s->psypp, s->planar_samples, s->channels); } From 89eea6df281f535849055f9ce0e49b36eeef767a Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sat, 28 Jan 2012 17:51:22 -0500 Subject: [PATCH 24/26] aacenc: make sure to encode enough frames to cover all input samples. Currently, any samples in the final frame are not decoded because they are only represented by one frame instead of two. So we encode two final frames to cover both the analysis delay and the MDCT delay. --- libavcodec/aacenc.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 5125bd62a1..97ebbe6bab 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -510,14 +510,12 @@ static int aac_encode_frame(AVCodecContext *avctx, int chan_el_counter[4]; FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; - if (s->last_frame) + if (s->last_frame == 2) return 0; - if (data) { - deinterleave_input_samples(s, data, avctx->frame_size); - if (s->psypp) - ff_psy_preprocess(s->psypp, s->planar_samples, s->channels); - } + deinterleave_input_samples(s, data, data ? avctx->frame_size : 0); + if (s->psypp) + ff_psy_preprocess(s->psypp, s->planar_samples, s->channels); if (!avctx->frame_number) return 0; @@ -648,7 +646,7 @@ static int aac_encode_frame(AVCodecContext *avctx, } if (!data) - s->last_frame = 1; + s->last_frame++; return put_bits_count(&s->pb)>>3; } From c9b309e8cbc460beb50fffce6c38054f9cbdecfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 30 Jan 2012 21:11:33 +0200 Subject: [PATCH 25/26] doc: Fix the name of the new function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- doc/APIchanges | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 39f1a3eed4..7545fa51dc 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -106,7 +106,7 @@ API changes, most recent first: Add av_toupper()/av_tolower() 2011-11-05 - b6d08f4 - lavf 53.13.0 - Add avformat_network_init()/avformat_network_uninit() + Add avformat_network_init()/avformat_network_deinit() 2011-10-27 - 512557b - lavc 53.15.0 Remove avcodec_parse_frame. From d7edd359ec28142120eb7fde77b775309b6038d8 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 30 Jan 2012 16:05:28 +0100 Subject: [PATCH 26/26] avconv: deprecate the -deinterlace option Its quality is horrible, yadif should always be used instead. --- avconv.c | 11 +++++++++-- doc/avconv.texi | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/avconv.c b/avconv.c index a6f0838a96..9f4766ee38 100644 --- a/avconv.c +++ b/avconv.c @@ -4371,6 +4371,13 @@ static int opt_vsync(const char *opt, const char *arg) return 0; } +static int opt_deinterlace(const char *opt, const char *arg) +{ + av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -filter:v yadif instead\n", opt); + do_deinterlace = 1; + return 0; +} + #define OFFSET(x) offsetof(OptionsContext, x) static const OptionDef options[] = { /* main options */ @@ -4435,8 +4442,8 @@ static const OptionDef options[] = { "use same quantizer as source (implies VBR)" }, { "pass", HAS_ARG | OPT_VIDEO, {(void*)opt_pass}, "select the pass number (1 or 2)", "n" }, { "passlogfile", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void*)&pass_logfilename_prefix}, "select two pass log file name prefix", "prefix" }, - { "deinterlace", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_deinterlace}, - "deinterlace pictures" }, + { "deinterlace", OPT_EXPERT | OPT_VIDEO, {(void*)opt_deinterlace}, + "this option is deprecated, use the yadif filter instead" }, { "vstats", OPT_EXPERT | OPT_VIDEO, {(void*)&opt_vstats}, "dump video coding statistics to file" }, { "vstats_file", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_vstats_file}, "dump video coding statistics to file", "file" }, #if CONFIG_AVFILTER diff --git a/doc/avconv.texi b/doc/avconv.texi index 0a83326379..6d96a2f0d3 100644 --- a/doc/avconv.texi +++ b/doc/avconv.texi @@ -528,6 +528,8 @@ How strictly to follow the standards. @item -deinterlace Deinterlace pictures. +This option is deprecated since the deinterlacing is very low quality. +Use the yadif filter with @code{-filter:v yadif}. @item -vstats Dump video coding statistics to @file{vstats_HHMMSS.log}. @item -vstats_file @var{file}