diff mbox series

[FFmpeg-devel,04/17] avcodec/ac3enc: Use bit-operations for bit-mask

Message ID GV1P250MB073730C38ACEF9DD78C806178F012@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 8261d5d38c93419535dbd81116fc1d065716e039
Headers show
Series [FFmpeg-devel,01/17] avcodec/ac3enc: Don't presume ch_layout to be AV_CHANNEL_ORDER_NATIVE | 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 April 7, 2024, 9:09 p.m. UTC
Simply masking the LFE bit is more natural than subtracting
if set.

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

Patch

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 1a65e35161..31b9474822 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -2199,10 +2199,8 @@  static av_cold void set_channel_info(AVCodecContext *avctx)
     s->channels     = channels;
     s->fbw_channels = channels - s->lfe_on;
     s->lfe_channel  = s->lfe_on ? s->fbw_channels + 1 : -1;
-    if (s->lfe_on)
-        mask -= AV_CH_LOW_FREQUENCY;
 
-    switch (mask) {
+    switch (mask & ~AV_CH_LOW_FREQUENCY) {
     case AV_CH_LAYOUT_MONO:           s->channel_mode = AC3_CHMODE_MONO;   break;
     case AV_CH_LAYOUT_STEREO:         s->channel_mode = AC3_CHMODE_STEREO; break;
     case AV_CH_LAYOUT_SURROUND:       s->channel_mode = AC3_CHMODE_3F;     break;