Using Convert in lieu of ExtractBuffer: Less error prone (as we don't need to compute buffer sizes etc.). This cl is first in a series (doing all of WebRtc would make it quite a big cl). While at it, fixing a few headers.
BUG=988 Review URL: https://webrtc-codereview.appspot.com/995014 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3343 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -185,19 +185,11 @@ I420Decoder::Decode(const EncodedImage& inputImage,
|
||||
}
|
||||
// Set decoded image parameters.
|
||||
int half_width = (_width + 1) / 2;
|
||||
int half_height = (_height + 1) / 2;
|
||||
int size_y = _width * _height;
|
||||
int size_uv = half_width * half_height;
|
||||
|
||||
const uint8_t* buffer_y = inputImage._buffer;
|
||||
const uint8_t* buffer_u = buffer_y + size_y;
|
||||
const uint8_t* buffer_v = buffer_u + size_uv;
|
||||
// TODO(mikhal): Do we need an align stride?
|
||||
int ret = _decodedImage.CreateFrame(size_y, buffer_y,
|
||||
size_uv, buffer_u,
|
||||
size_uv, buffer_v,
|
||||
_width, _height,
|
||||
_width, half_width, half_width);
|
||||
_decodedImage.CreateEmptyFrame(_width, _height,
|
||||
_width, half_width, half_width);
|
||||
// Converting from buffer to plane representation.
|
||||
int ret = ConvertToI420(kI420, inputImage._buffer, 0, 0, _width, _height,
|
||||
0, kRotateNone, &_decodedImage);
|
||||
if (ret < 0) {
|
||||
return WEBRTC_VIDEO_CODEC_MEMORY;
|
||||
}
|
||||
|
||||
@ -255,6 +255,9 @@ UnitTest::Setup()
|
||||
|
||||
unsigned int frameLength = 0;
|
||||
int i=0;
|
||||
_inputVideoBuffer.CreateEmptyFrame(_inst.width, _inst.height, _inst.width,
|
||||
(_inst.width + 1) / 2,
|
||||
(_inst.width + 1) / 2);
|
||||
while (frameLength == 0)
|
||||
{
|
||||
if (i > 0)
|
||||
@ -262,13 +265,8 @@ UnitTest::Setup()
|
||||
// Insert yet another frame
|
||||
ASSERT_TRUE(fread(_refFrame, 1, _lengthSourceFrame,
|
||||
_sourceFile) == _lengthSourceFrame);
|
||||
_inputVideoBuffer.CreateFrame(size_y, _refFrame,
|
||||
size_uv, _refFrame + size_y,
|
||||
size_uv, _refFrame + size_y + size_uv,
|
||||
_inst.width, _inst.height,
|
||||
_inst.width,
|
||||
(_inst.width + 1) / 2,
|
||||
(_inst.width + 1) / 2);
|
||||
EXPECT_EQ(0, ConvertToI420(kI420, _refFrame, 0, 0, _width, _height,
|
||||
0, kRotateNone, &_inputVideoBuffer));
|
||||
_encoder->Encode(_inputVideoBuffer, NULL, NULL);
|
||||
ASSERT_TRUE(WaitForEncodedFrame() > 0);
|
||||
}
|
||||
|
||||
@ -144,11 +144,7 @@ int SequenceCoder(webrtc::test::CommandLineParser parser) {
|
||||
unsigned int length = webrtc::CalcBufferSize(webrtc::kI420, width, height);
|
||||
webrtc::scoped_array<uint8_t> frame_buffer(new uint8_t[length]);
|
||||
|
||||
int half_height = (height + 1) / 2;
|
||||
int half_width = (width + 1) / 2;
|
||||
int size_y = width * height;
|
||||
int size_uv = half_width * half_height;
|
||||
|
||||
// Set and register callbacks.
|
||||
Vp8SequenceCoderEncodeCallback encoder_callback(encoded_file);
|
||||
encoder->RegisterEncodeCompleteCallback(&encoder_callback);
|
||||
@ -159,17 +155,15 @@ int SequenceCoder(webrtc::test::CommandLineParser parser) {
|
||||
int64_t starttime = webrtc::TickTime::MillisecondTimestamp();
|
||||
int frame_cnt = 1;
|
||||
int frames_processed = 0;
|
||||
input_frame.CreateEmptyFrame(width, height, width, half_width, half_width);
|
||||
while (!feof(input_file) &&
|
||||
(num_frames == -1 || frames_processed < num_frames)) {
|
||||
if (fread(frame_buffer.get(), 1, length, input_file) != length)
|
||||
continue;
|
||||
if (frame_cnt >= start_frame) {
|
||||
input_frame.CreateFrame(size_y, frame_buffer.get(),
|
||||
size_uv, frame_buffer.get() + size_y,
|
||||
size_uv, frame_buffer.get() + size_y +
|
||||
size_uv,
|
||||
width, height,
|
||||
width, half_width, half_width);
|
||||
webrtc::ConvertToI420(webrtc::kI420, frame_buffer.get(), 0, 0,
|
||||
width, height, 0, webrtc::kRotateNone,
|
||||
&input_frame);
|
||||
encoder->Encode(input_frame, NULL, NULL);
|
||||
decoder->Decode(encoder_callback.encoded_image(), false, NULL);
|
||||
++frames_processed;
|
||||
|
||||
Reference in New Issue
Block a user