mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec: allow either planar or interleaved sample format when encoding mono
When there is only 1 channel, the planar and interleaved formats of the same data type should be treated as identical.
This commit is contained in:
parent
5364327186
commit
37f701f1c3
@ -792,9 +792,16 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
||||
if (av_codec_is_encoder(avctx->codec)) {
|
||||
int i;
|
||||
if (avctx->codec->sample_fmts) {
|
||||
for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; 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->channels == 1 &&
|
||||
av_get_planar_sample_fmt(avctx->sample_fmt) ==
|
||||
av_get_planar_sample_fmt(avctx->codec->sample_fmts[i])) {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user