- if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
- s->fmt_conv.float_interleave(out_samples_flt, output, 256,
- s->out_channels);
- out_samples_flt += 256 * s->out_channels;
- } else {
- s->fmt_conv.float_to_int16_interleave(out_samples_s16, output, 256,
- s->out_channels);
- out_samples_s16 += 256 * s->out_channels;
+ if (err)
+ for (ch = 0; ch < s->out_channels; ch++)
+ memcpy(s->outptr[channel_map[ch]], output[ch], sizeof(**output) * AC3_BLOCK_SIZE);
+ for (ch = 0; ch < s->out_channels; ch++)
+ output[ch] = s->outptr[channel_map[ch]];
+ for (ch = 0; ch < s->out_channels; ch++)
+ s->outptr[ch] += AC3_BLOCK_SIZE;
+ }
+
+ /* keep last block for error concealment in next frame */
+ for (ch = 0; ch < s->out_channels; ch++)
+ memcpy(s->output[ch], output[ch], sizeof(**output) * AC3_BLOCK_SIZE);
+
+ /*
+ * AVMatrixEncoding
+ *
+ * Check whether the input layout is compatible, and make sure we're not
+ * downmixing (else the matrix encoding is no longer applicable).
+ */
+ matrix_encoding = AV_MATRIX_ENCODING_NONE;
+ if (s->channel_mode == AC3_CHMODE_STEREO &&
+ s->channel_mode == (s->output_mode & ~AC3_OUTPUT_LFEON)) {
+ if (s->dolby_surround_mode == AC3_DSURMOD_ON)
+ matrix_encoding = AV_MATRIX_ENCODING_DOLBY;
+ else if (s->dolby_headphone_mode == AC3_DHEADPHONMOD_ON)
+ matrix_encoding = AV_MATRIX_ENCODING_DOLBYHEADPHONE;
+ } else if (s->channel_mode >= AC3_CHMODE_2F2R &&
+ s->channel_mode == (s->output_mode & ~AC3_OUTPUT_LFEON)) {
+ switch (s->dolby_surround_ex_mode) {
+ case AC3_DSUREXMOD_ON: // EX or PLIIx
+ matrix_encoding = AV_MATRIX_ENCODING_DOLBYEX;
+ break;
+ case AC3_DSUREXMOD_PLIIZ:
+ matrix_encoding = AV_MATRIX_ENCODING_DPLIIZ;
+ break;
+ default: // not indicated or off
+ break;