2011-11-28 18:09:41 +00:00
|
|
|
/*
|
2012-02-06 10:11:25 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-11-28 18:09:41 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
2011-11-28 18:09:41 +00:00
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <cstdint>
|
2011-11-28 18:09:41 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/video/i420_buffer.h"
|
2018-03-09 15:03:26 -08:00
|
|
|
#include "common_video/include/video_frame_buffer.h"
|
2017-12-11 09:32:13 +01:00
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "third_party/libyuv/include/libyuv.h"
|
2011-11-28 18:09:41 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
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
2014-11-20 22:28:14 +00:00
|
|
|
size_t CalcBufferSize(VideoType type, int width, int height) {
|
2016-11-29 05:30:40 -08:00
|
|
|
RTC_DCHECK_GE(width, 0);
|
|
|
|
|
RTC_DCHECK_GE(height, 0);
|
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
2014-11-20 22:28:14 +00:00
|
|
|
size_t buffer_size = 0;
|
2011-11-28 18:09:41 +00:00
|
|
|
switch (type) {
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kI420:
|
|
|
|
|
case VideoType::kIYUV:
|
|
|
|
|
case VideoType::kYV12: {
|
2012-07-10 20:48:48 +00:00
|
|
|
int half_width = (width + 1) >> 1;
|
|
|
|
|
int half_height = (height + 1) >> 1;
|
|
|
|
|
buffer_size = width * height + half_width * half_height * 2;
|
2011-11-28 18:09:41 +00:00
|
|
|
break;
|
2012-07-10 20:48:48 +00:00
|
|
|
}
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kRGB565:
|
|
|
|
|
case VideoType::kYUY2:
|
|
|
|
|
case VideoType::kUYVY:
|
2012-07-10 20:48:48 +00:00
|
|
|
buffer_size = width * height * 2;
|
2011-11-28 18:09:41 +00:00
|
|
|
break;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kRGB24:
|
2012-07-10 20:48:48 +00:00
|
|
|
buffer_size = width * height * 3;
|
2011-11-28 18:09:41 +00:00
|
|
|
break;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kBGRA:
|
|
|
|
|
case VideoType::kARGB:
|
2012-07-10 20:48:48 +00:00
|
|
|
buffer_size = width * height * 4;
|
2011-11-28 18:09:41 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
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
2014-11-20 22:28:14 +00:00
|
|
|
break;
|
2011-11-28 18:09:41 +00:00
|
|
|
}
|
2012-07-10 20:48:48 +00:00
|
|
|
return buffer_size;
|
2011-11-28 18:09:41 +00:00
|
|
|
}
|
|
|
|
|
|
2017-06-01 10:02:26 -07:00
|
|
|
int ExtractBuffer(const rtc::scoped_refptr<I420BufferInterface>& input_frame,
|
2016-06-13 13:06:01 +02:00
|
|
|
size_t size,
|
|
|
|
|
uint8_t* buffer) {
|
2016-11-29 05:30:40 -08:00
|
|
|
RTC_DCHECK(buffer);
|
2016-06-13 13:06:01 +02:00
|
|
|
if (!input_frame)
|
2012-10-24 18:33:04 +00:00
|
|
|
return -1;
|
2016-06-13 13:06:01 +02:00
|
|
|
int width = input_frame->width();
|
|
|
|
|
int height = input_frame->height();
|
2017-04-28 07:18:05 -07:00
|
|
|
size_t length = CalcBufferSize(VideoType::kI420, width, height);
|
2012-10-24 18:33:04 +00:00
|
|
|
if (size < length) {
|
2018-06-19 15:03:05 +02:00
|
|
|
return -1;
|
2012-10-24 18:33:04 +00:00
|
|
|
}
|
|
|
|
|
|
2017-06-01 10:02:26 -07:00
|
|
|
int chroma_width = input_frame->ChromaWidth();
|
|
|
|
|
int chroma_height = input_frame->ChromaHeight();
|
Reland of Delete webrtc::VideoFrame methods buffer and stride. (patchset #1 id:1 of https://codereview.webrtc.org/1983583002/ )
Reason for revert:
Should work after cl https://codereview.webrtc.org/1985693002/ is landed, which initializes the frames used by FakeWebRtcVideoCaptureModule. So intend to reland after that, with no changes.
Original issue's description:
> Revert of Delete webrtc::VideoFrame methods buffer and stride. (patchset #2 id:290001 of https://codereview.webrtc.org/1963413004/ )
>
> Reason for revert:
> Speculative revert to see if failures on the DrMemory bot are related to this cl. See e.g. here:
> https://build.chromium.org/p/client.webrtc/builders/Win%20DrMemory%20Full/builds/4243
>
> UNINITIALIZED READ: reading 0x04980040-0x04980060 32 byte(s) within 0x04980040-0x04980060
> # 0 CopyRow_AVX
> # 1 CopyPlane
> # 2 I420Copy
> # 3 webrtc::ExtractBuffer
> # 4 cricket::WebRtcVideoCapturer::SignalFrameCapturedOnStartThread
> # 5 cricket::WebRtcVideoCapturer::OnIncomingCapturedFrame
> # 6 FakeWebRtcVideoCaptureModule::SendFrame
> # 7 WebRtcVideoCapturerTest_TestCaptureVcm_Test::TestBody
> # 8 testing::internal::HandleSehExceptionsInMethodIfSupported<>
>
> Original issue's description:
> > Reland of Delete webrtc::VideoFrame methods buffer and stride. (patchset #1 id:1 of https://codereview.webrtc.org/1935443002/ )
> >
> > Reason for revert:
> > I plan to reland this change in a week or two, after downstream users are updated.
> >
> > Original issue's description:
> > > Revert of Delete webrtc::VideoFrame methods buffer and stride. (patchset #14 id:250001 of https://codereview.webrtc.org/1900673002/ )
> > >
> > > Reason for revert:
> > > Breaks chrome FYI bots.
> > >
> > > Original issue's description:
> > > > Delete webrtc::VideoFrame methods buffer and stride.
> > > >
> > > > To make the HasOneRef/IsMutable hack work, also had to change the
> > > > video_frame_buffer method to return a const ref to a scoped_ref_ptr,
> > > > to not imply an AddRef.
> > > >
> > > > BUG=webrtc:5682
> > >
> > > TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5682
> > >
> > > Committed: https://crrev.com/5b3c443d301f2c2f18dac5b02652c08b91ea3828
> > > Cr-Commit-Position: refs/heads/master@{#12558}
> >
> > TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org
> > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/d0dc66e0ea30c8614001e425a4ae0aa7dd56c2a7
> > Cr-Commit-Position: refs/heads/master@{#12721}
>
> TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org,nisse@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/d49c30cd2fe442f2b5b4ecec8d5cbaa430464725
> Cr-Commit-Position: refs/heads/master@{#12745}
TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org,tommi@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/1979193003
Cr-Commit-Position: refs/heads/master@{#12773}
2016-05-17 04:05:47 -07:00
|
|
|
|
2018-06-19 15:03:05 +02:00
|
|
|
libyuv::I420Copy(input_frame->DataY(), input_frame->StrideY(),
|
|
|
|
|
input_frame->DataU(), input_frame->StrideU(),
|
|
|
|
|
input_frame->DataV(), input_frame->StrideV(), buffer, width,
|
|
|
|
|
buffer + width * height, chroma_width,
|
|
|
|
|
buffer + width * height + chroma_width * chroma_height,
|
|
|
|
|
chroma_width, width, height);
|
2012-10-24 18:33:04 +00:00
|
|
|
|
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
2014-11-20 22:28:14 +00:00
|
|
|
return static_cast<int>(length);
|
2012-10-24 18:33:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-13 13:06:01 +02:00
|
|
|
int ExtractBuffer(const VideoFrame& input_frame, size_t size, uint8_t* buffer) {
|
2017-06-01 10:02:26 -07:00
|
|
|
return ExtractBuffer(input_frame.video_frame_buffer()->ToI420(), size,
|
|
|
|
|
buffer);
|
2016-06-13 13:06:01 +02:00
|
|
|
}
|
2012-10-24 18:33:04 +00:00
|
|
|
|
2011-12-28 21:21:40 +00:00
|
|
|
int ConvertVideoType(VideoType video_type) {
|
2015-12-10 03:11:42 -08:00
|
|
|
switch (video_type) {
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kUnknown:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::FOURCC_ANY;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kI420:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::FOURCC_I420;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kIYUV: // same as VideoType::kYV12
|
|
|
|
|
case VideoType::kYV12:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::FOURCC_YV12;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kRGB24:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::FOURCC_24BG;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kRGB565:
|
2012-05-04 17:07:30 +00:00
|
|
|
return libyuv::FOURCC_RGBP;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kYUY2:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::FOURCC_YUY2;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kUYVY:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::FOURCC_UYVY;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kMJPEG:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::FOURCC_MJPG;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kARGB:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::FOURCC_ARGB;
|
2017-04-28 07:18:05 -07:00
|
|
|
case VideoType::kBGRA:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::FOURCC_BGRA;
|
|
|
|
|
}
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
2012-02-06 11:06:01 +00:00
|
|
|
return libyuv::FOURCC_ANY;
|
2011-12-28 21:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-29 17:21:40 -07:00
|
|
|
int ConvertFromI420(const VideoFrame& src_frame,
|
|
|
|
|
VideoType dst_video_type,
|
|
|
|
|
int dst_sample_size,
|
2011-12-28 21:21:40 +00:00
|
|
|
uint8_t* dst_frame) {
|
2017-06-01 10:02:26 -07:00
|
|
|
rtc::scoped_refptr<I420BufferInterface> i420_buffer =
|
|
|
|
|
src_frame.video_frame_buffer()->ToI420();
|
Reland of Delete webrtc::VideoFrame methods buffer and stride. (patchset #1 id:1 of https://codereview.webrtc.org/1983583002/ )
Reason for revert:
Should work after cl https://codereview.webrtc.org/1985693002/ is landed, which initializes the frames used by FakeWebRtcVideoCaptureModule. So intend to reland after that, with no changes.
Original issue's description:
> Revert of Delete webrtc::VideoFrame methods buffer and stride. (patchset #2 id:290001 of https://codereview.webrtc.org/1963413004/ )
>
> Reason for revert:
> Speculative revert to see if failures on the DrMemory bot are related to this cl. See e.g. here:
> https://build.chromium.org/p/client.webrtc/builders/Win%20DrMemory%20Full/builds/4243
>
> UNINITIALIZED READ: reading 0x04980040-0x04980060 32 byte(s) within 0x04980040-0x04980060
> # 0 CopyRow_AVX
> # 1 CopyPlane
> # 2 I420Copy
> # 3 webrtc::ExtractBuffer
> # 4 cricket::WebRtcVideoCapturer::SignalFrameCapturedOnStartThread
> # 5 cricket::WebRtcVideoCapturer::OnIncomingCapturedFrame
> # 6 FakeWebRtcVideoCaptureModule::SendFrame
> # 7 WebRtcVideoCapturerTest_TestCaptureVcm_Test::TestBody
> # 8 testing::internal::HandleSehExceptionsInMethodIfSupported<>
>
> Original issue's description:
> > Reland of Delete webrtc::VideoFrame methods buffer and stride. (patchset #1 id:1 of https://codereview.webrtc.org/1935443002/ )
> >
> > Reason for revert:
> > I plan to reland this change in a week or two, after downstream users are updated.
> >
> > Original issue's description:
> > > Revert of Delete webrtc::VideoFrame methods buffer and stride. (patchset #14 id:250001 of https://codereview.webrtc.org/1900673002/ )
> > >
> > > Reason for revert:
> > > Breaks chrome FYI bots.
> > >
> > > Original issue's description:
> > > > Delete webrtc::VideoFrame methods buffer and stride.
> > > >
> > > > To make the HasOneRef/IsMutable hack work, also had to change the
> > > > video_frame_buffer method to return a const ref to a scoped_ref_ptr,
> > > > to not imply an AddRef.
> > > >
> > > > BUG=webrtc:5682
> > >
> > > TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5682
> > >
> > > Committed: https://crrev.com/5b3c443d301f2c2f18dac5b02652c08b91ea3828
> > > Cr-Commit-Position: refs/heads/master@{#12558}
> >
> > TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org
> > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/d0dc66e0ea30c8614001e425a4ae0aa7dd56c2a7
> > Cr-Commit-Position: refs/heads/master@{#12721}
>
> TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org,nisse@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/d49c30cd2fe442f2b5b4ecec8d5cbaa430464725
> Cr-Commit-Position: refs/heads/master@{#12745}
TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org,tommi@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/1979193003
Cr-Commit-Position: refs/heads/master@{#12773}
2016-05-17 04:05:47 -07:00
|
|
|
return libyuv::ConvertFromI420(
|
2017-06-01 10:02:26 -07:00
|
|
|
i420_buffer->DataY(), i420_buffer->StrideY(), i420_buffer->DataU(),
|
|
|
|
|
i420_buffer->StrideU(), i420_buffer->DataV(), i420_buffer->StrideV(),
|
|
|
|
|
dst_frame, dst_sample_size, src_frame.width(), src_frame.height(),
|
Reland of Delete webrtc::VideoFrame methods buffer and stride. (patchset #1 id:1 of https://codereview.webrtc.org/1983583002/ )
Reason for revert:
Should work after cl https://codereview.webrtc.org/1985693002/ is landed, which initializes the frames used by FakeWebRtcVideoCaptureModule. So intend to reland after that, with no changes.
Original issue's description:
> Revert of Delete webrtc::VideoFrame methods buffer and stride. (patchset #2 id:290001 of https://codereview.webrtc.org/1963413004/ )
>
> Reason for revert:
> Speculative revert to see if failures on the DrMemory bot are related to this cl. See e.g. here:
> https://build.chromium.org/p/client.webrtc/builders/Win%20DrMemory%20Full/builds/4243
>
> UNINITIALIZED READ: reading 0x04980040-0x04980060 32 byte(s) within 0x04980040-0x04980060
> # 0 CopyRow_AVX
> # 1 CopyPlane
> # 2 I420Copy
> # 3 webrtc::ExtractBuffer
> # 4 cricket::WebRtcVideoCapturer::SignalFrameCapturedOnStartThread
> # 5 cricket::WebRtcVideoCapturer::OnIncomingCapturedFrame
> # 6 FakeWebRtcVideoCaptureModule::SendFrame
> # 7 WebRtcVideoCapturerTest_TestCaptureVcm_Test::TestBody
> # 8 testing::internal::HandleSehExceptionsInMethodIfSupported<>
>
> Original issue's description:
> > Reland of Delete webrtc::VideoFrame methods buffer and stride. (patchset #1 id:1 of https://codereview.webrtc.org/1935443002/ )
> >
> > Reason for revert:
> > I plan to reland this change in a week or two, after downstream users are updated.
> >
> > Original issue's description:
> > > Revert of Delete webrtc::VideoFrame methods buffer and stride. (patchset #14 id:250001 of https://codereview.webrtc.org/1900673002/ )
> > >
> > > Reason for revert:
> > > Breaks chrome FYI bots.
> > >
> > > Original issue's description:
> > > > Delete webrtc::VideoFrame methods buffer and stride.
> > > >
> > > > To make the HasOneRef/IsMutable hack work, also had to change the
> > > > video_frame_buffer method to return a const ref to a scoped_ref_ptr,
> > > > to not imply an AddRef.
> > > >
> > > > BUG=webrtc:5682
> > >
> > > TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5682
> > >
> > > Committed: https://crrev.com/5b3c443d301f2c2f18dac5b02652c08b91ea3828
> > > Cr-Commit-Position: refs/heads/master@{#12558}
> >
> > TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org
> > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/d0dc66e0ea30c8614001e425a4ae0aa7dd56c2a7
> > Cr-Commit-Position: refs/heads/master@{#12721}
>
> TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org,nisse@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/d49c30cd2fe442f2b5b4ecec8d5cbaa430464725
> Cr-Commit-Position: refs/heads/master@{#12745}
TBR=perkj@webrtc.org,magjed@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,stefan@webrtc.org,tommi@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/1979193003
Cr-Commit-Position: refs/heads/master@{#12773}
2016-05-17 04:05:47 -07:00
|
|
|
ConvertVideoType(dst_video_type));
|
2011-12-28 21:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
2018-03-09 15:03:26 -08:00
|
|
|
rtc::scoped_refptr<I420ABufferInterface> ScaleI420ABuffer(
|
|
|
|
|
const I420ABufferInterface& buffer,
|
|
|
|
|
int target_width,
|
|
|
|
|
int target_height) {
|
|
|
|
|
rtc::scoped_refptr<I420Buffer> yuv_buffer =
|
|
|
|
|
I420Buffer::Create(target_width, target_height);
|
|
|
|
|
yuv_buffer->ScaleFrom(buffer);
|
|
|
|
|
rtc::scoped_refptr<I420Buffer> axx_buffer =
|
|
|
|
|
I420Buffer::Create(target_width, target_height);
|
|
|
|
|
libyuv::ScalePlane(buffer.DataA(), buffer.StrideA(), buffer.width(),
|
|
|
|
|
buffer.height(), axx_buffer->MutableDataY(),
|
|
|
|
|
axx_buffer->StrideY(), target_width, target_height,
|
|
|
|
|
libyuv::kFilterBox);
|
|
|
|
|
rtc::scoped_refptr<I420ABufferInterface> merged_buffer = WrapI420ABuffer(
|
|
|
|
|
yuv_buffer->width(), yuv_buffer->height(), yuv_buffer->DataY(),
|
|
|
|
|
yuv_buffer->StrideY(), yuv_buffer->DataU(), yuv_buffer->StrideU(),
|
|
|
|
|
yuv_buffer->DataV(), yuv_buffer->StrideV(), axx_buffer->DataY(),
|
|
|
|
|
axx_buffer->StrideY(),
|
2021-01-11 13:26:35 +01:00
|
|
|
// To keep references alive.
|
|
|
|
|
[yuv_buffer, axx_buffer] {});
|
2018-03-09 15:03:26 -08:00
|
|
|
return merged_buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-01 14:12:23 +02:00
|
|
|
rtc::scoped_refptr<I420BufferInterface> ScaleVideoFrameBuffer(
|
|
|
|
|
const I420BufferInterface& source,
|
|
|
|
|
int dst_width,
|
|
|
|
|
int dst_height) {
|
|
|
|
|
rtc::scoped_refptr<I420Buffer> scaled_buffer =
|
|
|
|
|
I420Buffer::Create(dst_width, dst_height);
|
|
|
|
|
scaled_buffer->ScaleFrom(source);
|
|
|
|
|
return scaled_buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-01 14:12:08 +02:00
|
|
|
double I420SSE(const I420BufferInterface& ref_buffer,
|
|
|
|
|
const I420BufferInterface& test_buffer) {
|
|
|
|
|
RTC_DCHECK_EQ(ref_buffer.width(), test_buffer.width());
|
|
|
|
|
RTC_DCHECK_EQ(ref_buffer.height(), test_buffer.height());
|
|
|
|
|
const uint64_t width = test_buffer.width();
|
|
|
|
|
const uint64_t height = test_buffer.height();
|
|
|
|
|
const uint64_t sse_y = libyuv::ComputeSumSquareErrorPlane(
|
|
|
|
|
ref_buffer.DataY(), ref_buffer.StrideY(), test_buffer.DataY(),
|
|
|
|
|
test_buffer.StrideY(), width, height);
|
|
|
|
|
const int width_uv = (width + 1) >> 1;
|
|
|
|
|
const int height_uv = (height + 1) >> 1;
|
|
|
|
|
const uint64_t sse_u = libyuv::ComputeSumSquareErrorPlane(
|
|
|
|
|
ref_buffer.DataU(), ref_buffer.StrideU(), test_buffer.DataU(),
|
|
|
|
|
test_buffer.StrideU(), width_uv, height_uv);
|
|
|
|
|
const uint64_t sse_v = libyuv::ComputeSumSquareErrorPlane(
|
|
|
|
|
ref_buffer.DataV(), ref_buffer.StrideV(), test_buffer.DataV(),
|
|
|
|
|
test_buffer.StrideV(), width_uv, height_uv);
|
|
|
|
|
const double samples = width * height + 2 * (width_uv * height_uv);
|
|
|
|
|
const double sse = sse_y + sse_u + sse_v;
|
|
|
|
|
return sse / (samples * 255.0 * 255.0);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 15:03:26 -08:00
|
|
|
// Compute PSNR for an I420A frame (all planes). Can upscale test frame.
|
|
|
|
|
double I420APSNR(const I420ABufferInterface& ref_buffer,
|
|
|
|
|
const I420ABufferInterface& test_buffer) {
|
|
|
|
|
RTC_DCHECK_GE(ref_buffer.width(), test_buffer.width());
|
|
|
|
|
RTC_DCHECK_GE(ref_buffer.height(), test_buffer.height());
|
|
|
|
|
if ((ref_buffer.width() != test_buffer.width()) ||
|
|
|
|
|
(ref_buffer.height() != test_buffer.height())) {
|
|
|
|
|
rtc::scoped_refptr<I420ABufferInterface> scaled_buffer =
|
|
|
|
|
ScaleI420ABuffer(test_buffer, ref_buffer.width(), ref_buffer.height());
|
|
|
|
|
return I420APSNR(ref_buffer, *scaled_buffer);
|
|
|
|
|
}
|
|
|
|
|
const int width = test_buffer.width();
|
|
|
|
|
const int height = test_buffer.height();
|
|
|
|
|
const uint64_t sse_y = libyuv::ComputeSumSquareErrorPlane(
|
|
|
|
|
ref_buffer.DataY(), ref_buffer.StrideY(), test_buffer.DataY(),
|
|
|
|
|
test_buffer.StrideY(), width, height);
|
|
|
|
|
const int width_uv = (width + 1) >> 1;
|
|
|
|
|
const int height_uv = (height + 1) >> 1;
|
|
|
|
|
const uint64_t sse_u = libyuv::ComputeSumSquareErrorPlane(
|
|
|
|
|
ref_buffer.DataU(), ref_buffer.StrideU(), test_buffer.DataU(),
|
|
|
|
|
test_buffer.StrideU(), width_uv, height_uv);
|
|
|
|
|
const uint64_t sse_v = libyuv::ComputeSumSquareErrorPlane(
|
|
|
|
|
ref_buffer.DataV(), ref_buffer.StrideV(), test_buffer.DataV(),
|
|
|
|
|
test_buffer.StrideV(), width_uv, height_uv);
|
|
|
|
|
const uint64_t sse_a = libyuv::ComputeSumSquareErrorPlane(
|
|
|
|
|
ref_buffer.DataA(), ref_buffer.StrideA(), test_buffer.DataA(),
|
|
|
|
|
test_buffer.StrideA(), width, height);
|
|
|
|
|
const uint64_t samples = 2 * (uint64_t)width * (uint64_t)height +
|
|
|
|
|
2 * ((uint64_t)width_uv * (uint64_t)height_uv);
|
|
|
|
|
const uint64_t sse = sse_y + sse_u + sse_v + sse_a;
|
|
|
|
|
const double psnr = libyuv::SumSquareErrorToPsnr(sse, samples);
|
|
|
|
|
return (psnr > kPerfectPSNR) ? kPerfectPSNR : psnr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Compute PSNR for an I420A frame (all planes)
|
|
|
|
|
double I420APSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
|
|
|
|
|
if (!ref_frame || !test_frame)
|
|
|
|
|
return -1;
|
|
|
|
|
RTC_DCHECK(ref_frame->video_frame_buffer()->type() ==
|
|
|
|
|
VideoFrameBuffer::Type::kI420A);
|
|
|
|
|
RTC_DCHECK(test_frame->video_frame_buffer()->type() ==
|
|
|
|
|
VideoFrameBuffer::Type::kI420A);
|
|
|
|
|
return I420APSNR(*ref_frame->video_frame_buffer()->GetI420A(),
|
|
|
|
|
*test_frame->video_frame_buffer()->GetI420A());
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 02:23:28 -08:00
|
|
|
// Compute PSNR for an I420 frame (all planes). Can upscale test frame.
|
2017-06-01 10:02:26 -07:00
|
|
|
double I420PSNR(const I420BufferInterface& ref_buffer,
|
|
|
|
|
const I420BufferInterface& test_buffer) {
|
2017-02-15 02:23:28 -08:00
|
|
|
RTC_DCHECK_GE(ref_buffer.width(), test_buffer.width());
|
|
|
|
|
RTC_DCHECK_GE(ref_buffer.height(), test_buffer.height());
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
if ((ref_buffer.width() != test_buffer.width()) ||
|
2017-02-15 02:23:28 -08:00
|
|
|
(ref_buffer.height() != test_buffer.height())) {
|
|
|
|
|
rtc::scoped_refptr<I420Buffer> scaled_buffer =
|
|
|
|
|
I420Buffer::Create(ref_buffer.width(), ref_buffer.height());
|
|
|
|
|
scaled_buffer->ScaleFrom(test_buffer);
|
|
|
|
|
return I420PSNR(ref_buffer, *scaled_buffer);
|
|
|
|
|
}
|
|
|
|
|
double psnr = libyuv::I420Psnr(
|
|
|
|
|
ref_buffer.DataY(), ref_buffer.StrideY(), ref_buffer.DataU(),
|
|
|
|
|
ref_buffer.StrideU(), ref_buffer.DataV(), ref_buffer.StrideV(),
|
|
|
|
|
test_buffer.DataY(), test_buffer.StrideY(), test_buffer.DataU(),
|
|
|
|
|
test_buffer.StrideU(), test_buffer.DataV(), test_buffer.StrideV(),
|
|
|
|
|
test_buffer.width(), test_buffer.height());
|
2012-11-29 10:08:16 +00:00
|
|
|
// LibYuv sets the max psnr value to 128, we restrict it here.
|
2012-10-04 17:22:32 +00:00
|
|
|
// In case of 0 mse in one frame, 128 can skew the results significantly.
|
2012-12-13 10:15:06 +00:00
|
|
|
return (psnr > kPerfectPSNR) ? kPerfectPSNR : psnr;
|
2012-10-04 17:22:32 +00:00
|
|
|
}
|
2012-10-24 18:33:04 +00:00
|
|
|
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
// Compute PSNR for an I420 frame (all planes)
|
|
|
|
|
double I420PSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
|
2015-03-16 13:46:52 +00:00
|
|
|
if (!ref_frame || !test_frame)
|
2012-10-04 17:22:32 +00:00
|
|
|
return -1;
|
2017-06-01 10:02:26 -07:00
|
|
|
return I420PSNR(*ref_frame->video_frame_buffer()->ToI420(),
|
|
|
|
|
*test_frame->video_frame_buffer()->ToI420());
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
}
|
|
|
|
|
|
2022-03-23 19:56:56 +01:00
|
|
|
double I420WeightedPSNR(const I420BufferInterface& ref_buffer,
|
|
|
|
|
const I420BufferInterface& test_buffer) {
|
|
|
|
|
RTC_DCHECK_GE(ref_buffer.width(), test_buffer.width());
|
|
|
|
|
RTC_DCHECK_GE(ref_buffer.height(), test_buffer.height());
|
|
|
|
|
if ((ref_buffer.width() != test_buffer.width()) ||
|
|
|
|
|
(ref_buffer.height() != test_buffer.height())) {
|
|
|
|
|
rtc::scoped_refptr<I420Buffer> scaled_ref_buffer =
|
|
|
|
|
I420Buffer::Create(test_buffer.width(), test_buffer.height());
|
|
|
|
|
scaled_ref_buffer->ScaleFrom(ref_buffer);
|
|
|
|
|
return I420WeightedPSNR(*scaled_ref_buffer, test_buffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Luma.
|
|
|
|
|
int width_y = test_buffer.width();
|
|
|
|
|
int height_y = test_buffer.height();
|
|
|
|
|
uint64_t sse_y = libyuv::ComputeSumSquareErrorPlane(
|
|
|
|
|
ref_buffer.DataY(), ref_buffer.StrideY(), test_buffer.DataY(),
|
|
|
|
|
test_buffer.StrideY(), width_y, height_y);
|
|
|
|
|
uint64_t num_samples_y = (uint64_t)width_y * (uint64_t)height_y;
|
|
|
|
|
double psnr_y = libyuv::SumSquareErrorToPsnr(sse_y, num_samples_y);
|
|
|
|
|
|
|
|
|
|
// Chroma.
|
|
|
|
|
int width_uv = (width_y + 1) >> 1;
|
|
|
|
|
int height_uv = (height_y + 1) >> 1;
|
|
|
|
|
uint64_t sse_u = libyuv::ComputeSumSquareErrorPlane(
|
|
|
|
|
ref_buffer.DataU(), ref_buffer.StrideU(), test_buffer.DataU(),
|
|
|
|
|
test_buffer.StrideU(), width_uv, height_uv);
|
|
|
|
|
uint64_t num_samples_uv = (uint64_t)width_uv * (uint64_t)height_uv;
|
|
|
|
|
double psnr_u = libyuv::SumSquareErrorToPsnr(sse_u, num_samples_uv);
|
|
|
|
|
uint64_t sse_v = libyuv::ComputeSumSquareErrorPlane(
|
|
|
|
|
ref_buffer.DataV(), ref_buffer.StrideV(), test_buffer.DataV(),
|
|
|
|
|
test_buffer.StrideV(), width_uv, height_uv);
|
|
|
|
|
double psnr_v = libyuv::SumSquareErrorToPsnr(sse_v, num_samples_uv);
|
|
|
|
|
|
|
|
|
|
// Weights from Ohm et. al 2012.
|
|
|
|
|
double psnr_yuv = (6.0 * psnr_y + psnr_u + psnr_v) / 8.0;
|
|
|
|
|
return (psnr_yuv > kPerfectPSNR) ? kPerfectPSNR : psnr_yuv;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 15:03:26 -08:00
|
|
|
// Compute SSIM for an I420A frame (all planes). Can upscale test frame.
|
|
|
|
|
double I420ASSIM(const I420ABufferInterface& ref_buffer,
|
|
|
|
|
const I420ABufferInterface& test_buffer) {
|
|
|
|
|
RTC_DCHECK_GE(ref_buffer.width(), test_buffer.width());
|
|
|
|
|
RTC_DCHECK_GE(ref_buffer.height(), test_buffer.height());
|
|
|
|
|
if ((ref_buffer.width() != test_buffer.width()) ||
|
|
|
|
|
(ref_buffer.height() != test_buffer.height())) {
|
|
|
|
|
rtc::scoped_refptr<I420ABufferInterface> scaled_buffer =
|
|
|
|
|
ScaleI420ABuffer(test_buffer, ref_buffer.width(), ref_buffer.height());
|
|
|
|
|
return I420ASSIM(ref_buffer, *scaled_buffer);
|
|
|
|
|
}
|
|
|
|
|
const double yuv_ssim = libyuv::I420Ssim(
|
|
|
|
|
ref_buffer.DataY(), ref_buffer.StrideY(), ref_buffer.DataU(),
|
|
|
|
|
ref_buffer.StrideU(), ref_buffer.DataV(), ref_buffer.StrideV(),
|
|
|
|
|
test_buffer.DataY(), test_buffer.StrideY(), test_buffer.DataU(),
|
|
|
|
|
test_buffer.StrideU(), test_buffer.DataV(), test_buffer.StrideV(),
|
|
|
|
|
test_buffer.width(), test_buffer.height());
|
|
|
|
|
const double a_ssim = libyuv::CalcFrameSsim(
|
|
|
|
|
ref_buffer.DataA(), ref_buffer.StrideA(), test_buffer.DataA(),
|
|
|
|
|
test_buffer.StrideA(), test_buffer.width(), test_buffer.height());
|
|
|
|
|
return (yuv_ssim + (a_ssim * 0.8)) / 1.8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Compute SSIM for an I420A frame (all planes)
|
|
|
|
|
double I420ASSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
|
|
|
|
|
if (!ref_frame || !test_frame)
|
|
|
|
|
return -1;
|
|
|
|
|
RTC_DCHECK(ref_frame->video_frame_buffer()->type() ==
|
|
|
|
|
VideoFrameBuffer::Type::kI420A);
|
|
|
|
|
RTC_DCHECK(test_frame->video_frame_buffer()->type() ==
|
|
|
|
|
VideoFrameBuffer::Type::kI420A);
|
|
|
|
|
return I420ASSIM(*ref_frame->video_frame_buffer()->GetI420A(),
|
|
|
|
|
*test_frame->video_frame_buffer()->GetI420A());
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 02:23:28 -08:00
|
|
|
// Compute SSIM for an I420 frame (all planes). Can upscale test_buffer.
|
2017-06-01 10:02:26 -07:00
|
|
|
double I420SSIM(const I420BufferInterface& ref_buffer,
|
|
|
|
|
const I420BufferInterface& test_buffer) {
|
2017-02-15 02:23:28 -08:00
|
|
|
RTC_DCHECK_GE(ref_buffer.width(), test_buffer.width());
|
|
|
|
|
RTC_DCHECK_GE(ref_buffer.height(), test_buffer.height());
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
if ((ref_buffer.width() != test_buffer.width()) ||
|
2017-02-15 02:23:28 -08:00
|
|
|
(ref_buffer.height() != test_buffer.height())) {
|
|
|
|
|
rtc::scoped_refptr<I420Buffer> scaled_buffer =
|
|
|
|
|
I420Buffer::Create(ref_buffer.width(), ref_buffer.height());
|
|
|
|
|
scaled_buffer->ScaleFrom(test_buffer);
|
|
|
|
|
return I420SSIM(ref_buffer, *scaled_buffer);
|
|
|
|
|
}
|
|
|
|
|
return libyuv::I420Ssim(
|
|
|
|
|
ref_buffer.DataY(), ref_buffer.StrideY(), ref_buffer.DataU(),
|
|
|
|
|
ref_buffer.StrideU(), ref_buffer.DataV(), ref_buffer.StrideV(),
|
|
|
|
|
test_buffer.DataY(), test_buffer.StrideY(), test_buffer.DataU(),
|
|
|
|
|
test_buffer.StrideU(), test_buffer.DataV(), test_buffer.StrideV(),
|
|
|
|
|
test_buffer.width(), test_buffer.height());
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
}
|
2018-03-09 15:03:26 -08:00
|
|
|
|
Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2343083002/ )
Reason for revert:
Will fix android build failure.
Original issue's description:
> Revert of Update test code to use I420Buffer when writing pixel data. (patchset #2 id:140001 of https://codereview.webrtc.org/2342783003/ )
>
> Reason for revert:
> I was too impatient; this made android builds fail instead. See https://build.chromium.org/p/client.webrtc/builders/Linux32%20ARM/builds/585/steps/compile/logs/stdio
>
> Original issue's description:
> > Reland of Update test code to use I420Buffer when writing pixel data. (patchset #1 id:1 of https://codereview.webrtc.org/2342123003/ )
> >
> > Reason for revert:
> > Intending to fix problem and reland.
> >
> > Original issue's description:
> > > Revert of Update test code to use I420Buffer when writing pixel data. (patchset #5 id:80001 of https://codereview.webrtc.org/2333373007/ )
> > >
> > > Reason for revert:
> > > Fails 64-bit windows builds, it turns out I missed some of the needed int/size_t casts. Example https://build.chromium.org/p/client.webrtc/waterfall?builder=Win64%20Release
> > >
> > > Hope our windows try bots get back in working shape soon.
> > >
> > > Original issue's description:
> > > > Update test code to use I420Buffer when writing pixel data.
> > > >
> > > > VideoFrameBuffer and VideoFrame will become immutable.
> > > >
> > > > BUG=webrtc:5921
> > > > R=magjed@webrtc.org, phoglund@webrtc.org
> > > >
> > > > Committed: https://crrev.com/280ad1514e44bf6717e5871526dd4632f759eb3d
> > > > Cr-Commit-Position: refs/heads/master@{#14249}
> > >
> > > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:5921
> > >
> > > Committed: https://crrev.com/fbf14607267adf03d235273283ca452a1e564861
> > > Cr-Commit-Position: refs/heads/master@{#14251}
> >
> > TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/d21534a8cfe636bbcf3d7bb151945590abc92b2a
> > Cr-Commit-Position: refs/heads/master@{#14258}
>
> TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/3011627142bccdd73fce9fec854abb1f6b02b5c1
> Cr-Commit-Position: refs/heads/master@{#14259}
TBR=phoglund@webrtc.org,palmkvist@webrtc.org,magjed@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2347863002
Cr-Commit-Position: refs/heads/master@{#14283}
2016-09-19 00:34:46 -07:00
|
|
|
double I420SSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
|
|
|
|
|
if (!ref_frame || !test_frame)
|
|
|
|
|
return -1;
|
2017-06-01 10:02:26 -07:00
|
|
|
return I420SSIM(*ref_frame->video_frame_buffer()->ToI420(),
|
|
|
|
|
*test_frame->video_frame_buffer()->ToI420());
|
2012-10-04 17:22:32 +00:00
|
|
|
}
|
2016-09-17 02:39:03 -07:00
|
|
|
|
2017-06-19 16:46:31 +02:00
|
|
|
void NV12Scale(uint8_t* tmp_buffer,
|
2018-06-19 15:03:05 +02:00
|
|
|
const uint8_t* src_y,
|
|
|
|
|
int src_stride_y,
|
|
|
|
|
const uint8_t* src_uv,
|
|
|
|
|
int src_stride_uv,
|
|
|
|
|
int src_width,
|
|
|
|
|
int src_height,
|
|
|
|
|
uint8_t* dst_y,
|
|
|
|
|
int dst_stride_y,
|
|
|
|
|
uint8_t* dst_uv,
|
|
|
|
|
int dst_stride_uv,
|
|
|
|
|
int dst_width,
|
|
|
|
|
int dst_height) {
|
2016-10-20 03:34:29 -07:00
|
|
|
const int src_chroma_width = (src_width + 1) / 2;
|
|
|
|
|
const int src_chroma_height = (src_height + 1) / 2;
|
|
|
|
|
|
|
|
|
|
if (src_width == dst_width && src_height == dst_height) {
|
|
|
|
|
// No scaling.
|
|
|
|
|
libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, src_width,
|
|
|
|
|
src_height);
|
|
|
|
|
libyuv::CopyPlane(src_uv, src_stride_uv, dst_uv, dst_stride_uv,
|
|
|
|
|
src_chroma_width * 2, src_chroma_height);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scaling.
|
|
|
|
|
// Allocate temporary memory for spitting UV planes and scaling them.
|
|
|
|
|
const int dst_chroma_width = (dst_width + 1) / 2;
|
|
|
|
|
const int dst_chroma_height = (dst_height + 1) / 2;
|
|
|
|
|
|
2017-06-19 16:46:31 +02:00
|
|
|
uint8_t* const src_u = tmp_buffer;
|
2016-10-20 03:34:29 -07:00
|
|
|
uint8_t* const src_v = src_u + src_chroma_width * src_chroma_height;
|
|
|
|
|
uint8_t* const dst_u = src_v + src_chroma_width * src_chroma_height;
|
|
|
|
|
uint8_t* const dst_v = dst_u + dst_chroma_width * dst_chroma_height;
|
|
|
|
|
|
|
|
|
|
// Split source UV plane into separate U and V plane using the temporary data.
|
2018-06-19 15:03:05 +02:00
|
|
|
libyuv::SplitUVPlane(src_uv, src_stride_uv, src_u, src_chroma_width, src_v,
|
|
|
|
|
src_chroma_width, src_chroma_width, src_chroma_height);
|
2016-10-20 03:34:29 -07:00
|
|
|
|
|
|
|
|
// Scale the planes.
|
2018-06-19 15:03:05 +02:00
|
|
|
libyuv::I420Scale(
|
|
|
|
|
src_y, src_stride_y, src_u, src_chroma_width, src_v, src_chroma_width,
|
|
|
|
|
src_width, src_height, dst_y, dst_stride_y, dst_u, dst_chroma_width,
|
|
|
|
|
dst_v, dst_chroma_width, dst_width, dst_height, libyuv::kFilterBox);
|
2016-10-20 03:34:29 -07:00
|
|
|
|
|
|
|
|
// Merge the UV planes into the destination.
|
2018-06-19 15:03:05 +02:00
|
|
|
libyuv::MergeUVPlane(dst_u, dst_chroma_width, dst_v, dst_chroma_width, dst_uv,
|
|
|
|
|
dst_stride_uv, dst_chroma_width, dst_chroma_height);
|
2016-10-20 03:34:29 -07:00
|
|
|
}
|
|
|
|
|
|
2017-05-08 05:32:05 -07:00
|
|
|
NV12ToI420Scaler::NV12ToI420Scaler() = default;
|
|
|
|
|
NV12ToI420Scaler::~NV12ToI420Scaler() = default;
|
|
|
|
|
|
2018-06-19 15:03:05 +02:00
|
|
|
void NV12ToI420Scaler::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,
|
|
|
|
|
uint8_t* dst_y,
|
|
|
|
|
int dst_stride_y,
|
|
|
|
|
uint8_t* dst_u,
|
|
|
|
|
int dst_stride_u,
|
|
|
|
|
uint8_t* dst_v,
|
|
|
|
|
int dst_stride_v,
|
|
|
|
|
int dst_width,
|
|
|
|
|
int dst_height) {
|
2016-09-17 02:39:03 -07:00
|
|
|
if (src_width == dst_width && src_height == dst_height) {
|
|
|
|
|
// No scaling.
|
|
|
|
|
tmp_uv_planes_.clear();
|
|
|
|
|
tmp_uv_planes_.shrink_to_fit();
|
2018-06-19 15:03:05 +02:00
|
|
|
libyuv::NV12ToI420(src_y, src_stride_y, src_uv, src_stride_uv, dst_y,
|
|
|
|
|
dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v,
|
|
|
|
|
src_width, src_height);
|
2016-09-17 02:39:03 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scaling.
|
|
|
|
|
// Allocate temporary memory for spitting UV planes.
|
|
|
|
|
const int src_uv_width = (src_width + 1) / 2;
|
|
|
|
|
const int src_uv_height = (src_height + 1) / 2;
|
|
|
|
|
tmp_uv_planes_.resize(src_uv_width * src_uv_height * 2);
|
|
|
|
|
tmp_uv_planes_.shrink_to_fit();
|
|
|
|
|
|
|
|
|
|
// Split source UV plane into separate U and V plane using the temporary data.
|
|
|
|
|
uint8_t* const src_u = tmp_uv_planes_.data();
|
|
|
|
|
uint8_t* const src_v = tmp_uv_planes_.data() + src_uv_width * src_uv_height;
|
2018-06-19 15:03:05 +02:00
|
|
|
libyuv::SplitUVPlane(src_uv, src_stride_uv, src_u, src_uv_width, src_v,
|
|
|
|
|
src_uv_width, src_uv_width, src_uv_height);
|
2016-09-17 02:39:03 -07:00
|
|
|
|
|
|
|
|
// Scale the planes into the destination.
|
2018-06-19 15:03:05 +02:00
|
|
|
libyuv::I420Scale(src_y, src_stride_y, src_u, src_uv_width, src_v,
|
|
|
|
|
src_uv_width, src_width, src_height, dst_y, dst_stride_y,
|
|
|
|
|
dst_u, dst_stride_u, dst_v, dst_stride_v, dst_width,
|
|
|
|
|
dst_height, libyuv::kFilterBox);
|
2016-09-17 02:39:03 -07:00
|
|
|
}
|
|
|
|
|
|
2011-11-28 18:09:41 +00:00
|
|
|
} // namespace webrtc
|