From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <ffmpeg-devel-bounces@ffmpeg.org> Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 65F4F4BA87 for <ffmpegdev@gitmailbox.com>; Tue, 1 Apr 2025 17:16:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E4858687D66; Tue, 1 Apr 2025 20:16:40 +0300 (EEST) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4A177687D6F for <ffmpeg-devel@ffmpeg.org>; Tue, 1 Apr 2025 20:16:34 +0300 (EEST) Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-3018e2d042bso6958930a91.2 for <ffmpeg-devel@ffmpeg.org>; Tue, 01 Apr 2025 10:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743527792; x=1744132592; 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=M9HvwRdj/f/t0NLsDjJqMYrWRwn994tTAi3D0Z6vUu90X7cH3H2XqxfxGCH6/KwATl 75qlv9FLMcTh39zQRQ1tIFnZLCE/Z7e8QLESRnFSObffZ4nF+ZzbpdxpgcosxpWwnwWt UVwCBWg0zJu2P7mGigyQ01nF9qi3NQKdbO7r4uzbEshDl+WzTEj+W73PZTOCPC+L5hQv nUfaeHLv98LKXz+tQ5E+cDUbsj21OTnSB+XkgBPvcZ7vK/vX+8mFUTHr3LKrGVoJ+nGO AKpDZzKkRlQl++5LdbmCm0bncDZYwNF2jqCgdWWot7UDg1ZhrZeE7w11VhxcdV7Ufrl6 XBFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743527792; x=1744132592; 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=rCgBdC5XYGIrNMGu/F91bAORiU3BukHFLOs3WcXXvNV2+t0b2cb6Xsmt9nC5x2SLBm ianYj3L0lm9Uep3l6dHLlX5SM6ebPXeqU149t1u9p4D7VulCb5JOPR9sSmpqcup4Og9V ScolXq94F7HmQuugfg2LNXUAGz/j5amQMZ8IsnqnCi64AZMYaK1VZpr7Kgf0iJz89Zbf Vg1A+DmIW7mIPFAAHFBXXg//4mRI8OgI4fjCKdK3/VpZsVurSivbgj7XpnSaegL/8vng abYZPfmyFZUgZNvAi4Pb0Y/j6fWpUd+eevgO0szH0MHxJ9tyXQVapFi6NzYGdmKXNpTW m0OA== X-Gm-Message-State: AOJu0YybDGFzz3HK4bCMwcmtzpiJLfYuL7G4W33LbxVabdw9LNo+6ZMu qKERO/CIUT0+PWQ01Rbj93mpwwScUdypw6AUiVocUtWnvTgGvI/chOX+hv8oUY0= X-Gm-Gg: ASbGnculSzZV2dwYlO3olgr0xUE3jKTnFAbkUkA6EJX/YZUNHE3kyO1mqlevJh5qz7r g1+Tjx2hY2n5ivdA9tQ6sXmRhkanpaX1DDKnny2I9GJplj1+Hj0PZOQovi8y8hvubstXLQS6Tec gmwwul1W5+Tm4FN0PsS6WfX0nLj001PrkpaSU/2khrYSCijxw4kNQB6vQ2MgOeql+1TqIhqv1Ke 1rwXZZt2oOxhN4rR7D+fxKwt2cXXutGTYziWX4OWnkMJzmj/CX7F1fzsMM5+KdCnq6pQzIeFdXt ySL+LhVkUIpscTRKIsLmlji3JNxMlx9l1H/ZZ2uqIB/isiGOwD6hA85BXSGD9MpDfg== X-Google-Smtp-Source: AGHT+IFYLka8Yq3aaeUNJIn3NrLu3yVD+TCrw4N3xfB5GoqwREaT7Ko+CjMUTBx5rNE7q88qYU2CaA== X-Received: by 2002:a17:90b:270e:b0:2fe:d766:ad95 with SMTP id 98e67ed59e1d1-305608774a9mr6038285a91.9.1743527792264; Tue, 01 Apr 2025 10:16:32 -0700 (PDT) Received: from localhost.localdomain ([124.79.129.75]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291eee0bafsm90902495ad.90.2025.04.01.10.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 10:16:31 -0700 (PDT) From: toqsxw@gmail.com X-Google-Original-From: toqsxw@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Apr 2025 01:15:59 +0800 Message-ID: <20250401171616.1378-2-toqsxw@outlook.com> X-Mailer: git-send-email 2.44.0.windows.1 In-Reply-To: <20250401171616.1378-1-toqsxw@outlook.com> References: <20250401171616.1378-1-toqsxw@outlook.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 02/19] 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 <ffmpeg-devel.ffmpeg.org> List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel> List-Post: <mailto:ffmpeg-devel@ffmpeg.org> List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Cc: Wu Jianhua <toqsxw@outlook.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250401171616.1378-2-toqsxw@outlook.com/> List-Archive: <https://master.gitmailbox.com/ffmpegdev/> List-Post: <mailto:ffmpegdev@gitmailbox.com> From: Wu Jianhua <toqsxw@outlook.com> Signed-off-by: Wu Jianhua <toqsxw@outlook.com> --- 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 <toqsxw@outlook.com> + * + * 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 <toqsxw@outlook.com> + * + * 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 <stdint.h> + +#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".