• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2023 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 /*!\file
12  * \brief Describes the TPL stats descriptor and associated operations
13  *
14  */
15 #ifndef VPX_VPX_VPX_TPL_H_
16 #define VPX_VPX_VPX_TPL_H_
17 
18 #include <stdio.h>
19 
20 #include "./vpx_integer.h"
21 #include "./vpx_codec.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /*!\brief Current ABI version number
28  *
29  * \internal
30  * If this file is altered in any way that changes the ABI, this value
31  * must be bumped.  Examples include, but are not limited to, changing
32  * types, removing or reassigning enums, adding/removing/rearranging
33  * fields to structures
34  */
35 #define VPX_TPL_ABI_VERSION (2) /**<\hideinitializer*/
36 
37 /*!\brief Temporal dependency model stats for each block before propagation */
38 typedef struct VpxTplBlockStats {
39   int16_t row;         /**< Pixel row of the top left corner */
40   int16_t col;         /**< Pixel col of the top left corner */
41   int64_t intra_cost;  /**< Intra cost */
42   int64_t inter_cost;  /**< Inter cost */
43   int16_t mv_r;        /**< Motion vector row */
44   int16_t mv_c;        /**< Motion vector col */
45   int64_t recrf_rate;  /**< Rate from reconstructed ref frame */
46   int64_t recrf_dist;  /**< Distortion from reconstructed ref frame */
47   int ref_frame_index; /**< Ref frame index in the ref frame buffer */
48 } VpxTplBlockStats;
49 
50 /*!\brief Temporal dependency model stats for each frame before propagation */
51 typedef struct VpxTplFrameStats {
52   int frame_width;  /**< Frame width */
53   int frame_height; /**< Frame height */
54   int num_blocks;   /**< Number of blocks. Size of block_stats_list */
55   VpxTplBlockStats *block_stats_list; /**< List of tpl stats for each block */
56 } VpxTplFrameStats;
57 
58 /*!\brief Temporal dependency model stats for each GOP before propagation */
59 typedef struct VpxTplGopStats {
60   int size; /**< GOP size, also the size of frame_stats_list. */
61   VpxTplFrameStats *frame_stats_list; /**< List of tpl stats for each frame */
62 } VpxTplGopStats;
63 
64 /*!\brief Write VpxTplGopStats to file
65  *
66  * Accepts an opened file handle and writes \p tpl_gop_stats.
67  *
68  * \param[in]    tpl_file       A FILE pointer that's already been opened.
69  * \param[in]    tpl_gop_stats  VpxTplGopStats that contains TPL stats for the
70  *                              whole GOP.
71  *
72  * \return VPX_CODEC_OK if TPL stats are successfully written.
73  */
74 vpx_codec_err_t vpx_write_tpl_gop_stats(FILE *tpl_file,
75                                         const VpxTplGopStats *tpl_gop_stats);
76 
77 /*!\brief Read VpxTplGopStats from file
78  *
79  * Accepts an opened file handle and reads TPL stats and stores them into
80  * \p tpl_gop_stats. Allocates memory for TPL stats.
81  *
82  * \param[in]     tpl_file       A FILE pointer that's already been opened.
83  * \param[out]    tpl_gop_stats  VpxTplGopStats that contains TPL stats for the
84  *                               whole GOP.
85  *
86  * \return VPX_CODEC_OK if TPL stats are successfully read from file.
87  */
88 vpx_codec_err_t vpx_read_tpl_gop_stats(FILE *tpl_file,
89                                        VpxTplGopStats *tpl_gop_stats);
90 
91 /*!\brief Free the memory allocated for VpxTplGopStats
92  *
93  * \param[in]    tpl_gop_stats  VpxTplGopStats that contains TPL stats for the
94  *                              whole GOP.
95  */
96 void vpx_free_tpl_gop_stats(VpxTplGopStats *tpl_gop_stats);
97 
98 #ifdef __cplusplus
99 }  // extern "C"
100 #endif
101 
102 #endif  // VPX_VPX_VPX_TPL_H_
103