From 1c9f56f96924a34679f2ea9ce335d114f1ec04a3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 23 Mar 2026 12:01:41 +0100 Subject: [PATCH] avcodec/sbc: Use union to save space One buffer is encoder-only, the other decoder-only. Also move crc_ctx before the buffers (into padding). Signed-off-by: Andreas Rheinhardt --- libavcodec/sbc.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libavcodec/sbc.h b/libavcodec/sbc.h index 0a54f1fbbc..e0105f7338 100644 --- a/libavcodec/sbc.h +++ b/libavcodec/sbc.h @@ -102,16 +102,18 @@ struct sbc_frame { /* bit number x set means joint stereo has been used in subband x */ uint8_t joint; + const AVCRC *crc_ctx; + /* only the lower 4 bits of every element are to be used */ DECLARE_ALIGNED(SBC_ALIGN, uint32_t, scale_factor)[2][8]; - /* raw integer subband samples in the frame */ - DECLARE_ALIGNED(SBC_ALIGN, int32_t, sb_sample_f)[16][2][8]; + union { + /* raw integer subband samples in the frame - encoder only */ + DECLARE_ALIGNED(SBC_ALIGN, int32_t, sb_sample_f)[16][2][8]; - /* modified subband samples */ - DECLARE_ALIGNED(SBC_ALIGN, int32_t, sb_sample)[16][2][8]; - - const AVCRC *crc_ctx; + /* modified subband samples - decoder only */ + DECLARE_ALIGNED(SBC_ALIGN, int32_t, sb_sample)[16][2][8]; + }; }; uint8_t ff_sbc_crc8(const AVCRC *crc_ctx, const uint8_t *data, size_t len);