Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: webrtc/media/base/videoframefactory.h

Issue 1960073002: New method CreateScaledFrame in the VideoFrameFactory interface. Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Implement cropping. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ 11 #ifndef WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_
12 #define WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ 12 #define WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_
13 13
14 #include <memory> 14 #include <memory>
15 15
16 #include "webrtc/media/base/videoframe.h" 16 #include "webrtc/media/base/videoframe.h"
17 17
18 namespace cricket { 18 namespace cricket {
19 19
20 struct CapturedFrame; 20 struct CapturedFrame;
21 class VideoFrame; 21 class VideoFrame;
22 22
23 // Creates cricket::VideoFrames, or a subclass of cricket::VideoFrame 23 // Creates cricket::VideoFrames, or a subclass of cricket::VideoFrame
24 // depending on the subclass of VideoFrameFactory. 24 // depending on the subclass of VideoFrameFactory.
25 class VideoFrameFactory { 25 class VideoFrameFactory {
26 public: 26 public:
27 VideoFrameFactory() : apply_rotation_(false) {} 27 VideoFrameFactory() : apply_rotation_(false) {}
28 virtual ~VideoFrameFactory() {} 28 virtual ~VideoFrameFactory() {}
29 29
30 // Convert a CapturedFrame to a VideoFrame. |width| and |height|
31 // give the desired size, and the factory is expected to first crop
32 // the frame to get a matching aspect ratio, and then scale it to
33 // the right size. The size refers the the image before application
34 // of |input_frame->rotation|.
35 virtual std::unique_ptr<VideoFrame> CreateScaledFrame(
36 const CapturedFrame* input_frame,
37 int width,
38 int height) const;
39
40 // The CreateAliasedFrame methods are deprecated, since cropping is
41 // no longer supported, and we don't want raw pointer return types.
42 // TODO(nisse): Delete when all users are updated.
43
30 // The returned frame aliases the aliased_frame if the input color 44 // The returned frame aliases the aliased_frame if the input color
31 // space allows for aliasing, otherwise a color conversion will 45 // space allows for aliasing, otherwise a color conversion will
32 // occur. Returns NULL if conversion fails. 46 // occur. Returns NULL if conversion fails.
33 47
34 // The returned frame will be a center crop of |input_frame| with 48 // The returned frame will be a center crop of |input_frame| with
35 // size |cropped_width| x |cropped_height|. 49 // size |cropped_width| x |cropped_height|.
36 virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame, 50 virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame,
37 int cropped_width, 51 int cropped_width,
38 int cropped_height) const = 0; 52 int cropped_height) const {
39 53 // Dummy default implementation, to make it easier to delete in
54 // subclasses.
55 return NULL;
56 }
40 // The returned frame will be a center crop of |input_frame| with size 57 // The returned frame will be a center crop of |input_frame| with size
41 // |cropped_width| x |cropped_height|, scaled to |output_width| x 58 // |cropped_width| x |cropped_height|, scaled to |output_width| x
42 // |output_height|. 59 // |output_height|.
43 virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame, 60 virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame,
44 int cropped_input_width, 61 int cropped_input_width,
45 int cropped_input_height, 62 int cropped_input_height,
46 int output_width, 63 int output_width,
47 int output_height) const; 64 int output_height) const;
48 65
49 void SetApplyRotation(bool enable) { apply_rotation_ = enable; } 66 void SetApplyRotation(bool enable) { apply_rotation_ = enable; }
50 67
51 protected: 68 protected:
52 bool apply_rotation_; 69 bool apply_rotation_;
53 70
54 private: 71 private:
55 // An internal frame buffer to avoid reallocations. It is mutable because it 72 // An internal frame buffer to avoid reallocations. It is mutable because it
56 // does not affect behaviour, only performance. 73 // does not affect behaviour, only performance.
57 mutable std::unique_ptr<VideoFrame> output_frame_; 74 mutable std::unique_ptr<VideoFrame> output_frame_;
58 }; 75 };
59 76
60 } // namespace cricket 77 } // namespace cricket
61 78
62 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ 79 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698