Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information. This CL was reviewed and approved in pieces in the following CLs: https://webrtc-codereview.appspot.com/24209004/ https://webrtc-codereview.appspot.com/24229004/ https://webrtc-codereview.appspot.com/24259004/ https://webrtc-codereview.appspot.com/25109004/ https://webrtc-codereview.appspot.com/26099004/ https://webrtc-codereview.appspot.com/27069004/ https://webrtc-codereview.appspot.com/27969004/ https://webrtc-codereview.appspot.com/27989004/ https://webrtc-codereview.appspot.com/29009004/ https://webrtc-codereview.appspot.com/30929004/ https://webrtc-codereview.appspot.com/30939004/ https://webrtc-codereview.appspot.com/31999004/ Committing as TBR to the original reviewers. BUG=chromium:81439 TEST=none TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom Review URL: https://webrtc-codereview.appspot.com/23129004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -81,8 +81,8 @@ void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv);
|
||||
// - width :frame width in pixels.
|
||||
// - height :frame height in pixels.
|
||||
// Return value: :The required size in bytes to accommodate the specified
|
||||
// video frame or -1 in case of an error .
|
||||
int CalcBufferSize(VideoType type, int width, int height);
|
||||
// video frame.
|
||||
size_t CalcBufferSize(VideoType type, int width, int height);
|
||||
|
||||
// TODO(mikhal): Add unit test for these two functions and determine location.
|
||||
// Print I420VideoFrame to file
|
||||
@ -101,7 +101,7 @@ int PrintI420VideoFrame(const I420VideoFrame& frame, FILE* file);
|
||||
// - buffer : Pointer to buffer
|
||||
// Return value: length of buffer if OK, < 0 otherwise.
|
||||
int ExtractBuffer(const I420VideoFrame& input_frame,
|
||||
int size, uint8_t* buffer);
|
||||
size_t size, uint8_t* buffer);
|
||||
// Convert To I420
|
||||
// Input:
|
||||
// - src_video_type : Type of input video.
|
||||
@ -119,7 +119,7 @@ int ConvertToI420(VideoType src_video_type,
|
||||
const uint8_t* src_frame,
|
||||
int crop_x, int crop_y,
|
||||
int src_width, int src_height,
|
||||
int sample_size,
|
||||
size_t sample_size,
|
||||
VideoRotationMode rotation,
|
||||
I420VideoFrame* dst_frame);
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ class TestLibYuv : public ::testing::Test {
|
||||
const int height_;
|
||||
const int size_y_;
|
||||
const int size_uv_;
|
||||
const int frame_length_;
|
||||
const size_t frame_length_;
|
||||
};
|
||||
|
||||
TestLibYuv::TestLibYuv()
|
||||
@ -110,8 +110,8 @@ void TestLibYuv::SetUp() {
|
||||
ASSERT_TRUE(source_file_ != NULL) << "Cannot read file: "<<
|
||||
input_file_name << "\n";
|
||||
|
||||
EXPECT_EQ(fread(orig_buffer_.get(), 1, frame_length_, source_file_),
|
||||
static_cast<unsigned int>(frame_length_));
|
||||
EXPECT_EQ(frame_length_,
|
||||
fread(orig_buffer_.get(), 1, frame_length_, source_file_));
|
||||
EXPECT_EQ(0, orig_frame_.CreateFrame(size_y_, orig_buffer_.get(),
|
||||
size_uv_, orig_buffer_.get() + size_y_,
|
||||
size_uv_, orig_buffer_.get() +
|
||||
@ -206,8 +206,8 @@ TEST_F(TestLibYuv, ConvertTest) {
|
||||
width_, height_,
|
||||
width_, (width_ + 1) / 2, (width_ + 1) / 2);
|
||||
EXPECT_EQ(0, ConvertFromYV12(yv12_frame, kI420, 0, res_i420_buffer.get()));
|
||||
if (fwrite(res_i420_buffer.get(), 1, frame_length_,
|
||||
output_file) != static_cast<unsigned int>(frame_length_)) {
|
||||
if (fwrite(res_i420_buffer.get(), 1, frame_length_, output_file) !=
|
||||
frame_length_) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ class TestScaler : public ::testing::Test {
|
||||
const int half_height_;
|
||||
const int size_y_;
|
||||
const int size_uv_;
|
||||
const int frame_length_;
|
||||
const size_t frame_length_;
|
||||
};
|
||||
|
||||
TestScaler::TestScaler()
|
||||
@ -392,7 +392,7 @@ double TestScaler::ComputeAvgSequencePSNR(FILE* input_file,
|
||||
rewind(input_file);
|
||||
rewind(output_file);
|
||||
|
||||
int required_size = CalcBufferSize(kI420, width, height);
|
||||
size_t required_size = CalcBufferSize(kI420, width, height);
|
||||
uint8_t* input_buffer = new uint8_t[required_size];
|
||||
uint8_t* output_buffer = new uint8_t[required_size];
|
||||
|
||||
@ -400,12 +400,10 @@ double TestScaler::ComputeAvgSequencePSNR(FILE* input_file,
|
||||
double avg_psnr = 0;
|
||||
I420VideoFrame in_frame, out_frame;
|
||||
while (feof(input_file) == 0) {
|
||||
if ((size_t)required_size !=
|
||||
fread(input_buffer, 1, required_size, input_file)) {
|
||||
if (fread(input_buffer, 1, required_size, input_file) != required_size) {
|
||||
break;
|
||||
}
|
||||
if ((size_t)required_size !=
|
||||
fread(output_buffer, 1, required_size, output_file)) {
|
||||
if (fread(output_buffer, 1, required_size, output_file) != required_size) {
|
||||
break;
|
||||
}
|
||||
frame_count++;
|
||||
@ -441,15 +439,15 @@ void TestScaler::ScaleSequence(ScaleMethod method,
|
||||
int64_t start_clock, total_clock;
|
||||
total_clock = 0;
|
||||
int frame_count = 0;
|
||||
int src_required_size = CalcBufferSize(kI420, src_width, src_height);
|
||||
size_t src_required_size = CalcBufferSize(kI420, src_width, src_height);
|
||||
scoped_ptr<uint8_t[]> frame_buffer(new uint8_t[src_required_size]);
|
||||
int size_y = src_width * src_height;
|
||||
int size_uv = ((src_width + 1) / 2) * ((src_height + 1) / 2);
|
||||
|
||||
// Running through entire sequence.
|
||||
while (feof(source_file) == 0) {
|
||||
if ((size_t)src_required_size !=
|
||||
fread(frame_buffer.get(), 1, src_required_size, source_file))
|
||||
if (fread(frame_buffer.get(), 1, src_required_size, source_file) !=
|
||||
src_required_size)
|
||||
break;
|
||||
|
||||
input_frame.CreateFrame(size_y, frame_buffer.get(),
|
||||
|
||||
@ -66,8 +66,10 @@ void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv) {
|
||||
*stride_uv = AlignInt((width + 1) / 2, k16ByteAlignment);
|
||||
}
|
||||
|
||||
int CalcBufferSize(VideoType type, int width, int height) {
|
||||
int buffer_size = 0;
|
||||
size_t CalcBufferSize(VideoType type, int width, int height) {
|
||||
assert(width >= 0);
|
||||
assert(height >= 0);
|
||||
size_t buffer_size = 0;
|
||||
switch (type) {
|
||||
case kI420:
|
||||
case kNV12:
|
||||
@ -95,7 +97,7 @@ int CalcBufferSize(VideoType type, int width, int height) {
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
return buffer_size;
|
||||
}
|
||||
@ -122,11 +124,12 @@ int PrintI420VideoFrame(const I420VideoFrame& frame, FILE* file) {
|
||||
}
|
||||
|
||||
int ExtractBuffer(const I420VideoFrame& input_frame,
|
||||
int size, uint8_t* buffer) {
|
||||
size_t size, uint8_t* buffer) {
|
||||
assert(buffer);
|
||||
if (input_frame.IsZeroSize())
|
||||
return -1;
|
||||
int length = CalcBufferSize(kI420, input_frame.width(), input_frame.height());
|
||||
size_t length =
|
||||
CalcBufferSize(kI420, input_frame.width(), input_frame.height());
|
||||
if (size < length) {
|
||||
return -1;
|
||||
}
|
||||
@ -147,7 +150,7 @@ int ExtractBuffer(const I420VideoFrame& input_frame,
|
||||
plane_ptr += input_frame.stride(static_cast<PlaneType>(plane));
|
||||
}
|
||||
}
|
||||
return length;
|
||||
return static_cast<int>(length);
|
||||
}
|
||||
|
||||
|
||||
@ -230,7 +233,7 @@ int ConvertToI420(VideoType src_video_type,
|
||||
const uint8_t* src_frame,
|
||||
int crop_x, int crop_y,
|
||||
int src_width, int src_height,
|
||||
int sample_size,
|
||||
size_t sample_size,
|
||||
VideoRotationMode rotation,
|
||||
I420VideoFrame* dst_frame) {
|
||||
int dst_width = dst_frame->width();
|
||||
|
||||
Reference in New Issue
Block a user