diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-08-24 10:28:32 +0000 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-11-06 09:02:08 +0100 |
commit | 56dc46a1893251e74be1ad63e54fb38d754bb1fe (patch) | |
tree | 494be843557be4ffb1b905dfaec2559c63c43ba8 /libavformat/riffenc.c | |
parent | 91e8d2eb1f7bf3af949008b106ec1ca037b88b0e (diff) | |
download | ffmpeg-56dc46a1893251e74be1ad63e54fb38d754bb1fe.tar.gz |
riffenc: do not fall back on AVCodecContext.frame_size for MP3
It will not be set unless the codec context is used as the encoding
context, which is discouraged. For MP2, av_get_audio_frame_duration()
will already set the frame size properly. For MP3, set the frame size
explicitly.
Diffstat (limited to 'libavformat/riffenc.c')
-rw-r--r-- | libavformat/riffenc.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c index b83533a250..81b3b2da12 100644 --- a/libavformat/riffenc.c +++ b/libavformat/riffenc.c @@ -63,8 +63,6 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc) * fall back on using AVCodecContext.frame_size, which is not as reliable * for indicating packet duration. */ frame_size = av_get_audio_frame_duration(enc, enc->block_align); - if (!frame_size) - frame_size = enc->frame_size; waveformatextensible = (enc->channels > 2 && enc->channel_layout) || enc->sample_rate > 48000 || @@ -96,12 +94,10 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc) enc->bits_per_coded_sample, bps); } - if (enc->codec_id == AV_CODEC_ID_MP2 || - enc->codec_id == AV_CODEC_ID_MP3) { - /* This is wrong, but it seems many demuxers do not work if this - * is set correctly. */ + if (enc->codec_id == AV_CODEC_ID_MP2) { blkalign = frame_size; - // blkalign = 144 * enc->bit_rate/enc->sample_rate; + } else if (enc->codec_id == AV_CODEC_ID_MP3) { + blkalign = 576 * (enc->sample_rate <= 24000 ? 1 : 2); } else if (enc->codec_id == AV_CODEC_ID_AC3) { blkalign = 3840; /* maximum bytes per frame */ } else if (enc->block_align != 0) { /* specified by the codec */ |