tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

timing.c (4098B)


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