diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-06-16 03:53:58 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-06-16 03:53:58 +0200 |
commit | 7a02527b05e2ae5ffab579062dbe3c888758335f (patch) | |
tree | c52ec9666f9436a6c15df3c6b32d08d897771aba | |
parent | a0bafaabb0656ca3bb3591beba0de79f6153fdac (diff) | |
parent | b203f65451646b1555d458a3601159f7d89a3397 (diff) | |
download | ffmpeg-7a02527b05e2ae5ffab579062dbe3c888758335f.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
ac3enc: use correct alignment and length in channel coupling dsp functions.
ffmpeg: don't abuse a global for passing framerate from input to output
ffmpeg: don't abuse a global for passing channels from input to output
ffmpeg: don't abuse a global for passing samplerate from input to output
ARM: update ff_h264_idct8_add4_neon for 4:4:4 changes
swscale: use SwsContext for av_log when available
swscale: Remove HAVE_MMX from files that are only compiled with MMX enabled.
swscale: Fix compilation with --disable-mmx2.
Conflicts:
ffmpeg.c
libswscale/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | ffmpeg.c | 61 | ||||
-rw-r--r-- | libavcodec/ac3enc_template.c | 24 | ||||
-rw-r--r-- | libavcodec/arm/h264dsp_init_arm.c | 3 | ||||
-rw-r--r-- | libavcodec/arm/h264idct_neon.S | 41 | ||||
-rw-r--r-- | libswscale/utils.c | 8 | ||||
-rw-r--r-- | libswscale/x86/rgb2rgb.c | 2 | ||||
-rw-r--r-- | libswscale/x86/swscale_mmx.c | 2 | ||||
-rw-r--r-- | libswscale/x86/yuv2rgb_mmx.c | 6 | ||||
-rw-r--r-- | tests/fate2.mak | 2 | ||||
-rwxr-xr-x | tests/lavf-regression.sh | 12 | ||||
-rwxr-xr-x | tests/regression-funcs.sh | 2 |
11 files changed, 92 insertions, 71 deletions
@@ -173,12 +173,12 @@ static char *vfilters = NULL; #endif static int intra_only = 0; -static int audio_sample_rate = 44100; +static int audio_sample_rate = 0; static int64_t channel_layout = 0; #define QSCALE_NONE -99999 static float audio_qscale = QSCALE_NONE; static int audio_disable = 0; -static int audio_channels = 1; +static int audio_channels = 0; static char *audio_codec_name = NULL; static unsigned int audio_codec_tag = 0; static char *audio_language = NULL; @@ -283,6 +283,7 @@ typedef struct AVOutputStream { int resample_height; int resample_width; int resample_pix_fmt; + AVRational frame_rate; float frame_aspect_ratio; @@ -2267,6 +2268,17 @@ static int transcode(AVFormatContext **output_files, if(!ost->fifo) goto fail; ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); + if (!codec->sample_rate) { + codec->sample_rate = icodec->sample_rate; + if (icodec->lowres) + codec->sample_rate >>= icodec->lowres; + } + choose_sample_rate(ost->st, codec->codec); + codec->time_base = (AVRational){1, codec->sample_rate}; + if (!codec->channels) + codec->channels = icodec->channels; + if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) + codec->channel_layout = 0; ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; ist->decoding_needed = 1; @@ -2292,6 +2304,14 @@ static int transcode(AVFormatContext **output_files, ost->encoding_needed = 1; ist->decoding_needed = 1; + if (!ost->frame_rate.num) + ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1}; + if (codec->codec && codec->codec->supported_framerates && !force_fps) { + int idx = av_find_nearest_q_idx(ost->frame_rate, codec->codec->supported_framerates); + ost->frame_rate = codec->codec->supported_framerates[idx]; + } + codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num}; + #if CONFIG_AVFILTER if (configure_video_filters(ist, ost)) { fprintf(stderr, "Error opening filters!\n"); @@ -3369,16 +3389,9 @@ static int opt_input_file(const char *opt, const char *filename) input_codecs[nb_input_codecs-1] = avcodec_find_decoder(dec->codec_id); set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, input_codecs[nb_input_codecs-1]); channel_layout = dec->channel_layout; - audio_channels = dec->channels; - audio_sample_rate = dec->sample_rate; audio_sample_fmt = dec->sample_fmt; if(audio_disable) st->discard= AVDISCARD_ALL; - /* Note that av_find_stream_info can add more streams, and we - * currently have no chance of setting up lowres decoding - * early enough for them. */ - if (dec->lowres) - audio_sample_rate >>= dec->lowres; break; case AVMEDIA_TYPE_VIDEO: input_codecs[nb_input_codecs-1] = avcodec_find_decoder_by_name(video_codec_name); @@ -3408,9 +3421,6 @@ static int opt_input_file(const char *opt, const char *filename) (float)rfps / rfps_base, rfps, rfps_base); } - /* update the current frame rate to match the stream frame rate */ - frame_rate.num = rfps; - frame_rate.den = rfps_base; if(video_disable) st->discard= AVDISCARD_ALL; @@ -3445,6 +3455,9 @@ static int opt_input_file(const char *opt, const char *filename) video_channel = 0; top_field_first = -1; + frame_rate = (AVRational){0, 0}; + audio_sample_rate = 0; + audio_channels = 0; av_freep(&video_codec_name); av_freep(&audio_codec_name); @@ -3555,16 +3568,12 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) } else { const char *p; int i; - AVRational fps= frame_rate.num ? frame_rate : (AVRational){25,1}; + if (frame_rate.num) + ost->frame_rate = frame_rate; video_enc->codec_id = codec_id; set_context_opts(video_enc, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); - if (codec && codec->supported_framerates && !force_fps) - fps = codec->supported_framerates[av_find_nearest_q_idx(fps, codec->supported_framerates)]; - video_enc->time_base.den = fps.num; - video_enc->time_base.num = fps.den; - video_enc->width = frame_width; video_enc->height = frame_height; video_enc->pix_fmt = frame_pix_fmt; @@ -3691,8 +3700,6 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) } if (audio_stream_copy) { st->stream_copy = 1; - audio_enc->channels = audio_channels; - audio_enc->sample_rate = audio_sample_rate; } else { audio_enc->codec_id = codec_id; set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); @@ -3701,16 +3708,14 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) audio_enc->flags |= CODEC_FLAG_QSCALE; audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale; } - audio_enc->channels = audio_channels; + if (audio_channels) + audio_enc->channels = audio_channels; audio_enc->sample_fmt = audio_sample_fmt; - audio_enc->sample_rate = audio_sample_rate; + if (audio_sample_rate) + audio_enc->sample_rate = audio_sample_rate; audio_enc->channel_layout = channel_layout; - if (av_get_channel_layout_nb_channels(channel_layout) != audio_channels) - audio_enc->channel_layout = 0; choose_sample_fmt(st, codec); - choose_sample_rate(st, codec); } - audio_enc->time_base= (AVRational){1, audio_sample_rate}; if (audio_language) { av_dict_set(&st->metadata, "language", audio_language, 0); av_freep(&audio_language); @@ -3983,6 +3988,10 @@ static int opt_output_file(const char *opt, const char *filename) set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL); + frame_rate = (AVRational){0, 0}; + audio_sample_rate = 0; + audio_channels = 0; + av_freep(&forced_key_frames); uninit_opts(); init_opts(); diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index 0547165aaf..f6248a82c9 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -134,36 +134,38 @@ void AC3_NAME(apply_channel_coupling)(AC3EncodeContext *s) LOCAL_ALIGNED_16(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]); int blk, ch, bnd, i, j; CoefSumType energy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16] = {{{0}}}; - int num_cpl_coefs = s->num_cpl_subbands * 12; + int cpl_start, num_cpl_coefs; memset(cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords)); memset(fixed_cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*fixed_cpl_coords)); + /* align start to 16-byte boundary. align length to multiple of 32. + note: coupling start bin % 4 will always be 1 */ + cpl_start = s->start_freq[CPL_CH] - 1; + num_cpl_coefs = FFALIGN(s->num_cpl_subbands * 12 + 1, 32); + cpl_start = FFMIN(256, cpl_start + num_cpl_coefs) - num_cpl_coefs; + /* calculate coupling channel from fbw channels */ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { AC3Block *block = &s->blocks[blk]; - CoefType *cpl_coef = &block->mdct_coef[CPL_CH][s->start_freq[CPL_CH]]; + CoefType *cpl_coef = &block->mdct_coef[CPL_CH][cpl_start]; if (!block->cpl_in_use) continue; - memset(cpl_coef-1, 0, (num_cpl_coefs+4) * sizeof(*cpl_coef)); + memset(cpl_coef, 0, num_cpl_coefs * sizeof(*cpl_coef)); for (ch = 1; ch <= s->fbw_channels; ch++) { - CoefType *ch_coef = &block->mdct_coef[ch][s->start_freq[CPL_CH]]; + CoefType *ch_coef = &block->mdct_coef[ch][cpl_start]; if (!block->channel_in_cpl[ch]) continue; for (i = 0; i < num_cpl_coefs; i++) cpl_coef[i] += ch_coef[i]; } - /* note: coupling start bin % 4 will always be 1 and num_cpl_coefs - will always be a multiple of 12, so we need to subtract 1 from - the start and add 4 to the length when using optimized - functions which require 16-byte alignment. */ /* coefficients must be clipped to +/- 1.0 in order to be encoded */ - s->dsp.vector_clipf(cpl_coef-1, cpl_coef-1, -1.0f, 1.0f, num_cpl_coefs+4); + s->dsp.vector_clipf(cpl_coef, cpl_coef, -1.0f, 1.0f, num_cpl_coefs); /* scale coupling coefficients from float to 24-bit fixed-point */ - s->ac3dsp.float_to_fixed24(&block->fixed_coef[CPL_CH][s->start_freq[CPL_CH]-1], - cpl_coef-1, num_cpl_coefs+4); + s->ac3dsp.float_to_fixed24(&block->fixed_coef[CPL_CH][cpl_start], + cpl_coef, num_cpl_coefs); } /* calculate energy in each band in coupling channel and each fbw channel */ diff --git a/libavcodec/arm/h264dsp_init_arm.c b/libavcodec/arm/h264dsp_init_arm.c index b344584799..e9146405c2 100644 --- a/libavcodec/arm/h264dsp_init_arm.c +++ b/libavcodec/arm/h264dsp_init_arm.c @@ -122,8 +122,7 @@ static void ff_h264dsp_init_neon(H264DSPContext *c, const int bit_depth) c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; c->h264_idct_add16 = ff_h264_idct_add16_neon; c->h264_idct_add16intra = ff_h264_idct_add16intra_neon; - //FIXME: reenable when asm is updated. - //c->h264_idct_add8 = ff_h264_idct_add8_neon; + c->h264_idct_add8 = ff_h264_idct_add8_neon; c->h264_idct8_add = ff_h264_idct8_add_neon; c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; c->h264_idct8_add4 = ff_h264_idct8_add4_neon; diff --git a/libavcodec/arm/h264idct_neon.S b/libavcodec/arm/h264idct_neon.S index 6b6a669f35..afd3718518 100644 --- a/libavcodec/arm/h264idct_neon.S +++ b/libavcodec/arm/h264idct_neon.S @@ -148,24 +148,27 @@ function ff_h264_idct_add8_neon, export=1 add r5, r1, #16*4 add r1, r2, #16*32 mov r2, r3 + mov r3, r1 ldr r6, [sp, #32] movrel r7, scan8+16 - mov ip, #7 -1: ldrb r8, [r7], #1 - ldr r0, [r5], #4 + mov r12, #0 +1: ldrb r8, [r7, r12] + ldr r0, [r5, r12, lsl #2] ldrb r8, [r6, r8] - tst ip, #4 - addne r0, r0, r4 - addeq r0, r0, r9 + add r0, r0, r4 + add r1, r3, r12, lsl #5 cmp r8, #0 ldrsh r8, [r1] adrne lr, ff_h264_idct_add_neon adreq lr, ff_h264_idct_dc_add_neon cmpeq r8, #0 blxne lr - subs ip, ip, #1 - add r1, r1, #32 - bge 1b + add r12, r12, #1 + cmp r12, #4 + moveq r12, #16 + moveq r4, r9 + cmp r12, #20 + blt 1b pop {r4-r10,pc} endfunc @@ -374,11 +377,15 @@ function ff_h264_idct8_add4_neon, export=1 endfunc .section .rodata -scan8: .byte 4+1*8, 5+1*8, 4+2*8, 5+2*8 - .byte 6+1*8, 7+1*8, 6+2*8, 7+2*8 - .byte 4+3*8, 5+3*8, 4+4*8, 5+4*8 - .byte 6+3*8, 7+3*8, 6+4*8, 7+4*8 - .byte 1+1*8, 2+1*8 - .byte 1+2*8, 2+2*8 - .byte 1+4*8, 2+4*8 - .byte 1+5*8, 2+5*8 +scan8: .byte 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8 + .byte 6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8 + .byte 4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8 + .byte 6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8 + .byte 4+ 6*8, 5+ 6*8, 4+ 7*8, 5+ 7*8 + .byte 6+ 6*8, 7+ 6*8, 6+ 7*8, 7+ 7*8 + .byte 4+ 8*8, 5+ 8*8, 4+ 9*8, 5+ 9*8 + .byte 6+ 8*8, 7+ 8*8, 6+ 9*8, 7+ 9*8 + .byte 4+11*8, 5+11*8, 4+12*8, 5+12*8 + .byte 6+11*8, 7+11*8, 6+12*8, 7+12*8 + .byte 4+13*8, 5+13*8, 4+14*8, 5+14*8 + .byte 6+13*8, 7+13*8, 6+14*8, 7+14*8 diff --git a/libswscale/utils.c b/libswscale/utils.c index c41590fd62..984f2c52fa 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -790,11 +790,11 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) unscaled = (srcW == dstW && srcH == dstH); if (!isSupportedIn(srcFormat)) { - av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as input pixel format\n", av_get_pix_fmt_name(srcFormat)); + av_log(c, AV_LOG_ERROR, "%s is not supported as input pixel format\n", av_get_pix_fmt_name(srcFormat)); return AVERROR(EINVAL); } if (!isSupportedOut(dstFormat)) { - av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as output pixel format\n", av_get_pix_fmt_name(dstFormat)); + av_log(c, AV_LOG_ERROR, "%s is not supported as output pixel format\n", av_get_pix_fmt_name(dstFormat)); return AVERROR(EINVAL); } @@ -810,12 +810,12 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) |SWS_SPLINE |SWS_BICUBLIN); if(!i || (i & (i-1))) { - av_log(NULL, AV_LOG_ERROR, "swScaler: Exactly one scaler algorithm must be chosen\n"); + av_log(c, AV_LOG_ERROR, "Exactly one scaler algorithm must be chosen\n"); return AVERROR(EINVAL); } /* sanity check */ if (srcW<4 || srcH<1 || dstW<8 || dstH<1) { //FIXME check if these are enough and try to lowwer them after fixing the relevant parts of the code - av_log(NULL, AV_LOG_ERROR, "swScaler: %dx%d -> %dx%d is invalid scaling dimension\n", + av_log(c, AV_LOG_ERROR, "%dx%d -> %dx%d is invalid scaling dimension\n", srcW, srcH, dstW, dstH); return AVERROR(EINVAL); } diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c index 78b804e367..ed7f5adb74 100644 --- a/libswscale/x86/rgb2rgb.c +++ b/libswscale/x86/rgb2rgb.c @@ -127,7 +127,7 @@ void rgb2rgb_init_x86(void) { int cpu_flags = av_get_cpu_flags(); - if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) + if (cpu_flags & AV_CPU_FLAG_MMX) rgb2rgb_init_MMX(); if (HAVE_AMD3DNOW && cpu_flags & AV_CPU_FLAG_3DNOW) rgb2rgb_init_3DNOW(); diff --git a/libswscale/x86/swscale_mmx.c b/libswscale/x86/swscale_mmx.c index 2d5b88070a..775d5f683d 100644 --- a/libswscale/x86/swscale_mmx.c +++ b/libswscale/x86/swscale_mmx.c @@ -182,6 +182,8 @@ void ff_sws_init_swScale_mmx(SwsContext *c) if (cpu_flags & AV_CPU_FLAG_MMX) sws_init_swScale_MMX(c); +#if HAVE_MMX2 if (cpu_flags & AV_CPU_FLAG_MMX2) sws_init_swScale_MMX2(c); +#endif } diff --git a/libswscale/x86/yuv2rgb_mmx.c b/libswscale/x86/yuv2rgb_mmx.c index d46d5126da..df0e1a3726 100644 --- a/libswscale/x86/yuv2rgb_mmx.c +++ b/libswscale/x86/yuv2rgb_mmx.c @@ -72,14 +72,16 @@ SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c) c->srcFormat != PIX_FMT_YUVA420P) return NULL; - if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2) { +#if HAVE_MMX2 + if (cpu_flags & AV_CPU_FLAG_MMX2) { switch (c->dstFormat) { case PIX_FMT_RGB24: return yuv420_rgb24_MMX2; case PIX_FMT_BGR24: return yuv420_bgr24_MMX2; } } +#endif - if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) { + if (cpu_flags & AV_CPU_FLAG_MMX) { switch (c->dstFormat) { case PIX_FMT_RGB32: if (c->srcFormat == PIX_FMT_YUVA420P) { diff --git a/tests/fate2.mak b/tests/fate2.mak index 6a9448faf1..066f9ef583 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -165,7 +165,7 @@ fate-wmapro-2ch: CMP = oneoff fate-wmapro-2ch: REF = $(SAMPLES)/wmapro/Beethovens_9th-1_small.pcm FATE_TESTS += fate-ansi -fate-ansi: CMD = framecrc -i $(SAMPLES)/ansi/TRE-IOM5.ANS -pix_fmt rgb24 +fate-ansi: CMD = framecrc -ar 44100 -i $(SAMPLES)/ansi/TRE-IOM5.ANS -pix_fmt rgb24 FATE_TESTS += fate-wmv8-drm # discard last packet to avoid fails due to overread of VC-1 decoder diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh index 94d258334b..39e752b3c6 100755 --- a/tests/lavf-regression.sh +++ b/tests/lavf-regression.sh @@ -14,7 +14,7 @@ eval do_$test=y do_lavf() { file=${outfile}lavf.$1 - 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 $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $2 do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file $3 } @@ -39,8 +39,8 @@ do_image_formats() do_audio_only() { file=${outfile}lavf.$1 - 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 + do_ffmpeg $file $DEC_OPTS $2 -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $3 + do_ffmpeg_crc $file $DEC_OPTS $4 -i $target_path/$file } rm -f "$logfile" @@ -55,7 +55,7 @@ fi if [ -n "$do_rm" ] ; then file=${outfile}lavf.rm -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 +do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed # broken #do_ffmpeg_crc $file -i $target_path/$file fi @@ -181,11 +181,11 @@ do_audio_only wav fi if [ -n "$do_alaw" ] ; then -do_audio_only al +do_audio_only al "" "" "-ar 44100" fi if [ -n "$do_mulaw" ] ; then -do_audio_only ul +do_audio_only ul "" "" "-ar 44100" fi if [ -n "$do_au" ] ; then diff --git a/tests/regression-funcs.sh b/tests/regression-funcs.sh index 4cf2e20fd8..e57cdf111e 100755 --- a/tests/regression-funcs.sh +++ b/tests/regression-funcs.sh @@ -114,7 +114,7 @@ do_video_encoding() do_audio_encoding() { file=${outfile}$1 - do_ffmpeg $file $DEC_OPTS -ac 2 -f s16le -i $pcm_src -ab 128k $ENC_OPTS $2 + do_ffmpeg $file $DEC_OPTS -ac 2 -ar 44100 -f s16le -i $pcm_src -ab 128k $ENC_OPTS $2 } do_audio_decoding() |