From patchwork Thu Sep 12 08:23:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 51545 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp778716vqi; Thu, 12 Sep 2024 01:49:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUe3pBIhS2icm645v0vIKxPxLl0e4/f84hzu2xRHaYNXc8LDQAN1P8YbTmeOgYp4XGiXnsMDu/zpe+kjSmA/oor@gmail.com X-Google-Smtp-Source: AGHT+IHGw75/AdFenneOxAEqP44awCVJdpgMtwzkeDUTsrD+xQmv4coh+tKhKsW8A/cxJjoX2v0J X-Received: by 2002:a05:6512:3d8e:b0:530:aeea:27e1 with SMTP id 2adb3069b0e04-53678fec5bfmr1069350e87.50.1726130952410; Thu, 12 Sep 2024 01:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726130952; cv=none; d=google.com; s=arc-20240605; b=bzPXJ1iHVOYPuu0JaREWAzrFdnYJGnol30XRtdelR68bYrXJVBnPJu0zSXGxfzNcGw eViEOfsW7y3rnm7RjIoVrh04vWbCTwSkM+HBIpE7yPcpIFORplvWfqk5fHW9h5TnrYzS T4lhhViX5Vr8rA5GZqtZSz/mS54AgGK2wzeSPU9RWyqHLLRQj1+s81ehqP7N3JD82Bgz b+hhrXXF6uDNs6Ubx7wjxAy9K5YUfjxGwGqT/zF2p3yeXecDl5esVEImiYPy2olhVSvA Js3cdftGFQU2tXVVaJusZBGuKNux2SZ0eIdlGbt6+Xta+ygV5lOsvMjYr04AoUHOKkKL q7Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to :delivered-to; bh=TwTpvTmC/5wFp6YOjH/xkmbkWA91p/TTEamyAbohAOw=; fh=Ont/7iEF8fqtg5HC8SyRso6lu6K4YqkD/WYfFN9cWQs=; b=KpV49sYFi7oV6GaEhN7GJxb02TxS+xniATZ4YIJhT47XYHqHZOWTbSSSGLs91SjsI6 JXdPNS6axgsbjzI7eINEKow5Js/1Zk5RrSqCmhTOzgojVtxT3tF//JQ2TiwfCwukgJhF M11rvgCUZXIICS07gjnMpOFZ39JiCiZVemKWeE/2R+B9wj+7ooeE78LDR0hZDZ40EHf1 3AEldsDHI72Pv4ps2piY1ySAGiW7blgrzocSq45l5qHo4e2gJ8iFdsUWaA5gPig4EeTf keLWy9Ol9Ituhczj7NjUvm3UuXMwbVuUNLkj3Z5Rug5QE0yuT4FEoLiHd107iLd5DbjA lRrw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5c3ebda84c0si7941044a12.495.2024.09.12.01.49.12; Thu, 12 Sep 2024 01:49:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 61C4F68DE04; Thu, 12 Sep 2024 11:23:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14C4168D98A for ; Thu, 12 Sep 2024 11:23:42 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Thu, 12 Sep 2024 10:23:16 +0200 Message-ID: <20240912082334.925402-1-dev@lynne.ee> X-Mailer: git-send-email 2.45.2.753.g447d99e1c3b MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] cbs_h265: add raw filler encoding 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: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne , Dave Airlie Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: NA7bbxB6woRh From: Dave Airlie --- libavcodec/cbs_h2645.c | 17 ++++++++++++++++ libavcodec/cbs_h265.h | 6 ++++++ libavcodec/cbs_h265_syntax_template.c | 29 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 4abd9e0c2e..1969ad8116 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1055,6 +1055,14 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, } break; + case HEVC_NAL_FD_NUT: + { + err = cbs_h265_read_filler(ctx, &gbc, unit->content); + if (err < 0) + return err; + } + break; + case HEVC_NAL_SEI_PREFIX: case HEVC_NAL_SEI_SUFFIX: { @@ -1497,6 +1505,14 @@ static int cbs_h265_write_nal_unit(CodedBitstreamContext *ctx, } break; + case HEVC_NAL_FD_NUT: + { + err = cbs_h265_write_filler(ctx, pbc, unit->content); + if (err < 0) + return err; + } + break; + case HEVC_NAL_SEI_PREFIX: case HEVC_NAL_SEI_SUFFIX: { @@ -2006,6 +2022,7 @@ static const CodedBitstreamUnitTypeDescriptor cbs_h265_unit_types[] = { CBS_UNIT_TYPE_INTERNAL_REF(HEVC_NAL_PPS, H265RawPPS, extension_data.data), CBS_UNIT_TYPE_POD(HEVC_NAL_AUD, H265RawAUD), + CBS_UNIT_TYPE_POD(HEVC_NAL_FD_NUT, H265RawFiller), // Slices of non-IRAP pictures. CBS_UNIT_RANGE_INTERNAL_REF(HEVC_NAL_TRAIL_N, HEVC_NAL_RASL_R, diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h index 892a35bd22..26a5a34fe9 100644 --- a/libavcodec/cbs_h265.h +++ b/libavcodec/cbs_h265.h @@ -741,6 +741,12 @@ typedef struct H265RawSEI { SEIRawMessageList message_list; } H265RawSEI; +typedef struct H265RawFiller { + H265RawNALUnitHeader nal_unit_header; + + uint32_t filler_size; +} H265RawFiller; + typedef struct CodedBitstreamH265Context { // Reader/writer context in common with the H.264 implementation. CodedBitstreamH2645Context common; diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 9f0281b8e8..1c11514435 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -2364,3 +2364,32 @@ static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } + + +static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw, + H265RawFiller *current) +{ + int err; + + HEADER("Filler Data"); + + CHECK(FUNC(nal_unit_header)(ctx, rw, ¤t->nal_unit_header, + HEVC_NAL_FD_NUT)); + +#ifdef READ + while (show_bits(rw, 8) == 0xff) { + fixed(8, ff_byte, 0xff); + ++current->filler_size; + } +#else + { + uint32_t i; + for (i = 0; i < current->filler_size; i++) + fixed(8, ff_byte, 0xff); + } +#endif + + CHECK(FUNC(rbsp_trailing_bits)(ctx, rw)); + + return 0; +}