diff mbox series

[FFmpeg-devel,6/9] avcodec/aptxdec: Process data in complete blocks only

Message ID GV1P250MB0737B6D1211B7DECE35094508F499@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit e6bfb14223e44b4110c1d171d1ecffe9c80302a8
Headers show
Series [FFmpeg-devel,1/9] fate/audio: Add tests for APTX (HD) | expand


Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 15, 2022, 7:28 p.m. UTC
The APTX (HD) decoder decodes blocks of four (six) bytes to four
output samples. It makes no sense to handle incomplete blocks:
They would just lead to synchronization errors, in which case
the complete frame is discarded. So only handle complete blocks.
This also avoids reading from the packet's padding and writing
into the frame's padding.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
 libavcodec/aptxdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/libavcodec/aptxdec.c b/libavcodec/aptxdec.c
index 878c9ffe1b..d254b3026b 100644
--- a/libavcodec/aptxdec.c
+++ b/libavcodec/aptxdec.c
@@ -151,7 +151,7 @@  static int aptx_decode_frame(AVCodecContext *avctx, AVFrame *frame,
     /* get output buffer */
     frame->ch_layout.nb_channels = NB_CHANNELS;
     frame->format = AV_SAMPLE_FMT_S32P;
-    frame->nb_samples = 4 * avpkt->size / s->block_size;
+    frame->nb_samples = 4 * (avpkt->size / s->block_size);
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;