[FFmpeg-devel] [PATCH] avcodec/libdcadec: export matrix encoding side data
James Almer
jamrial at gmail.com
Tue Jul 7 00:38:28 CEST 2015
On 06/07/15 7:02 PM, Hendrik Leppkes wrote:
> On Mon, Jul 6, 2015 at 10:25 PM, James Almer <jamrial at gmail.com> wrote:
>> Signed-off-by: James Almer <jamrial at gmail.com>
>> ---
>> libavcodec/libdcadec.c | 21 +++++++++++++++++++++
>> 1 file changed, 21 insertions(+)
>>
>> diff --git a/libavcodec/libdcadec.c b/libavcodec/libdcadec.c
>> index 890d270..9d4b9e8 100644
>> --- a/libavcodec/libdcadec.c
>> +++ b/libavcodec/libdcadec.c
>> @@ -41,6 +41,7 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data,
>> {
>> DCADecContext *s = avctx->priv_data;
>> AVFrame *frame = data;
>> + struct dcadec_exss_info *exss;
>> int ret, i, k;
>> int **samples, nsamples, channel_mask, sample_rate, bits_per_sample, profile;
>> uint32_t mrk;
>> @@ -127,6 +128,26 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data,
>> } else
>> avctx->bit_rate = 0;
>>
>> + if (exss = dcadec_context_get_exss_info(s->ctx)) {
>> + enum AVMatrixEncoding matrix_encoding;
>> +
>> + switch(exss->matrix_encoding) {
>> + case DCADEC_MATRIX_ENCODING_SURROUND:
>> + matrix_encoding = AV_MATRIX_ENCODING_DOLBY;
>> + break;
>> + case DCADEC_MATRIX_ENCODING_HEADPHONE:
>> + matrix_encoding = AV_MATRIX_ENCODING_DOLBYHEADPHONE;
>> + break;
>> + default:
>> + matrix_encoding = AV_MATRIX_ENCODING_NONE;
>> + break;
>> + }
>
> I think Dolby would disagree. ;)
The native dca decoder sets AV_MATRIX_ENCODING_DOLBY for the same type of frames this
would, stating they are the equivalent. So does mlpdec.
>
> Maybe we should just not set anything when the expected value is NONE?
> Not that it really matters. but sending an "empty" value all the time
> may not be required?
I'm replicating the native dca decoder behavior with this. If you for example use the
ashowinfo filter, it will output "side data - matrix encoding: none".
Not setting anything in that case would save us a ff_side_data_update_matrix_encoding
call per frame, though, so i guess I'll do just that.
Both encodings are apparently guaranteed to be set only with stereo streams, so maybe
i should also check for channel amount and skip the entire branch? 99% of streams out
there are multichannel after all.
>
> - Hendrik
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list