From patchwork Fri Sep 25 14:43:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 22587 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 75D8044B053 for ; Fri, 25 Sep 2020 18:06:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5E6ED68B6AA; Fri, 25 Sep 2020 18:06:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EE70A68AE53 for ; Fri, 25 Sep 2020 18:06:19 +0300 (EEST) Received: by mail-qt1-f194.google.com with SMTP id k25so2143880qtu.4 for ; Fri, 25 Sep 2020 08:06:19 -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=OZyJ6HrGq3ndBr8jJnZs7m+N8LjdHWLrpT6cNG4Pzd4=; b=VZfY1ogaA1JWEwl1eDYnr116mLV+RBtqViPiZqw28j0t7t+5ncRTZnSDxRrW7WkCXn 37E42w/b+rD5xrzT0JYIvGPqwb/q44SaLjZ671Fh+6CrCbE6URyKaYvRR9j2daXvsFaQ bk23Fp9Hb93+n9kQLyHJbctHBNx7ZHYCdAn1FsjPSqhrtzsN+GUWLb+62wza5tEZB3J8 q5TuJUhdAAO8TEGb2jW8BeGiZYnk89Gy56tt7rxgtcsBG8UuqEdRIYbl9nW29s/kiYde h+6xSBfr1nqVTJn6Ab+7FpJW232mmTaiU7Jzv1AIyZz6AV3T7ULc/7Z2+3ZT+e6JcN/j UTpQ== 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=OZyJ6HrGq3ndBr8jJnZs7m+N8LjdHWLrpT6cNG4Pzd4=; b=uc4gUfoXNT7MiSlsG/hWpZaP6hkN/5gbWDyQkhcHFnkc3mQBDUuhVhmNfF0CLZCaVe CHzrPbHPds37P/DpOpwJ9YDkQPo+viLPxORG4mABa/oPvfGTlIYEGXgsnHZlRfABm11f OVH4p5Mph8qqUCxn+1WygAlV+Oy0TU/1CBwDI/Pr1Jtdy5CAzWEMvXEqquuoxyKcQzLF AfYn0fBhf87dGE/6VIu4xnpye1MoHGK+4DqUuSTdepENQDyWkvLR9drjZsQuxofZT76y oo5PE0bteMwxpcniE4XckwGY6a3yeiHkDhsuNIVvwiwsuOLFo5PjxdwJ9Wbxz50DABBR trxw== X-Gm-Message-State: AOAM533yyAhSj0g+LizXaYiqAPOwF68n0pjpuYcl62RCHplJXAIDW373 kqXI5Lh4KtJCCxBtIAueIvtL3RfO2n5wkQ== X-Google-Smtp-Source: ABdhPJysXDiMIGMXCNluLvCx0p1Ic7UstNufFs/Q3be+VNS9Pl8C+UxHHnnjIev64OfKDgEkk3NoLQ== X-Received: by 2002:ac8:7003:: with SMTP id x3mr4667755qtm.206.1601045015349; Fri, 25 Sep 2020 07:43:35 -0700 (PDT) Received: from localhost.localdomain ([191.83.208.67]) by smtp.gmail.com with ESMTPSA id x126sm1792498qkb.101.2020.09.25.07.43.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 07:43:34 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 25 Sep 2020 11:43:13 -0300 Message-Id: <20200925144318.6194-3-jamrial@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200925144318.6194-1-jamrial@gmail.com> References: <20200925144318.6194-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] avcodec/cbs_h2645: implement CodedBitstreamType.flush() callbacks 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" Signed-off-by: James Almer --- libavcodec/cbs_h2645.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index b9233f4df7..b6d77dd17f 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1296,6 +1296,24 @@ static int cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx, return 0; } +static void cbs_h264_flush(CodedBitstreamContext *ctx) +{ + CodedBitstreamH264Context *h264 = ctx->priv_data; + + for (int i = 0; i < FF_ARRAY_ELEMS(h264->sps); i++) { + av_buffer_unref(&h264->sps_ref[i]); + h264->sps[i] = NULL; + } + for (int i = 0; i < FF_ARRAY_ELEMS(h264->pps); i++) { + av_buffer_unref(&h264->pps_ref[i]); + h264->pps[i] = NULL; + } + + h264->active_sps = NULL; + h264->active_pps = NULL; + h264->last_slice_nal_unit_type = 0; +} + static void cbs_h264_close(CodedBitstreamContext *ctx) { CodedBitstreamH264Context *h264 = ctx->priv_data; @@ -1309,6 +1327,28 @@ static void cbs_h264_close(CodedBitstreamContext *ctx) av_buffer_unref(&h264->pps_ref[i]); } +static void cbs_h265_flush(CodedBitstreamContext *ctx) +{ + CodedBitstreamH265Context *h265 = ctx->priv_data; + + for (int i = 0; i < FF_ARRAY_ELEMS(h265->vps); i++) { + av_buffer_unref(&h265->vps_ref[i]); + h265->vps[i] = NULL; + } + for (int i = 0; i < FF_ARRAY_ELEMS(h265->sps); i++) { + av_buffer_unref(&h265->sps_ref[i]); + h265->sps[i] = NULL; + } + for (int i = 0; i < FF_ARRAY_ELEMS(h265->pps); i++) { + av_buffer_unref(&h265->pps_ref[i]); + h265->pps[i] = NULL; + } + + h265->active_vps = NULL; + h265->active_sps = NULL; + h265->active_pps = NULL; +} + static void cbs_h265_close(CodedBitstreamContext *ctx) { CodedBitstreamH265Context *h265 = ctx->priv_data; @@ -1480,6 +1520,7 @@ const CodedBitstreamType ff_cbs_type_h264 = { .write_unit = &cbs_h264_write_nal_unit, .assemble_fragment = &cbs_h2645_assemble_fragment, + .flush = &cbs_h264_flush, .close = &cbs_h264_close, }; @@ -1495,6 +1536,7 @@ const CodedBitstreamType ff_cbs_type_h265 = { .write_unit = &cbs_h265_write_nal_unit, .assemble_fragment = &cbs_h2645_assemble_fragment, + .flush = &cbs_h265_flush, .close = &cbs_h265_close, };