From patchwork Fri Mar 19 05:58:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26463 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 39653449D11 for ; Fri, 19 Mar 2021 07:59:19 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0921F68819D; Fri, 19 Mar 2021 07:59:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A34236880AA for ; Fri, 19 Mar 2021 07:59:12 +0200 (EET) Received: by mail-ej1-f48.google.com with SMTP id a7so7739428ejs.3 for ; Thu, 18 Mar 2021 22:59: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:reply-to:mime-version :content-transfer-encoding; bh=x+4Sxb0kjj+S/0fabK9TM2c1JI7QU3JbIOq0YM95yyE=; b=u6v7Fqt5EK8dFEAaWyQPIYWNwdpg4PHMK1pjAZAEqZigo667gHl1iBinMmjTvy2VJh uRMKxaraunGF+q9hg8e6CLK1YNUblxwxRUWB8Q3gJPybOvVHXGQ9c8RmAC/QxzPauKae 2flVhbv0C0xNdaBxR/4Om8yWdNYhOz5N20LXJQ//ghHzrD2zQfyU7A5oR7uPkyyFePB0 fK7pRn3K+AI54ajPZIY+MPmGJv8LFXgxF2d6jT8fkd9CbRobAnMD7qhCbBHCicxPpUO0 84xAsFc6HPKDHT1sJZZZ5n7G+CPBHROy6tX3T1497nRtP+CmftRawWuqxCc2LxWDGQxV u08g== 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:reply-to :mime-version:content-transfer-encoding; bh=x+4Sxb0kjj+S/0fabK9TM2c1JI7QU3JbIOq0YM95yyE=; b=HUSsTs8C36DjdKwCBvYrUn9pQMOrgDPs9VlpmpuRT5+qOZvgUpV72VgG5q0FEO1UvZ tPDIJJ5XrWuQHl0eyksLFnWIzGLeMUhN1hjqPPny3U78I1eyJU2dmwSwzm5IXskuHyEb P2sX9mXCtfkSc5d4jd9YqkBPNX9Zz2Diukflm2JievzlhuMF1wb5IzXSqxOJldcqWwRV v3AzKKRQuKT0Cn+7UkGq/aZaF9c7hPg1R9UV0GwumEu8GxOC00fBwTObVbmxvqZW8myS UMhCXrCC4TAJDCqbItQS7pJIT+cLgK18AsSIAPr6p1S18YWfNpvl19r3i+WDMKJD+X1j EQOQ== X-Gm-Message-State: AOAM531NkLSRHE5WB2/GeVxKMunxDGcUEaJ1U7x9Y6ueKUPIGoNLoB0T w4nNUOCv9xxrRDcVlgh1/p+Flk9Yfctskw== X-Google-Smtp-Source: ABdhPJyBpu9gIVoPONFXFxLSKpj/Vr2/NBnAK6RtDlvQJXdeyA/pg/b+BR35NlCKgNP5wr8GnaZWFg== X-Received: by 2002:a17:907:761c:: with SMTP id jx28mr2449775ejc.417.1616133552004; Thu, 18 Mar 2021 22:59:12 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:11 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:47 +0100 Message-Id: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/18] libavformat/utils: Fix indentation 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" Originally added in 12f996edfab67b65af0ff1ee829f9eeabb025b0f behind #if 0; aebb56e1844d61965c97e95534c3ae0da69df028 then removed the #if and replaced it by using av_dlog. Then commit 1a3eb042c704dea190c644def5b32c9cee8832b8 replaced this with av_log at trace level. Yet the code block always stayed within { } at an increased level of indentation. Signed-off-by: Andreas Rheinhardt --- libavformat/utils.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 295e676c9c..d9a08c9ccd 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2945,23 +2945,19 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset) } update_stream_timings(ic); - { - int i; - AVStream av_unused *st; - for (i = 0; i < ic->nb_streams; i++) { - st = ic->streams[i]; - if (st->time_base.den) - av_log(ic, AV_LOG_TRACE, "stream %d: start_time: %s duration: %s\n", i, - av_ts2timestr(st->start_time, &st->time_base), - av_ts2timestr(st->duration, &st->time_base)); - } - av_log(ic, AV_LOG_TRACE, - "format: start_time: %s duration: %s (estimate from %s) bitrate=%"PRId64" kb/s\n", - av_ts2timestr(ic->start_time, &AV_TIME_BASE_Q), - av_ts2timestr(ic->duration, &AV_TIME_BASE_Q), - duration_estimate_name(ic->duration_estimation_method), - (int64_t)ic->bit_rate / 1000); - } + for (unsigned i = 0; i < ic->nb_streams; i++) { + AVStream *st = ic->streams[i]; + if (st->time_base.den) + av_log(ic, AV_LOG_TRACE, "stream %u: start_time: %s duration: %s\n", i, + av_ts2timestr(st->start_time, &st->time_base), + av_ts2timestr(st->duration, &st->time_base)); + } + av_log(ic, AV_LOG_TRACE, + "format: start_time: %s duration: %s (estimate from %s) bitrate=%"PRId64" kb/s\n", + av_ts2timestr(ic->start_time, &AV_TIME_BASE_Q), + av_ts2timestr(ic->duration, &AV_TIME_BASE_Q), + duration_estimate_name(ic->duration_estimation_method), + (int64_t)ic->bit_rate / 1000); } static int has_codec_parameters(AVStream *st, const char **errmsg_ptr) From patchwork Fri Mar 19 05:58:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26464 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 8E678449D11 for ; Fri, 19 Mar 2021 07:59:44 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6AC1168A57A; Fri, 19 Mar 2021 07:59:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3FD1668A26E for ; Fri, 19 Mar 2021 07:59:38 +0200 (EET) Received: by mail-ej1-f53.google.com with SMTP id l4so7739967ejc.10 for ; Thu, 18 Mar 2021 22:59:38 -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:reply-to :mime-version:content-transfer-encoding; bh=Dl96XLRkve5qxXgeme88UHcGeYbfg4fg3wU8bC9rWfQ=; b=FfhyINUXDKgfW15R0+4+tGcPQLfCTYtG4EiDBE9nc4Tyov76ulILJCurG/3HaHiKiw oOFLmrTZGIan+JxjfEH3wYQOPYySsyaNrDiHeuX9Q28EiuCpDipOD+HcBf9uGzSzkfF3 7irvsVY/aynJgv/1EmQ2ckTqx+GbpXvafBnUdYuoKNhemllxVAhfILFw7ZajgoI3DSsN 6qF2dCESmH+/6QZopd6dGVT7rHkqiUAG0I6tXFHsAVqJ4Q1li8ZgkuoFBVaXq/SMfV2s s/u+Zs60butzcOgBQHj53guayrHs8E1eq9dg5lPXqhIJmy9d/LoP+TpkcPbOio4rvF24 U7NQ== 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:reply-to:mime-version:content-transfer-encoding; bh=Dl96XLRkve5qxXgeme88UHcGeYbfg4fg3wU8bC9rWfQ=; b=r8pT90K1fiM+xGQTzU/HPb1P2WRL/dyGBYbQRAhkQSlEzBSHYg0EPXYg4Mv90JPNKi gtVHDeOuh1iYuNoz+gqfLLtKKxYK/vYZAcIBOyVRuclKN07xcxAwCE48q6qkmJaILtKJ lvrHe921ZOKwIr5C7Mw5/GORRhq/ZgsY45pRYBaJ0Qb4fu6J9tSuMVhsSzwy0gYsA6cX Hpuk1KBhSs7mVxm+amzH/VrYPXgYs4E+usMk9QJXY6mjGeakGcp9XhFQJVmE0Yd+022Z 8T66VAaNmuLDjQKq7UejKuMvYWEVJKQ7fd/nUu1+r+AHzY6gUCUiIBMYG50gc1CtmbMr Hz7g== X-Gm-Message-State: AOAM530PJLHXMV0N8tVYI9gfF+OCT0OXPrtv14LhLxxXyILC35PwxT7W DoU25wVm6xem5RRz+JwUP7ZIjbRC/GSegA== X-Google-Smtp-Source: ABdhPJyxYB7S5Y6dG3Nr72CrU8aDkSupOkO1Dgv2ZhC0LeT2QID5jc5b3w8UEICZtY0pN01J6sNqlQ== X-Received: by 2002:a17:906:1155:: with SMTP id i21mr2444146eja.218.1616133577559; Thu, 18 Mar 2021 22:59:37 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:37 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:48 +0100 Message-Id: <20210319055904.2264501-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/18] avformat/utils: Always leave parse_pkt in blank state, avoid resetting 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" Always leaving said packet in a blank state after having used it allows to avoid having to reset it before one uses it; and it also allows to use it in more places than just in parse_packets() here. Signed-off-by: Andreas Rheinhardt --- libavformat/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index d9a08c9ccd..0c167d0cb9 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1427,9 +1427,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int size = pkt->size; int ret = 0, got_output = flush; - if (size || flush) { - av_packet_unref(out_pkt); - } else if (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) { + if (!size && !flush && st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) { // preserve 0-size sync packets compute_pkt_fields(s, st, st->parser, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE); } @@ -1525,6 +1523,8 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, } fail: + out_pkt->data = NULL; + out_pkt->size = 0; av_packet_unref(pkt); return ret; } From patchwork Fri Mar 19 05:58:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26465 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 B4D5E449D11 for ; Fri, 19 Mar 2021 07:59:45 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8CC3368A636; Fri, 19 Mar 2021 07:59:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E456668A57A for ; Fri, 19 Mar 2021 07:59:38 +0200 (EET) Received: by mail-ej1-f51.google.com with SMTP id r12so7745171ejr.5 for ; Thu, 18 Mar 2021 22:59:38 -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:reply-to :mime-version:content-transfer-encoding; bh=Y4NwX9rPT1XmAENjao9nMylyOHaNQvploksWqqrmnZc=; b=ILA2r0zNGEk6O+moim0eCmeLU+VUCJz/Muge5Ut31Zl/pt5zDk80+PPp+k2Rr0ntAZ sn6+TUHpL69UOK0VFQKsF2TfxnC0jrGF4CC5ZG6ric9WWVLhQ26UP2TZT0U/I7Ifsjfb dDbv/wOEdxl4+tOVxgXo0dJY19vwrX5K0tDgJB1LhXfxB9kJ9GyiR7JhRa6gcbm7HKvc vEGPo4nI1/QZT0cpRi9fHgTNahV1uUvR2ZPt9GfkY+eMyufHVhWrv+m51heR76Zlh4xt pAukWiqqJg+JYohZcYGLzj/2AxViWODdpLPTIY3/hhdPDsCq+WEUS83w4YHezPmtgj/5 YMag== 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:reply-to:mime-version:content-transfer-encoding; bh=Y4NwX9rPT1XmAENjao9nMylyOHaNQvploksWqqrmnZc=; b=JPy1ZsdfAtkViW65UWN2/x7AnHrdm9FYSg3/BYEgmVKyBG3kGpudGal+5sinkjJxen AV45TMpsx9tLg9FjSNGXfYv4mRsx7D0iuZuH5ZgHOIV5EuJh452C62ZKPJTnGXA1DchN bH0fo59z0zWBW6a5QLMzTcu+aFpawxfRkZW8U9zJmKDyabWh4KKftsB27RoOIkkk2iwv 681tx/gxRgNg4youv0bCa3WDMEK3oUK93p8UjDIYWWVD/XjfpkN+ClaE0LQ10r7piTmF q2XsH5otaa6/kdUDNFYHf5HPPmur3qaU73g2HiJ8eP0/V8W6nOYRG40tVYGqzEPyi87o Q4lQ== X-Gm-Message-State: AOAM531H3k2agPPRHqNJXv8gItAhfgw0+xxrAMts359q9X4v7KZqaXbI JFdXst798bHLoEEFIqICksbpbWtWdpjGBw== X-Google-Smtp-Source: ABdhPJxqNaYqmusbzARXRgsBHsRu0SedvU0WfIxow/uE7TpKQ5OO1RWht8a4HpzN2YJQaNIEZS3Azg== X-Received: by 2002:a17:906:c301:: with SMTP id s1mr2417325ejz.382.1616133578281; Thu, 18 Mar 2021 22:59:38 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:37 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:49 +0100 Message-Id: <20210319055904.2264501-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/18] avformat/utils: Don't allocate separate packet for extract_extradata 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" One can simply reuse AVFormatInternal.parse_pkt instead. Signed-off-by: Andreas Rheinhardt --- libavformat/internal.h | 12 ++++++++++-- libavformat/utils.c | 29 ++++++++++------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 3c6b2921c1..a810d51bba 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -90,9 +90,18 @@ struct AVFormatInternal { /** * Packets split by the parser get queued here. */ - AVPacket *parse_pkt; struct PacketList *parse_queue; struct PacketList *parse_queue_end; + /** + * The generic code uses this as a temporary packet + * to parse packets; it may also be used for other means + * for short periods that are guaranteed not to overlap + * with calls to av_read_frame() (or ff_read_packet()) + * or with each other. + * Every user has to ensure that this packet is blank + * after using it. + */ + AVPacket *parse_pkt; /** * Used to hold temporary packets. @@ -190,7 +199,6 @@ struct AVStreamInternal { * supported) */ struct { AVBSFContext *bsf; - AVPacket *pkt; int inited; } extract_extradata; diff --git a/libavformat/utils.c b/libavformat/utils.c index 0c167d0cb9..3542e40afd 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3498,13 +3498,9 @@ static int extract_extradata_init(AVStream *st) if (!ret) goto finish; - sti->extract_extradata.pkt = av_packet_alloc(); - if (!sti->extract_extradata.pkt) - return AVERROR(ENOMEM); - ret = av_bsf_alloc(f, &sti->extract_extradata.bsf); if (ret < 0) - goto fail; + return ret; ret = avcodec_parameters_copy(sti->extract_extradata.bsf->par_in, st->codecpar); @@ -3523,14 +3519,12 @@ finish: return 0; fail: av_bsf_free(&sti->extract_extradata.bsf); - av_packet_free(&sti->extract_extradata.pkt); return ret; } -static int extract_extradata(AVStream *st, const AVPacket *pkt) +static int extract_extradata(AVStream *st, AVPacket *tmp, const AVPacket *pkt) { AVStreamInternal *sti = st->internal; - AVPacket *pkt_ref; int ret; if (!sti->extract_extradata.inited) { @@ -3542,27 +3536,26 @@ static int extract_extradata(AVStream *st, const AVPacket *pkt) if (sti->extract_extradata.inited && !sti->extract_extradata.bsf) return 0; - pkt_ref = sti->extract_extradata.pkt; - ret = av_packet_ref(pkt_ref, pkt); + ret = av_packet_ref(tmp, pkt); if (ret < 0) return ret; - ret = av_bsf_send_packet(sti->extract_extradata.bsf, pkt_ref); + ret = av_bsf_send_packet(sti->extract_extradata.bsf, tmp); if (ret < 0) { - av_packet_unref(pkt_ref); + av_packet_unref(tmp); return ret; } while (ret >= 0 && !sti->avctx->extradata) { - ret = av_bsf_receive_packet(sti->extract_extradata.bsf, pkt_ref); + ret = av_bsf_receive_packet(sti->extract_extradata.bsf, tmp); if (ret < 0) { if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) return ret; continue; } - for (int i = 0; i < pkt_ref->side_data_elems; i++) { - AVPacketSideData *side_data = &pkt_ref->side_data[i]; + for (int i = 0; i < tmp->side_data_elems; i++) { + AVPacketSideData *side_data = &tmp->side_data[i]; if (side_data->type == AV_PKT_DATA_NEW_EXTRADATA) { sti->avctx->extradata = side_data->data; sti->avctx->extradata_size = side_data->size; @@ -3571,7 +3564,7 @@ static int extract_extradata(AVStream *st, const AVPacket *pkt) break; } } - av_packet_unref(pkt_ref); + av_packet_unref(tmp); } return 0; @@ -3923,7 +3916,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st->internal->info->frame_delay_evidence = 1; } if (!st->internal->avctx->extradata) { - ret = extract_extradata(st, pkt); + ret = extract_extradata(st, ic->internal->parse_pkt, pkt); if (ret < 0) goto unref_then_goto_end; } @@ -4189,7 +4182,6 @@ find_stream_info_err: avcodec_close(ic->streams[i]->internal->avctx); av_freep(&ic->streams[i]->internal->info); av_bsf_free(&ic->streams[i]->internal->extract_extradata.bsf); - av_packet_free(&ic->streams[i]->internal->extract_extradata.pkt); } if (ic->pb) av_log(ic, AV_LOG_DEBUG, "After avformat_find_stream_info() pos: %"PRId64" bytes read:%"PRId64" seeks:%d frames:%d\n", @@ -4391,7 +4383,6 @@ static void free_stream(AVStream **pst) av_freep(&st->internal->probe_data.buf); av_bsf_free(&st->internal->extract_extradata.bsf); - av_packet_free(&st->internal->extract_extradata.pkt); if (st->internal->info) av_freep(&st->internal->info->duration_error); From patchwork Fri Mar 19 05:58:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26466 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 C1179449D11 for ; Fri, 19 Mar 2021 07:59:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AB47768A67E; Fri, 19 Mar 2021 07:59:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D006A68A60C for ; Fri, 19 Mar 2021 07:59:39 +0200 (EET) Received: by mail-ej1-f52.google.com with SMTP id ce10so7739117ejb.6 for ; Thu, 18 Mar 2021 22:59:39 -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:reply-to :mime-version:content-transfer-encoding; bh=Ano5hR6SisKC1O1SNKIpITSp3Ott5Gcg1z5eNwo15IU=; b=gn/AeaQg3YNt0N1EL4IflnSNJtvejkk3RJfwKhNf9HS2zPm2IotfZf3Hh5tUZyoddn 0xrPcMLAh9GXVw5201gaBPnGN2fJLQBJbo7mQ2tGPanl4flauLFu180o0T53o3sXqdS8 RzFItgWSj/zqAj1sfvWQhVyZOOUfvjsCC8iSDqE6hNZ/NyExPd5tEEjHAdye4OdCFpqB Avilw6tAS/fGxjUMW42u1ojrqSvIa2f/ptiMBDTlfw4v5R83yO7ycjvtxsuW+bZEI3Yf LctvUMHmjY3oBKoEEF/tYsrRuaqZsf6xKV89dUgX6xWcPdXqOivJYmILrctLbDPkMcW6 J8ug== 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:reply-to:mime-version:content-transfer-encoding; bh=Ano5hR6SisKC1O1SNKIpITSp3Ott5Gcg1z5eNwo15IU=; b=JpReMHPZeOc3XiBfB89KLb0m1wCVNzdFisHdg6MRcE+cB4tbkwa4iHKRa5XfsucnKO uINEC1mCPEsyzD1gzKB3X0uKXhty7pOeM0Dt8KKqxbCElVAT/eJ8uWZQ5SarZHD0dL60 1WDtPFfuPFMDXxEOsDphOjocxqzFZsXxK63YhBMrI5Iv5xEwP9uX6fbs0tQo34Bu78hg lldwDzxW9jsQELTLs1IFySfuPqTQMfIN03ZVaplR5EJ7wVi37Kdztfy9pqIxK1FADH2Q z6jItoS9fVlXLqscSi5N7qm27gGO0vg5GsWUou74NuOVgEEGedQCxqe4KaqNPvFrXUXN gKyw== X-Gm-Message-State: AOAM533+rxT8+1CeDe74FkZkavQC1BulRptQxDt8lQ+K5o9Qkbd2HvcI bSER8olgy5EO4ItuzcIbQz57M4CJGJ/pJQ== X-Google-Smtp-Source: ABdhPJzu2iTH/t4Pm0lS2hqGEv54KGS3tip4WmvbkeSR5roNUiJVAFmq4RArNxHd8xIU3VL0DwHNfg== X-Received: by 2002:a17:906:70d:: with SMTP id y13mr2426826ejb.170.1616133579050; Thu, 18 Mar 2021 22:59:39 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:38 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:50 +0100 Message-Id: <20210319055904.2264501-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/18] avformat/matroskadec: Reuse AVFormatInternal.parse_pkt 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" Before 8d78e90a6ba96646f7f25aff6ca3e12e71cec164 the Matroska demuxer used stack packets to hold temporary packets; now it uses a temporary packet allocated by the Matroska demuxer. Yet because it used stack packets the code has always properly reset the packet on error, while on success these temporary packets were put into a packet list via avpriv_packet_list_put(), which already resets the source packet. This means that this code is compatible with just reusing AVFormatInternal.parse_pkt (which is unused while one is in the demuxer's read_packet() function). Compared to before 8d78e90a6 this no longer wastes one initialization per AVPacket read (the resetting of the stack packet performed by av_packet_move_ref() in avpriv_packet_list_put() was for naught). Signed-off-by: Andreas Rheinhardt --- libavformat/internal.h | 3 +++ libavformat/matroskadec.c | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index a810d51bba..c730332031 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -98,6 +98,9 @@ struct AVFormatInternal { * for short periods that are guaranteed not to overlap * with calls to av_read_frame() (or ff_read_packet()) * or with each other. + * It may be used by demuxers as a replacement for + * stack packets (unless they call one of the aforementioned + * functions with their own AVFormatContext). * Every user has to ensure that this packet is blank * after using it. */ diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 9acfdf5b32..1dc188c946 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -381,6 +381,8 @@ typedef struct MatroskaDemuxContext { /* byte position of the segment inside the stream */ int64_t segment_start; + /* This packet coincides with AVFormatInternal.parse_pkt + * and is not owned by us. */ AVPacket *pkt; /* the packet queue */ @@ -2945,9 +2947,7 @@ static int matroska_read_header(AVFormatContext *s) } ebml_free(ebml_syntax, &ebml); - matroska->pkt = av_packet_alloc(); - if (!matroska->pkt) - return AVERROR(ENOMEM); + matroska->pkt = s->internal->parse_pkt; /* The next thing is a segment. */ pos = avio_tell(matroska->ctx->pb); @@ -3528,7 +3528,6 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, if (!pkt_size && !additional_size) goto no_output; - av_packet_unref(pkt); if (!buf) pkt->buf = av_buffer_create(pkt_data, pkt_size + AV_INPUT_BUFFER_PADDING_SIZE, NULL, NULL, 0); @@ -3902,7 +3901,6 @@ static int matroska_read_close(AVFormatContext *s) int n; matroska_clear_queue(matroska); - av_packet_free(&matroska->pkt); for (n = 0; n < matroska->tracks.nb_elem; n++) if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO) From patchwork Fri Mar 19 05:58:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26467 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 A0055449D11 for ; Fri, 19 Mar 2021 07:59:48 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8787368A778; Fri, 19 Mar 2021 07:59:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7FBC568A26E for ; Fri, 19 Mar 2021 07:59:40 +0200 (EET) Received: by mail-ej1-f42.google.com with SMTP id hq27so7745304ejc.9 for ; Thu, 18 Mar 2021 22:59:40 -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:reply-to :mime-version:content-transfer-encoding; bh=QczEzdX+p2pJWe4YElpgn0a06axjr7CqEYWfojZdHYk=; b=TDSkaNoiNyKlS9UzS3DZxP3F5frqDXkoCXRrR0+ZhKZBw2sKl51cjOPRM0qudJW0F6 wIUgTkEJiMX3rk4miNq6S5hx2wbySP6y8Rz5RZmvpj09PZTxsATkjKauXUTqLhJ7P4oQ dK25FElN0sGpIPov4Lx0rVUsIniaOmDOpQNquJVUXQflwwcjiDwxhrGr8A9fA5Lgm5Rj QctK4FeeiAkDiqX9p0ArTuUhGU2ukjRF0lR5lsdbmJXJZP1oKLesBXrDbdozR0dYdnuM JwmDFsLli7hV/mqPczeDxMbKUmtRNnLxBg3n25mpTVc+J+XWAGcbZILcjerSfU1Gs8a7 5vew== 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:reply-to:mime-version:content-transfer-encoding; bh=QczEzdX+p2pJWe4YElpgn0a06axjr7CqEYWfojZdHYk=; b=RUOxSV+z/20YmeB/rk/1u3v5C+4Ig+S3JvWKlDUH/Ez6m6rTJ8L2uTE7wzB5NiGK8B bWq0QvvQKhSzTk/H2rnR8tcAWfrhOxOoq5oy/opeBWsGxV5H+1SfNpbygafwvt+Zxw7/ EK9btUQLKMggp6XMsdnT3fAMuvxhKexQjX/76wCpEypMlgrair/J6etJszunfSdzEQ4H GIJUR438N7PApRqHkwiYkmXD7n/Nr26t2f7iWFgAjIMxc6Q1rhJhQ97LK5+wmjoIE/kR 4SEYqfQAXvfOh19z8qLboJ4CaiButKVQ8K2pUbdeMU++9mEKZeqDJnarabEnBdrY/wra 0sfA== X-Gm-Message-State: AOAM533Nr4amtqiTKTI70WWCyY8fTJ+nut2kw4glhJhjhJtSNiDMlEsh j4bmg9TKBp0UTNNBkSqsblweRORMZYP2JQ== X-Google-Smtp-Source: ABdhPJxGu8VwYxu0DH4CcTE8YyQzlBg0KzrwRejKeykO2KgTeX7SzPTZ+NcX4+kKjvhcDTvISHTBJg== X-Received: by 2002:a17:906:b015:: with SMTP id v21mr2338687ejy.243.1616133579861; Thu, 18 Mar 2021 22:59:39 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:39 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:51 +0100 Message-Id: <20210319055904.2264501-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/18] avformat/moflex: Simplify freeing 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/moflex.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavformat/moflex.c b/libavformat/moflex.c index 41335ada78..dabe113e6b 100644 --- a/libavformat/moflex.c +++ b/libavformat/moflex.c @@ -369,10 +369,7 @@ static int moflex_read_seek(AVFormatContext *s, int stream_index, static int moflex_read_close(AVFormatContext *s) { for (int i = 0; i < s->nb_streams; i++) { - AVPacket *packet = s->streams[i]->priv_data; - - av_packet_free(&packet); - s->streams[i]->priv_data = 0; + av_packet_free((AVPacket **)&s->streams[i]->priv_data); } return 0; From patchwork Fri Mar 19 05:58:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26468 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 B9302449D11 for ; Fri, 19 Mar 2021 07:59:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A547568A831; Fri, 19 Mar 2021 07:59:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4489E68A6EA for ; Fri, 19 Mar 2021 07:59:41 +0200 (EET) Received: by mail-ej1-f50.google.com with SMTP id w3so7734925ejc.4 for ; Thu, 18 Mar 2021 22:59:41 -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:reply-to :mime-version:content-transfer-encoding; bh=JdMjfhNc6gbxHGJgcNG9rw2Ui2HndBuVyRE4e5AqRuE=; b=Y/I70ctwjSvV7mgZ0X/g/IA09Ni2ikD6tDIz1PHaViI5tDmQpgm0puZjbI2B8d74Lb aZ+OKbJLLp4+H4QO30mAVtrB982u9EzfKnsPre/Fkpn4M8yfAmHjP+/vHrPpdkqj/+ot bLhnZ8eGLK9C5ahr4Swr7zpFztLAYm0+ujy/d1egAmXDnfVVbph55M2BcolbFkiuJrdi C/eOa4SHHE8fKnG8skpf7PyAEnFQQhZYQhZ52K6NrnXaARA+UVLKvicu/Ip6fyUdrM6b LvOdZ8SU6AFuYF1BJq48mr9VelN610gHTY9OnLhgiZrt8jXj2jQRMHP+VyqQhXyOQQzO Ni9w== 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:reply-to:mime-version:content-transfer-encoding; bh=JdMjfhNc6gbxHGJgcNG9rw2Ui2HndBuVyRE4e5AqRuE=; b=L0XJg5LvreJhS+8ZFzs5neE+hqTPSFOc7N2B0bNodUhu9Y/7KzLkh0m0t8xVzDtn1d U3+HUbEFQDTDulAB00J9IuNvstSX/pkisA5TxLHLbu/4/Zvi/ttrrhlILJ/iIl8/N36k eEc3goSY0ha596+No+UTbtdRij7/uDaQgn7ShzILZxyP0V7Ae3oAXTRGU7k9HalUJS4q YEU6VrR/YddDD+iczXWw+L+7+xRrGj7OhQcg79/lJUVlWyfuTtZ9LUUtjPzSwf2cs8Oc SbTK9NIn3dxUheh5hm+am6J0e3Jgbxsm/MPQehC3KNnYnqfuxCJN3duqzrvuYdaXGCBc pRzA== X-Gm-Message-State: AOAM531p9188BgD3QcCLY/5MdUo4XLd57SmvAa271H7KgCbVmlu80fl2 5bL4DAd1Shk2udqCqfwUger+ZTdQNhJEbQ== X-Google-Smtp-Source: ABdhPJyazjYwmxuiMc0i6wdqYMDuXW/WbOHgKdQayt27GfdqD6/OjKPFmdZjdN5q4i3lNOni2Xd5Ig== X-Received: by 2002:a17:906:5495:: with SMTP id r21mr2442649ejo.471.1616133580566; Thu, 18 Mar 2021 22:59:40 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:40 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:52 +0100 Message-Id: <20210319055904.2264501-6-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/18] avformat/apetag: Avoid stack packet when reading attached picture 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" Read it directly into AVStream.attached_pic. Signed-off-by: Andreas Rheinhardt --- libavformat/apetag.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/apetag.c b/libavformat/apetag.c index 454c6c688b..23ee6b516d 100644 --- a/libavformat/apetag.c +++ b/libavformat/apetag.c @@ -79,10 +79,9 @@ static int ape_tag_read_field(AVFormatContext *s) av_dict_set(&st->metadata, key, filename, 0); if ((id = ff_guess_image2_codec(filename)) != AV_CODEC_ID_NONE) { - AVPacket pkt; int ret; - ret = av_get_packet(s->pb, &pkt, size); + ret = av_get_packet(s->pb, &st->attached_pic, size); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Error reading cover art.\n"); return ret; @@ -92,7 +91,6 @@ static int ape_tag_read_field(AVFormatContext *s) st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->codec_id = id; - st->attached_pic = pkt; st->attached_pic.stream_index = st->index; st->attached_pic.flags |= AV_PKT_FLAG_KEY; } else { From patchwork Fri Mar 19 05:58:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26470 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 2DEC1449D11 for ; Fri, 19 Mar 2021 07:59:52 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DF55068A880; Fri, 19 Mar 2021 07:59:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E10D968A682 for ; Fri, 19 Mar 2021 07:59:41 +0200 (EET) Received: by mail-ej1-f53.google.com with SMTP id jy13so7726907ejc.2 for ; Thu, 18 Mar 2021 22:59:41 -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:reply-to :mime-version:content-transfer-encoding; bh=0VfeZon+vIKaDVTObW3wFo/3GT2I5n7Rt8+OlC9H3HM=; b=RI7LC1UgGU2CahXcXvVhnRU8e0NMllgg7pofnn2WVhHhoBUGWn/utpi/p8U4lAo7+d pRfUC/7g5XDkCzqIa6ey3tMntXTMggjZWTC1v1YbdObELLk72c7t5VGOXXLoiR1KXfud ypK/FbbfA+ZxuFdAmARGJuOHNrtOkGYIl/uuOdmk+g8ZBFFXfy2jsZDwFd5KnTKZYjwV Nz8MUJYtk5u3ja3Owz7QK7SJ4fUo1Z9A64Xks58APsoxLDGkX8xiMcEGcS4UrqpLoKo2 k7UdJkfb6gCNICNeAT1D3Rv3AI2LSLWYA6TJ3vQ+XDGIthvbhNNXis37SvGpS+JwyPJK RTEA== 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:reply-to:mime-version:content-transfer-encoding; bh=0VfeZon+vIKaDVTObW3wFo/3GT2I5n7Rt8+OlC9H3HM=; b=CACLvGUgGOTQu2nB14qQhKBWPEm3NjQm5n8ACesQkdw2AqzNfQBoyg+htQ/AG0eOvK BbvmvvNep38YpjnB5i1IvUxXglTSDwAas7sp9KFqIPdtfj6472EM3tP/4R/ZviiOjtME eu45l6yfitxeA81bDAbda0KaNw6cIbT0l7z5iirBageDadziwjy2G8G+2dmaRfDvoE7v L5k75IPhho6rl3gSK2c/GLMmln11tM8ZkbtuZCcBhZyAIk4B1VsBX5uIqvq4c/g7KP2O hGbd57YEvNdARNvMErZsq/oO5RGk0JBWnmDWpJ33aq0SW7XECiis1icaTWI+7zUL9hrN In0A== X-Gm-Message-State: AOAM532pKoq+FAB/bXO5GPoGCutk26TLkbkbd98jMmobBQxxSMn4TBGv 82mYB5p+cD7l2lLeLGzKCJiJQWELWx+MSg== X-Google-Smtp-Source: ABdhPJwXPwpH1navlqBSv0UgxH49TiWYSmPq2LAENMcvkLWKRk54aZ9O5fsBBSIr5Dtjs7Q6IpQzJw== X-Received: by 2002:a17:907:1b20:: with SMTP id mp32mr2406096ejc.495.1616133581301; Thu, 18 Mar 2021 22:59:41 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:40 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:53 +0100 Message-Id: <20210319055904.2264501-7-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/18] avformat/asfdec_f: Avoid stack packet 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" Replace it by using AVFormatInternal.parse_pkt which is otherwise unused when reading a header. Signed-off-by: Andreas Rheinhardt --- libavformat/asfdec_f.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c index 1484b544d9..2fae528f4d 100644 --- a/libavformat/asfdec_f.c +++ b/libavformat/asfdec_f.c @@ -860,17 +860,17 @@ static int asf_read_header(AVFormatContext *s) } else { if (!s->keylen) { if (!ff_guidcmp(&g, &ff_asf_content_encryption)) { + AVPacket *pkt = s->internal->parse_pkt; unsigned int len; - AVPacket pkt; av_log(s, AV_LOG_WARNING, "DRM protected stream detected, decoding will likely fail!\n"); len= avio_rl32(pb); av_log(s, AV_LOG_DEBUG, "Secret data:\n"); - if ((ret = av_get_packet(pb, &pkt, len)) < 0) + if ((ret = av_get_packet(pb, pkt, len)) < 0) return ret; - av_hex_dump_log(s, AV_LOG_DEBUG, pkt.data, pkt.size); - av_packet_unref(&pkt); + av_hex_dump_log(s, AV_LOG_DEBUG, pkt->data, pkt->size); + av_packet_unref(pkt); len= avio_rl32(pb); if (len > UINT16_MAX) From patchwork Fri Mar 19 05:58:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26472 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 C00E2449D11 for ; Fri, 19 Mar 2021 07:59:54 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7D74068A8B9; Fri, 19 Mar 2021 07:59:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A7EB268A6B5 for ; Fri, 19 Mar 2021 07:59:42 +0200 (EET) Received: by mail-ed1-f42.google.com with SMTP id w18so9452397edc.0 for ; Thu, 18 Mar 2021 22:59:42 -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:reply-to :mime-version:content-transfer-encoding; bh=GU2dsgWqK/mobsV8NfKx95OZzLHx/CI7H+piHWdepys=; b=kNjCZ45jjnCty1ILF8gxqohn/uC/WlGmPe0fpXeWWVaufWYUofD5FVOelGNSP+Xl01 vYSZhrndF5nYT1YyE098aQcdS0PHLAevHdMrxX2gWjkkDyQnR1oHL83evffpbMRzl8UU Gvcl9KQelm+ivjFuhzSDWFq32rJZK/IF27KsN4QJI9iZuzYB0s8OZJTHPHQDt4uJV/FA vzQeRKE2YwrUupKy/9Uu9bVLwQQsCukVQZQcsjUF0VxIp56GrOcDC3AZz6bzGEdm/27e GOxsmzCLsC/GeFgTGcjqB8Ir41v/DxkMHNYSEDHE7WTJKYkIgkAI+nMzB/TrGcPZyPfO gFXw== 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:reply-to:mime-version:content-transfer-encoding; bh=GU2dsgWqK/mobsV8NfKx95OZzLHx/CI7H+piHWdepys=; b=jD5l7xxAwSid09g3h83czapo+3FtDU9YSAwZdaXVh12Daa2ematV4G8V6fzcRqsJqi 0bcDG1DCgALEoG6QmIC7k6TwJ8TG/YhiTdK8RIMkFm0gP22PoDgkj4T48d297Z5VTd87 mpaUssjFzYksyDdtjzBwkUH9jAA4rfAXb7Z7jDwh6pA+Af2iR1raCzK1r1ImA6ojkCeA 65b3iLJicBVLfpFC4X1FK5f2YFgmeokcyvo1RUIYxafTiy0B4znQIdwEplTIWNGZVVB9 K1xc9ahJDZgeGPB6CqhLFb5rhnasN7OJ/bM9uy43NKlBTppMqz9y7eW5Z7QA7KgdKdW2 ctUg== X-Gm-Message-State: AOAM533Aqis/4J991wUHKI6lXiQ8uU3r7RQY+SAjwjFIDof6vQLD9mfq wvaMWuyHG5R+Bg8rSRd9d8At2+LnuGLyuw== X-Google-Smtp-Source: ABdhPJxpJZREPRffg8bUKwQVfBiFlY37+FzHZS08A1VCiUXwh2AOu+0SUzxS52Zap0/amVR06tXQ+g== X-Received: by 2002:aa7:c353:: with SMTP id j19mr7618232edr.263.1616133582015; Thu, 18 Mar 2021 22:59:42 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:41 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:54 +0100 Message-Id: <20210319055904.2264501-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/18] avformat/ipmovie: Remove redundant av_packet_unref() 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" When one of these errors happens during ipmovie_read_packet(), an error is returned and the packet is cleaned up generically. And since 712d3ac539f30239b764d8621829dc9dc913da61 the same happens in ipmovie_read_header(). Signed-off-by: Andreas Rheinhardt --- libavformat/ipmovie.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index 3234d591da..26886d9592 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -194,7 +194,6 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, if (avio_read(pb, pkt->data + 8, s->video_chunk_size) != s->video_chunk_size) { - av_packet_unref(pkt); return CHUNK_EOF; } @@ -205,7 +204,6 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, if (avio_read(pb, pkt->data + 8 + s->video_chunk_size, s->decode_map_chunk_size) != s->decode_map_chunk_size) { - av_packet_unref(pkt); return CHUNK_EOF; } } @@ -217,7 +215,6 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, if (avio_read(pb, pkt->data + 8 + s->video_chunk_size + s->decode_map_chunk_size, s->skip_map_chunk_size) != s->skip_map_chunk_size) { - av_packet_unref(pkt); return CHUNK_EOF; } } From patchwork Fri Mar 19 05:58:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26474 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 141A5449D11 for ; Fri, 19 Mar 2021 07:59:57 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C68BD68A64D; Fri, 19 Mar 2021 07:59:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7EE3268A68F for ; Fri, 19 Mar 2021 07:59:43 +0200 (EET) Received: by mail-ej1-f49.google.com with SMTP id b9so7753814ejc.11 for ; Thu, 18 Mar 2021 22:59:43 -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:reply-to :mime-version:content-transfer-encoding; bh=cptgBE2gkG9sEBGuSXg+3of/7b+uOvJBf4lhhrfoOtk=; b=lf1hW4CSkOHxsIgo6IlrRZ+CvUmCAvHxUbXoAxHyj/BM+3ikrhu/JuvVIwLNL3xpOB TOMPobKK9Y5aa1wYMjuYFxdMsHkVFcCIW30FFslLjtqiZPRBol+pJ2c+ENFJ48VQRuzT 5cvWFR7wwWHBjI+P3cuzgL3dSuc8bgSrDGj9vOdl6KiLS2TQ6X64olJuTfxq872o98Qp sq60rFU+OpOO0G06Ip9Lk8s+U9W6gyHUAtwKHXngXUJgMUaM5AbdqLR5UpVcFzNouREq vBwjnBJnUy6Fmy+BqmgCxOnt59L5LffIkKSv16HRvwGSt3L8ozLyUs4smlC1Q+cRMzHi 6V+A== 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:reply-to:mime-version:content-transfer-encoding; bh=cptgBE2gkG9sEBGuSXg+3of/7b+uOvJBf4lhhrfoOtk=; b=Ft3V9IBP+Lewg14BLEHTJoVHvQn1ATQpbjIKV53C5CbCB/KTMuBvFLWCanKEDGKr+t jyiQMbGXpu9OLJuaAtrjHt1jqQA8or5U+IECHnDNAEoEUHWyhrmVUH6xMICc2JJwmQts kVTGVtIwqUWJpnvHShCzvWn+CARVxfwjisBnD2XIAvHC04fhc07UNWlO0GTObrbmBlhH 53NE4lsJwsqiaUGaGRnsdhD3vU/7y5nspjLE6b1L6Zn7WiOkhKXxIv41hzLDA7tm4pAC ZWjGTdBjArJ3q0H0Do54W33zKaL666RFizMQUd2Ve4zDUjCXK9GQlBTkxP6fN6fgkHdH NQSg== X-Gm-Message-State: AOAM531nMRwAf5yz3kH+/e/E/76UiaeBmMzVvDd3aVUOfYcQWhj5+WWv jlxDmblfhwUlqb8mnN1PmkIBMf1kmKq9yQ== X-Google-Smtp-Source: ABdhPJxQDaeSs5SMRgOu6vDyyiBUXykIJYybni1ADITxfuY9Gt/XD+TYL23lHFn6v8wVxc9ph5Ng8A== X-Received: by 2002:a17:906:5e55:: with SMTP id b21mr2452795eju.289.1616133582799; Thu, 18 Mar 2021 22:59:42 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:42 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:55 +0100 Message-Id: <20210319055904.2264501-9-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/18] avformat/ipmovie: Avoid reading packets during read_header 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" They will be discarded anyway because this can only happen for invalid data. This already implies that the pkt won't be used at all when parsing the very first chunk when reading the header, so one can use NULL as argument and remove the av_packet_unref() on error. Signed-off-by: Andreas Rheinhardt --- libavformat/ipmovie.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index 26886d9592..3f40bb8fe8 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -47,6 +47,7 @@ #define CHUNK_SHUTDOWN 0x0004 #define CHUNK_END 0x0005 /* these last types are used internally */ +#define CHUNK_HAVE_PACKET 0xFFFB #define CHUNK_DONE 0xFFFC #define CHUNK_NOMEM 0xFFFD #define CHUNK_EOF 0xFFFE @@ -154,7 +155,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, av_log(s->avf, AV_LOG_TRACE, "sending audio frame with pts %"PRId64" (%d audio frames)\n", pkt->pts, s->audio_frame_count); - chunk_type = CHUNK_VIDEO; + chunk_type = CHUNK_HAVE_PACKET; } else if (s->frame_format) { @@ -230,7 +231,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, s->video_pts += s->frame_pts_inc; - chunk_type = CHUNK_VIDEO; + chunk_type = CHUNK_HAVE_PACKET; } else { @@ -602,10 +603,6 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, /* make a note of where the stream is sitting */ s->next_chunk_offset = avio_tell(pb); - /* dispatch the first of any pending packets */ - if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY)) - chunk_type = load_ipmovie_packet(s, pb, pkt); - return chunk_type; } @@ -658,8 +655,7 @@ static int ipmovie_read_header(AVFormatContext *s) ipmovie->palette[i] = 0xFFU << 24; /* process the first chunk which should be CHUNK_INIT_VIDEO */ - if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO) { - av_packet_unref(&pkt); + if (process_ipmovie_chunk(ipmovie, pb, NULL) != CHUNK_INIT_VIDEO) { return AVERROR_INVALIDDATA; } @@ -708,6 +704,10 @@ static int ipmovie_read_packet(AVFormatContext *s, for (;;) { ret = process_ipmovie_chunk(ipmovie, pb, pkt); + /* dispatch the first of any pending packets */ + if ((ret == CHUNK_VIDEO) || (ret == CHUNK_AUDIO_ONLY)) + ret = load_ipmovie_packet(ipmovie, pb, pkt); + if (ret == CHUNK_BAD) ret = AVERROR_INVALIDDATA; else if (ret == CHUNK_EOF) @@ -716,7 +716,7 @@ static int ipmovie_read_packet(AVFormatContext *s, ret = AVERROR(ENOMEM); else if (ret == CHUNK_END || ret == CHUNK_SHUTDOWN) ret = AVERROR_EOF; - else if (ret == CHUNK_VIDEO) + else if (ret == CHUNK_HAVE_PACKET) ret = 0; else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO) continue; From patchwork Fri Mar 19 05:58:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26476 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 6751F449D11 for ; Fri, 19 Mar 2021 07:59:59 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4FE0368A993; Fri, 19 Mar 2021 07:59:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2FF3368A830 for ; Fri, 19 Mar 2021 07:59:44 +0200 (EET) Received: by mail-ed1-f41.google.com with SMTP id bx7so9378500edb.12 for ; Thu, 18 Mar 2021 22:59:44 -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:reply-to :mime-version:content-transfer-encoding; bh=YK6gsndloiIFdoq4Ot1YAG9nKgORIXp78bGOkzHEJeY=; b=p5tW9tIQk02KwQOaHakvJObZ5Nn8ooghcyEUtT0vqqJ9QEF+RwTPtcgyMkF4IWILZD rVXLOaVfwmO+6G80c9fDeCfuhJxzI6gmbY22nSreo3WV+3Zg90lm3cHKB76XuXTnmPP0 VMmCbDqLxm5bsEG47Vw0K4Cq+MqoI8JM4G9RAWKjxPfcUzUzxrzB6QQHlgiwxlnvQc4w ZJ+mQeiPR2h6OIT+Dv8H3Aa6UY+82Onv2d0ivgTZ35S6AhzGag7slDHzAN/YzuueQf4U 2Y9dwaPKgncpG1eKZc0dpB7gbeGZs846tYnKlCcktr5n/CKBF5lQQjlGKwhu3Nba9HWY z1pQ== 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:reply-to:mime-version:content-transfer-encoding; bh=YK6gsndloiIFdoq4Ot1YAG9nKgORIXp78bGOkzHEJeY=; b=SVE3DwPvHAEkiLJQ4cGWt02t1WoFrvOSIyxDi/h1Mqt2iSlCvk8UjkpcR0hjfy37ux PdHDvGxVuKREjL2xoHfGoMPl+dSPa5+pB5ojtfTRPb8jIxReO6XsyOI5yKVvP7dW8ETn ZXPhWcsXUB0+RfC9GYlWQJ1O24tVGyZ1CRfBEp7Dy7fs0DekFWQemggag8Tls76o4hYT vKHu0hYoqBR7SCWw+k5Lp9gFiYrDuWHbrVNsWUXauuEQIii2Ur7RWodQ2i5rLDv9xrcq HTav9j6Ze0sRsfC3QrHrPzmgFXmkJNQbyQIzchJkEgo6NuTZ/qLDjUJdQ+5IZEMCsz62 R/Yg== X-Gm-Message-State: AOAM531yDYt8QjRAWhK4TOoK5foToB2uiXdXPpninKlzlX07afsBtdz9 iEmCdn7tEFsgs2UZDzIH3Ph7A95aaLgsrA== X-Google-Smtp-Source: ABdhPJw27yfxohkdMny/ChLWaPN5h/e6UXNvqG/QQGxQPO3nIU5Wh7nAF031b38f7kxvR5SaAsOz/A== X-Received: by 2002:a50:fd8b:: with SMTP id o11mr7623481edt.346.1616133583493; Thu, 18 Mar 2021 22:59:43 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:43 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:56 +0100 Message-Id: <20210319055904.2264501-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/18] avformat/ipmovie: Deduplicate parsing video data opcodes 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 --- libavformat/ipmovie.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index 3f40bb8fe8..f1cc30b6c0 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -560,28 +560,11 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, break; case OPCODE_VIDEO_DATA_06: - av_log(s->avf, AV_LOG_TRACE, "set video data format 0x06\n"); - s->frame_format = 0x06; - - /* log position and move on for now */ - s->video_chunk_offset = avio_tell(pb); - s->video_chunk_size = opcode_size; - avio_skip(pb, opcode_size); - break; - case OPCODE_VIDEO_DATA_10: - av_log(s->avf, AV_LOG_TRACE, "set video data format 0x10\n"); - s->frame_format = 0x10; - - /* log position and move on for now */ - s->video_chunk_offset = avio_tell(pb); - s->video_chunk_size = opcode_size; - avio_skip(pb, opcode_size); - break; - case OPCODE_VIDEO_DATA_11: - av_log(s->avf, AV_LOG_TRACE, "set video data format 0x11\n"); - s->frame_format = 0x11; + s->frame_format = opcode_type; + av_log(s->avf, AV_LOG_TRACE, "set video data format 0x%02X\n", + opcode_type); /* log position and move on for now */ s->video_chunk_offset = avio_tell(pb); From patchwork Fri Mar 19 05:58:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26478 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 44CFF44A856 for ; Fri, 19 Mar 2021 08:02:23 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 10FA568A7D8; Fri, 19 Mar 2021 08:00:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EC87168A7FC for ; Fri, 19 Mar 2021 07:59:44 +0200 (EET) Received: by mail-ej1-f41.google.com with SMTP id r12so7746096ejr.5 for ; Thu, 18 Mar 2021 22:59:44 -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:reply-to :mime-version:content-transfer-encoding; bh=zKF6KabzjdRCngkhAJbnABrcjjwFKHBTnAXnUO9VE9k=; b=XjWwSmBp5SN9FzuGnrYQoeVD9KOMzz5BJ69/+6Z+JXGCtAAdoCKDCLLY4ouSjAhoA1 IPLuSlkJMW3L8Xuqd7cITSWjbMxUSPwb9vNaQI7wfJDo2dUydE6B2Vp3TPC78BV/0s5O qU9kJx7Kjc+/Y1v7B7mMJCbw+lGVYvbx9zbNef9FqdmYXeI1SShM7t6OQgXvA8GcTWW4 8Wh2JaZEqC+BrGVHFu3TUZpdKe6efQOoile7IKraGsbxov3WXTCSrf+4R+arH9IZV2cs puv1IrlmU+9t1jH0wnL+/nXd/bNl44jd8MJ1NOae/hVlXlwQqSF5Tyoj5uBeWjqSlolq ro5g== 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:reply-to:mime-version:content-transfer-encoding; bh=zKF6KabzjdRCngkhAJbnABrcjjwFKHBTnAXnUO9VE9k=; b=itssHsr0lUthkNATJemETL254le2KVFT+0CkeswQ1V4qmdTuK42ROEzY1NRpiGFPV8 IpkPrF+SyWG38YHB18rjpRr79ox7h4HlI+mAmpjGpAJTdIpwu9nUdpZmOPFcN+/zqTVx tSsvjgl0opSwb4Q1klfZuIJlCSFYwbox5F9wLhDT6VV+0HixPRdbt3kNJwFgO4LeVfc2 FWXVdxs437N5umGLiCgpy7jHz8GVUIphJTFP45/mGLhIx9dr58EJ4xxqXzq/CJEFPMPn 39k1Ykt6ISrm1EFapNSXOEAnpeAfdyTyTna3cbrmecKz0jnxQnxIgUF84jXhLOVofQWU 8oWg== X-Gm-Message-State: AOAM530DF4ziz3CX4BdWh1A7E9YtJarpKr6utbVW5ti/n9K2uXFgzjod bPu6h7zphOV7TUKHriZE6suDV3oqIsFYOQ== X-Google-Smtp-Source: ABdhPJxTkX+hDLg59cLL8Lb3qAf9WDuAuq/DgWF6bAp5zAMmBNk+JLoxz4OsnmP2ABNHOgsC0m49MQ== X-Received: by 2002:a17:906:7fc4:: with SMTP id r4mr2404306ejs.81.1616133584209; Thu, 18 Mar 2021 22:59:44 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:43 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:57 +0100 Message-Id: <20210319055904.2264501-11-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/18] avformat/ipmovie: Fix indentation 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 --- libavformat/ipmovie.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index f1cc30b6c0..a71575235f 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -686,27 +686,27 @@ static int ipmovie_read_packet(AVFormatContext *s, int ret; for (;;) { - ret = process_ipmovie_chunk(ipmovie, pb, pkt); + ret = process_ipmovie_chunk(ipmovie, pb, pkt); /* dispatch the first of any pending packets */ if ((ret == CHUNK_VIDEO) || (ret == CHUNK_AUDIO_ONLY)) ret = load_ipmovie_packet(ipmovie, pb, pkt); - if (ret == CHUNK_BAD) - ret = AVERROR_INVALIDDATA; - else if (ret == CHUNK_EOF) - ret = AVERROR(EIO); - else if (ret == CHUNK_NOMEM) - ret = AVERROR(ENOMEM); - else if (ret == CHUNK_END || ret == CHUNK_SHUTDOWN) - ret = AVERROR_EOF; - else if (ret == CHUNK_HAVE_PACKET) - ret = 0; - else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO) - continue; - else - continue; - - return ret; + if (ret == CHUNK_BAD) + ret = AVERROR_INVALIDDATA; + else if (ret == CHUNK_EOF) + ret = AVERROR(EIO); + else if (ret == CHUNK_NOMEM) + ret = AVERROR(ENOMEM); + else if (ret == CHUNK_END || ret == CHUNK_SHUTDOWN) + ret = AVERROR_EOF; + else if (ret == CHUNK_HAVE_PACKET) + ret = 0; + else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO) + continue; + else + continue; + + return ret; } } From patchwork Fri Mar 19 05:58:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26479 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 89B5C44A856 for ; Fri, 19 Mar 2021 08:02:34 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0249468A9D5; Fri, 19 Mar 2021 08:00:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 991F868A774 for ; Fri, 19 Mar 2021 07:59:45 +0200 (EET) Received: by mail-ed1-f43.google.com with SMTP id h10so9365323edt.13 for ; Thu, 18 Mar 2021 22:59:45 -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:reply-to :mime-version:content-transfer-encoding; bh=2ryIm7BmQEPDZhVPqii19HO5Qo1WsHndl1qDjC1YaME=; b=C7qAe0C4RbpMMPSAS2i3z6Wz5M865e+DG/f5Ub3A+rV8+X9xVMLe1N0Un+xl5oupXU YggvScGrsV3ob99AvPMCPyS2ItFeDY9e3bCahbu09Vmy4Wda/wnERDXmD4d0lOdCJ2b0 6CoPgs8h46nQJElhRuaiS37n/UCMgM73uHIM6wPDFaeaDIlHrvVGXPhHHL8YF8PRskU/ UkU6FEzKaQQcgOTkTPX4mhxKNlFALn2gq8MXnPBBft8XFfM4Gtemd/kJL51vZsGP9Ot4 jbxsh7N7JZEp3PUcg7JzvKUl5WQkYS1UaTnd3mwc35zXoK9z2sQwtpwM+Jx1V3tlgOyp M5rg== 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:reply-to:mime-version:content-transfer-encoding; bh=2ryIm7BmQEPDZhVPqii19HO5Qo1WsHndl1qDjC1YaME=; b=D4Q6eGNTs6VSHZ+h2SwmyWyedLTiohic/IRnCyPQXDvoojjiHiQYVE+LkA0Gms80pS g5/9W27/K72FHNK6PuB+R5IezeMOcN2nWKcDyh6UqqXaNFZIBK2UESqyT2wdaEfK7YTA CLkrT2Gc2JeR5lSJiCMNc4vrtUDrOjDmcnM94M6NsnAitYOH+idyX05jcOAaTC0baAcw LZDy61qRp8QcimXOBtG8E7AVxODfcRSnlOMzOnWo8wqZ8lpvyUWZKdV9z4YbfMsH9Rfk ooITG+xclVzpI3j9fkDDf7JssEVgLjanjcGtQhjq0NvYQNHApR13gayTaNZF6atVGgKT eEEw== X-Gm-Message-State: AOAM531XauMmyIa0Z+p4j1shNHgmfqUeOw5wNmJdRW5Lj2xL9/AnAh4V x/nXa53T0+QDwYNnNDbdKJDP2zRxVRVn9w== X-Google-Smtp-Source: ABdhPJzZ8TXX/976rrIyxX3L9pLKmd/y9oPwKzzl+FxoE2WIexP4aSxQ/7ublSnX3LHcNJJT3eUnCQ== X-Received: by 2002:a05:6402:68e:: with SMTP id f14mr7623584edy.169.1616133584941; Thu, 18 Mar 2021 22:59:44 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:44 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:58 +0100 Message-Id: <20210319055904.2264501-12-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/18] avformat/ipmovie: Remove redundant initializations 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" The demuxer's context has already been zeroed generically. Signed-off-by: Andreas Rheinhardt --- libavformat/ipmovie.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index a71575235f..048e748cfd 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -623,13 +623,6 @@ static int ipmovie_read_header(AVFormatContext *s) if (avio_feof(pb)) return AVERROR_EOF; } - /* initialize private context members */ - ipmovie->video_pts = ipmovie->audio_frame_count = 0; - ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset = - ipmovie->decode_map_chunk_offset = ipmovie->skip_map_chunk_offset = 0; - ipmovie->decode_map_chunk_size = ipmovie->video_chunk_size = - ipmovie->skip_map_chunk_size = 0; - ipmovie->send_buffer = ipmovie->frame_format = 0; /* on the first read, this will position the stream at the first chunk */ ipmovie->next_chunk_offset = avio_tell(pb) + 4; From patchwork Fri Mar 19 05:58:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26469 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 D5AB8449D11 for ; Fri, 19 Mar 2021 07:59:50 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A334568A867; Fri, 19 Mar 2021 07:59:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6ADDB68A700 for ; Fri, 19 Mar 2021 07:59:46 +0200 (EET) Received: by mail-ej1-f53.google.com with SMTP id jy13so7727416ejc.2 for ; Thu, 18 Mar 2021 22:59:46 -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:reply-to :mime-version:content-transfer-encoding; bh=x4HlZJmSH8lYhfM/OEQWBYRYHBYKIRQPo6JrgssNqOM=; b=HNvO82aIen5eXs8wYJ4xUJzrWZYTELIlfVo1DEGBLARM7yytk6sI7K6f6xdanrdkUX dH5z7Pf5Kx9p/1KXIIq3qpveys4rMiV2REFFD8LPCS1umQphjQJEcJ5O041/xMAMXG2h U60LviPH/hJt9GXIH0WOtiL/aNkDyM4ii6HZaqMcUgPTZeHlfU9l+/5SWtXSqx8hWJiw CkB55WsB1NQCYm8RV+QOQUBZgBuxhWggd5e2jvXpOJZVscUrmp5AX2fQiqUWt3VQ/MlY G6NvS4DwfXJTwHAQdsFaJt1CduN8/cteCoz5fqrG4fZ+gXxEog5b2RoY33/RInnKcLL0 qvUw== 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:reply-to:mime-version:content-transfer-encoding; bh=x4HlZJmSH8lYhfM/OEQWBYRYHBYKIRQPo6JrgssNqOM=; b=Ft1yESQhN4gaUzGrLmV0kSaeC7PgtObCmUXuPjq6Z7ShrwaXTPd8HaPEWDYC3K0bT4 jucTFOUo1FXnqONe1j8Ry5qKhmdu8qO0c778G4qlwRaRcw6658vMHYoexED/S1OYy64a Jh1XaCR2umS9jyoA6bzOEzbiVlM4mWTmxTjNV76gjUU61qOuCBJLGo5BA5m8bSgsgeLN auf4kG+sOGpoO/A/7PXAp9lBSwmA5FcHy0VjJsma0BJq65tXiAwPX57Xl/O+b07KhV4I PDZ7+SE0uChaefWpa+84u/SXCxuc08itXK9SIe5tcgC9wLMHM+OS/6YCV1jEDmOlcom6 iPDA== X-Gm-Message-State: AOAM531Jaq5+MNtqNbtYRurWHQf1tUmcGVjrLwOuWxiyJLoJy+fwUHy0 iOu8qpRVf7Tt296V0K05rKwnfcVJ/ncYJQ== X-Google-Smtp-Source: ABdhPJyGzLyS9S1UnZNzYXY/5FRWIZeFfpVDFYaSFsR1Rn1dzg7ODUf8/ASIT0aGlQFWFVNFIXol6Q== X-Received: by 2002:a17:906:14d0:: with SMTP id y16mr2503815ejc.242.1616133585732; Thu, 18 Mar 2021 22:59:45 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:45 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:58:59 +0100 Message-Id: <20210319055904.2264501-13-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/18] avformat/ipmovie: Avoid stack packet 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" Replace it in ipmovie_read_header() by AVFormatInternal.parse_pkt which is unused when reading the header. Signed-off-by: Andreas Rheinhardt --- libavformat/ipmovie.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index 048e748cfd..9118d7d807 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -608,7 +608,6 @@ static int ipmovie_read_header(AVFormatContext *s) { IPMVEContext *ipmovie = s->priv_data; AVIOContext *pb = s->pb; - AVPacket pkt; AVStream *st; unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE]; int chunk_type, i; @@ -645,8 +644,7 @@ static int ipmovie_read_header(AVFormatContext *s) if (chunk_type == CHUNK_VIDEO) ipmovie->audio_type = AV_CODEC_ID_NONE; /* no audio */ - else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO) { - av_packet_unref(&pkt); + else if (process_ipmovie_chunk(ipmovie, pb, s->internal->parse_pkt) != CHUNK_INIT_AUDIO) { return AVERROR_INVALIDDATA; } From patchwork Fri Mar 19 05:59:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26471 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 DC3B4449D11 for ; Fri, 19 Mar 2021 07:59:53 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CDB8868A830; Fri, 19 Mar 2021 07:59:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 591F968A753 for ; Fri, 19 Mar 2021 07:59:47 +0200 (EET) Received: by mail-ed1-f44.google.com with SMTP id w18so9452675edc.0 for ; Thu, 18 Mar 2021 22:59:47 -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:reply-to :mime-version:content-transfer-encoding; bh=/Rx92WlP2D7QQQwXVKkdwjpkUnmmgC7CoI1u/zu1V7o=; b=PnqT4qzIXxDh0J8eaT11S3Nj6lvqIVja3/zF9Yo04003Sf7umKMbEznDopx+M7b4fp gahK7LyxDoU1YLXHHfvd8OkcrKMWpRX/bLApt0t9887MKUu+xx7VXo77C+7iKWZfoSzo e8qymYCQesrekrLp6dcXrALOfUepBDYF3/t2qoPmtV9eIsKNRYHNQgFIIVdmSqPjxyxz qi6o0OHMSIt0aIwDTIzzWYGG+Fb9LNfvXYE6a6n9NnhMzOb/JyGgCAOE1gA1khO9keWg CdvPUUNFLhjhL+nVlsuAyyMYNLFxr5WOqQhzDi93hK8ffDYzyvjCody8SslKDPoQgiPk YE0Q== 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:reply-to:mime-version:content-transfer-encoding; bh=/Rx92WlP2D7QQQwXVKkdwjpkUnmmgC7CoI1u/zu1V7o=; b=nhon6THIONmoqEQU3ZEpkBBDdTA3Bd3fQJudQGFT6i0At+f5rJMOpGSY1mzby5xUY4 +G+eH0qc37zhlBJA9VGcvJBVEANeQpRfJ4TyYfOj+2+RbHQzXAt7IAC/2qX32ngRYsoG ApUVPoIFmagtbxkL1OhKyzHsg2We+GgRlWBdOIY+IpNQii/P22r0O5FJMID3aByWvyaV nqN3nl7disj26ZpsromHSjjnn3EpQL4ulLxmtvrJFk23Q4RlK0lo9u0SfcgMQTMbbWVB CHVsUO4WiJgfqYePwXzK7ABdPc9qlrSdtdKiBcMltmRSn3Jds/WdOUYvPWAyUCsHSd61 RL0A== X-Gm-Message-State: AOAM533ZOQmeWWedQ+G6jUxrKMBDPrF3DxnHL0EG3jK0ezpXMb+ku+t/ jjaY4kEGqpF+e3+LrMRBx/RFTtl9ubMpWw== X-Google-Smtp-Source: ABdhPJymkXFI+x8cwmbYP/NCvzCfeUWDh1vS6uaYpkUEW0Unr4YLODj02Q1fY1yPobqiIznvrSDQkQ== X-Received: by 2002:a05:6402:95b:: with SMTP id h27mr7780175edz.93.1616133586556; Thu, 18 Mar 2021 22:59:46 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:46 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:59:00 +0100 Message-Id: <20210319055904.2264501-14-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/18] avformat/webpenc: Use init instead of write_header function 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" webp_write_header() didn't write anything. Signed-off-by: Andreas Rheinhardt --- libavformat/webpenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index 9fb472257d..8c32ff66df 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -33,7 +33,7 @@ typedef struct WebpContext{ int using_webp_anim_encoder; } WebpContext; -static int webp_write_header(AVFormatContext *s) +static int webp_init(AVFormatContext *s) { AVStream *st; @@ -210,7 +210,7 @@ AVOutputFormat ff_webp_muxer = { .extensions = "webp", .priv_data_size = sizeof(WebpContext), .video_codec = AV_CODEC_ID_WEBP, - .write_header = webp_write_header, + .init = webp_init, .write_packet = webp_write_packet, .write_trailer = webp_write_trailer, .priv_class = &webp_muxer_class, From patchwork Fri Mar 19 05:59:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26473 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 C3B1C449D11 for ; Fri, 19 Mar 2021 07:59:55 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 986F168A8F8; Fri, 19 Mar 2021 07:59:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0135468A755 for ; Fri, 19 Mar 2021 07:59:47 +0200 (EET) Received: by mail-ed1-f43.google.com with SMTP id h13so9409268eds.5 for ; Thu, 18 Mar 2021 22:59:47 -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:reply-to :mime-version:content-transfer-encoding; bh=yCooxezW47pca0PySozvhLp24UZefqUwoLPDQ1I0t2o=; b=r3JPasv+tN5qXay2DJn70rDOe2UcJ0YvBL0AySTzCUEO+8AFeq7AVeAErUDfjrbN3o 0OCM3vXmHjklY46K5QjhNfwM2nTq4CgtLj18oykq5Zr8jUaoYvhwdHMfVlYrwICbvRqt dW7SIU/J3y2j8EsJrGCEl1wD8kRKZmDxZbVvtZlwog1YDDJf382/Ha2z7gYEpyDPb8Pf DbT9DC+j2U1vEh4HXAQzBdle/PYr0JJ5O627WilIfy3ivjo+K3epNNQn7iWBLhd3r6Ed gwxZPkyWcLrkj7QqXB9wk3C7EvuwKz1XoOFMAwjqyInQKaGDldLaC+9jSceo4fY/RV6b DSJg== 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:reply-to:mime-version:content-transfer-encoding; bh=yCooxezW47pca0PySozvhLp24UZefqUwoLPDQ1I0t2o=; b=dqPoMRTX4FrSZTjQLFTfnuC5hosUTBXX95m++f5wIrgfcBk9jM8gufFZa0rfn40no3 60i9tFyc68V0wlreLMufrNKdOa7RhZ8wwjoLMEaA09j4OA33OjchMk549qTeplx6wvI5 0DpE5dE+TmWB3aVSZPczaKKZ7vgsGDvF31mVYwdJLenNMoE77VM0XjwFRxfCrNYKpAT6 iV1fQYyyb7Bph9q7uDN/Idn0fhrM1OTaWp2FDtV2+iHvuxHwGJmAipaKt5Z9gTkRT8nC ETF7aWXV32QIQXOAUzOIsXpIgK9hNUKIyzmvQRaWQZENCR08WirFK36fQIyFXGH1gZ6J CM9w== X-Gm-Message-State: AOAM531l6HlP9fwpXSAxxO4Vn56G/WrU14eFO5R+cp/NNw9FK1OnkU02 h/MSAtSp2bw7B8LIrjFxGozJ1pN9QBuCRQ== X-Google-Smtp-Source: ABdhPJzvjRHIxiSI+ogas0EQPa8R+AzcpjxK+tNmoHkRtslbw9hhU9rHlIMLTEsbEg7q0u9pgTH4AQ== X-Received: by 2002:a05:6402:42d1:: with SMTP id i17mr7424761edc.131.1616133587347; Thu, 18 Mar 2021 22:59:47 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:46 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:59:01 +0100 Message-Id: <20210319055904.2264501-15-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/18] avformat/webpenc: Fix memleak when using invalid 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The WebP muxer uses sometimes caches a packet it receives to write it later; yet if a cached packet is too small (so small as to be invalid), it is cached, but not written and not unreferenced. Such a packet leaks, either by being overwritten by the next frame or because it is never unreferenced at all. Fix this by not caching unusable packets at all; and error out on invalid packets. Signed-off-by: Andreas Rheinhardt --- libavformat/webpenc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index 8c32ff66df..e3b12aeed2 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -53,24 +53,22 @@ static int webp_init(AVFormatContext *s) static int is_animated_webp_packet(AVPacket *pkt) { - if (pkt->size) { int skip = 0; unsigned flags = 0; if (pkt->size < 4) - return 0; + return AVERROR_INVALIDDATA; if (AV_RL32(pkt->data) == AV_RL32("RIFF")) skip = 12; - + // Safe to do this as a valid WebP bitstream is >=30 bytes. if (pkt->size < skip + 4) - return 0; + return AVERROR_INVALIDDATA; if (AV_RL32(pkt->data + skip) == AV_RL32("VP8X")) { flags |= pkt->data[skip + 4 + 4]; } if (flags & 2) // ANIMATION_FLAG is on return 1; - } return 0; } @@ -84,13 +82,9 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts) unsigned flags = 0; int vp8x = 0; - if (w->last_pkt.size < 4) - return 0; if (AV_RL32(w->last_pkt.data) == AV_RL32("RIFF")) skip = 12; - if (w->last_pkt.size < skip + 4) - return 0; // Safe to do this as a valid WebP bitstream is >=30 bytes. if (AV_RL32(w->last_pkt.data + skip) == AV_RL32("VP8X")) { flags |= w->last_pkt.data[skip + 4 + 4]; vp8x = 1; @@ -149,7 +143,14 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts) static int webp_write_packet(AVFormatContext *s, AVPacket *pkt) { WebpContext *w = s->priv_data; - w->using_webp_anim_encoder |= is_animated_webp_packet(pkt); + int ret; + + if (!pkt->size) + return 0; + ret = is_animated_webp_packet(pkt); + if (ret < 0) + return ret; + w->using_webp_anim_encoder |= ret; if (w->using_webp_anim_encoder) { avio_write(s->pb, pkt->data, pkt->size); From patchwork Fri Mar 19 05:59:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26475 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 792D8449D11 for ; Fri, 19 Mar 2021 07:59:58 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3BE2968A980; Fri, 19 Mar 2021 07:59:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0299A68A82A for ; Fri, 19 Mar 2021 07:59:48 +0200 (EET) Received: by mail-ed1-f45.google.com with SMTP id e7so9372236edu.10 for ; Thu, 18 Mar 2021 22:59:48 -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:reply-to :mime-version:content-transfer-encoding; bh=kvSTtde8p7lwqe3B7PK6DD/y0ib8061qycohvP4WcfI=; b=VyzHiVCZRsxYixRpRyqmZjKAHbAQprG/hyMzDTT4Gyne8WF4V7+jyy/hbGE4WmS5A7 WvNqvQ/H8m96bKbXEnXN9Ykc2XVEO1/VNx8YvpfuPb0rUJbTW2hPxMkRM2Ezpxz6RtJj NMsfYPTrgFN1nWSO+tnLEDogOHsKAOzFSy3ZJzGMCInYFqdgMO/UTIazot3ZtyNhuEwn IBWHMNvOlfzQcJ1ig0PzdAtOTROJHg3YydyufgbOKzY75ly4PdiY6oODDlxsSCJiekuB y0dCL8wHQ6/9wnofNzxBN9CL1FSmtEwEuI9mDXrzi6MkwkuTbu8LTvVLpZFjJhA1YBca W1MQ== 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:reply-to:mime-version:content-transfer-encoding; bh=kvSTtde8p7lwqe3B7PK6DD/y0ib8061qycohvP4WcfI=; b=jNldMu0J/kqS4hk9lY4Iyi17ecDhhYk95qYxn1LUz1nFrymqKCemlZah0P2AJjZPp5 sxlSFIkWYq6YM+QTWn91DrWCbTSmIBluZyD34KvstgKrBvBwvoukjnolm9qiVyTpbXrM 0Hxg7K9ErVTtDZ4yQVEFHflqjwW9ZMkjJdjOoh8VRr+S/iKZ6T+2deUR/yTH1uHiKUMk BEDYod2WjVyXrnnVIlk21O/ghe/t9eg0LT4DID3vGHbqjydTEh/vZju8FbXrhJHI3gBt 5VXaty2yzGNFuwUfSxX09eUQA0R5yWKQs75S0M5P07jLIRA7VshswiCqylz13vV+/jIR MN0Q== X-Gm-Message-State: AOAM533Rvf2PQkOqx3KFk6ZJvMPv3htbsv2+NNrUa1E/fBlYkvWtQM15 1RvjNGoRHqLaBcjGb5JrSGkTua/P9azSeQ== X-Google-Smtp-Source: ABdhPJz520bnNoVhZdm/i7yfpbJYGlDDM44rmwbqfosr7r6BoVx55o5yMrgRh/A01V0jPjEU1KJJIQ== X-Received: by 2002:a05:6402:34c4:: with SMTP id w4mr7946966edc.367.1616133588184; Thu, 18 Mar 2021 22:59:48 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:47 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:59:02 +0100 Message-Id: <20210319055904.2264501-16-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/18] avformat/webpenc: Reindentation 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 --- libavformat/webpenc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index e3b12aeed2..d5edf89289 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -53,22 +53,22 @@ static int webp_init(AVFormatContext *s) static int is_animated_webp_packet(AVPacket *pkt) { - int skip = 0; - unsigned flags = 0; + int skip = 0; + unsigned flags = 0; - if (pkt->size < 4) + if (pkt->size < 4) return AVERROR_INVALIDDATA; - if (AV_RL32(pkt->data) == AV_RL32("RIFF")) - skip = 12; + if (AV_RL32(pkt->data) == AV_RL32("RIFF")) + skip = 12; // Safe to do this as a valid WebP bitstream is >=30 bytes. - if (pkt->size < skip + 4) + if (pkt->size < skip + 4) return AVERROR_INVALIDDATA; - if (AV_RL32(pkt->data + skip) == AV_RL32("VP8X")) { - flags |= pkt->data[skip + 4 + 4]; - } + if (AV_RL32(pkt->data + skip) == AV_RL32("VP8X")) { + flags |= pkt->data[skip + 4 + 4]; + } - if (flags & 2) // ANIMATION_FLAG is on - return 1; + if (flags & 2) // ANIMATION_FLAG is on + return 1; return 0; } From patchwork Fri Mar 19 05:59:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26477 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 C2EEC44A856 for ; Fri, 19 Mar 2021 08:02:11 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 34AF568A99E; Fri, 19 Mar 2021 08:00:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D55068A830 for ; Fri, 19 Mar 2021 07:59:49 +0200 (EET) Received: by mail-ed1-f41.google.com with SMTP id l18so1193714edc.9 for ; Thu, 18 Mar 2021 22:59:49 -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:reply-to :mime-version:content-transfer-encoding; bh=AjAoTCURib04lbD0IcDey1Q4VBKfKVm1Wj8cGpFuVaM=; b=eMp4P427nTi3b0bpxHxm15NCzApm6/ObHMtVX+riHWHh9paqXMWdzVW0BUPRy6Fzlv V+onudQiQ5oqNn/fGWmG6MmRkFmOfWER2QnDwizKH20Z5QFrPUta5OKl2vnLxhB0K2K1 6uzd+mJ+CGZolGligg7obpHHCF+abfgzWaCu32HXWtv+HrqTFdeUETw9gDMTGgfzyBQd Cv/dHYcqzyVrcSBun87BJiR7NvfhRxIorsPinC3NmHI6COjACj68yoeK0Y4qrlOLyfVB RXVcspfSZuCdnANNektLuebwVoe/dc/O+6RF9FcbHx7aTFEWtO1XqxLLygXZYfA3c2KL VDBA== 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:reply-to:mime-version:content-transfer-encoding; bh=AjAoTCURib04lbD0IcDey1Q4VBKfKVm1Wj8cGpFuVaM=; b=BcS0EEtZydsimBrPeBERWCjaBJ9WC3nJaE4U72P6RF4C6hOyHtWULqE1JNTl6X1i+O K1fXRo+SBXDo4t3f7LvQhmIUMJ34EMDXIzJHYS+eKSfdgW3PsJ2Fskp30kmzCC3Zwcko oifF7Mv6iceRhydxaLwPPpbE5nrq7FVbgKdfqARUr7oo5+5NnB4+VB2l3081nGfQNyU2 085ttcls1zPBwNHg3IzgBbwfjUwR9nDNtgCxKDB3TG7ICEE4dlPLQzDQrAzPDeOobQPm hwSvrVPeZcT5sHaL2E8/sUJBWHwavG4Q2r6w9NBPU/G6fqan0bgZqWeBlwZ3i4BpX82x R9Gg== X-Gm-Message-State: AOAM532KEhqBp+OTDwQHsrgJ5hKu3lqIZcs8Uc5a6ge3elKP/4JfHOVf aqebVCe9DCeAwY5ZzAt4EO5xPJ9Jj1AYDg== X-Google-Smtp-Source: ABdhPJwaUPSzxjRAxfEhzNpmMiDNB6ScnNrq4f+1bu5JzVOiG+amCnlMtnPFV9mqEtub3tqlLUCNAA== X-Received: by 2002:a05:6402:35c8:: with SMTP id z8mr7703863edc.341.1616133588923; Thu, 18 Mar 2021 22:59:48 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc08960.dynamic.kabel-deutschland.de. [188.192.137.96]) by smtp.gmail.com with ESMTPSA id x17sm3109344ejd.68.2021.03.18.22.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:59:48 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 06:59:03 +0100 Message-Id: <20210319055904.2264501-17-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> References: <20210319055904.2264501-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/18] avformat/webpenc: Fix memleak when trailer is never written 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" When the trailer is never written (or when a stream switches from non-animation mode to animation mode mid-stream), a cached packet (if existing) would leak. Fix this by adding a deinit function. Signed-off-by: Andreas Rheinhardt --- AVFormatInternal.parse_pkt is completely unused for muxers, so it can be reused in this muxer and this deinit function removed again. See https://github.com/mkver/FFmpeg/commits/packet_reuse for more. libavformat/webpenc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index d5edf89289..ed8325c02d 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -191,6 +191,13 @@ static int webp_write_trailer(AVFormatContext *s) return 0; } +static void webp_deinit(AVFormatContext *s) +{ + WebpContext *w = s->priv_data; + + av_packet_unref(&w->last_pkt); +} + #define OFFSET(x) offsetof(WebpContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { @@ -214,6 +221,7 @@ AVOutputFormat ff_webp_muxer = { .init = webp_init, .write_packet = webp_write_packet, .write_trailer = webp_write_trailer, + .deinit = webp_deinit, .priv_class = &webp_muxer_class, .flags = AVFMT_VARIABLE_FPS, };