]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/ac3enc: Use actual size of buffer in init_put_bits()
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Mon, 29 Mar 2021 16:19:43 +0000 (18:19 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Fri, 2 Apr 2021 10:06:56 +0000 (12:06 +0200)
Since the very beginning (since de6d9b6404bfd1c589799142da5a95428f146edd)
the AC-3 encoder used AC3_MAX_CODED_FRAME_SIZE (namely 3840) for the
size of the output buffer (without any check at all).
This causes problems when encoding EAC-3 for which the maximum is too small,
smaller than the actual size of the buffer: One can run into asserts used
by the PutBits API. Ticket #8513 is about such a case and this commit
fixes it by using the real size of the buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
libavcodec/ac3.h
libavcodec/ac3enc.c

index f8f6a81f45105920243b47536134f0f5bacc66b5..e358f8d9e3971118ba4fda6d8314097a49c05e80 100644 (file)
@@ -27,7 +27,6 @@
 #ifndef AVCODEC_AC3_H
 #define AVCODEC_AC3_H
 
-#define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
 #define EAC3_MAX_CHANNELS 16          /**< maximum number of channels in EAC3 */
 #define AC3_MAX_CHANNELS 7            /**< maximum number of channels, including coupling channel */
 #define CPL_CH 0                      /**< coupling channel index */
index 8044e6dcd008676a99e1f547f865119a6b343d3c..4cfd0afe128f1fdb77f5fd26a3441395e2a9a266 100644 (file)
@@ -1729,7 +1729,7 @@ static void ac3_output_frame(AC3EncodeContext *s, unsigned char *frame)
 {
     int blk;
 
-    init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
+    init_put_bits(&s->pb, frame, s->frame_size);
 
     s->output_frame_header(s);