I420: Updating computation of buffer size to use calcBufferSize (odd size support).

BUG=
TEST=

Review URL: https://webrtc-codereview.appspot.com/687004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2509 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2012-07-11 18:20:39 +00:00
parent 262bdedfda
commit 538f0ab96f

View File

@ -8,9 +8,13 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "i420.h"
#include "modules/video_coding/codecs/i420/main/interface/i420.h"
#include <string.h>
#include "common_video/libyuv/include/libyuv.h"
namespace webrtc
{
@ -55,8 +59,9 @@ int I420Encoder::InitEncode(const VideoCodec* codecSettings,
_encodedImage._buffer = NULL;
_encodedImage._size = 0;
}
const uint32_t newSize = (3 * codecSettings->width *
codecSettings->height) >> 1;
const uint32_t newSize = CalcBufferSize(kI420,
codecSettings->width,
codecSettings->height);
uint8_t* newBuffer = new uint8_t[newSize];
if (newBuffer == NULL) {
return WEBRTC_VIDEO_CODEC_MEMORY;
@ -93,8 +98,9 @@ int I420Encoder::Encode(const RawImage& inputImage,
_encodedImage._buffer = NULL;
_encodedImage._size = 0;
}
const uint32_t newSize = (3 * _encodedImage._encodedWidth *
_encodedImage._encodedHeight) >> 1;
const uint32_t newSize = CalcBufferSize(kI420,
_encodedImage._encodedWidth,
_encodedImage._encodedHeight);
uint8_t* newBuffer = new uint8_t[newSize];
if (newBuffer == NULL) {
return WEBRTC_VIDEO_CODEC_MEMORY;
@ -174,7 +180,7 @@ I420Decoder::Decode(const EncodedImage& inputImage,
_decodedImage._size = 0;
}
if (_decodedImage._buffer == NULL) {
const uint32_t newSize = (3*_width*_height) >> 1;
const uint32_t newSize = CalcBufferSize(kI420, _width, _height);
uint8_t* newBuffer = new uint8_t[newSize];
if (newBuffer == NULL) {
return WEBRTC_VIDEO_CODEC_MEMORY;