From patchwork Fri Mar 5 16:33:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 26155 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 871C744B0AC for ; Fri, 5 Mar 2021 18:42:45 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B3B7B68AD3D; Fri, 5 Mar 2021 18:36:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CF19D68ACFD for ; Fri, 5 Mar 2021 18:36:12 +0200 (EET) Received: by mail-qk1-f179.google.com with SMTP id 130so2513137qkh.11 for ; Fri, 05 Mar 2021 08:36:12 -0800 (PST) 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=qXddxSdxnbFRlIeVOtSeVAY15y3sWTU/p9PoqJmDTjA=; b=Jng6GYcIP2qUbF/HO+IyhnT1Ycdh//tPJV0lYbHW6Rqizcj0qot+b4iB42H2cAAbnp sQb29uRw9qMOsFViImYj2M02RBChjdstBHB+tEFZB5Ek/C2/Ew3Z8nTZjxsbi11aUAPt UuTRvFN7AiD2E7aH7+urDDLheZx3tSsVXvmL5O23rf2yVGgU0LuC85ntsBz8ApqWwGh5 KlW9CblFhAtzLhpFnyQGiF0YBxcJNQzSEiwklAYua5lf5zjkYDt8T4jSnjOYH7E44pzS UAD6ILT0UiRKo8W/EyuoiTjhtq4dLCx5ExVhdIG9i0rRlgOE7AIiHevL7qi2XiGFlaa1 aHHg== 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=qXddxSdxnbFRlIeVOtSeVAY15y3sWTU/p9PoqJmDTjA=; b=q5U3UvaEy1y33AL67N/J1rDoBvTTML6YeEejSlV8hOH7JlDbvYZt039J9aK137eaRb hJ+7ANFypjpABuhCj5oelv5FJ8clBRH4rpAow10gznwzZh3yE5kMKMcGvRnh0sLx9MVV ADUyaNrLuC0rIaRJuOzrh7shID7iYnzx0J9WyWHVh2jFU4drusRtBKI6lFOcJ8FQ3Ufv 90uIydLfXznCoAq6djobqiZjwYIu7ImiHpQwn8Af8eGafLIQSYuaWAdRv9kOO0Arj5CY 8a5opVtWmXQWtCrvclAyL7AGytSY4C/JeEJ71jwa5LVi6kTwEsVESa/gTYY/QSl21wHS kbvQ== X-Gm-Message-State: AOAM530Qt6DUmdrXDNSSUv2JmAKFCks26BrBB/DGst6N0fZii/JBWMIp NCFe+DZ13mfrmO8ZjM3u1cAE1beJd4I35g== X-Google-Smtp-Source: ABdhPJxr5jXBDGS9kuPGoVw6yeXoFZySBLX/PRV+NHfinB7WiFsADoqsTpKLZ2RdQXXgZej3rF1Hww== X-Received: by 2002:a37:a785:: with SMTP id q127mr9502126qke.425.1614962171276; Fri, 05 Mar 2021 08:36:11 -0800 (PST) Received: from localhost.localdomain ([181.23.89.132]) by smtp.gmail.com with ESMTPSA id b10sm2168494qtt.23.2021.03.05.08.36.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Mar 2021 08:36:10 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Mar 2021 13:33:27 -0300 Message-Id: <20210305163339.63164-37-jamrial@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305163339.63164-1-jamrial@gmail.com> References: <20210305163339.63164-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 36/48] avfilter/vf_uspp: use av_packet_alloc() to allocate packets 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 --- libavfilter/vf_uspp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c index 8b39f53c3d..8c75207593 100644 --- a/libavfilter/vf_uspp.c +++ b/libavfilter/vf_uspp.c @@ -51,6 +51,7 @@ typedef struct USPPContext { int outbuf_size; uint8_t *outbuf; AVCodecContext *avctx_enc[BLOCK*BLOCK]; + AVPacket *pkt; AVFrame *frame; AVFrame *frame_dec; int8_t *non_b_qp_table; @@ -240,19 +241,19 @@ static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3], const int y1c = y1 >> p->vsub; const int BLOCKc = BLOCK >> p->hsub; int offset; - AVPacket pkt = {0}; + AVPacket *pkt = p->pkt; int got_pkt_ptr; - av_init_packet(&pkt); - pkt.data = p->outbuf; - pkt.size = p->outbuf_size; + av_packet_unref(pkt); + pkt->data = p->outbuf; + pkt->size = p->outbuf_size; p->frame->data[0] = p->src[0] + x1 + y1 * p->frame->linesize[0]; p->frame->data[1] = p->src[1] + x1c + y1c * p->frame->linesize[1]; p->frame->data[2] = p->src[2] + x1c + y1c * p->frame->linesize[2]; p->frame->format = p->avctx_enc[i]->pix_fmt; - ret = avcodec_encode_video2(p->avctx_enc[i], &pkt, p->frame, &got_pkt_ptr); + ret = avcodec_encode_video2(p->avctx_enc[i], pkt, p->frame, &got_pkt_ptr); if (ret < 0) { av_log(p->avctx_enc[i], AV_LOG_ERROR, "Encoding failed\n"); continue; @@ -373,6 +374,8 @@ static int config_input(AVFilterLink *inlink) uspp->outbuf_size = (width + BLOCK) * (height + BLOCK) * 10; if (!(uspp->frame = av_frame_alloc())) return AVERROR(ENOMEM); + if (!(uspp->pkt = av_packet_alloc())) + return AVERROR(ENOMEM); if (!(uspp->outbuf = av_malloc(uspp->outbuf_size))) return AVERROR(ENOMEM); @@ -465,6 +468,7 @@ static av_cold void uninit(AVFilterContext *ctx) av_freep(&uspp->non_b_qp_table); av_freep(&uspp->outbuf); + av_packet_free(&uspp->pkt); av_frame_free(&uspp->frame); }