LCOV - code coverage report
Current view: top level - third_party/aom/av1/encoder - firstpass.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 5 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef AV1_ENCODER_FIRSTPASS_H_
      13             : #define AV1_ENCODER_FIRSTPASS_H_
      14             : 
      15             : #include "av1/encoder/lookahead.h"
      16             : #include "av1/encoder/ratectrl.h"
      17             : 
      18             : #ifdef __cplusplus
      19             : extern "C" {
      20             : #endif
      21             : 
      22             : #if CONFIG_FP_MB_STATS
      23             : 
      24             : #define FPMB_DCINTRA_MASK 0x01
      25             : 
      26             : #define FPMB_MOTION_ZERO_MASK 0x02
      27             : #define FPMB_MOTION_LEFT_MASK 0x04
      28             : #define FPMB_MOTION_RIGHT_MASK 0x08
      29             : #define FPMB_MOTION_UP_MASK 0x10
      30             : #define FPMB_MOTION_DOWN_MASK 0x20
      31             : 
      32             : #define FPMB_ERROR_SMALL_MASK 0x40
      33             : #define FPMB_ERROR_LARGE_MASK 0x80
      34             : #define FPMB_ERROR_SMALL_TH 2000
      35             : #define FPMB_ERROR_LARGE_TH 48000
      36             : 
      37             : typedef struct {
      38             :   uint8_t *mb_stats_start;
      39             :   uint8_t *mb_stats_end;
      40             : } FIRSTPASS_MB_STATS;
      41             : #endif
      42             : 
      43             : #if CONFIG_EXT_REFS
      44             : // Length of the bi-predictive frame group (BFG)
      45             : // NOTE: Currently each BFG contains one backward ref (BWF) frame plus a certain
      46             : //       number of bi-predictive frames.
      47             : #define BFG_INTERVAL 2
      48             : // The maximum number of extra ALT_REF's
      49             : // NOTE: This number cannot be greater than 2 or the reference frame buffer will
      50             : //       overflow.
      51             : #define MAX_EXT_ARFS 2
      52             : #define MIN_EXT_ARF_INTERVAL 4
      53             : #endif  // CONFIG_EXT_REFS
      54             : 
      55             : #define VLOW_MOTION_THRESHOLD 950
      56             : 
      57             : typedef struct {
      58             :   double frame;
      59             :   double weight;
      60             :   double intra_error;
      61             :   double coded_error;
      62             :   double sr_coded_error;
      63             :   double pcnt_inter;
      64             :   double pcnt_motion;
      65             :   double pcnt_second_ref;
      66             :   double pcnt_neutral;
      67             :   double intra_skip_pct;
      68             :   double inactive_zone_rows;  // Image mask rows top and bottom.
      69             :   double inactive_zone_cols;  // Image mask columns at left and right edges.
      70             :   double MVr;
      71             :   double mvr_abs;
      72             :   double MVc;
      73             :   double mvc_abs;
      74             :   double MVrv;
      75             :   double MVcv;
      76             :   double mv_in_out_count;
      77             :   double new_mv_count;
      78             :   double duration;
      79             :   double count;
      80             : } FIRSTPASS_STATS;
      81             : 
      82             : typedef enum {
      83             :   KF_UPDATE = 0,
      84             :   LF_UPDATE = 1,
      85             :   GF_UPDATE = 2,
      86             :   ARF_UPDATE = 3,
      87             :   OVERLAY_UPDATE = 4,
      88             : #if CONFIG_EXT_REFS
      89             :   BRF_UPDATE = 5,            // Backward Reference Frame
      90             :   LAST_BIPRED_UPDATE = 6,    // Last Bi-predictive Frame
      91             :   BIPRED_UPDATE = 7,         // Bi-predictive Frame, but not the last one
      92             :   INTNL_OVERLAY_UPDATE = 8,  // Internal Overlay Frame
      93             :   FRAME_UPDATE_TYPES = 9
      94             : #else
      95             :   FRAME_UPDATE_TYPES = 5
      96             : #endif  // CONFIG_EXT_REFS
      97             : } FRAME_UPDATE_TYPE;
      98             : 
      99             : #define FC_ANIMATION_THRESH 0.15
     100             : typedef enum {
     101             :   FC_NORMAL = 0,
     102             :   FC_GRAPHICS_ANIMATION = 1,
     103             :   FRAME_CONTENT_TYPES = 2
     104             : } FRAME_CONTENT_TYPE;
     105             : 
     106             : typedef struct {
     107             :   unsigned char index;
     108             :   RATE_FACTOR_LEVEL rf_level[(MAX_LAG_BUFFERS * 2) + 1];
     109             :   FRAME_UPDATE_TYPE update_type[(MAX_LAG_BUFFERS * 2) + 1];
     110             :   unsigned char arf_src_offset[(MAX_LAG_BUFFERS * 2) + 1];
     111             :   unsigned char arf_update_idx[(MAX_LAG_BUFFERS * 2) + 1];
     112             :   unsigned char arf_ref_idx[(MAX_LAG_BUFFERS * 2) + 1];
     113             : #if CONFIG_EXT_REFS
     114             :   unsigned char brf_src_offset[(MAX_LAG_BUFFERS * 2) + 1];
     115             :   unsigned char bidir_pred_enabled[(MAX_LAG_BUFFERS * 2) + 1];
     116             : #endif  // CONFIG_EXT_REFS
     117             :   int bit_allocation[(MAX_LAG_BUFFERS * 2) + 1];
     118             : } GF_GROUP;
     119             : 
     120             : typedef struct {
     121             :   unsigned int section_intra_rating;
     122             :   FIRSTPASS_STATS total_stats;
     123             :   FIRSTPASS_STATS this_frame_stats;
     124             :   const FIRSTPASS_STATS *stats_in;
     125             :   const FIRSTPASS_STATS *stats_in_start;
     126             :   const FIRSTPASS_STATS *stats_in_end;
     127             :   FIRSTPASS_STATS total_left_stats;
     128             :   int first_pass_done;
     129             :   int64_t bits_left;
     130             :   double modified_error_min;
     131             :   double modified_error_max;
     132             :   double modified_error_left;
     133             :   double mb_av_energy;
     134             : 
     135             : #if CONFIG_FP_MB_STATS
     136             :   uint8_t *frame_mb_stats_buf;
     137             :   uint8_t *this_frame_mb_stats;
     138             :   FIRSTPASS_MB_STATS firstpass_mb_stats;
     139             : #endif
     140             :   // An indication of the content type of the current frame
     141             :   FRAME_CONTENT_TYPE fr_content_type;
     142             : 
     143             :   // Projected total bits available for a key frame group of frames
     144             :   int64_t kf_group_bits;
     145             : 
     146             :   // Error score of frames still to be coded in kf group
     147             :   int64_t kf_group_error_left;
     148             : 
     149             :   // The fraction for a kf groups total bits allocated to the inter frames
     150             :   double kfgroup_inter_fraction;
     151             : 
     152             :   int sr_update_lag;
     153             : 
     154             :   int kf_zeromotion_pct;
     155             :   int last_kfgroup_zeromotion_pct;
     156             :   int gf_zeromotion_pct;
     157             :   int active_worst_quality;
     158             :   int baseline_active_worst_quality;
     159             :   int extend_minq;
     160             :   int extend_maxq;
     161             :   int extend_minq_fast;
     162             : 
     163             :   GF_GROUP gf_group;
     164             : } TWO_PASS;
     165             : 
     166             : struct AV1_COMP;
     167             : 
     168             : void av1_init_first_pass(struct AV1_COMP *cpi);
     169             : void av1_rc_get_first_pass_params(struct AV1_COMP *cpi);
     170             : void av1_first_pass(struct AV1_COMP *cpi, const struct lookahead_entry *source);
     171             : void av1_end_first_pass(struct AV1_COMP *cpi);
     172             : 
     173             : void av1_init_second_pass(struct AV1_COMP *cpi);
     174             : void av1_rc_get_second_pass_params(struct AV1_COMP *cpi);
     175             : void av1_twopass_postencode_update(struct AV1_COMP *cpi);
     176             : 
     177             : // Post encode update of the rate control parameters for 2-pass
     178             : void av1_twopass_postencode_update(struct AV1_COMP *cpi);
     179             : 
     180             : void av1_calculate_next_scaled_size(const struct AV1_COMP *cpi,
     181             :                                     int *scaled_frame_width,
     182             :                                     int *scaled_frame_height);
     183             : 
     184             : #if CONFIG_FRAME_SUPERRES
     185             : // This is the size after superress scaling, which could be 1:1.
     186             : // Superres scaling happens after regular downscaling.
     187             : // TODO(afergs): Limit overall reduction to 1/2 of the original size
     188             : void av1_calculate_superres_size(const struct AV1_COMP *cpi, int *encoded_width,
     189             :                                  int *encoded_height);
     190             : #endif  // CONFIG_FRAME_SUPERRES
     191             : 
     192             : #if CONFIG_EXT_REFS
     193           0 : static INLINE int get_number_of_extra_arfs(int interval, int arf_pending) {
     194           0 :   if (arf_pending && MAX_EXT_ARFS > 0)
     195             :     return interval >= MIN_EXT_ARF_INTERVAL * (MAX_EXT_ARFS + 1)
     196             :                ? MAX_EXT_ARFS
     197           0 :                : interval >= MIN_EXT_ARF_INTERVAL * MAX_EXT_ARFS
     198             :                      ? MAX_EXT_ARFS - 1
     199           0 :                      : 0;
     200             :   else
     201           0 :     return 0;
     202             : }
     203             : #endif  // CONFIG_EXT_REFS
     204             : 
     205             : #ifdef __cplusplus
     206             : }  // extern "C"
     207             : #endif
     208             : 
     209             : #endif  // AV1_ENCODER_FIRSTPASS_H_

Generated by: LCOV version 1.13