From patchwork Sat May 30 16:05:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 19989 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 158A944A6AD for ; Sat, 30 May 2020 19:06:18 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E751F68A800; Sat, 30 May 2020 19:06:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2F55F68804B for ; Sat, 30 May 2020 19:06:12 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id r7so7251892wro.1 for ; Sat, 30 May 2020 09:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Efe3bKu3KIwtRPWXrh+EnvIuDZGYfXq+PPAhhe3+1Ts=; b=jfMmyN2BPo7PcB4gxMKf2AqeYsn4+8HD3q4TZNUJQ8+zZd1drN1EXQW+erM/E2Wcwh I4BfDn6q1xIXhRSJPM8FPYUlX7Ic4+tX+HKZvQlTWT6u0siXJULmZFKMmh2TLP/qjiFY z7plartQU/8S0pfbpyTiq7qFXTzrLY5zyWNjVKtRG+gP+ZPNybEbn8nv0YvrQ4MEF7gK JEbrSe4dzeTlUFqnS2PNUzUpHlH7m01FmmGeBuabNsUvXNAL9qbcgi4K5A4CLZusDGrL DBXE907x4FXKx1Hyecnxml3GEKz0mOxl+ltwIuuJ7HLp29CD0Lq2a23iLZN+/zu6en37 7Bcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Efe3bKu3KIwtRPWXrh+EnvIuDZGYfXq+PPAhhe3+1Ts=; b=SYoYvLz6tNhQqN+LxR8Fk/vC5ss5TMOgEDypLNcvvxGULU66OG6X0b1ohLzcXzEQwo OYrlytlwhi1cyKGdkpF8ZeNIh2pzMhQ4dSgltpzeTas7R0l9YconXXkzVirryLHf8fwI bpcZKLub+10BAJzNrItw8w6krECoWdlOgw/aPsOfdiTuzZOQhBYhVBbzm6f/kiam7BHo G8hXjq3rbyde7YmUMUneIY76kjmkP4WUPtLLzEo7b4uH0aHJpSQOVMdDZX9ZdB3vES/b tOstrkb/d7f5TpuuYOJZqLdEdLKhlRSGWhyPnd5H5Lrc9yFtUduL8OCl5f++qyXkk1Mt Mikg== X-Gm-Message-State: AOAM533KX1ObHi39nyCzEgY/IGHSfKVa8Terx+i5Lf8PJvbKn0xh4Lww ai5I5q99soCLsrPLAHweedlGsAqW X-Google-Smtp-Source: ABdhPJyHbC7UxuxGXAQ190LqbTuWW5PgqJCnd3jZCHULno+JkuJySlR/Spv/r9pLy/hEIRIV3kpl2w== X-Received: by 2002:a5d:4e03:: with SMTP id p3mr14244415wrt.350.1590854771391; Sat, 30 May 2020 09:06:11 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id v27sm15186517wrv.81.2020.05.30.09.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 09:06:10 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 30 May 2020 18:05:07 +0200 Message-Id: <20200530160541.29517-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200530160541.29517-1-andreas.rheinhardt@gmail.com> References: <20200530160541.29517-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/36] avcodec/vp9_superframe_bsf: Reuse vp9_superframe_flush() 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavcodec/vp9_superframe_bsf.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/libavcodec/vp9_superframe_bsf.c b/libavcodec/vp9_superframe_bsf.c index 34a47aa69e..d9c78c67f5 100644 --- a/libavcodec/vp9_superframe_bsf.c +++ b/libavcodec/vp9_superframe_bsf.c @@ -31,6 +31,16 @@ typedef struct VP9BSFContext { AVPacket *cache[MAX_CACHE]; } VP9BSFContext; +static void vp9_superframe_flush(AVBSFContext *ctx) +{ + VP9BSFContext *s = ctx->priv_data; + + // unref cached data + for (int n = 0; n < s->n_cache; n++) + av_packet_unref(s->cache[n]); + s->n_cache = 0; +} + static void stats(AVPacket * const *in, int n_in, unsigned *_max, unsigned *_sum) { @@ -102,7 +112,7 @@ static int vp9_superframe_filter(AVBSFContext *ctx, AVPacket *pkt) { GetBitContext gb; VP9BSFContext *s = ctx->priv_data; - int res, invisible, profile, marker, uses_superframe_syntax = 0, n; + int res, invisible, profile, marker, uses_superframe_syntax = 0; res = ff_bsf_get_packet_ref(ctx, pkt); if (res < 0) @@ -166,9 +176,7 @@ static int vp9_superframe_filter(AVBSFContext *ctx, AVPacket *pkt) if (res < 0) goto done; - for (n = 0; n < s->n_cache; n++) - av_packet_unref(s->cache[n]); - s->n_cache = 0; + vp9_superframe_flush(ctx); done: if (res < 0) @@ -191,17 +199,6 @@ static int vp9_superframe_init(AVBSFContext *ctx) return 0; } -static void vp9_superframe_flush(AVBSFContext *ctx) -{ - VP9BSFContext *s = ctx->priv_data; - int n; - - // unref cached data - for (n = 0; n < s->n_cache; n++) - av_packet_unref(s->cache[n]); - s->n_cache = 0; -} - static void vp9_superframe_close(AVBSFContext *ctx) { VP9BSFContext *s = ctx->priv_data;