[FFmpeg-devel] [PATCH 07/11] avcodec/aptx: Use AVCodecContext.frame_size according to the API
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Mon Aug 30 00:27:40 EEST 2021
Currently the APTX (HD) codecs set frame_size if unset and check
whether it is divisible by block_size (corresponding to block_align
as used by other codecs). But this is based upon a misunderstanding
of the API: frame_size is not in bytes, but in samples.*
Said value is also not intended to be set by the user at all,
but set by encoders and (possibly) decoders if the number of channels
in a frame is constant. The latter condition is not fulfilled here,
so only set it for encoders to the value that it already had for APTX:
1024 samples (per channel).
*: If it were needed to check said value, one would need to check
for it to be divisible by four (four samples correspond to one block
of block_size bytes).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/aptx.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/libavcodec/aptx.c b/libavcodec/aptx.c
index 3aeee1907c..97397aca68 100644
--- a/libavcodec/aptx.c
+++ b/libavcodec/aptx.c
@@ -515,14 +515,8 @@ av_cold int ff_aptx_init(AVCodecContext *avctx)
s->hd = avctx->codec->id == AV_CODEC_ID_APTX_HD;
s->block_size = s->hd ? 6 : 4;
- if (avctx->frame_size == 0)
- avctx->frame_size = 256 * s->block_size;
-
- if (avctx->frame_size % s->block_size) {
- av_log(avctx, AV_LOG_ERROR,
- "Frame size must be a multiple of %d samples\n", s->block_size);
- return AVERROR(EINVAL);
- }
+ if (av_codec_is_encoder(avctx->codec))
+ avctx->frame_size = 1024;
for (chan = 0; chan < NB_CHANNELS; chan++) {
Channel *channel = &s->channels[chan];
--
2.30.2
More information about the ffmpeg-devel
mailing list