History

avcodec/ac3enc: Combine cpl_coord buffers

Andreas Rheinhardt committed 2 years ago

Commit da460fb1 parent 5b9fab02 files · +7 −8Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/ac3enc.c +6 −6
  2. libavcodec/ac3enc.h +1 −2
libavcodec/ac3enc.c+6−6
@@ -2194,8 +2194,7 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) · 2193 unmodified lines
21942194 av_freep(&s->band_psd_buffer);
21952195 av_freep(&s->mask_buffer);
21962196 av_freep(&s->qmant_buffer);
2197− av_freep(&s->cpl_coord_exp_buffer);
2198− av_freep(&s->cpl_coord_mant_buffer);
2197+ av_freep(&s->cpl_coord_buffer);
21992198 av_freep(&s->fdsp);
22002199
22012200 av_tx_uninit(&s->tx);
@@ -2439,6 +2438,7 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) · 237 unmodified lines
24392438 int channels = s->channels + 1; /* includes coupling channel */
24402439 int channel_blocks = channels * s->num_blocks;
24412440 int total_coefs = AC3_MAX_COEFS * channel_blocks;
2441+ uint8_t *cpl_coord_mant_buffer;
24422442 const unsigned sampletype_size = SAMPLETYPE_SIZE(s);
24432443
24442444 for (int ch = 0; ch < s->channels; ch++) {
@@ -2464,9 +2464,9 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) · 19 unmodified lines
24642464 return AVERROR(ENOMEM);
24652465 }
24662466 if (s->cpl_enabled) {
2467− if (!FF_ALLOC_TYPED_ARRAY(s->cpl_coord_exp_buffer, channel_blocks * 16) ||
2468− !FF_ALLOC_TYPED_ARRAY(s->cpl_coord_mant_buffer, channel_blocks * 16))
2467+ if (!FF_ALLOC_TYPED_ARRAY(s->cpl_coord_buffer, channel_blocks * 32))
24692468 return AVERROR(ENOMEM);
2469+ cpl_coord_mant_buffer = s->cpl_coord_buffer + 16 * channel_blocks;
24702470 }
24712471 for (blk = 0; blk < s->num_blocks; blk++) {
24722472 AC3Block *block = &s->blocks[blk];
@@ -2479,8 +2479,8 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) · 6 unmodified lines
24792479 block->mask[ch] = &s->mask_buffer [64 * (blk * channels + ch)];
24802480 block->qmant[ch] = &s->qmant_buffer [AC3_MAX_COEFS * (blk * channels + ch)];
24812481 if (s->cpl_enabled) {
2482− block->cpl_coord_exp[ch] = &s->cpl_coord_exp_buffer [16 * (blk * channels + ch)];
2483− block->cpl_coord_mant[ch] = &s->cpl_coord_mant_buffer[16 * (blk * channels + ch)];
2482+ block->cpl_coord_exp[ch] = &s->cpl_coord_buffer [16 * (blk * channels + ch)];
2483+ block->cpl_coord_mant[ch] = &cpl_coord_mant_buffer[16 * (blk * channels + ch)];
24842484 }
24852485
24862486 /* arrangement: channel, block, coeff */
libavcodec/ac3enc.h+1−2
@@ -243,8 +243,7 @@ typedef struct AC3EncodeContext { · 242 unmodified lines
243243 int16_t *band_psd_buffer;
244244 int16_t *mask_buffer;
245245 int16_t *qmant_buffer;
246− uint8_t *cpl_coord_exp_buffer;
247− uint8_t *cpl_coord_mant_buffer;
246+ uint8_t *cpl_coord_buffer;
248247
249248 uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies
250249 uint8_t frame_exp_strategy[AC3_MAX_CHANNELS]; ///< frame exp strategy index

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t