1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

mlp: move pack_output pointer to decoder context

The current pack_output function pointer is a property of the decoder,
rather than a constant method provided by the DSP code. Indeed, except
for an unused initialisation, the field is never used in DSP code.
This commit is contained in:
Rémi Denis-Courmont 2023-12-18 20:28:14 +02:00
parent c933ff2779
commit 0f05f9ed3e
3 changed files with 28 additions and 29 deletions

View File

@ -173,6 +173,14 @@ typedef struct MLPDecodeContext {
DECLARE_ALIGNED(32, int32_t, sample_buffer)[MAX_BLOCKSIZE][MAX_CHANNELS]; DECLARE_ALIGNED(32, int32_t, sample_buffer)[MAX_BLOCKSIZE][MAX_CHANNELS];
MLPDSPContext dsp; MLPDSPContext dsp;
int32_t (*pack_output)(int32_t lossless_check_data,
uint16_t blockpos,
int32_t (*sample_buffer)[MAX_CHANNELS],
void *data,
uint8_t *ch_assign,
int8_t *output_shift,
uint8_t max_matrix_channel,
int is32);
} MLPDecodeContext; } MLPDecodeContext;
static const enum AVChannel thd_channel_order[] = { static const enum AVChannel thd_channel_order[] = {
@ -422,10 +430,10 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->avctx->sample_fmt = AV_SAMPLE_FMT_S32; m->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
else else
m->avctx->sample_fmt = AV_SAMPLE_FMT_S16; m->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(m->substream[m->max_decoded_substream].ch_assign, m->pack_output = m->dsp.mlp_select_pack_output(m->substream[m->max_decoded_substream].ch_assign,
m->substream[m->max_decoded_substream].output_shift, m->substream[m->max_decoded_substream].output_shift,
m->substream[m->max_decoded_substream].max_matrix_channel, m->substream[m->max_decoded_substream].max_matrix_channel,
m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
m->params_valid = 1; m->params_valid = 1;
for (substr = 0; substr < MAX_SUBSTREAMS; substr++) for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
@ -663,10 +671,10 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
if (substr == m->max_decoded_substream) { if (substr == m->max_decoded_substream) {
av_channel_layout_uninit(&m->avctx->ch_layout); av_channel_layout_uninit(&m->avctx->ch_layout);
av_channel_layout_from_mask(&m->avctx->ch_layout, s->mask); av_channel_layout_from_mask(&m->avctx->ch_layout, s->mask);
m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign, m->pack_output = m->dsp.mlp_select_pack_output(s->ch_assign,
s->output_shift, s->output_shift,
s->max_matrix_channel, s->max_matrix_channel,
m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
if (m->avctx->codec_id == AV_CODEC_ID_MLP && m->needs_reordering) { if (m->avctx->codec_id == AV_CODEC_ID_MLP && m->needs_reordering) {
if (s->mask == (AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY) || if (s->mask == (AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY) ||
@ -925,10 +933,10 @@ static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp,
} }
} }
if (substr == m->max_decoded_substream) if (substr == m->max_decoded_substream)
m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign, m->pack_output = m->dsp.mlp_select_pack_output(s->ch_assign,
s->output_shift, s->output_shift,
s->max_matrix_channel, s->max_matrix_channel,
m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
} }
if (s->param_presence_flags & PARAM_QUANTSTEP) if (s->param_presence_flags & PARAM_QUANTSTEP)
@ -1155,14 +1163,14 @@ static int output_data(MLPDecodeContext *m, unsigned int substr,
frame->nb_samples = s->blockpos; frame->nb_samples = s->blockpos;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret; return ret;
s->lossless_check_data = m->dsp.mlp_pack_output(s->lossless_check_data, s->lossless_check_data = m->pack_output(s->lossless_check_data,
s->blockpos, s->blockpos,
m->sample_buffer, m->sample_buffer,
frame->data[0], frame->data[0],
s->ch_assign, s->ch_assign,
s->output_shift, s->output_shift,
s->max_matrix_channel, s->max_matrix_channel,
is32); is32);
/* Update matrix encoding side data */ /* Update matrix encoding side data */
if (s->matrix_encoding != s->prev_matrix_encoding) { if (s->matrix_encoding != s->prev_matrix_encoding) {

View File

@ -130,7 +130,6 @@ av_cold void ff_mlpdsp_init(MLPDSPContext *c)
c->mlp_filter_channel = mlp_filter_channel; c->mlp_filter_channel = mlp_filter_channel;
c->mlp_rematrix_channel = ff_mlp_rematrix_channel; c->mlp_rematrix_channel = ff_mlp_rematrix_channel;
c->mlp_select_pack_output = mlp_select_pack_output; c->mlp_select_pack_output = mlp_select_pack_output;
c->mlp_pack_output = ff_mlp_pack_output;
#if ARCH_ARM #if ARCH_ARM
ff_mlpdsp_init_arm(c); ff_mlpdsp_init_arm(c);
#elif ARCH_X86 #elif ARCH_X86

View File

@ -66,14 +66,6 @@ typedef struct MLPDSPContext {
int8_t *output_shift, int8_t *output_shift,
uint8_t max_matrix_channel, uint8_t max_matrix_channel,
int is32))(int32_t, uint16_t, int32_t (*)[], void *, uint8_t*, int8_t *, uint8_t, int); int is32))(int32_t, uint16_t, int32_t (*)[], void *, uint8_t*, int8_t *, uint8_t, int);
int32_t (*mlp_pack_output)(int32_t lossless_check_data,
uint16_t blockpos,
int32_t (*sample_buffer)[MAX_CHANNELS],
void *data,
uint8_t *ch_assign,
int8_t *output_shift,
uint8_t max_matrix_channel,
int is32);
} MLPDSPContext; } MLPDSPContext;
void ff_mlpdsp_init(MLPDSPContext *c); void ff_mlpdsp_init(MLPDSPContext *c);