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:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user