diff mbox series

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

Message ID AM7PR03MB66607695B23A4A90E3FD73688FCA9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Superseded
Headers show
Series [FFmpeg-devel,01/11] tests/fate-run: Allow multiple inputs for transcode() | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

Commit Message

Andreas Rheinhardt Aug. 29, 2021, 9:27 p.m. UTC
Otherwise one could read into the frame's padding when one encounters
the small last frame.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@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 mbox series

Patch

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;