aboutsummaryrefslogtreecommitdiff
path: root/image/codecs/indeo
diff options
context:
space:
mode:
authorPaul Gilbert2016-09-06 08:13:10 -0400
committerPaul Gilbert2016-09-10 10:08:12 -0400
commitc165826316a71b378e3493a4a5fb6a6e1740bbab (patch)
treefc657dae321669b08bb962510002dd8d0c01535a /image/codecs/indeo
parent5f0962696f97df2cce27d065d99b04243de59334 (diff)
downloadscummvm-rg350-c165826316a71b378e3493a4a5fb6a6e1740bbab.tar.gz
scummvm-rg350-c165826316a71b378e3493a4a5fb6a6e1740bbab.tar.bz2
scummvm-rg350-c165826316a71b378e3493a4a5fb6a6e1740bbab.zip
IMAGE: Created Indeo decoder base class for shared Indeo4/5 functionality
Diffstat (limited to 'image/codecs/indeo')
-rw-r--r--image/codecs/indeo/indeo.cpp52
-rw-r--r--image/codecs/indeo/indeo.h37
2 files changed, 81 insertions, 8 deletions
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();
+};
+
/*------------------------------------------------------------------------*/
/**