From c165826316a71b378e3493a4a5fb6a6e1740bbab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 6 Sep 2016 08:13:10 -0400 Subject: IMAGE: Created Indeo decoder base class for shared Indeo4/5 functionality --- image/codecs/indeo/indeo.cpp | 52 ++++++++++++++++++++++++++++++++++++++++---- image/codecs/indeo/indeo.h | 37 +++++++++++++++++++++++++++---- 2 files changed, 81 insertions(+), 8 deletions(-) (limited to 'image/codecs/indeo') diff --git a/image/codecs/indeo/indeo.cpp b/image/codecs/indeo/indeo.cpp index 9de32fa301..820823b77e 100644 --- a/image/codecs/indeo/indeo.cpp +++ b/image/codecs/indeo/indeo.cpp @@ -20,10 +20,10 @@ * */ -/* Common structures and macros shared by both Indeo4 and Indeo5 decoders, - * derived from ffmpeg. We don't currently support Indeo5 decoding, but - * just in case we eventually need it, this is kept as a separate file - * like it is in ffmpeg. +/* Common structures, macros, and base class shared by both Indeo4 and + * Indeo5 decoders, derived from ffmpeg. We don't currently support Indeo5 + * decoding, but just in case we eventually need it, this is kept as a separate + * file like it is in ffmpeg. * * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg * written, produced, and directed by Alan Smithee @@ -31,6 +31,7 @@ #include "image/codecs/indeo/indeo.h" #include "image/codecs/indeo/mem.h" +#include "common/system.h" #include "common/textconsole.h" #include "common/util.h" @@ -383,6 +384,49 @@ int IVIBandDesc::ivi_init_tiles(IVITile *ref_tile, int p, int b, int t_height, i /*------------------------------------------------------------------------*/ +IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height) : Codec() { + _pixelFormat = g_system->getScreenFormat(); + _surface = new Graphics::ManagedSurface(); + _surface->create(width, height, _pixelFormat); + _ctx.gb = nullptr; + _ctx.pic_conf.pic_width = _ctx.pic_conf.pic_height = 0; + _ctx.show_indeo4_info = false; + _ctx.b_ref_buf = 3; // buffer 2 is used for scalability mode +} + +IndeoDecoderBase::~IndeoDecoderBase() { + delete _surface; +} + +int IndeoDecoderBase::decodeIndeoFrame() { + // Decode the header + int err = decodePictureHeader(); + + if (!err && _ctx.gop_invalid) + err = -1; + + if (!err && _ctx.frame_type == IVI4_FRAMETYPE_NULL_LAST) { + // Returning the previous frame, so exit wth success + return 0; + } + + if (!err && _ctx.gop_flags & IVI5_IS_PROTECTED) { + warning("Password-protected clip"); + err = -1; + } + + if (!err && !_ctx.planes[0].bands) { + warning("Color planes not initialized yet"); + err = -1; + } + + // TODO + + return err; +} + +/*------------------------------------------------------------------------*/ + int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) { if (((w + 128) * (uint64)(h + 128)) < (INT_MAX / 8)) return 0; diff --git a/image/codecs/indeo/indeo.h b/image/codecs/indeo/indeo.h index d689994b03..c84f257f27 100644 --- a/image/codecs/indeo/indeo.h +++ b/image/codecs/indeo/indeo.h @@ -21,11 +21,13 @@ */ #include "common/scummsys.h" +#include "graphics/managed_surface.h" +#include "image/codecs/codec.h" -/* Common structures and macros shared by both Indeo4 and Indeo5 decoders, - * derived from ffmpeg. We don't currently support Indeo5 decoding, but - * just in case we eventually need it, this is kept as a separate file - * like it is in ffmpeg. +/* Common structures, macros, and base class shared by both Indeo4 and + * Indeo5 decoders, derived from ffmpeg. We don't currently support Indeo5 + * decoding, but just in case we eventually need it, this is kept as a separate + * file like it is in ffmpeg. * * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg * written, produced, and directed by Alan Smithee @@ -330,6 +332,33 @@ struct IVI45DecContext { int got_p_frame; }; +class IndeoDecoderBase : public Codec { +protected: + IVI45DecContext _ctx; + Graphics::PixelFormat _pixelFormat; + Graphics::ManagedSurface *_surface; +protected: + /** + * Returns the pixel format for the decoder's surface + */ + virtual Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; } + + /** + * Decode the Indeo picture header. + * @returns 0 = Ok, negative number = error + */ + virtual int decodePictureHeader() = 0; + + /** + * Decodes the Indeo frame from the bit reader already + * loaded into the context + */ + int decodeIndeoFrame(); +public: + IndeoDecoderBase(uint16 width, uint16 height); + virtual ~IndeoDecoderBase(); +}; + /*------------------------------------------------------------------------*/ /** -- cgit v1.2.3