This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit e245f4d5cf642faa6f43002654dfc84ba457b78c Author: James Almer <[email protected]> AuthorDate: Thu Feb 19 10:40:48 2026 -0300 Commit: James Almer <[email protected]> CommitDate: Sat Feb 28 16:14:40 2026 -0300 avcodec/bsf: add a LCEVC metadata bitstream filter Signed-off-by: James Almer <[email protected]> --- Changelog | 1 + libavcodec/bitstream_filters.c | 1 + libavcodec/bsf/Makefile | 1 + libavcodec/bsf/lcevc_metadata.c | 204 ++++++++++++++++++++++++++++++++++++++++ libavcodec/version.h | 4 +- 5 files changed, 209 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 26416cb1d6..f5ff8e549b 100644 --- a/Changelog +++ b/Changelog @@ -24,6 +24,7 @@ version <next>: - Remove the old HLS protocol handler - Vulkan compute codec optimizations - swscale Vulkan support +- LCEVC metadata bitstream filter version 8.0: diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c index b4b852c7e6..150cca8939 100644 --- a/libavcodec/bitstream_filters.c +++ b/libavcodec/bitstream_filters.c @@ -48,6 +48,7 @@ extern const FFBitStreamFilter ff_hapqa_extract_bsf; extern const FFBitStreamFilter ff_hevc_metadata_bsf; extern const FFBitStreamFilter ff_hevc_mp4toannexb_bsf; extern const FFBitStreamFilter ff_imx_dump_header_bsf; +extern const FFBitStreamFilter ff_lcevc_metadata_bsf; extern const FFBitStreamFilter ff_media100_to_mjpegb_bsf; extern const FFBitStreamFilter ff_mjpeg2jpeg_bsf; extern const FFBitStreamFilter ff_mjpega_dump_header_bsf; diff --git a/libavcodec/bsf/Makefile b/libavcodec/bsf/Makefile index 360fd1e32f..eb090090ef 100644 --- a/libavcodec/bsf/Makefile +++ b/libavcodec/bsf/Makefile @@ -25,6 +25,7 @@ OBJS-$(CONFIG_HEVC_METADATA_BSF) += bsf/h265_metadata.o OBJS-$(CONFIG_DOVI_RPU_BSF) += bsf/dovi_rpu.o OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF) += bsf/hevc_mp4toannexb.o OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF) += bsf/imx_dump_header.o +OBJS-$(CONFIG_LCEVC_METADATA_BSF) += bsf/lcevc_metadata.o OBJS-$(CONFIG_MEDIA100_TO_MJPEGB_BSF) += bsf/media100_to_mjpegb.o OBJS-$(CONFIG_MJPEG2JPEG_BSF) += bsf/mjpeg2jpeg.o OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += bsf/mjpega_dump_header.o diff --git a/libavcodec/bsf/lcevc_metadata.c b/libavcodec/bsf/lcevc_metadata.c new file mode 100644 index 0000000000..4512999214 --- /dev/null +++ b/libavcodec/bsf/lcevc_metadata.c @@ -0,0 +1,204 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/common.h" +#include "libavutil/opt.h" + +#include "bsf.h" +#include "bsf_internal.h" +#include "cbs.h" +#include "cbs_bsf.h" +#include "cbs_lcevc.h" +#include "lcevc.h" + +typedef struct LCEVCMetadataContext { + CBSBSFContext common; + + int overscan_appropriate_flag; + + int video_format; + int video_full_range_flag; + int colour_primaries; + int transfer_characteristics; + int matrix_coefficients; + + int chroma_sample_loc_type; + + LCEVCRawAdditionalInfo ai; + + int delete_filler; +} LCEVCMetadataContext; + +static int lcevc_metadata_handle_vui(AVBSFContext *bsf, + CodedBitstreamFragment *au) +{ + LCEVCMetadataContext *ctx = bsf->priv_data; + LCEVCRawProcessBlock *block = NULL; + LCEVCRawAdditionalInfo *ai = &ctx->ai; + LCEVCRawVUI *vui = &ai->vui; + int position, err; + + position = ff_cbs_lcevc_find_process_block(ctx->common.output, au, + LCEVC_PAYLOAD_TYPE_GLOBAL_CONFIG, + &block); + if (position < 0) + return 0; + + memset(ai, 0, sizeof(*ai)); + ai->additional_info_type = LCEVC_ADDITIONAL_INFO_TYPE_VUI; + + if (ctx->overscan_appropriate_flag >= 0) { + vui->overscan_info_present_flag = 1; + vui->overscan_appropriate_flag = ctx->overscan_appropriate_flag; + } + + if (ctx->video_format >= 0) { + vui->video_signal_type_present_flag = 1; + vui->video_format = ctx->video_format; + } else + vui->video_format = 5; + + if (ctx->video_full_range_flag >= 0) { + vui->video_signal_type_present_flag = 1; + vui->video_full_range_flag = ctx->video_full_range_flag; + } + + if (ctx->colour_primaries >= 0) { + vui->video_signal_type_present_flag = vui->colour_description_present_flag = 1; + vui->colour_primaries = ctx->colour_primaries; + } else + vui->colour_primaries = 2; + if (ctx->transfer_characteristics >= 0) { + vui->video_signal_type_present_flag = vui->colour_description_present_flag = 1; + vui->transfer_characteristics = ctx->transfer_characteristics; + } else + vui->transfer_characteristics = 2; + if (ctx->matrix_coefficients >= 0) { + vui->video_signal_type_present_flag = vui->colour_description_present_flag = 1; + vui->matrix_coefficients = ctx->matrix_coefficients; + } else + vui->matrix_coefficients = 2; + + if (ctx->chroma_sample_loc_type >= 0) { + vui->chroma_loc_info_present_flag = 1; + vui->chroma_sample_loc_type_top_field = ctx->chroma_sample_loc_type; + vui->chroma_sample_loc_type_top_field = ctx->chroma_sample_loc_type; + } + + err = ff_cbs_lcevc_add_process_block(ctx->common.output, au, position, + LCEVC_PAYLOAD_TYPE_ADDITIONAL_INFO, + ai, NULL); + if (err < 0) + return err; + + return 0; +} + +static int lcevc_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, + CodedBitstreamFragment *au) +{ + LCEVCMetadataContext *ctx = bsf->priv_data; + int err; + + if (ctx->overscan_appropriate_flag >= 0 || ctx->video_format >= 0 || + ctx->video_full_range_flag >= 0 || ctx->colour_primaries >= 0 || + ctx->transfer_characteristics >= 0 || ctx->matrix_coefficients >= 0 || + ctx->chroma_sample_loc_type >= 0) { + err = lcevc_metadata_handle_vui(bsf, au); + if (err < 0) + return err; + } + + if (ctx->delete_filler) { + for (int i = 0; i < au->nb_units; i++) { + if (au->units[i].type == LCEVC_NON_IDR_NUT || + au->units[i].type == LCEVC_IDR_NUT) { + ff_cbs_lcevc_delete_process_block_type(ctx->common.output, au, + LCEVC_PAYLOAD_TYPE_FILLER); + } + } + } + + return 0; +} + +static const CBSBSFType lcevc_metadata_type = { + .codec_id = AV_CODEC_ID_LCEVC, + .fragment_name = "access unit", + .unit_name = "NAL unit", + .update_fragment = &lcevc_metadata_update_fragment, +}; + +static int lcevc_metadata_init(AVBSFContext *bsf) +{ + return ff_cbs_bsf_generic_init(bsf, &lcevc_metadata_type); +} + +#define OFFSET(x) offsetof(LCEVCMetadataContext, x) +#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM) +static const AVOption lcevc_metadata_options[] = { + { "overscan_appropriate_flag", "Set VUI overscan appropriate flag", + OFFSET(overscan_appropriate_flag), AV_OPT_TYPE_BOOL, + { .i64 = -1 }, -1, 1, FLAGS }, + + { "video_format", "Set video format (table E-2)", + OFFSET(video_format), AV_OPT_TYPE_INT, + { .i64 = -1 }, -1, 5, FLAGS}, + { "video_full_range_flag", "Set video full range flag", + OFFSET(video_full_range_flag), AV_OPT_TYPE_BOOL, + { .i64 = -1 }, -1, 1, FLAGS }, + { "colour_primaries", "Set colour primaries (table E-3)", + OFFSET(colour_primaries), AV_OPT_TYPE_INT, + { .i64 = -1 }, -1, 255, FLAGS }, + { "transfer_characteristics", "Set transfer characteristics (table E-4)", + OFFSET(transfer_characteristics), AV_OPT_TYPE_INT, + { .i64 = -1 }, -1, 255, FLAGS }, + { "matrix_coefficients", "Set matrix coefficients (table E-5)", + OFFSET(matrix_coefficients), AV_OPT_TYPE_INT, + { .i64 = -1 }, -1, 255, FLAGS }, + + { "chroma_sample_loc_type", "Set chroma sample location type (figure E-1)", + OFFSET(chroma_sample_loc_type), AV_OPT_TYPE_INT, + { .i64 = -1 }, -1, 5, FLAGS }, + + { "delete_filler", "Delete all filler", + OFFSET(delete_filler), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS}, + + { NULL } +}; + +static const AVClass lcevc_metadata_class = { + .class_name = "lcevc_metadata_bsf", + .item_name = av_default_item_name, + .option = lcevc_metadata_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const enum AVCodecID lcevc_metadata_codec_ids[] = { + AV_CODEC_ID_LCEVC, AV_CODEC_ID_NONE, +}; + +const FFBitStreamFilter ff_lcevc_metadata_bsf = { + .p.name = "lcevc_metadata", + .p.codec_ids = lcevc_metadata_codec_ids, + .p.priv_class = &lcevc_metadata_class, + .priv_data_size = sizeof(LCEVCMetadataContext), + .init = &lcevc_metadata_init, + .close = &ff_cbs_bsf_generic_close, + .filter = &ff_cbs_bsf_generic_filter, +}; diff --git a/libavcodec/version.h b/libavcodec/version.h index 21443642a3..e0fe2eb7b8 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,8 +29,8 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 23 -#define LIBAVCODEC_VERSION_MICRO 103 +#define LIBAVCODEC_VERSION_MINOR 24 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
