From patchwork Sat Jun 17 22:00:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42182 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp2448782pzb; Sat, 17 Jun 2023 15:01:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6S0mzJue2ATWv4k6c89hZthrZbp169+FlK7bz2oCq538GU/2B67zRTCW36CBEcRDxJZqLV X-Received: by 2002:a17:906:974d:b0:953:37eb:7727 with SMTP id o13-20020a170906974d00b0095337eb7727mr5813694ejy.43.1687039314530; Sat, 17 Jun 2023 15:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687039314; cv=none; d=google.com; s=arc-20160816; b=MBGRNKs6fgfRnSVGIpkpUmY7fsP+Tfgt1G8UKPmRQYzJjL6q4oHK3FKdAi5tM0AjFQ Nu+5ARVmaB6rZWkmeGWoOrR7VTNwAmfkkHWPrmZaiekYR4Aqz+nDOu13M84BAiWZto71 AaKmMFSuWy98bM+kUSaTLrlw5mWhe/IG5BCM5RhJd+1mzhZsQfcl/ZOPWFs1bxoO43kV oTj7nj0ZgvNqIc42Kh9JFKlaGQKMdazqhi4U+wgMZQxy70Q8tWmlTW2ZagftuLTWSjqF JMLFCmG/Jf22i4NnPxbinU++lLQzhHZbRGW7J2+0Dk62Rl4J35TZ6yuEOgeZzw4trkxs jZ6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=OlaW73yDmzUejzUYH9p+LYFBRlEaosXraYigh8iXb0U=; b=aWvUPDx8XcTXKnvu/vk3Cm3NuQqsx723W+Asj9gkvEAOlcGckXZAy7OeAMBj3sGIQ0 1hJf4iYGMP6Huai5CIkBquzxgs/fvj5hKCZXnJm/CHnZ4O2UCythCyarYRyvG97nAC45 cgWlefRl8ZmaMlKYkQGLo9Eg45y/DNBbKrL7DiqNEtesMEJA9bWpD04aG3qXUpuVMVqn 1KOWBjepPIPRnuch6GWTL/b7rlEYb8TrnhMySC0dCcLz6c/zUBrRhiXkq1YHH9aojWJv kO9KCvCPxD1vmraBdSPyAvOVQVcfKZLn3Ia935eryezmATi8uDlT7kCjeWd8f/Dta2w6 A8QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=AakB7k2+; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b16-20020a170906195000b00988462a2b62si477633eje.222.2023.06.17.15.01.54; Sat, 17 Jun 2023 15:01:54 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=AakB7k2+; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CBD3468BFAC; Sun, 18 Jun 2023 01:00:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 035CB68BF89 for ; Sun, 18 Jun 2023 01:00:52 +0300 (EEST) Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-1a1fa977667so2305673fac.1 for ; Sat, 17 Jun 2023 15:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687039250; x=1689631250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Itn5dO/NyQLa5hdquDly2lk8KSPRS8purdNw+FEsY28=; b=AakB7k2+Gk555viM9LC/yyvVBWb75Ua+sGwTOOpaabUzc/8LAIGtQa2z0l1qaId+Np phWiMBSwF1MP/2Dd3ORl3H3bQBsha5zvPKQjFDhKL11KFASKwDCwLGgtsCV2UoLKJnTg unGb1TG7d83FM48oHDoqkZPuAkrD1ltQoqvnICcW76wiZgKNDgN60XcTr35LkRYV8bNB W/E7ki3GIWBbNHehMHf2tq4pg0UUcjqWSkQ0kKCJORW78siVY2Xjj5aB0vNYXR63MB+N p1A0zEq5JAkubhBOR9P3Si4K9gHlV3oJREAJtZTO/LfX7R843oL891UxK34sZG1MpsV0 ORhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687039250; x=1689631250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Itn5dO/NyQLa5hdquDly2lk8KSPRS8purdNw+FEsY28=; b=gNTIoAuSBhtLfG7f2VzvY7jJ8yEdv7bl3VVbu7uNfk7c3dthtljqNauN0gH+p8Y4jh 1Ib1Kebe43cbOiUESSXGY4sE5Od9gjiyOQnVf8dss2Ak0NDKQ9kYx8Q/PbbN+9K0nS2e fUNZ1XDBa4CpLvmhKvwScxNoJVeLjQhYLSaHJemxRD4PndAl4OZL1OTSxokeN5YC5p3v Ouo0WyhQ/IDMWjY42cvQ6NmEqkYDu2FZNbhRjjv8dcXNo8N9HqWKmDzMUcv5K4yuioWM JMlDtum9KtkEmKSqaJiHvDJXaW/0I7GUzxyRhsAXhpJKSK3QisoC8Bw7LsxutO8cJ7n+ tufg== X-Gm-Message-State: AC+VfDwGKyo/eZ70+chb9TwfDAHB8ddvs2AXrbedDnCcqIbcqwxZakBj OBIRhjBqYbveaKidZozPigM1GDJB+CQ= X-Received: by 2002:a05:6870:3a03:b0:1a9:8316:9b0a with SMTP id du3-20020a0568703a0300b001a983169b0amr2852914oab.7.1687039250100; Sat, 17 Jun 2023 15:00:50 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id o42-20020a05687096aa00b0019280078be5sm6246497oaq.6.2023.06.17.15.00.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 15:00:49 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Jun 2023 19:00:15 -0300 Message-ID: <20230617220015.12669-7-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230617151848.1378-1-jamrial@gmail.com> References: <20230617151848.1378-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/10] avcodec/evc_parse: remove ff_evc_parse_nal_unit() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RD3r579+Pqyo Signed-off-by: James Almer --- libavcodec/evc_parse.c | 156 ---------------------------------------- libavcodec/evc_parse.h | 42 ----------- libavcodec/evc_parser.c | 7 ++ 3 files changed, 7 insertions(+), 198 deletions(-) diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c index 0ad0d82137..48bd3ce5e9 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -258,159 +258,3 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, return 0; } - -int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx) -{ - int nalu_type, nalu_size; - int tid; - const uint8_t *data = buf; - int data_size = buf_size; - - // ctx->picture_structure = AV_PICTURE_STRUCTURE_FRAME; - ctx->key_frame = -1; - - nalu_size = buf_size; - if (nalu_size <= 0) { - av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", nalu_size); - return AVERROR_INVALIDDATA; - } - - // @see ISO_IEC_23094-1_2020, 7.4.2.2 NAL unit header semantic (Table 4 - NAL unit type codes and NAL unit type classes) - // @see enum EVCNALUnitType in evc.h - nalu_type = evc_get_nalu_type(data, data_size, logctx); - if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) { - av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", nalu_type); - return AVERROR_INVALIDDATA; - } - ctx->nalu_type = nalu_type; - - tid = ff_evc_get_temporal_id(data, data_size, logctx); - if (tid < 0) { - av_log(logctx, AV_LOG_ERROR, "Invalid temporial id: (%d)\n", tid); - return AVERROR_INVALIDDATA; - } - ctx->nuh_temporal_id = tid; - - data += EVC_NALU_HEADER_SIZE; - data_size -= EVC_NALU_HEADER_SIZE; - - switch(nalu_type) { - case EVC_SPS_NUT: { - EVCParserSPS *sps; - int bit_depth; - - sps = ff_evc_parse_sps(&ctx->ps, data, nalu_size); - if (!sps) { - av_log(logctx, AV_LOG_ERROR, "SPS parsing error\n"); - return AVERROR_INVALIDDATA; - } - - ctx->coded_width = sps->pic_width_in_luma_samples; - ctx->coded_height = sps->pic_height_in_luma_samples; - - if(sps->picture_cropping_flag) { - ctx->width = sps->pic_width_in_luma_samples - sps->picture_crop_left_offset - sps->picture_crop_right_offset; - ctx->height = sps->pic_height_in_luma_samples - sps->picture_crop_top_offset - sps->picture_crop_bottom_offset; - } else { - ctx->width = sps->pic_width_in_luma_samples; - ctx->height = sps->pic_height_in_luma_samples; - } - - if (sps->profile_idc == 1) ctx->profile = FF_PROFILE_EVC_MAIN; - else ctx->profile = FF_PROFILE_EVC_BASELINE; - - if (sps->vui_parameters_present_flag && sps->vui_parameters.timing_info_present_flag) { - int64_t num = sps->vui_parameters.num_units_in_tick; - int64_t den = sps->vui_parameters.time_scale; - if (num != 0 && den != 0) - av_reduce(&ctx->framerate.den, &ctx->framerate.num, num, den, 1 << 30); - } else - ctx->framerate = (AVRational) { 0, 1 }; - - bit_depth = sps->bit_depth_chroma_minus8 + 8; - ctx->format = AV_PIX_FMT_NONE; - - switch (bit_depth) { - case 8: - ctx->format = pix_fmts_8bit[sps->chroma_format_idc]; - break; - case 9: - ctx->format = pix_fmts_9bit[sps->chroma_format_idc]; - break; - case 10: - ctx->format = pix_fmts_10bit[sps->chroma_format_idc]; - break; - case 12: - ctx->format = pix_fmts_12bit[sps->chroma_format_idc]; - break; - case 14: - ctx->format = pix_fmts_14bit[sps->chroma_format_idc]; - break; - case 16: - ctx->format = pix_fmts_16bit[sps->chroma_format_idc]; - break; - } - av_assert0(ctx->format != AV_PIX_FMT_NONE); - - break; - } - case EVC_PPS_NUT: { - EVCParserPPS *pps; - - pps = ff_evc_parse_pps(&ctx->ps, data, nalu_size); - if (!pps) { - av_log(logctx, AV_LOG_ERROR, "PPS parsing error\n"); - return AVERROR_INVALIDDATA; - } - break; - } - case EVC_SEI_NUT: // Supplemental Enhancement Information - case EVC_APS_NUT: // Adaptation parameter set - case EVC_FD_NUT: // Filler data - break; - case EVC_IDR_NUT: // Coded slice of a IDR or non-IDR picture - case EVC_NOIDR_NUT: { - EVCParserSliceHeader sh; - int ret; - - ret = ff_evc_parse_slice_header(&sh, &ctx->ps, nalu_type, data, nalu_size); - if (ret < 0) { - av_log(logctx, AV_LOG_ERROR, "Slice header parsing error\n"); - return ret; - } - - switch (sh.slice_type) { - case EVC_SLICE_TYPE_B: { - ctx->pict_type = AV_PICTURE_TYPE_B; - break; - } - case EVC_SLICE_TYPE_P: { - ctx->pict_type = AV_PICTURE_TYPE_P; - break; - } - case EVC_SLICE_TYPE_I: { - ctx->pict_type = AV_PICTURE_TYPE_I; - break; - } - default: { - ctx->pict_type = AV_PICTURE_TYPE_NONE; - } - } - - ctx->key_frame = (nalu_type == EVC_IDR_NUT) ? 1 : 0; - - // POC (picture order count of the current picture) derivation - // @see ISO/IEC 23094-1:2020(E) 8.3.1 Decoding process for picture order count - ret = ff_evc_derive_poc(&ctx->ps, &sh, &ctx->poc, nalu_type, tid); - if (ret < 0) - return ret; - - ctx->output_picture_number = ctx->poc.PicOrderCntVal; - ctx->key_frame = (nalu_type == EVC_IDR_NUT) ? 1 : 0; - - break; - } - } - - return 0; -} diff --git a/libavcodec/evc_parse.h b/libavcodec/evc_parse.h index f31075ff9c..a1fbbc643d 100644 --- a/libavcodec/evc_parse.h +++ b/libavcodec/evc_parse.h @@ -81,46 +81,6 @@ typedef struct EVCParserPoc { int DocOffset; // the decoding order count of the previous picture } EVCParserPoc; -typedef struct EVCParserContext { - EVCParamSets ps; - EVCParserPoc poc; - - int nuh_temporal_id; // the value of TemporalId (shall be the same for all VCL NAL units of an Access Unit) - int nalu_type; // the current NALU type - - // Dimensions of the decoded video intended for presentation. - int width; - int height; - - // Dimensions of the coded video. - int coded_width; - int coded_height; - - // The format of the coded data, corresponds to enum AVPixelFormat - int format; - - // AV_PICTURE_TYPE_I, EVC_SLICE_TYPE_P, AV_PICTURE_TYPE_B - int pict_type; - - // Set by parser to 1 for key frames and 0 for non-key frames - int key_frame; - - // Picture number incremented in presentation or output order. - // This corresponds to EVCEVCParserPoc::PicOrderCntVal - int output_picture_number; - - // profile - // 0: FF_PROFILE_EVC_BASELINE - // 1: FF_PROFILE_EVC_MAIN - int profile; - - // Framerate value in the compressed bitstream - AVRational framerate; - - int parsed_extradata; - -} EVCParserContext; - static inline int evc_get_nalu_type(const uint8_t *bits, int bits_size, void *logctx) { int unit_type_plus1 = 0; @@ -157,8 +117,6 @@ static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_si // nuh_temporal_id specifies a temporal identifier for the NAL unit int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx); -int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx); - int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, const EVCParamSets *ps, enum EVCNALUnitType nalu_type, const uint8_t *buf, int buf_size); diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c index c30da6846e..710fabccb2 100644 --- a/libavcodec/evc_parser.c +++ b/libavcodec/evc_parser.c @@ -25,6 +25,13 @@ #include "evc.h" #include "evc_parse.h" +typedef struct EVCParserContext { + EVCParamSets ps; + EVCParserPoc poc; + + int parsed_extradata; +} EVCParserContext; + #define NUM_CHROMA_FORMATS 4 // @see ISO_IEC_23094-1 section 6.2 table 2 static const enum AVPixelFormat pix_fmts_8bit[NUM_CHROMA_FORMATS] = {