From 6182db10c8414f6d638b30cee5aff3f117fb45e3 Mon Sep 17 00:00:00 2001 From: "mikhal@webrtc.org" Date: Wed, 11 Jul 2012 18:43:36 +0000 Subject: [PATCH] vp8: Updating wrapper to use CalcBufferSize (includes odd size support). BUG= TEST= Review URL: https://webrtc-codereview.appspot.com/685004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2510 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/modules/video_coding/codecs/vp8/main/source/vp8.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/video_coding/codecs/vp8/main/source/vp8.cc b/src/modules/video_coding/codecs/vp8/main/source/vp8.cc index 0255dd3de..33643a54b 100644 --- a/src/modules/video_coding/codecs/vp8/main/source/vp8.cc +++ b/src/modules/video_coding/codecs/vp8/main/source/vp8.cc @@ -16,6 +16,7 @@ #include #include +#include "common_video/libyuv/include/libyuv.h" #include "module_common_types.h" #include "reference_picture_selection.h" #include "temporal_layers.h" @@ -170,7 +171,7 @@ int VP8Encoder::InitEncode(const VideoCodec* inst, if (encoded_image_._buffer != NULL) { delete [] encoded_image_._buffer; } - encoded_image_._size = (3 * codec_.width * codec_.height) >> 1; + encoded_image_._size = CalcBufferSize(kI420, codec_.width, codec_.height); encoded_image_._buffer = new uint8_t[encoded_image_._size]; encoded_image_._completeFrame = true; @@ -857,8 +858,8 @@ int VP8Decoder::ReturnFrame(const vpx_image_t* img, uint32_t timestamp) { return WEBRTC_VIDEO_CODEC_NO_OUTPUT; } - // Allocate memory for decoded image - uint32_t required_size = (3 * img->d_h * img->d_w) >> 1; + // Allocate memory for decoded image. + uint32_t required_size = CalcBufferSize(kI420, img->d_w, img->d_h); if (required_size > decoded_image_._size) { delete [] decoded_image_._buffer; decoded_image_._buffer = NULL; @@ -885,7 +886,7 @@ int VP8Decoder::ReturnFrame(const vpx_image_t* img, uint32_t timestamp) { // Set image parameters decoded_image_._height = img->d_h; decoded_image_._width = img->d_w; - decoded_image_._length = (3 * img->d_h * img->d_w) >> 1; + decoded_image_._length = CalcBufferSize(kI420, img->d_w, img->d_h); decoded_image_._timeStamp = timestamp; int ret = decode_complete_callback_->Decoded(decoded_image_); if (ret != 0)