History

truehd: break out part of output_data into platform-specific callback.

Verified with profiling that this doesn't have a measurable effect upon overall performance.

Ben Avison committed 12 years ago

Commit b9eb0341 parent fcf5fc43 files · +83 −17Browse files

Unified · Split

3 files
  1. libavcodec/mlpdec.c +23 −17
  2. libavcodec/mlpdsp.c +38 −0
  3. libavcodec/mlpdsp.h +22 −0
libavcodec/mlpdec.c+23−17
@@ -360,6 +360,10 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) · 359 unmodified lines
360360 m->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
361361 else
362362 m->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
363+ m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(m->substream[m->max_decoded_substream].ch_assign,
364+ m->substream[m->max_decoded_substream].output_shift,
365+ m->substream[m->max_decoded_substream].max_matrix_channel,
366+ m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
363367
364368 m->params_valid = 1;
365369 for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
@@ -588,6 +592,10 @@ FF_ENABLE_DEPRECATION_WARNINGS · 222 unmodified lines
588592 if (substr == m->max_decoded_substream) {
589593 m->avctx->channels = s->max_matrix_channel + 1;
590594 m->avctx->channel_layout = s->ch_layout;
595+ m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign,
596+ s->output_shift,
597+ s->max_matrix_channel,
598+ m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
591599 }
592600
593601 return 0;
@@ -818,9 +826,15 @@ static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, · 224 unmodified lines
818826 return ret;
819827
820828 if (s->param_presence_flags & PARAM_OUTSHIFT)
821− if (get_bits1(gbp))
829+ if (get_bits1(gbp)) {
822830 for (ch = 0; ch <= s->max_matrix_channel; ch++)
823831 s->output_shift[ch] = get_sbits(gbp, 4);
832+ if (substr == m->max_decoded_substream)
833+ m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign,
834+ s->output_shift,
835+ s->max_matrix_channel,
836+ m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
837+ }
824838
825839 if (s->param_presence_flags & PARAM_QUANTSTEP)
826840 if (get_bits1(gbp))
@@ -1019,9 +1033,6 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, · 192 unmodified lines
10191033 {
10201034 AVCodecContext *avctx = m->avctx;
10211035 SubStream *s = &m->substream[substr];
1022− unsigned int i, out_ch = 0;
1023− int32_t *data_32;
1024− int16_t *data_16;
10251036 int ret;
10261037 int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
10271038
@@ -1041,19 +1052,14 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, · 13 unmodified lines
10411052 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
10421053 return ret;
10431054 }
1044− data_32 = (int32_t *)frame->data[0];
1045− data_16 = (int16_t *)frame->data[0];
1046−
1047− for (i = 0; i < s->blockpos; i++) {
1048− for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) {
1049− int mat_ch = s->ch_assign[out_ch];
1050− int32_t sample = m->sample_buffer[i][mat_ch]
1051− << s->output_shift[mat_ch];
1052− s->lossless_check_data ^= (sample & 0xffffff) << mat_ch;
1053− if (is32) *data_32++ = sample << 8;
1054− else *data_16++ = sample >> 8;
1055− }
1056− }
1055+ s->lossless_check_data = m->dsp.mlp_pack_output(s->lossless_check_data,
1056+ s->blockpos,
1057+ m->sample_buffer,
1058+ frame->data[0],
1059+ s->ch_assign,
1060+ s->output_shift,
1061+ s->max_matrix_channel,
1062+ is32);
10571063
10581064 /* Update matrix encoding side data */
10591065 if ((ret = ff_side_data_update_matrix_encoding(frame, s->matrix_encoding)) < 0)
libavcodec/mlpdsp.c+38−0
@@ -89,10 +89,48 @@ void ff_mlp_rematrix_channel(int32_t *samples, · 88 unmodified lines
8989 }
9090 }
9191
92+static int32_t (*mlp_select_pack_output(uint8_t *ch_assign,
93+ int8_t *output_shift,
94+ uint8_t max_matrix_channel,
95+ int is32))(int32_t, uint16_t, int32_t (*)[], void *, uint8_t*, int8_t *, uint8_t, int)
96+{
97+ return ff_mlp_pack_output;
98+}
99+
100+int32_t ff_mlp_pack_output(int32_t lossless_check_data,
101+ uint16_t blockpos,
102+ int32_t (*sample_buffer)[MAX_CHANNELS],
103+ void *data,
104+ uint8_t *ch_assign,
105+ int8_t *output_shift,
106+ uint8_t max_matrix_channel,
107+ int is32)
108+{
109+ unsigned int i, out_ch = 0;
110+ int32_t *data_32 = data;
111+ int16_t *data_16 = data;
112+
113+ for (i = 0; i < blockpos; i++) {
114+ for (out_ch = 0; out_ch <= max_matrix_channel; out_ch++) {
115+ int mat_ch = ch_assign[out_ch];
116+ int32_t sample = sample_buffer[i][mat_ch]
117+ << output_shift[mat_ch];
118+ lossless_check_data ^= (sample & 0xffffff) << mat_ch;
119+ if (is32)
120+ *data_32++ = sample << 8;
121+ else
122+ *data_16++ = sample >> 8;
123+ }
124+ }
125+ return lossless_check_data;
126+}
127+
92128 av_cold void ff_mlpdsp_init(MLPDSPContext *c)
93129 {
94130 c->mlp_filter_channel = mlp_filter_channel;
95131 c->mlp_rematrix_channel = ff_mlp_rematrix_channel;
132+ c->mlp_select_pack_output = mlp_select_pack_output;
133+ c->mlp_pack_output = ff_mlp_pack_output;
96134 if (ARCH_ARM)
97135 ff_mlpdsp_init_arm(c);
98136 if (ARCH_X86)
libavcodec/mlpdsp.h+22−0
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #define AVCODEC_MLPDSP_H
2424
2525 #include <stdint.h>
26+#include "mlp.h"
2627
2728 void ff_mlp_rematrix_channel(int32_t *samples,
2829 const int32_t *coeffs,
@@ -36,6 +37,15 @@ void ff_mlp_rematrix_channel(int32_t *samples, · 7 unmodified lines
3637 int access_unit_size_pow2,
3738 int32_t mask);
3839
40+int32_t ff_mlp_pack_output(int32_t lossless_check_data,
41+ uint16_t blockpos,
42+ int32_t (*sample_buffer)[MAX_CHANNELS],
43+ void *data,
44+ uint8_t *ch_assign,
45+ int8_t *output_shift,
46+ uint8_t max_matrix_channel,
47+ int is32);
48+
3949 typedef struct MLPDSPContext {
4050 void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff,
4151 int firorder, int iirorder,
@@ -52,6 +62,18 @@ typedef struct MLPDSPContext { · 10 unmodified lines
5262 int matrix_noise_shift,
5363 int access_unit_size_pow2,
5464 int32_t mask);
65+ int32_t (*(*mlp_select_pack_output)(uint8_t *ch_assign,
66+ int8_t *output_shift,
67+ uint8_t max_matrix_channel,
68+ int is32))(int32_t, uint16_t, int32_t (*)[], void *, uint8_t*, int8_t *, uint8_t, int);
69+ int32_t (*mlp_pack_output)(int32_t lossless_check_data,
70+ uint16_t blockpos,
71+ int32_t (*sample_buffer)[MAX_CHANNELS],
72+ void *data,
73+ uint8_t *ch_assign,
74+ int8_t *output_shift,
75+ uint8_t max_matrix_channel,
76+ int is32);
5577 } MLPDSPContext;
5678
5779 void ff_mlpdsp_init(MLPDSPContext *c);

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