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.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-06-04 09:02:37 +00:00
|
|
|
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
2011-11-28 18:09:41 +00:00
|
|
|
|
|
|
|
|
#include <assert.h>
|
2012-10-24 18:33:04 +00:00
|
|
|
#include <string.h>
|
2011-11-28 18:09:41 +00:00
|
|
|
|
2013-06-04 23:53:48 +00:00
|
|
|
// NOTE(ajm): Path provided by gyp.
|
|
|
|
|
#include "libyuv.h" // NOLINT
|
2011-11-28 18:09:41 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2011-12-27 23:45:30 +00:00
|
|
|
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;
|
2012-01-03 18:49:15 +00:00
|
|
|
case kVideoBGRA:
|
|
|
|
|
return kBGRA;
|
2012-02-24 11:53:49 +00:00
|
|
|
case kVideoMJPEG:
|
|
|
|
|
return kMJPG;
|
2011-12-27 23:45:30 +00:00
|
|
|
default:
|
|
|
|
|
assert(false);
|
|
|
|
|
}
|
|
|
|
|
return kUnknown;
|
|
|
|
|
}
|
|
|
|
|
|
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) {
|
|
|
|
|
assert(width >= 0);
|
|
|
|
|
assert(height >= 0);
|
|
|
|
|
size_t buffer_size = 0;
|
2011-11-28 18:09:41 +00:00
|
|
|
switch (type) {
|
|
|
|
|
case kI420:
|
|
|
|
|
case kNV12:
|
|
|
|
|
case kNV21:
|
|
|
|
|
case kIYUV:
|
2012-07-10 20:48:48 +00:00
|
|
|
case kYV12: {
|
|
|
|
|
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
|
|
|
}
|
2011-11-28 18:09:41 +00:00
|
|
|
case kARGB4444:
|
|
|
|
|
case kRGB565:
|
|
|
|
|
case kARGB1555:
|
|
|
|
|
case kYUY2:
|
|
|
|
|
case kUYVY:
|
2012-07-10 20:48:48 +00:00
|
|
|
buffer_size = width * height * 2;
|
2011-11-28 18:09:41 +00:00
|
|
|
break;
|
|
|
|
|
case kRGB24:
|
2012-07-10 20:48:48 +00:00
|
|
|
buffer_size = width * height * 3;
|
2011-11-28 18:09:41 +00:00
|
|
|
break;
|
2012-01-03 18:49:15 +00:00
|
|
|
case kBGRA:
|
2011-11-28 18:09:41 +00:00
|
|
|
case kARGB:
|
2012-07-10 20:48:48 +00:00
|
|
|
buffer_size = width * height * 4;
|
2011-11-28 18:09:41 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
assert(false);
|
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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static int PrintPlane(const uint8_t* buf,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int stride,
|
|
|
|
|
FILE* file) {
|
|
|
|
|
for (int i = 0; i < height; i++, buf += stride) {
|
|
|
|
|
if (fwrite(buf, 1, width, file) != static_cast<unsigned int>(width))
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO(nisse): Belongs with the test code?
|
2015-05-29 17:21:40 -07:00
|
|
|
int PrintVideoFrame(const VideoFrame& frame, FILE* file) {
|
2012-10-24 18:33:04 +00:00
|
|
|
if (file == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
if (frame.IsZeroSize())
|
|
|
|
|
return -1;
|
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
|
|
|
int width = frame.video_frame_buffer()->width();
|
|
|
|
|
int height = frame.video_frame_buffer()->height();
|
|
|
|
|
int chroma_width = (width + 1) / 2;
|
|
|
|
|
int chroma_height = (height + 1) / 2;
|
|
|
|
|
|
|
|
|
|
if (PrintPlane(frame.video_frame_buffer()->DataY(), width, height,
|
|
|
|
|
frame.video_frame_buffer()->StrideY(), file) < 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (PrintPlane(frame.video_frame_buffer()->DataU(),
|
|
|
|
|
chroma_width, chroma_height,
|
|
|
|
|
frame.video_frame_buffer()->StrideU(), file) < 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (PrintPlane(frame.video_frame_buffer()->DataV(),
|
|
|
|
|
chroma_width, chroma_height,
|
|
|
|
|
frame.video_frame_buffer()->StrideV(), file) < 0) {
|
|
|
|
|
return -1;
|
2015-12-10 03:11:42 -08:00
|
|
|
}
|
|
|
|
|
return 0;
|
2012-10-24 18:33:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-13 13:06:01 +02:00
|
|
|
int ExtractBuffer(const rtc::scoped_refptr<VideoFrameBuffer>& input_frame,
|
|
|
|
|
size_t size,
|
|
|
|
|
uint8_t* buffer) {
|
2012-10-24 18:33:04 +00:00
|
|
|
assert(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();
|
|
|
|
|
size_t length = CalcBufferSize(kI420, width, height);
|
2012-10-24 18:33:04 +00:00
|
|
|
if (size < length) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
int chroma_width = (width + 1) / 2;
|
|
|
|
|
int chroma_height = (height + 1) / 2;
|
|
|
|
|
|
2016-06-13 13:06:01 +02:00
|
|
|
libyuv::I420Copy(input_frame->DataY(),
|
|
|
|
|
input_frame->StrideY(),
|
|
|
|
|
input_frame->DataU(),
|
|
|
|
|
input_frame->StrideU(),
|
|
|
|
|
input_frame->DataV(),
|
|
|
|
|
input_frame->StrideV(),
|
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
|
|
|
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) {
|
|
|
|
|
return ExtractBuffer(input_frame.video_frame_buffer(), size, buffer);
|
|
|
|
|
}
|
2012-10-24 18:33:04 +00:00
|
|
|
|
2011-11-28 18:09:41 +00:00
|
|
|
int ConvertNV12ToRGB565(const uint8_t* src_frame,
|
|
|
|
|
uint8_t* dst_frame,
|
|
|
|
|
int width, int height) {
|
2012-07-10 20:48:48 +00:00
|
|
|
int abs_height = (height < 0) ? -height : height;
|
2011-11-28 18:09:41 +00:00
|
|
|
const uint8_t* yplane = src_frame;
|
2012-07-10 20:48:48 +00:00
|
|
|
const uint8_t* uvInterlaced = src_frame + (width * abs_height);
|
2011-11-28 18:09:41 +00:00
|
|
|
|
|
|
|
|
return libyuv::NV12ToRGB565(yplane, width,
|
2012-07-10 20:48:48 +00:00
|
|
|
uvInterlaced, (width + 1) >> 1,
|
2011-11-28 18:09:41 +00:00
|
|
|
dst_frame, width,
|
|
|
|
|
width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ConvertRGB24ToARGB(const uint8_t* src_frame, uint8_t* dst_frame,
|
|
|
|
|
int width, int height, int dst_stride) {
|
2012-07-10 20:48:48 +00:00
|
|
|
if (dst_stride == 0)
|
2011-11-28 18:09:41 +00:00
|
|
|
dst_stride = width;
|
|
|
|
|
return libyuv::RGB24ToARGB(src_frame, width,
|
|
|
|
|
dst_frame, dst_stride,
|
|
|
|
|
width, height);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-09 17:07:31 +00:00
|
|
|
libyuv::RotationMode ConvertRotationMode(VideoRotation rotation) {
|
2015-12-10 03:11:42 -08:00
|
|
|
switch (rotation) {
|
2015-03-09 17:07:31 +00:00
|
|
|
case kVideoRotation_0:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::kRotate0;
|
2015-03-09 17:07:31 +00:00
|
|
|
case kVideoRotation_90:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::kRotate90;
|
2015-03-09 17:07:31 +00:00
|
|
|
case kVideoRotation_180:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::kRotate180;
|
2015-03-09 17:07:31 +00:00
|
|
|
case kVideoRotation_270:
|
2011-12-28 21:21:40 +00:00
|
|
|
return libyuv::kRotate270;
|
|
|
|
|
}
|
2012-02-06 11:06:01 +00:00
|
|
|
assert(false);
|
|
|
|
|
return libyuv::kRotate0;
|
2011-12-28 21:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ConvertVideoType(VideoType video_type) {
|
2015-12-10 03:11:42 -08:00
|
|
|
switch (video_type) {
|
2011-12-28 21:21:40 +00:00
|
|
|
case kUnknown:
|
|
|
|
|
return libyuv::FOURCC_ANY;
|
|
|
|
|
case kI420:
|
|
|
|
|
return libyuv::FOURCC_I420;
|
|
|
|
|
case kIYUV: // same as KYV12
|
|
|
|
|
case kYV12:
|
|
|
|
|
return libyuv::FOURCC_YV12;
|
|
|
|
|
case kRGB24:
|
|
|
|
|
return libyuv::FOURCC_24BG;
|
|
|
|
|
case kABGR:
|
|
|
|
|
return libyuv::FOURCC_ABGR;
|
2012-01-05 18:19:32 +00:00
|
|
|
case kRGB565:
|
2012-05-04 17:07:30 +00:00
|
|
|
return libyuv::FOURCC_RGBP;
|
2011-12-28 21:21:40 +00:00
|
|
|
case kYUY2:
|
|
|
|
|
return libyuv::FOURCC_YUY2;
|
|
|
|
|
case kUYVY:
|
|
|
|
|
return libyuv::FOURCC_UYVY;
|
|
|
|
|
case kMJPG:
|
|
|
|
|
return libyuv::FOURCC_MJPG;
|
|
|
|
|
case kNV21:
|
|
|
|
|
return libyuv::FOURCC_NV21;
|
|
|
|
|
case kNV12:
|
|
|
|
|
return libyuv::FOURCC_NV12;
|
|
|
|
|
case kARGB:
|
|
|
|
|
return libyuv::FOURCC_ARGB;
|
|
|
|
|
case kBGRA:
|
|
|
|
|
return libyuv::FOURCC_BGRA;
|
2012-07-14 00:03:55 +00:00
|
|
|
case kARGB4444:
|
|
|
|
|
return libyuv::FOURCC_R444;
|
|
|
|
|
case kARGB1555:
|
|
|
|
|
return libyuv::FOURCC_RGBO;
|
2011-12-28 21:21:40 +00:00
|
|
|
}
|
2012-02-06 11:06:01 +00:00
|
|
|
assert(false);
|
|
|
|
|
return libyuv::FOURCC_ANY;
|
2011-12-28 21:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
// TODO(nisse): Delete this wrapper, let callers use libyuv directly.
|
2011-12-28 21:21:40 +00:00
|
|
|
int ConvertToI420(VideoType src_video_type,
|
|
|
|
|
const uint8_t* src_frame,
|
2015-03-09 17:07:31 +00:00
|
|
|
int crop_x,
|
|
|
|
|
int crop_y,
|
|
|
|
|
int src_width,
|
|
|
|
|
int src_height,
|
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 sample_size,
|
2015-03-09 17:07:31 +00:00
|
|
|
VideoRotation rotation,
|
2015-05-29 17:21:40 -07:00
|
|
|
VideoFrame* dst_frame) {
|
2012-11-01 15:45:38 +00:00
|
|
|
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.
|
2015-03-09 17:07:31 +00:00
|
|
|
if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) {
|
2012-11-01 15:45:38 +00:00
|
|
|
dst_width = dst_frame->height();
|
2015-12-10 03:11:42 -08:00
|
|
|
dst_height = dst_frame->width();
|
2012-11-01 15:45:38 +00:00
|
|
|
}
|
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::ConvertToI420(
|
|
|
|
|
src_frame, sample_size,
|
|
|
|
|
dst_frame->video_frame_buffer()->MutableDataY(),
|
|
|
|
|
dst_frame->video_frame_buffer()->StrideY(),
|
|
|
|
|
dst_frame->video_frame_buffer()->MutableDataU(),
|
|
|
|
|
dst_frame->video_frame_buffer()->StrideU(),
|
|
|
|
|
dst_frame->video_frame_buffer()->MutableDataV(),
|
|
|
|
|
dst_frame->video_frame_buffer()->StrideV(),
|
|
|
|
|
crop_x, crop_y,
|
|
|
|
|
src_width, src_height,
|
|
|
|
|
dst_width, dst_height,
|
|
|
|
|
ConvertRotationMode(rotation),
|
|
|
|
|
ConvertVideoType(src_video_type));
|
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) {
|
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(
|
|
|
|
|
src_frame.video_frame_buffer()->DataY(),
|
|
|
|
|
src_frame.video_frame_buffer()->StrideY(),
|
|
|
|
|
src_frame.video_frame_buffer()->DataU(),
|
|
|
|
|
src_frame.video_frame_buffer()->StrideU(),
|
|
|
|
|
src_frame.video_frame_buffer()->DataV(),
|
|
|
|
|
src_frame.video_frame_buffer()->StrideV(),
|
|
|
|
|
dst_frame, dst_sample_size,
|
|
|
|
|
src_frame.width(), src_frame.height(),
|
|
|
|
|
ConvertVideoType(dst_video_type));
|
2011-12-28 21:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-04 17:22:32 +00:00
|
|
|
// Compute PSNR for an I420 frame (all planes)
|
2016-09-16 05:45:08 -07:00
|
|
|
double I420PSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
|
|
|
|
|
if (!ref_frame || !test_frame)
|
2012-10-04 17:22:32 +00:00
|
|
|
return -1;
|
2016-09-16 05:45:08 -07:00
|
|
|
else if ((ref_frame->width() != test_frame->width()) ||
|
|
|
|
|
(ref_frame->height() != test_frame->height()))
|
|
|
|
|
return -1;
|
|
|
|
|
else if (ref_frame->width() < 0 || ref_frame->height() < 0)
|
2015-03-16 13:46:52 +00:00
|
|
|
return -1;
|
|
|
|
|
|
2016-09-16 05:45:08 -07:00
|
|
|
double psnr = libyuv::I420Psnr(ref_frame->video_frame_buffer()->DataY(),
|
|
|
|
|
ref_frame->video_frame_buffer()->StrideY(),
|
|
|
|
|
ref_frame->video_frame_buffer()->DataU(),
|
|
|
|
|
ref_frame->video_frame_buffer()->StrideU(),
|
|
|
|
|
ref_frame->video_frame_buffer()->DataV(),
|
|
|
|
|
ref_frame->video_frame_buffer()->StrideV(),
|
|
|
|
|
test_frame->video_frame_buffer()->DataY(),
|
|
|
|
|
test_frame->video_frame_buffer()->StrideY(),
|
|
|
|
|
test_frame->video_frame_buffer()->DataU(),
|
|
|
|
|
test_frame->video_frame_buffer()->StrideU(),
|
|
|
|
|
test_frame->video_frame_buffer()->DataV(),
|
|
|
|
|
test_frame->video_frame_buffer()->StrideV(),
|
|
|
|
|
test_frame->width(), test_frame->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
|
|
|
|
2016-09-16 05:45:08 -07:00
|
|
|
// Compute SSIM for an I420 frame (all planes)
|
|
|
|
|
double I420SSIM(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;
|
2016-09-16 05:45:08 -07:00
|
|
|
else if ((ref_frame->width() != test_frame->width()) ||
|
|
|
|
|
(ref_frame->height() != test_frame->height()))
|
2015-03-16 13:46:52 +00:00
|
|
|
return -1;
|
2016-09-16 05:45:08 -07:00
|
|
|
else if (ref_frame->width() < 0 || ref_frame->height() < 0)
|
2015-03-16 13:46:52 +00:00
|
|
|
return -1;
|
|
|
|
|
|
2016-09-16 05:45:08 -07:00
|
|
|
return libyuv::I420Ssim(ref_frame->video_frame_buffer()->DataY(),
|
|
|
|
|
ref_frame->video_frame_buffer()->StrideY(),
|
|
|
|
|
ref_frame->video_frame_buffer()->DataU(),
|
|
|
|
|
ref_frame->video_frame_buffer()->StrideU(),
|
|
|
|
|
ref_frame->video_frame_buffer()->DataV(),
|
|
|
|
|
ref_frame->video_frame_buffer()->StrideV(),
|
|
|
|
|
test_frame->video_frame_buffer()->DataY(),
|
|
|
|
|
test_frame->video_frame_buffer()->StrideY(),
|
|
|
|
|
test_frame->video_frame_buffer()->DataU(),
|
|
|
|
|
test_frame->video_frame_buffer()->StrideU(),
|
|
|
|
|
test_frame->video_frame_buffer()->DataV(),
|
|
|
|
|
test_frame->video_frame_buffer()->StrideV(),
|
|
|
|
|
test_frame->width(), test_frame->height());
|
2012-10-04 17:22:32 +00:00
|
|
|
}
|
2011-11-28 18:09:41 +00:00
|
|
|
} // namespace webrtc
|