From patchwork Wed Nov 18 16:52:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 23700 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 EC2B644B913 for ; Wed, 18 Nov 2020 18:53:23 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C10DA68B5D6; Wed, 18 Nov 2020 18:53:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C92C56805BE for ; Wed, 18 Nov 2020 18:53:17 +0200 (EET) Received: by mail-qk1-f178.google.com with SMTP id 199so2414702qkg.9 for ; Wed, 18 Nov 2020 08:53:17 -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=LwRE02dZGBlcPFOhnEsPfllyRvMltHozYMAy78jx7RI=; b=Ncr+Age7OWjotgdfZUqS6T7OrD+rO8jQeFpYa0L2sY06bU2wx/oTMuRi4/up5PFpwh R0VcTVq+eDtb8uH2kK5U5nBRCmj8fij4E7hPOLIltnW2XYvCqTCWKpjs/l5yYWg91rJk 1HbV5auBmizW4JssooIrPcDktaNWlewXmitjmUKIp8TKQ0pr1a1BItMkC4+45MbT8UNg gN5Ifa/gAd38ZvcgimCcB5ScdMomxKc76MAbduFQEpAO000G6/IMRO9iG3EuGjX6v84Y MRdYkRHYZbl7YNeIcRRb7xfS3IyzHUEXvzhFfeB1kuZNl/mnw7n1wBE0sK0in+K0m9fu UCfw== 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=LwRE02dZGBlcPFOhnEsPfllyRvMltHozYMAy78jx7RI=; b=DDrOLtNAHbnD+/IDrGZmIrf6qrLJqbOydZKyGbb8ZVnY3mLTR+FjEN21g9c1jzVBIN GW9V4AHbbpbSnzfxXxVNufEbi+VtIC3lGTSfdvPtlZrcSFv8FMyWzr2i6Ei0MnHwp6tS 2Bdu9clCAGSEF2a0YFXk9brhH10ydbb4iEQO1+mcb3iT6xV1AMe0v8wYAmLtP9QR3yYR ObBqhguw14f8prJ270hWmbS4xgjI+VyxD2dMr5olX/PEbVMHMDdU/7jfss/t8rnFqbaX P+6qk94/XEB+2cMDcDYBzsB1fFsZr7xmLg3flPO9/5lEq3O9AD1leK35A6hx+mX7lnp9 J5dw== X-Gm-Message-State: AOAM530Gvw3KpPdSk4t1vFlB0a96MP1Yd1++tdEfoC/Ziembkdpe17KB ZVaM4xObLkZRH92N6EAOLVzEJtiOp6aiMQ== X-Google-Smtp-Source: ABdhPJwEOhJdKT+1XUsmkjBOc2AbVgpoNQNNMwX1NrVv41IBHoEDfzip5tAnsr6UgzWCS+KGMT1mkg== X-Received: by 2002:a37:b642:: with SMTP id g63mr5518101qkf.460.1605718395817; Wed, 18 Nov 2020 08:53:15 -0800 (PST) Received: from localhost.localdomain ([181.23.91.217]) by smtp.gmail.com with ESMTPSA id f14sm4863788qkk.89.2020.11.18.08.53.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 08:53:15 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 18 Nov 2020 13:52:34 -0300 Message-Id: <20201118165247.4130-6-jamrial@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118165247.4130-1-jamrial@gmail.com> References: <20201118165247.4130-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/18] avcodec/decode: port to the new packet list API 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/decode.c | 20 ++++++++++---------- libavcodec/internal.h | 4 +--- libavcodec/utils.c | 11 ++++++----- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 5a1849f944..8a81280e7c 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -147,19 +147,21 @@ fail2: static int extract_packet_props(AVCodecInternal *avci, AVPacket *pkt) { +#if FF_API_PACKET_LIST + struct PacketList *pkt_props = (struct PacketList *)avci->pkt_props; +#else + AVPacketList *pkt_props = avci->pkt_props; +#endif int ret = 0; - ret = avpriv_packet_list_put(&avci->pkt_props, &avci->pkt_props_tail, pkt, - av_packet_copy_props, 0); + ret = av_packet_list_put(avci->pkt_props, pkt, av_packet_copy_props, 0); if (ret < 0) return ret; - avci->pkt_props_tail->pkt.size = pkt->size; // HACK: Needed for ff_decode_frame_props(). - avci->pkt_props_tail->pkt.data = (void*)1; // HACK: Needed for IS_EMPTY(). + pkt_props->tail->pkt.size = pkt->size; // HACK: Needed for ff_decode_frame_props(). + pkt_props->tail->pkt.data = (void*)1; // HACK: Needed for IS_EMPTY(). if (IS_EMPTY(avci->last_pkt_props)) { - ret = avpriv_packet_list_get(&avci->pkt_props, - &avci->pkt_props_tail, - avci->last_pkt_props); + ret = av_packet_list_get(avci->pkt_props, avci->last_pkt_props, 0); av_assert0(ret != AVERROR(EAGAIN)); } return ret; @@ -1722,9 +1724,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) }; if (IS_EMPTY(pkt)) - avpriv_packet_list_get(&avctx->internal->pkt_props, - &avctx->internal->pkt_props_tail, - pkt); + av_packet_list_get(avctx->internal->pkt_props, pkt, 0); if (pkt) { frame->pts = pkt->pts; diff --git a/libavcodec/internal.h b/libavcodec/internal.h index c72cce869e..e7d1d9ccb5 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -31,7 +31,6 @@ #include "libavutil/mathematics.h" #include "libavutil/pixfmt.h" #include "avcodec.h" -#include "packet_internal.h" #include "config.h" /** @@ -146,8 +145,7 @@ typedef struct AVCodecInternal { * for decoding. */ AVPacket *last_pkt_props; - PacketListEntry *pkt_props; - PacketListEntry *pkt_props_tail; + AVPacketList *pkt_props; /** * temporary buffer used for encoders to store their bitstream diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 9b074e2dda..42e6850169 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -593,10 +593,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code avci->es.in_frame = av_frame_alloc(); avci->ds.in_pkt = av_packet_alloc(); avci->last_pkt_props = av_packet_alloc(); + avci->pkt_props = av_packet_list_alloc(); if (!avci->compat_decode_frame || !avci->compat_encode_packet || !avci->buffer_frame || !avci->buffer_pkt || !avci->es.in_frame || !avci->ds.in_pkt || - !avci->to_free || !avci->last_pkt_props) { + !avci->to_free || !avci->last_pkt_props || + !avci->pkt_props) { ret = AVERROR(ENOMEM); goto free_and_end; } @@ -1054,6 +1056,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_packet_free(&avci->compat_encode_packet); av_packet_free(&avci->buffer_pkt); av_packet_free(&avci->last_pkt_props); + av_packet_list_free(&avci->pkt_props); av_packet_free(&avci->ds.in_pkt); av_frame_free(&avci->es.in_frame); @@ -1094,8 +1097,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) av_packet_unref(avci->buffer_pkt); av_packet_unref(avci->last_pkt_props); - avpriv_packet_list_free(&avci->pkt_props, - &avci->pkt_props_tail); + av_packet_list_flush(avci->pkt_props); av_frame_unref(avci->es.in_frame); av_packet_unref(avci->ds.in_pkt); @@ -1158,8 +1160,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) av_packet_free(&avctx->internal->compat_encode_packet); av_packet_free(&avctx->internal->buffer_pkt); av_packet_free(&avctx->internal->last_pkt_props); - avpriv_packet_list_free(&avctx->internal->pkt_props, - &avctx->internal->pkt_props_tail); + av_packet_list_free(&avctx->internal->pkt_props); av_packet_free(&avctx->internal->ds.in_pkt); av_frame_free(&avctx->internal->es.in_frame);