From 0e5f7b48d277887591cf7fa7c1bc37a34db13530 Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 6 Jan 2022 08:32:46 +0100 Subject: mp_image: add dolbyvision metadata Co-authored-by: Niklas Haas --- video/mp_image.c | 10 ++++++++++ video/mp_image.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/video/mp_image.c b/video/mp_image.c index 91755c3273..11539eb7c7 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -204,6 +204,7 @@ static void mp_image_destructor(void *ptr) av_buffer_unref(&mpi->hwctx); av_buffer_unref(&mpi->icc_profile); av_buffer_unref(&mpi->a53_cc); + av_buffer_unref(&mpi->dovi); for (int n = 0; n < mpi->num_ff_side_data; n++) av_buffer_unref(&mpi->ff_side_data[n].buf); talloc_free(mpi->ff_side_data); @@ -340,6 +341,7 @@ struct mp_image *mp_image_new_ref(struct mp_image *img) ref_buffer(&ok, &new->hwctx); ref_buffer(&ok, &new->icc_profile); ref_buffer(&ok, &new->a53_cc); + ref_buffer(&ok, &new->dovi); new->ff_side_data = talloc_memdup(NULL, new->ff_side_data, new->num_ff_side_data * sizeof(new->ff_side_data[0])); @@ -381,6 +383,7 @@ struct mp_image *mp_image_new_dummy_ref(struct mp_image *img) new->hwctx = NULL; new->icc_profile = NULL; new->a53_cc = NULL; + new->dovi = NULL; new->num_ff_side_data = 0; new->ff_side_data = NULL; return new; @@ -530,6 +533,7 @@ void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src) } } assign_bufref(&dst->icc_profile, src->icc_profile); + assign_bufref(&dst->dovi, src->dovi); assign_bufref(&dst->a53_cc, src->a53_cc); } @@ -1004,6 +1008,12 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src) if (sd) dst->a53_cc = sd->buf; +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 16, 100) + sd = av_frame_get_side_data(src, AV_FRAME_DATA_DOVI_METADATA); + if (sd) + dst->dovi = sd->buf; +#endif + for (int n = 0; n < src->nb_side_data; n++) { sd = src->side_data[n]; struct mp_ff_side_data mpsd = { diff --git a/video/mp_image.h b/video/mp_image.h index dd82251464..17c0eae53f 100644 --- a/video/mp_image.h +++ b/video/mp_image.h @@ -108,6 +108,8 @@ typedef struct mp_image { struct AVBufferRef *icc_profile; // Closed captions packet, if any (only after decoder) struct AVBufferRef *a53_cc; + // Dolby Vision metadata, if any + struct AVBufferRef *dovi; // Other side data we don't care about. struct mp_ff_side_data *ff_side_data; int num_ff_side_data; -- cgit v1.2.3