[FFmpeg-devel] [PATCH] CDToons decoder
This adds a decoder for Broderbund's sprite-based QuickTime CDToons codec, based on the decoder I wrote for ScummVM. A couple of samples can be found at http://noopwafel.net/cdtoons/. Signed-off-by: Alyssa Milburn --- Changelog | 1 + doc/general.texi| 2 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/cdtoons.c| 438 libavcodec/codec_desc.c | 7 + libavcodec/version.h| 2 +- libavformat/isom.c | 1 + libavformat/riff.c | 1 + 10 files changed, 454 insertions(+), 1 deletion(-) create mode 100644 libavcodec/cdtoons.c diff --git a/Changelog b/Changelog index b9401aaab6..9cac485bb5 100644 --- a/Changelog +++ b/Changelog @@ -29,6 +29,7 @@ version : - mvha decoder - MPEG-H 3D Audio support in mp4 - thistogram filter +- CDToons decoder version 4.2: diff --git a/doc/general.texi b/doc/general.texi index a5b77e0de1..8fdf8af9fe 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -844,6 +844,8 @@ following image formats are supported: @tab Codec used in Delphine Software International games. @item Discworld II BMV Video @tab @tab X @item Canopus Lossless Codec @tab @tab X +@item CDToons@tab @tab X +@tab Codec used in various Broderbund games. @item Cinepak@tab @tab X @item Cirrus Logic AccuPak @tab X @tab X @tab fourcc: CLJR diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c1f35b40d8..383a6da32d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -244,6 +244,7 @@ OBJS-$(CONFIG_CAVS_DECODER)+= cavs.o cavsdec.o cavsdsp.o \ cavsdata.o OBJS-$(CONFIG_CCAPTION_DECODER)+= ccaption_dec.o ass.o OBJS-$(CONFIG_CDGRAPHICS_DECODER) += cdgraphics.o +OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o OBJS-$(CONFIG_CDXL_DECODER)+= cdxl.o OBJS-$(CONFIG_CFHD_DECODER)+= cfhd.o cfhddata.o OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index ec7366144f..a87f29829d 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -68,6 +68,7 @@ extern AVCodec ff_brender_pix_decoder; extern AVCodec ff_c93_decoder; extern AVCodec ff_cavs_decoder; extern AVCodec ff_cdgraphics_decoder; +extern AVCodec ff_cdtoons_decoder; extern AVCodec ff_cdxl_decoder; extern AVCodec ff_cfhd_decoder; extern AVCodec ff_cinepak_encoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 119b32dc1f..e9a24165ed 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -460,6 +460,7 @@ enum AVCodecID { AV_CODEC_ID_IMM5, AV_CODEC_ID_MVDV, AV_CODEC_ID_MVHA, +AV_CODEC_ID_CDTOONS, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/cdtoons.c b/libavcodec/cdtoons.c new file mode 100644 index 00..d6c441b8e3 --- /dev/null +++ b/libavcodec/cdtoons.c @@ -0,0 +1,438 @@ +/* + * CDToons video decoder + * Copyright (C) 2011 The FFmpeg project + * + * 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-1301 USA + */ + +/** + * @file + * CDToons video decoder + * @author Alyssa Milburn + */ + +#include + +#include "libavutil/attributes.h" +#include "libavutil/internal.h" +#include "avcodec.h" +#include "bytestream.h" +#include "internal.h" + +#define CDTOONS_HEADER_SIZE 44 +#define CDTOONS_MAX_SPRITES 1200 + +typedef struct CDToonsSprite { +uint16_t flags; +uint16_t owner_frame; +uint16_t start_frame; +uint16_t end_frame; +uint32_t size; +uint8_t *data; +} CDToonsSprite; + +typedef struct CDToonsContext { +AVCodecContext *avctx; +AVFrame *frame; + +uint16_t last_pal_id; ///< The index of the active palette sprite. +uint32_t pal[256]; ///< The currently-used palette data. +CDToonsSprite sprites[CDTOONS_MAX_SPRITES]; +} CDToonsContext; + +static int cdtoons_render_sprite(AVCodecContext *avctx, const uint8_t *data, + uint32_t data_size, + int dst_x, int dst_y, int width, int height) +{ +
Re: [FFmpeg-devel] [PATCH] CDToons decoder
On 1/5/2020 6:57 PM, Alyssa Milburn wrote: > This adds a decoder for Broderbund's sprite-based QuickTime CDToons > codec, based on the decoder I wrote for ScummVM. > > A couple of samples can be found at http://noopwafel.net/cdtoons/. > > Signed-off-by: Alyssa Milburn > --- > Changelog | 1 + > doc/general.texi| 2 + > libavcodec/Makefile | 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/avcodec.h| 1 + > libavcodec/cdtoons.c| 438 > libavcodec/codec_desc.c | 7 + > libavcodec/version.h| 2 +- > libavformat/isom.c | 1 + > libavformat/riff.c | 1 + > 10 files changed, 454 insertions(+), 1 deletion(-) > create mode 100644 libavcodec/cdtoons.c > > diff --git a/Changelog b/Changelog > index b9401aaab6..9cac485bb5 100644 > --- a/Changelog > +++ b/Changelog > @@ -29,6 +29,7 @@ version : > - mvha decoder > - MPEG-H 3D Audio support in mp4 > - thistogram filter > +- CDToons decoder > > > version 4.2: > diff --git a/doc/general.texi b/doc/general.texi > index a5b77e0de1..8fdf8af9fe 100644 > --- a/doc/general.texi > +++ b/doc/general.texi > @@ -844,6 +844,8 @@ following image formats are supported: > @tab Codec used in Delphine Software International games. > @item Discworld II BMV Video @tab @tab X > @item Canopus Lossless Codec @tab @tab X > +@item CDToons@tab @tab X > +@tab Codec used in various Broderbund games. > @item Cinepak@tab @tab X > @item Cirrus Logic AccuPak @tab X @tab X > @tab fourcc: CLJR > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index c1f35b40d8..383a6da32d 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -244,6 +244,7 @@ OBJS-$(CONFIG_CAVS_DECODER)+= cavs.o > cavsdec.o cavsdsp.o \ >cavsdata.o > OBJS-$(CONFIG_CCAPTION_DECODER)+= ccaption_dec.o ass.o > OBJS-$(CONFIG_CDGRAPHICS_DECODER) += cdgraphics.o > +OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o > OBJS-$(CONFIG_CDXL_DECODER)+= cdxl.o > OBJS-$(CONFIG_CFHD_DECODER)+= cfhd.o cfhddata.o > OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index ec7366144f..a87f29829d 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -68,6 +68,7 @@ extern AVCodec ff_brender_pix_decoder; > extern AVCodec ff_c93_decoder; > extern AVCodec ff_cavs_decoder; > extern AVCodec ff_cdgraphics_decoder; > +extern AVCodec ff_cdtoons_decoder; > extern AVCodec ff_cdxl_decoder; > extern AVCodec ff_cfhd_decoder; > extern AVCodec ff_cinepak_encoder; > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index 119b32dc1f..e9a24165ed 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -460,6 +460,7 @@ enum AVCodecID { > AV_CODEC_ID_IMM5, > AV_CODEC_ID_MVDV, > AV_CODEC_ID_MVHA, > +AV_CODEC_ID_CDTOONS, > > /* various PCM "codecs" */ > AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the > start of audio codecs > diff --git a/libavcodec/cdtoons.c b/libavcodec/cdtoons.c > new file mode 100644 > index 00..d6c441b8e3 > --- /dev/null > +++ b/libavcodec/cdtoons.c > @@ -0,0 +1,438 @@ > +/* > + * CDToons video decoder > + * Copyright (C) 2011 The FFmpeg project 2011? > + * > + * 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-1301 > USA > + */ > + > +/** > + * @file > + * CDToons video decoder > + * @author Alyssa Milburn You could add this as a copyright line above instead. > + */ > + > +#include > + > +#include "libavutil/attributes.h" > +#include "libavutil/internal.h" > +#include "avcodec.h" > +#include "bytestream.h" > +#include "internal.h" > + > +#define CDTOONS_HEADER_SIZE 44 > +#define CDTOONS_MAX_SPRITES 1200 > + > +typedef struct CDToonsSprite { > +uint16_t flags; > +uint16_t owner_frame; > +uint16_t start_frame; > +uint16_t end_frame; > +uint32_t size; > +uint8_t *data; > +} CDToonsSprite; > + > +typedef struct CDToonsContext { > +AVCodecContext *avctx; > +AVFrame *frame; > + > +uint16_t last_pal_id; ///< T
Re: [FFmpeg-devel] [PATCH] CDToons decoder
Am So., 5. Jan. 2020 um 22:57 Uhr schrieb Alyssa Milburn : > diff --git a/libavformat/riff.c b/libavformat/riff.c > index c73f6e9db0..560a3aa208 100644 > --- a/libavformat/riff.c > +++ b/libavformat/riff.c > @@ -491,6 +491,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { > { AV_CODEC_ID_IMM5, MKTAG('I', 'M', 'M', '5') }, > { AV_CODEC_ID_MVDV, MKTAG('M', 'V', 'D', 'V') }, > { AV_CODEC_ID_MVHA, MKTAG('M', 'V', 'H', 'A') }, > +{ AV_CODEC_ID_CDTOONS, MKTAG('Q', 'k', 'B', 'k') }, > { AV_CODEC_ID_NONE, 0 } Does the codec really exist in avi? I ask because the sample files you provide are mov. If no avi files exist, please remove above hunk. And please put your name in the copyright line as suggested by James. Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] CDToons decoder
On Sun, Jan 05, 2020 at 07:37:06PM -0300, James Almer wrote: > > + * Copyright (C) 2011 The FFmpeg project > > 2011? This patch has been lying around for a while. :/ Will update to 2020. > Use av_fast_malloc() instead of constantly freeing and reallocating > these buffers. See libavutil/mem.h Sprites are typically only allocated once for a given sprite_id, so for most situations the only difference would be to delay deallocation until the end of the video. Do you think it's worth doing anyway? (Easy enough to do.) Otherwise: ACK, thank you for the fast review. - Alyssa ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] CDToons decoder
On 1/5/20, Alyssa Milburn wrote: > This adds a decoder for Broderbund's sprite-based QuickTime CDToons > codec, based on the decoder I wrote for ScummVM. > > A couple of samples can be found at http://noopwafel.net/cdtoons/. > > Signed-off-by: Alyssa Milburn > --- > Changelog | 1 + > doc/general.texi| 2 + > libavcodec/Makefile | 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/avcodec.h| 1 + > libavcodec/cdtoons.c| 438 > libavcodec/codec_desc.c | 7 + > libavcodec/version.h| 2 +- > libavformat/isom.c | 1 + > libavformat/riff.c | 1 + > 10 files changed, 454 insertions(+), 1 deletion(-) > create mode 100644 libavcodec/cdtoons.c > > diff --git a/Changelog b/Changelog > index b9401aaab6..9cac485bb5 100644 > --- a/Changelog > +++ b/Changelog > @@ -29,6 +29,7 @@ version : > - mvha decoder > - MPEG-H 3D Audio support in mp4 > - thistogram filter > +- CDToons decoder > > > version 4.2: > diff --git a/doc/general.texi b/doc/general.texi > index a5b77e0de1..8fdf8af9fe 100644 > --- a/doc/general.texi > +++ b/doc/general.texi > @@ -844,6 +844,8 @@ following image formats are supported: > @tab Codec used in Delphine Software International games. > @item Discworld II BMV Video @tab @tab X > @item Canopus Lossless Codec @tab @tab X > +@item CDToons@tab @tab X > +@tab Codec used in various Broderbund games. > @item Cinepak@tab @tab X > @item Cirrus Logic AccuPak @tab X @tab X > @tab fourcc: CLJR > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index c1f35b40d8..383a6da32d 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -244,6 +244,7 @@ OBJS-$(CONFIG_CAVS_DECODER)+= cavs.o > cavsdec.o cavsdsp.o \ >cavsdata.o > OBJS-$(CONFIG_CCAPTION_DECODER)+= ccaption_dec.o ass.o > OBJS-$(CONFIG_CDGRAPHICS_DECODER) += cdgraphics.o > +OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o > OBJS-$(CONFIG_CDXL_DECODER)+= cdxl.o > OBJS-$(CONFIG_CFHD_DECODER)+= cfhd.o cfhddata.o > OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index ec7366144f..a87f29829d 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -68,6 +68,7 @@ extern AVCodec ff_brender_pix_decoder; > extern AVCodec ff_c93_decoder; > extern AVCodec ff_cavs_decoder; > extern AVCodec ff_cdgraphics_decoder; > +extern AVCodec ff_cdtoons_decoder; > extern AVCodec ff_cdxl_decoder; > extern AVCodec ff_cfhd_decoder; > extern AVCodec ff_cinepak_encoder; > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index 119b32dc1f..e9a24165ed 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -460,6 +460,7 @@ enum AVCodecID { > AV_CODEC_ID_IMM5, > AV_CODEC_ID_MVDV, > AV_CODEC_ID_MVHA, > +AV_CODEC_ID_CDTOONS, > > /* various PCM "codecs" */ > AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the > start of audio codecs > diff --git a/libavcodec/cdtoons.c b/libavcodec/cdtoons.c > new file mode 100644 > index 00..d6c441b8e3 > --- /dev/null > +++ b/libavcodec/cdtoons.c > @@ -0,0 +1,438 @@ > +/* > + * CDToons video decoder > + * Copyright (C) 2011 The FFmpeg project > + * > + * 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-1301 > USA > + */ > + > +/** > + * @file > + * CDToons video decoder > + * @author Alyssa Milburn > + */ > + > +#include > + > +#include "libavutil/attributes.h" > +#include "libavutil/internal.h" > +#include "avcodec.h" > +#include "bytestream.h" > +#include "internal.h" > + > +#define CDTOONS_HEADER_SIZE 44 > +#define CDTOONS_MAX_SPRITES 1200 > + > +typedef struct CDToonsSprite { > +uint16_t flags; > +uint16_t owner_frame; > +uint16_t start_frame; > +uint16_t end_frame; > +uint32_t size; > +uint8_t *data; > +} CDToonsSprite; > + > +typedef struct CDToonsContext { > +AVCodecContext *avctx; > +AVFrame *frame; > + > +uint16_t last_pal_id; ///< The index of the active palette sprite. > +uint32_t pal[256]; ///< The curren
Re: [FFmpeg-devel] [PATCH] CDToons decoder
What's status of this? On 1/5/20, Alyssa Milburn wrote: > This adds a decoder for Broderbund's sprite-based QuickTime CDToons > codec, based on the decoder I wrote for ScummVM. > > A couple of samples can be found at http://noopwafel.net/cdtoons/. > If you do not plan on sending updated patch, i would happy to finish this patch so it can be pushed to master. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".