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 295AD40E7A for ; Fri, 31 Dec 2021 19:50:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8E3B068B082; Fri, 31 Dec 2021 21:50:42 +0200 (EET) Received: from mail.personalprojects.net (mail.personalprojects.net [51.79.67.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0783568B07D for ; Fri, 31 Dec 2021 21:50:36 +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=FPLm775FzecavwjTYkgDdjEbMVWgbXIujJ1DCY/FHN8=; b=jA5fDormEKUwBf8qkPX9MiK6xl pr76viMAa4+saHkTB3FEjVaUZCQ8ijxjNaAOpRAltPLSdic6J+meYYBG/zA1C1peTF0oyU3D1bbJy GO8j+6njhq7N72IzYrhJjsLEY+aDKY5+B9vxB0fOBBc6euljv6X/XqyHZlfCfTktI5og=; 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 1n3Nv8-0006Oe-Rb for ffmpeg-devel@ffmpeg.org; Fri, 31 Dec 2021 14:50:34 -0500 From: John-Paul Stewart To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Dec 2021 14:50:18 -0500 Message-Id: <20211231195019.16191-2-jpstewart@personalprojects.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211231195019.16191-1-jpstewart@personalprojects.net> References: <20211231195019.16191-1-jpstewart@personalprojects.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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 | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c index ea955d2b11..7493bcc762 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,20 +309,27 @@ static int mv_read_header(AVFormatContext *avctx) avio_skip(pb, 10); - /* allocate audio track first to prevent unnecessary seeking - * (audio packet always precede video packet for a given frame) */ - ast = avformat_new_stream(avctx, NULL); - if (!ast) - return AVERROR(ENOMEM); - 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; + + 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); + + ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + } else if (v != MOVIE_SILENT) + return AVERROR_INVALIDDATA; + + avio_skip(pb, 2); + vst->duration = vst->nb_frames = avio_rb32(pb); v = avio_rb32(pb); switch (v) { @@ -338,7 +349,7 @@ static int mv_read_header(AVFormatContext *avctx) vst->codecpar->height = avio_rb32(pb); avio_skip(pb, 12); - ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + if (ast) { ast->nb_frames = vst->nb_frames; ast->codecpar->sample_rate = avio_rb32(pb); if (ast->codecpar->sample_rate <= 0) { @@ -373,6 +384,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 +399,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".