diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-04-28 04:23:36 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-04-28 04:26:01 +0200 |
commit | 0665199e438fcdd2000717352fc665a8cf017f7c (patch) | |
tree | 41e6d53948b16b9b1c82900da0d28c61efab9333 /libavcodec/utils.c | |
parent | e5d80c7b2d893422e2e60a97e08bfc48ca1684e6 (diff) | |
parent | b239526873dc81f9b66796ad4d9fe1cb93ec34d3 (diff) | |
download | ffmpeg-0665199e438fcdd2000717352fc665a8cf017f7c.tar.gz |
Merge remote branch 'qatar/master'
* qatar/master:
vorbisdec: Rename silly "class_" variable to plain "class".
simple_idct_alpha: Drop some useless casts.
Simplify av_log_missing_feature().
ac3enc: remove check for mismatching channels and channel_layout
If AVCodecContext.channels is 0 and AVCodecContext.channel_layout is non-zero, set channels based on channel_layout.
If AVCodecContext.channel_layout and AVCodecContext.channels are both non-zero, check to make sure they do not contradict eachother.
cosmetics: indentation
Check AVCodec.supported_samplerates and AVCodec.channel_layouts in avcodec_open().
aacdec: remove sf_scale and sf_offset.
aacdec: use a scale of 2 in the LTP MDCT rather than doubling the coefficient table values from the spec.
Define POW_SF2_ZERO in aac.h and use for ff_aac_pow2sf_tabp[] offsets instead of hardcoding 200 everywhere.
Large intensity stereo and PNS indices are legal. Clip them instead of erroring out. A magnitude of 100 corresponds to 2^25 so the will most likely result in clipped output anyway.
qpeg: use reget_buffer() in decode_frame()
ultimotion: use reget_buffer() in ulti_decode_frame()
smacker: remove unnecessary call to avctx->release_buffer in decode_frame()
avparser: don't av_malloc(0).
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 6cdbb43e48..45bf73ff7e 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -555,15 +555,50 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) ret = AVERROR(EINVAL); goto free_and_end; } - if (avctx->codec->sample_fmts && avctx->codec->encode) { + if (avctx->codec->encode) { int i; - for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) - if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) - break; - if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) { - av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n"); - ret = AVERROR(EINVAL); - goto free_and_end; + if (avctx->codec->sample_fmts) { + for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) + if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) + break; + if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) { + av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n"); + ret = AVERROR(EINVAL); + goto free_and_end; + } + } + if (avctx->codec->supported_samplerates) { + for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++) + if (avctx->sample_rate == avctx->codec->supported_samplerates[i]) + break; + if (avctx->codec->supported_samplerates[i] == 0) { + av_log(avctx, AV_LOG_ERROR, "Specified sample_rate is not supported\n"); + ret = AVERROR(EINVAL); + goto free_and_end; + } + } + if (avctx->codec->channel_layouts) { + if (!avctx->channel_layout) { + av_log(avctx, AV_LOG_WARNING, "channel_layout not specified\n"); + } else { + for (i = 0; avctx->codec->channel_layouts[i] != 0; i++) + if (avctx->channel_layout == avctx->codec->channel_layouts[i]) + break; + if (avctx->codec->channel_layouts[i] == 0) { + av_log(avctx, AV_LOG_ERROR, "Specified channel_layout is not supported\n"); + ret = AVERROR(EINVAL); + goto free_and_end; + } + } + } + if (avctx->channel_layout && avctx->channels) { + if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) { + av_log(avctx, AV_LOG_ERROR, "channel layout does not match number of channels\n"); + ret = AVERROR(EINVAL); + goto free_and_end; + } + } else if (avctx->channel_layout) { + avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout); } } @@ -1194,11 +1229,9 @@ void av_log_missing_feature(void *avc, const char *feature, int want_sample) av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your FFmpeg " "version to the newest one from Git. If the problem still " "occurs, it means that your file has a feature which has not " - "been implemented.", feature); + "been implemented.\n", feature); if(want_sample) av_log_ask_for_sample(avc, NULL); - else - av_log(avc, AV_LOG_WARNING, "\n"); } void av_log_ask_for_sample(void *avc, const char *msg, ...) |