chromium/third_party/libaom/source/libaom/av1/encoder/level.h

/*
 * Copyright (c) 2019, Alliance for Open Media. All rights reserved.
 *
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */

#ifndef AOM_AV1_ENCODER_LEVEL_H_
#define AOM_AV1_ENCODER_LEVEL_H_

#include "av1/common/enums.h"

struct AV1_COMP;

// AV1 Level Specifications
AV1LevelSpec;

FrameRecord;

// Record frame info. in a rolling window.
#define FRAME_WINDOW_SIZE
FrameWindowBuffer;

AV1LevelStats;

// The following data structures are for the decoder model.
FRAME_BUFFER;

// Interval of bits transmission for a DFG(Decodable Frame Group).
DFG_INTERVAL;

#define DFG_INTERVAL_QUEUE_SIZE
DFG_INTERVAL_QUEUE;

enum {} UENUM1BYTE();

enum {} UENUM1BYTE();

#define BUFFER_POOL_MAX_SIZE
DECODER_MODEL;

AV1LevelInfo;

AV1LevelParams;

static inline int is_in_operating_point(int operating_point,
                                        int temporal_layer_id,
                                        int spatial_layer_id) {}

void av1_init_level_info(struct AV1_COMP *cpi);

void av1_update_level_info(struct AV1_COMP *cpi, size_t size, int64_t ts_start,
                           int64_t ts_end);

// Return sequence level indices in seq_level_idx[MAX_NUM_OPERATING_POINTS].
aom_codec_err_t av1_get_seq_level_idx(const SequenceHeader *seq_params,
                                      const AV1LevelParams *level_params,
                                      int *seq_level_idx);

aom_codec_err_t av1_get_target_seq_level_idx(const SequenceHeader *seq_params,
                                             const AV1LevelParams *level_params,
                                             int *target_seq_level_idx);

// This function uses the decoder model to check whether there could be
// SMOOTHING_BUFFER_UNDERFLOW or SMOOTHING_BUFFER_OVERFLOW. It does not
// update the content of decoder_model, and can be used to target certain
// encoding level in the recode loop.
DECODER_MODEL_STATUS av1_decoder_model_try_smooth_buf(
    const struct AV1_COMP *const cpi, size_t coded_bits,
    const DECODER_MODEL *const decoder_model);

// Return max bitrate(bps) for given level.
double av1_get_max_bitrate_for_level(AV1_LEVEL level_index, int tier,
                                     BITSTREAM_PROFILE profile);

// Get max number of tiles and tile columns for given level.
void av1_get_max_tiles_for_level(AV1_LEVEL level_index, int *const max_tiles,
                                 int *const max_tile_cols);

// Return minimum compression ratio for given level.
double av1_get_min_cr_for_level(AV1_LEVEL level_index, int tier,
                                int is_still_picture);
#endif  // AOM_AV1_ENCODER_LEVEL_H_