From patchwork Wed Aug 24 08:43:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 37444 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp2371648pzh; Wed, 24 Aug 2022 01:45:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR7doMimMymnn2eFhcjcYglk1GcB6YYSniokvRZPRSZCW905ekAD1quBVv/q0Ma37WsBTEZw X-Received: by 2002:a17:906:478f:b0:73d:7919:b23 with SMTP id cw15-20020a170906478f00b0073d79190b23mr2108199ejc.690.1661330730918; Wed, 24 Aug 2022 01:45:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661330730; cv=none; d=google.com; s=arc-20160816; b=KE/MI2r2PLqQrgV8SGt6XVaou2Klc27rRtqcVqJluY3N8faMrxaYNb8fmDcUkBYYJG BwJ4m87/XBDa19kGlo4X9oTPTkvCRr1x+SyAZ5byHkqso0P3vnJPhelgfaIIlh3PjL1N wODKYcj/c2c5BRcgcuPLN2gIgeFqgd2PZXF4XurfjHBru2+RUzINaIyxf588FdZw5SmD sfpVbKAvSBQR1q1STehEMwxg9476DFJNuXduW7rh46qh2GXJmLHk9OAHNGva9n/tkj4b EeeHl9YpQsIbNwxrJFwgntX0Xf5/quV1z6cwvnsXsQ4Xb7rId2oatG+w8tHYIV8dBWh4 20Kg== 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=NSOYgRsfrJS8BLyRx2D80nPf8wPICyWk37wKbbFO/mE=; b=nKC2Z9J1Tp08PRB9RHhjx/GxupXyyISzRHPrBFZx50iLpPK7KH4S7uYVGvFDhD0u86 SsEW6IplTB1cW6KRRagC14VmPQUUYavaVoxIVtUbUNrlioulZEQQ4qnjcls0f5E9c0AD PPojMIv0H9l4wmrZbxxP3UNr5lVmBMHI/u0Og2yd1+8Rhmaol1q5+oO1ATT+wflHUHNK HFVSIJSidGK0lyeaQOohmqdk9g2xQFBXjAF5jtoKY58B35irGJgQaCvlb2yas3oxdT1V uUpRdj1rzexbbwuMvlraXjZbIzZWn2dJ+3k3NdjxOEZYjtgJnh6guapVJXGY6FfnbcBj J8yg== 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 l14-20020a170906794e00b0073d6f592b12si2357610ejo.485.2022.08.24.01.45.30; Wed, 24 Aug 2022 01:45:30 -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 7D1D568BA0C; Wed, 24 Aug 2022 11:44:01 +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 2577B68B9EB for ; Wed, 24 Aug 2022 11:43:50 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id C2DC2240D26 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 J3E4reOjV7kF for ; Wed, 24 Aug 2022 10:43:48 +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 DA881240D25 for ; Wed, 24 Aug 2022 10:43:41 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id AC3AD3A25F7; Wed, 24 Aug 2022 10:43:35 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Aug 2022 10:43:14 +0200 Message-Id: <20220824084318.333-14-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 14/18] lavf/dv: forward errors from avformat_new_stream() 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: PyG2Z7EWBxwv --- libavformat/dv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavformat/dv.c b/libavformat/dv.c index c888111789..24d6897da5 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -268,11 +268,13 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) ach = 2; /* Dynamic handling of the audio streams in DV */ + c->ach = 0; for (i = 0; i < ach; i++) { if (!c->ast[i]) { c->ast[i] = avformat_new_stream(c->fctx, NULL); if (!c->ast[i]) - break; + return AVERROR(ENOMEM); + avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, c->sys->time_base.den); c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; c->ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; @@ -290,7 +292,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) c->ast[i]->codecpar->bit_rate = 2 * dv_audio_frequency[freq] * 16; c->ast[i]->start_time = 0; } - c->ach = i; + c->ach = ach; return (c->sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */ } @@ -410,6 +412,9 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, /* Queueing audio packet */ /* FIXME: in case of no audio/bad audio we have to do something */ size = dv_extract_audio_info(c, buf); + if (size < 0) + return size; + for (i = 0; i < c->ach; i++) { c->audio_pkt[i].pos = pos; c->audio_pkt[i].size = size;