|
|
|
@ -67,7 +67,7 @@ typedef struct SubStream { |
|
|
|
|
/// For each channel output by the matrix, the output channel to map it to
|
|
|
|
|
uint8_t ch_assign[MAX_CHANNELS]; |
|
|
|
|
/// The channel layout for this substream
|
|
|
|
|
uint64_t ch_layout; |
|
|
|
|
uint64_t mask; |
|
|
|
|
/// The matrix encoding mode for this substream
|
|
|
|
|
enum AVMatrixEncoding matrix_encoding; |
|
|
|
|
|
|
|
|
@ -383,17 +383,17 @@ static int read_major_sync(MLPDecodeContext *m, BitstreamContext *bc) |
|
|
|
|
* major sync. */ |
|
|
|
|
if (m->avctx->codec_id == AV_CODEC_ID_MLP) { |
|
|
|
|
if ((substr = (mh.num_substreams > 1))) |
|
|
|
|
m->substream[0].ch_layout = AV_CH_LAYOUT_STEREO; |
|
|
|
|
m->substream[substr].ch_layout = mh.channel_layout_mlp; |
|
|
|
|
m->substream[0].mask = AV_CH_LAYOUT_STEREO; |
|
|
|
|
m->substream[substr].mask = mh.channel_layout_mlp; |
|
|
|
|
} else { |
|
|
|
|
if ((substr = (mh.num_substreams > 1))) |
|
|
|
|
m->substream[0].ch_layout = AV_CH_LAYOUT_STEREO; |
|
|
|
|
m->substream[0].mask = AV_CH_LAYOUT_STEREO; |
|
|
|
|
if (mh.num_substreams > 2) |
|
|
|
|
if (mh.channel_layout_thd_stream2) |
|
|
|
|
m->substream[2].ch_layout = mh.channel_layout_thd_stream2; |
|
|
|
|
m->substream[2].mask = mh.channel_layout_thd_stream2; |
|
|
|
|
else |
|
|
|
|
m->substream[2].ch_layout = mh.channel_layout_thd_stream1; |
|
|
|
|
m->substream[substr].ch_layout = mh.channel_layout_thd_stream1; |
|
|
|
|
m->substream[2].mask = mh.channel_layout_thd_stream1; |
|
|
|
|
m->substream[substr].mask = mh.channel_layout_thd_stream1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Parse the TrueHD decoder channel modifiers and set each substream's
|
|
|
|
@ -511,12 +511,12 @@ static int read_restart_header(MLPDecodeContext *m, BitstreamContext *bc, |
|
|
|
|
s->max_channel = max_channel; |
|
|
|
|
s->max_matrix_channel = max_matrix_channel; |
|
|
|
|
|
|
|
|
|
if (m->avctx->request_channel_layout && (s->ch_layout & m->avctx->request_channel_layout) == |
|
|
|
|
if (m->avctx->request_channel_layout && (s->mask & m->avctx->request_channel_layout) == |
|
|
|
|
m->avctx->request_channel_layout && m->max_decoded_substream > substr) { |
|
|
|
|
av_log(m->avctx, AV_LOG_DEBUG, |
|
|
|
|
"Extracting %d-channel downmix (0x%"PRIx64") from substream %d. " |
|
|
|
|
"Further substreams will be skipped.\n", |
|
|
|
|
s->max_channel + 1, s->ch_layout, substr); |
|
|
|
|
s->max_channel + 1, s->mask, substr); |
|
|
|
|
m->max_decoded_substream = substr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -543,9 +543,9 @@ static int read_restart_header(MLPDecodeContext *m, BitstreamContext *bc, |
|
|
|
|
for (ch = 0; ch <= s->max_matrix_channel; ch++) { |
|
|
|
|
int ch_assign = bitstream_read(bc, 6); |
|
|
|
|
if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD) { |
|
|
|
|
uint64_t channel = thd_channel_layout_extract_channel(s->ch_layout, |
|
|
|
|
uint64_t channel = thd_channel_layout_extract_channel(s->mask, |
|
|
|
|
ch_assign); |
|
|
|
|
ch_assign = av_get_channel_layout_channel_index(s->ch_layout, |
|
|
|
|
ch_assign = av_get_channel_layout_channel_index(s->mask, |
|
|
|
|
channel); |
|
|
|
|
} |
|
|
|
|
if (ch_assign < 0 || ch_assign > s->max_matrix_channel) { |
|
|
|
@ -587,7 +587,7 @@ static int read_restart_header(MLPDecodeContext *m, BitstreamContext *bc, |
|
|
|
|
|
|
|
|
|
if (substr == m->max_decoded_substream) { |
|
|
|
|
m->avctx->channels = s->max_matrix_channel + 1; |
|
|
|
|
m->avctx->channel_layout = s->ch_layout; |
|
|
|
|
m->avctx->channel_layout = s->mask; |
|
|
|
|
m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign, |
|
|
|
|
s->output_shift, |
|
|
|
|
s->max_matrix_channel, |
|
|
|
|