[FFmpeg-devel] [PATCH 11/11] avcodec/aptxenc: Process data in complete blocks of four samples only

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Aug 30 00:27:44 EEST 2021


Otherwise one could read into the frame's padding when one encounters
the small last frame.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
With this patch the last few samples of the last frame will be ignored.
It would be possible to avoid that by padding the frame to a multiple
of four samples. This could be done with a new codec cap/flag; the existing
padding code could be reused for this.

 libavcodec/aptxenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c
index 5ea6053c26..effab86b61 100644
--- a/libavcodec/aptxenc.c
+++ b/libavcodec/aptxenc.c
@@ -215,7 +215,7 @@ static int aptx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)
         return ret;
 
-    output_size = s->block_size * frame->nb_samples/4;
+    output_size = s->block_size * (frame->nb_samples/4);
     if ((ret = ff_get_encode_buffer(avctx, avpkt, output_size, 0)) < 0)
         return ret;
 
-- 
2.30.2



More information about the ffmpeg-devel mailing list