diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-17 13:57:45 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-19 13:44:40 +0000 |
commit | 6ec7b8da05d21a3878bd21c691b41e675d74bb1c (patch) | |
tree | b87f250bc19413750b9bb9cdbf2da20ef5014820 /chromium/third_party/webrtc/common_video | |
parent | ec02ee4181c49b61fce1c8fb99292dbb8139cc90 (diff) | |
download | qtwebengine-chromium-6ec7b8da05d21a3878bd21c691b41e675d74bb1c.tar.gz |
BASELINE: Update Chromium to 60.0.3112.70
Change-Id: I9911c2280a014d4632f254857876a395d4baed2d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/third_party/webrtc/common_video')
15 files changed, 175 insertions, 401 deletions
diff --git a/chromium/third_party/webrtc/common_video/BUILD.gn b/chromium/third_party/webrtc/common_video/BUILD.gn index 152f98b089f..043e19da49d 100644 --- a/chromium/third_party/webrtc/common_video/BUILD.gn +++ b/chromium/third_party/webrtc/common_video/BUILD.gn @@ -36,6 +36,7 @@ rtc_static_library("common_video") { "include/i420_buffer_pool.h", "include/incoming_video_stream.h", "include/video_bitrate_allocator.h", + "include/video_frame.h", "include/video_frame_buffer.h", "incoming_video_stream.cc", "libyuv/include/webrtc_libyuv.h", @@ -59,6 +60,7 @@ rtc_static_library("common_video") { "..:webrtc_common", "../base:rtc_base", "../base:rtc_task_queue", + "../modules:module_api", "../system_wrappers", ] public_deps = [ @@ -72,14 +74,6 @@ rtc_static_library("common_video") { # Need to add a directory normally exported by libyuv. include_dirs += [ "$rtc_libyuv_dir/include" ] } - - if (is_ios || is_mac) { - sources += [ - "corevideo_frame_buffer.cc", - "include/corevideo_frame_buffer.h", - ] - libs = [ "CoreVideo.framework" ] - } } if (rtc_include_tests) { diff --git a/chromium/third_party/webrtc/common_video/DEPS b/chromium/third_party/webrtc/common_video/DEPS index ad03e661693..7dbbdb4f959 100644 --- a/chromium/third_party/webrtc/common_video/DEPS +++ b/chromium/third_party/webrtc/common_video/DEPS @@ -2,4 +2,6 @@ include_rules = [ "+webrtc/base", "+webrtc/media/base", "+webrtc/system_wrappers", + # TODO(magjed): This is temporary, remove once external clients are updated. + "+webrtc/sdk/objc", ] diff --git a/chromium/third_party/webrtc/common_video/corevideo_frame_buffer.cc b/chromium/third_party/webrtc/common_video/corevideo_frame_buffer.cc deleted file mode 100644 index 6455ed18f01..00000000000 --- a/chromium/third_party/webrtc/common_video/corevideo_frame_buffer.cc +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2016 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/common_video/include/corevideo_frame_buffer.h" - -#include "libyuv/convert.h" -#include "webrtc/base/checks.h" -#include "webrtc/base/logging.h" -#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" - -namespace webrtc { - -CoreVideoFrameBuffer::CoreVideoFrameBuffer(CVPixelBufferRef pixel_buffer, - int adapted_width, - int adapted_height, - int crop_width, - int crop_height, - int crop_x, - int crop_y) - : NativeHandleBuffer(pixel_buffer, adapted_width, adapted_height), - pixel_buffer_(pixel_buffer), - buffer_width_(CVPixelBufferGetWidth(pixel_buffer)), - buffer_height_(CVPixelBufferGetHeight(pixel_buffer)), - crop_width_(crop_width), crop_height_(crop_height), - // Can only crop at even pixels. - crop_x_(crop_x & ~1), crop_y_(crop_y & ~1) { - CVBufferRetain(pixel_buffer_); -} - -CoreVideoFrameBuffer::CoreVideoFrameBuffer(CVPixelBufferRef pixel_buffer) - : NativeHandleBuffer(pixel_buffer, - CVPixelBufferGetWidth(pixel_buffer), - CVPixelBufferGetHeight(pixel_buffer)), - pixel_buffer_(pixel_buffer), - buffer_width_(width_), buffer_height_(height_), - crop_width_(width_), crop_height_(height_), - crop_x_(0), crop_y_(0) { - CVBufferRetain(pixel_buffer_); -} - -CoreVideoFrameBuffer::~CoreVideoFrameBuffer() { - CVBufferRelease(pixel_buffer_); -} - -rtc::scoped_refptr<VideoFrameBuffer> -CoreVideoFrameBuffer::NativeToI420Buffer() { - const OSType pixel_format = CVPixelBufferGetPixelFormatType(pixel_buffer_); - RTC_DCHECK(pixel_format == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange || - pixel_format == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange); - - CVPixelBufferLockBaseAddress(pixel_buffer_, kCVPixelBufferLock_ReadOnly); - const uint8_t* src_y = static_cast<const uint8_t*>( - CVPixelBufferGetBaseAddressOfPlane(pixel_buffer_, 0)); - const int src_y_stride = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer_, 0); - const uint8_t* src_uv = static_cast<const uint8_t*>( - CVPixelBufferGetBaseAddressOfPlane(pixel_buffer_, 1)); - const int src_uv_stride = - CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer_, 1); - - // Crop just by modifying pointers. - src_y += src_y_stride * crop_y_ + crop_x_; - src_uv += src_uv_stride * (crop_y_ / 2) + crop_x_; - - // TODO(magjed): Use a frame buffer pool. - NV12ToI420Scaler nv12_to_i420_scaler; - rtc::scoped_refptr<I420Buffer> buffer = - new rtc::RefCountedObject<I420Buffer>(width_, height_); - nv12_to_i420_scaler.NV12ToI420Scale( - src_y, src_y_stride, - src_uv, src_uv_stride, - crop_width_, crop_height_, - buffer->MutableDataY(), buffer->StrideY(), - buffer->MutableDataU(), buffer->StrideU(), - buffer->MutableDataV(), buffer->StrideV(), - buffer->width(), buffer->height()); - - CVPixelBufferUnlockBaseAddress(pixel_buffer_, kCVPixelBufferLock_ReadOnly); - - return buffer; -} - -bool CoreVideoFrameBuffer::RequiresCropping() const { - return crop_width_ != buffer_width_ || crop_height_ != buffer_height_; -} - -bool CoreVideoFrameBuffer::CropAndScaleTo( - std::vector<uint8_t>* tmp_buffer, - CVPixelBufferRef output_pixel_buffer) const { - // Prepare output pointers. - RTC_DCHECK_EQ(CVPixelBufferGetPixelFormatType(output_pixel_buffer), - kCVPixelFormatType_420YpCbCr8BiPlanarFullRange); - CVReturn cv_ret = CVPixelBufferLockBaseAddress(output_pixel_buffer, 0); - if (cv_ret != kCVReturnSuccess) { - LOG(LS_ERROR) << "Failed to lock base address: " << cv_ret; - return false; - } - const int dst_width = CVPixelBufferGetWidth(output_pixel_buffer); - const int dst_height = CVPixelBufferGetHeight(output_pixel_buffer); - uint8_t* dst_y = reinterpret_cast<uint8_t*>( - CVPixelBufferGetBaseAddressOfPlane(output_pixel_buffer, 0)); - const int dst_y_stride = - CVPixelBufferGetBytesPerRowOfPlane(output_pixel_buffer, 0); - uint8_t* dst_uv = reinterpret_cast<uint8_t*>( - CVPixelBufferGetBaseAddressOfPlane(output_pixel_buffer, 1)); - const int dst_uv_stride = - CVPixelBufferGetBytesPerRowOfPlane(output_pixel_buffer, 1); - - // Prepare source pointers. - const OSType src_pixel_format = - CVPixelBufferGetPixelFormatType(pixel_buffer_); - RTC_DCHECK( - src_pixel_format == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange || - src_pixel_format == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange); - CVPixelBufferLockBaseAddress(pixel_buffer_, kCVPixelBufferLock_ReadOnly); - const uint8_t* src_y = static_cast<const uint8_t*>( - CVPixelBufferGetBaseAddressOfPlane(pixel_buffer_, 0)); - const int src_y_stride = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer_, 0); - const uint8_t* src_uv = static_cast<const uint8_t*>( - CVPixelBufferGetBaseAddressOfPlane(pixel_buffer_, 1)); - const int src_uv_stride = - CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer_, 1); - - // Crop just by modifying pointers. - src_y += src_y_stride * crop_y_ + crop_x_; - src_uv += src_uv_stride * (crop_y_ / 2) + crop_x_; - - NV12Scale(tmp_buffer, - src_y, src_y_stride, - src_uv, src_uv_stride, - crop_width_, crop_height_, - dst_y, dst_y_stride, - dst_uv, dst_uv_stride, - dst_width, dst_height); - - CVPixelBufferUnlockBaseAddress(pixel_buffer_, kCVPixelBufferLock_ReadOnly); - CVPixelBufferUnlockBaseAddress(output_pixel_buffer, 0); - - return true; -} - -} // namespace webrtc diff --git a/chromium/third_party/webrtc/common_video/h264/sps_vui_rewriter.cc b/chromium/third_party/webrtc/common_video/h264/sps_vui_rewriter.cc index 2e118d5233b..534e75c8658 100644 --- a/chromium/third_party/webrtc/common_video/h264/sps_vui_rewriter.cc +++ b/chromium/third_party/webrtc/common_video/h264/sps_vui_rewriter.cc @@ -18,6 +18,7 @@ #include "webrtc/base/bitbuffer.h" #include "webrtc/base/checks.h" #include "webrtc/base/logging.h" +#include "webrtc/base/safe_minmax.h" #include "webrtc/common_video/h264/h264_common.h" #include "webrtc/common_video/h264/sps_parser.h" @@ -351,8 +352,7 @@ bool CopyRemainingBits(rtc::BitBuffer* source, COPY_BITS(source, destination, bits_tmp, misaligned_bits); } while (source->RemainingBitCount() > 0) { - size_t count = std::min(static_cast<size_t>(32u), - static_cast<size_t>(source->RemainingBitCount())); + auto count = rtc::SafeMin<size_t>(32u, source->RemainingBitCount()); COPY_BITS(source, destination, bits_tmp, count); } // TODO(noahric): The last byte could be all zeroes now, which we should just diff --git a/chromium/third_party/webrtc/common_video/i420_video_frame_unittest.cc b/chromium/third_party/webrtc/common_video/i420_video_frame_unittest.cc index 8c97ca7ac4c..f3ee9314c7c 100644 --- a/chromium/third_party/webrtc/common_video/i420_video_frame_unittest.cc +++ b/chromium/third_party/webrtc/common_video/i420_video_frame_unittest.cc @@ -12,6 +12,7 @@ #include <string.h> #include "webrtc/api/video/video_frame.h" +#include "webrtc/api/video/i420_buffer.h" #include "webrtc/base/bind.h" #include "webrtc/base/timeutils.h" #include "webrtc/test/fake_texture_frame.h" @@ -291,20 +292,4 @@ INSTANTIATE_TEST_CASE_P(Rotate, TestI420BufferRotate, kVideoRotation_180, kVideoRotation_270)); -class TestI420BufferRotateOld - : public ::testing::TestWithParam<webrtc::VideoRotation> {}; - -TEST_P(TestI420BufferRotateOld, Rotates) { - rtc::scoped_refptr<VideoFrameBuffer> buffer = CreateGradient(640, 480); - rtc::scoped_refptr<VideoFrameBuffer> rotated_buffer = - I420Buffer::Rotate(buffer, GetParam()); - CheckRotate(640, 480, GetParam(), *rotated_buffer); -} - -INSTANTIATE_TEST_CASE_P(Rotate, TestI420BufferRotateOld, - ::testing::Values(kVideoRotation_0, - kVideoRotation_90, - kVideoRotation_180, - kVideoRotation_270)); - } // namespace webrtc diff --git a/chromium/third_party/webrtc/common_video/include/corevideo_frame_buffer.h b/chromium/third_party/webrtc/common_video/include/corevideo_frame_buffer.h index a00b6770ffb..44ef1db0c5d 100644 --- a/chromium/third_party/webrtc/common_video/include/corevideo_frame_buffer.h +++ b/chromium/third_party/webrtc/common_video/include/corevideo_frame_buffer.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 The WebRTC project authors. All Rights Reserved. + * Copyright 2017 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -8,52 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ +// TODO(magjed): Remove this file once external clients are updated. #ifndef WEBRTC_COMMON_VIDEO_INCLUDE_COREVIDEO_FRAME_BUFFER_H_ #define WEBRTC_COMMON_VIDEO_INCLUDE_COREVIDEO_FRAME_BUFFER_H_ -#include <CoreVideo/CoreVideo.h> - -#include <vector> - -#include "webrtc/common_video/include/video_frame_buffer.h" - -namespace webrtc { - -class CoreVideoFrameBuffer : public NativeHandleBuffer { - public: - explicit CoreVideoFrameBuffer(CVPixelBufferRef pixel_buffer); - CoreVideoFrameBuffer(CVPixelBufferRef pixel_buffer, - int adapted_width, - int adapted_height, - int crop_width, - int crop_height, - int crop_x, - int crop_y); - ~CoreVideoFrameBuffer() override; - - rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; - // Returns true if the internal pixel buffer needs to be cropped. - bool RequiresCropping() const; - // Crop and scales the internal pixel buffer to the output pixel buffer. The - // tmp buffer is used for intermediary splitting the UV channels. This - // function returns true if successful. - bool CropAndScaleTo(std::vector<uint8_t>* tmp_buffer, - CVPixelBufferRef output_pixel_buffer) const; - - private: - CVPixelBufferRef pixel_buffer_; - // buffer_width/height is the actual pixel buffer resolution. The width/height - // in NativeHandleBuffer, i.e. width()/height(), is the resolution we will - // scale to in NativeToI420Buffer(). Cropping happens before scaling, so: - // buffer_width >= crop_width >= width(). - const int buffer_width_; - const int buffer_height_; - const int crop_width_; - const int crop_height_; - const int crop_x_; - const int crop_y_; -}; - -} // namespace webrtc +#include "webrtc/sdk/objc/Framework/Classes/corevideo_frame_buffer.h" #endif // WEBRTC_COMMON_VIDEO_INCLUDE_COREVIDEO_FRAME_BUFFER_H_ diff --git a/chromium/third_party/webrtc/common_video/include/video_frame.h b/chromium/third_party/webrtc/common_video/include/video_frame.h new file mode 100644 index 00000000000..1e8f37c171c --- /dev/null +++ b/chromium/third_party/webrtc/common_video/include/video_frame.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_H_ +#define WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_H_ + +// TODO(nisse): This header file should eventually be deleted. The +// EncodedImage class stays in this file until we have figured out how +// to refactor and clean up related interfaces, at which point it +// should be moved to somewhere under api/. + +#include "webrtc/common_types.h" +#include "webrtc/typedefs.h" + +namespace webrtc { + +// TODO(pbos): Rename EncodedFrame and reformat this class' members. +class EncodedImage { + public: + static const size_t kBufferPaddingBytesH264; + + // Some decoders require encoded image buffers to be padded with a small + // number of additional bytes (due to over-reading byte readers). + static size_t GetBufferPaddingBytes(VideoCodecType codec_type); + + EncodedImage() : EncodedImage(nullptr, 0, 0) {} + + EncodedImage(uint8_t* buffer, size_t length, size_t size) + : _buffer(buffer), _length(length), _size(size) {} + + // TODO(kthelgason): get rid of this struct as it only has a single member + // remaining. + struct AdaptReason { + AdaptReason() : bw_resolutions_disabled(-1) {} + int bw_resolutions_disabled; // Number of resolutions that are not sent + // due to bandwidth for this frame. + // Or -1 if information is not provided. + }; + uint32_t _encodedWidth = 0; + uint32_t _encodedHeight = 0; + uint32_t _timeStamp = 0; + // NTP time of the capture time in local timebase in milliseconds. + int64_t ntp_time_ms_ = 0; + int64_t capture_time_ms_ = 0; + FrameType _frameType = kVideoFrameDelta; + uint8_t* _buffer; + size_t _length; + size_t _size; + VideoRotation rotation_ = kVideoRotation_0; + VideoContentType content_type_ = VideoContentType::UNSPECIFIED; + bool _completeFrame = false; + AdaptReason adapt_reason_; + int qp_ = -1; // Quantizer value. + + // When an application indicates non-zero values here, it is taken as an + // indication that all future frames will be constrained with those limits + // until the application indicates a change again. + PlayoutDelay playout_delay_ = {-1, -1}; +}; + +} // namespace webrtc + +#endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_H_ diff --git a/chromium/third_party/webrtc/common_video/include/video_frame_buffer.h b/chromium/third_party/webrtc/common_video/include/video_frame_buffer.h index dfdd480b5dc..7e2fcf99e1f 100644 --- a/chromium/third_party/webrtc/common_video/include/video_frame_buffer.h +++ b/chromium/third_party/webrtc/common_video/include/video_frame_buffer.h @@ -14,9 +14,6 @@ #include <memory> #include "webrtc/api/video/video_frame_buffer.h" -// TODO(nisse): For backwards compatibility, files including this file -// expect it to declare I420Buffer. Delete after callers are updated. -#include "webrtc/api/video/i420_buffer.h" #include "webrtc/base/callback.h" #include "webrtc/base/scoped_ref_ptr.h" @@ -30,6 +27,7 @@ class NativeHandleBuffer : public VideoFrameBuffer { public: NativeHandleBuffer(void* native_handle, int width, int height); + Type type() const override; int width() const override; int height() const override; const uint8_t* DataY() const override; @@ -47,7 +45,7 @@ class NativeHandleBuffer : public VideoFrameBuffer { const int height_; }; -class WrappedI420Buffer : public webrtc::VideoFrameBuffer { +class WrappedI420Buffer : public PlanarYuvBuffer { public: WrappedI420Buffer(int width, int height, @@ -58,6 +56,8 @@ class WrappedI420Buffer : public webrtc::VideoFrameBuffer { const uint8_t* v_plane, int v_stride, const rtc::Callback0<void>& no_longer_used); + Type type() const override; + int width() const override; int height() const override; @@ -68,10 +68,6 @@ class WrappedI420Buffer : public webrtc::VideoFrameBuffer { int StrideU() const override; int StrideV() const override; - void* native_handle() const override; - - rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; - private: friend class rtc::RefCountedObject<WrappedI420Buffer>; ~WrappedI420Buffer() override; diff --git a/chromium/third_party/webrtc/common_video/include/video_image.h b/chromium/third_party/webrtc/common_video/include/video_image.h deleted file mode 100644 index 4a6e451c0f3..00000000000 --- a/chromium/third_party/webrtc/common_video/include/video_image.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_IMAGE_H_ -#define WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_IMAGE_H_ - -// TODO(pbos): Remove this file and include webrtc/video_frame.h instead. -#include "webrtc/video_frame.h" - -#endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_IMAGE_H_ diff --git a/chromium/third_party/webrtc/common_video/libyuv/include/webrtc_libyuv.h b/chromium/third_party/webrtc/common_video/libyuv/include/webrtc_libyuv.h index 6d7ed1fd02d..0924f68b4f5 100644 --- a/chromium/third_party/webrtc/common_video/libyuv/include/webrtc_libyuv.h +++ b/chromium/third_party/webrtc/common_video/libyuv/include/webrtc_libyuv.h @@ -19,39 +19,19 @@ #include <vector> #include "webrtc/api/video/video_frame.h" -#include "webrtc/common_types.h" // RawVideoTypes. +#include "webrtc/common_types.h" // VideoTypes. #include "webrtc/typedefs.h" namespace webrtc { class I420Buffer; -// Supported video types. -enum VideoType { - kUnknown, - kI420, - kIYUV, - kRGB24, - kABGR, - kARGB, - kARGB4444, - kRGB565, - kARGB1555, - kYUY2, - kYV12, - kUYVY, - kMJPG, - kNV21, - kNV12, - kBGRA, -}; - // This is the max PSNR value our algorithms can return. const double kPerfectPSNR = 48.0f; -// Conversion between the RawVideoType and the LibYuv videoType. -// TODO(wu): Consolidate types into one type throughout WebRtc. -VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type); +// TODO(nisse): Some downstream apps call CalcBufferSize with +// ::webrtc::kI420 as the first argument. Delete after they are updated. +const VideoType kI420 = VideoType::kI420; // Calculate the required buffer size. // Input: @@ -150,6 +130,8 @@ void NV12Scale(std::vector<uint8_t>* tmp_buffer, // than separate NV12->I420 + I420->I420 scaling. class NV12ToI420Scaler { public: + NV12ToI420Scaler(); + ~NV12ToI420Scaler(); void NV12ToI420Scale(const uint8_t* src_y, int src_stride_y, const uint8_t* src_uv, int src_stride_uv, int src_width, int src_height, diff --git a/chromium/third_party/webrtc/common_video/libyuv/libyuv_unittest.cc b/chromium/third_party/webrtc/common_video/libyuv/libyuv_unittest.cc index 8f421f3038d..c60085c3604 100644 --- a/chromium/third_party/webrtc/common_video/libyuv/libyuv_unittest.cc +++ b/chromium/third_party/webrtc/common_video/libyuv/libyuv_unittest.cc @@ -53,7 +53,7 @@ TestLibYuv::TestLibYuv() height_(288), size_y_(width_ * height_), size_uv_(((width_ + 1) / 2) * ((height_ + 1) / 2)), - frame_length_(CalcBufferSize(kI420, 352, 288)) {} + frame_length_(CalcBufferSize(VideoType::kI420, 352, 288)) {} void TestLibYuv::SetUp() { const std::string input_file_name = webrtc::test::ResourcePath("foreman_cif", @@ -94,10 +94,11 @@ TEST_F(TestLibYuv, ConvertTest) { printf("\nConvert #%d I420 <-> I420 \n", j); std::unique_ptr<uint8_t[]> out_i420_buffer(new uint8_t[frame_length_]); - EXPECT_EQ(0, ConvertFromI420(*orig_frame_, kI420, 0, out_i420_buffer.get())); - EXPECT_EQ(0, ConvertToI420(kI420, out_i420_buffer.get(), 0, 0, width_, - height_, 0, kVideoRotation_0, - res_i420_buffer.get())); + EXPECT_EQ(0, ConvertFromI420(*orig_frame_, VideoType::kI420, 0, + out_i420_buffer.get())); + EXPECT_EQ(0, + ConvertToI420(VideoType::kI420, out_i420_buffer.get(), 0, 0, width_, + height_, 0, kVideoRotation_0, res_i420_buffer.get())); if (PrintVideoFrame(*res_i420_buffer, output_file) < 0) { return; @@ -114,11 +115,12 @@ TEST_F(TestLibYuv, ConvertTest) { Calc16ByteAlignedStride(width_, &stride_y, &stride_uv); res_i420_buffer = I420Buffer::Create(width_, height_, stride_y, stride_uv, stride_uv); - EXPECT_EQ(0, ConvertFromI420(*orig_frame_, kRGB24, 0, res_rgb_buffer2.get())); + EXPECT_EQ(0, ConvertFromI420(*orig_frame_, VideoType::kRGB24, 0, + res_rgb_buffer2.get())); - EXPECT_EQ(0, ConvertToI420(kRGB24, res_rgb_buffer2.get(), 0, 0, width_, - height_, 0, kVideoRotation_0, - res_i420_buffer.get())); + EXPECT_EQ( + 0, ConvertToI420(VideoType::kRGB24, res_rgb_buffer2.get(), 0, 0, width_, + height_, 0, kVideoRotation_0, res_i420_buffer.get())); if (PrintVideoFrame(*res_i420_buffer, output_file) < 0) { return; @@ -131,10 +133,11 @@ TEST_F(TestLibYuv, ConvertTest) { printf("\nConvert #%d I420 <-> UYVY\n", j); std::unique_ptr<uint8_t[]> out_uyvy_buffer(new uint8_t[width_ * height_ * 2]); - EXPECT_EQ(0, ConvertFromI420(*orig_frame_, kUYVY, 0, out_uyvy_buffer.get())); - EXPECT_EQ(0, ConvertToI420(kUYVY, out_uyvy_buffer.get(), 0, 0, width_, - height_, 0, kVideoRotation_0, - res_i420_buffer.get())); + EXPECT_EQ(0, ConvertFromI420(*orig_frame_, VideoType::kUYVY, 0, + out_uyvy_buffer.get())); + EXPECT_EQ(0, + ConvertToI420(VideoType::kUYVY, out_uyvy_buffer.get(), 0, 0, width_, + height_, 0, kVideoRotation_0, res_i420_buffer.get())); psnr = I420PSNR(*orig_frame_->video_frame_buffer(), *res_i420_buffer); EXPECT_EQ(48.0, psnr); if (PrintVideoFrame(*res_i420_buffer, output_file) < 0) { @@ -144,11 +147,12 @@ TEST_F(TestLibYuv, ConvertTest) { printf("\nConvert #%d I420 <-> YUY2\n", j); std::unique_ptr<uint8_t[]> out_yuy2_buffer(new uint8_t[width_ * height_ * 2]); - EXPECT_EQ(0, ConvertFromI420(*orig_frame_, kYUY2, 0, out_yuy2_buffer.get())); + EXPECT_EQ(0, ConvertFromI420(*orig_frame_, VideoType::kYUY2, 0, + out_yuy2_buffer.get())); - EXPECT_EQ(0, ConvertToI420(kYUY2, out_yuy2_buffer.get(), 0, 0, width_, - height_, 0, - kVideoRotation_0, res_i420_buffer.get())); + EXPECT_EQ(0, + ConvertToI420(VideoType::kYUY2, out_yuy2_buffer.get(), 0, 0, width_, + height_, 0, kVideoRotation_0, res_i420_buffer.get())); if (PrintVideoFrame(*res_i420_buffer, output_file) < 0) { return; @@ -160,12 +164,12 @@ TEST_F(TestLibYuv, ConvertTest) { printf("\nConvert #%d I420 <-> RGB565\n", j); std::unique_ptr<uint8_t[]> out_rgb565_buffer( new uint8_t[width_ * height_ * 2]); - EXPECT_EQ(0, - ConvertFromI420(*orig_frame_, kRGB565, 0, out_rgb565_buffer.get())); + EXPECT_EQ(0, ConvertFromI420(*orig_frame_, VideoType::kRGB565, 0, + out_rgb565_buffer.get())); - EXPECT_EQ(0, ConvertToI420(kRGB565, out_rgb565_buffer.get(), 0, 0, width_, - height_, 0, - kVideoRotation_0, res_i420_buffer.get())); + EXPECT_EQ(0, ConvertToI420(VideoType::kRGB565, out_rgb565_buffer.get(), 0, 0, + width_, height_, 0, kVideoRotation_0, + res_i420_buffer.get())); if (PrintVideoFrame(*res_i420_buffer, output_file) < 0) { return; } @@ -180,11 +184,11 @@ TEST_F(TestLibYuv, ConvertTest) { printf("\nConvert #%d I420 <-> ARGB8888\n", j); std::unique_ptr<uint8_t[]> out_argb8888_buffer( new uint8_t[width_ * height_ * 4]); - EXPECT_EQ(0, - ConvertFromI420(*orig_frame_, kARGB, 0, out_argb8888_buffer.get())); + EXPECT_EQ(0, ConvertFromI420(*orig_frame_, VideoType::kARGB, 0, + out_argb8888_buffer.get())); - EXPECT_EQ(0, ConvertToI420(kARGB, out_argb8888_buffer.get(), 0, 0, width_, - height_, 0, kVideoRotation_0, + EXPECT_EQ(0, ConvertToI420(VideoType::kARGB, out_argb8888_buffer.get(), 0, 0, + width_, height_, 0, kVideoRotation_0, res_i420_buffer.get())); if (PrintVideoFrame(*res_i420_buffer, output_file) < 0) { @@ -215,11 +219,11 @@ TEST_F(TestLibYuv, ConvertAlignedFrame) { rtc::scoped_refptr<I420Buffer> res_i420_buffer = I420Buffer::Create(width_, height_, stride_y, stride_uv, stride_uv); std::unique_ptr<uint8_t[]> out_i420_buffer(new uint8_t[frame_length_]); - EXPECT_EQ(0, ConvertFromI420(*orig_frame_, kI420, 0, + EXPECT_EQ(0, ConvertFromI420(*orig_frame_, VideoType::kI420, 0, out_i420_buffer.get())); - EXPECT_EQ(0, ConvertToI420(kI420, out_i420_buffer.get(), 0, 0, width_, - height_, 0, kVideoRotation_0, - res_i420_buffer.get())); + EXPECT_EQ(0, + ConvertToI420(VideoType::kI420, out_i420_buffer.get(), 0, 0, width_, + height_, 0, kVideoRotation_0, res_i420_buffer.get())); if (PrintVideoFrame(*res_i420_buffer, output_file) < 0) { return; @@ -242,17 +246,17 @@ TEST_F(TestLibYuv, RotateTest) { Calc16ByteAlignedStride(rotated_width, &stride_y, &stride_uv); rtc::scoped_refptr<I420Buffer> rotated_res_i420_buffer = I420Buffer::Create( rotated_width, rotated_height, stride_y, stride_uv, stride_uv); - EXPECT_EQ(0, ConvertToI420(kI420, orig_buffer, 0, 0, width_, height_, - 0, kVideoRotation_90, - rotated_res_i420_buffer.get())); - EXPECT_EQ(0, ConvertToI420(kI420, orig_buffer, 0, 0, width_, height_, - 0, kVideoRotation_270, - rotated_res_i420_buffer.get())); + EXPECT_EQ( + 0, ConvertToI420(VideoType::kI420, orig_buffer, 0, 0, width_, height_, 0, + kVideoRotation_90, rotated_res_i420_buffer.get())); + EXPECT_EQ( + 0, ConvertToI420(VideoType::kI420, orig_buffer, 0, 0, width_, height_, 0, + kVideoRotation_270, rotated_res_i420_buffer.get())); rotated_res_i420_buffer = I420Buffer::Create( width_, height_, width_, (width_ + 1) / 2, (width_ + 1) / 2); - EXPECT_EQ(0, ConvertToI420(kI420, orig_buffer, 0, 0, width_, height_, - 0, kVideoRotation_180, - rotated_res_i420_buffer.get())); + EXPECT_EQ( + 0, ConvertToI420(VideoType::kI420, orig_buffer, 0, 0, width_, height_, 0, + kVideoRotation_180, rotated_res_i420_buffer.get())); } static uint8_t Average(int a, int b, int c, int d) { 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 78cb68abd97..fd08029d1cd 100644 --- a/chromium/third_party/webrtc/common_video/libyuv/webrtc_libyuv.cc +++ b/chromium/third_party/webrtc/common_video/libyuv/webrtc_libyuv.cc @@ -21,69 +21,33 @@ namespace webrtc { -VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type) { - switch (type) { - case kVideoI420: - return kI420; - case kVideoIYUV: - return kIYUV; - case kVideoRGB24: - return kRGB24; - case kVideoARGB: - return kARGB; - case kVideoARGB4444: - return kARGB4444; - case kVideoRGB565: - return kRGB565; - case kVideoARGB1555: - return kARGB1555; - case kVideoYUY2: - return kYUY2; - case kVideoYV12: - return kYV12; - case kVideoUYVY: - return kUYVY; - case kVideoNV21: - return kNV21; - case kVideoNV12: - return kNV12; - case kVideoBGRA: - return kBGRA; - case kVideoMJPEG: - return kMJPG; - default: - RTC_NOTREACHED(); - } - return kUnknown; -} - size_t CalcBufferSize(VideoType type, int width, int height) { RTC_DCHECK_GE(width, 0); RTC_DCHECK_GE(height, 0); size_t buffer_size = 0; switch (type) { - case kI420: - case kNV12: - case kNV21: - case kIYUV: - case kYV12: { + case VideoType::kI420: + case VideoType::kNV12: + case VideoType::kNV21: + case VideoType::kIYUV: + case VideoType::kYV12: { int half_width = (width + 1) >> 1; int half_height = (height + 1) >> 1; buffer_size = width * height + half_width * half_height * 2; break; } - case kARGB4444: - case kRGB565: - case kARGB1555: - case kYUY2: - case kUYVY: + case VideoType::kARGB4444: + case VideoType::kRGB565: + case VideoType::kARGB1555: + case VideoType::kYUY2: + case VideoType::kUYVY: buffer_size = width * height * 2; break; - case kRGB24: + case VideoType::kRGB24: buffer_size = width * height * 3; break; - case kBGRA: - case kARGB: + case VideoType::kBGRA: + case VideoType::kARGB: buffer_size = width * height * 4; break; default: @@ -141,7 +105,7 @@ int ExtractBuffer(const rtc::scoped_refptr<VideoFrameBuffer>& input_frame, return -1; int width = input_frame->width(); int height = input_frame->height(); - size_t length = CalcBufferSize(kI420, width, height); + size_t length = CalcBufferSize(VideoType::kI420, width, height); if (size < length) { return -1; } @@ -207,36 +171,36 @@ libyuv::RotationMode ConvertRotationMode(VideoRotation rotation) { int ConvertVideoType(VideoType video_type) { switch (video_type) { - case kUnknown: + case VideoType::kUnknown: return libyuv::FOURCC_ANY; - case kI420: + case VideoType::kI420: return libyuv::FOURCC_I420; - case kIYUV: // same as KYV12 - case kYV12: + case VideoType::kIYUV: // same as VideoType::kYV12 + case VideoType::kYV12: return libyuv::FOURCC_YV12; - case kRGB24: + case VideoType::kRGB24: return libyuv::FOURCC_24BG; - case kABGR: + case VideoType::kABGR: return libyuv::FOURCC_ABGR; - case kRGB565: + case VideoType::kRGB565: return libyuv::FOURCC_RGBP; - case kYUY2: + case VideoType::kYUY2: return libyuv::FOURCC_YUY2; - case kUYVY: + case VideoType::kUYVY: return libyuv::FOURCC_UYVY; - case kMJPG: + case VideoType::kMJPEG: return libyuv::FOURCC_MJPG; - case kNV21: + case VideoType::kNV21: return libyuv::FOURCC_NV21; - case kNV12: + case VideoType::kNV12: return libyuv::FOURCC_NV12; - case kARGB: + case VideoType::kARGB: return libyuv::FOURCC_ARGB; - case kBGRA: + case VideoType::kBGRA: return libyuv::FOURCC_BGRA; - case kARGB4444: + case VideoType::kARGB4444: return libyuv::FOURCC_R444; - case kARGB1555: + case VideoType::kARGB1555: return libyuv::FOURCC_RGBO; } RTC_NOTREACHED(); @@ -403,6 +367,9 @@ void NV12Scale(std::vector<uint8_t>* tmp_buffer, dst_chroma_width, dst_chroma_height); } +NV12ToI420Scaler::NV12ToI420Scaler() = default; +NV12ToI420Scaler::~NV12ToI420Scaler() = default; + void NV12ToI420Scaler::NV12ToI420Scale( const uint8_t* src_y, int src_stride_y, const uint8_t* src_uv, int src_stride_uv, diff --git a/chromium/third_party/webrtc/common_video/rotation.h b/chromium/third_party/webrtc/common_video/rotation.h deleted file mode 100644 index f01c8129446..00000000000 --- a/chromium/third_party/webrtc/common_video/rotation.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// TODO(nisse): Delete this file, once downstream code is updated. - -#ifndef WEBRTC_COMMON_VIDEO_ROTATION_H_ -#define WEBRTC_COMMON_VIDEO_ROTATION_H_ - -#include "webrtc/api/video/video_rotation.h" - -#endif // WEBRTC_COMMON_VIDEO_ROTATION_H_ diff --git a/chromium/third_party/webrtc/common_video/video_frame.cc b/chromium/third_party/webrtc/common_video/video_frame.cc index 55eb5351c37..f062b732ef2 100644 --- a/chromium/third_party/webrtc/common_video/video_frame.cc +++ b/chromium/third_party/webrtc/common_video/video_frame.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/video_frame.h" +#include "webrtc/common_video/include/video_frame.h" #include <string.h> diff --git a/chromium/third_party/webrtc/common_video/video_frame_buffer.cc b/chromium/third_party/webrtc/common_video/video_frame_buffer.cc index 4646bf491f9..0322dd1fd50 100644 --- a/chromium/third_party/webrtc/common_video/video_frame_buffer.cc +++ b/chromium/third_party/webrtc/common_video/video_frame_buffer.cc @@ -30,6 +30,10 @@ NativeHandleBuffer::NativeHandleBuffer(void* native_handle, RTC_DCHECK_GT(height, 0); } +VideoFrameBuffer::Type NativeHandleBuffer::type() const { + return Type::kNative; +} + int NativeHandleBuffer::width() const { return width_; } @@ -92,6 +96,10 @@ WrappedI420Buffer::~WrappedI420Buffer() { no_longer_used_cb_(); } +VideoFrameBuffer::Type WrappedI420Buffer::type() const { + return Type::kI420; +} + int WrappedI420Buffer::width() const { return width_; } @@ -120,13 +128,4 @@ int WrappedI420Buffer::StrideV() const { return v_stride_; } -void* WrappedI420Buffer::native_handle() const { - return nullptr; -} - -rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() { - RTC_NOTREACHED(); - return nullptr; -} - } // namespace webrtc |