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 810F543BDD for ; Mon, 22 Aug 2022 10:00:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C452A68B9B7; Mon, 22 Aug 2022 13:00:12 +0300 (EEST) Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 432A868B815 for ; Mon, 22 Aug 2022 13:00:06 +0300 (EEST) Received: from 58402d044e49622716d64a4a76697097 ([1.136.254.209]) (authenticated (0 bits)) by mx.sdf.org (8.15.2/8.14.5) with ESMTPSA id 27M9xt08018966 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for ; Mon, 22 Aug 2022 09:59:59 GMT Date: Mon, 22 Aug 2022 19:59:49 +1000 From: Peter Ross To: ffmpeg-devel@ffmpeg.org Message-ID: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/ildadec: ILDA Image Data Transfer Format demuxer 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="===============3988179939667314794==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============3988179939667314794== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ROB0x6u44igmz4ee" Content-Disposition: inline --ROB0x6u44igmz4ee Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Signed-off-by: Peter Ross --- sample: 'ftp://ftp.photonlexicon.com/public/Laser Shows/ILDA Frames/wim.ild' doc/general_contents.texi | 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/ildadec.c | 137 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 libavformat/ildadec.c diff --git a/doc/general_contents.texi b/doc/general_contents.texi index 86ec6d606b..935101af6e 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -500,6 +500,7 @@ library: @item IFV @tab @tab X @tab A format used by some old CCTV DVRs. @item iLBC @tab X @tab X +@item ILDA Image Data Transfer Format @tab @tab X @item Interplay MVE @tab @tab X @tab Format used in various Interplay computer games. @item Iterated Systems ClearVideo @tab @tab X diff --git a/libavformat/Makefile b/libavformat/Makefile index f67a99f839..706edab6b1 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -260,6 +260,7 @@ OBJS-$(CONFIG_IFF_DEMUXER) +=3D iff.o OBJS-$(CONFIG_IFV_DEMUXER) +=3D ifv.o OBJS-$(CONFIG_ILBC_DEMUXER) +=3D ilbc.o OBJS-$(CONFIG_ILBC_MUXER) +=3D ilbc.o rawenc.o +OBJS-$(CONFIG_ILDA_DEMUXER) +=3D ildadec.o OBJS-$(CONFIG_IMAGE2_DEMUXER) +=3D img2dec.o img2.o OBJS-$(CONFIG_IMAGE2_MUXER) +=3D img2enc.o img2.o OBJS-$(CONFIG_IMAGE2PIPE_DEMUXER) +=3D img2dec.o img2.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index ae4479fb7a..6ff2b0a3c2 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -210,6 +210,7 @@ extern const AVInputFormat ff_iff_demuxer; extern const AVInputFormat ff_ifv_demuxer; extern const AVInputFormat ff_ilbc_demuxer; extern const AVOutputFormat ff_ilbc_muxer; +extern const AVInputFormat ff_ilda_demuxer; extern const AVInputFormat ff_image2_demuxer; extern const AVOutputFormat ff_image2_muxer; extern const AVInputFormat ff_image2pipe_demuxer; diff --git a/libavformat/ildadec.c b/libavformat/ildadec.c new file mode 100644 index 0000000000..ad2563f281 --- /dev/null +++ b/libavformat/ildadec.c @@ -0,0 +1,137 @@ +/* + * ILDA Image Data Transfer Format demuxer + * Copyright (c) 2020 Peter Ross (pross@xvid.org) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA + */ + +/** + * @file + * ILDA Image Data Transfer Format demuxer + */ + +#include "libavutil/intreadwrite.h" +#include "libavcodec/bytestream.h" +#include "avformat.h" +#include "internal.h" +#include "libavutil/opt.h" + +typedef struct { + AVClass *class; + int width, height; + AVRational framerate; +} ILDAContext; + +static const uint8_t record_size[] =3D {8, 6, 3, 3, 10, 8}; + +static int probe(const AVProbeData *p) +{ + if (p->buf_size < 8 || memcmp(p->buf, "ILDA", 4) || p->buf[4] || p->bu= f[5] || p->buf[6] || p->buf[7] >=3D FF_ARRAY_ELEMS(record_size)) + return 0; + return AVPROBE_SCORE_MAX / 4 + 1; +} + +static int read_header(AVFormatContext *avctx) +{ + ILDAContext * s =3D avctx->priv_data; + AVStream *st =3D avformat_new_stream(avctx, NULL); + + if (!st) + return AVERROR(ENOMEM); + + st->codecpar->codec_type =3D AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_id =3D AV_CODEC_ID_ILDA; + + st->codecpar->width =3D s->width; + st->codecpar->height =3D s->height; + avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num); + st->avg_frame_rate =3D s->framerate; + return 0; +} + +static int read_packet(AVFormatContext *s, AVPacket *pkt) +{ + AVIOContext *pb =3D s->pb; + uint8_t buf[32]; + int type, nb_entries, ret; + int64_t pos; + + if (avio_feof(pb)) + return AVERROR_EOF; + + pos =3D avio_tell(pb); + + if (avio_read(pb, buf, sizeof(buf)) !=3D sizeof(buf)) + return AVERROR(EIO); + + if (AV_RB32(buf) !=3D MKBETAG('I', 'L', 'D', 'A')) { + av_log(s, AV_LOG_ERROR, "unexpected tag\n"); + return AVERROR(EIO); + } + + type =3D buf[7]; + if (type >=3D FF_ARRAY_ELEMS(record_size)) + return AVERROR(EIO); + + nb_entries =3D AV_RB16(buf + 24); + if (!nb_entries) { + avio_seek(pb, -sizeof(buf), SEEK_CUR); + return AVERROR(EOF); + } + + ret =3D av_new_packet(pkt, sizeof(buf) + nb_entries * record_size[type= ]); + if (ret < 0) + return ret; + + memcpy(pkt->data, buf, sizeof(buf)); + + ret =3D avio_read(pb, pkt->data + sizeof(buf), nb_entries * record_siz= e[type]); + if (ret < 0) + return ret; + + pkt->pos =3D pos; + pkt->pts =3D AV_RB16(buf + 26); + pkt->flags |=3D AV_PKT_FLAG_KEY; + + return 0; +} + +#define OFFSET(x) offsetof(ILDAContext, x) +#define DEC AV_OPT_FLAG_DECODING_PARAM +static const AVOption options[] =3D { + { "video_size", "A string describing frame size, such as 640x480 or hd= 720.", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str =3D NULL}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = =3D "10"}, 0, INT_MAX, DEC }, + { NULL }, +}; + +static const AVClass ilda_demuxer_class =3D { + .class_name =3D "ILDA demuxer", + .item_name =3D av_default_item_name, + .option =3D options, + .version =3D LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_ilda_demuxer =3D { + .name =3D "ilda", + .long_name =3D NULL_IF_CONFIG_SMALL("ILDA Image Data Transfer For= mat"), + .priv_data_size =3D sizeof(ILDAContext), + .read_probe =3D probe, + .read_header =3D read_header, + .read_packet =3D read_packet, + .priv_class =3D &ilda_demuxer_class, + .flags =3D AVFMT_GENERIC_INDEX, +}; --=20 2.35.1 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) --ROB0x6u44igmz4ee Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSpB+AvpuUM0jTNINJnYHnFrEDdawUCYwNTkQAKCRBnYHnFrEDd a/X+AKCR6dw+P/calIyEETwcR6eGEI3mfACgqGGCQw23s43Kb+Ig3TqC7bEalXE= =cCXT -----END PGP SIGNATURE----- --ROB0x6u44igmz4ee-- --===============3988179939667314794== 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". --===============3988179939667314794==--