[FFmpeg-devel] [PATCH] avcodec: add libdcadec decoder

James Almer jamrial at gmail.com
Tue Mar 17 17:26:52 CET 2015


On 17/03/15 1:07 PM, Hendrik Leppkes wrote:
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index cdc8aa1..48e212f 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2851,6 +2851,7 @@ typedef struct AVCodecContext {
>  #define FF_PROFILE_DTS_96_24   40
>  #define FF_PROFILE_DTS_HD_HRA  50
>  #define FF_PROFILE_DTS_HD_MA   60
> +#define FF_PROFILE_DTS_EXPRESS 70

Maybe a separate patch?

[...]

> +static int dcadec_decode_frame(AVCodecContext *avctx, void *data,
> +                               int *got_frame_ptr, AVPacket *avpkt)
> +{
> +    DCADecContext *s = avctx->priv_data;
> +    AVFrame *frame = data;
> +    int ret, i, k;
> +    int **samples, nsamples, channel_mask, sample_rate, bits_per_sample, profile;
> +
> +    if ((ret = dcadec_context_parse(s->ctx, avpkt->data, avpkt->size)) < 0) {
> +        av_log(avctx, AV_LOG_ERROR, "dcadec_context_parse() failed: %d\n", -ret);
> +        return AVERROR_UNKNOWN;

AVERROR_EXTERNAL, or maybe translate the DCADEC_E* error values.

[...]

> +    frame->nb_samples = nsamples;
> +    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
> +        return ret;
> +
> +    for (i = 0; i < avctx->channels; i++) {
> +        if (frame->format == AV_SAMPLE_FMT_S16P) {
> +            int16_t *plane = (int16_t *)frame->extended_data[i];
> +            for (k = 0; k < nsamples; k++)
> +                plane[k] = samples[i][k];
> +        } else {
> +            int32_t *plane = (int32_t *)frame->extended_data[i];
> +            int shift = 32 - bits_per_sample;
> +            for (k = 0; k < nsamples; k++)
> +                plane[k] = samples[i][k] << shift;
> +        }
> +    }

We don't have a generic decorrelate dsp?
I think there was something in fmtconvert, but libav nuked it for being unused.

[...]

> +AVCodec ff_libdcadec_decoder = {
> +    .name           = "libdcadec",
> +    .long_name      = NULL_IF_CONFIG_SMALL("dcadec DCA decoder"),
> +    .type           = AVMEDIA_TYPE_AUDIO,
> +    .id             = AV_CODEC_ID_DTS,
> +    .priv_data_size = sizeof(DCADecContext),
> +    .init           = dcadec_init,
> +    .decode         = dcadec_decode_frame,
> +    .close          = dcadec_close,
> +    .flush          = dcadec_flush,
> +    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_CHANNEL_CONF,
> +    .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_S16P,
> +                                                      AV_SAMPLE_FMT_NONE },
> +    .profiles       = NULL_IF_CONFIG_SMALL(profiles),
> +};

Missing version bump and changelog entry.



More information about the ffmpeg-devel mailing list