From patchwork Sat Jun 17 15:18:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42172 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp2297437pzb; Sat, 17 Jun 2023 08:19:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7SX7B6RxPrx5qQQduA/WpOA1ONlBG9zIIp3GYhJxqCh/2NPbU48BKewnEgM7FhZPWE1Fmq X-Received: by 2002:a17:907:a0c:b0:978:8e8c:1bcb with SMTP id bb12-20020a1709070a0c00b009788e8c1bcbmr4773230ejc.43.1687015152267; Sat, 17 Jun 2023 08:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687015152; cv=none; d=google.com; s=arc-20160816; b=I04bOrGRZ1qSaRZUD8dG3sERynaREoWe0W1Tg56oDoPLgvRIKg1Cs/EV6kiRjGBGIJ ePkOZywESWSkadVPXaeKu2v95Ap6JcLqylixRzTcZqkobJQpA8AjzKw5LNw09wqFuUuN Wkk5jL33qbEFLxRegorZJfxWsk1souaA7KHW9kTJPUDgUeOkkU6BWDOKzLtvPz42CWp+ w4UztAWfajFTSnqISPELIs7AGxql54eoZig0rKwAaMYke49sg4FS+4+UaZMu1MpjzGPI SjTKDAbUWODkWrEbFfMue7ofi2Q2tM/rBakDVZoZMCMCwoXYf2c6XEKXr9GeqSNyM/AC cAoA== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=w5o/47DHLDrhjVqT+IxprpNNFx2bbp+2mK/nA89C8eA=; b=r3WGeTekYjEBgeEo2SbRZEQj9bUZWM4CNRhQ9k6FX8cXjJCnURaouY119ODS1M3YH3 8D2aaYhCiAh1qatVUwfZCNIn7M9sDJUDvluHV5vhtRrMcZJVH+AFXDHy5AQHf7PEgvQT 5xxf9q+LrEZoMLXYLUjWUdrOIj7E0GWjEhNR4ZjJhT1yud9200+ZGgYcaaijmKrKVn4R 9PyWlVSd95Ts5VYZAuWFC+ZmaFu1aGM2C/SthNVyh4bh/rjD+98QJoTUaejnKRugollm pvP7Gqk3ZqJ93TXqaxtcURAz/p6ZdRCnS7b0yA/ETSmwJj4QzAV0xPJtdZdXjqexJTUR wfEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=X9MDK0Jm; 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 v23-20020a1709060b5700b00987ddccbe11si655443ejg.628.2023.06.17.08.19.11; Sat, 17 Jun 2023 08:19: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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=X9MDK0Jm; 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 5DDE368C3AF; Sat, 17 Jun 2023 18:19:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 01E6368C09C for ; Sat, 17 Jun 2023 18:18:59 +0300 (EEST) Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-55e0706af99so1215880eaf.1 for ; Sat, 17 Jun 2023 08:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687015137; x=1689607137; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=REXLU3KsFOIAdmFCwu0Q44U8l3/CQh+nNiAFsSRk/D4=; b=X9MDK0Jmde6MCJToeoHYuKxKZHQq9ZmTsuEm5rRky3nCFK3hrA9dKCquQ2FQYqp8Fx ovF9+kFfXcbgrxLGsW6dTmdC+kyIrSBZokoCtE55Z39DIZsHPd11AB+Nl9wF9R+mbkBM jcCY2y87GSW91CYiwkxohZkQzEGd2Ew8dqal2hVj4xCbcKRYlITBluf8ot+2sAbIXWdw +3/eARm4pxRU4T6ytrN9BPYYwndwMHfzr3fP08o2VgSVKCZGOY29BU5objPhIEP1mxb+ L0niv00xpZd5mCRJE+7LtTKRUDWpscJ38mfR0hdeEOeb/SRXdiwp8t1FgWIGrpN+SSOA FnlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687015137; x=1689607137; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=REXLU3KsFOIAdmFCwu0Q44U8l3/CQh+nNiAFsSRk/D4=; b=i58b1XJ9LSIIYLzBBchIkbwf8pA3jV+R7YmMYBecLzFd4qTtuF64kRAx04A1OqWAC8 RbDS4sLa4pny02Tm48z7dGE1R58q5sbLYQKWctuLI3vx7FlxSXjNf0EvTxu1z2YiejhH PC8ebaev1bV5JAK0R3B2PWPWCzWLyA2/wmGzCeCEseH9Ymx28qZwfg4mYhqdsnZF6imm XbSFccHoYcEVkphu/1NKGEThPt/2X+gSkVS9jlukgToRym1zfKopBHJPmkbYtV1hb7y9 Vt85qcsE767gYIkeYKYu7Nh1oSUGOMS6+C/HyjlglRCgxf2v6x1KjXkktAU7CmwpyOvw 7Rjw== X-Gm-Message-State: AC+VfDy4ecTv39AUHMcXJH4AFY4lCcvkxpW6hx5lo/DV867eFfvK0P0k hYJL87fL8Hchg3oe8vwN0lTnTdtwJwc= X-Received: by 2002:a05:6808:d4b:b0:398:2f92:65ca with SMTP id w11-20020a0568080d4b00b003982f9265camr7055680oik.7.1687015137472; Sat, 17 Jun 2023 08:18:57 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id j189-20020acab9c6000000b0039600e3376asm9533452oif.1.2023.06.17.08.18.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 08:18:56 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Jun 2023 12:18:46 -0300 Message-ID: <20230617151848.1378-1-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/evc_frame_merge: use av_fast_realloc() 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: a9IbdAXoyriU Signed-off-by: James Almer --- libavcodec/evc_frame_merge_bsf.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c index 7cc701f5c5..827f114f0b 100644 --- a/libavcodec/evc_frame_merge_bsf.c +++ b/libavcodec/evc_frame_merge_bsf.c @@ -26,13 +26,11 @@ #include "evc.h" #include "evc_parse.h" -#define INIT_AU_BUF_CAPACITY 1024 - // Access unit data typedef struct AccessUnitBuffer { uint8_t *data; // the data buffer size_t data_size; // size of data in bytes - size_t capacity; // buffer capacity + unsigned capacity; // buffer capacity } AccessUnitBuffer; typedef struct EVCFMergeContext { @@ -72,9 +70,8 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) AVPacket *in = ctx->in; - int free_space = 0; size_t nalu_size = 0; - uint8_t *nalu = NULL; + uint8_t *buffer, *nalu = NULL; int au_end_found = 0; int err; @@ -102,15 +99,14 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) au_end_found = end_of_access_unit_found(parser_ctx); - free_space = ctx->au_buffer.capacity - ctx->au_buffer.data_size; - while (free_space < in->size) { - ctx->au_buffer.capacity *= 2; - free_space = ctx->au_buffer.capacity - ctx->au_buffer.data_size; - - if (free_space >= in->size) - ctx->au_buffer.data = av_realloc(ctx->au_buffer.data, ctx->au_buffer.capacity); + buffer = av_fast_realloc(ctx->au_buffer.data, &ctx->au_buffer.capacity, + ctx->au_buffer.data_size + in->size); + if (!buffer) { + av_freep(&ctx->au_buffer.data); + return AVERROR(ENOMEM); } + ctx->au_buffer.data = buffer; memcpy(ctx->au_buffer.data + ctx->au_buffer.data_size, in->data, in->size); ctx->au_buffer.data_size += in->size; @@ -143,10 +139,6 @@ static int evc_frame_merge_init(AVBSFContext *bsf) if (!ctx->in) return AVERROR(ENOMEM); - ctx->au_buffer.capacity = INIT_AU_BUF_CAPACITY; - ctx->au_buffer.data = av_malloc(INIT_AU_BUF_CAPACITY); - ctx->au_buffer.data_size = 0; - return 0; } From patchwork Sat Jun 17 15:18:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42173 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp2297512pzb; Sat, 17 Jun 2023 08:19:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4EqHgTvWc+QNH0G5twtDnGqFOafUdOTFYqLOvdPnO6HYeVdHkgjJEoQBFkwnLboAFOEH0s X-Received: by 2002:a17:906:5d0c:b0:982:26c5:d05c with SMTP id g12-20020a1709065d0c00b0098226c5d05cmr5852689ejt.7.1687015162104; Sat, 17 Jun 2023 08:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687015162; cv=none; d=google.com; s=arc-20160816; b=rtKkupb9Eo/pJR9xbBkIHJZeNvo3X9RbWC0o3R8HIdDlvkQ7QXzoFsJpYcOJWa75ne CQ0Jut4j8QvH1uZ1hQU6JP5Ui9uL3sKqJRAdzbBmFz+SdugYczXo0vERRQKTmq1XQ1Um h7t5LQ371Kf07EIJ8J4hj7T9catvSSBxUqD5bRpIbqHGUkpcnHsWrgE1ri4LjbcpuCIR /N6xFjViT72nnGmnlPfBrgG4TAoQJJKg85lYy+O/tEFk2cCRmP29BgkXclG3eCTiCFOE fy+AJIrFHarbOJN/2mkqWSInuSEtn1sOo++uDdmqC5SozRV+R2YAR3vkeQqdyVPYhYee pdNw== 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=WMJZzo4jANfJ82W20uWN2OqiKA41B303CYPp3i105GI=; b=PelonWcjc4UL0T3vPtnlymerP5pmPGu0jJ8TuCla2m4UUmOA0SWpPZ86WUhWdbNAcL tjdMZe54N6xGeTbg89AGrUTQFH3PttuxVcPJvnYt4bmlcHrkudTzucD5ectSxCY+uEKM ZxKKZxVqsl6GSPDImhPRtL5LNdrGCaEdlykUUjJwCY6OX6aWVAJjhVyTA2UA75F3WFiV Yo6vjqxReeXSXKKxsejCwV8Fv4633rWK4CHkuQyqqZfJ0OdflkSfzEThO43hCDufXxj9 P5ZQO5PF6nvrcGZ0QPLfoQj/CPk0UAsGw6nlBiOGOrL826focbI3colGQ67N597e5ibf 0x1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=BTJh3OfJ; 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 n17-20020a170906165100b0096633b5c0aesi3461739ejd.809.2023.06.17.08.19.21; Sat, 17 Jun 2023 08:19:22 -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=BTJh3OfJ; 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 7B4BD68C3B0; Sat, 17 Jun 2023 18:19:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D26C768C09C for ; Sat, 17 Jun 2023 18:19:00 +0300 (EEST) Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-55af44f442dso1299082eaf.1 for ; Sat, 17 Jun 2023 08:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687015139; x=1689607139; 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=jvksy0Zs8edtbUaRjOtRIECsmgBu9zcu77ROzm+r5ss=; b=BTJh3OfJ776WgF+h8Jh5Ey7Szt2TNuas3HUzHDbc6I5RlJ4ZSw4aYTRt1v+n/lXVHa Sw+Y/FREj0x68olIHpGHLuuWtvw/mugOZNUCjwe45CmYxXeh6OYe73UkEvvnf9ehyWQY +SJZa0psKi/4w8GnUJ9ifhxWy83pdlI0ZXVTrmUSuwwa13R+t49CDaHKBTcl42SWlbio zmPTiQf1eGuE9ByzNSlSwsfhw+zifp2ej0YkdSJ5vMVfv0VN5Y2V46XLVXBWPYCZXVFu IX9YUJFFdSmCETszxDNV7dNPu8am4aavoYsqsvcAhCzOK7nhGJSqrkFc4AiU7s5+6Ciq ttIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687015139; x=1689607139; 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=jvksy0Zs8edtbUaRjOtRIECsmgBu9zcu77ROzm+r5ss=; b=SpjsYaE4+TatZ6H/Mxabw6lfEltB9ExQneScjAwmoQv+Bwsh6/YeCVYrHb/8bkfIpd Bz2SnilKugYHoLUbbKi0BOWlyYwc01pyt4s8wCMeLh9QGq5ssTGi3rMiZahiSMsE/3lq LczDen3YIqvx5/wWcrOkklYWjW67eI08dW4DCmjSmqQW5WK/IWUlwgzlJF3PNxtYKaZp NjFtuyK7WLaa8qmwegKcZeSBiFpGATjIaMBAPMhk2zd2h72SGXgOIMVVkZsmCs05kZg4 kfGpU8lxZJHoX3eo3w65WEPtDL+7SVe5Ehm1MbaPCn46snsavTt1U+mdKwYF7YUcACYD GaDw== X-Gm-Message-State: AC+VfDzYgsuCpJcDU3OQSA95PyDcyzw8ALodmA1Y0tBzcwqY43dCDr7A ouaT/ZfIShsWiDJUoyedeg4meIvJLHA= X-Received: by 2002:aca:6106:0:b0:38e:ca21:db29 with SMTP id v6-20020aca6106000000b0038eca21db29mr6780173oib.27.1687015138865; Sat, 17 Jun 2023 08:18:58 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id j189-20020acab9c6000000b0039600e3376asm9533452oif.1.2023.06.17.08.18.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 08:18:58 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Jun 2023 12:18:47 -0300 Message-ID: <20230617151848.1378-2-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 2/3] avcodec/evc_frame_merge_bsf: use av_new_packet() 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: Ki1GaMKhRFd2 This ensures the buffer is padded as required by the AVPacket API. Signed-off-by: James Almer --- libavcodec/evc_frame_merge_bsf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c index 827f114f0b..540bb63631 100644 --- a/libavcodec/evc_frame_merge_bsf.c +++ b/libavcodec/evc_frame_merge_bsf.c @@ -114,14 +114,14 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) av_packet_unref(in); if (au_end_found) { - uint8_t *data = av_memdup(ctx->au_buffer.data, ctx->au_buffer.data_size); size_t data_size = ctx->au_buffer.data_size; ctx->au_buffer.data_size = 0; - if (!data) - return AVERROR(ENOMEM); + err = av_new_packet(out, data_size); + if (err < 0) + return err; - err = av_packet_from_data(out, data, data_size); + memcpy(out->data, ctx->au_buffer.data, data_size); } else err = AVERROR(EAGAIN); From patchwork Sat Jun 17 15:18:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42174 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp2297560pzb; Sat, 17 Jun 2023 08:19:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67FNL2rOlqXxUgvvUqs3DlHpBSx8yG4jqy1PeqUbTMu3NWt175ImreBD0O8v80w3YwxrKd X-Received: by 2002:a17:907:1ca3:b0:988:565f:bf46 with SMTP id nb35-20020a1709071ca300b00988565fbf46mr230810ejc.32.1687015170882; Sat, 17 Jun 2023 08:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687015170; cv=none; d=google.com; s=arc-20160816; b=Kq0XQFV9K8TeeS8HXw1YyGBzxiGwFtf64DniMEDaUCEOPnxZwYHgumTdZyZTQ/aNew IAjRcSdcIPNk+h/e0N2KLdkD6c96pcNGCbevlZKmJIfsGX6/uotE0Tuya13py8X00N2l WQwcIZt1ZU/2eNNeJ9XuqvmW+pDSH3F/Jxl+fdB99qXfyQG5kpUSdAW1uWC/OsC02ui2 Xou7Ils/29vLGh16QdENSmHIjWQtq+j/VPhyU8jwGOUGOZsPiQXu/oIsX8HTvvLwf4Uh BS2YjItnHnpYSKlWA0jZaf4j4pYPoeDrxnbMMAEI9lVRCDGvT73Q+SFfB7NuCZUOIRNL WzsA== 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=OpcosEr+CF8QOsWVzxRjL9cMTt+Rvdj6cMGmn/+4hbA=; b=C0pBlp6YjPe4lVV7smsim2lfa7nhhXOvBNb6UKGbblcccXsTkMiWqe5dKLmwngF/vQ dh2S0zfGbJxxiWfUhR7bdemJzfFI1aN6de0DKVbwJgvjklP/btzsU5+x/DwS6SLPaDux q5meMEbOFBKt5iNl43tdku7Jc1CfnfUmTsRpyw8HT48q7tFWV/M5v3/8ZqKFd3HCLvlh M8itODLkmJ4xo0jYB+ooa42ejlrjZAli/YLlmG0GrVcqDUdX2jsnfDnuUjjiPywyWidH QQxS2Fn2BAte/DrY7J8M4CkRy3vmpYYmcjDJJ7KY8BlwmhnbC0+dSfEG5ox7AM47eViV n+tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=KZVnu9ku; 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 z19-20020a170906945300b00977cc09e9f6si11324372ejx.979.2023.06.17.08.19.30; Sat, 17 Jun 2023 08:19:30 -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=KZVnu9ku; 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 756AF68C39C; Sat, 17 Jun 2023 18:19:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 47D7B68C3AA for ; Sat, 17 Jun 2023 18:19:02 +0300 (EEST) Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-39ce64700cbso1494897b6e.0 for ; Sat, 17 Jun 2023 08:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687015140; x=1689607140; 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=hvO7TL6IKPfWNUQOcMEVW1YBeWyUB1h7E8PD6t9w58E=; b=KZVnu9kuIK7bntKbdPsjTInlsjv5N0WZQztE/8QMmsN218VA3h1UvGMgYFbVILfg4y cJ2a/R/kqdzfjdPkry5kjtC+tuevbZlHDBxoWkXi00oNNJ7pbhIfyKydizVdBZoxiXC2 IcpVWS7JmqxcQzL37qDnAcMFGC0MLNifuxPgenaj/xOGW7aYZRY4qMe7z7ILXMLZZtYY v/GFeGKovox/MKgisFzmM6zfMYjZGB6kX9qHHezsO30TbA5uI+5WvdZeuccMMXgsHDId Y8CXUcnKMRfHYonU19wzhSUWgiR221OLh60p9fLYMCE3jBYO0G4/CWWZEgtfDMnXiRaw nKKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687015140; x=1689607140; 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=hvO7TL6IKPfWNUQOcMEVW1YBeWyUB1h7E8PD6t9w58E=; b=ZUzHTQwI2zeKVD5/gVmBQjW0OpLWZF6z5H8nbi/JtCGT/ejNS8lwg13dlJFOVWeaUb hmGF2hExjEkXFXiCuVoeJKsEnRL+/KumRsNJZs03HFXnmFVeLuD2vCi1CbJLOjC3yfZj x9Cf8fhU1VhhqIuMuxlWZNTV2KmXzh8aiBJCeUK8pPRsJqG4j6uam88RvTKORTJgpEq7 q7n3DNNYk7vO6dmnj4XvmZ+dD0RW1b35c+ZZFzeb+Fz1U0f/PVJ7aJ5qK9SREMrJoUId 32iNcL+2HWttJCfjMaBb0JDotkfpkls7UI3nI5j+cK2+qhwAeDr151M8E28AxzFc9v0D /sjQ== X-Gm-Message-State: AC+VfDzs8E9Lr2Z5TwKKJazG7EKlLl2jSlnJBRfEkWcd2sKx9XVI0g5b xFqE3EBGntZLqQY4avlYC3MIjdZPpFE= X-Received: by 2002:a05:6808:1152:b0:399:8529:672c with SMTP id u18-20020a056808115200b003998529672cmr7265860oiu.33.1687015140260; Sat, 17 Jun 2023 08:19:00 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id j189-20020acab9c6000000b0039600e3376asm9533452oif.1.2023.06.17.08.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 08:18:59 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Jun 2023 12:18:48 -0300 Message-ID: <20230617151848.1378-3-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 3/3] fate/lavf-container: add a test to remux raw evc into mp4 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: Mnh+iEuUkyyK Signed-off-by: James Almer --- tests/fate/lavf-container.mak | 2 ++ tests/ref/lavf-fate/evc.mp4 | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 tests/ref/lavf-fate/evc.mp4 diff --git a/tests/fate/lavf-container.mak b/tests/fate/lavf-container.mak index 93740475b4..0d4a224601 100644 --- a/tests/fate/lavf-container.mak +++ b/tests/fate/lavf-container.mak @@ -71,6 +71,7 @@ FATE_AVCONV += $(FATE_LAVF_CONTAINER) fate-lavf-container fate-lavf: $(FATE_LAVF_CONTAINER) FATE_LAVF_CONTAINER_FATE-$(call ALLYES, IVF_DEMUXER AV1_PARSER MOV_MUXER) += av1.mp4 +FATE_LAVF_CONTAINER_FATE-$(call ALLYES, EVC_DEMUXER EVC_PARSER MOV_MUXER) += evc.mp4 FATE_LAVF_CONTAINER_FATE-$(call ALLYES, IVF_DEMUXER AV1_PARSER MATROSKA_MUXER) += av1.mkv FATE_LAVF_CONTAINER_FATE-$(call ALLYES, H264_DEMUXER H264_PARSER MOV_MUXER) += h264.mp4 FATE_LAVF_CONTAINER_FATE-$(call ALLYES, MATROSKA_DEMUXER OGG_MUXER) += vp3.ogg @@ -87,6 +88,7 @@ $(FATE_LAVF_CONTAINER_FATE): $(AREF) $(VREF) fate-lavf-fate-av1.mp4: CMD = lavf_container_fate "av1-test-vectors/av1-1-b8-05-mv.ivf" "" "-c:v copy" fate-lavf-fate-av1.mkv: CMD = lavf_container_fate "av1-test-vectors/av1-1-b8-05-mv.ivf" "" "-c:v copy" +fate-lavf-fate-evc.mp4: CMD = lavf_container_fate "evc/akiyo_cif.evc" "" "-c:v copy" fate-lavf-fate-h264.mp4: CMD = lavf_container_fate "h264/intra_refresh.h264" "" "-c:v copy" fate-lavf-fate-vp3.ogg: CMD = lavf_container_fate "vp3/coeff_level64.mkv" "-idct auto" fate-lavf-fate-vp8.ogg: CMD = lavf_container_fate "vp8/RRSF49-short.webm" "" "-acodec copy" diff --git a/tests/ref/lavf-fate/evc.mp4 b/tests/ref/lavf-fate/evc.mp4 new file mode 100644 index 0000000000..b0afa350ac --- /dev/null +++ b/tests/ref/lavf-fate/evc.mp4 @@ -0,0 +1,3 @@ +55294f868fa3b31d34a48344c4f72630 *tests/data/lavf-fate/lavf.evc.mp4 +37386 tests/data/lavf-fate/lavf.evc.mp4 +tests/data/lavf-fate/lavf.evc.mp4 CRC=0x48063f85 From patchwork Sat Jun 17 22:00:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42176 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp2448230pzb; Sat, 17 Jun 2023 15:00:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7z7osvGmq3OTKgPKZbnKdOru8wRlUVQ6/41To2HPUcsalLFr9W0xdLzjCCwOe8mGUYNP6V X-Received: by 2002:a05:6402:498:b0:519:b784:b157 with SMTP id k24-20020a056402049800b00519b784b157mr3460679edv.12.1687039255119; Sat, 17 Jun 2023 15:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687039255; cv=none; d=google.com; s=arc-20160816; b=gyrbG3jt/v/r7SCkdBrpTeDsEsIRbFr1DDHMi1mmPz8iWGWAXhJRRzIkydLehUf5B5 fByjRNm7aI5ozBuRvlufe7dfIRqztt5rZ1ZzcQ/uJsuSrz4A5sn9Fgp0HSMhsaM7goUb lZHjW4YJZhTKSF2ztoEzkqXoGxKxcNpT5ubHknB6NuSZBoSg9DeyFVVVsTwXWSmF8Z68 dqo/fAgB7/y1nl9j4us6iS+fWIwxwecGgR+boW4gBStWctQ74jtFq00rFcpipaQUFFz9 ehutO8zbnnUVhyBVZf+DLhQHYvEyHO2ALrVEvB4SwC59+LVnkNm0rK+1KWQEU0FE17rd PVTA== 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=Sc5QJsnrmNcunIYRhf96C7b70MIwTWs7Mm3JFG0wedc=; b=EvXf4RJTsKWuoO39zXiiqs0NmWpyrOvn+/Iqs8Wz0pZ/H9EazJtHO/S1/OHxR6r2Al AfgU7xmPAKWViHzm0V1ltftXXOS6nz9EOe0Z5XBQ4vwaU8tdfQdujAbArFykd+gCnjdX WlmT0bLT9wD0+stW2PsHPuVXSPaEpqDbR306fzDDE8Bygvq6vrLEdfN6Jv9VfIX9YceN sGKWJstExuTiu9+pISfX+PMmo1Pf038XBihWsX3tzkqlt5cJeIg0zcU0vNFsQths0il9 cV+DxT7L3h8+SiWx6vVxuR0X09BdLkBCcLWZvdAVGY2wHx2FCLAFTO9Ww7W/Rnw9P5vv fElw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=B4zoEvhs; 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 f1-20020a056402160100b005184305b356si3696078edv.14.2023.06.17.15.00.54; Sat, 17 Jun 2023 15:00:55 -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=B4zoEvhs; 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 8142D68BF30; Sun, 18 Jun 2023 01:00:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D60568B14C for ; Sun, 18 Jun 2023 01:00:44 +0300 (EEST) Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-1a9a42edfc9so1950179fac.0 for ; Sat, 17 Jun 2023 15:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687039242; x=1689631242; 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=oVAZE8daACbeixr/ndYuWfUjmVr4JXZFPcNnk7lfeAY=; b=B4zoEvhsEwDNl5zakpidQIH6EObY4bkfOu50ydG620MkvPMFWXdUxXp4NgC1GLcQqI xVeWdNN61rRwq4UMrQqbmAVfTG6CFv/n/V7pa/nWUv9FFPDqiH3z7dJUPLur+k/ZH2gh Yg08F8h4Z9nkXrPa3AcfXsv0ufoGi8s81y1Rn4cAvD3L21I0YElqTtwCwrCQCRvtvvGg U5yrpnms1/gckxe3ChCOrhc90rl6pOPzAp/G+ccZ1mX9rIlTwokSKNojZnugwPw3d8Wn hk2kfycOsgD3MDcEml+LaVJqNzFETgP3aAj40MpR05r3hMaKevuuFjeKjGRbCJ6yzGEr 7tBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687039242; x=1689631242; 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=oVAZE8daACbeixr/ndYuWfUjmVr4JXZFPcNnk7lfeAY=; b=aE03QKMEmKNNIrCfj8TvxAYGnWmOyGgkI8mXdXOSRgAjC7unsFHMLYfl0ZQ3gzCFKq ygxG0/7uFcvVNaFVspS8DMUusyo7wOP1pi6m0A5SPcTeaKcoCKWx6S5so80pkq6I9v8p LQyyl4LFppTNDzVsTOCeXq3OaTsoeAuBN5AlMO4AK1IVNEmbhOhSflVSQ7qaB2AI23JG 6FB/O4Q3rj09jQjsXxsXXEPvJRRlsAwLfIgUWah9cc54HtgbTkTNrAau1bSKwsv9fTYs 9SMEZ8U/zzFPtPfJhHBD06VOjs+OCabpBkLRpwF1odLqZrM1u9P+e/v0AVf1UgwerMuf N+HQ== X-Gm-Message-State: AC+VfDziRufyTM5kBu/1BA+Vh4UnaAN7agMqeMpZWo9rZ+LBCn40JZj8 mmb2CST6zWtgUm6LKq745w2IbxSmtFQ= X-Received: by 2002:a05:6870:e147:b0:195:f440:40e9 with SMTP id z7-20020a056870e14700b00195f44040e9mr1901399oaa.31.1687039241451; Sat, 17 Jun 2023 15:00:41 -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.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 15:00:40 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Jun 2023 19:00:09 -0300 Message-ID: <20230617220015.12669-1-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 04/10] avcodec/evc_parse: split off Parameter Set parsing into its own file 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: X59RI2uA/1zo Signed-off-by: James Almer --- libavcodec/Makefile | 2 +- libavcodec/evc_frame_merge_bsf.c | 4 +- libavcodec/evc_parse.c | 371 +----------------------------- libavcodec/evc_parse.h | 198 +--------------- libavcodec/evc_parser.c | 2 +- libavcodec/evc_ps.c | 381 +++++++++++++++++++++++++++++++ libavcodec/evc_ps.h | 228 ++++++++++++++++++ 7 files changed, 621 insertions(+), 565 deletions(-) create mode 100644 libavcodec/evc_ps.c create mode 100644 libavcodec/evc_ps.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 0ce8fe5b9c..723bfa25c7 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -84,7 +84,7 @@ OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o OBJS-$(CONFIG_DEFLATE_WRAPPER) += zlib_wrapper.o OBJS-$(CONFIG_DOVI_RPU) += dovi_rpu.o OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o -OBJS-$(CONFIG_EVCPARSE) += evc_parse.o +OBJS-$(CONFIG_EVCPARSE) += evc_parse.o evc_ps.o OBJS-$(CONFIG_EXIF) += exif.o tiff_common.o OBJS-$(CONFIG_FAANDCT) += faandct.o OBJS-$(CONFIG_FAANIDCT) += faanidct.o diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c index 540bb63631..f497780afb 100644 --- a/libavcodec/evc_frame_merge_bsf.c +++ b/libavcodec/evc_frame_merge_bsf.c @@ -58,7 +58,7 @@ static void evc_frame_merge_flush(AVBSFContext *bsf) { EVCFMergeContext *ctx = bsf->priv_data; - ff_evc_parse_free(&ctx->parser_ctx); + ff_evc_ps_free(&ctx->parser_ctx.ps); av_packet_unref(ctx->in); ctx->au_buffer.data_size = 0; } @@ -147,7 +147,7 @@ static void evc_frame_merge_close(AVBSFContext *bsf) EVCFMergeContext *ctx = bsf->priv_data; av_packet_free(&ctx->in); - ff_evc_parse_free(&ctx->parser_ctx); + ff_evc_ps_free(&ctx->parser_ctx.ps); ctx->au_buffer.capacity = 0; av_freep(&ctx->au_buffer.data); diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c index 44be5c5291..a8e6356b96 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -21,8 +21,6 @@ #include "evc.h" #include "evc_parse.h" -#define EXTENDED_SAR 255 - #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] = { @@ -71,355 +69,6 @@ int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx) return temporal_id; } -// @see ISO_IEC_23094-1 (7.3.7 Reference picture list structure syntax) -static int ref_pic_list_struct(GetBitContext *gb, RefPicListStruct *rpl) -{ - uint32_t delta_poc_st, strp_entry_sign_flag = 0; - rpl->ref_pic_num = get_ue_golomb(gb); - if (rpl->ref_pic_num > 0) { - delta_poc_st = get_ue_golomb(gb); - - rpl->ref_pics[0] = delta_poc_st; - if (rpl->ref_pics[0] != 0) { - strp_entry_sign_flag = get_bits(gb, 1); - - rpl->ref_pics[0] *= 1 - (strp_entry_sign_flag << 1); - } - } - - for (int i = 1; i < rpl->ref_pic_num; ++i) { - delta_poc_st = get_ue_golomb(gb); - if (delta_poc_st != 0) - strp_entry_sign_flag = get_bits(gb, 1); - rpl->ref_pics[i] = rpl->ref_pics[i - 1] + delta_poc_st * (1 - (strp_entry_sign_flag << 1)); - } - - return 0; -} - -// @see ISO_IEC_23094-1 (E.2.2 HRD parameters syntax) -static int hrd_parameters(GetBitContext *gb, HRDParameters *hrd) -{ - hrd->cpb_cnt_minus1 = get_ue_golomb(gb); - hrd->bit_rate_scale = get_bits(gb, 4); - hrd->cpb_size_scale = get_bits(gb, 4); - for (int SchedSelIdx = 0; SchedSelIdx <= hrd->cpb_cnt_minus1; SchedSelIdx++) { - hrd->bit_rate_value_minus1[SchedSelIdx] = get_ue_golomb(gb); - hrd->cpb_size_value_minus1[SchedSelIdx] = get_ue_golomb(gb); - hrd->cbr_flag[SchedSelIdx] = get_bits(gb, 1); - } - hrd->initial_cpb_removal_delay_length_minus1 = get_bits(gb, 5); - hrd->cpb_removal_delay_length_minus1 = get_bits(gb, 5); - hrd->cpb_removal_delay_length_minus1 = get_bits(gb, 5); - hrd->time_offset_length = get_bits(gb, 5); - - return 0; -} - -// @see ISO_IEC_23094-1 (E.2.1 VUI parameters syntax) -static int vui_parameters(GetBitContext *gb, VUIParameters *vui) -{ - vui->aspect_ratio_info_present_flag = get_bits(gb, 1); - if (vui->aspect_ratio_info_present_flag) { - vui->aspect_ratio_idc = get_bits(gb, 8); - if (vui->aspect_ratio_idc == EXTENDED_SAR) { - vui->sar_width = get_bits(gb, 16); - vui->sar_height = get_bits(gb, 16); - } - } - vui->overscan_info_present_flag = get_bits(gb, 1); - if (vui->overscan_info_present_flag) - vui->overscan_appropriate_flag = get_bits(gb, 1); - vui->video_signal_type_present_flag = get_bits(gb, 1); - if (vui->video_signal_type_present_flag) { - vui->video_format = get_bits(gb, 3); - vui->video_full_range_flag = get_bits(gb, 1); - vui->colour_description_present_flag = get_bits(gb, 1); - if (vui->colour_description_present_flag) { - vui->colour_primaries = get_bits(gb, 8); - vui->transfer_characteristics = get_bits(gb, 8); - vui->matrix_coefficients = get_bits(gb, 8); - } - } - vui->chroma_loc_info_present_flag = get_bits(gb, 1); - if (vui->chroma_loc_info_present_flag) { - vui->chroma_sample_loc_type_top_field = get_ue_golomb(gb); - vui->chroma_sample_loc_type_bottom_field = get_ue_golomb(gb); - } - vui->neutral_chroma_indication_flag = get_bits(gb, 1); - - vui->field_seq_flag = get_bits(gb, 1); - - vui->timing_info_present_flag = get_bits(gb, 1); - if (vui->timing_info_present_flag) { - vui->num_units_in_tick = get_bits(gb, 32); - vui->time_scale = get_bits(gb, 32); - vui->fixed_pic_rate_flag = get_bits(gb, 1); - } - vui->nal_hrd_parameters_present_flag = get_bits(gb, 1); - if (vui->nal_hrd_parameters_present_flag) - hrd_parameters(gb, &vui->hrd_parameters); - vui->vcl_hrd_parameters_present_flag = get_bits(gb, 1); - if (vui->vcl_hrd_parameters_present_flag) - hrd_parameters(gb, &vui->hrd_parameters); - if (vui->nal_hrd_parameters_present_flag || vui->vcl_hrd_parameters_present_flag) - vui->low_delay_hrd_flag = get_bits(gb, 1); - vui->pic_struct_present_flag = get_bits(gb, 1); - vui->bitstream_restriction_flag = get_bits(gb, 1); - if (vui->bitstream_restriction_flag) { - vui->motion_vectors_over_pic_boundaries_flag = get_bits(gb, 1); - vui->max_bytes_per_pic_denom = get_ue_golomb(gb); - vui->max_bits_per_mb_denom = get_ue_golomb(gb); - vui->log2_max_mv_length_horizontal = get_ue_golomb(gb); - vui->log2_max_mv_length_vertical = get_ue_golomb(gb); - vui->num_reorder_pics = get_ue_golomb(gb); - vui->max_dec_pic_buffering = get_ue_golomb(gb); - } - - return 0; -} - -// @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) -EVCParserSPS *ff_evc_parse_sps(EVCParserContext *ctx, const uint8_t *bs, int bs_size) -{ - GetBitContext gb; - EVCParserSPS *sps; - int sps_seq_parameter_set_id; - - if (init_get_bits8(&gb, bs, bs_size) < 0) - return NULL; - - sps_seq_parameter_set_id = get_ue_golomb(&gb); - - if (sps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) - return NULL; - - if(!ctx->sps[sps_seq_parameter_set_id]) { - if((ctx->sps[sps_seq_parameter_set_id] = av_malloc(sizeof(EVCParserSPS))) == NULL) - return NULL; - } - - sps = ctx->sps[sps_seq_parameter_set_id]; - memset(sps, 0, sizeof(*sps)); - - sps->sps_seq_parameter_set_id = sps_seq_parameter_set_id; - - // the Baseline profile is indicated by profile_idc eqal to 0 - // the Main profile is indicated by profile_idc eqal to 1 - sps->profile_idc = get_bits(&gb, 8); - - sps->level_idc = get_bits(&gb, 8); - - skip_bits_long(&gb, 32); /* skip toolset_idc_h */ - skip_bits_long(&gb, 32); /* skip toolset_idc_l */ - - // 0 - monochrome - // 1 - 4:2:0 - // 2 - 4:2:2 - // 3 - 4:4:4 - sps->chroma_format_idc = get_ue_golomb(&gb); - - sps->pic_width_in_luma_samples = get_ue_golomb(&gb); - sps->pic_height_in_luma_samples = get_ue_golomb(&gb); - - sps->bit_depth_luma_minus8 = get_ue_golomb(&gb); - sps->bit_depth_chroma_minus8 = get_ue_golomb(&gb); - - sps->sps_btt_flag = get_bits(&gb, 1); - if (sps->sps_btt_flag) { - sps->log2_ctu_size_minus5 = get_ue_golomb(&gb); - sps->log2_min_cb_size_minus2 = get_ue_golomb(&gb); - sps->log2_diff_ctu_max_14_cb_size = get_ue_golomb(&gb); - sps->log2_diff_ctu_max_tt_cb_size = get_ue_golomb(&gb); - sps->log2_diff_min_cb_min_tt_cb_size_minus2 = get_ue_golomb(&gb); - } - - sps->sps_suco_flag = get_bits(&gb, 1); - if (sps->sps_suco_flag) { - sps->log2_diff_ctu_size_max_suco_cb_size = get_ue_golomb(&gb); - sps->log2_diff_max_suco_min_suco_cb_size = get_ue_golomb(&gb); - } - - sps->sps_admvp_flag = get_bits(&gb, 1); - if (sps->sps_admvp_flag) { - sps->sps_affine_flag = get_bits(&gb, 1); - sps->sps_amvr_flag = get_bits(&gb, 1); - sps->sps_dmvr_flag = get_bits(&gb, 1); - sps->sps_mmvd_flag = get_bits(&gb, 1); - sps->sps_hmvp_flag = get_bits(&gb, 1); - } - - sps->sps_eipd_flag = get_bits(&gb, 1); - if (sps->sps_eipd_flag) { - sps->sps_ibc_flag = get_bits(&gb, 1); - if (sps->sps_ibc_flag) - sps->log2_max_ibc_cand_size_minus2 = get_ue_golomb(&gb); - } - - sps->sps_cm_init_flag = get_bits(&gb, 1); - if (sps->sps_cm_init_flag) - sps->sps_adcc_flag = get_bits(&gb, 1); - - sps->sps_iqt_flag = get_bits(&gb, 1); - if (sps->sps_iqt_flag) - sps->sps_ats_flag = get_bits(&gb, 1); - - sps->sps_addb_flag = get_bits(&gb, 1); - sps->sps_alf_flag = get_bits(&gb, 1); - sps->sps_htdf_flag = get_bits(&gb, 1); - sps->sps_rpl_flag = get_bits(&gb, 1); - sps->sps_pocs_flag = get_bits(&gb, 1); - sps->sps_dquant_flag = get_bits(&gb, 1); - sps->sps_dra_flag = get_bits(&gb, 1); - - if (sps->sps_pocs_flag) - sps->log2_max_pic_order_cnt_lsb_minus4 = get_ue_golomb(&gb); - - if (!sps->sps_pocs_flag || !sps->sps_rpl_flag) { - sps->log2_sub_gop_length = get_ue_golomb(&gb); - if (sps->log2_sub_gop_length == 0) - sps->log2_ref_pic_gap_length = get_ue_golomb(&gb); - } - - if (!sps->sps_rpl_flag) - sps->max_num_tid0_ref_pics = get_ue_golomb(&gb); - else { - sps->sps_max_dec_pic_buffering_minus1 = get_ue_golomb(&gb); - sps->long_term_ref_pic_flag = get_bits(&gb, 1); - sps->rpl1_same_as_rpl0_flag = get_bits(&gb, 1); - sps->num_ref_pic_list_in_sps[0] = get_ue_golomb(&gb); - - for (int i = 0; i < sps->num_ref_pic_list_in_sps[0]; ++i) - ref_pic_list_struct(&gb, &sps->rpls[0][i]); - - if (!sps->rpl1_same_as_rpl0_flag) { - sps->num_ref_pic_list_in_sps[1] = get_ue_golomb(&gb); - for (int i = 0; i < sps->num_ref_pic_list_in_sps[1]; ++i) - ref_pic_list_struct(&gb, &sps->rpls[1][i]); - } - } - - sps->picture_cropping_flag = get_bits(&gb, 1); - - if (sps->picture_cropping_flag) { - sps->picture_crop_left_offset = get_ue_golomb(&gb); - sps->picture_crop_right_offset = get_ue_golomb(&gb); - sps->picture_crop_top_offset = get_ue_golomb(&gb); - sps->picture_crop_bottom_offset = get_ue_golomb(&gb); - } - - if (sps->chroma_format_idc != 0) { - sps->chroma_qp_table_struct.chroma_qp_table_present_flag = get_bits(&gb, 1); - - if (sps->chroma_qp_table_struct.chroma_qp_table_present_flag) { - sps->chroma_qp_table_struct.same_qp_table_for_chroma = get_bits(&gb, 1); - sps->chroma_qp_table_struct.global_offset_flag = get_bits(&gb, 1); - for (int i = 0; i < (sps->chroma_qp_table_struct.same_qp_table_for_chroma ? 1 : 2); i++) { - sps->chroma_qp_table_struct.num_points_in_qp_table_minus1[i] = get_ue_golomb(&gb);; - for (int j = 0; j <= sps->chroma_qp_table_struct.num_points_in_qp_table_minus1[i]; j++) { - sps->chroma_qp_table_struct.delta_qp_in_val_minus1[i][j] = get_bits(&gb, 6); - sps->chroma_qp_table_struct.delta_qp_out_val[i][j] = get_se_golomb(&gb); - } - } - } - } - - sps->vui_parameters_present_flag = get_bits(&gb, 1); - if (sps->vui_parameters_present_flag) - vui_parameters(&gb, &(sps->vui_parameters)); - - // @note - // If necessary, add the missing fields to the EVCParserSPS structure - // and then extend parser implementation - - return sps; -} - -// @see ISO_IEC_23094-1 (7.3.2.2 SPS RBSP syntax) -// -// @note -// The current implementation of parse_sps function doesn't handle VUI parameters parsing. -// If it will be needed, parse_sps function could be extended to handle VUI parameters parsing -// to initialize fields of the AVCodecContex i.e. color_primaries, color_trc,color_range -// -EVCParserPPS *ff_evc_parse_pps(EVCParserContext *ctx, const uint8_t *bs, int bs_size) -{ - GetBitContext gb; - EVCParserPPS *pps; - - int pps_pic_parameter_set_id; - - if (init_get_bits8(&gb, bs, bs_size) < 0) - return NULL; - - pps_pic_parameter_set_id = get_ue_golomb(&gb); - if (pps_pic_parameter_set_id > EVC_MAX_PPS_COUNT) - return NULL; - - if(!ctx->pps[pps_pic_parameter_set_id]) { - if ((ctx->pps[pps_pic_parameter_set_id] = av_malloc(sizeof(EVCParserPPS))) == NULL) - return NULL; - } - - pps = ctx->pps[pps_pic_parameter_set_id]; - memset(pps, 0, sizeof(*pps)); - - pps->pps_pic_parameter_set_id = pps_pic_parameter_set_id; - - pps->pps_seq_parameter_set_id = get_ue_golomb(&gb); - if (pps->pps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) { - av_freep(&ctx->pps[pps_pic_parameter_set_id]); - return NULL; - } - - pps->num_ref_idx_default_active_minus1[0] = get_ue_golomb(&gb); - pps->num_ref_idx_default_active_minus1[1] = get_ue_golomb(&gb); - pps->additional_lt_poc_lsb_len = get_ue_golomb(&gb); - pps->rpl1_idx_present_flag = get_bits(&gb, 1); - pps->single_tile_in_pic_flag = get_bits(&gb, 1); - - if (!pps->single_tile_in_pic_flag) { - pps->num_tile_columns_minus1 = get_ue_golomb(&gb); - pps->num_tile_rows_minus1 = get_ue_golomb(&gb); - pps->uniform_tile_spacing_flag = get_bits(&gb, 1); - - if (!pps->uniform_tile_spacing_flag) { - for (int i = 0; i < pps->num_tile_columns_minus1; i++) - pps->tile_column_width_minus1[i] = get_ue_golomb(&gb); - - for (int i = 0; i < pps->num_tile_rows_minus1; i++) - pps->tile_row_height_minus1[i] = get_ue_golomb(&gb); - } - pps->loop_filter_across_tiles_enabled_flag = get_bits(&gb, 1); - pps->tile_offset_len_minus1 = get_ue_golomb(&gb); - } - - pps->tile_id_len_minus1 = get_ue_golomb(&gb); - pps->explicit_tile_id_flag = get_bits(&gb, 1); - - if (pps->explicit_tile_id_flag) { - for (int i = 0; i <= pps->num_tile_rows_minus1; i++) { - for (int j = 0; j <= pps->num_tile_columns_minus1; j++) - pps->tile_id_val[i][j] = get_bits(&gb, pps->tile_id_len_minus1 + 1); - } - } - - pps->pic_dra_enabled_flag = 0; - pps->pic_dra_enabled_flag = get_bits(&gb, 1); - - if (pps->pic_dra_enabled_flag) - pps->pic_dra_aps_id = get_bits(&gb, 5); - - pps->arbitrary_slice_present_flag = get_bits(&gb, 1); - pps->constrained_intra_pred_flag = get_bits(&gb, 1); - pps->cu_qp_delta_enabled_flag = get_bits(&gb, 1); - - if (pps->cu_qp_delta_enabled_flag) - pps->log2_cu_qp_delta_area_minus6 = get_ue_golomb(&gb); - - return pps; -} - // @see ISO_IEC_23094-1 (7.3.2.6 Slice layer RBSP syntax) static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *sh, const uint8_t *bs, int bs_size) { @@ -439,11 +88,11 @@ static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *s if (slice_pic_parameter_set_id < 0 || slice_pic_parameter_set_id >= EVC_MAX_PPS_COUNT) return AVERROR_INVALIDDATA; - pps = ctx->pps[slice_pic_parameter_set_id]; + pps = ctx->ps.pps[slice_pic_parameter_set_id]; if(!pps) return AVERROR_INVALIDDATA; - sps = ctx->sps[pps->pps_seq_parameter_set_id]; + sps = ctx->ps.sps[pps->pps_seq_parameter_set_id]; if(!sps) return AVERROR_INVALIDDATA; @@ -579,7 +228,7 @@ int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_siz int SubGopLength; int bit_depth; - sps = ff_evc_parse_sps(ctx, data, nalu_size); + 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; @@ -642,7 +291,7 @@ int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_siz case EVC_PPS_NUT: { EVCParserPPS *pps; - pps = ff_evc_parse_pps(ctx, data, nalu_size); + 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; @@ -688,8 +337,8 @@ int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_siz // 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 - pps = ctx->pps[sh.slice_pic_parameter_set_id]; - sps = ctx->sps[pps->pps_seq_parameter_set_id]; + pps = ctx->ps.pps[sh.slice_pic_parameter_set_id]; + sps = ctx->ps.sps[pps->pps_seq_parameter_set_id]; av_assert0(sps && pps); if (sps->sps_pocs_flag) { @@ -764,11 +413,3 @@ int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_siz return 0; } - -void ff_evc_parse_free(EVCParserContext *ctx) { - for (int i = 0; i < EVC_MAX_SPS_COUNT; i++) - av_freep(&ctx->sps[i]); - - for (int i = 0; i < EVC_MAX_PPS_COUNT; i++) - av_freep(&ctx->pps[i]); -} diff --git a/libavcodec/evc_parse.h b/libavcodec/evc_parse.h index ee4b6c5708..b5462f5711 100644 --- a/libavcodec/evc_parse.h +++ b/libavcodec/evc_parse.h @@ -30,190 +30,7 @@ #include "libavutil/log.h" #include "libavutil/rational.h" #include "evc.h" - -#define EVC_MAX_QP_TABLE_SIZE 58 -#define NUM_CPB 32 - -// rpl structure -typedef struct RefPicListStruct { - int poc; - int tid; - int ref_pic_num; - int ref_pic_active_num; - int ref_pics[EVC_MAX_NUM_REF_PICS]; - char pic_type; - -} RefPicListStruct; - -// chromaQP table structure to be signalled in SPS -typedef struct ChromaQpTable { - int chroma_qp_table_present_flag; // u(1) - int same_qp_table_for_chroma; // u(1) - int global_offset_flag; // u(1) - int num_points_in_qp_table_minus1[2]; // ue(v) - int delta_qp_in_val_minus1[2][EVC_MAX_QP_TABLE_SIZE]; // u(6) - int delta_qp_out_val[2][EVC_MAX_QP_TABLE_SIZE]; // se(v) -} ChromaQpTable; - -// Hypothetical Reference Decoder (HRD) parameters, part of VUI -typedef struct HRDParameters { - int cpb_cnt_minus1; // ue(v) - int bit_rate_scale; // u(4) - int cpb_size_scale; // u(4) - int bit_rate_value_minus1[NUM_CPB]; // ue(v) - int cpb_size_value_minus1[NUM_CPB]; // ue(v) - int cbr_flag[NUM_CPB]; // u(1) - int initial_cpb_removal_delay_length_minus1; // u(5) - int cpb_removal_delay_length_minus1; // u(5) - int dpb_output_delay_length_minus1; // u(5) - int time_offset_length; // u(5) -} HRDParameters; - -// video usability information (VUI) part of SPS -typedef struct VUIParameters { - int aspect_ratio_info_present_flag; // u(1) - int aspect_ratio_idc; // u(8) - int sar_width; // u(16) - int sar_height; // u(16) - int overscan_info_present_flag; // u(1) - int overscan_appropriate_flag; // u(1) - int video_signal_type_present_flag; // u(1) - int video_format; // u(3) - int video_full_range_flag; // u(1) - int colour_description_present_flag; // u(1) - int colour_primaries; // u(8) - int transfer_characteristics; // u(8) - int matrix_coefficients; // u(8) - int chroma_loc_info_present_flag; // u(1) - int chroma_sample_loc_type_top_field; // ue(v) - int chroma_sample_loc_type_bottom_field; // ue(v) - int neutral_chroma_indication_flag; // u(1) - int field_seq_flag; // u(1) - int timing_info_present_flag; // u(1) - int num_units_in_tick; // u(32) - int time_scale; // u(32) - int fixed_pic_rate_flag; // u(1) - int nal_hrd_parameters_present_flag; // u(1) - int vcl_hrd_parameters_present_flag; // u(1) - int low_delay_hrd_flag; // u(1) - int pic_struct_present_flag; // u(1) - int bitstream_restriction_flag; // u(1) - int motion_vectors_over_pic_boundaries_flag; // u(1) - int max_bytes_per_pic_denom; // ue(v) - int max_bits_per_mb_denom; // ue(v) - int log2_max_mv_length_horizontal; // ue(v) - int log2_max_mv_length_vertical; // ue(v) - int num_reorder_pics; // ue(v) - int max_dec_pic_buffering; // ue(v) - - HRDParameters hrd_parameters; -} VUIParameters; - -// The sturcture reflects SPS RBSP(raw byte sequence payload) layout -// @see ISO_IEC_23094-1 section 7.3.2.1 -// -// The following descriptors specify the parsing process of each element -// u(n) - unsigned integer using n bits -// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with the left bit first -typedef struct EVCParserSPS { - int sps_seq_parameter_set_id; // ue(v) - int profile_idc; // u(8) - int level_idc; // u(8) - int toolset_idc_h; // u(32) - int toolset_idc_l; // u(32) - int chroma_format_idc; // ue(v) - int pic_width_in_luma_samples; // ue(v) - int pic_height_in_luma_samples; // ue(v) - int bit_depth_luma_minus8; // ue(v) - int bit_depth_chroma_minus8; // ue(v) - - int sps_btt_flag; // u(1) - int log2_ctu_size_minus5; // ue(v) - int log2_min_cb_size_minus2; // ue(v) - int log2_diff_ctu_max_14_cb_size; // ue(v) - int log2_diff_ctu_max_tt_cb_size; // ue(v) - int log2_diff_min_cb_min_tt_cb_size_minus2; // ue(v) - - int sps_suco_flag; // u(1) - int log2_diff_ctu_size_max_suco_cb_size; // ue(v) - int log2_diff_max_suco_min_suco_cb_size; // ue(v) - - int sps_admvp_flag; // u(1) - int sps_affine_flag; // u(1) - int sps_amvr_flag; // u(1) - int sps_dmvr_flag; // u(1) - int sps_mmvd_flag; // u(1) - int sps_hmvp_flag; // u(1) - - int sps_eipd_flag; // u(1) - int sps_ibc_flag; // u(1) - int log2_max_ibc_cand_size_minus2; // ue(v) - - int sps_cm_init_flag; // u(1) - int sps_adcc_flag; // u(1) - - int sps_iqt_flag; // u(1) - int sps_ats_flag; // u(1) - - int sps_addb_flag; // u(1) - int sps_alf_flag; // u(1) - int sps_htdf_flag; // u(1) - int sps_rpl_flag; // u(1) - int sps_pocs_flag; // u(1) - int sps_dquant_flag; // u(1) - int sps_dra_flag; // u(1) - - int log2_max_pic_order_cnt_lsb_minus4; // ue(v) - int log2_sub_gop_length; // ue(v) - int log2_ref_pic_gap_length; // ue(v) - - int max_num_tid0_ref_pics; // ue(v) - - int sps_max_dec_pic_buffering_minus1; // ue(v) - int long_term_ref_pic_flag; // u(1) - int rpl1_same_as_rpl0_flag; // u(1) - int num_ref_pic_list_in_sps[2]; // ue(v) - struct RefPicListStruct rpls[2][EVC_MAX_NUM_RPLS]; - - int picture_cropping_flag; // u(1) - int picture_crop_left_offset; // ue(v) - int picture_crop_right_offset; // ue(v) - int picture_crop_top_offset; // ue(v) - int picture_crop_bottom_offset; // ue(v) - - struct ChromaQpTable chroma_qp_table_struct; - - int vui_parameters_present_flag; // u(1) - - struct VUIParameters vui_parameters; - -} EVCParserSPS; - -typedef struct EVCParserPPS { - int pps_pic_parameter_set_id; // ue(v) - int pps_seq_parameter_set_id; // ue(v) - int num_ref_idx_default_active_minus1[2]; // ue(v) - int additional_lt_poc_lsb_len; // ue(v) - int rpl1_idx_present_flag; // u(1) - int single_tile_in_pic_flag; // u(1) - int num_tile_columns_minus1; // ue(v) - int num_tile_rows_minus1; // ue(v) - int uniform_tile_spacing_flag; // u(1) - int tile_column_width_minus1[EVC_MAX_TILE_ROWS]; // ue(v) - int tile_row_height_minus1[EVC_MAX_TILE_COLUMNS]; // ue(v) - int loop_filter_across_tiles_enabled_flag; // u(1) - int tile_offset_len_minus1; // ue(v) - int tile_id_len_minus1; // ue(v) - int explicit_tile_id_flag; // u(1) - int tile_id_val[EVC_MAX_TILE_ROWS][EVC_MAX_TILE_COLUMNS]; // u(v) - int pic_dra_enabled_flag; // u(1) - int pic_dra_aps_id; // u(5) - int arbitrary_slice_present_flag; // u(1) - int constrained_intra_pred_flag; // u(1) - int cu_qp_delta_enabled_flag; // u(1) - int log2_cu_qp_delta_area_minus6; // ue(v) - -} EVCParserPPS; +#include "evc_ps.h" // The sturcture reflects Slice Header RBSP(raw byte sequence payload) layout // @see ISO_IEC_23094-1 section 7.3.2.6 @@ -265,10 +82,7 @@ typedef struct EVCParserPoc { } EVCParserPoc; typedef struct EVCParserContext { - //ParseContext pc; - EVCParserSPS *sps[EVC_MAX_SPS_COUNT]; - EVCParserPPS *pps[EVC_MAX_PPS_COUNT]; - + 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) @@ -349,14 +163,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); -// @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) -EVCParserSPS *ff_evc_parse_sps(EVCParserContext *ctx, const uint8_t *bs, int bs_size); - -// @see ISO_IEC_23094-1 (7.3.2.2 SPS RBSP syntax) -EVCParserPPS *ff_evc_parse_pps(EVCParserContext *ctx, const uint8_t *bs, int bs_size); - int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx); -void ff_evc_parse_free(EVCParserContext *ctx); - #endif /* AVCODEC_EVC_PARSE_H */ diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c index c85b8f89e7..1fd8aac1dc 100644 --- a/libavcodec/evc_parser.c +++ b/libavcodec/evc_parser.c @@ -202,7 +202,7 @@ static void evc_parser_close(AVCodecParserContext *s) { EVCParserContext *ctx = s->priv_data; - ff_evc_parse_free(ctx); + ff_evc_ps_free(&ctx->ps); } const AVCodecParser ff_evc_parser = { diff --git a/libavcodec/evc_ps.c b/libavcodec/evc_ps.c new file mode 100644 index 0000000000..af74ba46b0 --- /dev/null +++ b/libavcodec/evc_ps.c @@ -0,0 +1,381 @@ +/* + * 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 "golomb.h" +#include "parser.h" +#include "evc.h" +#include "evc_ps.h" + +#define EXTENDED_SAR 255 + +// @see ISO_IEC_23094-1 (7.3.7 Reference picture list structure syntax) +static int ref_pic_list_struct(GetBitContext *gb, RefPicListStruct *rpl) +{ + uint32_t delta_poc_st, strp_entry_sign_flag = 0; + rpl->ref_pic_num = get_ue_golomb(gb); + if (rpl->ref_pic_num > 0) { + delta_poc_st = get_ue_golomb(gb); + + rpl->ref_pics[0] = delta_poc_st; + if (rpl->ref_pics[0] != 0) { + strp_entry_sign_flag = get_bits(gb, 1); + + rpl->ref_pics[0] *= 1 - (strp_entry_sign_flag << 1); + } + } + + for (int i = 1; i < rpl->ref_pic_num; ++i) { + delta_poc_st = get_ue_golomb(gb); + if (delta_poc_st != 0) + strp_entry_sign_flag = get_bits(gb, 1); + rpl->ref_pics[i] = rpl->ref_pics[i - 1] + delta_poc_st * (1 - (strp_entry_sign_flag << 1)); + } + + return 0; +} + +// @see ISO_IEC_23094-1 (E.2.2 HRD parameters syntax) +static int hrd_parameters(GetBitContext *gb, HRDParameters *hrd) +{ + hrd->cpb_cnt_minus1 = get_ue_golomb(gb); + hrd->bit_rate_scale = get_bits(gb, 4); + hrd->cpb_size_scale = get_bits(gb, 4); + for (int SchedSelIdx = 0; SchedSelIdx <= hrd->cpb_cnt_minus1; SchedSelIdx++) { + hrd->bit_rate_value_minus1[SchedSelIdx] = get_ue_golomb(gb); + hrd->cpb_size_value_minus1[SchedSelIdx] = get_ue_golomb(gb); + hrd->cbr_flag[SchedSelIdx] = get_bits(gb, 1); + } + hrd->initial_cpb_removal_delay_length_minus1 = get_bits(gb, 5); + hrd->cpb_removal_delay_length_minus1 = get_bits(gb, 5); + hrd->cpb_removal_delay_length_minus1 = get_bits(gb, 5); + hrd->time_offset_length = get_bits(gb, 5); + + return 0; +} + +// @see ISO_IEC_23094-1 (E.2.1 VUI parameters syntax) +static int vui_parameters(GetBitContext *gb, VUIParameters *vui) +{ + vui->aspect_ratio_info_present_flag = get_bits(gb, 1); + if (vui->aspect_ratio_info_present_flag) { + vui->aspect_ratio_idc = get_bits(gb, 8); + if (vui->aspect_ratio_idc == EXTENDED_SAR) { + vui->sar_width = get_bits(gb, 16); + vui->sar_height = get_bits(gb, 16); + } + } + vui->overscan_info_present_flag = get_bits(gb, 1); + if (vui->overscan_info_present_flag) + vui->overscan_appropriate_flag = get_bits(gb, 1); + vui->video_signal_type_present_flag = get_bits(gb, 1); + if (vui->video_signal_type_present_flag) { + vui->video_format = get_bits(gb, 3); + vui->video_full_range_flag = get_bits(gb, 1); + vui->colour_description_present_flag = get_bits(gb, 1); + if (vui->colour_description_present_flag) { + vui->colour_primaries = get_bits(gb, 8); + vui->transfer_characteristics = get_bits(gb, 8); + vui->matrix_coefficients = get_bits(gb, 8); + } + } + vui->chroma_loc_info_present_flag = get_bits(gb, 1); + if (vui->chroma_loc_info_present_flag) { + vui->chroma_sample_loc_type_top_field = get_ue_golomb(gb); + vui->chroma_sample_loc_type_bottom_field = get_ue_golomb(gb); + } + vui->neutral_chroma_indication_flag = get_bits(gb, 1); + + vui->field_seq_flag = get_bits(gb, 1); + + vui->timing_info_present_flag = get_bits(gb, 1); + if (vui->timing_info_present_flag) { + vui->num_units_in_tick = get_bits(gb, 32); + vui->time_scale = get_bits(gb, 32); + vui->fixed_pic_rate_flag = get_bits(gb, 1); + } + vui->nal_hrd_parameters_present_flag = get_bits(gb, 1); + if (vui->nal_hrd_parameters_present_flag) + hrd_parameters(gb, &vui->hrd_parameters); + vui->vcl_hrd_parameters_present_flag = get_bits(gb, 1); + if (vui->vcl_hrd_parameters_present_flag) + hrd_parameters(gb, &vui->hrd_parameters); + if (vui->nal_hrd_parameters_present_flag || vui->vcl_hrd_parameters_present_flag) + vui->low_delay_hrd_flag = get_bits(gb, 1); + vui->pic_struct_present_flag = get_bits(gb, 1); + vui->bitstream_restriction_flag = get_bits(gb, 1); + if (vui->bitstream_restriction_flag) { + vui->motion_vectors_over_pic_boundaries_flag = get_bits(gb, 1); + vui->max_bytes_per_pic_denom = get_ue_golomb(gb); + vui->max_bits_per_mb_denom = get_ue_golomb(gb); + vui->log2_max_mv_length_horizontal = get_ue_golomb(gb); + vui->log2_max_mv_length_vertical = get_ue_golomb(gb); + vui->num_reorder_pics = get_ue_golomb(gb); + vui->max_dec_pic_buffering = get_ue_golomb(gb); + } + + return 0; +} + +// @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) +EVCParserSPS *ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size) +{ + GetBitContext gb; + EVCParserSPS *sps; + int sps_seq_parameter_set_id; + + if (init_get_bits8(&gb, bs, bs_size) < 0) + return NULL; + + sps_seq_parameter_set_id = get_ue_golomb(&gb); + + if (sps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) + return NULL; + + if(!ps->sps[sps_seq_parameter_set_id]) { + if((ps->sps[sps_seq_parameter_set_id] = av_malloc(sizeof(EVCParserSPS))) == NULL) + return NULL; + } + + sps = ps->sps[sps_seq_parameter_set_id]; + memset(sps, 0, sizeof(*sps)); + + sps->sps_seq_parameter_set_id = sps_seq_parameter_set_id; + + // the Baseline profile is indicated by profile_idc eqal to 0 + // the Main profile is indicated by profile_idc eqal to 1 + sps->profile_idc = get_bits(&gb, 8); + + sps->level_idc = get_bits(&gb, 8); + + skip_bits_long(&gb, 32); /* skip toolset_idc_h */ + skip_bits_long(&gb, 32); /* skip toolset_idc_l */ + + // 0 - monochrome + // 1 - 4:2:0 + // 2 - 4:2:2 + // 3 - 4:4:4 + sps->chroma_format_idc = get_ue_golomb(&gb); + + sps->pic_width_in_luma_samples = get_ue_golomb(&gb); + sps->pic_height_in_luma_samples = get_ue_golomb(&gb); + + sps->bit_depth_luma_minus8 = get_ue_golomb(&gb); + sps->bit_depth_chroma_minus8 = get_ue_golomb(&gb); + + sps->sps_btt_flag = get_bits(&gb, 1); + if (sps->sps_btt_flag) { + sps->log2_ctu_size_minus5 = get_ue_golomb(&gb); + sps->log2_min_cb_size_minus2 = get_ue_golomb(&gb); + sps->log2_diff_ctu_max_14_cb_size = get_ue_golomb(&gb); + sps->log2_diff_ctu_max_tt_cb_size = get_ue_golomb(&gb); + sps->log2_diff_min_cb_min_tt_cb_size_minus2 = get_ue_golomb(&gb); + } + + sps->sps_suco_flag = get_bits(&gb, 1); + if (sps->sps_suco_flag) { + sps->log2_diff_ctu_size_max_suco_cb_size = get_ue_golomb(&gb); + sps->log2_diff_max_suco_min_suco_cb_size = get_ue_golomb(&gb); + } + + sps->sps_admvp_flag = get_bits(&gb, 1); + if (sps->sps_admvp_flag) { + sps->sps_affine_flag = get_bits(&gb, 1); + sps->sps_amvr_flag = get_bits(&gb, 1); + sps->sps_dmvr_flag = get_bits(&gb, 1); + sps->sps_mmvd_flag = get_bits(&gb, 1); + sps->sps_hmvp_flag = get_bits(&gb, 1); + } + + sps->sps_eipd_flag = get_bits(&gb, 1); + if (sps->sps_eipd_flag) { + sps->sps_ibc_flag = get_bits(&gb, 1); + if (sps->sps_ibc_flag) + sps->log2_max_ibc_cand_size_minus2 = get_ue_golomb(&gb); + } + + sps->sps_cm_init_flag = get_bits(&gb, 1); + if (sps->sps_cm_init_flag) + sps->sps_adcc_flag = get_bits(&gb, 1); + + sps->sps_iqt_flag = get_bits(&gb, 1); + if (sps->sps_iqt_flag) + sps->sps_ats_flag = get_bits(&gb, 1); + + sps->sps_addb_flag = get_bits(&gb, 1); + sps->sps_alf_flag = get_bits(&gb, 1); + sps->sps_htdf_flag = get_bits(&gb, 1); + sps->sps_rpl_flag = get_bits(&gb, 1); + sps->sps_pocs_flag = get_bits(&gb, 1); + sps->sps_dquant_flag = get_bits(&gb, 1); + sps->sps_dra_flag = get_bits(&gb, 1); + + if (sps->sps_pocs_flag) + sps->log2_max_pic_order_cnt_lsb_minus4 = get_ue_golomb(&gb); + + if (!sps->sps_pocs_flag || !sps->sps_rpl_flag) { + sps->log2_sub_gop_length = get_ue_golomb(&gb); + if (sps->log2_sub_gop_length == 0) + sps->log2_ref_pic_gap_length = get_ue_golomb(&gb); + } + + if (!sps->sps_rpl_flag) + sps->max_num_tid0_ref_pics = get_ue_golomb(&gb); + else { + sps->sps_max_dec_pic_buffering_minus1 = get_ue_golomb(&gb); + sps->long_term_ref_pic_flag = get_bits(&gb, 1); + sps->rpl1_same_as_rpl0_flag = get_bits(&gb, 1); + sps->num_ref_pic_list_in_sps[0] = get_ue_golomb(&gb); + + for (int i = 0; i < sps->num_ref_pic_list_in_sps[0]; ++i) + ref_pic_list_struct(&gb, &sps->rpls[0][i]); + + if (!sps->rpl1_same_as_rpl0_flag) { + sps->num_ref_pic_list_in_sps[1] = get_ue_golomb(&gb); + for (int i = 0; i < sps->num_ref_pic_list_in_sps[1]; ++i) + ref_pic_list_struct(&gb, &sps->rpls[1][i]); + } + } + + sps->picture_cropping_flag = get_bits(&gb, 1); + + if (sps->picture_cropping_flag) { + sps->picture_crop_left_offset = get_ue_golomb(&gb); + sps->picture_crop_right_offset = get_ue_golomb(&gb); + sps->picture_crop_top_offset = get_ue_golomb(&gb); + sps->picture_crop_bottom_offset = get_ue_golomb(&gb); + } + + if (sps->chroma_format_idc != 0) { + sps->chroma_qp_table_struct.chroma_qp_table_present_flag = get_bits(&gb, 1); + + if (sps->chroma_qp_table_struct.chroma_qp_table_present_flag) { + sps->chroma_qp_table_struct.same_qp_table_for_chroma = get_bits(&gb, 1); + sps->chroma_qp_table_struct.global_offset_flag = get_bits(&gb, 1); + for (int i = 0; i < (sps->chroma_qp_table_struct.same_qp_table_for_chroma ? 1 : 2); i++) { + sps->chroma_qp_table_struct.num_points_in_qp_table_minus1[i] = get_ue_golomb(&gb);; + for (int j = 0; j <= sps->chroma_qp_table_struct.num_points_in_qp_table_minus1[i]; j++) { + sps->chroma_qp_table_struct.delta_qp_in_val_minus1[i][j] = get_bits(&gb, 6); + sps->chroma_qp_table_struct.delta_qp_out_val[i][j] = get_se_golomb(&gb); + } + } + } + } + + sps->vui_parameters_present_flag = get_bits(&gb, 1); + if (sps->vui_parameters_present_flag) + vui_parameters(&gb, &(sps->vui_parameters)); + + // @note + // If necessary, add the missing fields to the EVCParserSPS structure + // and then extend parser implementation + + return sps; +} + +// @see ISO_IEC_23094-1 (7.3.2.2 SPS RBSP syntax) +// +// @note +// The current implementation of parse_sps function doesn't handle VUI parameters parsing. +// If it will be needed, parse_sps function could be extended to handle VUI parameters parsing +// to initialize fields of the AVCodecContex i.e. color_primaries, color_trc,color_range +// +EVCParserPPS *ff_evc_parse_pps(EVCParamSets *ps, const uint8_t *bs, int bs_size) +{ + GetBitContext gb; + EVCParserPPS *pps; + + int pps_pic_parameter_set_id; + + if (init_get_bits8(&gb, bs, bs_size) < 0) + return NULL; + + pps_pic_parameter_set_id = get_ue_golomb(&gb); + if (pps_pic_parameter_set_id > EVC_MAX_PPS_COUNT) + return NULL; + + if(!ps->pps[pps_pic_parameter_set_id]) { + if ((ps->pps[pps_pic_parameter_set_id] = av_malloc(sizeof(EVCParserPPS))) == NULL) + return NULL; + } + + pps = ps->pps[pps_pic_parameter_set_id]; + memset(pps, 0, sizeof(*pps)); + + pps->pps_pic_parameter_set_id = pps_pic_parameter_set_id; + + pps->pps_seq_parameter_set_id = get_ue_golomb(&gb); + if (pps->pps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) { + av_freep(&ps->pps[pps_pic_parameter_set_id]); + return NULL; + } + + pps->num_ref_idx_default_active_minus1[0] = get_ue_golomb(&gb); + pps->num_ref_idx_default_active_minus1[1] = get_ue_golomb(&gb); + pps->additional_lt_poc_lsb_len = get_ue_golomb(&gb); + pps->rpl1_idx_present_flag = get_bits(&gb, 1); + pps->single_tile_in_pic_flag = get_bits(&gb, 1); + + if (!pps->single_tile_in_pic_flag) { + pps->num_tile_columns_minus1 = get_ue_golomb(&gb); + pps->num_tile_rows_minus1 = get_ue_golomb(&gb); + pps->uniform_tile_spacing_flag = get_bits(&gb, 1); + + if (!pps->uniform_tile_spacing_flag) { + for (int i = 0; i < pps->num_tile_columns_minus1; i++) + pps->tile_column_width_minus1[i] = get_ue_golomb(&gb); + + for (int i = 0; i < pps->num_tile_rows_minus1; i++) + pps->tile_row_height_minus1[i] = get_ue_golomb(&gb); + } + pps->loop_filter_across_tiles_enabled_flag = get_bits(&gb, 1); + pps->tile_offset_len_minus1 = get_ue_golomb(&gb); + } + + pps->tile_id_len_minus1 = get_ue_golomb(&gb); + pps->explicit_tile_id_flag = get_bits(&gb, 1); + + if (pps->explicit_tile_id_flag) { + for (int i = 0; i <= pps->num_tile_rows_minus1; i++) { + for (int j = 0; j <= pps->num_tile_columns_minus1; j++) + pps->tile_id_val[i][j] = get_bits(&gb, pps->tile_id_len_minus1 + 1); + } + } + + pps->pic_dra_enabled_flag = 0; + pps->pic_dra_enabled_flag = get_bits(&gb, 1); + + if (pps->pic_dra_enabled_flag) + pps->pic_dra_aps_id = get_bits(&gb, 5); + + pps->arbitrary_slice_present_flag = get_bits(&gb, 1); + pps->constrained_intra_pred_flag = get_bits(&gb, 1); + pps->cu_qp_delta_enabled_flag = get_bits(&gb, 1); + + if (pps->cu_qp_delta_enabled_flag) + pps->log2_cu_qp_delta_area_minus6 = get_ue_golomb(&gb); + + return pps; +} + +void ff_evc_ps_free(EVCParamSets *ps) { + for (int i = 0; i < EVC_MAX_SPS_COUNT; i++) + av_freep(&ps->sps[i]); + + for (int i = 0; i < EVC_MAX_PPS_COUNT; i++) + av_freep(&ps->pps[i]); +} diff --git a/libavcodec/evc_ps.h b/libavcodec/evc_ps.h new file mode 100644 index 0000000000..989336079f --- /dev/null +++ b/libavcodec/evc_ps.h @@ -0,0 +1,228 @@ +/* + * 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 + */ + +/** + * @file + * EVC decoder/parser shared code + */ + +#ifndef AVCODEC_EVC_PS_H +#define AVCODEC_EVC_PS_H + +#include + +#include "evc.h" + +#define EVC_MAX_QP_TABLE_SIZE 58 +#define NUM_CPB 32 + +// rpl structure +typedef struct RefPicListStruct { + int poc; + int tid; + int ref_pic_num; + int ref_pic_active_num; + int ref_pics[EVC_MAX_NUM_REF_PICS]; + char pic_type; + +} RefPicListStruct; + +// chromaQP table structure to be signalled in SPS +typedef struct ChromaQpTable { + int chroma_qp_table_present_flag; // u(1) + int same_qp_table_for_chroma; // u(1) + int global_offset_flag; // u(1) + int num_points_in_qp_table_minus1[2]; // ue(v) + int delta_qp_in_val_minus1[2][EVC_MAX_QP_TABLE_SIZE]; // u(6) + int delta_qp_out_val[2][EVC_MAX_QP_TABLE_SIZE]; // se(v) +} ChromaQpTable; + +// Hypothetical Reference Decoder (HRD) parameters, part of VUI +typedef struct HRDParameters { + int cpb_cnt_minus1; // ue(v) + int bit_rate_scale; // u(4) + int cpb_size_scale; // u(4) + int bit_rate_value_minus1[NUM_CPB]; // ue(v) + int cpb_size_value_minus1[NUM_CPB]; // ue(v) + int cbr_flag[NUM_CPB]; // u(1) + int initial_cpb_removal_delay_length_minus1; // u(5) + int cpb_removal_delay_length_minus1; // u(5) + int dpb_output_delay_length_minus1; // u(5) + int time_offset_length; // u(5) +} HRDParameters; + +// video usability information (VUI) part of SPS +typedef struct VUIParameters { + int aspect_ratio_info_present_flag; // u(1) + int aspect_ratio_idc; // u(8) + int sar_width; // u(16) + int sar_height; // u(16) + int overscan_info_present_flag; // u(1) + int overscan_appropriate_flag; // u(1) + int video_signal_type_present_flag; // u(1) + int video_format; // u(3) + int video_full_range_flag; // u(1) + int colour_description_present_flag; // u(1) + int colour_primaries; // u(8) + int transfer_characteristics; // u(8) + int matrix_coefficients; // u(8) + int chroma_loc_info_present_flag; // u(1) + int chroma_sample_loc_type_top_field; // ue(v) + int chroma_sample_loc_type_bottom_field; // ue(v) + int neutral_chroma_indication_flag; // u(1) + int field_seq_flag; // u(1) + int timing_info_present_flag; // u(1) + int num_units_in_tick; // u(32) + int time_scale; // u(32) + int fixed_pic_rate_flag; // u(1) + int nal_hrd_parameters_present_flag; // u(1) + int vcl_hrd_parameters_present_flag; // u(1) + int low_delay_hrd_flag; // u(1) + int pic_struct_present_flag; // u(1) + int bitstream_restriction_flag; // u(1) + int motion_vectors_over_pic_boundaries_flag; // u(1) + int max_bytes_per_pic_denom; // ue(v) + int max_bits_per_mb_denom; // ue(v) + int log2_max_mv_length_horizontal; // ue(v) + int log2_max_mv_length_vertical; // ue(v) + int num_reorder_pics; // ue(v) + int max_dec_pic_buffering; // ue(v) + + HRDParameters hrd_parameters; +} VUIParameters; + +// The sturcture reflects SPS RBSP(raw byte sequence payload) layout +// @see ISO_IEC_23094-1 section 7.3.2.1 +// +// The following descriptors specify the parsing process of each element +// u(n) - unsigned integer using n bits +// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with the left bit first +typedef struct EVCParserSPS { + int sps_seq_parameter_set_id; // ue(v) + int profile_idc; // u(8) + int level_idc; // u(8) + int toolset_idc_h; // u(32) + int toolset_idc_l; // u(32) + int chroma_format_idc; // ue(v) + int pic_width_in_luma_samples; // ue(v) + int pic_height_in_luma_samples; // ue(v) + int bit_depth_luma_minus8; // ue(v) + int bit_depth_chroma_minus8; // ue(v) + + int sps_btt_flag; // u(1) + int log2_ctu_size_minus5; // ue(v) + int log2_min_cb_size_minus2; // ue(v) + int log2_diff_ctu_max_14_cb_size; // ue(v) + int log2_diff_ctu_max_tt_cb_size; // ue(v) + int log2_diff_min_cb_min_tt_cb_size_minus2; // ue(v) + + int sps_suco_flag; // u(1) + int log2_diff_ctu_size_max_suco_cb_size; // ue(v) + int log2_diff_max_suco_min_suco_cb_size; // ue(v) + + int sps_admvp_flag; // u(1) + int sps_affine_flag; // u(1) + int sps_amvr_flag; // u(1) + int sps_dmvr_flag; // u(1) + int sps_mmvd_flag; // u(1) + int sps_hmvp_flag; // u(1) + + int sps_eipd_flag; // u(1) + int sps_ibc_flag; // u(1) + int log2_max_ibc_cand_size_minus2; // ue(v) + + int sps_cm_init_flag; // u(1) + int sps_adcc_flag; // u(1) + + int sps_iqt_flag; // u(1) + int sps_ats_flag; // u(1) + + int sps_addb_flag; // u(1) + int sps_alf_flag; // u(1) + int sps_htdf_flag; // u(1) + int sps_rpl_flag; // u(1) + int sps_pocs_flag; // u(1) + int sps_dquant_flag; // u(1) + int sps_dra_flag; // u(1) + + int log2_max_pic_order_cnt_lsb_minus4; // ue(v) + int log2_sub_gop_length; // ue(v) + int log2_ref_pic_gap_length; // ue(v) + + int max_num_tid0_ref_pics; // ue(v) + + int sps_max_dec_pic_buffering_minus1; // ue(v) + int long_term_ref_pic_flag; // u(1) + int rpl1_same_as_rpl0_flag; // u(1) + int num_ref_pic_list_in_sps[2]; // ue(v) + struct RefPicListStruct rpls[2][EVC_MAX_NUM_RPLS]; + + int picture_cropping_flag; // u(1) + int picture_crop_left_offset; // ue(v) + int picture_crop_right_offset; // ue(v) + int picture_crop_top_offset; // ue(v) + int picture_crop_bottom_offset; // ue(v) + + struct ChromaQpTable chroma_qp_table_struct; + + int vui_parameters_present_flag; // u(1) + + struct VUIParameters vui_parameters; + +} EVCParserSPS; + +typedef struct EVCParserPPS { + int pps_pic_parameter_set_id; // ue(v) + int pps_seq_parameter_set_id; // ue(v) + int num_ref_idx_default_active_minus1[2]; // ue(v) + int additional_lt_poc_lsb_len; // ue(v) + int rpl1_idx_present_flag; // u(1) + int single_tile_in_pic_flag; // u(1) + int num_tile_columns_minus1; // ue(v) + int num_tile_rows_minus1; // ue(v) + int uniform_tile_spacing_flag; // u(1) + int tile_column_width_minus1[EVC_MAX_TILE_ROWS]; // ue(v) + int tile_row_height_minus1[EVC_MAX_TILE_COLUMNS]; // ue(v) + int loop_filter_across_tiles_enabled_flag; // u(1) + int tile_offset_len_minus1; // ue(v) + int tile_id_len_minus1; // ue(v) + int explicit_tile_id_flag; // u(1) + int tile_id_val[EVC_MAX_TILE_ROWS][EVC_MAX_TILE_COLUMNS]; // u(v) + int pic_dra_enabled_flag; // u(1) + int pic_dra_aps_id; // u(5) + int arbitrary_slice_present_flag; // u(1) + int constrained_intra_pred_flag; // u(1) + int cu_qp_delta_enabled_flag; // u(1) + int log2_cu_qp_delta_area_minus6; // ue(v) + +} EVCParserPPS; + +typedef struct EVCParamSets { + EVCParserSPS *sps[EVC_MAX_SPS_COUNT]; + EVCParserPPS *pps[EVC_MAX_PPS_COUNT]; +} EVCParamSets; + +// @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) +EVCParserSPS *ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size); + +// @see ISO_IEC_23094-1 (7.3.2.2 SPS RBSP syntax) +EVCParserPPS *ff_evc_parse_pps(EVCParamSets *ps, const uint8_t *bs, int bs_size); + +void ff_evc_ps_free(EVCParamSets *ps); + +#endif /* AVCODEC_EVC_PS_H */ From patchwork Sat Jun 17 22:00:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42177 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp2448327pzb; Sat, 17 Jun 2023 15:01:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5xoEtUBw/rHkAheoXXz9ySZHNQNw9NTdg0+Ezgiv2kABOzI590MdTksHL9qVkME5KpEhyw X-Received: by 2002:adf:eac3:0:b0:311:17c5:3a9a with SMTP id o3-20020adfeac3000000b0031117c53a9amr4628932wrn.38.1687039267196; Sat, 17 Jun 2023 15:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687039267; cv=none; d=google.com; s=arc-20160816; b=rsFrzwLUfLRtzREIqXuvpGG1G9qxIY7U0o4eLQBxH4jKE/WRV6K1dKSey2yykegG1H PscNoFW8095DdS7dLciPaelcQzNSHHTkXF3tywJImp8zfMVyLd9bFWPrSIrMYGlGZI70 onqQHffBkogfC2gUrpvvXyFodfBtFHAbMHTlnf5mWTTHKAtJ5FH90Lmdl0wL9N4J0AUO htl/LwMcKZ+KgGXJO+SWB3mTy6cMbmJ5Tr9VqSSnj8q4akWyc9mar5bblufat/nq0uEl CUkcqeJ4Tko8PjJJe8JbFVgXU3WFFtarlkI9ErAeM6+cqEbxpW+13goFT9pEPH7gN7f0 ZkRQ== 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=vmR+hwQWAfhlquNTbOFwNjAhh8OVG0qLCx7nEwUdPBE=; b=GCaqOsEnPljTkeaSVl6XjtDQfYl0DWsJwytdZCfeK8HYV8UqzjRIruyv9dEJ509Hyh GAL6e38xnTo1QmpH/J84wSNi1xZ44cHLReXUJYAx9faCV7lcCMlSA4QkAO3tpOofHx+u Q5vKymQOTDGvH7FqJTe/aYq9Y32QrT4IjerNNENvrTMA6XKZS3Seu/7n5ojBZ1wlyWpQ YjaAtFKwTCx9RWzMX4oFAYrr/aRrLQyXn1azsfcGkWYRk0S0u1rnSLHgL4As1gkefXn9 +ZQYeJRJ441ILq6G3YS3DgR722t0Vmy2AEbABIMNhfbq/auxqGbIjVdNTiPEm5eZNEQP 1LMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=YJx7E9D6; 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 o14-20020a056402038e00b0051a27469761si3466727edv.123.2023.06.17.15.01.06; Sat, 17 Jun 2023 15:01:07 -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=YJx7E9D6; 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 AA9FB68BF43; Sun, 18 Jun 2023 01:00:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B55F768B14C for ; Sun, 18 Jun 2023 01:00:44 +0300 (EEST) Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-1a9df9ef16dso1642973fac.0 for ; Sat, 17 Jun 2023 15:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687039243; x=1689631243; 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=xKagQX7MnVeBjDsbZ8azyDVkGyCtz7lRq85ZsUPR50I=; b=YJx7E9D6l2EVAEt3Xp3twjrksd2GCFFMrzx48wSmJxVN951A/G65bpCwpjxSJpEr6/ xJ9az+DEOxcnUrn+BAkQ6PkmuJnJwtvXLDyJAxA7CupcNB3WUXV5Sl/x6yRBX0hBsAnq q+epEIEKkFD1zKiKqjE922V7Eu1CsOYuMYPDTqKQyR+rnRqjszjfr8rv9YvXZhWyD+i7 vzVn6qxx+9p9j+Cx/QaxyokUp/t6z2+neQ+RHWsLp+nU/RSuIrmWy0kdJv9MZwOHZTjb ZbmlcmePzy4+oGVOr7o+9rPP18UX2/KcTcCMXJKFRt8PuXaildhRp+x2CYIIq+Vdgg26 trAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687039243; x=1689631243; 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=xKagQX7MnVeBjDsbZ8azyDVkGyCtz7lRq85ZsUPR50I=; b=Y0/REAo3EfJEwodJ4fMv8eDAm1dTbMaT+hS69VaqcFL+0rHdDTC93QycX74TszTCms Qp4uFzzkQil8AX8U2lY3zjj9TIbsB6aw/BBIHu0EmCctVE5fdcv3vT06i9YPKKrx44FO BheYGbK2gsBKV6avKwVY4E7/TEN+IV+Lb8UO8ODsEvQ7/redHLS+uBOrFE/DVcSHS0RL z0BmZvqEG/tIUhGlbFBjGEH6/bErUzKnJ5Fb5HIbANjxlk9XeTv1VeTKFexdP5lFnhez Ct/UmoozBlktr9ipo1eeUxWnVBS8arJCH92fGWPB69qeB8ww029TCLQZeLsOZfJ4NXG0 TvEA== X-Gm-Message-State: AC+VfDwtPwDcvhrpeeep13E0rekKfOaZANo9Eb1VFt6MXf7IHFq9NemL ax7EEJ16+JVfTLSMSF49DNBK8CPWw68= X-Received: by 2002:a05:6870:4708:b0:19e:cc9f:8a45 with SMTP id b8-20020a056870470800b0019ecc9f8a45mr4579746oaq.38.1687039242964; Sat, 17 Jun 2023 15:00:42 -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.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 15:00:42 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Jun 2023 19:00:10 -0300 Message-ID: <20230617220015.12669-2-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 05/10] avcodec/evc_parser: stop exporting delay and gop_size 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: Na8FYYvP4Qpc The former is a property a decoder may export, and the latter is only used in encoding scenarios. Signed-off-by: James Almer --- libavcodec/evc_parse.c | 6 ------ libavcodec/evc_parse.h | 6 ------ libavcodec/evc_parser.c | 2 -- 3 files changed, 14 deletions(-) diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c index a8e6356b96..1fe58c8050 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -225,7 +225,6 @@ int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_siz switch(nalu_type) { case EVC_SPS_NUT: { EVCParserSPS *sps; - int SubGopLength; int bit_depth; sps = ff_evc_parse_sps(&ctx->ps, data, nalu_size); @@ -245,11 +244,6 @@ int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_siz ctx->height = sps->pic_height_in_luma_samples; } - SubGopLength = (int)pow(2.0, sps->log2_sub_gop_length); - ctx->gop_size = SubGopLength; - - ctx->delay = (sps->sps_max_dec_pic_buffering_minus1) ? sps->sps_max_dec_pic_buffering_minus1 - 1 : SubGopLength + sps->max_num_tid0_ref_pics - 1; - if (sps->profile_idc == 1) ctx->profile = FF_PROFILE_EVC_MAIN; else ctx->profile = FF_PROFILE_EVC_BASELINE; diff --git a/libavcodec/evc_parse.h b/libavcodec/evc_parse.h index b5462f5711..2748f8dfbf 100644 --- a/libavcodec/evc_parse.h +++ b/libavcodec/evc_parse.h @@ -117,12 +117,6 @@ typedef struct EVCParserContext { // Framerate value in the compressed bitstream AVRational framerate; - // Number of pictures in a group of pictures - int gop_size; - - // Number of frames the decoded output will be delayed relative to the encoded input - int delay; - int parsed_extradata; } EVCParserContext; diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c index 1fd8aac1dc..4fd8c49fd4 100644 --- a/libavcodec/evc_parser.c +++ b/libavcodec/evc_parser.c @@ -72,8 +72,6 @@ static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const s->format = ctx->format; avctx->framerate = ctx->framerate; - avctx->gop_size = ctx->gop_size; - avctx->delay = ctx->delay; avctx->profile = ctx->profile; } else if(ctx->nalu_type == EVC_NOIDR_NUT || ctx->nalu_type == EVC_IDR_NUT) { From patchwork Sat Jun 17 22:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42178 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp2448416pzb; Sat, 17 Jun 2023 15:01:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4PCq7k8sppKM5QMkbhRHXwcfoKjBURg9XmVtsiLbNkBABHMKp/y2E2/qjupPFTtOQ3moWX X-Received: by 2002:a17:907:9309:b0:966:17b2:5b0b with SMTP id bu9-20020a170907930900b0096617b25b0bmr4925364ejc.49.1687039276583; Sat, 17 Jun 2023 15:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687039276; cv=none; d=google.com; s=arc-20160816; b=BqBe66Cdsx3+g4KeDSbSH7jtDIhv9RjotoLHj7huxiy9Z2vvE12rqL/dg+QngPSYdA 4syt/C5MoVMcoE8XGP/J8KHsuQF+O5DD+afWDUGuuEyqm+3Q2BWEJOOZ3AViX5Uhlpko Z1vJLJPVbxKQRRc3I5uX7xtyl3cNjcKrNnl1ylb/SfWJcd2ityD1iCDSjPBmG6Q3VSId UV8YXjUz8/pBaoI4Y/tr+2Vsp2yUHNbtbKc61qT2q9ZziiNBNzmVc/OS5uCtO4N2OgiX 4jcW2oNFEMkwGZkToMUpa2oCX47rw0WPdJz4dZsAP1v4GR8eiOX1y9OTWBc0tOmSnTav 324g== 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=BiJwiXuVDxENdZf4wKYBFOk5X2OJZwF4nLqPSCPjuE8=; b=znif81qR97sQVFACNdizGJ5XFyJEsTLixoMTDHdZoiJZFOuXXacCf5WBUaEpEmUd2R PiynK8RyBS3nsnVayrXZ42RX4c1uCwdDnM34whll9iRojbJNkHiPo9H+7DZy4boFPboN hTyI2PV3zGNcE27sFiRBYwHfmvArBlxnV32SEcT54cuZKS3Uhyasmme1bnMZ6B8N8how 27BBLrGaDX29xrBVt1PqW873+rtL6Um1Qa+5ZG4aI8nxDQt3r6GqRCkYFn4z6ZmwLrk/ YjorVrhgCZxX4e1+1N7qyyIamtM6PwLlUuqyUWNbjRllgyDFG/u+ghR2oxGdENjK9tFa SUKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b="bR44u/Bc"; 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 n9-20020a170906840900b00966147253f4si12002115ejx.662.2023.06.17.15.01.16; Sat, 17 Jun 2023 15:01:16 -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="bR44u/Bc"; 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 B59EF68BF4A; Sun, 18 Jun 2023 01:00:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4BB6568BF36 for ; Sun, 18 Jun 2023 01:00:46 +0300 (EEST) Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-1a9ae7cc01dso1400794fac.3 for ; Sat, 17 Jun 2023 15:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687039244; x=1689631244; 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=2A1WgaJtMbgKul7yaZFQrwTVnxA46bdcyNre3PNuN9I=; b=bR44u/BcVramSQx3ltS0kitfjOQMTFEXblYQv9qQPdfpHlhtDQjmJ78coUroZy1hn9 joZq5QH/tOIigBQcJXwatSdpVPdStgZayJ3e0wxNXA81yL0SQN36n9CtJO5CBAV2JgCm qVUm7NQ/oM9FOMMyJ8qxRHUWrRJlmkdLWdSLPMp20QFRxCyOwORySW7Ld9gUIq82qv3j labMA0vufLpaPavHefwtSHHAPLi6pl155QhYrVnnboR15K73ueNT7LdY/8YdLQhuG5Je CGru2Bvw41NeLFsYp3rp+jnXpI6EPlodfmEk9jc4bGJQ4MTnnb4V2h6/7KuhNJdvCVEA b5Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687039244; x=1689631244; 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=2A1WgaJtMbgKul7yaZFQrwTVnxA46bdcyNre3PNuN9I=; b=URVPxLMJloDD3EhWT95mZIRy/dxfYJFjKHCcpL/455ILnBktKclBoz7AVbebyVx6EP Q2/0XNmGToQX4V8QK6895O1OGMhuSU9W1J63WQoqy88S9f87873rq7gKlRUwRQq/DbQV JtNWA8/+mXceHmoRK+VG7aCtUgJ28zk9dS2Isze0ox20PmC6J9FtUf7EepnVPElgu8WC 1fMGmMOHcICz7yTuiwZOaq7Xho7mIOyj7985pSHhU37tNcW0jJOxlmOHpI6aP5/bWTGS D38C4i+UPe/mu3PwsQvSYyC0BoatKKTgoLYH8xj+fCBmNJwyg3hcF/romWcpsfZTJ7Ck mB6Q== X-Gm-Message-State: AC+VfDzf4t9oUh1WPEhnNr/fpD9CrTs4K+huQ8r4orQuSbiFHeXWq74H 25+kYFaGGGNd9YF/qhXuA/Y1j+EdqsU= X-Received: by 2002:a05:6870:51c3:b0:1a9:facf:158 with SMTP id b3-20020a05687051c300b001a9facf0158mr1137470oaj.35.1687039244368; Sat, 17 Jun 2023 15:00:44 -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.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 15:00:43 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Jun 2023 19:00:11 -0300 Message-ID: <20230617220015.12669-3-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 06/10] avcodec/evc_parse: split off deriving PoC 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: 3yN8BhW3r4/I Signed-off-by: James Almer --- libavcodec/evc_parse.c | 142 +++++++++++++++++++++-------------------- libavcodec/evc_parse.h | 5 ++ 2 files changed, 79 insertions(+), 68 deletions(-) diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c index 1fe58c8050..262ef5aa39 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -187,6 +187,77 @@ static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *s return 0; } +int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, + EVCParserPoc *poc, enum EVCNALUnitType nalu_type, int tid) +{ + const EVCParserPPS *pps = ps->pps[sh->slice_pic_parameter_set_id]; + const EVCParserSPS *sps; + + if (!pps) + return AVERROR_INVALIDDATA; + + sps = ps->sps[pps->pps_seq_parameter_set_id]; + if (!sps) + return AVERROR_INVALIDDATA; + + if (sps->sps_pocs_flag) { + int PicOrderCntMsb = 0; + poc->prevPicOrderCntVal = poc->PicOrderCntVal; + + if (nalu_type == EVC_IDR_NUT) + PicOrderCntMsb = 0; + else { + int MaxPicOrderCntLsb = 1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4); + int prevPicOrderCntLsb = poc->PicOrderCntVal & (MaxPicOrderCntLsb - 1); + int prevPicOrderCntMsb = poc->PicOrderCntVal - prevPicOrderCntLsb; + + if ((sh->slice_pic_order_cnt_lsb < prevPicOrderCntLsb) && + ((prevPicOrderCntLsb - sh->slice_pic_order_cnt_lsb) >= (MaxPicOrderCntLsb / 2))) + PicOrderCntMsb = prevPicOrderCntMsb + MaxPicOrderCntLsb; + else if ((sh->slice_pic_order_cnt_lsb > prevPicOrderCntLsb) && + ((sh->slice_pic_order_cnt_lsb - prevPicOrderCntLsb) > (MaxPicOrderCntLsb / 2))) + PicOrderCntMsb = prevPicOrderCntMsb - MaxPicOrderCntLsb; + else + PicOrderCntMsb = prevPicOrderCntMsb; + } + poc->PicOrderCntVal = PicOrderCntMsb + sh->slice_pic_order_cnt_lsb; + } else { + if (nalu_type == EVC_IDR_NUT) { + poc->PicOrderCntVal = 0; + poc->DocOffset = -1; + } else { + int SubGopLength = (int)pow(2.0, sps->log2_sub_gop_length); + if (tid == 0) { + poc->PicOrderCntVal = poc->prevPicOrderCntVal + SubGopLength; + poc->DocOffset = 0; + poc->prevPicOrderCntVal = poc->PicOrderCntVal; + } else { + int ExpectedTemporalId; + int PocOffset; + int prevDocOffset = poc->DocOffset; + + poc->DocOffset = (prevDocOffset + 1) % SubGopLength; + if (poc->DocOffset == 0) { + poc->prevPicOrderCntVal += SubGopLength; + ExpectedTemporalId = 0; + } else + ExpectedTemporalId = 1 + (int)log2(poc->DocOffset); + while (tid != ExpectedTemporalId) { + poc->DocOffset = (poc->DocOffset + 1) % SubGopLength; + if (poc->DocOffset == 0) + ExpectedTemporalId = 0; + else + ExpectedTemporalId = 1 + (int)log2(poc->DocOffset); + } + PocOffset = (int)(SubGopLength * ((2.0 * poc->DocOffset + 1) / (int)pow(2.0, tid) - 2)); + poc->PicOrderCntVal = poc->prevPicOrderCntVal + PocOffset; + } + } + } + + return 0; +} + int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx) { int nalu_type, nalu_size; @@ -299,8 +370,6 @@ int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_siz case EVC_IDR_NUT: // Coded slice of a IDR or non-IDR picture case EVC_NOIDR_NUT: { EVCParserSliceHeader sh; - const EVCParserSPS *sps; - const EVCParserPPS *pps; int ret; ret = evc_parse_slice_header(ctx, &sh, data, nalu_size); @@ -331,72 +400,9 @@ int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_siz // 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 - pps = ctx->ps.pps[sh.slice_pic_parameter_set_id]; - sps = ctx->ps.sps[pps->pps_seq_parameter_set_id]; - av_assert0(sps && pps); - - if (sps->sps_pocs_flag) { - - int PicOrderCntMsb = 0; - ctx->poc.prevPicOrderCntVal = ctx->poc.PicOrderCntVal; - - if (nalu_type == EVC_IDR_NUT) - PicOrderCntMsb = 0; - else { - int MaxPicOrderCntLsb = 1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4); - - int prevPicOrderCntLsb = ctx->poc.PicOrderCntVal & (MaxPicOrderCntLsb - 1); - int prevPicOrderCntMsb = ctx->poc.PicOrderCntVal - prevPicOrderCntLsb; - - - if ((sh.slice_pic_order_cnt_lsb < prevPicOrderCntLsb) && - ((prevPicOrderCntLsb - sh.slice_pic_order_cnt_lsb) >= (MaxPicOrderCntLsb / 2))) - - PicOrderCntMsb = prevPicOrderCntMsb + MaxPicOrderCntLsb; - - else if ((sh.slice_pic_order_cnt_lsb > prevPicOrderCntLsb) && - ((sh.slice_pic_order_cnt_lsb - prevPicOrderCntLsb) > (MaxPicOrderCntLsb / 2))) - - PicOrderCntMsb = prevPicOrderCntMsb - MaxPicOrderCntLsb; - - else - PicOrderCntMsb = prevPicOrderCntMsb; - } - ctx->poc.PicOrderCntVal = PicOrderCntMsb + sh.slice_pic_order_cnt_lsb; - - } else { - if (nalu_type == EVC_IDR_NUT) { - ctx->poc.PicOrderCntVal = 0; - ctx->poc.DocOffset = -1; - } else { - int SubGopLength = (int)pow(2.0, sps->log2_sub_gop_length); - if (tid == 0) { - ctx->poc.PicOrderCntVal = ctx->poc.prevPicOrderCntVal + SubGopLength; - ctx->poc.DocOffset = 0; - ctx->poc.prevPicOrderCntVal = ctx->poc.PicOrderCntVal; - } else { - int ExpectedTemporalId; - int PocOffset; - int prevDocOffset = ctx->poc.DocOffset; - - ctx->poc.DocOffset = (prevDocOffset + 1) % SubGopLength; - if (ctx->poc.DocOffset == 0) { - ctx->poc.prevPicOrderCntVal += SubGopLength; - ExpectedTemporalId = 0; - } else - ExpectedTemporalId = 1 + (int)log2(ctx->poc.DocOffset); - while (tid != ExpectedTemporalId) { - ctx->poc.DocOffset = (ctx->poc.DocOffset + 1) % SubGopLength; - if (ctx->poc.DocOffset == 0) - ExpectedTemporalId = 0; - else - ExpectedTemporalId = 1 + (int)log2(ctx->poc.DocOffset); - } - PocOffset = (int)(SubGopLength * ((2.0 * ctx->poc.DocOffset + 1) / (int)pow(2.0, tid) - 2)); - ctx->poc.PicOrderCntVal = ctx->poc.prevPicOrderCntVal + PocOffset; - } - } - } + 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; diff --git a/libavcodec/evc_parse.h b/libavcodec/evc_parse.h index 2748f8dfbf..97825efcd5 100644 --- a/libavcodec/evc_parse.h +++ b/libavcodec/evc_parse.h @@ -159,4 +159,9 @@ 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); +// 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 +int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, + EVCParserPoc *poc, enum EVCNALUnitType nalu_type, int tid); + #endif /* AVCODEC_EVC_PARSE_H */ From patchwork Sat Jun 17 22:00:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42179 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp2448504pzb; Sat, 17 Jun 2023 15:01:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ75iGsJqQt7ttaAGUfyWK9pyKXjaubqLx+z8ifw7ry2+7QApcuHGPjteT/GJpKis666tr/2 X-Received: by 2002:a05:6402:2816:b0:51a:41fd:9732 with SMTP id h22-20020a056402281600b0051a41fd9732mr4380158ede.11.1687039286517; Sat, 17 Jun 2023 15:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687039286; cv=none; d=google.com; s=arc-20160816; b=Zay5uijtM3vak8pNAKP3adcRvfiHkRBci62THAM2CGTl6GqN41Sz+LccrhFDgzrCG5 OSkRkJMjEQZgIuT8oRNFfk94W4BwDEIehId4S7D8pIj8vP94mrfD7ig1IaYgc6py6nu+ xjiid/VjbGzL14YxSazq6KR0h2/HxadOaGE4kwzgTTQOaMMmg077AMKBEvUTE1Pbd/Fz o1ePOeqVsQWhnI298fG/kj63brVVTh2vzYS/QEWQQu9PM7JmeZnf9jlCens88aQjHmn9 ST90tvp58pZ6rYjjKkYNUPTMb/SXQwFKmmXA843bfWJfLktZ1FCHnecuMCtR0nAnRIeK kmGA== 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=dMKJKNzdQTo5smNkIKyH81Kv+xJMQ9qXM4uVc3PtrQM=; b=aImimuAvAPql3D+IaGXf8TlE4OgMQ0NY+W4guYgU6WGCvJX4H1TLxGe6UmiwYMdYRb W+QVBCCSyyWszKCrHZR0Hg34B89yJ1cat7WgtY2wHCbm2BGsObaNaZrbnHPY+AhWscm7 Dh2tJynhPdAwWHFVIHwucwTZ4rp3eTTi2VwLdoAJ9gdSPaqkvJsSiTBik8cTuC7cSSnx SbxE2k2RQikCHlL2hHyAG/IrRcoL6ypTnRz1ADnLtUlSMk6YJn78hkxl+Fx4vRFf9YDe FdvhTfallfvODqmksDUJy0O9yFys3sMPgjgGZOEv2JR1FhBRmJEuNiC03XzWlU3VbG3Q 1qXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=E1arpbA5; 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 i23-20020a056402055700b0051a2ee807fbsi3323404edx.168.2023.06.17.15.01.26; Sat, 17 Jun 2023 15:01:26 -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=E1arpbA5; 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 D3A3E68BF5F; Sun, 18 Jun 2023 01:00:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BBAD568BF4B for ; Sun, 18 Jun 2023 01:00:47 +0300 (EEST) Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-1a9ae7cc01dso1400804fac.3 for ; Sat, 17 Jun 2023 15:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687039246; x=1689631246; 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=9/A0jGqT6yN+YxghQ6Yj0/Ae/l7LJ9JlCq9O2GHpHdc=; b=E1arpbA5jgqlIIEy+ETKDRN3XVLphg5awCSzTh3vddPokR+WVqDnbus0KGYZwMS/7Q NqEu6DBVSbVBQOnEXctYP8Rkie2gPrXEOJU4lPss+PnDgGWIF7vHWC5ZD/bdMXFiOvk8 RLwleAhtCQPpJFV7WHfjLuOpzCyCLEA82gEWwHuOfR4ttYDHwwbLnJeb9dR+Ap4MFVbd GyztD5djTwpwIw9kCO3nSc4Tx6u2E0/NhJK4jBjzylMFiRoTlinJ98UxID4jxRBkbijl +wEcXjI/A5NgoXTphQ2NOvrW+9/NR1W+0yap0PQjamEDezULJ4s4n+tuADLR3SKiUChJ zsUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687039246; x=1689631246; 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=9/A0jGqT6yN+YxghQ6Yj0/Ae/l7LJ9JlCq9O2GHpHdc=; b=Y7NCq99NBSh9B33BlDuoToG3x/ViQ5hJMXKkNfYEg8Xtotph8Hb27vxfpcgw1n5aff z9GsgY1vIqTK2WV/1gNMjfsWX9V/ObGWT4UddWjAWl4+LL/ArXOJd1FmGFWgEaCPBerq C4kDitaUvKjqj8IB28qOROivtTySZmxC7eW70Gj5pNOP4Db7+hgC0p8FdRzhnjF3MRl2 6L73Pf56wCiHcm3DJHHADij7Nro4meRR4dDe6CVTVxEItm9x7PWUIJ0TkLGpaoy+rF3i 0bd7ZNMAK26pYMxz59F7uSt0X1OW3gIuF7usZOFojjA8pdNhYAq0PINZS0jmKwuVgmdO BMIA== X-Gm-Message-State: AC+VfDzC5aU0h4NC9iekYmVoBQd8sga8Xs4ghMKlLrAbbU3r7iEyFeHo vIhXYIE0+R3y6eBnZJZaD14JfzE/da0= X-Received: by 2002:a05:6870:c395:b0:19e:475:9e2c with SMTP id g21-20020a056870c39500b0019e04759e2cmr1893824oao.58.1687039245666; Sat, 17 Jun 2023 15:00:45 -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.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 15:00:45 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Jun 2023 19:00:12 -0300 Message-ID: <20230617220015.12669-4-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 07/10] avcodec/evc_parser: make ff_evc_parse_nal_unit() local to the parser 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: 3ml57chXjKIY This is in preparation for the following commits. Signed-off-by: James Almer --- libavcodec/evc_parse.c | 17 +-- libavcodec/evc_parse.h | 3 + libavcodec/evc_parser.c | 222 ++++++++++++++++++++++++++++++++++------ 3 files changed, 202 insertions(+), 40 deletions(-) diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c index 262ef5aa39..0ad0d82137 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -70,11 +70,12 @@ int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx) } // @see ISO_IEC_23094-1 (7.3.2.6 Slice layer RBSP syntax) -static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *sh, const uint8_t *bs, int bs_size) +int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, const EVCParamSets *ps, + enum EVCNALUnitType nalu_type, const uint8_t *bs, int bs_size) { GetBitContext gb; - EVCParserPPS *pps; - EVCParserSPS *sps; + const EVCParserPPS *pps; + const EVCParserSPS *sps; int num_tiles_in_slice = 0; int slice_pic_parameter_set_id; @@ -88,11 +89,11 @@ static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *s if (slice_pic_parameter_set_id < 0 || slice_pic_parameter_set_id >= EVC_MAX_PPS_COUNT) return AVERROR_INVALIDDATA; - pps = ctx->ps.pps[slice_pic_parameter_set_id]; + pps = ps->pps[slice_pic_parameter_set_id]; if(!pps) return AVERROR_INVALIDDATA; - sps = ctx->ps.sps[pps->pps_seq_parameter_set_id]; + sps = ps->sps[pps->pps_seq_parameter_set_id]; if(!sps) return AVERROR_INVALIDDATA; @@ -121,7 +122,7 @@ static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *s sh->slice_type = get_ue_golomb(&gb); - if (ctx->nalu_type == EVC_IDR_NUT) + if (nalu_type == EVC_IDR_NUT) sh->no_output_of_prior_pics_flag = get_bits(&gb, 1); if (sps->sps_mmvd_flag && ((sh->slice_type == EVC_SLICE_TYPE_B) || (sh->slice_type == EVC_SLICE_TYPE_P))) @@ -175,7 +176,7 @@ static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *s } } - if (ctx->nalu_type != EVC_IDR_NUT) { + if (nalu_type != EVC_IDR_NUT) { if (sps->sps_pocs_flag) sh->slice_pic_order_cnt_lsb = get_bits(&gb, sps->log2_max_pic_order_cnt_lsb_minus4 + 4); } @@ -372,7 +373,7 @@ int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_siz EVCParserSliceHeader sh; int ret; - ret = evc_parse_slice_header(ctx, &sh, data, nalu_size); + 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; diff --git a/libavcodec/evc_parse.h b/libavcodec/evc_parse.h index 97825efcd5..f31075ff9c 100644 --- a/libavcodec/evc_parse.h +++ b/libavcodec/evc_parse.h @@ -159,6 +159,9 @@ 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); + // 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 int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c index 4fd8c49fd4..d22922d1c9 100644 --- a/libavcodec/evc_parser.c +++ b/libavcodec/evc_parser.c @@ -25,6 +25,180 @@ #include "evc.h" #include "evc_parse.h" +#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] = { + AV_PIX_FMT_GRAY8, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P +}; + +static const enum AVPixelFormat pix_fmts_9bit[NUM_CHROMA_FORMATS] = { + AV_PIX_FMT_GRAY9, AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9 +}; + +static const enum AVPixelFormat pix_fmts_10bit[NUM_CHROMA_FORMATS] = { + AV_PIX_FMT_GRAY10, AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10 +}; + +static const enum AVPixelFormat pix_fmts_12bit[NUM_CHROMA_FORMATS] = { + AV_PIX_FMT_GRAY12, AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12 +}; + +static const enum AVPixelFormat pix_fmts_14bit[NUM_CHROMA_FORMATS] = { + AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14 +}; + +static const enum AVPixelFormat pix_fmts_16bit[NUM_CHROMA_FORMATS] = { + AV_PIX_FMT_GRAY16, AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16 +}; + +static int parse_nal_unit(AVCodecParserContext *s, AVCodecContext *avctx, + const uint8_t *buf, int buf_size) +{ + EVCParserContext *ctx = s->priv_data; + int nalu_type, tid; + + if (buf_size <= 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", buf_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(buf, buf_size, avctx); + if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", nalu_type); + return AVERROR_INVALIDDATA; + } + + tid = ff_evc_get_temporal_id(buf, buf_size, avctx); + if (tid < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid temporial id: (%d)\n", tid); + return AVERROR_INVALIDDATA; + } + + buf += EVC_NALU_HEADER_SIZE; + buf_size -= EVC_NALU_HEADER_SIZE; + + switch (nalu_type) { + case EVC_SPS_NUT: { + EVCParserSPS *sps = ff_evc_parse_sps(&ctx->ps, buf, buf_size); + if (!sps) { + av_log(avctx, AV_LOG_ERROR, "SPS parsing error\n"); + return AVERROR_INVALIDDATA; + } + break; + } + case EVC_PPS_NUT: { + EVCParserPPS *pps = ff_evc_parse_pps(&ctx->ps, buf, buf_size); + if (!pps) { + av_log(avctx, AV_LOG_ERROR, "PPS parsing error\n"); + return AVERROR_INVALIDDATA; + } + break; + } + case EVC_IDR_NUT: // Coded slice of a IDR or non-IDR picture + case EVC_NOIDR_NUT: { + const EVCParserPPS *pps; + const EVCParserSPS *sps; + EVCParserSliceHeader sh; + int bit_depth; + int ret; + + ret = ff_evc_parse_slice_header(&sh, &ctx->ps, nalu_type, buf, buf_size); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Slice header parsing error\n"); + return ret; + } + + pps = ctx->ps.pps[sh.slice_pic_parameter_set_id]; + sps = ctx->ps.sps[pps->pps_seq_parameter_set_id]; + av_assert0(sps && pps); + + s->coded_width = sps->pic_width_in_luma_samples; + s->coded_height = sps->pic_height_in_luma_samples; + + if (sps->picture_cropping_flag) { + s->width = sps->pic_width_in_luma_samples - sps->picture_crop_left_offset - sps->picture_crop_right_offset; + s->height = sps->pic_height_in_luma_samples - sps->picture_crop_top_offset - sps->picture_crop_bottom_offset; + } else { + s->width = sps->pic_width_in_luma_samples; + s->height = sps->pic_height_in_luma_samples; + } + + switch (sh.slice_type) { + case EVC_SLICE_TYPE_B: { + s->pict_type = AV_PICTURE_TYPE_B; + break; + } + case EVC_SLICE_TYPE_P: { + s->pict_type = AV_PICTURE_TYPE_P; + break; + } + case EVC_SLICE_TYPE_I: { + s->pict_type = AV_PICTURE_TYPE_I; + break; + } + default: { + s->pict_type = AV_PICTURE_TYPE_NONE; + } + } + + avctx->profile = sps->profile_idc; + + 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(&avctx->framerate.den, &avctx->framerate.num, num, den, 1 << 30); + } else + avctx->framerate = (AVRational) { 0, 1 }; + + bit_depth = sps->bit_depth_chroma_minus8 + 8; + s->format = AV_PIX_FMT_NONE; + + switch (bit_depth) { + case 8: + s->format = pix_fmts_8bit[sps->chroma_format_idc]; + break; + case 9: + s->format = pix_fmts_9bit[sps->chroma_format_idc]; + break; + case 10: + s->format = pix_fmts_10bit[sps->chroma_format_idc]; + break; + case 12: + s->format = pix_fmts_12bit[sps->chroma_format_idc]; + break; + case 14: + s->format = pix_fmts_14bit[sps->chroma_format_idc]; + break; + case 16: + s->format = pix_fmts_16bit[sps->chroma_format_idc]; + break; + } + + s->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; + + s->output_picture_number = ctx->poc.PicOrderCntVal; + + break; + } + case EVC_SEI_NUT: // Supplemental Enhancement Information + case EVC_APS_NUT: // Adaptation parameter set + case EVC_FD_NUT: // Filler data + default: + break; + } + + return 0; +} + /** * Parse NAL units of found picture and decode some basic information. * @@ -35,13 +209,13 @@ */ static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t *buf, int buf_size) { - EVCParserContext *ctx = s->priv_data; const uint8_t *data = buf; int data_size = buf_size; int bytes_read = 0; - int nalu_size = 0; while (data_size > 0) { + int nalu_size = 0; + int ret; // Buffer size is not enough for buffer to store NAL unit 4-bytes prefix (length) if (data_size < EVC_NALU_LENGTH_PREFIX_SIZE) @@ -57,31 +231,12 @@ static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const if (data_size < nalu_size) return AVERROR_INVALIDDATA; - if (ff_evc_parse_nal_unit(ctx, data, nalu_size, avctx) != 0) { + ret = parse_nal_unit(s, avctx, data, nalu_size); + if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Parsing of NAL unit failed\n"); return AVERROR_INVALIDDATA; } - if(ctx->nalu_type == EVC_SPS_NUT) { - - s->coded_width = ctx->coded_width; - s->coded_height = ctx->coded_height; - s->width = ctx->width; - s->height = ctx->height; - - s->format = ctx->format; - - avctx->framerate = ctx->framerate; - avctx->profile = ctx->profile; - - } else if(ctx->nalu_type == EVC_NOIDR_NUT || ctx->nalu_type == EVC_IDR_NUT) { - - s->pict_type = ctx->pict_type; - s->key_frame = ctx->key_frame; - s->output_picture_number = ctx->output_picture_number; - - } - data += nalu_size; data_size -= nalu_size; } @@ -90,8 +245,10 @@ static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const // Decoding nal units from evcC (EVCDecoderConfigurationRecord) // @see @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.2 -static int decode_extradata(EVCParserContext *ctx, const uint8_t *data, int size, void *logctx) +static int decode_extradata(AVCodecParserContext *s, AVCodecContext *avctx) { + const uint8_t *data = avctx->extradata; + int size = avctx->extradata_size; int ret = 0; GetByteContext gb; @@ -108,7 +265,7 @@ static int decode_extradata(EVCParserContext *ctx, const uint8_t *data, int size // The value of this field shall be one of 0, 1, or 3 corresponding to a length encoded with 1, 2, or 4 bytes, respectively. if (bytestream2_get_bytes_left(&gb) < 18) { - av_log(logctx, AV_LOG_ERROR, "evcC %d too short\n", size); + av_log(avctx, AV_LOG_ERROR, "evcC %d too short\n", size); return AVERROR_INVALIDDATA; } @@ -121,7 +278,7 @@ static int decode_extradata(EVCParserContext *ctx, const uint8_t *data, int size if( nalu_length_field_size != 1 && nalu_length_field_size != 2 && nalu_length_field_size != 4 ) { - av_log(logctx, AV_LOG_ERROR, "The length in bytes of the NALUnitLenght field in a EVC video stream has unsupported value of %d\n", nalu_length_field_size); + av_log(avctx, AV_LOG_ERROR, "The length in bytes of the NALUnitLenght field in a EVC video stream has unsupported value of %d\n", nalu_length_field_size); return AVERROR_INVALIDDATA; } @@ -142,7 +299,7 @@ static int decode_extradata(EVCParserContext *ctx, const uint8_t *data, int size int nal_unit_length = bytestream2_get_be16(&gb); if (bytestream2_get_bytes_left(&gb) < nal_unit_length) { - av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit size in extradata.\n"); + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size in extradata.\n"); return AVERROR_INVALIDDATA; } @@ -150,8 +307,8 @@ static int decode_extradata(EVCParserContext *ctx, const uint8_t *data, int size nal_unit_type == EVC_PPS_NUT || nal_unit_type == EVC_APS_NUT || nal_unit_type == EVC_SEI_NUT ) { - if (ff_evc_parse_nal_unit(ctx, gb.buffer, nal_unit_length, logctx) != 0) { - av_log(logctx, AV_LOG_ERROR, "Parsing of NAL unit failed\n"); + if (parse_nal_unit(s, avctx, gb.buffer, nal_unit_length) != 0) { + av_log(avctx, AV_LOG_ERROR, "Parsing of NAL unit failed\n"); return AVERROR_INVALIDDATA; } } @@ -173,8 +330,11 @@ static int evc_parse(AVCodecParserContext *s, AVCodecContext *avctx, int ret; EVCParserContext *ctx = s->priv_data; + s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; + s->key_frame = 0; + if (avctx->extradata && !ctx->parsed_extradata) { - decode_extradata(ctx, avctx->extradata, avctx->extradata_size, avctx); + decode_extradata(s, avctx); ctx->parsed_extradata = 1; } @@ -187,8 +347,6 @@ static int evc_parse(AVCodecParserContext *s, AVCodecContext *avctx, return buf_size; } - s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; - // poutbuf contains just one Access Unit *poutbuf = buf; *poutbuf_size = buf_size; From patchwork Sat Jun 17 22:00:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42180 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp2448606pzb; Sat, 17 Jun 2023 15:01:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ54ckC7SQFjUtFTOwSujS825kh14Ko7M1km3Skx72ZBxv0U37ppTjsczMwGIACjWfKUmWn4 X-Received: by 2002:a17:907:9801:b0:96a:246b:c65d with SMTP id ji1-20020a170907980100b0096a246bc65dmr6750349ejc.12.1687039296036; Sat, 17 Jun 2023 15:01:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687039296; cv=none; d=google.com; s=arc-20160816; b=G3C+CvsEju0qmXIcnaH1ql7ZZCtLvuuqkwZa7ohUOQmuU48w22LAouWKgjAllJlurQ GwY0NoaRwQtdPatbdMuXp8D75u07YjSRPiJj5ztS/FrXHszEL1V6CIrG9LRPmpGMo/H1 NzGbwHBAZZ6qj8VnwnutNDiH5h1BBTWBaftGt/G9KweAAtGf4nNRamvaz7JK+7nV3518 nGHI7B1bsdFZpVfPtSo2edGMxY82SIML85DZN78Fo+vNSQC3M3tB2wKmCmXBJksxM6r6 6ugWV1dEVl0S2A45Mhe5PDLQZjDDbVuwjQNxtoEw+REZ/msLMZAYPqsHmC2UyZCYl48N y1ZA== 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=ZPFzimhuy/RpPcLZ4O0TBoaad37XMsmSeQa/mOsZ7QQ=; b=BPsIoFgr/KAlHzAdr46DBiol7A5A4BoM72sAAXFRd2xhxLcFxUa72DuEN7m9gP8aA2 /cQghm1H2eF05Rp+qzk3BvJzXGYrKwaOsMF9n6hE9oVTfi4Jufh8xTjOgXwAW8XjME/v x50ANnGHyBzuh9ixNJnDD+onFmswOexxWSuA1zf1sOG/TdNBlLH0W6s8DO6DbdGVAyFu 44+lJmFCwcLjjuaUTp3fOltlLb9sUVUBMUC9vwycKFP+MnxWFF6ZDTIyRyeaI0XM2fBl 5nb05h4U5N8stHaRo3FrZxgPUbAPP9+95zkRC96/W5G9rZMtqSyqlUyf6l1pZRFEKi7e VlLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=l71PX2bD; 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 d27-20020a170906371b00b00988479dc7f1si452905ejc.764.2023.06.17.15.01.35; Sat, 17 Jun 2023 15:01:36 -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=l71PX2bD; 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 DCB7868BF69; Sun, 18 Jun 2023 01:00:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DF0A268BF44 for ; Sun, 18 Jun 2023 01:00:48 +0300 (EEST) Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-1a9acdddb20so1905914fac.0 for ; Sat, 17 Jun 2023 15:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687039247; x=1689631247; 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=+tvaZ6IbcNmMZCqixKsSfCQQTWWZrSHNCELARU3yyeM=; b=l71PX2bDZvxxEpTnUnJytAhyKRnng3S5hqAfN5hby5a9IvghmjZ7YNi572QC2lIRM8 07LAOcE1AEEliRk17IOLbNMF+zTwMsZqrWIDvKNMxpJMw9DK8RzdGCeasbr7xxTS0jeM 9UdBHk3MRH3FrJunBR6j+6d3xfIeqBh9+kyw9M3Ed7KIfsYtwUIisr1RCfm+5gH0RqFd 3f6nPEj4e+v/78AW6Bb5E2Y55Sj6SJj8BQ9XCRpndtV7ApiMP0CkMzbqCo5E1j5usTqq 8JcEtQeI1XIX6Dc124hrwod4VLDv4Ek3DvlB4YGZb9gJ1te5lEX5t1I8QB3MlLlMbV93 i4uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687039247; x=1689631247; 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=+tvaZ6IbcNmMZCqixKsSfCQQTWWZrSHNCELARU3yyeM=; b=Vi8dyZwz4zkmrvAIA8QFNulAaXhl7awt1+WpUlKS4je1sAnX9k3P77yfRuH0VJfX6M eujnaMthYllmbq99+TcGfmh/4KSbHaOUp17Br3XIPtWgNyOWnlg2I7JY5nlJtanFtkBm LYvk97gNoChCaqvSBe4vomwUZzATXuNuF2QecmWgit3pnDIy7i86lrv3ur4rABaywR3J Ny/v0MZNkw82gijrYH+dx2N2SIlzGstu1sYldUBCdD+v2qih6Xu9BnZkSQxa+PekY30Q eGteQ7VgiK1uH4oPJJKOPpp2JZMebE6PHq44qmaOKaakNe6gIrhK+t5dh6Lo5ZlFTWeQ g20A== X-Gm-Message-State: AC+VfDzc0GLYaBPSZO5VF8bDl0u00Iq6YqjFeHsc5xQT7l5H5Q7rI4aV K/PH5cVdQoiM48AcP9U71Y0qvH+DFeg= X-Received: by 2002:a05:6870:c787:b0:1a6:8fdd:9902 with SMTP id dy7-20020a056870c78700b001a68fdd9902mr1770153oab.19.1687039247007; Sat, 17 Jun 2023 15:00:47 -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.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 15:00:46 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Jun 2023 19:00:13 -0300 Message-ID: <20230617220015.12669-5-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 08/10] avcodec/evc_parser: remove write only variable 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: zLq7lWpSuCdS Signed-off-by: James Almer --- libavcodec/evc_parser.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c index d22922d1c9..c30da6846e 100644 --- a/libavcodec/evc_parser.c +++ b/libavcodec/evc_parser.c @@ -211,7 +211,6 @@ static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const { const uint8_t *data = buf; int data_size = buf_size; - int bytes_read = 0; while (data_size > 0) { int nalu_size = 0; @@ -223,7 +222,6 @@ static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const nalu_size = evc_read_nal_unit_length(data, data_size, avctx); - bytes_read += EVC_NALU_LENGTH_PREFIX_SIZE; data += EVC_NALU_LENGTH_PREFIX_SIZE; data_size -= EVC_NALU_LENGTH_PREFIX_SIZE; From patchwork Sat Jun 17 22:00:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42181 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp2448691pzb; Sat, 17 Jun 2023 15:01:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lwuwjiL2d15ZA+ZW+peH/0lWk7iz4uZmWEwI+Pp9Y+A+e58Z52sDITc8TbGyUakSko4T5 X-Received: by 2002:a17:907:1c96:b0:977:cad5:1580 with SMTP id nb22-20020a1709071c9600b00977cad51580mr6130876ejc.40.1687039305450; Sat, 17 Jun 2023 15:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687039305; cv=none; d=google.com; s=arc-20160816; b=uQdCP8opsaLIlF1Fz/dKL0JgnD+iPvPz7KzfaLR/qQc38AC4GDWg0mn2uQebNf/12m yc0pp1xBPhtV6NYqUXzLCDRQJeGb+VcNGvcTjQ/7TjpNCeNXPPkPiPAq7iFbRood9zsD EDZgmsZQZCfew6bBKi96qRsu3/FrGPjrXW1rxjojyBqWeoJTan8iy9lEZrmfa2Kw+7p1 suaWoyDqSYS0yGhlzvauh/IY+XEUdXLMHJ5UCZiTHv9YX6jZ4McQ5gnGiLeJCeLkU2KD pfCCZP+6ge8ZIJWJRIXG/h2kT1S5IzkJoiVU9MhWzPJ9F3+7u492/gJ3ZNurNt1j1wBH JV9Q== 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=CmEsQYd2kt1d9NGxl/gCMh4BGH99HLfBh+/MYzXH+ek=; b=YYDgs6TrJXoQoKWqAWyN+YlTfyY6NufrTkPYef47KYxQeCBWR6Lm1IkKAXYnuNqI+E 9wHJA7ULIt3Z0SKWZPgl7yAmHpF8G0uyN8X9wSDRQDAzb5zGf+ZhrfYKWPJ462ui8nlJ bn2O5ELq9q4JHjmP49mKupyMrY5ncByOOINDPk5ljVdfHjX1HUMRuaiox5wv4csL/aLp CrjE4I7LNJ4AypVPWVp/4vhz2RrgQLfhGRm2VA0RAAtIdvceFXHPTbyVSRDnDqa9wDRK pmzKqBrMJWnr2qS68rBeEOK6OksPQHFDmGzr9d0Qfu+Zvh10sJfc1Qlrwm4U2r8xw9sq OU/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=gFvoHI1u; 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 p1-20020a17090628c100b00977c4ffb2d4si12565236ejd.310.2023.06.17.15.01.45; Sat, 17 Jun 2023 15:01:45 -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=gFvoHI1u; 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 D95B868BF88; Sun, 18 Jun 2023 01:00:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7D0F968BF66 for ; Sun, 18 Jun 2023 01:00:50 +0300 (EEST) Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-1a6a2cb4659so2226224fac.1 for ; Sat, 17 Jun 2023 15:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687039249; x=1689631249; 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=0uv2zyfNQ0Y7+UuVwSoP62jugHjIkPPW82E0tzK1/fE=; b=gFvoHI1uIQSX2o1rWfSdX/XhsYgsdKc02dBJPynDClia53y6/0W0rgjatCL/8HSuwr OXxqiU6zEHN7Xe6ZMUxIACF+lVv+C8f/LrfUkcBEFxyF6wxVaZA1RYjVAIAjVuNGrKYB +LhFtfdgSHzspr1JMQmsIlOJBvCACZ76fluLOZbqh2vGZvP+rCfSSp/Td5mIY9C2xs51 wLoKnqg6L1AiaEzS42/Dfc5GCD4v3pmVvG2hCEk6iILLMyVMZovIGgGIv5qW3kihyqtS QOL/sNt3AvEXbYJO6BpAGEI+BtGCcK011Dy0Lh2j1NpEg7uV7pFeK44LTYOBuVY1l3HW cvJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687039249; x=1689631249; 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=0uv2zyfNQ0Y7+UuVwSoP62jugHjIkPPW82E0tzK1/fE=; b=Denc3bCvzUF6VgRoAUK3FNiqNFkHdK4aS1raWe0Sz5TVYM6YTa6Wn63pQLO1RRHZJe 5l7LEYOKy+Bk8EqgMssT7JBv3TP+riGXNz+mUQE0nAQUph/HMnQbmxyZcVymfon1HxFT oXK3DAt1qufAmd30XfP24WfG76gXzSi9ZLAd8STKmvkqH7urvULtssBmG/GRg1jUZGgZ BEBAxfbr2NIYxeRu9WRFQQhkDm5mPnJoag5/ZLi1q73a70YpLOGKWPgrTbJdFI+IE2Af qqZ0yx5hoLJKEUFOUyrPBnHHKJwmD6vhxpt3nNcBX02KCQ86BbGvl/ekieNXhS2gvYED MHlA== X-Gm-Message-State: AC+VfDxN4XBYcX2OieZkk8xs9pkKjqq6qmzJc96f2Bwo4pebQ0TSobX7 oHmyFSvWo6TJ1+thn0B/g8vEShgNn2c= X-Received: by 2002:a05:6871:6a87:b0:192:8551:6d03 with SMTP id zf7-20020a0568716a8700b0019285516d03mr1619653oab.27.1687039248779; Sat, 17 Jun 2023 15:00:48 -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.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 15:00:48 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Jun 2023 19:00:14 -0300 Message-ID: <20230617220015.12669-6-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 09/10] avcodec/evc_frame_merge_bsf: make ff_evc_parse_nal_unit() local to the filter 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: Yd0hAXtmtfu2 Signed-off-by: James Almer --- libavcodec/evc_frame_merge_bsf.c | 114 +++++++++++++++++++++++++------ 1 file changed, 92 insertions(+), 22 deletions(-) diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c index f497780afb..817136a551 100644 --- a/libavcodec/evc_frame_merge_bsf.c +++ b/libavcodec/evc_frame_merge_bsf.c @@ -35,20 +35,27 @@ typedef struct AccessUnitBuffer { typedef struct EVCFMergeContext { AVPacket *in; - EVCParserContext parser_ctx; + EVCParamSets ps; + EVCParserPoc poc; AccessUnitBuffer au_buffer; } EVCFMergeContext; -static int end_of_access_unit_found(EVCParserContext *parser_ctx) +static int end_of_access_unit_found(const EVCParamSets *ps, const EVCParserSliceHeader *sh, + const EVCParserPoc *poc, enum EVCNALUnitType nalu_type) { - if (parser_ctx->profile == 0) { // BASELINE profile - if (parser_ctx->nalu_type == EVC_NOIDR_NUT || parser_ctx->nalu_type == EVC_IDR_NUT) + EVCParserPPS *pps = ps->pps[sh->slice_pic_parameter_set_id]; + EVCParserSPS *sps = ps->sps[pps->pps_seq_parameter_set_id]; + + av_assert0(sps && pps); + + if (sps->profile_idc == 0) { // BASELINE profile + if (nalu_type == EVC_NOIDR_NUT || nalu_type == EVC_IDR_NUT) return 1; } else { // MAIN profile - if (parser_ctx->nalu_type == EVC_NOIDR_NUT) { - if (parser_ctx->poc.PicOrderCntVal != parser_ctx->poc.prevPicOrderCntVal) + if (nalu_type == EVC_NOIDR_NUT) { + if (poc->PicOrderCntVal != poc->prevPicOrderCntVal) return 1; - } else if (parser_ctx->nalu_type == EVC_IDR_NUT) + } else if (nalu_type == EVC_IDR_NUT) return 1; } return 0; @@ -58,7 +65,7 @@ static void evc_frame_merge_flush(AVBSFContext *bsf) { EVCFMergeContext *ctx = bsf->priv_data; - ff_evc_ps_free(&ctx->parser_ctx.ps); + ff_evc_ps_free(&ctx->ps); av_packet_unref(ctx->in); ctx->au_buffer.data_size = 0; } @@ -66,12 +73,10 @@ static void evc_frame_merge_flush(AVBSFContext *bsf) static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) { EVCFMergeContext *ctx = bsf->priv_data; - EVCParserContext *parser_ctx = &ctx->parser_ctx; - AVPacket *in = ctx->in; - - size_t nalu_size = 0; uint8_t *buffer, *nalu = NULL; + enum EVCNALUnitType nalu_type; + int tid, nalu_size = 0; int au_end_found = 0; int err; @@ -81,29 +86,91 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) nalu_size = evc_read_nal_unit_length(in->data, EVC_NALU_LENGTH_PREFIX_SIZE, bsf); if (nalu_size <= 0) { - av_packet_unref(in); - return AVERROR_INVALIDDATA; + err = AVERROR_INVALIDDATA; + goto end; } nalu = in->data + EVC_NALU_LENGTH_PREFIX_SIZE; nalu_size = in->size - EVC_NALU_LENGTH_PREFIX_SIZE; // NAL unit parsing needed to determine if end of AU was found - err = ff_evc_parse_nal_unit(parser_ctx, nalu, nalu_size, bsf); - if (err < 0) { - av_log(bsf, AV_LOG_ERROR, "NAL Unit parsing error\n"); - av_packet_unref(in); + if (nalu_size <= 0) { + av_log(bsf, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", nalu_size); + err = AVERROR_INVALIDDATA; + goto end; + } - return err; + // @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(nalu, nalu_size, bsf); + if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) { + av_log(bsf, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", nalu_type); + err = AVERROR_INVALIDDATA; + goto end; } - au_end_found = end_of_access_unit_found(parser_ctx); + tid = ff_evc_get_temporal_id(nalu, nalu_size, bsf); + if (tid < 0) { + av_log(bsf, AV_LOG_ERROR, "Invalid temporial id: (%d)\n", tid); + err = AVERROR_INVALIDDATA; + goto end; + } + + nalu += EVC_NALU_HEADER_SIZE; + nalu_size -= EVC_NALU_HEADER_SIZE; + + switch (nalu_type) { + case EVC_SPS_NUT: { + EVCParserSPS *sps = ff_evc_parse_sps(&ctx->ps, nalu, nalu_size); + if (!sps) { + av_log(bsf, AV_LOG_ERROR, "SPS parsing error\n"); + err = AVERROR_INVALIDDATA; + goto end; + } + break; + } + case EVC_PPS_NUT: { + EVCParserPPS *pps = ff_evc_parse_pps(&ctx->ps, nalu, nalu_size); + if (!pps) { + av_log(bsf, AV_LOG_ERROR, "PPS parsing error\n"); + err = AVERROR_INVALIDDATA; + goto end; + } + break; + } + case EVC_IDR_NUT: // Coded slice of a IDR or non-IDR picture + case EVC_NOIDR_NUT: { + EVCParserSliceHeader sh; + + err = ff_evc_parse_slice_header(&sh, &ctx->ps, nalu_type, nalu, nalu_size); + if (err < 0) { + av_log(bsf, AV_LOG_ERROR, "Slice header parsing error\n"); + goto end; + } + + // 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 + err = ff_evc_derive_poc(&ctx->ps, &sh, &ctx->poc, nalu_type, tid); + if (err < 0) + goto end; + + au_end_found = end_of_access_unit_found(&ctx->ps, &sh, &ctx->poc, nalu_type); + + break; + } + case EVC_SEI_NUT: // Supplemental Enhancement Information + case EVC_APS_NUT: // Adaptation parameter set + case EVC_FD_NUT: // Filler data + default: + break; + } buffer = av_fast_realloc(ctx->au_buffer.data, &ctx->au_buffer.capacity, ctx->au_buffer.data_size + in->size); if (!buffer) { av_freep(&ctx->au_buffer.data); - return AVERROR(ENOMEM); + err = AVERROR_INVALIDDATA; + goto end; } ctx->au_buffer.data = buffer; @@ -128,6 +195,9 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) if (err < 0 && err != AVERROR(EAGAIN)) ctx->au_buffer.data_size = 0; +end: + if (err < 0) + av_packet_unref(in); return err; } @@ -147,7 +217,7 @@ static void evc_frame_merge_close(AVBSFContext *bsf) EVCFMergeContext *ctx = bsf->priv_data; av_packet_free(&ctx->in); - ff_evc_ps_free(&ctx->parser_ctx.ps); + ff_evc_ps_free(&ctx->ps); ctx->au_buffer.capacity = 0; av_freep(&ctx->au_buffer.data); 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] = { From patchwork Sun Jun 18 23:43:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42214 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp349036pzb; Sun, 18 Jun 2023 16:43:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ44v5RADnLtv/3KJMkOGtE5G2VMymOiNFbvRNCYOB2V5KV9GJEVgYGaHmirHoKwOiu6stHJ X-Received: by 2002:a05:6402:5186:b0:51a:5ad9:5851 with SMTP id q6-20020a056402518600b0051a5ad95851mr1030862edd.3.1687131837740; Sun, 18 Jun 2023 16:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687131837; cv=none; d=google.com; s=arc-20160816; b=x9pJnWTmzyO4ccCAeeydr+zY6f808Tev0Y68j82GC9vToCOvJ/fTvB10TVWSv2IXdh wfxeEAVUIVRLOkUQWcgZHtAGNxhGdZLdaU1KkjXvG84aveuUPzZoBOcCfT/Ku+VwS838 f/2jjp4aQMqXJXW+RFWORMLvhla4XHEF33Df/JV5Au5aTR8tnIQoX0VzldBgrNLNfX7H QqRBZ9U1qh6wqHeHQiTWm1f4uIo7scPFPNFu7zuNrSDSPODIbwpqQHlbe4Pfmshvpbge s0QE3tGuEc2BxihFgUpowUkpmhM0moUX7zbdEoZIg+YX1spZ3F7xr5bsKXo8ZhwO4iYj CaZg== 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=c+2ATPWdwtxzMHDKdtN3X8TKO7C35jKkoT5FY2bVyFE=; b=h99EdgcGI2wG7xJXy7HgVuiyZkboTVlk9nVFkLa3JyNvNkroA2nNIM4fFomJVo+R0O zS/rap+0TmYsOn7e8HbuwZKrFYC83x/aiyStv7tCHDdRS7RFEy7Xvr6Ujg7nXZQJsmgV UU1le0zrn/1OHVNwbuE8s5XGjKiyWXacr8TB7DLGW/zupgn16tKp+01XDndjydCo9IuU 8MF3bVrlMXI/DKoMucPYRhsUeSa+8dUPvv4scpoeA/a3363Alu7uYdZbWWO8KFGGW3xL 4zUns3UrJzjT1guDf1l+IK7p1ezCsmcdi3OdH9LzHs5j3fjyAeVOCZCGdRqfEH5PghUB 7W2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=hK501n7w; 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 y9-20020aa7c249000000b00514a0879266si13810669edo.207.2023.06.18.16.43.57; Sun, 18 Jun 2023 16:43:57 -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=hK501n7w; 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 66EAF689E65; Mon, 19 Jun 2023 02:43:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CFF5968B22C for ; Mon, 19 Jun 2023 02:43:46 +0300 (EEST) Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-39e86b3da59so2446425b6e.3 for ; Sun, 18 Jun 2023 16:43:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687131825; x=1689723825; 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=zL4qUVcG8B4rHh/h+6juTgb5MfiUJ0HgoSyfL3e6A4Y=; b=hK501n7wjNMZjVrcjhZCoq1fYS2JMhfOrOIH9mphB0JrP0OCuF6WHYS5OiWcmOaL6V QglkDYRHV50bLGfKnLbdi30f6AOgOqFV8i1LNvdvve+FwfHy2W5u5KVdydsFP5ppllap yVHCCeHaIL4do+/lX2wa7ltkY6KVe6AwEJ2zqiUPKT6ojMio7kvA9D4YdjS8Glq4VpmL vXFkXCsV1eoEhiMY5UJqo6IURxwOwo3dJB9oPgZ5xOJUS5/OYZobcDHLFKutoeLVtLc+ d56hcRK/oBsvw+YhzjkoInpgsi67Sp4uWDBE+I71vLYfbdsuZYnGzckIgOslvqUkSiJB BHSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687131825; x=1689723825; 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=zL4qUVcG8B4rHh/h+6juTgb5MfiUJ0HgoSyfL3e6A4Y=; b=PgIEK4A0IgpPJ1d8aUESUuiyFDZMpgxfYdmJ327Ha13YB5CZ/ee8wPO7DSAMVoGWk1 mroBug/RKaDDarPZNuZFdQCZ1I9PET4goKW2V2+FIkE4MlQM16GGsMU+3uully83XzAT LAi0Dt/ytaQtNH2eHlP4FbaDgt+61eeryT2BZXPqArWxjguIqd//Wu86H3wKS55SQVh8 yzZ4H5z6fnjAB2ftjUnI3+Dn1agW8ZSWP9wOlcmye8JNlJ2H3Eh5pt2TTYpCjSknxhNG stDb7ma/gL4rFR7svjbYyUTw8BUUVUi88mI+FsBQ4JJt1rF5pDPKH567f8bhyUkT3m93 0rdQ== X-Gm-Message-State: AC+VfDwx9PeOXvVmyu2TPvIEBLHhNdpp27n37PMR0TtnkUmDcMtbphIV yXDROkXHPKDcD9YprQ7PKZu1spcPf88= X-Received: by 2002:a05:6808:693:b0:396:40c4:a2ef with SMTP id k19-20020a056808069300b0039640c4a2efmr9105755oig.11.1687131824780; Sun, 18 Jun 2023 16:43:44 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id bk36-20020a0568081a2400b0039eb5f4543csm2069664oib.34.2023.06.18.16.43.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 16:43:44 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 20:43:26 -0300 Message-ID: <20230618234332.1370-1-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 11/17] avformat/evc: don't use an AVIOContext as log context 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: a/Wc6jBjn5O0 Signed-off-by: James Almer --- libavcodec/evc_parse.h | 3 ++- libavformat/evc.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/evc_parse.h b/libavcodec/evc_parse.h index a1fbbc643d..677e01a64a 100644 --- a/libavcodec/evc_parse.h +++ b/libavcodec/evc_parse.h @@ -105,7 +105,8 @@ static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_si uint32_t nalu_len = 0; if (bits_size < EVC_NALU_LENGTH_PREFIX_SIZE) { - av_log(logctx, AV_LOG_ERROR, "Can't read NAL unit length\n"); + if (logctx) // Don't log without a context + av_log(logctx, AV_LOG_ERROR, "Can't read NAL unit length\n"); return 0; } diff --git a/libavformat/evc.c b/libavformat/evc.c index dc75ccb56d..a7cc6167e8 100644 --- a/libavformat/evc.c +++ b/libavformat/evc.c @@ -359,7 +359,7 @@ int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data, evcc_init(&evcc); while (bytes_to_read > EVC_NALU_LENGTH_PREFIX_SIZE) { - nalu_size = evc_read_nal_unit_length(data, EVC_NALU_LENGTH_PREFIX_SIZE, pb); + nalu_size = evc_read_nal_unit_length(data, EVC_NALU_LENGTH_PREFIX_SIZE, NULL); if (nalu_size == 0) break; data += EVC_NALU_LENGTH_PREFIX_SIZE; @@ -367,7 +367,7 @@ int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data, if (bytes_to_read < nalu_size) break; - nalu_type = evc_get_nalu_type(data, bytes_to_read, pb); + nalu_type = evc_get_nalu_type(data, bytes_to_read, NULL); // @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.3 // NAL_unit_type indicates the type of the NAL units in the following array (which shall be all of that type); From patchwork Sun Jun 18 23:43:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42215 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp349095pzb; Sun, 18 Jun 2023 16:44:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7boN+qtK4ztre7rBvQVkYgxfmgXf8iglT9bn6cwZTHrSveC6bwM6zO8dekRHHOWA5jL+aW X-Received: by 2002:aa7:cccf:0:b0:51a:5e59:dba with SMTP id y15-20020aa7cccf000000b0051a5e590dbamr140743edt.6.1687131847501; Sun, 18 Jun 2023 16:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687131847; cv=none; d=google.com; s=arc-20160816; b=M2cIJQyr2lZ43iMpxjxrDMPD0b9HpRL/UOsorXUTr1xvExc2GI21IxkCvXS0FPkAdX AH5nGi/rsY2DOhzkmx54P34XsGwBtt1Q0Ns1DGl8ut/OJh/L1+io2KCY5UzesOnlvFqt 4HHE4BR3tKX9kzh0xw4XNRMRSFHYydjdCq4SR9vuxSUovcdwohibOtAYgvkZNx4Cbuwe UwcYbLznlAKLbwftfS/QDaKpD8uE2USvAqlzGKiZNItSp5iY/3qxiaIUACrsDu4Afq8v np3TvcD3ZNPpRsl+lKRLb9D81RCeyoIJQxb1EUJtxddp7Ws2KEY7pSK7UveosEj9xmtL kC+Q== 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=RjAK0zCF11icI8bT6e4H3S+/qby0n7xAn/p1M2JcXZI=; b=wn1qcp0u+oLFuPGLClLt1LAizDrj45mDgDSnduVDTxbH6vTtTJMfn34S8civ0Ezm7G K4d4eLOWA2k7qktG0FDYZJHu9R8JDr4u8bxqotySVnpGBbQXnx8kQ3NMZ/uWadH1nLiC HHIqHmKbl6K7RI7IqWu3Op2vBx+/tvxhPBB82mCDUfbnEStVjxj7O0ZCqm43g7Gh+gzU bynfhCeSvPn2o9VG9H+Il2hikcd4muVvemdUrhPn+gvZFakNCxMVYoyIXFCcZ4oDxd6M yxCweC+xPQuuUkw3PjqbcmINoLzqPA8B+894+UsfSkJQTbLgGdOsySXkfCm9wDlnNvG0 Oomg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=dSd7vtyE; 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 g25-20020aa7d1d9000000b00519ebe84231si5316940edp.163.2023.06.18.16.44.07; Sun, 18 Jun 2023 16:44:07 -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=dSd7vtyE; 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 7D6EF68BF50; Mon, 19 Jun 2023 02:43:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 21DD768BF1D for ; Mon, 19 Jun 2023 02:43:48 +0300 (EEST) Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6b46f27f562so410545a34.0 for ; Sun, 18 Jun 2023 16:43:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687131826; x=1689723826; 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=dUuCE2HCD6Bmk7QMz02iLT1pZMs+Cf6miQLb4EZFRzc=; b=dSd7vtyE96coHJdsPcGz2M3iQW3Q6I9J1N+an2ZXj2cJI/UBAiYqZak3Scrpw1Q3z4 ztZlYEUr5vRo7ZH5UpL9GkYUd6OxOUaNMLeujPJPSCTlJgfD2j7Y5T6wTvSwVTDLmh60 XQjdczTUxKZga0fY+1ECjTenGupP7EdCS046kYPEq69/gH4KkOM5fHfTdkUoipBMUoVg ri20b4Fey4Vu2CwPADhRb6fUojcxpp3WKrwcfq8mONhgBG2szhVS9tY6feaHfJH+hc9B N+D6v39tZ0HZ47XTXqHPXTZrMYE4wKyF/yWCu2Q/iqVta3Iocpdr5BpqQZA5v4U9tVa1 Tk9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687131826; x=1689723826; 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=dUuCE2HCD6Bmk7QMz02iLT1pZMs+Cf6miQLb4EZFRzc=; b=kMlq5CmvU3qxeFx1XXBb0d5u1n6qX5/FvB3xOv18e4fO+XLcnqo2WzfWQOxF7w3Cbs jX2G5BwZ59/H2HcWGZLqxX9WJpfabO/ffR/y+QqDEMnkUoA5jrEecI4fC5Vvdg/PwleW kVct7ZGFsPaiAX522t/dKnWFY2avd1seEOyKnPv7oqEadT9/m+YIz87U70d30oG+aH1p yfgixFe0LZ1+iXzAy3ir2qD3fMjGd5HY8sR9iKvuAR6sg0WnEEDQdFG56DNDjtoMyBst skADZvMqYkqGSC6d213+quH8RBWI8M8n7I9powCTHkOP9W+tMdjZJKIxb2r1U9v2DfVS QpMQ== X-Gm-Message-State: AC+VfDwoQ/tcpMr5RQSi9YaO3Dldh59y1/chEJYND5tKH0K+QvN+Au1b +2rMGKxIf8mI5WbkcpxT645N3DrzXAs= X-Received: by 2002:a05:6808:1145:b0:398:4795:930c with SMTP id u5-20020a056808114500b003984795930cmr6602625oiu.48.1687131826046; Sun, 18 Jun 2023 16:43:46 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id bk36-20020a0568081a2400b0039eb5f4543csm2069664oib.34.2023.06.18.16.43.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 16:43:45 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 20:43:27 -0300 Message-ID: <20230618234332.1370-2-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 12/17] avformat/evcdec: deduplicate nalu length and type parsing functions 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: AaRvMD+e6yIU Signed-off-by: James Almer --- libavformat/evcdec.c | 46 ++++---------------------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c index 807406885a..0f17edd371 100644 --- a/libavformat/evcdec.c +++ b/libavformat/evcdec.c @@ -20,10 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcodec/get_bits.h" -#include "libavcodec/golomb.h" #include "libavcodec/internal.h" #include "libavcodec/evc.h" +#include "libavcodec/evc_parse.h" #include "libavcodec/bsf.h" #include "libavutil/opt.h" @@ -66,43 +65,6 @@ static const AVClass evc_demuxer_class = { .version = LIBAVUTIL_VERSION_INT, }; -static int get_nalu_type(const uint8_t *bits, int bits_size) -{ - int unit_type_plus1 = 0; - - if (bits_size >= EVC_NALU_HEADER_SIZE) { - unsigned char *p = (unsigned char *)bits; - // forbidden_zero_bit - if ((p[0] & 0x80) != 0) // Cannot get bitstream information. Malformed bitstream. - return -1; - - // nal_unit_type - unit_type_plus1 = (p[0] >> 1) & 0x3F; - } - - return unit_type_plus1 - 1; -} - -static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size) -{ - uint32_t nalu_len = 0; - - if (bits_size >= EVC_NALU_LENGTH_PREFIX_SIZE) { - - int t = 0; - unsigned char *p = (unsigned char *)bits; - - for (int i = 0; i < EVC_NALU_LENGTH_PREFIX_SIZE; i++) - t = (t << 8) | p[i]; - - nalu_len = t; - if (nalu_len == 0) // Invalid bitstream size - return 0; - } - - return nalu_len; -} - static int parse_nal_units(const AVProbeData *p, EVCParserContext *ev) { int nalu_type; @@ -112,7 +74,7 @@ static int parse_nal_units(const AVProbeData *p, EVCParserContext *ev) while (bytes_to_read > EVC_NALU_LENGTH_PREFIX_SIZE) { - nalu_size = read_nal_unit_length(bits, EVC_NALU_LENGTH_PREFIX_SIZE); + nalu_size = evc_read_nal_unit_length(bits, EVC_NALU_LENGTH_PREFIX_SIZE, NULL); if (nalu_size == 0) break; bits += EVC_NALU_LENGTH_PREFIX_SIZE; @@ -120,7 +82,7 @@ static int parse_nal_units(const AVProbeData *p, EVCParserContext *ev) if(bytes_to_read < nalu_size) break; - nalu_type = get_nalu_type(bits, bytes_to_read); + nalu_type = evc_get_nalu_type(bits, bytes_to_read, NULL); if (nalu_type == EVC_SPS_NUT) ev->got_sps++; @@ -218,7 +180,7 @@ static int evc_read_packet(AVFormatContext *s, AVPacket *pkt) return ret; } - nalu_size = read_nal_unit_length((const uint8_t *)&buf, EVC_NALU_LENGTH_PREFIX_SIZE); + nalu_size = evc_read_nal_unit_length((const uint8_t *)&buf, EVC_NALU_LENGTH_PREFIX_SIZE, s); if(nalu_size <= 0) { av_packet_unref(pkt); return -1; From patchwork Sun Jun 18 23:43:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42216 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp349135pzb; Sun, 18 Jun 2023 16:44:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6iBxiN1ycYSDC7LEaj0JhSdqW22x2iIQE13GHqHxWnFrV8uwo7gjVt8KmJfxJZN1BoCmvL X-Received: by 2002:a05:6402:4409:b0:51a:409f:a0bd with SMTP id y9-20020a056402440900b0051a409fa0bdmr6713482eda.19.1687131856300; Sun, 18 Jun 2023 16:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687131856; cv=none; d=google.com; s=arc-20160816; b=B3ZQeTcHCUVA4NzVRnFHu9z8YFpnODK3WBicy2hCJP4juon5ZhelZNCqkTtIWOB5oP bQBS+JGfjSuTj9ZTiOTp45bQ89kaKeAUP7GgH6ZbDh7UyHmVHPIvATN09vmeZMf+QY26 sm2rQvIvLQ7aSONqnKRjtgPnq/d3AH05iMfOvAkMq5rR04ewH0M8MYY+pyXIze3qSQGC b2p3EXBiml+V0Hxrwb+6CyQ/+ooAYZ1w+GLywLN3Urrt8PtGsn7yR32MZBLuLJucjOYJ KAM54fP4QgolW9gq2DJMglv6uYIn4VUt3uqPsTmaGsWxK8iEt2WuhJxbth5vRHXJC8nW SEcQ== 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=ueSbc8RtZ0HcLhCxlxZJ6HrHWO6pe9iA29QAuMWUveo=; b=tVZw9Vmq7PT/McYZ7rurYEJ/5ZrCmKGeuMPhxKMYET60C16lW2yzsj1cPug1NTJWQS ZjKbL8EkMauTjKVDrlBzEgx0ldLsnTdNCwvk1dt37t/QfJQwAelHpPERMtj/DUH76uwF lYYSDUxKlvGnW4CnKiZKePEUKmRAbxi2FNS9EcuDQgeM7KyTfqWinEgEmRD3lP9ZjmDJ 3ahfzWbEVHpn1+7SWAh/+X8yKPi56KKSatnyP17QDwF0hMVzMabGR2ax0b2y7cV0UdOQ FH/vB+Q1GPl7KOemTst4FFN7e7RR9aM2+EZwS1PJIHmeHJ2u04LErwVKs99QNlrjd4Li +2rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=qBif7Xlc; 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 j17-20020aa7ca51000000b0051a52978d36si899819edt.276.2023.06.18.16.44.15; Sun, 18 Jun 2023 16:44:16 -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=qBif7Xlc; 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 7883C68BF63; Mon, 19 Jun 2023 02:43:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 19F1768BF45 for ; Mon, 19 Jun 2023 02:43:49 +0300 (EEST) Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3909756b8b1so1314137b6e.1 for ; Sun, 18 Jun 2023 16:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687131827; x=1689723827; 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=sZzk8QMHFAcIQqVfqI2xQuVQbSlhUA6AbnOgKsPU2KU=; b=qBif7XlcrPYjL66mc0IusBmBU3LHA8nBepY7XYxGEAU4zN9K2/Wwq+xOBvN5hpcpIR 6iHe4j3pEttvS+D1ej/tEsmH68sGR/olzzgivfPHx7/NwI42Nc0Aqm668XBFVNvJaEZ0 x76Zg4Xd/K+xOeJMoP4I5pTkEUg2Q9U+ILzqNkHHgEqt5MNceKyqBh/IXk0L/aqEnHlY 29QZdH9uBHIgtwBc9rE/Kh+6QlMvCuVcvqyNvqiC2SuUBK9TPOflTBT9bZdSeIglclaF 1pmGsNR6mN/2ThK8FbDtAiIr/cH/gmJZvKlgoNvKPXkyI2tZgEf34gckX9Gfk4jspls7 0H+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687131827; x=1689723827; 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=sZzk8QMHFAcIQqVfqI2xQuVQbSlhUA6AbnOgKsPU2KU=; b=erMAByr+4xDiGb1rfarIYGjqHWi1a/5zLnVW95LKl95OSPxQhXm4Bp2fAoPWQDZyT7 SZ0ZcwdnfWLfCLZ6PKuTdZh33uFb0NlsWWL8ZH5NZJFvx9Ve3qoHmHj0fAreZ1Jnq2d/ jt0VZsz9/NlRvJPFmSLUYgQK3ge2ABvrQ+I6nLnZusEPDmaalP7Klf9zGKJkSRyKrD52 Kt7MsVp/+pViI6CYJ7pD1SwEcBMoSWhv5uU/OXPRm+5Ruc6BeXN7vEuBEfvT1Ccq5qtT hgvb6lmhI8GIGHqjsYknMEMGXQogdzozQN67DkLzStVYAYBBRc/mznpSWS9sJImaueDp K1zA== X-Gm-Message-State: AC+VfDx2Dlr+39W5t2Xh7RfnRmN0ET9Gkbsu4jihJTsGXkIdhKZNMCyq QcOotxRN8ahfz4aKv9wf04P6xxh+aKs= X-Received: by 2002:a05:6808:a9a:b0:39a:b525:2a2e with SMTP id q26-20020a0568080a9a00b0039ab5252a2emr5785031oij.41.1687131827397; Sun, 18 Jun 2023 16:43:47 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id bk36-20020a0568081a2400b0039eb5f4543csm2069664oib.34.2023.06.18.16.43.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 16:43:47 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 20:43:28 -0300 Message-ID: <20230618234332.1370-3-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 13/17] avformat/evcdec: simplify probe function 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: dDrxXKZZ6GEQ Signed-off-by: James Almer --- libavformat/evcdec.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c index 0f17edd371..7a783e9809 100644 --- a/libavformat/evcdec.c +++ b/libavformat/evcdec.c @@ -34,14 +34,6 @@ #define RAW_PACKET_SIZE 1024 -typedef struct EVCParserContext { - int got_sps; - int got_pps; - int got_idr; - int got_nonidr; - -} EVCParserContext; - typedef struct EVCDemuxContext { const AVClass *class; AVRational framerate; @@ -65,10 +57,11 @@ static const AVClass evc_demuxer_class = { .version = LIBAVUTIL_VERSION_INT, }; -static int parse_nal_units(const AVProbeData *p, EVCParserContext *ev) +static int annexb_probe(const AVProbeData *p) { int nalu_type; size_t nalu_size; + int got_sps = 0, got_pps = 0, got_idr = 0, got_nonidr = 0; unsigned char *bits = (unsigned char *)p->buf; int bytes_to_read = p->buf_size; @@ -85,27 +78,19 @@ static int parse_nal_units(const AVProbeData *p, EVCParserContext *ev) nalu_type = evc_get_nalu_type(bits, bytes_to_read, NULL); if (nalu_type == EVC_SPS_NUT) - ev->got_sps++; + got_sps++; else if (nalu_type == EVC_PPS_NUT) - ev->got_pps++; + got_pps++; else if (nalu_type == EVC_IDR_NUT ) - ev->got_idr++; + got_idr++; else if (nalu_type == EVC_NOIDR_NUT) - ev->got_nonidr++; + got_nonidr++; bits += nalu_size; bytes_to_read -= nalu_size; } - return 0; -} - -static int annexb_probe(const AVProbeData *p) -{ - EVCParserContext ev = {0}; - int ret = parse_nal_units(p, &ev); - - if (ret == 0 && ev.got_sps && ev.got_pps && (ev.got_idr || ev.got_nonidr > 3)) + if (got_sps && got_pps && (got_idr || got_nonidr > 3)) return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg return 0; From patchwork Sun Jun 18 23:43:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42217 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp349181pzb; Sun, 18 Jun 2023 16:44:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6OraUSMgbpD7ZcGe50jFEEZrzqIqpBtGyIJUgbcm0+gQrwL8te26+4pv1iY4QURZiuiN+y X-Received: by 2002:a05:6402:121a:b0:51a:4628:d3f0 with SMTP id c26-20020a056402121a00b0051a4628d3f0mr3503789edw.38.1687131864265; Sun, 18 Jun 2023 16:44:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687131864; cv=none; d=google.com; s=arc-20160816; b=lEsYBU7LDUNGGaL1hjvJ/3Hx5IYu/YD+Pn7rjKTH0vNXgQASk2Q2fdwLzThOFmqQsK 3foP7de3o1r5v8elHcKoysxDUC563q+zqwx+JO2jm/QHr2oSUBWk8tnBoDrB5ooNy9mX yn3685gD6wuPMObW48dZIJedXcqXBVujHy2nxVPpNCOCvzlZUBPtNmpW8bPuRxf0iyDV WF3ql0kDb3uoF7w9OLFQTtkHlCrdoahqufUC2sfDxhKI8tODGAyy4dL+Ug8rFBwKya+m HQdcbKrZM9R+JzVwcWPl/EpJJJHbo461C83d/lO8Q1c3noVMjb8cvnU4T7C3rf4K36OR aSBg== 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=HwWrbd19DCVilc7G+w5M3qu0lXtdpAxeRWiYm5kUt/A=; b=XsODYHL913ObJBvy/O+GsNcZHm+aoren/mjoU+YD2+NRO1tWTO/4gwVXzCaoCry5eU SDihbvlokSAqyiyklt3fLHTgVaZn0EU+XgsBLNOWJ+xuNnz418Prt2yIrzJaLQqLs5q/ HoEYAd+qAYSvUJ1TXOlc9s2Q95JFzgxzg5QXqMxCudyiJixiDe3hRmFIesha1j8k8sF6 As+LsZNvmw5AqgRylOJ8wNoXgvaHrVelM5ZgV7j2EtXez2EgqMknXCQ9s3ASIHvoCZ94 xz3g6kycnf1S7nkqQdbVleomFOI7e/zMUwceGD1HFQzcfbFhzwq1sZDwviutaEPivMsm Awuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=feVGuatK; 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 o23-20020a056402039700b0050bc4a2975bsi13726512edv.681.2023.06.18.16.44.23; Sun, 18 Jun 2023 16:44:24 -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=feVGuatK; 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 7BEEE68BF69; Mon, 19 Jun 2023 02:43:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 833DD68B9FC for ; Mon, 19 Jun 2023 02:43:50 +0300 (EEST) Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6b2b6910facso2019322a34.1 for ; Sun, 18 Jun 2023 16:43:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687131829; x=1689723829; 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=5cjM0WNJAmVeWJLeHFcOWjos/+9BtjRFOFtQIsL43Yo=; b=feVGuatKfOzYyue0lnQWvxJe3dzcNuOUibwVg7YeuaJXYuNU6QklVpCtgO7v9WocT2 l0Rb/L/P8sJTr0ZB4mDtd3EAXDvNezPkmPFQZx00v4gx0oxuLj2tW1VUSkw4anBeJJKM S5mOn7zqNaSj83Ss3T10xPw9piWFLSsPmA0jSTkRnrEFokyUpeeLi3nzLE5HnIvkazJN N5rHGmm14v7ddodRGBECCBqcoZA2YMfDDkU91rjqkQGqc2fVdy8+i2kWTFjgyJbQQ+Id bcXje08c/V1mrh3bJqmC84MmdvKsZ+ieFDYg5hR+jldz/5Cx/B4VqHx5EHl7RtJD2cMB plRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687131829; x=1689723829; 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=5cjM0WNJAmVeWJLeHFcOWjos/+9BtjRFOFtQIsL43Yo=; b=I2lN1CY8u+nZTOkXix7MfYtoRz+vEAHzQDPrObHxuMiMn7S0kO1b/caaWHooam0REb 2FdTVUHxEUY0Ey+MJWnrbxs0OmFavbcoKqppp6IUxUPR9vhMvQDX5/VyLOr27I7oifLl mMPbmOgqDMspt4y7EDI7aaFHZK/lwdoRRaWGy02v94cjWR0GKkElxgl+Ai7emlNU0pVM bztG8nfomLLl09kq6mIwLLj6r2h1tmS6kvj5iI7+nQTQnWW+kNQ583pxbMOleJ5EvCSg kKKU7M8oWndllRDacYGV5MHghQ0Zp9F4lHeyZM7Qhh+HuSZ/vXI8l5LhBx/48TK6jyHR vKRQ== X-Gm-Message-State: AC+VfDyPhc4mTM0QJKdM+9IJEnKxT81Cr82dAgYohZLT+ADwvUmliU8X JisLE/UGMwshYlgi4BBveq78Qco11Qc= X-Received: by 2002:a05:6808:4c1:b0:398:2ec7:d5ed with SMTP id a1-20020a05680804c100b003982ec7d5edmr6769089oie.19.1687131828844; Sun, 18 Jun 2023 16:43:48 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id bk36-20020a0568081a2400b0039eb5f4543csm2069664oib.34.2023.06.18.16.43.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 16:43:48 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 20:43:29 -0300 Message-ID: <20230618234332.1370-4-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 14/17] avformat/evcdec: simplify au_end_found check 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: Vv99RNdxLvQH Signed-off-by: James Almer --- libavformat/evcdec.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c index 7a783e9809..a3a41cb4a5 100644 --- a/libavformat/evcdec.c +++ b/libavformat/evcdec.c @@ -144,7 +144,7 @@ static int evc_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret; int32_t nalu_size; - int au_end_found; + int au_end_found = 0; EVCDemuxContext *const c = s->priv_data; @@ -154,8 +154,6 @@ static int evc_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_EOF; } - au_end_found = 0; - while(!au_end_found) { uint8_t buf[EVC_NALU_LENGTH_PREFIX_SIZE]; @@ -191,9 +189,8 @@ static int evc_read_packet(AVFormatContext *s, AVPacket *pkt) av_log(s, AV_LOG_ERROR, "evc_frame_merge filter failed to " "send output packet\n"); - au_end_found = 1; - if (ret == AVERROR(EAGAIN)) - au_end_found = 0; + if (ret != AVERROR(EAGAIN)) + au_end_found = 1; } return ret; From patchwork Sun Jun 18 23:43:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42218 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp349231pzb; Sun, 18 Jun 2023 16:44:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hBq3tneW83R6f7t1WNjV4SpmN8B2UwG+tJ5xRcejkJYaON/iC5OMwO1TxJeYsNfyMDMmM X-Received: by 2002:a19:f201:0:b0:4f7:42de:3a8f with SMTP id q1-20020a19f201000000b004f742de3a8fmr3824661lfh.56.1687131872905; Sun, 18 Jun 2023 16:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687131872; cv=none; d=google.com; s=arc-20160816; b=UVM4bxndLOvwREw8KRvypZIig4lWFXeSKZ39CXIiNoCVwtYzQ4MAUKsEvL7TOfpXhG w2U/V/YGopXF2sb0tnF7k2s61TpNCg2+IGzP8tKqlGMTJiSr77pmL6iDI5ARLD64V+az VsHyRIkANEqVkmQgOelb8aSy4fjqnSrDahniQKDx2CDVQzUWQZ+77NKCB0PzeSUE4TQo y9LtLk5+sC0g8nl2Pck55/djWOSiGS9ugsKLIOc8YEXBULYy0yP2OYuqra+Gv0KFuh7X YXYG/xxCmf52MhoNCww3WByvrSaDRsOIAH32+QH6bWI61S9kPGUbILyKgQKxuCz6SZHr P+yQ== 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=6bKM42C0465jSvE6qGXQxEYWgPpaBdSCSuPNrjQxJyo=; b=F0XgyJDXqSuuA2g2UEX2TpWZpAP3WnhaXbANepVhBL22vk/NR/WWUW/+k4KXwmoD6v PAKuiLE450lyybw3Ff2h1MraPEysfw808k7K41yKo60oCurm9dvJVi5GW/Jj7I5W4o2L cLyLO6I5eJ0D1ZwH+MREl1Ig4b0Z6oUeGgWCmeRtqJfFmt/+kmLRssFH9BT/Nks/zefE oJ9J596Tl+phHoqFdd08WY3R/4wcVvU3NcVu45Sn5ZfJK8vkBcyUXlPew/GlbNPkL5Cq OnszClJtPjVd6oQogDTrWRiXZtFKhZ3rD+KYDV1nwPg4BmqxsQA7P2dYe5rBVnVOA+oA ravQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b="Ft/9Z4L8"; 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 w15-20020a50fa8f000000b0051a2d323834si4366523edr.596.2023.06.18.16.44.32; Sun, 18 Jun 2023 16:44:32 -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="Ft/9Z4L8"; 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 8A6C668BF7E; Mon, 19 Jun 2023 02:43:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C5A5C68BF65 for ; Mon, 19 Jun 2023 02:43:51 +0300 (EEST) Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-39cd0c3e8deso1896711b6e.1 for ; Sun, 18 Jun 2023 16:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687131830; x=1689723830; 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=ptTLAC5tCjlyYfwcwkJkP4XlsPM/oUOIEVnRijmW4ic=; b=Ft/9Z4L8oBjH0qE1sDO3xeq+7YeyVupJAk3jOy52XwM0MhH7JapZ8I0l6SLrimUIQY /uAZ5vvolfDdvZSr1dgp28iK+JH4Wy/obru/nJEA8aJcL/vcmTb2auXT5fRvY09xHCR4 il9CzVpUnwxdu6d2XcP8D6tiEOq3aKlf8k/Ehuy+/eplg4Rv7dH4LgX19M19hnkhsM2Q 6RK+ztnUw78OiOrMdISeS9ZRcRHZolJg5SkFBXw5jSFV2DywMTQFdZb6h3tJb5Y7UELA 1MsAx3bFjiWDQnjnkVwNdjdG7WYCFLDZ0fU3PSavo+8wr0m3A3oHn0L65LUJDwRc0Ymq jYWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687131830; x=1689723830; 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=ptTLAC5tCjlyYfwcwkJkP4XlsPM/oUOIEVnRijmW4ic=; b=Ozfasu+jtr7LGNQFWTSwIB7PQLQqEs95tu05ipkZwmOkZkycHwumjR/4kNnhGYnou1 JxPDoKLTca48aWafc/9KMj/juB2nR20EW8EA8aEApil71wwdVZUp6g9VAiLlsFR/S4aF cQs982sEivKzGFE6jIhEc1PSYXLxvKRb9Ze09NftrtObAcuP19oIEFj8U/p7NFXNwd97 nWqYuD/qi3QBpAJsfNmR7BnF1TVH3rLWHU7vzMFsTPruBt4HM0q48dsOP35133qIEkP7 7kmbl8CXxxYuRyxw73aFMl4vQ1/y7F0YC/thiMhHOrq7nqCCwozh6BWmLU9zU2WukX3+ Z23g== X-Gm-Message-State: AC+VfDwlb6pyNlVNLjbSeISzTbUtUjMakt5PMOzH9Ux+aZ2aIHlvWepT 3QNxtG5HIXnpisnaS+J02ZyeKi7jD0Y= X-Received: by 2002:a05:6808:2390:b0:39e:de37:19b0 with SMTP id bp16-20020a056808239000b0039ede3719b0mr532264oib.44.1687131830202; Sun, 18 Jun 2023 16:43: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 bk36-20020a0568081a2400b0039eb5f4543csm2069664oib.34.2023.06.18.16.43.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 16:43:49 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 20:43:30 -0300 Message-ID: <20230618234332.1370-5-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 15/17] avformat/evcdec: don't set AVCodecParameters.framerate 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: 9a3Z/xJddUjp It's not necessary. Setting AVStream.avg_frame_rate is enough. Signed-off-by: James Almer --- libavformat/evcdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c index a3a41cb4a5..3cadbc1530 100644 --- a/libavformat/evcdec.c +++ b/libavformat/evcdec.c @@ -119,7 +119,6 @@ static int evc_read_header(AVFormatContext *s) sti->need_parsing = AVSTREAM_PARSE_HEADERS; st->avg_frame_rate = c->framerate; - st->codecpar->framerate = c->framerate; // taken from rawvideo demuxers avpriv_set_pts_info(st, 64, 1, 1200000); From patchwork Sun Jun 18 23:43:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42219 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp349265pzb; Sun, 18 Jun 2023 16:44:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6fHc8RM8dF1kqDeAyPwSMXdaiJfH9toXzxHLy9xgpj0Vb8fQKIfsHd3RLPiAIeEMzGvFN0 X-Received: by 2002:a17:906:ef06:b0:961:be96:b0e7 with SMTP id f6-20020a170906ef0600b00961be96b0e7mr6126071ejs.48.1687131881748; Sun, 18 Jun 2023 16:44:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687131881; cv=none; d=google.com; s=arc-20160816; b=gGgoFN5yJDL3B/hnSD9bLDQFAUoRc8xtsjBcDR490AAav2aecxgkFx1kyoiZGhB1tW WoFOf+iV/gXUEO5QPBcCp0/VS0bvMMq/qKyTSdH4ZNHnPi0dCWBLSMbdhNZPR4ZDLWBC DzVTrPa3trJMIK/SGujJNgZTq5gP+jNRfcEzDW3xOCJv/mvR1rePGiQ1T4dnoqsu1JDv wtnM8e8OOiwJSvPFIx1BuQynpUt7dJfD1wQKyDnL1CGyVlfqfel5A6hbTVtxT3nSjLrp ev92lM+MTOeBKATke6AhmaWsUoWtQ41y/RYYX0dzuArrU0GCOKDTBUUUbZUpMaBAS2x7 atng== 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=ftR/3z0ta3hyhW9R1lmwaEBY/dmxw5CyKa4FgWL4yn8=; b=yMI6O8XoiZWvKvVMrj2FROEuf1voeSHiphaA0p9MZEjUTT4ZSpe4ZdQPSf0EBReV7l h5NAmtL2gtpUznJgtW5HDlqQq1rju8e3FKhimyJKGMmt2CfMQR77FHel0m4mVwpd2Prg jT2BqsYRvqLvw75di4pvQ8dU/weYGFdrvr0kuraGsayu3KYH0zY11XmQYxQ0gY3MAKIu CziFIOvP43OVoObv8lvREgsz2+bLaZHlgLl9Y4WTU1V142devpsAhuB4l+FLYPkFDWj0 SSMPE5VP5Bmf0Z12/4aoBzg5qYVMub6FML/SRwn6tp7MP2+Ad4g2Ns2+JgORv1NJgtpn QPLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=EVIilB44; 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 w4-20020a17090649c400b0097650856f55si13405280ejv.695.2023.06.18.16.44.41; Sun, 18 Jun 2023 16:44:41 -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=EVIilB44; 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 7733768BF8B; Mon, 19 Jun 2023 02:44:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6F69768BF4D for ; Mon, 19 Jun 2023 02:43:53 +0300 (EEST) Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-39e8a7701f0so1880733b6e.3 for ; Sun, 18 Jun 2023 16:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687131832; x=1689723832; 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=WGa0gO1KccuQGzI2YmoFFmwKG5mcyXy6/7e7K+q6t8s=; b=EVIilB44Ig9aubHWZja4alGCiFR1kxMG5iOQmBNj45g/2ZXf5CW0EdaO2mzgdnioF/ j7d6gJgrhdGstL3B6o7M0Ptbim5J1PpD6X4MMSwtl8tfRQvYnNOAwYd7b0uQX+j7qq6A 2TR7yiglj6ycFrgfX7LSad4nhciaj0ldTKHn26urxU0K29rMmNpP5HMMfpfUB6vVnXwT 545/IMh6LNA67FaaTnnduqPBonPCfp6pVJ/JhzuCz5cJJwfEfzaoNr+//suh6KwwH79j A/oeWscFephoO6kEp3t6XBh3Z7GWUadf7c7eG06mWu0EC8aaJPE3ojgGS81xsUzPZiPY NpUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687131832; x=1689723832; 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=WGa0gO1KccuQGzI2YmoFFmwKG5mcyXy6/7e7K+q6t8s=; b=lGgRMHta7A4+tjL7v1P8mKssZI1qd+XYVupIZefGuhk3pspyo/oMiuUpQ5t6j4pKGm BV/c+lbYlVoy/xy+K60f/5Ls6wvvNEuG5diRReD7W1pDyxOluNHISm/y5CxfZo8Oj97G mmtO5ncn/ThQmiyIxGZgV46qbVQdc1nYYfSXKSAzP9pXVVvEtzaeYRldLvlLf3by67oJ xqT44AZbfEizT28XYjVe65GXPTMovCTGKBaNY98pKxOTwuycbn/wAtnwmU99A4Wn0E6v 1r3Q2MbNpCreiF0Ok/i52FOwPKj7VO60+RHIaoWDjGDiw2Rvc/xw0NttYNg9OrGPhZyy HZzQ== X-Gm-Message-State: AC+VfDzrDJ/kkcqIpGvBAaYUC4GV1cCRKPoa73fWeuc5U3d/WL1Osn3b 9c6TOKkYkS3+mrUM9cJ6UP3tZkAlEK8= X-Received: by 2002:a05:6808:1a28:b0:39e:ce3a:70df with SMTP id bk40-20020a0568081a2800b0039ece3a70dfmr1911616oib.8.1687131831714; Sun, 18 Jun 2023 16:43:51 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id bk36-20020a0568081a2400b0039eb5f4543csm2069664oib.34.2023.06.18.16.43.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 16:43:51 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 20:43:31 -0300 Message-ID: <20230618234332.1370-6-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 16/17] avcodec/evc_ps: make ff_evc_parse_{sps, pps} return an error code 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: BMHMf3MGnILl Signed-off-by: James Almer --- libavcodec/evc_frame_merge_bsf.c | 17 +++++----- libavcodec/evc_parser.c | 18 +++++------ libavcodec/evc_ps.c | 54 ++++++++++++++++++-------------- libavcodec/evc_ps.h | 4 +-- 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c index 817136a551..e9f549eb71 100644 --- a/libavcodec/evc_frame_merge_bsf.c +++ b/libavcodec/evc_frame_merge_bsf.c @@ -120,24 +120,21 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) nalu_size -= EVC_NALU_HEADER_SIZE; switch (nalu_type) { - case EVC_SPS_NUT: { - EVCParserSPS *sps = ff_evc_parse_sps(&ctx->ps, nalu, nalu_size); - if (!sps) { + case EVC_SPS_NUT: + err = ff_evc_parse_sps(&ctx->ps, nalu, nalu_size); + if (err < 0) { av_log(bsf, AV_LOG_ERROR, "SPS parsing error\n"); - err = AVERROR_INVALIDDATA; goto end; } break; - } - case EVC_PPS_NUT: { - EVCParserPPS *pps = ff_evc_parse_pps(&ctx->ps, nalu, nalu_size); - if (!pps) { + case EVC_PPS_NUT: + err = ff_evc_parse_pps(&ctx->ps, nalu, nalu_size); + if (err < 0) { av_log(bsf, AV_LOG_ERROR, "PPS parsing error\n"); - err = AVERROR_INVALIDDATA; + goto end; } break; - } case EVC_IDR_NUT: // Coded slice of a IDR or non-IDR picture case EVC_NOIDR_NUT: { EVCParserSliceHeader sh; diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c index 710fabccb2..0f6abf8b0f 100644 --- a/libavcodec/evc_parser.c +++ b/libavcodec/evc_parser.c @@ -63,6 +63,7 @@ static int parse_nal_unit(AVCodecParserContext *s, AVCodecContext *avctx, { EVCParserContext *ctx = s->priv_data; int nalu_type, tid; + int ret; if (buf_size <= 0) { av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", buf_size); @@ -87,29 +88,26 @@ static int parse_nal_unit(AVCodecParserContext *s, AVCodecContext *avctx, buf_size -= EVC_NALU_HEADER_SIZE; switch (nalu_type) { - case EVC_SPS_NUT: { - EVCParserSPS *sps = ff_evc_parse_sps(&ctx->ps, buf, buf_size); - if (!sps) { + case EVC_SPS_NUT: + ret = ff_evc_parse_sps(&ctx->ps, buf, buf_size); + if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "SPS parsing error\n"); - return AVERROR_INVALIDDATA; + return ret; } break; - } - case EVC_PPS_NUT: { - EVCParserPPS *pps = ff_evc_parse_pps(&ctx->ps, buf, buf_size); - if (!pps) { + case EVC_PPS_NUT: + ret = ff_evc_parse_pps(&ctx->ps, buf, buf_size); + if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "PPS parsing error\n"); return AVERROR_INVALIDDATA; } break; - } case EVC_IDR_NUT: // Coded slice of a IDR or non-IDR picture case EVC_NOIDR_NUT: { const EVCParserPPS *pps; const EVCParserSPS *sps; EVCParserSliceHeader sh; int bit_depth; - int ret; ret = ff_evc_parse_slice_header(&sh, &ctx->ps, nalu_type, buf, buf_size); if (ret < 0) { diff --git a/libavcodec/evc_ps.c b/libavcodec/evc_ps.c index af74ba46b0..b8d7329b94 100644 --- a/libavcodec/evc_ps.c +++ b/libavcodec/evc_ps.c @@ -132,26 +132,26 @@ static int vui_parameters(GetBitContext *gb, VUIParameters *vui) } // @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) -EVCParserSPS *ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size) +int ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size) { GetBitContext gb; EVCParserSPS *sps; int sps_seq_parameter_set_id; + int ret; - if (init_get_bits8(&gb, bs, bs_size) < 0) - return NULL; + ret = init_get_bits8(&gb, bs, bs_size); + if (ret < 0) + return ret; sps_seq_parameter_set_id = get_ue_golomb(&gb); if (sps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) - return NULL; + return AVERROR_INVALIDDATA; - if(!ps->sps[sps_seq_parameter_set_id]) { - if((ps->sps[sps_seq_parameter_set_id] = av_malloc(sizeof(EVCParserSPS))) == NULL) - return NULL; - } + sps = av_malloc(sizeof(*sps)); + if (!sps) + return AVERROR(ENOMEM); - sps = ps->sps[sps_seq_parameter_set_id]; memset(sps, 0, sizeof(*sps)); sps->sps_seq_parameter_set_id = sps_seq_parameter_set_id; @@ -284,7 +284,10 @@ EVCParserSPS *ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size) // If necessary, add the missing fields to the EVCParserSPS structure // and then extend parser implementation - return sps; + av_freep(&ps->sps[sps_seq_parameter_set_id]); + ps->sps[sps_seq_parameter_set_id] = sps; + + return 0; } // @see ISO_IEC_23094-1 (7.3.2.2 SPS RBSP syntax) @@ -294,34 +297,33 @@ EVCParserSPS *ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size) // If it will be needed, parse_sps function could be extended to handle VUI parameters parsing // to initialize fields of the AVCodecContex i.e. color_primaries, color_trc,color_range // -EVCParserPPS *ff_evc_parse_pps(EVCParamSets *ps, const uint8_t *bs, int bs_size) +int ff_evc_parse_pps(EVCParamSets *ps, const uint8_t *bs, int bs_size) { GetBitContext gb; EVCParserPPS *pps; - int pps_pic_parameter_set_id; + int ret; - if (init_get_bits8(&gb, bs, bs_size) < 0) - return NULL; + ret = init_get_bits8(&gb, bs, bs_size); + if (ret < 0) + return ret; pps_pic_parameter_set_id = get_ue_golomb(&gb); if (pps_pic_parameter_set_id > EVC_MAX_PPS_COUNT) - return NULL; + return AVERROR_INVALIDDATA; - if(!ps->pps[pps_pic_parameter_set_id]) { - if ((ps->pps[pps_pic_parameter_set_id] = av_malloc(sizeof(EVCParserPPS))) == NULL) - return NULL; - } + pps = av_malloc(sizeof(*pps)); + if (!pps) + return AVERROR(ENOMEM); - pps = ps->pps[pps_pic_parameter_set_id]; memset(pps, 0, sizeof(*pps)); pps->pps_pic_parameter_set_id = pps_pic_parameter_set_id; pps->pps_seq_parameter_set_id = get_ue_golomb(&gb); if (pps->pps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) { - av_freep(&ps->pps[pps_pic_parameter_set_id]); - return NULL; + ret = AVERROR_INVALIDDATA; + goto fail; } pps->num_ref_idx_default_active_minus1[0] = get_ue_golomb(&gb); @@ -369,7 +371,13 @@ EVCParserPPS *ff_evc_parse_pps(EVCParamSets *ps, const uint8_t *bs, int bs_size) if (pps->cu_qp_delta_enabled_flag) pps->log2_cu_qp_delta_area_minus6 = get_ue_golomb(&gb); - return pps; + av_freep(&ps->pps[pps_pic_parameter_set_id]); + ps->pps[pps_pic_parameter_set_id] = pps; + + return 0; +fail: + av_free(pps); + return ret; } void ff_evc_ps_free(EVCParamSets *ps) { diff --git a/libavcodec/evc_ps.h b/libavcodec/evc_ps.h index 989336079f..c7ed2af37b 100644 --- a/libavcodec/evc_ps.h +++ b/libavcodec/evc_ps.h @@ -218,10 +218,10 @@ typedef struct EVCParamSets { } EVCParamSets; // @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) -EVCParserSPS *ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size); +int ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size); // @see ISO_IEC_23094-1 (7.3.2.2 SPS RBSP syntax) -EVCParserPPS *ff_evc_parse_pps(EVCParamSets *ps, const uint8_t *bs, int bs_size); +int ff_evc_parse_pps(EVCParamSets *ps, const uint8_t *bs, int bs_size); void ff_evc_ps_free(EVCParamSets *ps); From patchwork Sun Jun 18 23:43:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42220 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp349294pzb; Sun, 18 Jun 2023 16:44:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ76TMttMg/vSzp6/V26sB22+ST7EPJFp3AYScpwK1EZS0NeVk0WXJdR5GPQFluRtPneYbP7 X-Received: by 2002:a50:ee96:0:b0:51a:3334:f88b with SMTP id f22-20020a50ee96000000b0051a3334f88bmr5750018edr.10.1687131890087; Sun, 18 Jun 2023 16:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687131890; cv=none; d=google.com; s=arc-20160816; b=Lb7A57FRzhejixfVJYYKEGyjSBA2HyDch2h75mOa54+jM0hsGg82TplFdEfFsF372f 7KESGZmxkSwsJ+7wPSYn35ceGnZr3r9lK468QWKkAQlItHkKzZFlXKHMLu71Tm/Gr26G FBPviJSH4DA0xxEnMx191QcFfGtm8uk1Ck8ZBYYzuqdb28DmR5VXLaHwqG4KlI43AIyS 8P+QQNrZe0q9a+GnnUOB5v/cFGTf/lcTy5AhmWByGHnbAWtng6yhSTdqR+yj8W6W0fOe SY8fEt9PK7JBwWVxg3jG14QP+gAAORZevpzzJRiTf0QdjYqIsYfg8qBMzjLDOiibM8Rf 3c2A== 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=BryQSaIiXvqWNNwzDhjlY3+N29WIM+JW06ZDTWD0QYM=; b=MT47DYYZzzSrP4VNVZD4tPHJUlTUNXdXKYQY+iTWcFN5UdgVV32wvL0RB2D9MkqZQd MWev+ljCg8VvrSqNrgwSZ8xAeZY7ZRUQyAoO09W5Z5nVlPNMpmZo04Moa19/fuZcOZZr s9KPQFCJFvOlS+JJIueO0/LKvhoScfl5dLb3EYoPu8JPXl7P7nwxycbdrINxBaPGYMc0 W2L63d3i84Y2k6GjKZ8J3PQXAQUFeAJqKLk4iY/aVc4OlwmOls0d5NCqQAywwtqolfUS NH6rTSeTysvX2QP7kHijubrJ0AP+QL0rOhU1Z7KwJqtfzO6F2QECXrz/An2wiHwhgH8V bQXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=O9b41ndQ; 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 h24-20020aa7c618000000b0051a315d6e23si3579148edq.603.2023.06.18.16.44.49; Sun, 18 Jun 2023 16:44:50 -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=O9b41ndQ; 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 6D73668BF9E; Mon, 19 Jun 2023 02:44:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BAA2A68BF58 for ; Mon, 19 Jun 2023 02:43:54 +0300 (EEST) Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-39ca2539200so1969957b6e.1 for ; Sun, 18 Jun 2023 16:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687131833; x=1689723833; 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=TA8ylwkejxdWVhLpMtyU9C4CODHE4GQsdgQ7filMZHY=; b=O9b41ndQ7VlSyB55sbe861IutlDMHKBAqqmcojekqBs+w7I8Y7f7rsK75dCmJYVJYk YpPVG/g6pq0Sle0WAQ+EQrzmcnoJURBYnXtWgkTRDkJKFs3BX8FvsUHNym+BLC5Lh0WE UII0vVf8E6guzNDGHulAeOQEZ7rml7n+DRHpdG7znmvUBuIrmA1CUsn01QG9qVT8E9hr RB3mQitscas7JtvrcsHw1buhIbjsW37FmedXEhm4R1ySPuGfAakI+S3t3xVV0YfEz0ZU qBSZSNBZE0MCUlm2gHXNLuf+evQYhptu2iWUtEgEWEtU3G1xpWYqejEohor1ilYAVbfc Mv1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687131833; x=1689723833; 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=TA8ylwkejxdWVhLpMtyU9C4CODHE4GQsdgQ7filMZHY=; b=Y/wb91owVog893kyjBBug8JDVUebHv4BsXdNVGR543jLupaAD8Z+XaNJk6HVafKhpB KRvu6k51tmfn8kojjnbl/uhXqZpqmtrC14FPUx/3e4FANGSzYumRrPYSTbGMNACT6KhF QRoFwq2P0DmAMphnOTywOTAzvSZLTlv/p9t8ccNQr5/XO+nP+ADuKv5WCeVlgA8pBYYc ZtrkXChDg9CouFCLHB63Z6dhvmffHlD1naT2mx6N2TzShbBpuf8rL6ihdHQhM1spqJEr hDPi3YN5G7R1hUIcjOxFk2dDeVcFXK+suOlB8dpHlrMBCdEnBe1jj8ntqR1W1zs8JJw8 /pAQ== X-Gm-Message-State: AC+VfDwywGKxojgwVzcMfQ6/5ydRKs03EhNffUrP2wlXcW46kOOD8nDX CiaPAlrk5fHJs/Ec3lUtXyzX09IGUlY= X-Received: by 2002:aca:b9c6:0:b0:39c:7f78:ba6d with SMTP id j189-20020acab9c6000000b0039c7f78ba6dmr7755315oif.19.1687131833148; Sun, 18 Jun 2023 16:43:53 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id bk36-20020a0568081a2400b0039eb5f4543csm2069664oib.34.2023.06.18.16.43.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 16:43:52 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 20:43:32 -0300 Message-ID: <20230618234332.1370-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 17/17] avcodec/evc_ps: Check log2_sub_gop_length 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: Y3drPI1wU7ft From: Michael Niedermayer Fixes: 1.70141e+38 is outside the range of representable values of type 'int' Fixes: 59883/clusterfuzz-testcase-minimized-ffmpeg_BSF_EVC_FRAME_MERGE_fuzzer-5557887217565696 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer Signed-off-by: James Almer --- libavcodec/evc_ps.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/evc_ps.c b/libavcodec/evc_ps.c index b8d7329b94..0b8cc81d49 100644 --- a/libavcodec/evc_ps.c +++ b/libavcodec/evc_ps.c @@ -229,6 +229,10 @@ int ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size) if (!sps->sps_pocs_flag || !sps->sps_rpl_flag) { sps->log2_sub_gop_length = get_ue_golomb(&gb); + if (sps->log2_sub_gop_length > 5U) { + ret = AVERROR_INVALIDDATA; + goto fail; + } if (sps->log2_sub_gop_length == 0) sps->log2_ref_pic_gap_length = get_ue_golomb(&gb); } @@ -288,6 +292,9 @@ int ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size) ps->sps[sps_seq_parameter_set_id] = sps; return 0; +fail: + av_free(sps); + return ret; } // @see ISO_IEC_23094-1 (7.3.2.2 SPS RBSP syntax)