IMAGE: Remove unnecessary extra heap allocation of Indeo surface
This commit is contained in:
parent
7dd2c0342d
commit
d39a9272bf
4 changed files with 19 additions and 21 deletions
|
@ -479,15 +479,13 @@ IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height, uint bitsPerPixe
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_surface = new Graphics::Surface();
|
_surface.create(width, height, _pixelFormat);
|
||||||
_surface->create(width, height, _pixelFormat);
|
_surface.fillRect(Common::Rect(0, 0, width, height), (bitsPerPixel == 32) ? 0xff : 0);
|
||||||
_surface->fillRect(Common::Rect(0, 0, width, height), (bitsPerPixel == 32) ? 0xff : 0);
|
|
||||||
_ctx._bRefBuf = 3; // buffer 2 is used for scalability mode
|
_ctx._bRefBuf = 3; // buffer 2 is used for scalability mode
|
||||||
}
|
}
|
||||||
|
|
||||||
IndeoDecoderBase::~IndeoDecoderBase() {
|
IndeoDecoderBase::~IndeoDecoderBase() {
|
||||||
_surface->free();
|
_surface.free();
|
||||||
delete _surface;
|
|
||||||
IVIPlaneDesc::freeBuffers(_ctx._planes);
|
IVIPlaneDesc::freeBuffers(_ctx._planes);
|
||||||
if (_ctx._mbVlc._custTab._table)
|
if (_ctx._mbVlc._custTab._table)
|
||||||
_ctx._mbVlc._custTab.freeVlc();
|
_ctx._mbVlc._custTab.freeVlc();
|
||||||
|
@ -557,7 +555,7 @@ int IndeoDecoderBase::decodeIndeoFrame() {
|
||||||
if (!isNonNullFrame())
|
if (!isNonNullFrame())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
assert(_ctx._planes[0]._width <= _surface->w && _ctx._planes[0]._height <= _surface->h);
|
assert(_ctx._planes[0]._width <= _surface.w && _ctx._planes[0]._height <= _surface.h);
|
||||||
result = frame->setDimensions(_ctx._planes[0]._width, _ctx._planes[0]._height);
|
result = frame->setDimensions(_ctx._planes[0]._width, _ctx._planes[0]._height);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
return result;
|
return result;
|
||||||
|
@ -578,7 +576,7 @@ int IndeoDecoderBase::decodeIndeoFrame() {
|
||||||
outputPlane(&_ctx._planes[1], frame->_data[2], frame->_linesize[2]);
|
outputPlane(&_ctx._planes[1], frame->_data[2], frame->_linesize[2]);
|
||||||
|
|
||||||
// Merge the planes into the final surface
|
// Merge the planes into the final surface
|
||||||
YUVToRGBMan.convert410(_surface, Graphics::YUVToRGBManager::kScaleITU,
|
YUVToRGBMan.convert410(&_surface, Graphics::YUVToRGBManager::kScaleITU,
|
||||||
frame->_data[0], frame->_data[1], frame->_data[2], frame->_width, frame->_height,
|
frame->_data[0], frame->_data[1], frame->_data[2], frame->_width, frame->_height,
|
||||||
frame->_width, frame->_width);
|
frame->_width, frame->_width);
|
||||||
|
|
||||||
|
|
|
@ -519,7 +519,7 @@ private:
|
||||||
protected:
|
protected:
|
||||||
IVI45DecContext _ctx;
|
IVI45DecContext _ctx;
|
||||||
Graphics::PixelFormat _pixelFormat;
|
Graphics::PixelFormat _pixelFormat;
|
||||||
Graphics::Surface *_surface;
|
Graphics::Surface _surface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan patterns shared between indeo4 and indeo5
|
* Scan patterns shared between indeo4 and indeo5
|
||||||
|
|
|
@ -88,7 +88,7 @@ const Graphics::Surface *Indeo4Decoder::decodeFrame(Common::SeekableReadStream &
|
||||||
_ctx._frameData = nullptr;
|
_ctx._frameData = nullptr;
|
||||||
_ctx._frameSize = 0;
|
_ctx._frameSize = 0;
|
||||||
|
|
||||||
return (err < 0) ? nullptr : _surface;
|
return (err < 0) ? nullptr : &_surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Indeo4Decoder::decodePictureHeader() {
|
int Indeo4Decoder::decodePictureHeader() {
|
||||||
|
@ -607,16 +607,16 @@ int Indeo4Decoder::decodeRLETransparency(VLC_TYPE (*table)[2]) {
|
||||||
|
|
||||||
const uint32 opacityMask = 0xFF << _pixelFormat.aShift;
|
const uint32 opacityMask = 0xFF << _pixelFormat.aShift;
|
||||||
|
|
||||||
uint32 *pixel = (uint32 *)_surface->getPixels();
|
uint32 *pixel = (uint32 *)_surface.getPixels();
|
||||||
const int surfacePixelPitch = _surface->pitch / _surface->format.bytesPerPixel;
|
const int surfacePixelPitch = _surface.pitch / _surface.format.bytesPerPixel;
|
||||||
const int surfacePadding = surfacePixelPitch - _surface->w;
|
const int surfacePadding = surfacePixelPitch - _surface.w;
|
||||||
const uint32 *endOfVisibleRow = pixel + _surface->w;
|
const uint32 *endOfVisibleRow = pixel + _surface.w;
|
||||||
const uint32 *endOfVisibleArea = pixel + surfacePixelPitch * _surface->h - surfacePadding;
|
const uint32 *endOfVisibleArea = pixel + surfacePixelPitch * _surface.h - surfacePadding;
|
||||||
|
|
||||||
const int codecAlignedWidth = (_surface->w + 31) & ~31;
|
const int codecAlignedWidth = (_surface.w + 31) & ~31;
|
||||||
const int codecPaddingSize = codecAlignedWidth - _surface->w;
|
const int codecPaddingSize = codecAlignedWidth - _surface.w;
|
||||||
|
|
||||||
int numPixelsToRead = codecAlignedWidth * _surface->h;
|
int numPixelsToRead = codecAlignedWidth * _surface.h;
|
||||||
int numPixelsToSkip = 0;
|
int numPixelsToSkip = 0;
|
||||||
while (numPixelsToRead > 0) {
|
while (numPixelsToRead > 0) {
|
||||||
int value = _ctx._gb->getVLC2<1>(table, IVI_VLC_BITS);
|
int value = _ctx._gb->getVLC2<1>(table, IVI_VLC_BITS);
|
||||||
|
@ -774,8 +774,8 @@ int Indeo4Decoder::decodeTransparency() {
|
||||||
_surface->convertToInPlace(_pixelFormat);
|
_surface->convertToInPlace(_pixelFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(_surface->format.bytesPerPixel == 4);
|
assert(_surface.format.bytesPerPixel == 4);
|
||||||
assert((_surface->pitch % 4) == 0);
|
assert((_surface.pitch % 4) == 0);
|
||||||
|
|
||||||
const uint32 startByte = _ctx._gb->pos() / 8;
|
const uint32 startByte = _ctx._gb->pos() / 8;
|
||||||
|
|
||||||
|
@ -788,7 +788,7 @@ int Indeo4Decoder::decodeTransparency() {
|
||||||
// It should only be necessary to draw transparency here since the
|
// It should only be necessary to draw transparency here since the
|
||||||
// data from the YUV planes gets drawn to the output surface on each
|
// data from the YUV planes gets drawn to the output surface on each
|
||||||
// frame, which resets the surface pixels to be fully opaque
|
// frame, which resets the surface pixels to be fully opaque
|
||||||
_surface->fillRect(Common::Rect(_surface->w, _surface->h), 0);
|
_surface.fillRect(Common::Rect(_surface.w, _surface.h), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No alignment here
|
// No alignment here
|
||||||
|
|
|
@ -97,7 +97,7 @@ const Graphics::Surface *Indeo5Decoder::decodeFrame(Common::SeekableReadStream &
|
||||||
_ctx._frameData = nullptr;
|
_ctx._frameData = nullptr;
|
||||||
_ctx._frameSize = 0;
|
_ctx._frameSize = 0;
|
||||||
|
|
||||||
return (err < 0) ? nullptr : _surface;
|
return (err < 0) ? nullptr : &_surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Indeo5Decoder::decodePictureHeader() {
|
int Indeo5Decoder::decodePictureHeader() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue