From eeadaa6bc09dbecccfe3d227a336f6cdeba0b39a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 7 May 2011 13:57:21 +0100 Subject: [PATCH 01/11] regtest: separate flags for encoding and decoding This separates encoding and decoding flags, and passes them together with the related file argument instead of all at the start of the command line. Signed-off-by: Mans Rullgard --- tests/codec-regression.sh | 2 +- tests/lavf-regression.sh | 32 ++++++++++++++++---------------- tests/lavfi-regression.sh | 4 ++-- tests/regression-funcs.sh | 13 ++++++++----- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh index c8fd275e19..93b8901f42 100755 --- a/tests/codec-regression.sh +++ b/tests/codec-regression.sh @@ -61,7 +61,7 @@ do_video_decoding # mpeg2 encoding interlaced file=${outfile}mpeg2reuse.mpg -do_ffmpeg $file -sameq -me_threshold 256 -mb_threshold 1024 -i ${target_path}/${outfile}mpeg2thread.mpg -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 4 +do_ffmpeg $file $DEC_OPTS -me_threshold 256 -i ${target_path}/${outfile}mpeg2thread.mpg $ENC_OPTS -sameq -me_threshold 256 -mb_threshold 1024 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 4 do_video_decoding fi diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh index 7339c4e3c5..28f53f78b0 100755 --- a/tests/lavf-regression.sh +++ b/tests/lavf-regression.sh @@ -14,15 +14,15 @@ eval do_$test=y do_lavf() { file=${outfile}lavf.$1 - do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f s16le -i $pcm_src $2 - do_ffmpeg_crc $file -i $target_path/$file $3 + do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $2 + do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file $3 } do_streamed_images() { file=${outfile}${1}pipe.$1 - do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f image2pipe - do_ffmpeg_crc $file -f image2pipe -i $target_path/$file + do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src -f image2pipe $ENC_OPTS -t 1 -qscale 10 + do_ffmpeg_crc $file $DEC_OPTS -f image2pipe -i $target_path/$file } do_image_formats() @@ -30,17 +30,17 @@ do_image_formats() outfile="$datadir/images/$1/" mkdir -p "$outfile" file=${outfile}%02d.$1 - run_ffmpeg -t 0.5 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src $2 $3 -flags +bitexact -sws_flags +accurate_rnd+bitexact $target_path/$file + run_ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $2 $ENC_OPTS $3 -t 0.5 -y -qscale 10 $target_path/$file do_md5sum ${outfile}02.$1 >> $logfile - do_ffmpeg_crc $file $3 -i $target_path/$file + do_ffmpeg_crc $file $DEC_OPTS $3 -i $target_path/$file wc -c ${outfile}02.$1 >> $logfile } do_audio_only() { file=${outfile}lavf.$1 - do_ffmpeg $file -t 1 -qscale 10 $2 -f s16le -i $pcm_src $3 - do_ffmpeg_crc $file -i $target_path/$file + do_ffmpeg $file $DEC_OPTS $2 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $3 + do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file } rm -f "$logfile" @@ -56,7 +56,7 @@ fi if [ -n "$do_rm" ] ; then file=${outfile}lavf.rm -do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec ac3_fixed +do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed # broken #do_ffmpeg_crc $file -i $target_path/$file fi @@ -127,13 +127,13 @@ fi if [ -n "$do_gif" ] ; then file=${outfile}lavf.gif -do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -pix_fmt rgb24 -do_ffmpeg_crc $file -i $target_path/$file -pix_fmt rgb24 +do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t 1 -qscale 10 -pix_fmt rgb24 +do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file -pix_fmt rgb24 fi if [ -n "$do_yuv4mpeg" ] ; then file=${outfile}lavf.y4m -do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src +do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t 1 -qscale 10 #do_ffmpeg_crc $file -i $target_path/$file fi @@ -227,9 +227,9 @@ conversions="yuv420p yuv422p yuv444p yuyv422 yuv410p yuv411p yuvj420p \ monob yuv440p yuvj440p" for pix_fmt in $conversions ; do file=${outfile}${pix_fmt}.yuv - do_ffmpeg_nocheck $file -r 1 -t 1 -f image2 -vcodec pgmyuv -i $raw_src \ - -f rawvideo -s 352x288 -pix_fmt $pix_fmt $target_path/$raw_dst - do_ffmpeg $file -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $target_path/$raw_dst \ - -f rawvideo -s 352x288 -pix_fmt yuv444p + do_ffmpeg_nocheck $file $DEC_OPTS -r 1 -t 1 -f image2 -vcodec pgmyuv -i $raw_src \ + $ENC_OPTS -f rawvideo -s 352x288 -pix_fmt $pix_fmt $target_path/$raw_dst + do_ffmpeg $file $DEC_OPTS -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $target_path/$raw_dst \ + $ENC_OPTS -f rawvideo -s 352x288 -pix_fmt yuv444p done fi diff --git a/tests/lavfi-regression.sh b/tests/lavfi-regression.sh index ed13f7050a..17988192df 100755 --- a/tests/lavfi-regression.sh +++ b/tests/lavfi-regression.sh @@ -19,8 +19,8 @@ do_video_filter() { filters=$2 shift 2 printf '%-20s' $label >>$logfile - run_ffmpeg -f image2 -vcodec pgmyuv -i $raw_src \ - -vf "$filters" -vcodec rawvideo $* -f nut md5: >>$logfile + run_ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \ + $ENC_OPTS -vf "$filters" -vcodec rawvideo $* -f nut md5: >>$logfile } do_lavfi() { diff --git a/tests/regression-funcs.sh b/tests/regression-funcs.sh index 77ede1d5b7..0e4ea44f46 100755 --- a/tests/regression-funcs.sh +++ b/tests/regression-funcs.sh @@ -53,7 +53,10 @@ echov(){ . $(dirname $0)/md5.sh -FFMPEG_OPTS="-v 0 -threads $threads -y -flags +bitexact -dct fastint -idct simple -sws_flags +accurate_rnd+bitexact" +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" run_ffmpeg() { @@ -115,22 +118,22 @@ do_ffmpeg_nocheck() do_video_decoding() { - do_ffmpeg $raw_dst $1 -i $target_path/$file -f rawvideo $2 + do_ffmpeg $raw_dst $DEC_OPTS $1 -i $target_path/$file -f rawvideo $ENC_OPTS $2 } do_video_encoding() { file=${outfile}$1 - do_ffmpeg $file -f image2 -vcodec pgmyuv -i $raw_src $2 + do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS $2 } do_audio_encoding() { file=${outfile}$1 - do_ffmpeg $file -ab 128k -ac 2 -f s16le -i $pcm_src $2 + do_ffmpeg $file $DEC_OPTS -ac 2 -f s16le -i $pcm_src -ab 128k $ENC_OPTS $2 } do_audio_decoding() { - do_ffmpeg $pcm_dst -i $target_path/$file -sample_fmt s16 -f wav + do_ffmpeg $pcm_dst $DEC_OPTS -i $target_path/$file -sample_fmt s16 -f wav } From 3a2e80ecbc893cbe2ae5bfb7282e4588e7ad1fa5 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 8 May 2011 21:44:12 +0100 Subject: [PATCH 02/11] mpegaudio: remove CONFIG_AUDIO_NONSHORT This fake option cannot be enabled by normal means, and the floating-point decoder should provide the higher quality this option presumably was intended for. Signed-off-by: Mans Rullgard --- libavcodec/mpegaudio.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libavcodec/mpegaudio.h b/libavcodec/mpegaudio.h index fbfddcc5d2..870743ce38 100644 --- a/libavcodec/mpegaudio.h +++ b/libavcodec/mpegaudio.h @@ -35,8 +35,6 @@ #include "dsputil.h" #include "dct.h" -#define CONFIG_AUDIO_NONSHORT 0 - /* max frame size, in samples */ #define MPA_FRAME_SIZE 1152 @@ -73,12 +71,6 @@ #if CONFIG_FLOAT typedef float OUT_INT; #define OUT_FMT AV_SAMPLE_FMT_FLT -#elif CONFIG_MPEGAUDIO_HP && CONFIG_AUDIO_NONSHORT -typedef int32_t OUT_INT; -#define OUT_MAX INT32_MAX -#define OUT_MIN INT32_MIN -#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31) -#define OUT_FMT AV_SAMPLE_FMT_S32 #else typedef int16_t OUT_INT; #define OUT_MAX INT16_MAX From ecfc5e0b72eb24736cf1fcf9e91ee31f34626b47 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 9 May 2011 12:00:56 +0100 Subject: [PATCH 03/11] regtest: fix wma tests This adds $DEC_OPTS to the wma decode commands, making tests pass on systems where the bitexact flag is needed. Signed-off-by: Mans Rullgard --- tests/codec-regression.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh index 93b8901f42..2ee6166c33 100755 --- a/tests/codec-regression.sh +++ b/tests/codec-regression.sh @@ -318,12 +318,12 @@ fi if [ -n "$do_wmav1" ] ; then do_audio_encoding wmav1.asf "-acodec wmav1" -do_ffmpeg_nomd5 $pcm_dst -i $target_path/$file -f wav +do_ffmpeg_nomd5 $pcm_dst $DEC_OPTS -i $target_path/$file -f wav $tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile fi if [ -n "$do_wmav2" ] ; then do_audio_encoding wmav2.asf "-acodec wmav2" -do_ffmpeg_nomd5 $pcm_dst -i $target_path/$file -f wav +do_ffmpeg_nomd5 $pcm_dst $DEC_OPTS -i $target_path/$file -f wav $tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile fi From f9a6cfdd040991bfdbcf2bc97de6666a2ddcd97f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 9 May 2011 16:50:03 +0300 Subject: [PATCH 04/11] rtpproto: Remove an unused variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/rtpproto.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index e1659ee02d..1340665c74 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -138,15 +138,13 @@ static int rtp_open(URLContext *h, const char *uri, int flags) { RTPContext *s; int rtp_port, rtcp_port, - is_output, ttl, connect, + ttl, connect, local_rtp_port, local_rtcp_port, max_packet_size; char hostname[256]; char buf[1024]; char path[1024]; const char *p; - is_output = (flags & AVIO_FLAG_WRITE); - s = av_mallocz(sizeof(RTPContext)); if (!s) return AVERROR(ENOMEM); From a7ea5e3d35f30180ad69b86e6328f434e29119dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 9 May 2011 16:56:56 +0300 Subject: [PATCH 05/11] udp: Fix receiving RTP data over multicast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Earlier, AVIO_RDWR was handled as READ, and all the checks for the AVIO_WRONLY flag explicitly meant the write-only case. When changed from old AVIO/URL contants to AVIO_FLAG in 59d96941f0285a5, these comparisons were updated incorrectly, by mapping checks for AVIO_WRONLY to checks for AVIO_FLAG_WRITE. When receiving RTP over UDP, the urlcontext is opened with READ_WRITE flags. This patch updates the flag comparisons to check for the same conditions as the code did prior to 59d96941f0285a5. Signed-off-by: Martin Storsjö --- libavformat/udp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index 932eb19c2d..62c1c7c107 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -315,7 +315,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) h->is_streamed = 1; h->max_packet_size = 1472; - is_output = (flags & AVIO_FLAG_WRITE); + is_output = !(flags & AVIO_FLAG_READ); s = av_mallocz(sizeof(UDPContext)); if (!s) @@ -358,14 +358,14 @@ static int udp_open(URLContext *h, const char *uri, int flags) /* XXX: fix av_url_split */ if (hostname[0] == '\0' || hostname[0] == '?') { /* only accepts null hostname if input */ - if (flags & AVIO_FLAG_WRITE) + if (!(flags & AVIO_FLAG_READ)) goto fail; } else { if (ff_udp_set_remote_url(h, uri) < 0) goto fail; } - if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) + if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) s->local_port = port; udp_fd = udp_socket_create(s, &my_addr, &len); if (udp_fd < 0) @@ -382,7 +382,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) /* the bind is needed to give a port to the socket now */ /* if multicast, try the multicast address bind first */ - if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) { + if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) { bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len); } /* bind to the local address if not multicast or if the multicast @@ -395,7 +395,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) s->local_port = udp_port(&my_addr, len); if (s->is_multicast) { - if (h->flags & AVIO_FLAG_WRITE) { + if (!(h->flags & AVIO_FLAG_READ)) { /* output */ if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0) goto fail; @@ -478,7 +478,7 @@ static int udp_close(URLContext *h) { UDPContext *s = h->priv_data; - if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) + if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr); closesocket(s->udp_fd); av_free(s); From ed87375dd555a1e7798dcd56c967af0171525a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 9 May 2011 16:29:01 +0300 Subject: [PATCH 06/11] mpegtsenc: Clear st->priv_data when freeing it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If not cleared, the caller might try to free it. Signed-off-by: Martin Storsjö --- libavformat/mpegtsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index bf66aa0be3..55a16f7f0e 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -588,7 +588,7 @@ static int mpegts_write_header(AVFormatContext *s) av_free(pids); for(i = 0;i < s->nb_streams; i++) { st = s->streams[i]; - av_free(st->priv_data); + av_freep(&st->priv_data); } return -1; } From 6bb6fb05ba66ce42ca17c930d81d3e9cf37ab34d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 9 May 2011 12:40:37 +0100 Subject: [PATCH 07/11] mpegaudio: remove CONFIG_MPEGAUDIO_HP option The low quality mode is off by default and never tested. The high quality mode is also plenty fast enough. Signed-off-by: Mans Rullgard --- configure | 3 --- libavcodec/Makefile | 8 ------- libavcodec/bfin/mathops.h | 10 --------- libavcodec/mpegaudio.h | 5 +---- libavcodec/mpegaudio_tablegen.h | 2 ++ libavcodec/mpegaudiodec.c | 37 --------------------------------- libavcodec/mpegaudioenc.c | 5 +++-- 7 files changed, 6 insertions(+), 64 deletions(-) diff --git a/configure b/configure index 29440d80a9..955a568684 100755 --- a/configure +++ b/configure @@ -94,7 +94,6 @@ Configuration options: --enable-w32threads use Win32 threads [no] --enable-x11grab enable X11 grabbing [no] --disable-network disable network support [no] - --disable-mpegaudio-hp faster (but less accurate) MPEG audio decoding [no] --enable-gray enable full grayscale support (slower color) --disable-swscale-alpha disable alpha channel support in swscale --disable-fastdiv disable table-based division @@ -953,7 +952,6 @@ CONFIG_LIST=" mdct memalign_hack mlib - mpegaudio_hp network nonfree pic @@ -1643,7 +1641,6 @@ enable ffmpeg enable ffplay enable ffprobe enable ffserver -enable mpegaudio_hp enable network enable optimizations enable protocols diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 1d8452ac03..996b9b4d81 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -682,14 +682,6 @@ $(SUBDIR)cos_fixed_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF) $(SUBDIR)sin_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF) $(M)./$< sin > $@ -ifdef CONFIG_MPEGAUDIO_HP -$(SUBDIR)mpegaudio_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DFRAC_BITS=23 -$(SUBDIR)mpegaudio_tablegen.ho: CPPFLAGS += -DFRAC_BITS=23 -else -$(SUBDIR)mpegaudio_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DFRAC_BITS=15 -$(SUBDIR)mpegaudio_tablegen.ho: CPPFLAGS += -DFRAC_BITS=15 -endif - ifdef CONFIG_SMALL $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=1 else diff --git a/libavcodec/bfin/mathops.h b/libavcodec/bfin/mathops.h index db527bf249..bbee49380e 100644 --- a/libavcodec/bfin/mathops.h +++ b/libavcodec/bfin/mathops.h @@ -24,7 +24,6 @@ #include "config.h" -#if CONFIG_MPEGAUDIO_HP #define MULH(X,Y) ({ int xxo; \ __asm__ ( \ "a1 = %2.L * %1.L (FU);\n\t" \ @@ -34,15 +33,6 @@ "a1 = a1 >>> 16;\n\t" \ "%0 = (a0 += a1);\n\t" \ : "=d" (xxo) : "d" (X), "d" (Y) : "A0","A1"); xxo; }) -#else -#define MULH(X,Y) ({ int xxo; \ - __asm__ ( \ - "a1 = %2.H * %1.L (IS,M);\n\t" \ - "a0 = %1.H * %2.H, a1+= %1.H * %2.L (IS,M);\n\t"\ - "a1 = a1 >>> 16;\n\t" \ - "%0 = (a0 += a1);\n\t" \ - : "=d" (xxo) : "d" (X), "d" (Y) : "A0","A1"); xxo; }) -#endif /* signed 16x16 -> 32 multiply */ #define MUL16(a, b) ({ int xxo; \ diff --git a/libavcodec/mpegaudio.h b/libavcodec/mpegaudio.h index 870743ce38..f12b897e23 100644 --- a/libavcodec/mpegaudio.h +++ b/libavcodec/mpegaudio.h @@ -56,12 +56,9 @@ #define MP3_MASK 0xFFFE0CCF -#if CONFIG_MPEGAUDIO_HP +#ifndef FRAC_BITS #define FRAC_BITS 23 /* fractional bits for sb_samples and dct */ #define WFRAC_BITS 16 /* fractional bits for window */ -#else -#define FRAC_BITS 15 /* fractional bits for sb_samples and dct */ -#define WFRAC_BITS 14 /* fractional bits for window */ #endif #define FRAC_ONE (1 << FRAC_BITS) diff --git a/libavcodec/mpegaudio_tablegen.h b/libavcodec/mpegaudio_tablegen.h index ccaaf0ba78..6bde277916 100644 --- a/libavcodec/mpegaudio_tablegen.h +++ b/libavcodec/mpegaudio_tablegen.h @@ -38,6 +38,8 @@ static uint32_t expval_table[512][16]; static float exp_table_float[512]; static float expval_table_float[512][16]; +#define FRAC_BITS 23 + static void mpegaudio_tableinit(void) { int i, value, exponent; diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 024d618502..c18d7525f4 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -31,7 +31,6 @@ /* * TODO: - * - in low precision mode, use more 16 bit multiplies in synth filter * - test lsf / mpeg25 extensively. */ @@ -540,24 +539,6 @@ static inline float round_sample(float *sum) #define MLSS(rt, ra, rb) rt-=(ra)*(rb) -#elif FRAC_BITS <= 15 - -static inline int round_sample(int *sum) -{ - int sum1; - sum1 = (*sum) >> OUT_SHIFT; - *sum &= (1< 32 multiply add accumulate */ -#define MACS(rt, ra, rb) MAC16(rt, ra, rb) - -/* signed 16x16 -> 32 multiply */ -#define MULS(ra, rb) MUL16(ra, rb) - -#define MLSS(rt, ra, rb) MLS16(rt, ra, rb) - #else static inline int round_sample(int64_t *sum) @@ -624,8 +605,6 @@ void av_cold RENAME(ff_mpa_synth_init)(MPA_INT *window) v = ff_mpa_enwindow[i]; #if CONFIG_FLOAT v *= 1.0 / (1LL<<(16 + FRAC_BITS)); -#elif WFRAC_BITS < 16 - v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS); #endif window[i] = v; if ((i & 63) != 0) @@ -652,8 +631,6 @@ static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window, OUT_INT *samples2; #if CONFIG_FLOAT float sum, sum2; -#elif FRAC_BITS <= 15 - int sum, sum2; #else int64_t sum, sum2; #endif @@ -710,25 +687,11 @@ void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, { register MPA_INT *synth_buf; int offset; -#if FRAC_BITS <= 15 - int32_t tmp[32]; - int j; -#endif offset = *synth_buf_offset; synth_buf = synth_buf_ptr + offset; -#if FRAC_BITS <= 15 - dct32(tmp, sb_samples); - for(j=0;j<32;j++) { - /* NOTE: can cause a loss in precision if very high amplitude - sound */ - synth_buf[j] = av_clip_int16(tmp[j]); - } -#else dct32(synth_buf, sb_samples); -#endif - apply_window_mp3_c(synth_buf, window, dither_state, samples, incr); offset = (offset - 32) & 511; diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c index 65fac2ad29..e6f2e3b9c2 100644 --- a/libavcodec/mpegaudioenc.c +++ b/libavcodec/mpegaudioenc.c @@ -27,8 +27,9 @@ #include "avcodec.h" #include "put_bits.h" -#undef CONFIG_MPEGAUDIO_HP -#define CONFIG_MPEGAUDIO_HP 0 +#define FRAC_BITS 15 /* fractional bits for sb_samples and dct */ +#define WFRAC_BITS 14 /* fractional bits for window */ + #include "mpegaudio.h" /* currently, cannot change these constants (need to modify From 1435f2fa72b142b11e92a0c2715fd9516364e7db Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 9 May 2011 16:36:57 +0200 Subject: [PATCH 08/11] ffmpeg.c: store per-output stream sws flags. --- ffmpeg.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 2540a2e725..0d5b976327 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -245,8 +245,6 @@ static char *forced_key_frames = NULL; static float dts_delta_threshold = 10; -static unsigned int sws_flags = SWS_BICUBIC; - static int64_t timer_start; static uint8_t *audio_buf; @@ -303,6 +301,8 @@ typedef struct AVOutputStream { AVAudioConvert *reformat_ctx; AVFifoBuffer *fifo; /* for compression: one audio fifo per codec */ FILE *logfile; + + int sws_flags; } AVOutputStream; static AVOutputStream **output_streams_for_file[MAX_FILES] = { NULL }; @@ -378,7 +378,7 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) snprintf(args, 255, "%d:%d:flags=0x%X", codec->width, codec->height, - (int)av_get_int(sws_opts, "sws_flags", NULL)); + ost->sws_flags); if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"), NULL, args, NULL, graph)) < 0) return ret; @@ -387,7 +387,7 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) last_filter = filter; } - snprintf(args, sizeof(args), "flags=0x%X", (int)av_get_int(sws_opts, "sws_flags", NULL)); + snprintf(args, sizeof(args), "flags=0x%X", ost->sws_flags); graph->scale_sws_opts = av_strdup(args); if (vfilters) { @@ -617,6 +617,8 @@ static AVOutputStream *new_output_stream(AVFormatContext *oc, int file_idx) } ost->file_index = file_idx; ost->index = idx; + + ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); return ost; } @@ -1141,7 +1143,6 @@ static void do_video_out(AVFormatContext *s, /* initialize a new scaler context */ sws_freeContext(ost->img_resample_ctx); - sws_flags = av_get_int(sws_opts, "sws_flags", NULL); ost->img_resample_ctx = sws_getContext( ist->st->codec->width, ist->st->codec->height, @@ -1149,7 +1150,7 @@ static void do_video_out(AVFormatContext *s, ost->st->codec->width, ost->st->codec->height, ost->st->codec->pix_fmt, - sws_flags, NULL, NULL, NULL); + ost->sws_flags, NULL, NULL, NULL); if (ost->img_resample_ctx == NULL) { fprintf(stderr, "Cannot get resampling context\n"); ffmpeg_exit(1); @@ -2177,7 +2178,6 @@ static int transcode(AVFormatContext **output_files, fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n"); ffmpeg_exit(1); } - sws_flags = av_get_int(sws_opts, "sws_flags", NULL); ost->img_resample_ctx = sws_getContext( icodec->width, icodec->height, @@ -2185,7 +2185,7 @@ static int transcode(AVFormatContext **output_files, codec->width, codec->height, codec->pix_fmt, - sws_flags, NULL, NULL, NULL); + ost->sws_flags, NULL, NULL, NULL); if (ost->img_resample_ctx == NULL) { fprintf(stderr, "Cannot get resampling context\n"); ffmpeg_exit(1); From 19615089a044520432b8b28e0ed555cc0195416a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 7 May 2011 08:55:25 +0200 Subject: [PATCH 09/11] ffmpeg.c: reset avoptions after each input/output file. This is consistent with how all the other options work. --- cmdutils.c | 1 + ffmpeg.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/cmdutils.c b/cmdutils.c index 9da07223f5..f770c7963d 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -88,6 +88,7 @@ void uninit_opts(void) } av_freep(&opt_names); av_freep(&opt_values); + opt_name_count = 0; } void log_callback_help(void* ptr, int level, const char* fmt, va_list vl) diff --git a/ffmpeg.c b/ffmpeg.c index 0d5b976327..bb64f7cdc9 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3305,6 +3305,8 @@ static void opt_input_file(const char *filename) av_freep(&video_codec_name); av_freep(&audio_codec_name); av_freep(&subtitle_codec_name); + uninit_opts(); + init_opts(); } static void check_inputs(int *has_video_ptr, @@ -3850,6 +3852,8 @@ static void opt_output_file(const char *filename) set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL); av_freep(&forced_key_frames); + uninit_opts(); + init_opts(); } /* same option as mencoder */ From 0d849074a485b868552b3193a433a112be54e657 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 9 May 2011 13:08:08 +0100 Subject: [PATCH 10/11] mpegaudio: remove #if 0 blocks Signed-off-by: Mans Rullgard --- libavcodec/mpegaudiodec.c | 55 --------------------------------------- 1 file changed, 55 deletions(-) diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index c18d7525f4..0d2641418d 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -247,14 +247,6 @@ static inline int l3_unscale(int value, int exponent) static int dev_4_3_coefs[DEV_ORDER]; -#if 0 /* unused */ -static int pow_mult3[3] = { - POW_FIX(1.0), - POW_FIX(1.25992104989487316476), - POW_FIX(1.58740105196819947474), -}; -#endif - static av_cold void int_pow_init(void) { int i, a; @@ -266,53 +258,6 @@ static av_cold void int_pow_init(void) } } -#if 0 /* unused, remove? */ -/* return the mantissa and the binary exponent */ -static int int_pow(int i, int *exp_ptr) -{ - int e, er, eq, j; - int a, a1; - - /* renormalize */ - a = i; - e = POW_FRAC_BITS; - while (a < (1 << (POW_FRAC_BITS - 1))) { - a = a << 1; - e--; - } - a -= (1 << POW_FRAC_BITS); - a1 = 0; - for(j = DEV_ORDER - 1; j >= 0; j--) - a1 = POW_MULL(a, dev_4_3_coefs[j] + a1); - a = (1 << POW_FRAC_BITS) + a1; - /* exponent compute (exact) */ - e = e * 4; - er = e % 3; - eq = e / 3; - a = POW_MULL(a, pow_mult3[er]); - while (a >= 2 * POW_FRAC_ONE) { - a = a >> 1; - eq++; - } - /* convert to float */ - while (a < POW_FRAC_ONE) { - a = a << 1; - eq--; - } - /* now POW_FRAC_ONE <= a < 2 * POW_FRAC_ONE */ -#if POW_FRAC_BITS > FRAC_BITS - a = (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS); - /* correct overflow */ - if (a >= 2 * (1 << FRAC_BITS)) { - a = a >> 1; - eq++; - } -#endif - *exp_ptr = eq; - return a; -} -#endif - static av_cold int decode_init(AVCodecContext * avctx) { MPADecodeContext *s = avctx->priv_data; From a88ef93b4abbea9f18c8750113dc9e99931f2f8a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 9 May 2011 13:55:24 +0100 Subject: [PATCH 11/11] mpegaudiodec: group #includes more sanely Signed-off-by: Mans Rullgard --- libavcodec/mpegaudiodec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 0d2641418d..7fd6bd2dc6 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -28,6 +28,7 @@ #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" +#include "mathops.h" /* * TODO: @@ -37,8 +38,6 @@ #include "mpegaudio.h" #include "mpegaudiodecheader.h" -#include "mathops.h" - #if CONFIG_FLOAT # define SHR(a,b) ((a)*(1.0f/(1<<(b)))) # define compute_antialias compute_antialias_float