From patchwork Wed Oct 2 04:04:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 15445 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 BE8BD449550 for ; Wed, 2 Oct 2019 07:10:25 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A32AD687F1B; Wed, 2 Oct 2019 07:10:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 690E4687F28 for ; Wed, 2 Oct 2019 07:10:19 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id a6so5476126wma.5 for ; Tue, 01 Oct 2019 21:10:19 -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:mime-version :content-transfer-encoding; bh=lW0jnIBCVUGhHtDSQ777FUJy/u/qP3siaNfzKdNivWQ=; b=VVMYbcvoTrzaMzxnfK2cM8SBTKErwuwffyimLsD5nWiDBaTNAr2BasS9pSwdLSAurZ RKAIude+SX9a3LLrOixb7w8DeWCXCHahjMylg3Byumjqe6EqsNxNaznZwazRAt84vCMA chx4Jk9GJsqtlrXWJr/JEKYbhMYZwoprwgtodMOEDnslIjwarBZlijmuRl0niznuptwQ a2eusFin7bQVE2AzJwsiqsJbFHYPZ72fznbsUfX6DoNIhPGlny964UG7tUZNrfOkG9m+ GhWLuigrte7V4XARIb3Zc9jy6JZ65iPeYI1/7IgF4yJ4Rd70KdPvdxMS1rq/NqOYxwG5 PkgQ== 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:mime-version :content-transfer-encoding; bh=lW0jnIBCVUGhHtDSQ777FUJy/u/qP3siaNfzKdNivWQ=; b=LIW9W8sf2S0i2fO8JaRzW+oeXM0mXEC8Furj8xfDCbBGCeYPri/R/1HIyw14GD0T5o zbOrlBwPuas4miLRb2hZaTqoA5HEV4TGvR3OowVDPu9NNmG/qfBq7/Bxr6nCUhCAXiIe Q7+QGQxD3ZVwMSw+/RIhRdH9UJNbac/XDlER8jVdWF0ZQIaDQS1da3cKnE3FgjA3LTkl xznGA6lQZJz2UHR/v+vDCzPVBqm8vG99ArU4fhM1sHtRVU3+qhjjHVbK5DmYUpe92a7O DPimwOOQuNzJXt15snC5vNZ1WBJs/7dSTud7iB7Vw6imGuvmxbC3f/gtdPRpotlM810V j6Og== X-Gm-Message-State: APjAAAVdrt54LbkzGSPZ2EY9+Re4fPcnZMYs9mOnC8PlyaZ0UhP/4L8a 8on8Q98JY9nK9o2GnUaFMWacw+UZ X-Google-Smtp-Source: APXvYqx66N1WuWOHypaHerKNK9D9ullhZt3KPrIU20fhwgBwIM2eK9puqQ42gPRVVZtAmtOZqHgGDQ== X-Received: by 2002:a1c:a516:: with SMTP id o22mr1081702wme.116.1569989070528; Tue, 01 Oct 2019 21:04:30 -0700 (PDT) Received: from localhost.localdomain (ipbcc0f857.dynamic.kabel-deutschland.de. [188.192.248.87]) by smtp.gmail.com with ESMTPSA id g11sm5025712wmh.45.2019.10.01.21.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 21:04:29 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Oct 2019 06:04:10 +0200 Message-Id: <20191002040412.821-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/aiffenc: Use standard packet list functions 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" Up until now, aiffenc didn't rely on the standard functions for adding an element to a linked list and freeing the list, but instead reimplemented them. This has been changed. Signed-off-by: Andreas Rheinhardt --- libavformat/aiffenc.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index aab37418f0..dd8b8c3d01 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -36,7 +36,7 @@ typedef struct AIFFOutputContext { int64_t frames; int64_t ssnd; int audio_stream_idx; - AVPacketList *pict_list; + AVPacketList *pict_list, *pict_list_end; int write_id3v2; int id3v2_version; } AIFFOutputContext; @@ -215,9 +215,6 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt) if (pkt->stream_index == aiff->audio_stream_idx) avio_write(pb, pkt->data, pkt->size); else { - int ret; - AVPacketList *pict_list, *last; - if (s->streams[pkt->stream_index]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) return 0; @@ -229,24 +226,8 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt) if (s->streams[pkt->stream_index]->nb_frames >= 1) return 0; - pict_list = av_mallocz(sizeof(AVPacketList)); - if (!pict_list) - return AVERROR(ENOMEM); - - ret = av_packet_ref(&pict_list->pkt, pkt); - if (ret < 0) { - av_freep(&pict_list); - return ret; - } - - if (!aiff->pict_list) - aiff->pict_list = pict_list; - else { - last = aiff->pict_list; - while (last->next) - last = last->next; - last->next = pict_list; - } + return ff_packet_list_put(&aiff->pict_list, &aiff->pict_list_end, + pkt, FF_PACKETLIST_FLAG_REF_PACKET); } return 0; @@ -257,7 +238,6 @@ static int aiff_write_trailer(AVFormatContext *s) int ret; AVIOContext *pb = s->pb; AIFFOutputContext *aiff = s->priv_data; - AVPacketList *pict_list = aiff->pict_list; AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar; /* Chunks sizes must be even */ @@ -293,12 +273,7 @@ static int aiff_write_trailer(AVFormatContext *s) avio_flush(pb); } - while (pict_list) { - AVPacketList *next = pict_list->next; - av_packet_unref(&pict_list->pkt); - av_freep(&pict_list); - pict_list = next; - } + ff_packet_list_free(&aiff->pict_list, &aiff->pict_list_end); return 0; }