1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #ifndef VIDEO_ALIGNMENT_ADJUSTER_H_ 12*d9f75844SAndroid Build Coastguard Worker #define VIDEO_ALIGNMENT_ADJUSTER_H_ 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker #include "api/video_codecs/video_encoder.h" 15*d9f75844SAndroid Build Coastguard Worker #include "video/config/video_encoder_config.h" 16*d9f75844SAndroid Build Coastguard Worker 17*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 18*d9f75844SAndroid Build Coastguard Worker 19*d9f75844SAndroid Build Coastguard Worker class AlignmentAdjuster { 20*d9f75844SAndroid Build Coastguard Worker public: 21*d9f75844SAndroid Build Coastguard Worker // Returns the resolution alignment requested by the encoder (i.e 22*d9f75844SAndroid Build Coastguard Worker // `EncoderInfo::requested_resolution_alignment` which ensures that delivered 23*d9f75844SAndroid Build Coastguard Worker // frames to the encoder are divisible by this alignment). 24*d9f75844SAndroid Build Coastguard Worker // 25*d9f75844SAndroid Build Coastguard Worker // If `EncoderInfo::apply_alignment_to_all_simulcast_layers` is enabled, the 26*d9f75844SAndroid Build Coastguard Worker // alignment will be adjusted to ensure that each simulcast layer also is 27*d9f75844SAndroid Build Coastguard Worker // divisible by `requested_resolution_alignment`. The configured scale factors 28*d9f75844SAndroid Build Coastguard Worker // `scale_resolution_down_by` may be adjusted to a common multiple to limit 29*d9f75844SAndroid Build Coastguard Worker // the alignment value to avoid largely cropped frames and possibly with an 30*d9f75844SAndroid Build Coastguard Worker // aspect ratio far from the original. 31*d9f75844SAndroid Build Coastguard Worker 32*d9f75844SAndroid Build Coastguard Worker // Note: `max_layers` currently only taken into account when using default 33*d9f75844SAndroid Build Coastguard Worker // scale factors. 34*d9f75844SAndroid Build Coastguard Worker static int GetAlignmentAndMaybeAdjustScaleFactors( 35*d9f75844SAndroid Build Coastguard Worker const VideoEncoder::EncoderInfo& info, 36*d9f75844SAndroid Build Coastguard Worker VideoEncoderConfig* config, 37*d9f75844SAndroid Build Coastguard Worker absl::optional<size_t> max_layers); 38*d9f75844SAndroid Build Coastguard Worker }; 39*d9f75844SAndroid Build Coastguard Worker 40*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 41*d9f75844SAndroid Build Coastguard Worker 42*d9f75844SAndroid Build Coastguard Worker #endif // VIDEO_ALIGNMENT_ADJUSTER_H_ 43