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 D7F5B4907B for ; Sat, 2 Mar 2024 23:37:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 091EB68D31F; Sun, 3 Mar 2024 01:37:03 +0200 (EET) Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 893A868D13E for ; Sun, 3 Mar 2024 01:36:55 +0200 (EET) Received: from 39591f7afd128dc79d9aaff2e0abc776 ([1.145.170.249]) (authenticated (0 bits)) by mx.sdf.org (8.16.1/8.14.3) with ESMTPSA id 422NamqM022581 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for ; Sat, 2 Mar 2024 23:36:52 GMT Date: Sun, 3 Mar 2024 10:36:42 +1100 From: Peter Ross To: ffmpeg-devel@ffmpeg.org Message-ID: <85a99241dc108fad30290ffc7524541227c7dfdd.1709422402.git.pross@xvid.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/rmdec: support RMHD file format 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: multipart/mixed; boundary="===============6656521938681360708==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============6656521938681360708== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="M1/5YuY7OT9yI/jf" Content-Disposition: inline --M1/5YuY7OT9yI/jf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Signed-off-by: Peter Ross --- libavformat/rmdec.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 0f1534b582..e7f2480464 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -428,7 +428,8 @@ skip: static int rm_read_index(AVFormatContext *s) { AVIOContext *pb =3D s->pb; - unsigned int size, n_pkts, str_id, next_off, n, pos, pts; + unsigned int size, ver, n_pkts, str_id, next_off, n, pts; + uint64_t pos; AVStream *st; =20 do { @@ -437,10 +438,14 @@ static int rm_read_index(AVFormatContext *s) size =3D avio_rb32(pb); if (size < 20) return -1; - avio_skip(pb, 2); + ver =3D avio_rb16(pb); + if (ver !=3D 0 && ver !=3D 2) + return AVERROR_INVALIDDATA; n_pkts =3D avio_rb32(pb); str_id =3D avio_rb16(pb); next_off =3D avio_rb32(pb); + if (ver =3D=3D 2) + avio_skip(pb, 4); for (n =3D 0; n < s->nb_streams; n++) if (s->streams[n]->id =3D=3D str_id) { st =3D s->streams[n]; @@ -465,7 +470,7 @@ static int rm_read_index(AVFormatContext *s) return AVERROR_INVALIDDATA; avio_skip(pb, 2); pts =3D avio_rb32(pb); - pos =3D avio_rb32(pb); + pos =3D (ver =3D=3D 0) ? avio_rb32(pb) : avio_rb64(pb); avio_skip(pb, 4); /* packet no. */ =20 av_add_index_entry(st, pos, pts, 0, 0, AVINDEX_KEYFRAME); @@ -546,8 +551,10 @@ static int rm_read_header(AVFormatContext *s) AVIOContext *pb =3D s->pb; unsigned int tag; int tag_size; + int ver; unsigned int start_time, duration; - unsigned int data_off =3D 0, indx_off =3D 0; + unsigned int data_off =3D 0; + uint64_t indx_off =3D 0; char buf[128], mime[128]; int flags =3D 0; int ret; @@ -558,7 +565,7 @@ static int rm_read_header(AVFormatContext *s) if (tag =3D=3D MKTAG('.', 'r', 'a', 0xfd)) { /* very old .ra format */ return rm_read_header_old(s); - } else if (tag !=3D MKTAG('.', 'R', 'M', 'F')) { + } else if (tag !=3D MKTAG('.', 'R', 'M', 'F') && tag !=3D MKTAG('.', '= R', 'M', 'P')) { return AVERROR(EIO); } =20 @@ -572,10 +579,11 @@ static int rm_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; tag =3D avio_rl32(pb); tag_size =3D avio_rb32(pb); - avio_rb16(pb); + ver =3D avio_rb16(pb); av_log(s, AV_LOG_TRACE, "tag=3D%s size=3D%d\n", av_fourcc2str(tag), tag_size); - if (tag_size < 10 && tag !=3D MKTAG('D', 'A', 'T', 'A')) + if ((tag_size < 10 && tag !=3D MKTAG('D', 'A', 'T', 'A')) || + (ver !=3D 0 && ver !=3D 2)) return AVERROR_INVALIDDATA; switch(tag) { case MKTAG('P', 'R', 'O', 'P'): @@ -588,7 +596,7 @@ static int rm_read_header(AVFormatContext *s) duration =3D avio_rb32(pb); /* duration */ s->duration =3D av_rescale(duration, AV_TIME_BASE, 1000); avio_rb32(pb); /* preroll */ - indx_off =3D avio_rb32(pb); /* index offset */ + indx_off =3D (ver =3D=3D 0) ? avio_rb32(pb) : avio_rb64(pb); /= * index offset */ data_off =3D avio_rb32(pb); /* data offset */ avio_rb16(pb); /* nb streams */ flags =3D avio_rb16(pb); /* flags */ @@ -650,15 +658,17 @@ static int rm_read_header(AVFormatContext *s) rm->nb_packets =3D avio_rb32(pb); /* number of packets */ if (!rm->nb_packets && (flags & 4)) rm->nb_packets =3D 3600 * 25; + if (ver =3D=3D 2) + avio_skip(pb, 12); avio_rb32(pb); /* next data header */ =20 if (!data_off) - data_off =3D avio_tell(pb) - 18; + data_off =3D avio_tell(pb) - (ver =3D=3D 0 ? 18 : 30); if (indx_off && (pb->seekable & AVIO_SEEKABLE_NORMAL) && !(s->flags & AVFMT_FLAG_IGNIDX) && avio_seek(pb, indx_off, SEEK_SET) >=3D 0) { rm_read_index(s); - avio_seek(pb, data_off + 18, SEEK_SET); + avio_seek(pb, data_off + (ver =3D=3D 0 ? 18 : 30), SEEK_SET); } =20 return 0; @@ -703,12 +713,19 @@ static int rm_sync(AVFormatContext *s, int64_t *times= tamp, int *flags, int *stre state=3D (state<<8) + avio_r8(pb); =20 if(state =3D=3D MKBETAG('I', 'N', 'D', 'X')){ + int ver; int n_pkts; int64_t expected_len; len =3D avio_rb32(pb); - avio_skip(pb, 2); + ver =3D avio_rb16(pb); + if (ver !=3D 0 && ver !=3D 2) + return AVERROR_INVALIDDATA; n_pkts =3D avio_rb32(pb); - expected_len =3D 20 + n_pkts * 14LL; + + if (ver =3D=3D 0) + expected_len =3D 20 + n_pkts * 14LL; + else if (ver =3D=3D 2) + expected_len =3D 24 + n_pkts * 18LL; =20 if (len =3D=3D 20 && expected_len <=3D INT_MAX) /* some files don't add index entries to chunk size...= */ @@ -1078,7 +1095,7 @@ static int rm_probe(const AVProbeData *p) { /* check file header */ if ((p->buf[0] =3D=3D '.' && p->buf[1] =3D=3D 'R' && - p->buf[2] =3D=3D 'M' && p->buf[3] =3D=3D 'F' && + p->buf[2] =3D=3D 'M' && (p->buf[3] =3D=3D 'F' || p->buf[3] =3D=3D= 'P') && p->buf[4] =3D=3D 0 && p->buf[5] =3D=3D 0) || (p->buf[0] =3D=3D '.' && p->buf[1] =3D=3D 'r' && p->buf[2] =3D=3D 'a' && p->buf[3] =3D=3D 0xfd)) --=20 2.43.0 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) --M1/5YuY7OT9yI/jf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSpB+AvpuUM0jTNINJnYHnFrEDdawUCZeO4BQAKCRBnYHnFrEDd a035AKDU8BwOKK/HfhKZQKy50dB7ggzRGwCfVSpF5TzRTqyQ8/TBjN6sWuH/Ay4= =MvZ0 -----END PGP SIGNATURE----- --M1/5YuY7OT9yI/jf-- --===============6656521938681360708== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============6656521938681360708==--