diff mbox series

[FFmpeg-devel,11/12] avcodec/e?ac3enc: Inform compiler about PutBitContext being blank

Message ID AS8P250MB074430BAC1A1E98C935A81048FF52@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,01/12] avutil/avassert: Add av_unreachable and av_assume() macros | expand

Checks

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 May 24, 2024, 10:04 p.m. UTC
This turned out to be very beneficial: For GCC 13, the codesize
of ac3_output_frame_header went down from 4522B to 1247B and
from 10762B to 9298B for eac3_output_frame_header. For Clang 17,
the numbers went down from 3923B to 2477B and from 8338B to 6548B
(always with -O3).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/ac3enc.c  | 2 ++
 libavcodec/eac3enc.c | 2 ++
 2 files changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 3649289865..a1783577c5 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1638,6 +1638,8 @@  static void ac3_output_frame_header(AC3EncodeContext *s, PutBitContext *pb)
 {
     AC3EncOptions *opt = &s->options;
 
+    put_bits_assume_flushed(pb);
+
     put_bits(pb, 16, 0x0b77);   /* frame header */
     put_bits(pb, 16, 0);        /* crc1: will be filled later */
     put_bits(pb, 2,  s->bit_alloc.sr_code);
diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c
index 8ef3e7e773..1c522dae2e 100644
--- a/libavcodec/eac3enc.c
+++ b/libavcodec/eac3enc.c
@@ -135,6 +135,8 @@  static void eac3_output_frame_header(AC3EncodeContext *s, PutBitContext *pb)
     int blk, ch;
     AC3EncOptions *opt = &s->options;
 
+    put_bits_assume_flushed(pb);
+
     put_bits(pb, 16, 0x0b77);                   /* sync word */
 
     /* BSI header */