From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id D97254E00D for ; Sun, 27 Apr 2025 11:45:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B797168AF86; Sun, 27 Apr 2025 14:45:44 +0300 (EEST) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C3728687B1C for ; Sun, 27 Apr 2025 14:45:18 +0300 (EEST) Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7376e311086so5194594b3a.3 for ; Sun, 27 Apr 2025 04:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745754317; x=1746359117; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3L7cE4wQfEDsSKB5FhxLzGjYDxXR+QJt8hi4eugkOj4=; b=ABDbtYFLAD3NokOligZl6L8ysU7v95RhDtlF5bUY7N8JDNA4NMpzr7NNXxrDElgman rS+q+H/IiyLdRbLveum59bQTcKJHVx8nK3rnwJc/znvf8XMJqCtS85nPTipNdNGYYU1U lhAxJSxEsh375LKjT/6GW1nEntmsTyJxxl9JAIlU8nF5c9TR+5tJkH3xdi3r21UcJMC+ Dmd/rrfgDdIJAD+WqZa/eJUgGC1WT4sDZVIBstQUMa8efUATv7Hh2A50d0cu0M6VfeoP Xg9UrFV1AoBLAMLLlobAAwf7bwigrfT/w97oh19EYaKmHbM6x3OC2KAtsocFT/IKswND 8avw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745754317; x=1746359117; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3L7cE4wQfEDsSKB5FhxLzGjYDxXR+QJt8hi4eugkOj4=; b=UUlE92sJ04ot8jXezepm9iqWYaH/NLG+eSYF2EEPwyegIjD+ASLZrynKw5pKn3QmZA sJC3a04RW75zzdKlAl/rWF54WDoY3tYwdcJPYbxAMNpJnFMH7dKKGR8QLXNUoBRGgWk7 6YVMvVZA3c31ycBsywcfNxhWOIfmDd07N69TV4ha/+/SBLfUQ/wrYc9bXNvuC0QNL6hh GnpSkz3PtaOWGVdg2mVBJd6LeoIsS3HSCYBG6MzsgIshpg8yKRBwjnawHSU+A6BCbtlJ NvvYw/DfKcZmgsreYz+xCjqKjfKswyx4943aSid58fJR01re8GL+BQJmGkS2PEYgL5jV BL2A== X-Gm-Message-State: AOJu0Yx0apnrtr28AvlOdlWWAd44eBd+QvbpjtUhHAYUWmxibRaxXs9k ZpWCN9c4okwh2roPij0SeSbH34mpsOlO2qZYMoL2uwR2QRLUh7xvNFr8i2IS X-Gm-Gg: ASbGncsBlzxGSi+UUQFRP7p0bJbV1EBfu27GquBREiqHL+6K0+8WpaSzgxCjv3YZMQF zue4CvXX+4cqpCPUMAhcBLiLribJ6g3cfdgcxXifvpFe0M6gcNUGQbBZdL5Y0QjvaFJcCzfZE5b OiD48Iy49MWBZotwMhpEAETWKj4eUT9D/eXbHo5rNhkeE2/k256RLhTMpScOT+aQAiAyTDmRl6W iBLU4sdfJcJWyJPpu0eKza4wnfEpbE0+GuM+eGCLO+ccjZxz49nfQXgKk2Gu4DTCuhG0VLSTA/D Teebo+m9yTZzSC83viJhFZao8ny5MMSbBSzR1fZp/sD7vaBSDafK11a+FTOcUw== X-Google-Smtp-Source: AGHT+IHU8Gh4qm4aG7RYOU+OtwcX+CSuRVtsMbwD71cchQKgG+IQzlVwLrI87XsPht7khoOt4PhHTg== X-Received: by 2002:a05:6a21:1518:b0:204:4573:d854 with SMTP id adf61e73a8af0-2045b6ae840mr12338937637.9.1745754316759; Sun, 27 Apr 2025 04:45:16 -0700 (PDT) Received: from localhost.localdomain ([124.79.129.75]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e259134ebsm6064452b3a.27.2025.04.27.04.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Apr 2025 04:45:16 -0700 (PDT) From: toqsxw@gmail.com X-Google-Original-From: toqsxw@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Apr 2025 19:44:33 +0800 Message-ID: <20250427114451.1236-3-toqsxw@outlook.com> X-Mailer: git-send-email 2.44.0.windows.1 In-Reply-To: <20250427114451.1236-1-toqsxw@outlook.com> References: <20250427114451.1236-1-toqsxw@outlook.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 03/20] avcodec/vvc: support decoding prefix and suffix nal units X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: nuomi2021@gmail.com, Wu Jianhua Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Wu Jianhua Signed-off-by: Wu Jianhua --- configure | 4 ++- libavcodec/Makefile | 1 + libavcodec/vvc/Makefile | 1 + libavcodec/vvc/dec.c | 32 ++++++++++++++++++++++++ libavcodec/vvc/dec.h | 2 ++ libavcodec/vvc/sei.c | 55 +++++++++++++++++++++++++++++++++++++++++ libavcodec/vvc/sei.h | 45 +++++++++++++++++++++++++++++++++ 7 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 libavcodec/vvc/sei.c create mode 100644 libavcodec/vvc/sei.h diff --git a/configure b/configure index 2fdbe8cbbe..516f18becb 100755 --- a/configure +++ b/configure @@ -2654,6 +2654,7 @@ CONFIG_EXTRA=" vp56dsp vp8dsp vulkan_encode + vvc_sei wma_freqs wmv2dsp " @@ -2902,6 +2903,7 @@ mpegvideoenc_select="aandcttables fdctdsp me_cmp mpegvideo pixblockdsp" msmpeg4dec_select="h263_decoder" msmpeg4enc_select="h263_encoder" vc1dsp_select="h264chroma qpeldsp startcode" +vvc_sei_select="atsc_a53 golomb" wmv2dsp_select="qpeldsp" # decoders / encoders @@ -3138,7 +3140,7 @@ vp6f_decoder_select="vp6_decoder" vp7_decoder_select="h264pred videodsp vp8dsp" vp8_decoder_select="h264pred videodsp vp8dsp" vp9_decoder_select="videodsp vp9_parser vp9_superframe_split_bsf" -vvc_decoder_select="cabac cbs_h266 golomb videodsp" +vvc_decoder_select="cabac cbs_h266 golomb videodsp vvc_sei" wcmv_decoder_select="inflate_wrapper" webp_decoder_select="vp8_decoder exif" wmalossless_decoder_select="llauddsp" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 37b201ec4a..7467c883d3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -809,6 +809,7 @@ OBJS-$(CONFIG_VP9_V4L2M2M_DECODER) += v4l2_m2m_dec.o OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o OBJS-$(CONFIG_VQC_DECODER) += vqcdec.o OBJS-$(CONFIG_VVC_DECODER) += executor.o h2645data.o +OBJS-$(CONFIG_VVC_SEI) += h2645_sei.o aom_film_grain.o OBJS-$(CONFIG_WADY_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_WAVARC_DECODER) += wavarc.o OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o wavpackdata.o dsd.o diff --git a/libavcodec/vvc/Makefile b/libavcodec/vvc/Makefile index 6a28d32bc2..10125ffc2d 100644 --- a/libavcodec/vvc/Makefile +++ b/libavcodec/vvc/Makefile @@ -14,4 +14,5 @@ OBJS-$(CONFIG_VVC_DECODER) += vvc/dec.o \ vvc/mvs.o \ vvc/ps.o \ vvc/refs.o \ + vvc/sei.o \ vvc/thread.o \ diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c index 0b6443a112..206be3cc33 100644 --- a/libavcodec/vvc/dec.c +++ b/libavcodec/vvc/dec.c @@ -640,6 +640,7 @@ static av_cold void frame_context_free(VVCFrameContext *fc) pic_arrays_free(fc); av_frame_free(&fc->output_frame); ff_vvc_frame_ps_free(&fc->ps); + ff_vvc_sei_reset(&fc->sei); } static av_cold int frame_context_init(VVCFrameContext *fc, AVCodecContext *avctx) @@ -682,6 +683,10 @@ static int frame_context_setup(VVCFrameContext *fc, VVCContext *s) return ret; } } + + ret = ff_vvc_sei_replace(&fc->sei, &prev->sei); + if (ret < 0) + return ret; } if (IS_IDR(s)) { @@ -697,6 +702,22 @@ static int frame_context_setup(VVCFrameContext *fc, VVCContext *s) return 0; } +/* SEI does not affect decoding, so we ignore the return value */ +static void decode_prefix_sei(VVCFrameContext *fc, VVCContext *s) +{ + CodedBitstreamFragment *frame = &s->current_frame; + + for (int i = 0; i < frame->nb_units; i++) { + const CodedBitstreamUnit *unit = frame->units + i; + + if (unit->type == VVC_PREFIX_SEI_NUT) { + int ret = ff_vvc_sei_decode(&fc->sei, unit->content_ref, fc); + if (ret < 0) + return; + } + } +} + static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc) { const VVCPH *ph = &fc->ps.ph; @@ -710,6 +731,8 @@ static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc) if ((ret = ff_vvc_set_new_ref(s, fc, &fc->frame)) < 0) goto fail; + decode_prefix_sei(fc, s); + if (!IS_IDR(s)) ff_vvc_bump_frame(s, fc); @@ -914,6 +937,15 @@ static int decode_nal_unit(VVCContext *s, VVCFrameContext *fc, AVBufferRef *buf_ if (ret < 0) return ret; break; + case VVC_PREFIX_SEI_NUT: + /* handle by decode_prefix_sei() */ + break; + + case VVC_SUFFIX_SEI_NUT: + /* SEI does not affect decoding, so we ignore the return value*/ + if (fc) + ff_vvc_sei_decode(&fc->sei, unit->content_ref, fc); + break; } return 0; diff --git a/libavcodec/vvc/dec.h b/libavcodec/vvc/dec.h index 6aa3121550..df81a83489 100644 --- a/libavcodec/vvc/dec.h +++ b/libavcodec/vvc/dec.h @@ -29,6 +29,7 @@ #include "ps.h" #include "dsp.h" +#include "sei.h" #define LUMA 0 #define CHROMA 1 @@ -124,6 +125,7 @@ typedef struct VVCFrameContext { struct AVFrame *output_frame; VVCFrameParamSets ps; + VVCSEI sei; SliceContext **slices; int nb_slices; diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c new file mode 100644 index 0000000000..2842862a36 --- /dev/null +++ b/libavcodec/vvc/sei.c @@ -0,0 +1,55 @@ +/* + * VVC Supplementary Enhancement Information messages + * + * copyright (c) 2024 Wu Jianhua + * + * 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 "sei.h" +#include "dec.h" +#include "libavutil/refstruct.h" + +int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc) +{ + if (!sei) + return AVERROR_INVALIDDATA; + + for (int i = 0; i < sei->message_list.nb_messages; i++) { + SEIRawMessage *message = &sei->message_list.messages[i]; + + switch (message->payload_type) { + default: + av_log(fc->log_ctx, AV_LOG_DEBUG, "Skipped %s SEI %d\n", + sei->nal_unit_header.nal_unit_type == VVC_PREFIX_SEI_NUT ? + "PREFIX" : "SUFFIX", message->payload_type); + return FF_H2645_SEI_MESSAGE_UNHANDLED; + } + } + + return 0; +} + +int ff_vvc_sei_replace(VVCSEI *dst, const VVCSEI *src) +{ + return ff_h2645_sei_ctx_replace(&dst->common, &src->common); +} + +void ff_vvc_sei_reset(VVCSEI *s) +{ + ff_h2645_sei_reset(&s->common); +} diff --git a/libavcodec/vvc/sei.h b/libavcodec/vvc/sei.h new file mode 100644 index 0000000000..17e04cde63 --- /dev/null +++ b/libavcodec/vvc/sei.h @@ -0,0 +1,45 @@ +/* + * VVC Supplementary Enhancement Information messages + * + * copyright (c) 2024 Wu Jianhua + * + * 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 + */ + +#ifndef AVCODEC_VVC_SEI_H +#define AVCODEC_VVC_SEI_H + +#include + +#include "libavcodec/get_bits.h" +#include "libavcodec/cbs.h" +#include "libavcodec/cbs_h266.h" +#include "libavcodec/h2645_sei.h" +#include "libavcodec/sei.h" +#include "libavcodec/vvc.h" + +typedef struct VVCSEI { + H2645SEI common; +} VVCSEI; + +struct VVCFrameContext; + +int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc); +int ff_vvc_sei_replace(VVCSEI *dst, const VVCSEI *src); +void ff_vvc_sei_reset(VVCSEI *s); + +#endif /* AVCODEC_VVC_SEI_H */ -- 2.44.0.windows.1 _______________________________________________ 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".