Chromium Code Reviews| Index: webrtc/media/base/videoframefactory.h |
| diff --git a/webrtc/media/base/videoframefactory.h b/webrtc/media/base/videoframefactory.h |
| index 6aa2ce51733b0c01ea8d5187ace63865a2d32571..0f5b146a4f43ea2856350aaccccaf456155f7b19 100644 |
| --- a/webrtc/media/base/videoframefactory.h |
| +++ b/webrtc/media/base/videoframefactory.h |
| @@ -27,6 +27,21 @@ class VideoFrameFactory { |
| VideoFrameFactory() : apply_rotation_(false) {} |
| virtual ~VideoFrameFactory() {} |
| + // Convert a CapturedFrame to a VideoFrame. |width| and |height| |
| + // give the desired size, and the factory is expected to first crop |
| + // the frame to get a matching aspect ratio, and then scale it to |
| + // the right size. The size refers the the image before application |
| + // of |input_frame->rotation|. Subclasses usually only need to |
| + // override CreateScaledCroppedFrame, see below. |
| + virtual std::unique_ptr<VideoFrame> CreateScaledFrame( |
| + const CapturedFrame* input_frame, |
| + int width, |
| + int height) const; |
| + |
| + // The CreateAliasedFrame methods are deprecated, since cropping is |
| + // no longer supported, and we don't want raw pointer return types. |
| + // TODO(nisse): Delete when all users are updated. |
| + |
| // The returned frame aliases the aliased_frame if the input color |
| // space allows for aliasing, otherwise a color conversion will |
| // occur. Returns NULL if conversion fails. |
| @@ -35,8 +50,11 @@ class VideoFrameFactory { |
| // size |cropped_width| x |cropped_height|. |
| virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame, |
| int cropped_width, |
| - int cropped_height) const = 0; |
| - |
| + int cropped_height) const { |
| + // Dummy default implementation, to make it easier to delete in |
| + // subclasses. |
| + return NULL; |
|
perkj_webrtc
2016/05/11 10:05:17
return nullptr;
|
| + } |
| // The returned frame will be a center crop of |input_frame| with size |
| // |cropped_width| x |cropped_height|, scaled to |output_width| x |
| // |output_height|. |
| @@ -49,6 +67,18 @@ class VideoFrameFactory { |
| void SetApplyRotation(bool enable) { apply_rotation_ = enable; } |
| protected: |
| + // Similar to CreateScaledFrame, but gets cropping parameters as |
| + // inputs, and relies on the caller to choose them so that aspect |
| + // ration is preserved. |
| + virtual std::unique_ptr<VideoFrame> CreateScaledCroppedFrame( |
| + const CapturedFrame* input_frame, |
| + int crop_x, |
| + int crop_y, |
| + int crop_width, |
|
perkj_webrtc
2016/05/11 10:05:17
please document what the arguments mean.
nisse-webrtc
2016/05/12 12:23:06
I'm adding a comment. I'm also renaming the method
|
| + int crop_height, |
| + int dst_width, |
| + int dst_height) const; |
| + |
| bool apply_rotation_; |
| private: |