mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-06 18:27:26 +00:00
IMAGE: Created Indeo decoder base class for shared Indeo4/5 functionality
This commit is contained in:
parent
5f0962696f
commit
c165826316
image/codecs
@ -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;
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user