From patchwork Sun Sep 20 17:24:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 22542 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 0B18344B700 for ; Sun, 20 Sep 2020 20:25:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E41DA68B9D9; Sun, 20 Sep 2020 20:25:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D68C968B779 for ; Sun, 20 Sep 2020 20:25:08 +0300 (EEST) Received: by mail-qk1-f195.google.com with SMTP id g72so12562167qke.8 for ; Sun, 20 Sep 2020 10:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HcNMiR5KuuulGocJC/YTQpLGAYJQ03V/zcZKyusOopw=; b=Y6J1deHNzgbISLpI+BkpdUEAX8140SaY+aqMDZRTHpj8vg9gEF7/vRD0uBAhWGruXZ knc5xO7NJUXvYovinX7BDhSqdWL3s+KN4tZXnUtjabUxuFkaZEzORXstFJpcQqxACPYI F6G5/Z1l06cFeYYEDtThIelWPc1tb4uRwxJAfVIrNtHKq+thC9QvtZrzC5D3UUje6sel YBxViGgerg77JLGraJH9aeY8tl3AP6OOq9K6OCoxxF/3XdQGbvHb0655IogMDIM4viLs +O8ZwylXc19UMkgPVHugdAqWZr1d2sDtgRkte2DQ7kY0BJVggwxNrlCqUp4AQHDeVoYj hpQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HcNMiR5KuuulGocJC/YTQpLGAYJQ03V/zcZKyusOopw=; b=ikqh/zD4P+XQgUNkYFix7hV4Bp7b9qn9/ZHeQdwbjUQzCLH9MbmdvPXlt5qPq9Ni0+ H5rEvWzLlms8zKS4RQz16fOkJMDkuXPYGlW3MOZjGz3f+F51MjncnebnM4KXnRsOnMLg 1Gw97b7biA8JV2c0wpFn9nKTOImdj/k+Ycx3GN9qil96bICeLR4zTcT5XJ/V7X74z8TY nXxu7ty3LY/znYf0v4bH8fa6i6tpHZJF5TA2wKd45q02DmcjuC/47kxje+ZOVaYA3GDX r3R1x0uZeFHnEJmH0IcX11W5CWbxl4AAglBSECvrpEfPigVNmAPQaYQUeoreYl0JXtbs PvSA== X-Gm-Message-State: AOAM5325v1ItAnp5fLGmnFCyCXdjrclf4g744+Diu54IEFCU+Mprshea RkIu+sUfUtry9tx5EmK3/SQC0DXoXuwI8Q== X-Google-Smtp-Source: ABdhPJxPWh6qQuqoi9KxQof6mQU4vN6vywPd8wdOqQFTvCulB22L96sceeLGQzdP9vVTPASK+4DrGw== X-Received: by 2002:a37:4c15:: with SMTP id z21mr41600251qka.194.1600622707300; Sun, 20 Sep 2020 10:25:07 -0700 (PDT) Received: from localhost.localdomain ([191.83.208.67]) by smtp.gmail.com with ESMTPSA id g19sm6970762qka.84.2020.09.20.10.25.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2020 10:25:06 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 20 Sep 2020 14:24:41 -0300 Message-Id: <20200920172443.4763-2-jamrial@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200920172443.4763-1-jamrial@gmail.com> References: <20200920172443.4763-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/cbs: allow cbs_read_fragment_content() to discard units X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" The caller may not need all units in a fragment in reading only scenarios. They could in fact alter global state stored in the private CodedBitstreamType fields in an undesirable way. And unlike preventing decomposition of units, discarding can be done based on parsed values within the unit. Signed-off-by: James Almer --- libavcodec/cbs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index e73e18f398..363385b6f3 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -196,6 +196,11 @@ static int cbs_read_fragment_content(CodedBitstreamContext *ctx, av_log(ctx->log_ctx, AV_LOG_VERBOSE, "Decomposition unimplemented for unit %d " "(type %"PRIu32").\n", i, unit->type); + } else if (err == AVERROR(EAGAIN)) { + av_log(ctx->log_ctx, AV_LOG_VERBOSE, + "Discarding unit %d " + "(type %"PRIu32").\n", i, unit->type); + ff_cbs_delete_unit(frag, i--); } else if (err < 0) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit %d " "(type %"PRIu32").\n", i, unit->type);