Skip to content

Commit

Permalink
vp8: Updating wrapper to use CalcBufferSize (includes odd size support).
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mikhal@webrtc.org committed Jul 11, 2012
1 parent 538f0ab commit 6182db1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/modules/video_coding/codecs/vp8/main/source/vp8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <string.h>
#include <time.h>

#include "common_video/libyuv/include/libyuv.h"
#include "module_common_types.h"
#include "reference_picture_selection.h"
#include "temporal_layers.h"
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 6182db1

Please sign in to comment.