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
360 m->avctx->sample_fmt = AV_SAMPLE_FMT_S32;360 m->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
361 else361 else
362 m->avctx->sample_fmt = AV_SAMPLE_FMT_S16;362 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);
363 367
364 m->params_valid = 1;368 m->params_valid = 1;
365 for (substr = 0; substr < MAX_SUBSTREAMS; substr++)369 for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
@@ -588,6 +592,10 @@ FF_ENABLE_DEPRECATION_WARNINGS · 222 unmodified lines
588 if (substr == m->max_decoded_substream) {592 if (substr == m->max_decoded_substream) {
589 m->avctx->channels = s->max_matrix_channel + 1;593 m->avctx->channels = s->max_matrix_channel + 1;
590 m->avctx->channel_layout = s->ch_layout;594 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);
591 }599 }
592 600
593 return 0;601 return 0;
@@ -818,9 +826,15 @@ static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, · 224 unmodified lines
818 return ret;826 return ret;
819 827
820 if (s->param_presence_flags & PARAM_OUTSHIFT)828 if (s->param_presence_flags & PARAM_OUTSHIFT)
821 if (get_bits1(gbp))829 if (get_bits1(gbp)) {
822 for (ch = 0; ch <= s->max_matrix_channel; ch++)830 for (ch = 0; ch <= s->max_matrix_channel; ch++)
823 s->output_shift[ch] = get_sbits(gbp, 4);831 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 }
824 838
825 if (s->param_presence_flags & PARAM_QUANTSTEP)839 if (s->param_presence_flags & PARAM_QUANTSTEP)
826 if (get_bits1(gbp))840 if (get_bits1(gbp))
@@ -1019,9 +1033,6 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, · 192 unmodified lines
1019{1033{
1020 AVCodecContext *avctx = m->avctx;1034 AVCodecContext *avctx = m->avctx;
1021 SubStream *s = &m->substream[substr];1035 SubStream *s = &m->substream[substr];
1022 unsigned int i, out_ch = 0;
1023 int32_t *data_32;
1024 int16_t *data_16;
1025 int ret;1036 int ret;
1026 int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);1037 int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
1027 1038
@@ -1041,19 +1052,14 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, · 13 unmodified lines
1041 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");1052 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1042 return ret;1053 return ret;
1043 }1054 }
1044 data_32 = (int32_t *)frame->data[0];1055 s->lossless_check_data = m->dsp.mlp_pack_output(s->lossless_check_data,
1045 data_16 = (int16_t *)frame->data[0];1056 s->blockpos,
1046 1057 m->sample_buffer,
1047 for (i = 0; i < s->blockpos; i++) {1058 frame->data[0],
1048 for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) {1059 s->ch_assign,
1049 int mat_ch = s->ch_assign[out_ch];1060 s->output_shift,
1050 int32_t sample = m->sample_buffer[i][mat_ch]1061 s->max_matrix_channel,
1051 << s->output_shift[mat_ch];1062 is32);
1052 s->lossless_check_data ^= (sample & 0xffffff) << mat_ch;
1053 if (is32) *data_32++ = sample << 8;
1054 else *data_16++ = sample >> 8;
1055 }
1056 }
1057 1063
1058 /* Update matrix encoding side data */1064 /* Update matrix encoding side data */
1059 if ((ret = ff_side_data_update_matrix_encoding(frame, s->matrix_encoding)) < 0)1065 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
89 }89 }
90}90}
91 91
92static 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
100int32_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
92av_cold void ff_mlpdsp_init(MLPDSPContext *c)128av_cold void ff_mlpdsp_init(MLPDSPContext *c)
93{129{
94 c->mlp_filter_channel = mlp_filter_channel;130 c->mlp_filter_channel = mlp_filter_channel;
95 c->mlp_rematrix_channel = ff_mlp_rematrix_channel;131 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;
96 if (ARCH_ARM)134 if (ARCH_ARM)
97 ff_mlpdsp_init_arm(c);135 ff_mlpdsp_init_arm(c);
98 if (ARCH_X86)136 if (ARCH_X86)
libavcodec/mlpdsp.h+22−0
@@ -23,6 +23,7 @@ · 22 unmodified lines
23#define AVCODEC_MLPDSP_H23#define AVCODEC_MLPDSP_H
24 24
25#include <stdint.h>25#include <stdint.h>
26#include "mlp.h"
26 27
27void ff_mlp_rematrix_channel(int32_t *samples,28void ff_mlp_rematrix_channel(int32_t *samples,
28 const int32_t *coeffs,29 const int32_t *coeffs,
@@ -36,6 +37,15 @@ void ff_mlp_rematrix_channel(int32_t *samples, · 7 unmodified lines
36 int access_unit_size_pow2,37 int access_unit_size_pow2,
37 int32_t mask);38 int32_t mask);
38 39
40int32_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
39typedef struct MLPDSPContext {49typedef struct MLPDSPContext {
40 void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff,50 void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff,
41 int firorder, int iirorder,51 int firorder, int iirorder,
@@ -52,6 +62,18 @@ typedef struct MLPDSPContext { · 10 unmodified lines
52 int matrix_noise_shift,62 int matrix_noise_shift,
53 int access_unit_size_pow2,63 int access_unit_size_pow2,
54 int32_t mask);64 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);
55} MLPDSPContext;77} MLPDSPContext;
56 78
57void ff_mlpdsp_init(MLPDSPContext *c);79void 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