blob: 36ac062e91d71d6c1c1cbd01a32edcbcc4fa7223 [file] [log] [blame]
Åsa Perssonc5a74ff2020-09-20 17:50:00 +02001/*
2 * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef VIDEO_ALIGNMENT_ADJUSTER_H_
12#define VIDEO_ALIGNMENT_ADJUSTER_H_
13
14#include "api/video_codecs/video_encoder.h"
Jonas Oreland6c2dae22022-09-29 10:28:24 +020015#include "video/config/video_encoder_config.h"
Åsa Perssonc5a74ff2020-09-20 17:50:00 +020016
17namespace webrtc {
18
19class AlignmentAdjuster {
20 public:
21 // Returns the resolution alignment requested by the encoder (i.e
Artem Titovcfea2182021-08-10 01:22:31 +020022 // `EncoderInfo::requested_resolution_alignment` which ensures that delivered
Åsa Perssonc5a74ff2020-09-20 17:50:00 +020023 // frames to the encoder are divisible by this alignment).
24 //
Artem Titovcfea2182021-08-10 01:22:31 +020025 // If `EncoderInfo::apply_alignment_to_all_simulcast_layers` is enabled, the
Åsa Perssonc5a74ff2020-09-20 17:50:00 +020026 // alignment will be adjusted to ensure that each simulcast layer also is
Artem Titovab30d722021-07-27 16:22:11 +020027 // divisible by `requested_resolution_alignment`. The configured scale factors
28 // `scale_resolution_down_by` may be adjusted to a common multiple to limit
Åsa Perssonc5a74ff2020-09-20 17:50:00 +020029 // the alignment value to avoid largely cropped frames and possibly with an
30 // aspect ratio far from the original.
Åsa Perssona24d35e2021-01-19 10:25:10 +010031
Artem Titovab30d722021-07-27 16:22:11 +020032 // Note: `max_layers` currently only taken into account when using default
Åsa Perssona24d35e2021-01-19 10:25:10 +010033 // scale factors.
Åsa Perssonc5a74ff2020-09-20 17:50:00 +020034 static int GetAlignmentAndMaybeAdjustScaleFactors(
35 const VideoEncoder::EncoderInfo& info,
Åsa Perssona24d35e2021-01-19 10:25:10 +010036 VideoEncoderConfig* config,
37 absl::optional<size_t> max_layers);
Åsa Perssonc5a74ff2020-09-20 17:50:00 +020038};
39
40} // namespace webrtc
41
42#endif // VIDEO_ALIGNMENT_ADJUSTER_H_