diff --git a/configure b/configure index 7bcc5bfdc2..5a062b981c 100755 --- a/configure +++ b/configure @@ -106,7 +106,7 @@ Configuration options: --disable-lpc disable LPC code --disable-mdct disable MDCT code --disable-rdft disable RDFT code - --disable-vaapi disable VAAPI code + --enable-vaapi enable VAAPI code --disable-vdpau disable VDPAU code --disable-dxva2 disable DXVA2 code --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary) diff --git a/doc/APIchanges b/doc/APIchanges index a15e4a2e52..89104d0e41 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -37,6 +37,9 @@ API changes, most recent first: 2011-05-XX - XXXXXX - lavfi 2.6.0 - avcodec.h Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h. +2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h + Add av_opt_free convenience function. + 2011-05-28 - 0420bd7 - lavu 51.2.0 - pixdesc.h Add av_get_pix_fmt_name() in libavutil/pixdesc.h, and deprecate avcodec_get_pix_fmt_name() in libavcodec/avcodec.h in its favor. diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 768bbde494..2721423473 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -666,8 +666,12 @@ OBJS-$(!CONFIG_SMALL) += inverse.o -include $(SUBDIR)$(ARCH)/Makefile -SKIPHEADERS += %_tablegen.h aac_tablegen_decl.h \ - fft-internal.h $(ARCH)/vp56_arith.h +SKIPHEADERS += %_tablegen.h \ + %_tables.h \ + aac_tablegen_decl.h \ + fft-internal.h \ + tableprint.h \ + $(ARCH)/vp56_arith.h SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h SKIPHEADERS-$(CONFIG_LIBDIRAC) += libdirac.h SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h @@ -675,7 +679,7 @@ SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h -TESTPROGS = cabac dct eval fft fft-fixed h264 iirfilter rangecoder snow +TESTPROGS = cabac dct fft fft-fixed h264 iirfilter rangecoder snow TESTPROGS-$(HAVE_MMX) += motion TESTOBJS = dctref.o diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 2835eb3e45..d210e579d5 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -870,15 +870,11 @@ static av_cold void exponent_init(AC3EncodeContext *s) */ static void extract_exponents(AC3EncodeContext *s) { - int blk, ch; + int ch = !s->cpl_on; + int chan_size = AC3_MAX_COEFS * AC3_MAX_BLOCKS * (s->channels - ch + 1); + AC3Block *block = &s->blocks[0]; - for (ch = !s->cpl_on; ch <= s->channels; ch++) { - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { - AC3Block *block = &s->blocks[blk]; - s->ac3dsp.extract_exponents(block->exp[ch], block->fixed_coef[ch], - AC3_MAX_COEFS); - } - } + s->ac3dsp.extract_exponents(block->exp[ch], block->fixed_coef[ch], chan_size); } diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c index d53cd05c6b..02d3533b0c 100644 --- a/libavcodec/lagarith.c +++ b/libavcodec/lagarith.c @@ -20,7 +20,7 @@ */ /** - * @file libavcodec/lagarith.c + * @file * Lagarith lossless decoder * @author Nathan Caldwell */ diff --git a/libavcodec/lagarithrac.c b/libavcodec/lagarithrac.c index 0cbc3b84df..56c1d0bcc0 100644 --- a/libavcodec/lagarithrac.c +++ b/libavcodec/lagarithrac.c @@ -21,7 +21,7 @@ */ /** - * @file libavcodec/lagarithrac.c + * @file * Lagarith range decoder * @author Nathan Caldwell * @author David Conrad diff --git a/libavcodec/lagarithrac.h b/libavcodec/lagarithrac.h index d985b60353..2cb7323076 100644 --- a/libavcodec/lagarithrac.h +++ b/libavcodec/lagarithrac.h @@ -21,7 +21,7 @@ */ /** - * @file libavcodec/lagarithrac.h + * @file * Lagarith range decoder * @author Nathan Caldwell * @author David Conrad diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index cf7c1914e0..d81b9a387b 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -26,6 +26,8 @@ #include #include +#include "libavutil/common.h" + #define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\ void write_##type##_array(const type *data, int len)\ {\ diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index c97cb94413..c54eaee346 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -477,7 +477,6 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t * if(s->compr == TIFF_G4) s->fax_opts = value; break; - default: av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n", tag, tag); } diff --git a/libavcodec/utils.c b/libavcodec/utils.c index a628ea7aac..922decf3fb 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -858,6 +858,9 @@ av_cold int avcodec_close(AVCodecContext *avctx) avctx->codec->close(avctx); avcodec_default_free_buffers(avctx); avctx->coded_frame = NULL; + if (avctx->codec && avctx->codec->priv_class) + av_opt_free(avctx->priv_data); + av_opt_free(avctx); av_freep(&avctx->priv_data); if(avctx->codec && avctx->codec->encode) av_freep(&avctx->extradata); diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 66e2a3ed62..9ea330c930 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -16,7 +16,8 @@ YASM-OBJS-$(CONFIG_H264DSP) += x86/h264_deblock.o \ x86/h264_idct_10bit.o \ x86/h264_weight.o \ -YASM-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred.o +YASM-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred.o \ + x86/h264_intrapred_10bit.o MMX-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred_init.o YASM-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_yasm.o diff --git a/libavcodec/x86/h264_intrapred_10bit.asm b/libavcodec/x86/h264_intrapred_10bit.asm new file mode 100644 index 0000000000..5cb593ac38 --- /dev/null +++ b/libavcodec/x86/h264_intrapred_10bit.asm @@ -0,0 +1,337 @@ +;***************************************************************************** +;* MMX/SSE2/AVX-optimized 10-bit H.264 intra prediction code +;***************************************************************************** +;* Copyright (C) 2005-2011 x264 project +;* +;* Authors: Daniel Kang +;* +;* This file is part of Libav. +;* +;* Libav is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* Libav is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with Libav; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" +%include "x86util.asm" + +SECTION_RODATA + +SECTION .text + +cextern pw_4 +cextern pw_1 + +%macro PRED4x4_LOWPASS 4 + paddw %2, %3 + psrlw %2, 1 + pavgw %1, %4, %2 +%endmacro + +;----------------------------------------------------------------------------- +; void pred4x4_down_right(pixel *src, const pixel *topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED4x4_DR 1 +cglobal pred4x4_down_right_10_%1, 3,3 + sub r0, r2 + lea r1, [r0+r2*2] + movhps m1, [r1-8] + movhps m2, [r0+r2*1-8] + movhps m4, [r0-8] + punpckhwd m2, m4 + movq m3, [r0] + punpckhdq m1, m2 + PALIGNR m3, m1, 10, m1 + mova m1, m3 + movhps m4, [r1+r2*1-8] + PALIGNR m3, m4, 14, m4 + mova m2, m3 + movhps m4, [r1+r2*2-8] + PALIGNR m3, m4, 14, m4 + PRED4x4_LOWPASS m0, m3, m1, m2 + movq [r1+r2*2], m0 + psrldq m0, 2 + movq [r1+r2*1], m0 + psrldq m0, 2 + movq [r0+r2*2], m0 + psrldq m0, 2 + movq [r0+r2*1], m0 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED4x4_DR sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED4x4_DR ssse3 +%ifdef HAVE_AVX +INIT_AVX +PRED4x4_DR avx +%endif + +;----------------------------------------------------------------------------- +; void pred4x4_vertical_right(pixel *src, const pixel *topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED4x4_VR 1 +cglobal pred4x4_vertical_right_10_%1, 3,3,6 + sub r0, r2 + lea r1, [r0+r2*2] + movq m5, [r0] ; ........t3t2t1t0 + movhps m1, [r0-8] + PALIGNR m0, m5, m1, 14, m1 ; ......t3t2t1t0lt + pavgw m5, m0 + movhps m1, [r0+r2*1-8] + PALIGNR m0, m1, 14, m1 ; ....t3t2t1t0ltl0 + mova m1, m0 + movhps m2, [r0+r2*2-8] + PALIGNR m0, m2, 14, m2 ; ..t3t2t1t0ltl0l1 + mova m2, m0 + movhps m3, [r1+r2*1-8] + PALIGNR m0, m3, 14, m3 ; t3t2t1t0ltl0l1l2 + PRED4x4_LOWPASS m3, m1, m0, m2 + pslldq m1, m3, 12 + psrldq m3, 4 + movq [r0+r2*1], m5 + movq [r0+r2*2], m3 + PALIGNR m5, m1, 14, m2 + pslldq m1, 2 + movq [r1+r2*1], m5 + PALIGNR m3, m1, 14, m1 + movq [r1+r2*2], m3 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED4x4_VR sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED4x4_VR ssse3 +%ifdef HAVE_AVX +INIT_AVX +PRED4x4_VR avx +%endif + +;----------------------------------------------------------------------------- +; void pred4x4_horizontal_down(pixel *src, const pixel *topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED4x4_HD 1 +cglobal pred4x4_horizontal_down_10_%1, 3,3 + sub r0, r2 + lea r1, [r0+r2*2] + movq m0, [r0-8] ; lt .. + movhps m0, [r0] + pslldq m0, 2 ; t2 t1 t0 lt .. .. .. .. + movq m1, [r1+r2*2-8] ; l3 + movq m3, [r1+r2*1-8] + punpcklwd m1, m3 ; l2 l3 + movq m2, [r0+r2*2-8] ; l1 + movq m3, [r0+r2*1-8] + punpcklwd m2, m3 ; l0 l1 + punpckhdq m1, m2 ; l0 l1 l2 l3 + punpckhqdq m1, m0 ; t2 t1 t0 lt l0 l1 l2 l3 + psrldq m0, m1, 4 ; .. .. t2 t1 t0 lt l0 l1 + psrldq m2, m1, 2 ; .. t2 t1 t0 lt l0 l1 l2 + pavgw m5, m1, m2 + PRED4x4_LOWPASS m3, m1, m0, m2 + punpcklwd m5, m3 + psrldq m3, 8 + PALIGNR m3, m5, 12, m4 + movq [r1+r2*2], m5 + movhps [r0+r2*2], m5 + psrldq m5, 4 + movq [r1+r2*1], m5 + movq [r0+r2*1], m3 + RET +%endmacro + +INIT_XMM +%define PALIGNR PALIGNR_MMX +PRED4x4_HD sse2 +%define PALIGNR PALIGNR_SSSE3 +PRED4x4_HD ssse3 +%ifdef HAVE_AVX +INIT_AVX +PRED4x4_HD avx +%endif + +;----------------------------------------------------------------------------- +; void pred4x4_dc(pixel *src, const pixel *topright, int stride) +;----------------------------------------------------------------------------- +%macro HADDD 2 ; sum junk +%if mmsize == 16 + movhlps %2, %1 + paddd %1, %2 + pshuflw %2, %1, 0xE + paddd %1, %2 +%else + pshufw %2, %1, 0xE + paddd %1, %2 +%endif +%endmacro + +%macro HADDW 2 + pmaddwd %1, [pw_1] + HADDD %1, %2 +%endmacro + +INIT_MMX +cglobal pred4x4_dc_10_mmxext, 3,3 + sub r0, r2 + lea r1, [r0+r2*2] + movq m2, [r0+r2*1-8] + paddw m2, [r0+r2*2-8] + paddw m2, [r1+r2*1-8] + paddw m2, [r1+r2*2-8] + psrlq m2, 48 + movq m0, [r0] + HADDW m0, m1 + paddw m0, [pw_4] + paddw m0, m2 + psrlw m0, 3 + SPLATW m0, m0, 0 + movq [r0+r2*1], m0 + movq [r0+r2*2], m0 + movq [r1+r2*1], m0 + movq [r1+r2*2], m0 + RET + +;----------------------------------------------------------------------------- +; void pred4x4_down_left(pixel *src, const pixel *topright, int stride) +;----------------------------------------------------------------------------- +;TODO: more AVX here +%macro PRED4x4_DL 1 +cglobal pred4x4_down_left_10_%1, 3,3 + sub r0, r2 + movq m1, [r0] + movhps m1, [r1] + pslldq m5, m1, 2 + pxor m2, m5, m1 + psrldq m2, 2 + pxor m3, m1, m2 + PRED4x4_LOWPASS m0, m5, m3, m1 + lea r1, [r0+r2*2] + movhps [r1+r2*2], m0 + psrldq m0, 2 + movq [r0+r2*1], m0 + psrldq m0, 2 + movq [r0+r2*2], m0 + psrldq m0, 2 + movq [r1+r2*1], m0 + RET +%endmacro + +INIT_XMM +PRED4x4_DL sse2 +%ifdef HAVE_AVX +INIT_AVX +PRED4x4_DL avx +%endif + +;----------------------------------------------------------------------------- +; void pred4x4_vertical_left(pixel *src, const pixel *topright, int stride) +;----------------------------------------------------------------------------- +%macro PRED4x4_VL 1 +cglobal pred4x4_vertical_left_10_%1, 3,3 + sub r0, r2 + movu m1, [r0] + movhps m1, [r1] + psrldq m3, m1, 2 + psrldq m2, m1, 4 + pavgw m4, m3, m1 + PRED4x4_LOWPASS m0, m1, m2, m3 + lea r1, [r0+r2*2] + movq [r0+r2*1], m4 + movq [r0+r2*2], m0 + psrldq m4, 2 + psrldq m0, 2 + movq [r1+r2*1], m4 + movq [r1+r2*2], m0 + RET +%endmacro + +INIT_XMM +PRED4x4_VL sse2 +%ifdef HAVE_AVX +INIT_AVX +PRED4x4_VL avx +%endif + +;----------------------------------------------------------------------------- +; void pred4x4_horizontal_up(pixel *src, const pixel *topright, int stride) +;----------------------------------------------------------------------------- +INIT_MMX +cglobal pred4x4_horizontal_up_10_mmxext, 3,3 + sub r0, r2 + lea r1, [r0+r2*2] + movq m0, [r0+r2*1-8] + punpckhwd m0, [r0+r2*2-8] + movq m1, [r1+r2*1-8] + punpckhwd m1, [r1+r2*2-8] + punpckhdq m0, m1 + pshufw m1, m1, 0xFF + movq [r1+r2*2], m1 + movd [r1+r2*1+4], m1 + pshufw m2, m0, 11111001b + movq m1, m2 + pavgw m2, m0 + + pshufw m5, m0, 11111110b + PRED4x4_LOWPASS m3, m0, m5, m1 + movq m6, m2 + punpcklwd m6, m3 + movq [r0+r2*1], m6 + psrlq m2, 16 + psrlq m3, 16 + punpcklwd m2, m3 + movq [r0+r2*2], m2 + psrlq m2, 32 + movd [r1+r2*1], m2 + RET + + + +;----------------------------------------------------------------------------- +; void pred8x8_vertical(pixel *src, int stride) +;----------------------------------------------------------------------------- +INIT_XMM +cglobal pred8x8_vertical_10_sse2, 2,2 + sub r0, r1 + mova m0, [r0] +%rep 3 + mova [r0+r1*1], m0 + mova [r0+r1*2], m0 + lea r0, [r0+r1*2] +%endrep + mova [r0+r1*1], m0 + mova [r0+r1*2], m0 + RET + +;----------------------------------------------------------------------------- +; void pred8x8_horizontal(pixel *src, int stride) +;----------------------------------------------------------------------------- +INIT_XMM +cglobal pred8x8_horizontal_10_sse2, 2,3 + mov r2, 4 +.loop: + movq m0, [r0+r1*0-8] + movq m1, [r0+r1*1-8] + pshuflw m0, m0, 0xff + pshuflw m1, m1, 0xff + punpcklqdq m0, m0 + punpcklqdq m1, m1 + mova [r0+r1*0], m0 + mova [r0+r1*1], m1 + lea r0, [r0+r1*2] + dec r2 + jg .loop + REP_RET diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c index f001242315..878f956f88 100644 --- a/libavcodec/x86/h264_intrapred_init.c +++ b/libavcodec/x86/h264_intrapred_init.c @@ -21,6 +21,31 @@ #include "libavutil/cpu.h" #include "libavcodec/h264pred.h" +#define PRED4x4(TYPE, DEPTH, OPT) \ +void ff_pred4x4_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, const uint8_t *topright, int stride); + +PRED4x4(dc, 10, mmxext) +PRED4x4(down_left, 10, sse2) +PRED4x4(down_left, 10, avx) +PRED4x4(down_right, 10, sse2) +PRED4x4(down_right, 10, ssse3) +PRED4x4(down_right, 10, avx) +PRED4x4(vertical_left, 10, sse2) +PRED4x4(vertical_left, 10, avx) +PRED4x4(vertical_right, 10, sse2) +PRED4x4(vertical_right, 10, ssse3) +PRED4x4(vertical_right, 10, avx) +PRED4x4(horizontal_up, 10, mmxext) +PRED4x4(horizontal_down, 10, sse2) +PRED4x4(horizontal_down, 10, ssse3) +PRED4x4(horizontal_down, 10, avx) + +#define PRED8x8(TYPE, DEPTH, OPT) \ +void ff_pred8x8_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, int stride); + +PRED8x8(vertical, 10, sse2) +PRED8x8(horizontal, 10, sse2) + void ff_pred16x16_vertical_mmx (uint8_t *src, int stride); void ff_pred16x16_vertical_sse (uint8_t *src, int stride); void ff_pred16x16_horizontal_mmx (uint8_t *src, int stride); @@ -98,11 +123,8 @@ void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int s void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth) { int mm_flags = av_get_cpu_flags(); - const int high_depth = bit_depth > 8; - - if (high_depth) - return; + if (bit_depth == 8) { #if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx; @@ -226,4 +248,35 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth } } #endif + } else if (bit_depth == 10) { +#if HAVE_YASM + if (mm_flags & AV_CPU_FLAG_MMX2) { + h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; + h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; + } + if (mm_flags & AV_CPU_FLAG_SSE2) { + h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_sse2; + h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_sse2; + h->pred4x4[VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_10_sse2; + h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_sse2; + h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_sse2; + + h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vertical_10_sse2; + h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_10_sse2; + } + if (mm_flags & AV_CPU_FLAG_SSSE3) { + h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_ssse3; + h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_ssse3; + h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3; + } +#if HAVE_AVX + if (mm_flags&AV_CPU_FLAG_AVX) { + h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx; + h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx; + h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_avx; + h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_avx; + } +#endif /* HAVE_AVX */ +#endif /* HAVE_YASM */ + } } diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index f39a3c9957..f6216e0aa3 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -320,8 +320,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) last_frame_time = 0; out: - av_freep(&s->video_size); - av_freep(&s->framerate); return ret; } diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index dadcd70015..d5ba561db8 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -103,7 +103,6 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, int ret, flags = O_RDONLY; ret = av_parse_video_rate(&fbdev->fps, fbdev->framerate); - av_freep(&fbdev->framerate); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Couldn't parse framerate.\n"); return ret; diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c index f77a25748a..20170877dc 100644 --- a/libavdevice/libdc1394.c +++ b/libavdevice/libdc1394.c @@ -316,8 +316,6 @@ out_camera: dc1394_video_set_transmission(dc1394->camera, DC1394_OFF); dc1394_camera_free (dc1394->camera); out: - av_freep(&dc1394->video_size); - av_freep(&dc1394->pixel_format); dc1394_free(dc1394->d); return ret; } diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index d669f073b5..117f7cc534 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -663,10 +663,6 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap) st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8; out: - av_freep(&s->video_size); - av_freep(&s->pixel_format); - av_freep(&s->standard); - av_freep(&s->framerate); return res; } @@ -714,7 +710,7 @@ static int v4l2_read_close(AVFormatContext *s1) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "standard", "", OFFSET(standard), FF_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, + { "standard", "", OFFSET(standard), FF_OPT_TYPE_STRING, {.str = "NTSC" }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, { "channel", "", OFFSET(channel), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c index 49fa078dd8..a8e67e7dda 100644 --- a/libavdevice/vfwcap.c +++ b/libavdevice/vfwcap.c @@ -232,9 +232,6 @@ static int vfw_read_close(AVFormatContext *s) pktl = next; } - av_freep(&ctx->video_size); - av_freep(&ctx->framerate); - return 0; } diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 87ace1e57a..09c121ee7a 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -259,8 +259,6 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) st->codec->bit_rate = x11grab->frame_size * 1/av_q2d(x11grab->time_base) * 8; out: - av_freep(&x11grab->video_size); - av_freep(&x11grab->framerate); return ret; } diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index c70ff49d51..a4e009b7e0 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -102,9 +102,6 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->height = height; st->codec->pix_fmt = pix_fmt; fail: - av_freep(&s1->video_size); - av_freep(&s1->pixel_format); - av_freep(&s1->framerate); return ret; } default: @@ -183,7 +180,6 @@ int ff_raw_video_read_header(AVFormatContext *s, av_set_pts_info(st, 64, 1, 1200000); fail: - av_freep(&s1->framerate); return ret; } diff --git a/libavformat/tty.c b/libavformat/tty.c index bf426f64b6..eddadb49bd 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -121,7 +121,6 @@ static int read_header(AVFormatContext *avctx, } fail: - av_freep(&s->video_size); return ret; } diff --git a/libavformat/utils.c b/libavformat/utils.c index 53e1175243..a17fec3bd7 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2592,6 +2592,10 @@ void avformat_free_context(AVFormatContext *s) int i; AVStream *st; + av_opt_free(s); + if (s->iformat && s->iformat->priv_class) + av_opt_free(s->priv_data); + for(i=0;inb_streams;i++) { /* free all data in a stream component */ st = s->streams[i]; @@ -2621,7 +2625,6 @@ void avformat_free_context(AVFormatContext *s) } av_freep(&s->chapters); av_metadata_free(&s->metadata); - av_freep(&s->key); av_freep(&s->streams); av_free(s); } @@ -3201,6 +3204,8 @@ fail: av_freep(&s->streams[i]->priv_data); av_freep(&s->streams[i]->index_entries); } + if (s->iformat && s->iformat->priv_class) + av_opt_free(s->priv_data); av_freep(&s->priv_data); return ret; } diff --git a/libavutil/Makefile b/libavutil/Makefile index 1386ebb190..01231bd52d 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -75,7 +75,7 @@ OBJS-$(ARCH_ARM) += arm/cpu.o OBJS-$(ARCH_PPC) += ppc/cpu.o OBJS-$(ARCH_X86) += x86/cpu.o -TESTPROGS = adler32 aes base64 cpu crc des lls md5 pca sha tree +TESTPROGS = adler32 aes base64 cpu crc des eval lls md5 pca sha tree TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo DIRS = arm bfin sh4 x86 diff --git a/libavutil/internal.h b/libavutil/internal.h index 51bf40936e..d9ab8e9723 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -142,7 +142,6 @@ #define strncpy strncpy_is_forbidden_due_to_security_issues_use_av_strlcpy #undef exit #define exit exit_is_forbidden -#ifndef LIBAVFORMAT_BUILD #undef printf #define printf please_use_av_log_instead_of_printf #undef fprintf @@ -151,7 +150,6 @@ #define puts please_use_av_log_instead_of_puts #undef perror #define perror please_use_av_log_instead_of_perror -#endif #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\ {\ diff --git a/libavutil/opt.c b/libavutil/opt.c index 6b2bc7712d..f3c74a99ec 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -520,6 +520,14 @@ int av_set_options_string(void *ctx, const char *opts, return count; } +void av_opt_free(void *obj) +{ + const AVOption *o = NULL; + while ((o = av_next_option(obj, o))) + if (o->type == FF_OPT_TYPE_STRING || o->type == FF_OPT_TYPE_BINARY) + av_freep((uint8_t *)obj + o->offset); +} + #ifdef TEST #undef printf diff --git a/libavutil/opt.h b/libavutil/opt.h index b04c7905d6..c967ed5c6b 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -176,4 +176,9 @@ void av_opt_set_defaults2(void *s, int mask, int flags); int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep); +/** + * Free all string and binary options in obj. + */ +void av_opt_free(void *obj); + #endif /* AVUTIL_OPT_H */ diff --git a/tools/build_avopt b/tools/build_avopt deleted file mode 100755 index fcf165765c..0000000000 --- a/tools/build_avopt +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -sed 's/unsigned//g' |\ - sed 's/enum//g' |\ - egrep '^ *(int|float|double|AVRational|char *\*) *[a-zA-Z_0-9]* *;' |\ - sed 's/^ *\([^ ]*\)[ *]*\([^;]*\);.*$/{"\2", NULL, OFFSET(\2), FF_OPT_TYPE_\U\1, DEFAULT, \1_MIN, \1_MAX},/' |\ - sed 's/AVRATIONAL_M/INT_M/g'|\ - sed 's/TYPE_AVRATIONAL/TYPE_RATIONAL/g'|\ - sed 's/FLOAT_M/FLT_M/g'|\ - sed 's/FF_OPT_TYPE_CHAR/FF_OPT_TYPE_STRING/g' diff --git a/tools/jauche_sortierer.sh b/tools/jauche_sortierer.sh deleted file mode 100755 index 1f84f1a2a9..0000000000 --- a/tools/jauche_sortierer.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -#GPL -#TODO -#add pixelformat/sampleformat into the path of the codecs - -FFP=../ffprobe -TMP=$(mktemp) || exit 1 -TARGET=$1 -shift - -for v do - BASE=$(basename $v) - echo $v | egrep -i '(public|private)' >/dev/null && echo Warning $v may be private - $FFP $v 2> $TMP - FORM=$((grep 'Input #0, ' -m1 $TMP || echo 'Input #0, unknown') | sed 's/Input #0, \([a-zA-Z0-9_]*\).*/\1/' ) - mkdir -p $TARGET/container/$FORM - ln -s $v $TARGET/container/$FORM/$BASE - eval $(grep 'Stream #0\.[^:]*: [a-zA-Z0-9][^:]*: [a-zA-Z0-9]' $TMP | sed 's#[^:]*: \([a-zA-Z0-9]*\)[^:]*: \([a-zA-Z0-9]*\).*#mkdir -p '$TARGET'/\1/\2 ; ln -s '$v' '$TARGET'/\1/\2/'$BASE' ; #') -done - -rm $TMP