Home | History | Annotate | Download | only in encoder
      1 /*
      2  * Copyright (c) 2019, 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 #ifndef AOM_AV1_ENCODER_LEVEL_H_
     13 #define AOM_AV1_ENCODER_LEVEL_H_
     14 
     15 #include "av1/common/enums.h"
     16 
     17 struct AV1_COMP;
     18 
     19 // AV1 Level Specifications
     20 typedef struct {
     21   AV1_LEVEL level;
     22   int max_picture_size;
     23   int max_h_size;
     24   int max_v_size;
     25   int max_header_rate;
     26   int max_tile_rate;
     27   int max_tiles;
     28   int max_tile_cols;
     29   int64_t max_display_rate;
     30   int64_t max_decode_rate;
     31   double main_mbps;
     32   double high_mbps;
     33   double main_cr;
     34   double high_cr;
     35 } AV1LevelSpec;
     36 
     37 typedef struct {
     38   int64_t ts_start;
     39   int64_t ts_end;
     40   int pic_size;
     41   int frame_header_count;
     42   int tiles;
     43   int show_frame;
     44   int show_existing_frame;
     45 } FrameRecord;
     46 
     47 // Record frame info. in a rolling window.
     48 #define FRAME_WINDOW_SIZE 256
     49 typedef struct {
     50   FrameRecord buf[FRAME_WINDOW_SIZE];
     51   int num;    // Number of FrameRecord stored in the buffer.
     52   int start;  // Buffer index of the first FrameRecord.
     53 } FrameWindowBuffer;
     54 
     55 // Used to keep track of AV1 Level Stats. Currently unimplemented.
     56 typedef struct {
     57   uint64_t total_compressed_size;
     58   int max_tile_size;
     59   int max_superres_tile_width;
     60   int min_cropped_tile_width;
     61   int min_cropped_tile_height;
     62   int tile_width_is_valid;
     63   int min_frame_width;
     64   int min_frame_height;
     65   double total_time_encoded;
     66   double min_cr;
     67 } AV1LevelStats;
     68 
     69 typedef struct {
     70   AV1LevelStats level_stats;
     71   AV1LevelSpec level_spec;
     72 } AV1LevelInfo;
     73 
     74 void av1_update_level_info(struct AV1_COMP *cpi, size_t size, int64_t ts_start,
     75                            int64_t ts_end);
     76 
     77 // Return sequence level indices in seq_level_idx[MAX_NUM_OPERATING_POINTS].
     78 aom_codec_err_t av1_get_seq_level_idx(const struct AV1_COMP *cpi,
     79                                       int *seq_level_idx);
     80 
     81 #endif  // AOM_AV1_ENCODER_LEVEL_H_
     82