summaryrefslogtreecommitdiff
path: root/chromium/third_party/webrtc/common_video/libyuv/webrtc_libyuv.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/webrtc/common_video/libyuv/webrtc_libyuv.cc')
-rw-r--r--chromium/third_party/webrtc/common_video/libyuv/webrtc_libyuv.cc81
1 files changed, 21 insertions, 60 deletions
diff --git a/chromium/third_party/webrtc/common_video/libyuv/webrtc_libyuv.cc b/chromium/third_party/webrtc/common_video/libyuv/webrtc_libyuv.cc
index 0094525b5c0..65b4d0c5cd8 100644
--- a/chromium/third_party/webrtc/common_video/libyuv/webrtc_libyuv.cc
+++ b/chromium/third_party/webrtc/common_video/libyuv/webrtc_libyuv.cc
@@ -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);
}
@@ -173,15 +176,15 @@ int ConvertRGB24ToARGB(const uint8_t* src_frame, uint8_t* dst_frame,
width, height);
}
-libyuv::RotationMode ConvertRotationMode(VideoRotationMode rotation) {
+libyuv::RotationMode ConvertRotationMode(VideoRotation rotation) {
switch(rotation) {
- case kRotateNone:
+ case kVideoRotation_0:
return libyuv::kRotate0;
- case kRotate90:
+ case kVideoRotation_90:
return libyuv::kRotate90;
- case kRotate180:
+ case kVideoRotation_180:
return libyuv::kRotate180;
- case kRotate270:
+ case kVideoRotation_270:
return libyuv::kRotate270;
}
assert(false);
@@ -228,16 +231,18 @@ int ConvertVideoType(VideoType video_type) {
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,
- VideoRotationMode rotation,
+ int crop_x,
+ int crop_y,
+ int src_width,
+ int src_height,
+ size_t sample_size,
+ VideoRotation rotation,
I420VideoFrame* dst_frame) {
int dst_width = dst_frame->width();
int dst_height = dst_frame->height();
// LibYuv expects pre-rotation values for dst.
// Stride values should correspond to the destination values.
- if (rotation == kRotate90 || rotation == kRotate270) {
+ if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) {
dst_width = dst_frame->height();
dst_height =dst_frame->width();
}
@@ -285,50 +290,6 @@ int ConvertFromYV12(const I420VideoFrame& src_frame,
ConvertVideoType(dst_video_type));
}
-int MirrorI420LeftRight(const I420VideoFrame* src_frame,
- I420VideoFrame* dst_frame) {
- // Source and destination frames should have equal resolution.
- if (src_frame->width() != dst_frame->width() ||
- src_frame->height() != dst_frame->height())
- return -1;
- return libyuv::I420Mirror(src_frame->buffer(kYPlane),
- src_frame->stride(kYPlane),
- src_frame->buffer(kUPlane),
- src_frame->stride(kUPlane),
- src_frame->buffer(kVPlane),
- src_frame->stride(kVPlane),
- dst_frame->buffer(kYPlane),
- dst_frame->stride(kYPlane),
- dst_frame->buffer(kUPlane),
- dst_frame->stride(kUPlane),
- dst_frame->buffer(kVPlane),
- dst_frame->stride(kVPlane),
- src_frame->width(), src_frame->height());
-}
-
-int MirrorI420UpDown(const I420VideoFrame* src_frame,
- I420VideoFrame* dst_frame) {
- // Source and destination frames should have equal resolution
- if (src_frame->width() != dst_frame->width() ||
- src_frame->height() != dst_frame->height())
- return -1;
-
- // Inserting negative height flips the frame.
- return libyuv::I420Copy(src_frame->buffer(kYPlane),
- src_frame->stride(kYPlane),
- src_frame->buffer(kUPlane),
- src_frame->stride(kUPlane),
- src_frame->buffer(kVPlane),
- src_frame->stride(kVPlane),
- dst_frame->buffer(kYPlane),
- dst_frame->stride(kYPlane),
- dst_frame->buffer(kUPlane),
- dst_frame->stride(kUPlane),
- dst_frame->buffer(kVPlane),
- dst_frame->stride(kVPlane),
- src_frame->width(), -(src_frame->height()));
-}
-
// Compute PSNR for an I420 frame (all planes)
double I420PSNR(const I420VideoFrame* ref_frame,
const I420VideoFrame* test_frame) {