From patchwork Wed Aug 24 08:43:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 37441 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp2371448pzh; Wed, 24 Aug 2022 01:45:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR5vI7uwNCMYpOMGecyEtgHb1nnUKW1UTTWpqe9ZRzyVhM7oAD57aQbIF65HzEYLO8YdDrRf X-Received: by 2002:a17:906:491:b0:73d:c060:7cef with SMTP id f17-20020a170906049100b0073dc0607cefmr581503eja.111.1661330703292; Wed, 24 Aug 2022 01:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661330703; cv=none; d=google.com; s=arc-20160816; b=sEXjyoCa0Hphagp2Jq74gQat8DxUFQNLe0XoZdIJdlJnZG8yTudnZG/epTRO5Cfk+T E5lXrzIG1OhBY+hh7uPqxG8phw+zcgthk41WkCvWUkPjWntgmbK2iopNyJpknqfJp3+A zqchRX5vE7e0QfSJk/erJmhLoPAUp/QREvEulp7v1sBjxgSpPpVwfn+IH6C30aKuEdp/ p8UYN4NknedC2mnMCQjEn3mrnpQAT6lWVDoOzYQHA/bB+C17v5a7+B9OrnBcA8d89Q4j a9Gi8LpFNZog+4fhkXEUYWBWdfMHY2/aE9+xzf5BC2sEHqJORhL3XbIpRYnCC4or/svJ yzmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=6FTIDOZwxezvEcjVFk3K+2x5XQs/3+i6avuR9BOal2Y=; b=MVa0qyNdrFy9QFrzatIujNKHbWpgrsaB/QpVcFGdGf1FLQCooIPLtl8dOZxGQKPXsz El7fBCStAnLaEKQz+9htXhYH51ON53b0BExpy6DlXkOUxoKyeAK1dGosZfLMx4ah0RKT oNz/QajjkMBQW3j4MN0XTrezIcfg0YD+bnmCBVAYjZprC5E5uvoXpugMMhqU8flFpTeg bIbS7KqIx68IRl8eHxu1lAtrnYxCzUyz30YcTeRtxQHFaMFhubjs/RlZ4m+rM+D1Adpq EuuKY3WUzbg4phuEIDxfMAA8jXKep5NkTo8DK/upnkGHP/R/malRY9dDeG4wP/Uxf6rl ALiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id nb30-20020a1709071c9e00b00730a5a456e9si1939893ejc.758.2022.08.24.01.45.02; Wed, 24 Aug 2022 01:45:03 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3607568BA39; Wed, 24 Aug 2022 11:43:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1D8E968B823 for ; Wed, 24 Aug 2022 11:43:50 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 45FE8240D24 for ; Wed, 24 Aug 2022 10:43:48 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 23tbr5ZpBw6W for ; Wed, 24 Aug 2022 10:43:47 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E0FA9240D27 for ; Wed, 24 Aug 2022 10:43:41 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id A33973A2257; Wed, 24 Aug 2022 10:43:35 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Aug 2022 10:43:12 +0200 Message-Id: <20220824084318.333-12-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220824084318.333-1-anton@khirnov.net> References: <20220824084318.333-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/18] lavf/dv: make returning the video packet optional X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qD6Rp5Kja2Z2 The mov demuxer only returns DV audio, video packets are discarded. It first reads the data to be parsed into a packet. Then both this packet and the pointer to its data are passed together to avpriv_dv_produce_packet(), which parses the data and partially overwrites the packet. This is confusing and potentially dangerous, so just pass NULL and avoid pointless packet modification. --- libavformat/dv.c | 19 +++++++++++-------- libavformat/mov.c | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libavformat/dv.c b/libavformat/dv.c index 303cecf9bb..f88fe62349 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -430,14 +430,17 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, } } - /* Now it's time to return video packet */ - size = dv_extract_video_info(c, buf); - pkt->data = buf; - pkt->pos = pos; - pkt->size = size; - pkt->flags |= AV_PKT_FLAG_KEY; - pkt->stream_index = c->vst->index; - pkt->pts = c->frames; + /* return the video packet, if the caller wants it */ + if (pkt) { + size = dv_extract_video_info(c, buf); + + pkt->data = buf; + pkt->pos = pos; + pkt->size = size; + pkt->flags |= AV_PKT_FLAG_KEY; + pkt->stream_index = c->vst->index; + pkt->pts = c->frames; + } c->frames++; diff --git a/libavformat/mov.c b/libavformat/mov.c index 1d8c5b2904..a2b429e52f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8768,7 +8768,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } #if CONFIG_DV_DEMUXER if (mov->dv_demux && sc->dv_audio_container) { - ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); + ret = avpriv_dv_produce_packet(mov->dv_demux, NULL, pkt->data, pkt->size, pkt->pos); av_packet_unref(pkt); if (ret < 0) return ret;