From 0199e00bc80a55aacf7ecd393bf32dcd64e06739 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 19 May 2011 13:44:11 +0100 Subject: [PATCH 01/11] mpegaudio: move all header parsing to mpegaudiodecheader.[ch] Signed-off-by: Mans Rullgard --- libavcodec/mp3_header_compress_bsf.c | 2 +- libavcodec/mp3_header_decompress_bsf.c | 2 +- libavcodec/mpegaudio.h | 38 +----------------------- libavcodec/mpegaudio_parser.c | 39 ------------------------ libavcodec/mpegaudiodecheader.c | 37 +++++++++++++++++++++++ libavcodec/mpegaudiodecheader.h | 41 ++++++++++++++++++++++++-- 6 files changed, 79 insertions(+), 80 deletions(-) diff --git a/libavcodec/mp3_header_compress_bsf.c b/libavcodec/mp3_header_compress_bsf.c index c880e5e53d..bc3659ef3e 100644 --- a/libavcodec/mp3_header_compress_bsf.c +++ b/libavcodec/mp3_header_compress_bsf.c @@ -20,7 +20,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" -#include "mpegaudio.h" +#include "mpegaudiodecheader.h" static int mp3_header_compress(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, diff --git a/libavcodec/mp3_header_decompress_bsf.c b/libavcodec/mp3_header_decompress_bsf.c index b4b4167620..3f3074286a 100644 --- a/libavcodec/mp3_header_decompress_bsf.c +++ b/libavcodec/mp3_header_decompress_bsf.c @@ -20,7 +20,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" -#include "mpegaudio.h" +#include "mpegaudiodecheader.h" #include "mpegaudiodata.h" diff --git a/libavcodec/mpegaudio.h b/libavcodec/mpegaudio.h index a46ecc5a9f..b55680100b 100644 --- a/libavcodec/mpegaudio.h +++ b/libavcodec/mpegaudio.h @@ -30,7 +30,7 @@ # define CONFIG_FLOAT 0 #endif -#include "avcodec.h" +#include /* max frame size, in samples */ #define MPA_FRAME_SIZE 1152 @@ -47,8 +47,6 @@ #define MPA_DUAL 2 #define MPA_MONO 3 -#define MP3_MASK 0xFFFE0CCF - #ifndef FRAC_BITS #define FRAC_BITS 23 /* fractional bits for sb_samples and dct */ #define WFRAC_BITS 16 /* fractional bits for window */ @@ -72,40 +70,6 @@ typedef int32_t MPA_INT; typedef int16_t OUT_INT; #endif -#define MPA_DECODE_HEADER \ - int frame_size; \ - int error_protection; \ - int layer; \ - int sample_rate; \ - int sample_rate_index; /* between 0 and 8 */ \ - int bit_rate; \ - int nb_channels; \ - int mode; \ - int mode_ext; \ - int lsf; - -typedef struct MPADecodeHeader { - MPA_DECODE_HEADER -} MPADecodeHeader; - int ff_mpa_l2_select_table(int bitrate, int nb_channels, int freq, int lsf); -int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); - -/* fast header check for resync */ -static inline int ff_mpa_check_header(uint32_t header){ - /* header */ - if ((header & 0xffe00000) != 0xffe00000) - return -1; - /* layer check */ - if ((header & (3<<17)) == 0) - return -1; - /* bit rate */ - if ((header & (0xf<<12)) == 0xf<<12) - return -1; - /* frequency */ - if ((header & (3<<10)) == 3<<10) - return -1; - return 0; -} #endif /* AVCODEC_MPEGAUDIO_H */ diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c index 7cfd107d53..06d46f2152 100644 --- a/libavcodec/mpegaudio_parser.c +++ b/libavcodec/mpegaudio_parser.c @@ -38,45 +38,6 @@ typedef struct MpegAudioParseContext { #define SAME_HEADER_MASK \ (0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19)) -/* useful helper to get mpeg audio stream infos. Return -1 if error in - header, otherwise the coded frame size in bytes */ -int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) -{ - MPADecodeHeader s1, *s = &s1; - - if (ff_mpa_check_header(head) != 0) - return -1; - - if (ff_mpegaudio_decode_header(s, head) != 0) { - return -1; - } - - switch(s->layer) { - case 1: - avctx->codec_id = CODEC_ID_MP1; - *frame_size = 384; - break; - case 2: - avctx->codec_id = CODEC_ID_MP2; - *frame_size = 1152; - break; - default: - case 3: - avctx->codec_id = CODEC_ID_MP3; - if (s->lsf) - *frame_size = 576; - else - *frame_size = 1152; - break; - } - - *sample_rate = s->sample_rate; - *channels = s->nb_channels; - *bit_rate = s->bit_rate; - avctx->sub_id = s->layer; - return s->frame_size; -} - static int mpegaudio_parse(AVCodecParserContext *s1, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, diff --git a/libavcodec/mpegaudiodecheader.c b/libavcodec/mpegaudiodecheader.c index a0bd4fcee6..be7abc619d 100644 --- a/libavcodec/mpegaudiodecheader.c +++ b/libavcodec/mpegaudiodecheader.c @@ -108,3 +108,40 @@ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) #endif return 0; } + +int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) +{ + MPADecodeHeader s1, *s = &s1; + + if (ff_mpa_check_header(head) != 0) + return -1; + + if (ff_mpegaudio_decode_header(s, head) != 0) { + return -1; + } + + switch(s->layer) { + case 1: + avctx->codec_id = CODEC_ID_MP1; + *frame_size = 384; + break; + case 2: + avctx->codec_id = CODEC_ID_MP2; + *frame_size = 1152; + break; + default: + case 3: + avctx->codec_id = CODEC_ID_MP3; + if (s->lsf) + *frame_size = 576; + else + *frame_size = 1152; + break; + } + + *sample_rate = s->sample_rate; + *channels = s->nb_channels; + *bit_rate = s->bit_rate; + avctx->sub_id = s->layer; + return s->frame_size; +} diff --git a/libavcodec/mpegaudiodecheader.h b/libavcodec/mpegaudiodecheader.h index 41a491b986..2991595b02 100644 --- a/libavcodec/mpegaudiodecheader.h +++ b/libavcodec/mpegaudiodecheader.h @@ -27,13 +27,50 @@ #ifndef AVCODEC_MPEGAUDIODECHEADER_H #define AVCODEC_MPEGAUDIODECHEADER_H -#include "libavutil/common.h" -#include "mpegaudio.h" +#include "avcodec.h" +#define MP3_MASK 0xFFFE0CCF + +#define MPA_DECODE_HEADER \ + int frame_size; \ + int error_protection; \ + int layer; \ + int sample_rate; \ + int sample_rate_index; /* between 0 and 8 */ \ + int bit_rate; \ + int nb_channels; \ + int mode; \ + int mode_ext; \ + int lsf; + +typedef struct MPADecodeHeader { + MPA_DECODE_HEADER +} MPADecodeHeader; /* header decoding. MUST check the header before because no consistency check is done there. Return 1 if free format found and that the frame size must be computed externally */ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header); +/* useful helper to get mpeg audio stream infos. Return -1 if error in + header, otherwise the coded frame size in bytes */ +int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); + +/* fast header check for resync */ +static inline int ff_mpa_check_header(uint32_t header){ + /* header */ + if ((header & 0xffe00000) != 0xffe00000) + return -1; + /* layer check */ + if ((header & (3<<17)) == 0) + return -1; + /* bit rate */ + if ((header & (0xf<<12)) == 0xf<<12) + return -1; + /* frequency */ + if ((header & (3<<10)) == 3<<10) + return -1; + return 0; +} + #endif /* AVCODEC_MPEGAUDIODECHEADER_H */ From f255a28d140a64ea4c1a5060061863aec993b5ea Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 19 May 2011 13:27:24 +0100 Subject: [PATCH 02/11] mpegaudio: clean up #includes Signed-off-by: Mans Rullgard --- libavcodec/mpegaudio_parser.c | 1 - libavcodec/mpegaudiodata.h | 2 +- libavcodec/mpegaudiodec.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c index 06d46f2152..f07d34bd29 100644 --- a/libavcodec/mpegaudio_parser.c +++ b/libavcodec/mpegaudio_parser.c @@ -21,7 +21,6 @@ */ #include "parser.h" -#include "mpegaudio.h" #include "mpegaudiodecheader.h" diff --git a/libavcodec/mpegaudiodata.h b/libavcodec/mpegaudiodata.h index 841ec516ba..84458836fa 100644 --- a/libavcodec/mpegaudiodata.h +++ b/libavcodec/mpegaudiodata.h @@ -27,7 +27,7 @@ #ifndef AVCODEC_MPEGAUDIODATA_H #define AVCODEC_MPEGAUDIODATA_H -#include "libavutil/common.h" +#include #define MODE_EXT_MS_STEREO 2 #define MODE_EXT_I_STEREO 1 diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index f0d9958d2b..960d13d1e8 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -27,7 +27,6 @@ #include "libavutil/audioconvert.h" #include "avcodec.h" #include "get_bits.h" -#include "dsputil.h" #include "mathops.h" #include "mpegaudiodsp.h" From 50fefa10de920e16036f2be977c39fc0c286d024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 20 May 2011 11:33:57 +0300 Subject: [PATCH 03/11] mpegtsenc: Add an AVClass pointer to the private data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since a private class is set for this muxer, the callers will assume that the private data starts with an AVClass pointer. If no such member exists, the first few bytes of the struct will be overwritten, and the class pointer may be broken at any later time. Signed-off-by: Martin Storsjö --- libavformat/mpegtsenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 2aa9698651..393b779168 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -53,6 +53,7 @@ typedef struct MpegTSService { } MpegTSService; typedef struct MpegTSWrite { + const AVClass *av_class; MpegTSSection pat; /* MPEG2 pat table */ MpegTSSection sdt; /* MPEG2 sdt table context */ MpegTSService **services; From eb8da636af0652a4865055c237a76caff02b98bf Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 20 May 2011 12:06:51 +0100 Subject: [PATCH 04/11] fate: allow overriding default build and install dirs This is useful e.g. for building in a different filesystem than where the source is kept. Signed-off-by: Mans Rullgard --- tests/fate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fate.sh b/tests/fate.sh index 6f0e0fffcb..c522269b54 100755 --- a/tests/fate.sh +++ b/tests/fate.sh @@ -91,8 +91,8 @@ lock ${workdir} || die "${workdir} locked" cd ${workdir} || die "cd ${workdir} failed" src=${workdir}/src -build=${workdir}/build -inst=${workdir}/install +: ${build:=${workdir}/build} +: ${inst:=${workdir}/install} test -d "$src" && update || checkout || die "Error fetching source" From 5ffccc00567363c8e09d4c47dd03dee99c312b7d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 20 May 2011 12:47:42 +0100 Subject: [PATCH 05/11] fate: add comment field This adds a comment field to the report header, suitable for extra information not covered by the automatic fields. Signed-off-by: Mans Rullgard --- tests/fate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fate.sh b/tests/fate.sh index c522269b54..9fd117c3bc 100755 --- a/tests/fate.sh +++ b/tests/fate.sh @@ -75,7 +75,7 @@ clean(){ report(){ date=$(date -u +%Y%m%d%H%M%S) - echo "fate:0:${date}:${slot}:${version}:$1:$2" >report + echo "fate:0:${date}:${slot}:${version}:$1:$2:${comment}" >report cat ${build}/config.fate ${build}/tests/data/fate/*.rep >>report test -n "$fate_recv" && $tar report *.log | gzip | $fate_recv } From 6da57043eabdcde99e8411da3628f2249e951e66 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 20 May 2011 12:57:12 +0100 Subject: [PATCH 06/11] fate: disable threading for encoding This explicitly disables threading for encoding as slices are otherwise automatically activated. This should be dropped once option resetting between files is fully implemented. Signed-off-by: Mans Rullgard --- tests/regression-funcs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/regression-funcs.sh b/tests/regression-funcs.sh index b79c258e77..933aa648d6 100755 --- a/tests/regression-funcs.sh +++ b/tests/regression-funcs.sh @@ -53,7 +53,7 @@ echov(){ FFMPEG_OPTS="-v 0 -y" COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact" DEC_OPTS="$COMMON_OPTS -threads $threads" -ENC_OPTS="$COMMON_OPTS -dct fastint" +ENC_OPTS="$COMMON_OPTS -threads 1 -dct fastint" run_ffmpeg() { From d69f9a4234fefcbf038e6a19203df6865f38ffb8 Mon Sep 17 00:00:00 2001 From: Dave Yeo Date: Fri, 20 May 2011 17:33:38 +0200 Subject: [PATCH 07/11] Add support for a.out object format to assembler macros. This format is still used by e.g. OS/2. Signed-off-by: Diego Biurrun --- libavcodec/x86/dsputil_yasm.asm | 2 +- libavcodec/x86/fft_mmx.asm | 2 +- libavcodec/x86/fmtconvert.asm | 2 +- libavcodec/x86/x86inc.asm | 11 +++++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm index 15f626e8cf..8b19cc1441 100644 --- a/libavcodec/x86/dsputil_yasm.asm +++ b/libavcodec/x86/dsputil_yasm.asm @@ -30,7 +30,7 @@ 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 -section .text align=16 +SECTION_TEXT %macro SCALARPRODUCT 1 ; int scalarproduct_int16(int16_t *v1, int16_t *v2, int order, int shift) diff --git a/libavcodec/x86/fft_mmx.asm b/libavcodec/x86/fft_mmx.asm index fc5cb98926..bd2e8297e7 100644 --- a/libavcodec/x86/fft_mmx.asm +++ b/libavcodec/x86/fft_mmx.asm @@ -85,7 +85,7 @@ cextern cos_ %+ i %1 %endmacro -section .text align=16 +SECTION_TEXT %macro T2_3DN 4 ; z0, z1, mem0, mem1 mova %1, %3 diff --git a/libavcodec/x86/fmtconvert.asm b/libavcodec/x86/fmtconvert.asm index e023b48322..13d6cc0130 100644 --- a/libavcodec/x86/fmtconvert.asm +++ b/libavcodec/x86/fmtconvert.asm @@ -22,7 +22,7 @@ %include "x86inc.asm" %include "x86util.asm" -section .text align=16 +SECTION_TEXT %macro PSWAPD_SSE 2 pshufw %1, %2, 0x4e diff --git a/libavcodec/x86/x86inc.asm b/libavcodec/x86/x86inc.asm index 53091c14c9..c84d5566a2 100644 --- a/libavcodec/x86/x86inc.asm +++ b/libavcodec/x86/x86inc.asm @@ -63,11 +63,22 @@ %elifidn __OUTPUT_FORMAT__,macho SECTION .text align=%1 fakegot: + %elifidn __OUTPUT_FORMAT__,aout + section .text %else SECTION .rodata align=%1 %endif %endmacro +; aout does not support align= +%macro SECTION_TEXT 0-1 16 + %ifidn __OUTPUT_FORMAT__,aout + SECTION .text + %else + SECTION .text align=%1 + %endif +%endmacro + %ifdef WIN64 %define PIC %elifndef ARCH_X86_64 From 9297f1ed15a4707b1b59c5c347d7185ee0bb3ef8 Mon Sep 17 00:00:00 2001 From: Dave Yeo Date: Fri, 20 May 2011 17:26:52 +0200 Subject: [PATCH 08/11] configure: Set OS/2 objformat to a.out. Signed-off-by: Diego Biurrun --- configure | 1 + 1 file changed, 1 insertion(+) mode change 100755 => 100644 configure diff --git a/configure b/configure old mode 100755 new mode 100644 index 96867a550e..634edd54d3 --- a/configure +++ b/configure @@ -2473,6 +2473,7 @@ case $target_os in ;; os/2*) ln_s="cp -f" + objformat="aout" add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf' FFSERVERLDFLAGS="" From 0a6db2a25a70e3e8fb414e361719152a9e7e9766 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 16 May 2011 16:16:14 +0200 Subject: [PATCH 09/11] configure: Do not unconditionally add -Wall to host CFLAGS. Some compilers choke on -Wall, so only add the flag after checking it works. --- configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 634edd54d3..b63330cbff 100644 --- a/configure +++ b/configure @@ -1672,7 +1672,7 @@ LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' CC_O='-o $@' -host_cflags='-D_ISOC99_SOURCE -O3 -g -Wall' +host_cflags='-D_ISOC99_SOURCE -O3 -g' host_libs='-lm' target_path='$(CURDIR)' @@ -2334,6 +2334,7 @@ check_cc -D_LARGEFILE_SOURCE < Date: Fri, 20 May 2011 10:49:20 -0400 Subject: [PATCH 10/11] LATM/AAC: Free previously initialized context on reinit. Fixes memory leaks which are the result of overwriting already-initialized MDCT contexts during context reinitialization, e.g. in valgrind fate-aac-latm_000000001180bc60. Signed-off-by: Diego Biurrun --- libavcodec/aacdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index f2d50f4aba..fbb3582661 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -2464,6 +2464,7 @@ static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size, *out_size = 0; return avpkt->size; } else { + aac_decode_close(avctx); if ((err = aac_decode_init(avctx)) < 0) return err; latmctx->initialized = 1; From a1d0dcc7134f1401c682b5e13d4ab3864da21efb Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 20 May 2011 18:11:31 +0100 Subject: [PATCH 11/11] configure: make executable again Signed-off-by: Mans Rullgard --- configure | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 configure diff --git a/configure b/configure old mode 100644 new mode 100755