Adding Scale for I420VideoFrame

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2910 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2012-10-11 15:33:05 +00:00
parent 80f14d20c4
commit 58849fd1ec
2 changed files with 34 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#define WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_SCALER_H_
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "common_video/interface/i420_video_frame.h"
#include "typedefs.h"
namespace webrtc {
@ -47,9 +48,13 @@ class Scaler {
// Return value: 0 - OK,
// -1 - parameter error
// -2 - scaler not set
// TODO(mikhal): Remove legacy implementation of old VideoFrame.
int Scale(const VideoFrame& src_frame,
VideoFrame* dst_frame);
int Scale(const I420VideoFrame& src_frame,
I420VideoFrame* dst_frame);
private:
// Determine if the VideoTypes are currently supported.
bool SupportedVideoType(VideoType src_video_type,

View File

@ -84,6 +84,35 @@ int Scaler::Scale(const VideoFrame& src_frame,
libyuv::FilterMode(method_));
}
// TODO(mikhal): Add test to new function. Currently not used.
int Scaler::Scale(const I420VideoFrame& src_frame,
I420VideoFrame* dst_frame) {
assert(dst_frame);
// TODO(mikhal): Add isEmpty
// if (src_frame.Buffer() == NULL || src_frame.Length() == 0)
// return -1;
if (!set_)
return -2;
// TODO(mikhal): Setting stride equal to width - should align.
dst_frame->CreateEmptyFrame(dst_width_, dst_height_, dst_width_ ,
(dst_width_ + 1) / 2, (dst_width_ + 1) / 2);
return libyuv::I420Scale(src_frame.buffer(kYPlane), src_frame.stride(kYPlane),
src_frame.buffer(kUPlane), src_frame.stride(kYPlane),
src_frame.buffer(kVPlane), src_frame.stride(kYPlane),
src_width_, src_height_,
dst_frame->buffer(kYPlane),
dst_frame->stride(kYPlane),
dst_frame->buffer(kYPlane),
dst_frame->stride(kYPlane),
dst_frame->buffer(kYPlane),
dst_frame->stride(kYPlane),
dst_width_, dst_height_,
libyuv::FilterMode(method_));
}
// TODO(mikhal): Add support for more types.
bool Scaler::SupportedVideoType(VideoType src_video_type,
VideoType dst_video_type) {