1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/timing.h"
13*77c1e3ccSAndroid Build Coastguard Worker
14*77c1e3ccSAndroid Build Coastguard Worker /* Tables for AV1 max bitrates for different levels of main and high tier.
15*77c1e3ccSAndroid Build Coastguard Worker * The tables are in Kbps instead of Mbps in the specification.
16*77c1e3ccSAndroid Build Coastguard Worker * Note that depending on the profile, a multiplier is needed.
17*77c1e3ccSAndroid Build Coastguard Worker */
18*77c1e3ccSAndroid Build Coastguard Worker #define UNDEFINED_RATE \
19*77c1e3ccSAndroid Build Coastguard Worker (1 << 21) // Placeholder rate for levels with undefined rate
20*77c1e3ccSAndroid Build Coastguard Worker #define INVALID_RATE \
21*77c1e3ccSAndroid Build Coastguard Worker (0) // For invalid profile-level configuration, set rate to 0
22*77c1e3ccSAndroid Build Coastguard Worker
23*77c1e3ccSAndroid Build Coastguard Worker /* Max Bitrates for levels of Main Tier in kbps. Bitrate in main_kbps [31] */
24*77c1e3ccSAndroid Build Coastguard Worker /* is a dummy value. The decoder model is not applicable for level 31. */
25*77c1e3ccSAndroid Build Coastguard Worker static int32_t main_kbps[1 << LEVEL_BITS] = {
26*77c1e3ccSAndroid Build Coastguard Worker 1500, 3000, UNDEFINED_RATE, UNDEFINED_RATE,
27*77c1e3ccSAndroid Build Coastguard Worker 6000, 10000, UNDEFINED_RATE, UNDEFINED_RATE,
28*77c1e3ccSAndroid Build Coastguard Worker 12000, 20000, UNDEFINED_RATE, UNDEFINED_RATE,
29*77c1e3ccSAndroid Build Coastguard Worker 30000, 40000, 60000, 60000,
30*77c1e3ccSAndroid Build Coastguard Worker 60000, 100000, 160000, 160000,
31*77c1e3ccSAndroid Build Coastguard Worker UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE,
32*77c1e3ccSAndroid Build Coastguard Worker UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE,
33*77c1e3ccSAndroid Build Coastguard Worker UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE
34*77c1e3ccSAndroid Build Coastguard Worker };
35*77c1e3ccSAndroid Build Coastguard Worker
36*77c1e3ccSAndroid Build Coastguard Worker /* Max Bitrates for levels of High Tier in kbps. Bitrate in high_kbps [31] */
37*77c1e3ccSAndroid Build Coastguard Worker /* is a dummy value. The decoder model is not applicable for level 31. */
38*77c1e3ccSAndroid Build Coastguard Worker static int32_t high_kbps[1 << LEVEL_BITS] = {
39*77c1e3ccSAndroid Build Coastguard Worker INVALID_RATE, INVALID_RATE, INVALID_RATE, INVALID_RATE,
40*77c1e3ccSAndroid Build Coastguard Worker INVALID_RATE, INVALID_RATE, INVALID_RATE, INVALID_RATE,
41*77c1e3ccSAndroid Build Coastguard Worker 30000, 50000, UNDEFINED_RATE, UNDEFINED_RATE,
42*77c1e3ccSAndroid Build Coastguard Worker 100000, 160000, 240000, 240000,
43*77c1e3ccSAndroid Build Coastguard Worker 240000, 480000, 800000, 800000,
44*77c1e3ccSAndroid Build Coastguard Worker UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE,
45*77c1e3ccSAndroid Build Coastguard Worker UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE,
46*77c1e3ccSAndroid Build Coastguard Worker UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE, UNDEFINED_RATE
47*77c1e3ccSAndroid Build Coastguard Worker };
48*77c1e3ccSAndroid Build Coastguard Worker
49*77c1e3ccSAndroid Build Coastguard Worker /* BitrateProfileFactor */
50*77c1e3ccSAndroid Build Coastguard Worker static int bitrate_profile_factor[1 << PROFILE_BITS] = {
51*77c1e3ccSAndroid Build Coastguard Worker 1, 2, 3, 0, 0, 0, 0, 0
52*77c1e3ccSAndroid Build Coastguard Worker };
53*77c1e3ccSAndroid Build Coastguard Worker
av1_max_level_bitrate(BITSTREAM_PROFILE seq_profile,int seq_level_idx,int seq_tier)54*77c1e3ccSAndroid Build Coastguard Worker int64_t av1_max_level_bitrate(BITSTREAM_PROFILE seq_profile, int seq_level_idx,
55*77c1e3ccSAndroid Build Coastguard Worker int seq_tier) {
56*77c1e3ccSAndroid Build Coastguard Worker int64_t bitrate;
57*77c1e3ccSAndroid Build Coastguard Worker
58*77c1e3ccSAndroid Build Coastguard Worker if (seq_tier) {
59*77c1e3ccSAndroid Build Coastguard Worker bitrate = high_kbps[seq_level_idx] * bitrate_profile_factor[seq_profile];
60*77c1e3ccSAndroid Build Coastguard Worker } else {
61*77c1e3ccSAndroid Build Coastguard Worker bitrate = main_kbps[seq_level_idx] * bitrate_profile_factor[seq_profile];
62*77c1e3ccSAndroid Build Coastguard Worker }
63*77c1e3ccSAndroid Build Coastguard Worker
64*77c1e3ccSAndroid Build Coastguard Worker return bitrate * 1000;
65*77c1e3ccSAndroid Build Coastguard Worker }
66*77c1e3ccSAndroid Build Coastguard Worker
av1_set_aom_dec_model_info(aom_dec_model_info_t * decoder_model)67*77c1e3ccSAndroid Build Coastguard Worker void av1_set_aom_dec_model_info(aom_dec_model_info_t *decoder_model) {
68*77c1e3ccSAndroid Build Coastguard Worker decoder_model->encoder_decoder_buffer_delay_length = 16;
69*77c1e3ccSAndroid Build Coastguard Worker decoder_model->buffer_removal_time_length = 10;
70*77c1e3ccSAndroid Build Coastguard Worker decoder_model->frame_presentation_time_length = 10;
71*77c1e3ccSAndroid Build Coastguard Worker }
72*77c1e3ccSAndroid Build Coastguard Worker
av1_set_dec_model_op_parameters(aom_dec_model_op_parameters_t * op_params)73*77c1e3ccSAndroid Build Coastguard Worker void av1_set_dec_model_op_parameters(aom_dec_model_op_parameters_t *op_params) {
74*77c1e3ccSAndroid Build Coastguard Worker op_params->decoder_model_param_present_flag = 1;
75*77c1e3ccSAndroid Build Coastguard Worker op_params->decoder_buffer_delay = 90000 >> 1; // 0.5 s
76*77c1e3ccSAndroid Build Coastguard Worker op_params->encoder_buffer_delay = 90000 >> 1; // 0.5 s
77*77c1e3ccSAndroid Build Coastguard Worker op_params->low_delay_mode_flag = 0;
78*77c1e3ccSAndroid Build Coastguard Worker op_params->display_model_param_present_flag = 1;
79*77c1e3ccSAndroid Build Coastguard Worker op_params->initial_display_delay = 8; // 8 frames delay
80*77c1e3ccSAndroid Build Coastguard Worker }
81*77c1e3ccSAndroid Build Coastguard Worker
av1_set_resource_availability_parameters(aom_dec_model_op_parameters_t * op_params)82*77c1e3ccSAndroid Build Coastguard Worker void av1_set_resource_availability_parameters(
83*77c1e3ccSAndroid Build Coastguard Worker aom_dec_model_op_parameters_t *op_params) {
84*77c1e3ccSAndroid Build Coastguard Worker op_params->decoder_model_param_present_flag = 0;
85*77c1e3ccSAndroid Build Coastguard Worker op_params->decoder_buffer_delay =
86*77c1e3ccSAndroid Build Coastguard Worker 70000; // Resource availability mode default
87*77c1e3ccSAndroid Build Coastguard Worker op_params->encoder_buffer_delay =
88*77c1e3ccSAndroid Build Coastguard Worker 20000; // Resource availability mode default
89*77c1e3ccSAndroid Build Coastguard Worker op_params->low_delay_mode_flag = 0; // Resource availability mode default
90*77c1e3ccSAndroid Build Coastguard Worker op_params->display_model_param_present_flag = 1;
91*77c1e3ccSAndroid Build Coastguard Worker op_params->initial_display_delay = 8; // 8 frames delay
92*77c1e3ccSAndroid Build Coastguard Worker }
93