From: "Jan Ekström" <jeebjp@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v6 00/13] encoder AVCodecContext configuration side data Date: Wed, 28 Feb 2024 00:12:03 +0200 Message-ID: <20240227221226.1377758-1-jeebjp@gmail.com> (raw) Differences to v5: 1. rebased on top of current master 2. as requested by James, there is no longer a set struct, but instead there now is an additional **-based list as well as a separate counter. Comparison URL (mostly configure and wrappers, avutil/frame.c): https://github.com/jeeb/ffmpeg/compare/avcodec_cll_mdcv_side_data_v5..avcodec_cll_mdcv_side_data_v6 This patch set I've now been working for a while since I felt like it was weird we couldn't pass through information such as static HDR metadata to encoders from decoded input. This initial version adds the necessary framework, as well as adds static HDR metadata support for libsvtav1, libx264 as well as libx265 wrappers. An alternative to this would be to make encoders only properly initialize when they receive the first AVFrame, but that seems to be a bigger, nastier change than introducing an AVFrameSideDataSet in avctx as everything seems to presume that extradata etc are available after opening the encoder. Note: Any opinions on whether FFCodec or AVCodec should have handled_side_data list, so that if format specific generic logic is added, it could be checked whether the codec itself handles this side data? This could also be utilized to list handled side data from f.ex. `ffmpeg -h encoder=libsvtav1`. Jan Jan Ekström (13): avutil/frame: split side data list wiping out to non-AVFrame function avutil/frame: add helper for freeing arrays of side data avutil/frame: split side_data_from_buf to base and AVFrame func avutil/frame: split side data removal out to non-AVFrame function avutil/frame: add helper for adding side data to array avutil/frame: add helper for adding existing side data to set avutil/frame: add helper for getting side data from array avcodec: add frame side data array to AVCodecContext avcodec: add helper for configuring AVCodecContext's frame side data ffmpeg: pass first video AVFrame's side data to encoder avcodec/libsvtav1: add support for writing out CLL and MDCV avcodec/libx264: add support for writing out CLL and MDCV avcodec/libx265: add support for writing out CLL and MDCV configure | 2 + fftools/ffmpeg_enc.c | 10 ++ libavcodec/avcodec.c | 30 ++++++ libavcodec/avcodec.h | 28 ++++++ libavcodec/libsvtav1.c | 68 +++++++++++++ libavcodec/libx264.c | 79 ++++++++++++++++ libavcodec/libx265.c | 88 +++++++++++++++++ libavcodec/options.c | 2 + libavutil/Makefile | 1 + libavutil/frame.c | 163 ++++++++++++++++++++++++++------ libavutil/frame.h | 65 +++++++++++++ libavutil/tests/side_data_set.c | 103 ++++++++++++++++++++ tests/fate/enc_external.mak | 15 +++ tests/fate/libavutil.mak | 4 + tests/ref/fate/libsvtav1-hdr10 | 14 +++ tests/ref/fate/libx264-hdr10 | 15 +++ tests/ref/fate/libx265-hdr10 | 16 ++++ tests/ref/fate/side_data_set | 14 +++ 18 files changed, 687 insertions(+), 30 deletions(-) create mode 100644 libavutil/tests/side_data_set.c create mode 100644 tests/ref/fate/libsvtav1-hdr10 create mode 100644 tests/ref/fate/libx264-hdr10 create mode 100644 tests/ref/fate/libx265-hdr10 create mode 100644 tests/ref/fate/side_data_set Full diff based on the same base hash for v5->v6: diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 1eb2cca4ed..e39ba05b3b 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -247,10 +247,7 @@ int enc_open(void *opaque, const AVFrame *frame) ret = avcodec_configure_side_data( enc_ctx, - &(const AVFrameSideDataSet){ - .sd = frame->side_data, - .nb_sd = frame->nb_side_data - }, + (const AVFrameSideData **)frame->side_data, frame->nb_side_data, AV_FRAME_SIDE_DATA_SET_FLAG_NO_DUPLICATES); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "failed to configure video encoder: %s!\n", diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 923fac2c26..d3ec41b280 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -722,26 +722,28 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr } int avcodec_configure_side_data(AVCodecContext *avctx, - const AVFrameSideDataSet *set, + const AVFrameSideData **sd, const int nb_sd, unsigned int flags) { if (!avctx) return AVERROR(EINVAL); - if (!set) { - av_frame_side_data_set_uninit(&avctx->frame_sd_set); + if (!sd) { + av_frame_side_data_free( + &avctx->frame_side_data, &avctx->nb_frame_side_data); return 0; } - if (set->nb_sd > 0 && set->nb_sd == avctx->frame_sd_set.nb_sd && - set->sd == avctx->frame_sd_set.sd) + if (nb_sd > 0 && nb_sd == avctx->nb_frame_side_data && + sd == (const AVFrameSideData **)avctx->frame_side_data) return AVERROR(EINVAL); - for (int i = 0; i < set->nb_sd; i++) { - int ret = av_frame_side_data_set_entry_from_sd( - &avctx->frame_sd_set, set->sd[i], flags); + for (int i = 0; i < nb_sd; i++) { + int ret = av_frame_side_data_from_sd( + &avctx->frame_side_data, &avctx->nb_frame_side_data, sd[i], flags); if (ret < 0) { - av_frame_side_data_set_uninit(&avctx->frame_sd_set); + av_frame_side_data_free( + &avctx->frame_side_data, &avctx->nb_frame_side_data); return ret; } } diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index e9ed88330c..3b5ca9c0ef 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2126,7 +2126,8 @@ typedef struct AVCodecContext { * - encoding: set by user * - decoding: unused */ - AVFrameSideDataSet frame_sd_set; + AVFrameSideData **frame_side_data; + int nb_frame_side_data; } AVCodecContext; /** @@ -3169,8 +3170,9 @@ int avcodec_is_open(AVCodecContext *s); * whole side data set. * * @param avctx context to which the side data should be added - * @param set a set from which the side data should be added from. - * if null, clears out the side data for this context. + * @param sd array of side data to use as input. + * if null, clears out the side data for this context. + * @param nb_sd integer containing the number of entries in the array. * @param flags Some combination of AV_FRAME_SIDE_DATA_SET_FLAG_* flags, or 0. * * @return negative error code on failure, >=0 on success. @@ -3178,9 +3180,8 @@ int avcodec_is_open(AVCodecContext *s); * @see av_frame_side_data_set_new_entry regarding the flags. */ int avcodec_configure_side_data(AVCodecContext *avctx, - const AVFrameSideDataSet *set, + const AVFrameSideData **sd, const int nb_sd, unsigned int flags); - /** * @} */ diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index a108f46207..76f000fd64 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -189,13 +189,14 @@ static void handle_mdcv(struct EbSvtAv1MasteringDisplayInfo *dst, static void handle_side_data(AVCodecContext *avctx, EbSvtAv1EncConfiguration *param) { - const AVFrameSideDataSet set = avctx->frame_sd_set; const AVFrameSideData *cll_sd = - av_frame_side_data_set_get_entry( - set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + av_frame_side_data_get( + (const AVFrameSideData **)avctx->frame_side_data, + avctx->nb_frame_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); const AVFrameSideData *mdcv_sd = - av_frame_side_data_set_get_entry( - set, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + av_frame_side_data_get( + (const AVFrameSideData **)avctx->frame_side_data, + avctx->nb_frame_side_data, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); if (cll_sd) { const AVContentLightMetadata *cll = diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 683c0d1709..effdcfdb37 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -923,13 +923,14 @@ static void handle_mdcv(x264_param_t *params, static void handle_side_data(AVCodecContext *avctx, x264_param_t *params) { #if CONFIG_LIBX264_HDR10 - const AVFrameSideDataSet set = avctx->frame_sd_set; const AVFrameSideData *cll_sd = - av_frame_side_data_set_get_entry( - set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + av_frame_side_data_get( + (const AVFrameSideData **)avctx->frame_side_data, + avctx->nb_frame_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); const AVFrameSideData *mdcv_sd = - av_frame_side_data_set_get_entry( - set, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + av_frame_side_data_get( + (const AVFrameSideData **)avctx->frame_side_data, + avctx->nb_frame_side_data, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); if (cll_sd) { const AVContentLightMetadata *cll = diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 96e50a6223..8d366f51ab 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -232,13 +232,14 @@ end: static int handle_side_data(AVCodecContext *avctx, const x265_api *api, x265_param *params) { - const AVFrameSideDataSet set = avctx->frame_sd_set; const AVFrameSideData *cll_sd = - av_frame_side_data_set_get_entry( - set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + av_frame_side_data_get( + (const AVFrameSideData **)avctx->frame_side_data, + avctx->nb_frame_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); const AVFrameSideData *mdcv_sd = - av_frame_side_data_set_get_entry( - set, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + av_frame_side_data_get( + (const AVFrameSideData **)avctx->frame_side_data, + avctx->nb_frame_side_data, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); if (cll_sd) { const AVContentLightMetadata *cll = diff --git a/libavcodec/options.c b/libavcodec/options.c index 8e16d598a7..7e39b49b7e 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -181,7 +181,8 @@ void avcodec_free_context(AVCodecContext **pavctx) av_freep(&avctx->inter_matrix); av_freep(&avctx->rc_override); av_channel_layout_uninit(&avctx->ch_layout); - av_frame_side_data_set_uninit(&avctx->frame_sd_set); + av_frame_side_data_free( + &avctx->frame_side_data, &avctx->nb_frame_side_data); av_freep(pavctx); } diff --git a/libavutil/frame.c b/libavutil/frame.c index e4004daa4b..e7679bf34d 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -90,9 +90,9 @@ static void frame_side_data_wipe(AVFrame *frame) wipe_side_data(&frame->side_data, &frame->nb_side_data); } -void av_frame_side_data_set_uninit(AVFrameSideDataSet *set) +void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd) { - wipe_side_data(&set->sd, &set->nb_sd); + wipe_side_data(sd, nb_sd); } static void remove_side_data(AVFrameSideData ***sd, int *nb_side_data, @@ -110,19 +110,18 @@ static void remove_side_data(AVFrameSideData ***sd, int *nb_side_data, } } -static void remove_side_data_by_entry(AVFrameSideData ***sd, - int *nb_side_data, +static void remove_side_data_by_entry(AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *target) { - for (int i = *nb_side_data - 1; i >= 0; i--) { + for (int i = *nb_sd - 1; i >= 0; i--) { AVFrameSideData *entry = ((*sd)[i]); if (entry != target) continue; free_side_data(&entry); - ((*sd)[i]) = ((*sd)[*nb_side_data - 1]); - (*nb_side_data)--; + ((*sd)[i]) = ((*sd)[*nb_sd - 1]); + (*nb_sd)--; return; } @@ -820,7 +819,8 @@ FF_ENABLE_DEPRECATION_WARNINGS return NULL; } -static AVFrameSideData *add_side_data_to_set_from_buf(AVFrameSideDataSet *set, +static AVFrameSideData *add_side_data_to_set_from_buf(AVFrameSideData ***sd, + int *nb_sd, enum AVFrameSideDataType type, AVBufferRef *buf) { @@ -829,13 +829,13 @@ static AVFrameSideData *add_side_data_to_set_from_buf(AVFrameSideDataSet *set, if (!buf) return NULL; - if (set->nb_sd > INT_MAX / sizeof(*set->sd) - 1) + if (*nb_sd > INT_MAX / sizeof(*sd) - 1) return NULL; - tmp = av_realloc(set->sd, (set->nb_sd + 1) * sizeof(*set->sd)); + tmp = av_realloc(*sd, (*nb_sd + 1) * sizeof(*sd)); if (!tmp) return NULL; - set->sd = tmp; + *sd = tmp; ret = av_mallocz(sizeof(*ret)); if (!ret) @@ -846,7 +846,7 @@ static AVFrameSideData *add_side_data_to_set_from_buf(AVFrameSideDataSet *set, ret->size = buf->size; ret->type = type; - set->sd[set->nb_sd++] = ret; + (*sd)[(*nb_sd)++] = ret; return ret; } @@ -855,16 +855,9 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf) { - AVFrameSideDataSet set = { - .sd = frame->side_data, - .nb_sd = frame->nb_side_data, - }; - AVFrameSideData *ret = add_side_data_to_set_from_buf(&set, type, buf); - - frame->side_data = set.sd; - frame->nb_side_data = set.nb_sd; - - return ret; + return + add_side_data_to_set_from_buf(&frame->side_data, &frame->nb_side_data, + type, buf); } AVFrameSideData *av_frame_new_side_data(AVFrame *frame, @@ -879,29 +872,28 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame, return ret; } -AVFrameSideData *av_frame_side_data_set_new_entry(AVFrameSideDataSet *set, - enum AVFrameSideDataType type, - size_t size, - unsigned int flags) +AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type, + size_t size, unsigned int flags) { AVBufferRef *buf = av_buffer_alloc(size); AVFrameSideData *ret = NULL; if (flags & AV_FRAME_SIDE_DATA_SET_FLAG_NO_DUPLICATES) - remove_side_data(&set->sd, &set->nb_sd, type); + remove_side_data(sd, nb_sd, type); - ret = add_side_data_to_set_from_buf(set, type, buf); + ret = add_side_data_to_set_from_buf(sd, nb_sd, type, buf); if (!ret) av_buffer_unref(&buf); return ret; } -int av_frame_side_data_set_entry_from_sd(AVFrameSideDataSet *dst, - const AVFrameSideData *src, - unsigned int flags) +int av_frame_side_data_from_sd(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *src, + unsigned int flags) { - if (!dst || !src) + if (!sd || !src || !nb_sd || (*nb_sd && !*sd)) return AVERROR(EINVAL); { @@ -909,9 +901,9 @@ int av_frame_side_data_set_entry_from_sd(AVFrameSideDataSet *dst, AVFrameSideData *sd_dst = NULL; if (flags & AV_FRAME_SIDE_DATA_SET_FLAG_NO_DUPLICATES) - remove_side_data(&dst->sd, &dst->nb_sd, src->type); + remove_side_data(sd, nb_sd, src->type); - sd_dst = add_side_data_to_set_from_buf(dst, src->type, buf); + sd_dst = add_side_data_to_set_from_buf(sd, nb_sd, src->type, buf); if (!sd_dst) { av_buffer_unref(&buf); return AVERROR(ENOMEM); @@ -920,7 +912,7 @@ int av_frame_side_data_set_entry_from_sd(AVFrameSideDataSet *dst, { int ret = av_dict_copy(&sd_dst->metadata, src->metadata, 0); if (ret < 0) { - remove_side_data_by_entry(&dst->sd, &dst->nb_sd, sd_dst); + remove_side_data_by_entry(sd, nb_sd, sd_dst); return ret; } } @@ -929,12 +921,13 @@ int av_frame_side_data_set_entry_from_sd(AVFrameSideDataSet *dst, } } -AVFrameSideData *av_frame_side_data_set_get_entry(const AVFrameSideDataSet set, - enum AVFrameSideDataType type) +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + enum AVFrameSideDataType type) { - for (int i = 0; i < set.nb_sd; i++) { - if (set.sd[i]->type == type) - return set.sd[i]; + for (int i = 0; i < nb_sd; i++) { + if (sd[i]->type == type) + return sd[i]; } return NULL; } @@ -942,11 +935,8 @@ AVFrameSideData *av_frame_side_data_set_get_entry(const AVFrameSideDataSet set, AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type) { - return av_frame_side_data_set_get_entry( - (const AVFrameSideDataSet){ - .sd = frame->side_data, - .nb_sd = frame->nb_side_data - }, + return (AVFrameSideData *)av_frame_side_data_get( + (const AVFrameSideData **)frame->side_data, frame->nb_side_data, type ); } diff --git a/libavutil/frame.h b/libavutil/frame.h index e8517bf6ad..751f7a67d6 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -251,14 +251,6 @@ typedef struct AVFrameSideData { AVBufferRef *buf; } AVFrameSideData; -/** - * Structure to hold a set of AVFrameSideData - */ -typedef struct AVFrameSideDataSet { - AVFrameSideData **sd; - int nb_sd; -} AVFrameSideDataSet; - /** * Structure describing a single Region Of Interest. * @@ -1061,18 +1053,23 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type); * Free all side data entries and their contents, then zeroes out the * struct values. * - * @param set the set which should be uninitialized + * @param sd pointer to array of side data to free. Will be set to NULL + * upon return. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. Will be set to 0 upon return. */ -void av_frame_side_data_set_uninit(AVFrameSideDataSet *set); +void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); #define AV_FRAME_SIDE_DATA_SET_FLAG_NO_DUPLICATES (1 << 0) /** * Add a new side data entry to a set. * - * @param set a set to which the side data should be added - * @param type type of the added side data - * @param size size of the side data + * @param sd pointer to array of side data to which to add another entry. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param type type of the added side data + * @param size size of the side data * @param flags Some combination of AV_FRAME_SIDE_DATA_SET_FLAG_* flags, or 0. * * @return newly added side data on success, NULL on error. In case of @@ -1080,16 +1077,18 @@ void av_frame_side_data_set_uninit(AVFrameSideDataSet *set); * of matching AVFrameSideDataType will be removed before the * addition is attempted. */ -AVFrameSideData *av_frame_side_data_set_new_entry(AVFrameSideDataSet *set, - enum AVFrameSideDataType type, - size_t size, - unsigned int flags); +AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type, + size_t size, unsigned int flags); /** - * Add a new side data entry to a set based on existing side data. + * Add a new side data entry to a set based on existing side data, taking + * a reference towards the contained AVBufferRef. * - * @param dst a set to which the side data should be added - * @param src side data which should be added to the set + * @param sd pointer to array of side data to which to add another entry. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param src side data which should be added to the set * @param flags Some combination of AV_FRAME_SIDE_DATA_SET_FLAG_* flags, or 0. * * @return negative error code on failure, >=0 on success. In case of @@ -1097,21 +1096,23 @@ AVFrameSideData *av_frame_side_data_set_new_entry(AVFrameSideDataSet *set, * of matching AVFrameSideDataType will be removed before the * addition is attempted. */ -int av_frame_side_data_set_entry_from_sd(AVFrameSideDataSet *dst, - const AVFrameSideData *src, - unsigned int flags); +int av_frame_side_data_from_sd(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *src, + unsigned int flags); /** * Get a side data entry of a specific type from a set. * - * @param set the set from which side data should be queried from - * @param type type of side data to be queried + * @param sd array of side data. + * @param nb_sd integer containing the number of entries in the array. + * @param type type of side data to be queried * * @return a pointer to the side data of a given type on success, NULL if there * is no side data with such type in this set. */ -AVFrameSideData *av_frame_side_data_set_get_entry(const AVFrameSideDataSet set, - enum AVFrameSideDataType type); +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + enum AVFrameSideDataType type); /** * @} diff --git a/libavutil/tests/side_data_set.c b/libavutil/tests/side_data_set.c index 820b3aac44..7ef99db3d2 100644 --- a/libavutil/tests/side_data_set.c +++ b/libavutil/tests/side_data_set.c @@ -22,36 +22,42 @@ #include "libavutil/frame.c" #include "libavutil/mastering_display_metadata.h" -static void print_clls(const AVFrameSideDataSet set) +static void print_clls(const AVFrameSideData **sd, const int nb_sd) { - for (int i = 0; i < set.nb_sd; i++) { - AVFrameSideData *sd = set.sd[i]; + for (int i = 0; i < nb_sd; i++) { + const AVFrameSideData *entry = sd[i]; printf("sd %d, %s", - i, av_frame_side_data_name(sd->type)); + i, av_frame_side_data_name(entry->type)); - if (sd->type != AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) { + if (entry->type != AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) { putchar('\n'); continue; } printf(": MaxCLL: %u\n", - ((AVContentLightMetadata *)sd->data)->MaxCLL); + ((AVContentLightMetadata *)entry->data)->MaxCLL); } } +typedef struct FrameSideDataSet { + AVFrameSideData **sd; + int nb_sd; +} FrameSideDataSet; + int main(void) { - AVFrameSideDataSet set = { 0 }; + FrameSideDataSet set = { 0 }; av_assert0( - av_frame_side_data_set_new_entry( - &set, AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, 0, 0)); + av_frame_side_data_new(&set.sd, &set.nb_sd, + AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, + 0, 0)); // test entries in the middle for (int value = 1; value < 4; value++) { - AVFrameSideData *sd = av_frame_side_data_set_new_entry( - &set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, + AVFrameSideData *sd = av_frame_side_data_new( + &set.sd, &set.nb_sd, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, sizeof(AVContentLightMetadata), 0); av_assert0(sd); @@ -60,13 +66,13 @@ int main(void) } av_assert0( - av_frame_side_data_set_new_entry( - &set, AV_FRAME_DATA_SPHERICAL, 0, 0)); + av_frame_side_data_new( + &set.sd, &set.nb_sd, AV_FRAME_DATA_SPHERICAL, 0, 0)); // test entries at the end for (int value = 1; value < 4; value++) { - AVFrameSideData *sd = av_frame_side_data_set_new_entry( - &set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, + AVFrameSideData *sd = av_frame_side_data_new( + &set.sd, &set.nb_sd, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, sizeof(AVContentLightMetadata), 0); av_assert0(sd); @@ -75,11 +81,11 @@ int main(void) } puts("Initial addition results with duplicates:"); - print_clls(set); + print_clls((const AVFrameSideData **)set.sd, set.nb_sd); { - AVFrameSideData *sd = av_frame_side_data_set_new_entry( - &set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, + AVFrameSideData *sd = av_frame_side_data_new( + &set.sd, &set.nb_sd, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, sizeof(AVContentLightMetadata), AV_FRAME_SIDE_DATA_SET_FLAG_NO_DUPLICATES); @@ -89,9 +95,9 @@ int main(void) } puts("\nFinal state after a single 'no-duplicates' addition:"); - print_clls(set); + print_clls((const AVFrameSideData **)set.sd, set.nb_sd); - av_frame_side_data_set_uninit(&set); + av_frame_side_data_free(&set.sd, &set.nb_sd); return 0; } -- 2.43.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2024-02-27 22:12 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-27 22:12 Jan Ekström [this message] 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 01/13] avutil/frame: split side data list wiping out to non-AVFrame function Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 02/13] avutil/frame: add helper for freeing arrays of side data Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 03/13] avutil/frame: split side_data_from_buf to base and AVFrame func Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 04/13] avutil/frame: split side data removal out to non-AVFrame function Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 05/13] avutil/frame: add helper for adding side data to array Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 06/13] avutil/frame: add helper for adding existing side data to set Jan Ekström 2024-02-27 23:20 ` James Almer 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 07/13] avutil/frame: add helper for getting side data from array Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 08/13] avcodec: add frame side data array to AVCodecContext Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 09/13] avcodec: add helper for configuring AVCodecContext's frame side data Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 10/13] ffmpeg: pass first video AVFrame's side data to encoder Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 11/13] avcodec/libsvtav1: add support for writing out CLL and MDCV Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 12/13] avcodec/libx264: " Jan Ekström 2024-02-27 22:26 ` Andreas Rheinhardt 2024-02-27 23:39 ` Jan Ekström 2024-02-28 18:07 ` Jan Ekström 2024-02-27 22:12 ` [FFmpeg-devel] [PATCH v6 13/13] avcodec/libx265: " Jan Ekström
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240227221226.1377758-1-jeebjp@gmail.com \ --to=jeebjp@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git