diff options
Diffstat (limited to 'audio/decode/ad_spdif.c')
-rw-r--r-- | audio/decode/ad_spdif.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index 98a53f3ca0..3e77c4a302 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -45,6 +45,7 @@ struct spdifContext { struct mp_log *log; + struct mp_codec_params *codec; enum AVCodecID codec_id; AVFormatContext *lavf_ctx; AVPacket *avpkt; @@ -117,15 +118,17 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt, uint8_t *d = NULL; int s = 0; - av_parser_parse2(parser, ctx, &d, &s, pkt->data, pkt->size, 0, 0, 0); - *out_profile = profile = ctx->profile; - *out_rate = ctx->sample_rate; + if (av_parser_parse2(parser, ctx, &d, &s, pkt->data, pkt->size, 0, 0, 0) > 0) { + *out_profile = profile = ctx->profile; + *out_rate = ctx->sample_rate; + spdif_ctx->codec->codec_profile = avcodec_profile_name(spdif_ctx->codec_id, profile); + } avcodec_free_context(&ctx); av_parser_close(parser); } - if (profile != AV_PROFILE_UNKNOWN || spdif_ctx->codec_id != AV_CODEC_ID_DTS) + if (profile != AV_PROFILE_UNKNOWN || spdif_ctx->codec_id == AV_CODEC_ID_AC3) return; const AVCodec *codec = avcodec_find_decoder(spdif_ctx->codec_id); @@ -151,6 +154,13 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt, *out_profile = profile = ctx->profile; *out_rate = ctx->sample_rate; + struct mp_codec_params *c = spdif_ctx->codec; + c->codec_profile = av_get_profile_name(ctx->codec, ctx->profile); + if (!c->codec_profile) + c->codec_profile = avcodec_profile_name(ctx->codec_id, ctx->profile); + c->codec = ctx->codec_descriptor->name; + c->codec_desc = ctx->codec_descriptor->long_name; + done: av_frame_free(&frame); avcodec_free_context(&ctx); @@ -181,7 +191,7 @@ static int init_filter(struct mp_filter *da) goto fail; void *buffer = av_mallocz(OUTBUF_SIZE); - MP_HANDLE_OOM(buffer); + MP_HANDLE_OOM(buffer); lavf_ctx->pb = avio_alloc_context(buffer, OUTBUF_SIZE, 1, spdif_ctx, NULL, write_packet, NULL); if (!lavf_ctx->pb) { @@ -321,6 +331,7 @@ static void ad_spdif_process(struct mp_filter *da) if (init_filter(da) < 0) goto done; assert(spdif_ctx->avpkt); + assert(spdif_ctx->lavf_ctx); } spdif_ctx->out_buffer_len = 0; @@ -432,6 +443,7 @@ static struct mp_decoder *create(struct mp_filter *parent, struct spdifContext *spdif_ctx = da->priv; spdif_ctx->log = da->log; + spdif_ctx->codec = codec; spdif_ctx->pool = mp_aframe_pool_create(spdif_ctx); spdif_ctx->public.f = da; @@ -446,6 +458,10 @@ static struct mp_decoder *create(struct mp_filter *parent, return NULL; } + const AVCodecDescriptor *desc = avcodec_descriptor_get(spdif_ctx->codec_id); + if (desc) + codec->codec_desc = desc->long_name; + return &spdif_ctx->public; } |