| 1105 | /** Write the audio data into the output buffer. */ |
| 1106 | |
| 1107 | static int output_data(MLPDecodeContext *m, unsigned int substr, |
| 1108 | AVFrame *frame, int *got_frame_ptr) |
| 1109 | { |
| 1110 | AVCodecContext *avctx = m->avctx; |
| 1111 | SubStream *s = &m->substream[substr]; |
| 1112 | unsigned int mat; |
| 1113 | unsigned int maxchan; |
| 1114 | int ret; |
| 1115 | int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); |
| 1116 | |
| 1117 | if (m->avctx->ch_layout.nb_channels != s->max_matrix_channel + 1) { |
| 1118 | av_log(m->avctx, AV_LOG_ERROR, "channel count mismatch\n"); |
| 1119 | return AVERROR_INVALIDDATA; |
| 1120 | } |
| 1121 | |
| 1122 | if (!s->blockpos) { |
| 1123 | av_log(avctx, AV_LOG_ERROR, "No samples to output.\n"); |
| 1124 | return AVERROR_INVALIDDATA; |
| 1125 | } |
| 1126 | |
| 1127 | maxchan = s->max_matrix_channel; |
| 1128 | if (!s->noise_type) { |
| 1129 | generate_2_noise_channels(m, substr); |
| 1130 | maxchan += 2; |
| 1131 | } else { |
| 1132 | fill_noise_buffer(m, substr); |
| 1133 | } |
| 1134 | |
| 1135 | /* Apply the channel matrices in turn to reconstruct the original audio |
| 1136 | * samples. */ |
| 1137 | for (mat = 0; mat < s->num_primitive_matrices; mat++) { |
| 1138 | unsigned int dest_ch = s->matrix_out_ch[mat]; |
| 1139 | m->dsp.mlp_rematrix_channel(&m->sample_buffer[0][0], |
| 1140 | s->matrix_coeff[mat], |
| 1141 | &m->bypassed_lsbs[0][mat], |
| 1142 | m->noise_buffer, |
| 1143 | s->num_primitive_matrices - mat, |
| 1144 | dest_ch, |
| 1145 | s->blockpos, |
| 1146 | maxchan, |
| 1147 | s->matrix_noise_shift[mat], |
| 1148 | m->access_unit_size_pow2, |
| 1149 | MSB_MASK(s->quant_step_size[dest_ch])); |
| 1150 | } |
| 1151 | |
| 1152 | /* get output buffer */ |
| 1153 | frame->nb_samples = s->blockpos; |
| 1154 | if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) |
| 1155 | return ret; |
| 1156 | s->lossless_check_data = m->pack_output(s->lossless_check_data, |
| 1157 | s->blockpos, |
| 1158 | m->sample_buffer, |
| 1159 | frame->data[0], |
| 1160 | s->ch_assign, |
| 1161 | s->output_shift, |
| 1162 | s->max_matrix_channel, |
| 1163 | is32); |
| 1164 |
no test coverage detected