aboutsummaryrefslogtreecommitdiff
path: root/image/codecs
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
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')
-rw-r--r--image/codecs/indeo/indeo.cpp52
-rw-r--r--image/codecs/indeo/indeo.h37
-rw-r--r--image/codecs/indeo4.cpp21
-rw-r--r--image/codecs/indeo4.h18
4 files changed, 91 insertions, 37 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();
+};
+
/*------------------------------------------------------------------------*/
/**
diff --git a/image/codecs/indeo4.cpp b/image/codecs/indeo4.cpp
index bce9b5ad78..29616e9c63 100644
--- a/image/codecs/indeo4.cpp
+++ b/image/codecs/indeo4.cpp
@@ -28,7 +28,6 @@
* written, produced, and directed by Alan Smithee
*/
-#include "common/system.h"
#include "common/endian.h"
#include "common/stream.h"
#include "common/textconsole.h"
@@ -40,19 +39,8 @@ namespace Image {
#define IVI4_PIC_SIZE_ESC 7
-Indeo4Decoder::Indeo4Decoder(uint16 width, uint16 height) {
- _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;
+Indeo4Decoder::Indeo4Decoder(uint16 width, uint16 height) : IndeoDecoderBase(width, height) {
_ctx.is_indeo4 = true;
- _ctx.show_indeo4_info = false;
- _ctx.b_ref_buf = 3; // buffer 2 is used for scalability mode
-}
-
-Indeo4Decoder::~Indeo4Decoder() {
- delete _surface;
}
bool Indeo4Decoder::isIndeo4(Common::SeekableReadStream &stream) {
@@ -80,14 +68,13 @@ const Graphics::Surface *Indeo4Decoder::decodeFrame(Common::SeekableReadStream &
// Set up the GetBits instance for reading the stream
_ctx.gb = new GetBits(stream);
- // Decode the header
- int err = decodePictureHeader();
+ // Decode the frame
+ int err = decodeIndeoFrame();
+ // Free the bit reader
delete _ctx.gb;
_ctx.gb = nullptr;
- // TODO
- err = -1;
return (err < 0) ? nullptr : &_surface->rawSurface();
}
diff --git a/image/codecs/indeo4.h b/image/codecs/indeo4.h
index 838b0c3aef..b2d89d5d55 100644
--- a/image/codecs/indeo4.h
+++ b/image/codecs/indeo4.h
@@ -33,7 +33,6 @@
#ifndef IMAGE_CODECS_INDEO4_H
#define IMAGE_CODECS_INDEO4_H
-#include "image/codecs/codec.h"
#include "image/codecs/indeo/get_bits.h"
#include "image/codecs/indeo/indeo.h"
#include "graphics/managed_surface.h"
@@ -50,26 +49,21 @@ using namespace Indeo;
* Used in video:
* - AVIDecoder
*/
-class Indeo4Decoder : public Codec {
+class Indeo4Decoder : public IndeoDecoderBase {
public:
Indeo4Decoder(uint16 width, uint16 height);
- ~Indeo4Decoder();
+ virtual ~Indeo4Decoder() {}
- const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
- Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
+ virtual const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
static bool isIndeo4(Common::SeekableReadStream &stream);
-private:
- Graphics::PixelFormat _pixelFormat;
- Graphics::ManagedSurface *_surface;
- IVI45DecContext _ctx;
-
+protected:
/**
* Decode the Indeo 4 picture header.
* @returns 0 = Ok, negative number = error
*/
- int decodePictureHeader();
-
+ virtual int decodePictureHeader();
+private:
int scaleTileSize(int def_size, int size_factor);
/**