| @@ -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 | else | 361 | 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) |