cricket::VideoFrame: Refactor ConvertToRgbBuffer into base class

There is also an implementation in Chromium that can be removed if/when this lands:
content/renderer/media/webrtc/webrtc_video_capturer_adapter.cc

R=fbarchard@google.com, pbos@webrtc.org, perkj@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/32059004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7728 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
magjed@webrtc.org
2014-11-21 10:53:00 +00:00
parent ad0e71c9a3
commit bdcf38c894
4 changed files with 22 additions and 50 deletions

View File

@@ -115,6 +115,26 @@ void VideoFrame::CopyToFrame(VideoFrame* dst) const {
dst->GetYPitch(), dst->GetUPitch(), dst->GetVPitch());
}
size_t VideoFrame::ConvertToRgbBuffer(uint32 to_fourcc,
uint8* buffer,
size_t size,
int stride_rgb) const {
const size_t needed = std::abs(stride_rgb) * GetHeight();
if (size < needed) {
LOG(LS_WARNING) << "RGB buffer is not large enough";
return needed;
}
if (libyuv::ConvertFromI420(GetYPlane(), GetYPitch(), GetUPlane(),
GetUPitch(), GetVPlane(), GetVPitch(), buffer,
stride_rgb, static_cast<int>(GetWidth()),
static_cast<int>(GetHeight()), to_fourcc)) {
LOG(LS_ERROR) << "RGB type not supported: " << to_fourcc;
return 0; // 0 indicates error
}
return needed;
}
// TODO(fbarchard): Handle odd width/height with rounding.
void VideoFrame::StretchToPlanes(
uint8* dst_y, uint8* dst_u, uint8* dst_v,

View File

@@ -137,7 +137,7 @@ class VideoFrame {
// not (like snprintf). Parameters size and stride_rgb are in units of bytes.
// If there is insufficient space, nothing is written.
virtual size_t ConvertToRgbBuffer(uint32 to_fourcc, uint8 *buffer,
size_t size, int stride_rgb) const = 0;
size_t size, int stride_rgb) const;
// Writes the frame into the given planes, stretched to the given width and
// height. The parameter "interpolate" controls whether to interpolate or just