From 84a180fe858fd6de9c301cd884e2f1ff341781b3 Mon Sep 17 00:00:00 2001 From: Jerome Jiang Date: Thu, 27 Apr 2023 16:15:56 -0400 Subject: [PATCH] Move TplFrameStats to public header Get ready for changes to follow: - Custom reader/writer IO functions - Codec control to get TPL stats from the encoder Move the definition of TplFrameStats to public header so applications can use them directly. Bug: b/273736974 Change-Id: Ieb0db4560ddd966df1bc01f6a7e179cc97f9bac1 --- vp9/encoder/vp9_encoder.h | 16 ---------------- vp9/encoder/vp9_tpl_model.c | 3 ++- vpx/vpx_encoder.h | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h index 4378986..7c22c80 100644 --- a/vp9/encoder/vp9_encoder.h +++ b/vp9/encoder/vp9_encoder.h @@ -324,22 +324,6 @@ typedef struct TplDepFrame { #endif } TplDepFrame; -// Used to store the stats before propagation. -typedef struct TplBlockStats { - int64_t intra_cost; - int64_t inter_cost; - int_mv mv; - int64_t recrf_rate; - int64_t recrf_dist; - int ref_frame_index; -} TplBlockStats; - -typedef struct TplFrameStats { - int frame_width; - int frame_height; - TplBlockStats *block_stats_list; -} TplFrameStats; - #define TPL_DEP_COST_SCALE_LOG2 4 // TODO(jingning) All spatially adaptive variables should go to TileDataEnc. diff --git a/vp9/encoder/vp9_tpl_model.c b/vp9/encoder/vp9_tpl_model.c index 1dff8d3..dbd7482 100644 --- a/vp9/encoder/vp9_tpl_model.c +++ b/vp9/encoder/vp9_tpl_model.c @@ -374,7 +374,8 @@ static void tpl_store_before_propagation(TplBlockStats *tpl_block_stats, tpl_block_stats_ptr->intra_cost = src_stats->intra_cost; tpl_block_stats_ptr->recrf_dist = recon_error << TPL_DEP_COST_SCALE_LOG2; tpl_block_stats_ptr->recrf_rate = rate_cost << TPL_DEP_COST_SCALE_LOG2; - tpl_block_stats_ptr->mv = src_stats->mv; + tpl_block_stats_ptr->mv_r = src_stats->mv.as_mv.row; + tpl_block_stats_ptr->mv_c = src_stats->mv.as_mv.col; tpl_block_stats_ptr->ref_frame_index = src_stats->ref_frame_index; } } diff --git a/vpx/vpx_encoder.h b/vpx/vpx_encoder.h index a0d2c87..9247231 100644 --- a/vpx/vpx_encoder.h +++ b/vpx/vpx_encoder.h @@ -252,6 +252,25 @@ enum vpx_kf_mode { VPX_KF_DISABLED = 0 /**< Encoder does not place keyframes. */ }; +/*!\brief Temporal dependency model stats for each block before propagation */ +typedef struct TplBlockStats { + int64_t intra_cost; /**< Intra cost */ + int64_t inter_cost; /**< Inter cost */ + int16_t mv_r; /**< Motion vector row */ + int16_t mv_c; /**< Motion vector col */ + int64_t recrf_rate; /**< Rate from reconstructed ref frame */ + int64_t recrf_dist; /**< Distortion from reconstructed ref frame */ + int ref_frame_index; /**< Ref frame index */ +} TplBlockStats; + +/*!\brief Temporal dependency model stats for each frame before propagation */ +typedef struct TplFrameStats { + int frame_width; /**< Frame width */ + int frame_height; /**< Frame height */ + // Size of the list can be calculated from frame_width and frame_height. + TplBlockStats *block_stats_list; /**< List of tpl stats for each block */ +} TplFrameStats; + /*!\brief Encoded Frame Flags * * This type indicates a bitfield to be passed to vpx_codec_encode(), defining -- 2.7.4