diff --git a/DOCS/interface-changes/track-list-decoder-tag.txt b/DOCS/interface-changes/track-list-decoder-tag.txt new file mode 100644 index 0000000000000..2e999af3c2bb8 --- /dev/null +++ b/DOCS/interface-changes/track-list-decoder-tag.txt @@ -0,0 +1 @@ +add `track-list/N/decoder` diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 09efd950900ab..0931ddb289163 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -3077,6 +3077,9 @@ Property list match even if the default (builtin) demuxer is used, but there is no hard guarantee. + ``track-list/N/decoder`` + If this track is being decoded, the short decoder name, + ``track-list/N/decoder-desc`` If this track is being decoded, the human-readable decoder name, diff --git a/common/av_common.c b/common/av_common.c index e5733c3848991..277601d2fc7c9 100644 --- a/common/av_common.c +++ b/common/av_common.c @@ -410,4 +410,6 @@ void mp_codec_info_from_av(const AVCodecContext *avctx, struct mp_codec_params * c->codec_profile = avcodec_profile_name(avctx->codec_id, avctx->profile); c->codec = avctx->codec_descriptor->name; c->codec_desc = avctx->codec_descriptor->long_name; + c->decoder = avctx->codec->name; + c->decoder_desc = avctx->codec->long_name; } diff --git a/demux/stheader.h b/demux/stheader.h index 4f33bbc711c03..036c8f54e7f65 100644 --- a/demux/stheader.h +++ b/demux/stheader.h @@ -78,6 +78,12 @@ struct mp_codec_params { // Corresponding codec profile const char *codec_profile; + // E.g. "h264" (usually corresponds to AVCodec.name) + const char *decoder; + + // Usually corresponds to AVCodec.long_name + const char *decoder_desc; + // Usually a FourCC, exact meaning depends on codec. unsigned int codec_tag; diff --git a/filters/f_decoder_wrapper.c b/filters/f_decoder_wrapper.c index ba867621c5c6c..7abe95116d56f 100644 --- a/filters/f_decoder_wrapper.c +++ b/filters/f_decoder_wrapper.c @@ -224,7 +224,6 @@ struct priv { // --- Protected by cache_lock. char *cur_hwdec; - char *decoder_desc; bool try_spdif; bool attached_picture; bool pts_reset; @@ -397,9 +396,6 @@ static bool reinit_decoder(struct priv *p) reset_decoder(p); p->has_broken_packet_pts = -10; // needs 10 packets to reach decision - talloc_free(p->decoder_desc); - p->decoder_desc = NULL; - const struct mp_decoder_fns *driver = NULL; struct mp_decoder_list *list = NULL; char *user_list = NULL; @@ -451,11 +447,12 @@ static bool reinit_decoder(struct priv *p) p->decoder = driver->create(p->decf, p->codec, sel->decoder); if (p->decoder) { - mp_mutex_lock(&p->cache_lock); - const char *d = sel->desc && sel->desc[0] ? sel->desc : sel->decoder; - p->decoder_desc = talloc_strdup(p, d); - MP_VERBOSE(p, "Selected codec: %s\n", p->decoder_desc); - mp_mutex_unlock(&p->cache_lock); + p->codec->decoder = talloc_strdup(p, sel->decoder); + p->codec->decoder_desc = talloc_strdup(p, sel->desc && sel->desc[0] ? sel->desc : NULL); + MP_VERBOSE(p, "Selected decoder: %s", sel->decoder); + if (p->codec->decoder_desc) + MP_VERBOSE(p, " - %s", p->codec->decoder_desc); + MP_VERBOSE(p, "\n"); break; } @@ -482,15 +479,6 @@ bool mp_decoder_wrapper_reinit(struct mp_decoder_wrapper *d) return res; } -void mp_decoder_wrapper_get_desc(struct mp_decoder_wrapper *d, - char *buf, size_t buf_size) -{ - struct priv *p = d->f->priv; - mp_mutex_lock(&p->cache_lock); - snprintf(buf, buf_size, "%s", p->decoder_desc ? p->decoder_desc : ""); - mp_mutex_unlock(&p->cache_lock); -} - void mp_decoder_wrapper_set_frame_drops(struct mp_decoder_wrapper *d, int num) { struct priv *p = d->f->priv; diff --git a/filters/f_decoder_wrapper.h b/filters/f_decoder_wrapper.h index 9f1a8b5863b4a..a352dc0c4dd88 100644 --- a/filters/f_decoder_wrapper.h +++ b/filters/f_decoder_wrapper.h @@ -43,10 +43,6 @@ struct mp_decoder_wrapper { struct mp_decoder_wrapper *mp_decoder_wrapper_create(struct mp_filter *parent, struct sh_stream *src); -// For informational purposes. -void mp_decoder_wrapper_get_desc(struct mp_decoder_wrapper *d, - char *buf, size_t buf_size); - // Legacy decoder framedrop control. void mp_decoder_wrapper_set_frame_drops(struct mp_decoder_wrapper *d, int num); int mp_decoder_wrapper_get_frames_dropped(struct mp_decoder_wrapper *d); diff --git a/player/command.c b/player/command.c index ff5ca353f0d12..4814a897fd492 100644 --- a/player/command.c +++ b/player/command.c @@ -1977,10 +1977,6 @@ static int get_track_entry(int item, int action, void *arg, void *ctx) struct mp_codec_params p = track->stream ? *track->stream->codec : (struct mp_codec_params){0}; - char decoder_desc[256] = {0}; - if (track->dec) - mp_decoder_wrapper_get_desc(track->dec, decoder_desc, sizeof(decoder_desc)); - bool has_rg = track->stream && track->stream->codec->replaygain_data; struct replaygain_data rg = has_rg ? *track->stream->codec->replaygain_data : (struct replaygain_data){0}; @@ -2029,8 +2025,10 @@ static int get_track_entry(int item, int action, void *arg, void *ctx) .unavailable = !track->hls_bitrate}, {"program-id", SUB_PROP_INT(track->program_id), .unavailable = track->program_id < 0}, - {"decoder-desc", SUB_PROP_STR(decoder_desc), - .unavailable = !decoder_desc[0]}, + {"decoder", SUB_PROP_STR(p.decoder), + .unavailable = !p.decoder}, + {"decoder-desc", SUB_PROP_STR(p.decoder_desc), + .unavailable = !p.decoder_desc}, {"codec", SUB_PROP_STR(p.codec), .unavailable = !p.codec}, {"codec-desc", SUB_PROP_STR(p.codec_desc),