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

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

Issue 2558243003: Reland of Add ability to scale to arbitrary factors (Closed)
Patch Set: revert changes to vie_encoder Created 4 years 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
« no previous file with comments | « webrtc/media/base/adaptedvideotracksource.cc ('k') | webrtc/media/base/videoadapter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2010 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_VIDEOADAPTER_H_ 11 #ifndef WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_
12 #define WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_ 12 #define WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_
13 13
14 #include "webrtc/base/constructormagic.h" 14 #include "webrtc/base/constructormagic.h"
15 #include "webrtc/base/criticalsection.h" 15 #include "webrtc/base/criticalsection.h"
16 #include "webrtc/base/optional.h" 16 #include "webrtc/base/optional.h"
17 #include "webrtc/media/base/videocommon.h" 17 #include "webrtc/media/base/videocommon.h"
18 18
19 namespace cricket { 19 namespace cricket {
20 20
21 // VideoAdapter adapts an input video frame to an output frame based on the 21 // VideoAdapter adapts an input video frame to an output frame based on the
22 // specified input and output formats. The adaptation includes dropping frames 22 // specified input and output formats. The adaptation includes dropping frames
23 // to reduce frame rate and scaling frames. 23 // to reduce frame rate and scaling frames.
24 // VideoAdapter is thread safe. 24 // VideoAdapter is thread safe.
25 class VideoAdapter { 25 class VideoAdapter {
26 public: 26 public:
27 VideoAdapter(); 27 VideoAdapter();
28 VideoAdapter(int required_resolution_alignment);
28 virtual ~VideoAdapter(); 29 virtual ~VideoAdapter();
29 30
30 // Return the adapted resolution and cropping parameters given the 31 // Return the adapted resolution and cropping parameters given the
31 // input resolution. The input frame should first be cropped, then 32 // input resolution. The input frame should first be cropped, then
32 // scaled to the final output resolution. Returns true if the frame 33 // scaled to the final output resolution. Returns true if the frame
33 // should be adapted, and false if it should be dropped. 34 // should be adapted, and false if it should be dropped.
34 bool AdaptFrameResolution(int in_width, 35 bool AdaptFrameResolution(int in_width,
35 int in_height, 36 int in_height,
36 int64_t in_timestamp_ns, 37 int64_t in_timestamp_ns,
37 int* cropped_width, 38 int* cropped_width,
(...skipping 18 matching lines...) Expand all
56 private: 57 private:
57 // Determine if frame should be dropped based on input fps and requested fps. 58 // Determine if frame should be dropped based on input fps and requested fps.
58 bool KeepFrame(int64_t in_timestamp_ns); 59 bool KeepFrame(int64_t in_timestamp_ns);
59 60
60 int frames_in_; // Number of input frames. 61 int frames_in_; // Number of input frames.
61 int frames_out_; // Number of output frames. 62 int frames_out_; // Number of output frames.
62 int frames_scaled_; // Number of frames scaled. 63 int frames_scaled_; // Number of frames scaled.
63 int adaption_changes_; // Number of changes in scale factor. 64 int adaption_changes_; // Number of changes in scale factor.
64 int previous_width_; // Previous adapter output width. 65 int previous_width_; // Previous adapter output width.
65 int previous_height_; // Previous adapter output height. 66 int previous_height_; // Previous adapter output height.
67 // Resolution must be divisible by this factor.
68 const int required_resolution_alignment_;
66 // The target timestamp for the next frame based on requested format. 69 // The target timestamp for the next frame based on requested format.
67 rtc::Optional<int64_t> next_frame_timestamp_ns_ GUARDED_BY(critical_section_); 70 rtc::Optional<int64_t> next_frame_timestamp_ns_ GUARDED_BY(critical_section_);
68 71
69 // Max number of pixels requested via calls to OnOutputFormatRequest, 72 // Max number of pixels requested via calls to OnOutputFormatRequest,
70 // OnResolutionRequest respectively. 73 // OnResolutionRequest respectively.
71 // The adapted output format is the minimum of these. 74 // The adapted output format is the minimum of these.
72 rtc::Optional<VideoFormat> requested_format_ GUARDED_BY(critical_section_); 75 rtc::Optional<VideoFormat> requested_format_ GUARDED_BY(critical_section_);
73 int resolution_request_max_pixel_count_ GUARDED_BY(critical_section_); 76 int resolution_request_max_pixel_count_ GUARDED_BY(critical_section_);
74 int resolution_request_max_pixel_count_step_up_ GUARDED_BY(critical_section_); 77 bool step_up_ GUARDED_BY(critical_section_);
75 78
76 // The critical section to protect the above variables. 79 // The critical section to protect the above variables.
77 rtc::CriticalSection critical_section_; 80 rtc::CriticalSection critical_section_;
78 81
79 RTC_DISALLOW_COPY_AND_ASSIGN(VideoAdapter); 82 RTC_DISALLOW_COPY_AND_ASSIGN(VideoAdapter);
80 }; 83 };
81 84
82 } // namespace cricket 85 } // namespace cricket
83 86
84 #endif // WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_ 87 #endif // WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_
OLDNEW
« no previous file with comments | « webrtc/media/base/adaptedvideotracksource.cc ('k') | webrtc/media/base/videoadapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698