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

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

Issue 2557323002: Revert of Add ability to scale to arbitrary factors (Closed)
Patch Set: 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);
29 virtual ~VideoAdapter(); 28 virtual ~VideoAdapter();
30 29
31 // Return the adapted resolution and cropping parameters given the 30 // Return the adapted resolution and cropping parameters given the
32 // input resolution. The input frame should first be cropped, then 31 // input resolution. The input frame should first be cropped, then
33 // scaled to the final output resolution. Returns true if the frame 32 // scaled to the final output resolution. Returns true if the frame
34 // should be adapted, and false if it should be dropped. 33 // should be adapted, and false if it should be dropped.
35 bool AdaptFrameResolution(int in_width, 34 bool AdaptFrameResolution(int in_width,
36 int in_height, 35 int in_height,
37 int64_t in_timestamp_ns, 36 int64_t in_timestamp_ns,
38 int* cropped_width, 37 int* cropped_width,
(...skipping 18 matching lines...) Expand all
57 private: 56 private:
58 // Determine if frame should be dropped based on input fps and requested fps. 57 // Determine if frame should be dropped based on input fps and requested fps.
59 bool KeepFrame(int64_t in_timestamp_ns); 58 bool KeepFrame(int64_t in_timestamp_ns);
60 59
61 int frames_in_; // Number of input frames. 60 int frames_in_; // Number of input frames.
62 int frames_out_; // Number of output frames. 61 int frames_out_; // Number of output frames.
63 int frames_scaled_; // Number of frames scaled. 62 int frames_scaled_; // Number of frames scaled.
64 int adaption_changes_; // Number of changes in scale factor. 63 int adaption_changes_; // Number of changes in scale factor.
65 int previous_width_; // Previous adapter output width. 64 int previous_width_; // Previous adapter output width.
66 int previous_height_; // Previous adapter output height. 65 int previous_height_; // Previous adapter output height.
67 // Resolution must be divisible by this factor.
68 const int required_resolution_alignment_;
69 // The target timestamp for the next frame based on requested format. 66 // The target timestamp for the next frame based on requested format.
70 rtc::Optional<int64_t> next_frame_timestamp_ns_ GUARDED_BY(critical_section_); 67 rtc::Optional<int64_t> next_frame_timestamp_ns_ GUARDED_BY(critical_section_);
71 68
72 // Max number of pixels requested via calls to OnOutputFormatRequest, 69 // Max number of pixels requested via calls to OnOutputFormatRequest,
73 // OnResolutionRequest respectively. 70 // OnResolutionRequest respectively.
74 // The adapted output format is the minimum of these. 71 // The adapted output format is the minimum of these.
75 rtc::Optional<VideoFormat> requested_format_ GUARDED_BY(critical_section_); 72 rtc::Optional<VideoFormat> requested_format_ GUARDED_BY(critical_section_);
76 int resolution_request_max_pixel_count_ GUARDED_BY(critical_section_); 73 int resolution_request_max_pixel_count_ GUARDED_BY(critical_section_);
77 int resolution_request_max_pixel_count_step_up_ GUARDED_BY(critical_section_); 74 int resolution_request_max_pixel_count_step_up_ GUARDED_BY(critical_section_);
78 75
79 // The critical section to protect the above variables. 76 // The critical section to protect the above variables.
80 rtc::CriticalSection critical_section_; 77 rtc::CriticalSection critical_section_;
81 78
82 RTC_DISALLOW_COPY_AND_ASSIGN(VideoAdapter); 79 RTC_DISALLOW_COPY_AND_ASSIGN(VideoAdapter);
83 }; 80 };
84 81
85 } // namespace cricket 82 } // namespace cricket
86 83
87 #endif // WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_ 84 #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