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 ESMTP id 86D984914E for ; Wed, 3 Jul 2024 21:27:30 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6E13668D9F2; Thu, 4 Jul 2024 00:26:53 +0300 (EEST) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DC32668D9DE for ; Thu, 4 Jul 2024 00:26:42 +0300 (EEST) Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2c9785517c0so25634a91.0 for ; Wed, 03 Jul 2024 14:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720042000; x=1720646800; darn=ffmpeg.org; 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=V2HXMlWRD1ybNqTLfPl3QMUgh/lmKyf6OlPg/hFHnzM=; b=f8vKXRqi9Yo7+cgkQS25LJDzJ0vxohyqPfKrsfCRWsixKMDBO43+3QLso7bUZrNf/U bKO9Y8hqbZEnXpjFkW8LkmWmIgo4pH9Wl6Y4Y6MUuKLIARGr2eVsgGJVy5I30NeJJGzr +LYLcLYgQVUoz1QU6xYianheRvUTMg1nTurNDGmnAGOibDsCjHwgMchgXHsEbCftGtFw DRPLf3T38K+UQeI1/E4xlYYdyPtLPJCWv/oJ556WVyeMdyaeXV76pFJ7MIQUGkSB7yLu 306r9Rp54suAmgP67bhq5Y5ns60hhNJ/rCMkLX/0VOiyFiPBKFGCiU6LzEd1YN5KsA+8 SYRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720042000; x=1720646800; 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=V2HXMlWRD1ybNqTLfPl3QMUgh/lmKyf6OlPg/hFHnzM=; b=AiShEuVEkqGt01q9PwxHlmZE+8uRJkxcH5ho9ro1EUctgAx1yMG9j0+jnutE5mTf/O OZeIquXlN+Rd2BwhCg8rNe1J3adSLr8mJLInXeeWpAldBSxCqGHkYnj0t2/fRg4coFER 3MqMhTY8kzRHYSEwZC6kb8Z99G2YWrQenwo9gTqG7yO6WoY1qQjaQ2MW8LxZZ6Qkln8v KPI7FjjEJd71gGAKkHIG+QcVZQpvudKXlC+WEBaYT/Xw9yDdMneRWjzBmMzCtBqPeBm9 T4ehBQcez96qzeOvNSjnRjCb3QePEZBXX58NKkSu+RVACj9SIpMPUbRlKLyaO7hZzwy8 p/fg== X-Gm-Message-State: AOJu0YxgKce+W7fZHl80qeLw0WmRW7NZciSVmK9JTrhUdGVlAoz0jIHl O57K6hVS2ugUGLAhWAYOJh65g+38dPiAuzz5T0qo9LQAbPh0/DyqZGmKhw== X-Google-Smtp-Source: AGHT+IFGfttHIbGg11eIPzF/Jj8ftO+DD/faKmeyhR0AR/lBHdeey6sD8b/ajfWKEdaOzJwITUuwhQ== X-Received: by 2002:a17:90a:517:b0:2c3:37e7:aaa8 with SMTP id 98e67ed59e1d1-2c93d785fa1mr7489789a91.46.1720042000019; Wed, 03 Jul 2024 14:26:40 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91ce58877sm11370560a91.24.2024.07.03.14.26.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 14:26:39 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 3 Jul 2024 18:26:41 -0300 Message-ID: <20240703212648.48483-6-jamrial@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240703212648.48483-1-jamrial@gmail.com> References: <20240703212648.48483-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/11] avformat/hevc: use a single array for per-PS NALUs 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 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: Signed-off-by: James Almer --- libavformat/hevc.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/libavformat/hevc.c b/libavformat/hevc.c index 40f46668f9..6fe701032b 100644 --- a/libavformat/hevc.c +++ b/libavformat/hevc.c @@ -40,15 +40,20 @@ enum { NB_ARRAYS }; + #define FLAG_ARRAY_COMPLETENESS (1 << 0) #define FLAG_IS_NALFF (1 << 1) +typedef struct HVCCNALUnit { + uint16_t nalUnitLength; + const uint8_t *nalUnit; +} HVCCNALUnit; + typedef struct HVCCNALUnitArray { uint8_t array_completeness; uint8_t NAL_unit_type; uint16_t numNalus; - uint16_t *nalUnitLength; - const uint8_t **nalUnit; + HVCCNALUnit *nal; } HVCCNALUnitArray; typedef struct HEVCDecoderConfigurationRecord { @@ -674,19 +679,17 @@ static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type, static int hvcc_array_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size, HVCCNALUnitArray *array) { + HVCCNALUnit *nal; int ret; uint16_t numNalus = array->numNalus; - ret = av_reallocp_array(&array->nalUnit, numNalus + 1, sizeof(uint8_t*)); - if (ret < 0) - return ret; - - ret = av_reallocp_array(&array->nalUnitLength, numNalus + 1, sizeof(uint16_t)); + ret = av_reallocp_array(&array->nal, numNalus + 1, sizeof(*array->nal)); if (ret < 0) return ret; - array->nalUnit [numNalus] = nal_buf; - array->nalUnitLength[numNalus] = nal_size; + nal = &array->nal[numNalus]; + nal->nalUnit = nal_buf; + nal->nalUnitLength = nal_size; array->numNalus++; return 0; @@ -785,8 +788,7 @@ static void hvcc_close(HEVCDecoderConfigurationRecord *hvcc) for (unsigned i = 0; i < FF_ARRAY_ELEMS(hvcc->arrays); i++) { HVCCNALUnitArray *const array = &hvcc->arrays[i]; array->numNalus = 0; - av_freep(&array->nalUnit); - av_freep(&array->nalUnitLength); + av_freep(&array->nal); } } @@ -871,7 +873,7 @@ static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc) for (unsigned k = 0; k < array->numNalus; k++) av_log(NULL, AV_LOG_TRACE, "nalUnitLength[%u][%u]: %"PRIu16"\n", - j, k, array->nalUnitLength[k]); + j, k, array->nal[k].nalUnitLength); j++; } @@ -972,12 +974,13 @@ static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc) avio_wb16(pb, array->numNalus); for (unsigned j = 0; j < array->numNalus; j++) { + HVCCNALUnit *nal = &array->nal[j]; + /* unsigned int(16) nalUnitLength; */ - avio_wb16(pb, array->nalUnitLength[j]); + avio_wb16(pb, nal->nalUnitLength); /* bit(8*nalUnitLength) nalUnit; */ - avio_write(pb, array->nalUnit[j], - array->nalUnitLength[j]); + avio_write(pb, nal->nalUnit, nal->nalUnitLength); } } -- 2.45.2 _______________________________________________ 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".