From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 18CD940DC0 for ; Sat, 1 Jan 2022 01:12:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A7F7A68A7FD; Sat, 1 Jan 2022 03:12:02 +0200 (EET) Received: from mail.personalprojects.net (mail.personalprojects.net [51.79.67.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A7D6689BEA for ; Sat, 1 Jan 2022 03:11:56 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=personalprojects.net; s=20211201; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=91T4lQE/Tcl1/jDI5kHHDuDJtFHiupADpUrn6t1/GAw=; b=AXz4OYo3Qzog4YJWGl+JeIk3yL CcuPpLLDI9TTkW4+M8doO21ckCVSVYUDHQKon+VgtAXAy7KV4e4p7LWIpqO2Vx+itxPES4dgL2gDD Dm8e4TJe3MS8iL2MG/iLXgBN9CH0wDGIaltflWw8Eetny3jaBU1YBcqi/fZYxI0i3tM4=; Received: from bras-base-simcon3012w-grc-05-64-231-188-105.dsl.bell.ca ([64.231.188.105] helo=courtney.binaryfoundry.ca) by mail.personalprojects.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n3Sw6-0006lA-Hl for ffmpeg-devel@ffmpeg.org; Fri, 31 Dec 2021 20:11:54 -0500 From: John-Paul Stewart To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Dec 2021 20:11:47 -0500 Message-Id: <20220101011148.13921-2-jpstewart@personalprojects.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101011148.13921-1-jpstewart@personalprojects.net> References: <20220101011148.13921-1-jpstewart@personalprojects.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat/mvdec: make audio stream conditional 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Only allocate an audio stream if there is one in the data. Silicon Graphics movie format will contain default values (16 bit samples, 2 audio channels, 22050 Hz sample rate) even when no audio is present in the file. This confuses FFmpeg into thinking such an audio stream is present with 0 samples in it. There is a flag value in the format to indicate whether or not audio is present. This patch checks that and behaves accordingly. Signed-off-by: John-Paul Stewart --- libavformat/mvdec.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c index ea955d2b11..0f0474141b 100644 --- a/libavformat/mvdec.c +++ b/libavformat/mvdec.c @@ -45,6 +45,10 @@ typedef struct MvContext { int aformat; ///< audio format } MvContext; +/* these magic numbers are defined in moviefile.h on Silicon Grahpics IRIX */ +#define MOVIE_SOUND 1 +#define MOVIE_SILENT 2 + #define AUDIO_FORMAT_SIGNED 401 static int mv_probe(const AVProbeData *p) @@ -305,18 +309,25 @@ static int mv_read_header(AVFormatContext *avctx) avio_skip(pb, 10); + fps = av_d2q(av_int2double(avio_rb64(pb)), INT_MAX); + /* allocate audio track first to prevent unnecessary seeking * (audio packet always precede video packet for a given frame) */ + v = avio_rb16(pb); + if (v == MOVIE_SOUND) { + /* movie has sound so allocate an audio stream */ ast = avformat_new_stream(avctx, NULL); if (!ast) return AVERROR(ENOMEM); + } else if (v != MOVIE_SILENT) + return AVERROR_INVALIDDATA; + + avio_skip(pb, 2); vst = avformat_new_stream(avctx, NULL); if (!vst) return AVERROR(ENOMEM); - fps = av_d2q(av_int2double(avio_rb64(pb)), INT_MAX); avpriv_set_pts_info(vst, 64, fps.den, fps.num); - avio_skip(pb, 4); vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; vst->avg_frame_rate = fps; vst->duration = vst->nb_frames = avio_rb32(pb); @@ -338,6 +349,7 @@ static int mv_read_header(AVFormatContext *avctx) vst->codecpar->height = avio_rb32(pb); avio_skip(pb, 12); + if (ast) { ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; ast->nb_frames = vst->nb_frames; ast->codecpar->sample_rate = avio_rb32(pb); @@ -373,6 +385,8 @@ static int mv_read_header(AVFormatContext *avctx) return AVERROR_INVALIDDATA; avio_skip(pb, 8); + } else + avio_skip(pb, 24); /* skip meaningless audio metadata */ var_read_metadata(avctx, "title", 0x80); var_read_metadata(avctx, "comment", 0x100); @@ -386,9 +400,11 @@ static int mv_read_header(AVFormatContext *avctx) if (avio_feof(pb)) return AVERROR_INVALIDDATA; avio_skip(pb, 8); + if (ast) { av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME); - av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME); timestamp += asize / (ast->codecpar->channels * (uint64_t)bytes_per_sample); + } + av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME); } } else if (!version && avio_rb16(pb) == 3) { avio_skip(pb, 4); -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".