1 /******************************************************************************
2 *
3 * Copyright (C) 2022 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *****************************************************************************
18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20
21 /**
22 *******************************************************************************
23 * @file
24 * isvce_nalu_stat_aggregator.h
25 *
26 * @brief
27 * Contains objects used for aggregating nalu statistics
28 *
29 *******************************************************************************
30 */
31
32 #ifndef _ISVCE_NALU_STAT_AGGREGATOR_H_
33 #define _ISVCE_NALU_STAT_AGGREGATOR_H_
34
35 #include <stdbool.h>
36
37 #include "ih264_typedefs.h"
38 #include "isvce.h"
39 #include "isvc_defs.h"
40 #include "isvce_defs.h"
41
42 /* Macros */
43 /* +1 for '\0' */
44 #define MAX_BYTES_PER_NALU_INFO (45 + 1)
45
46 /* SPS + (MAX_NUM_SPATIAL_LAYERS - 1) * SUBSET_SPS +
47 * MAX_NUM_SPATIAL_LAYERS * PPS + */
48 /* 1 PREFIX_NALU + 1 SLICE_[NON|]IDR + (MAX_NUM_SPATIAL_LAYERS - 1) *
49 * CODED_SLICE_EXTENSION */
50 #define MAX_NALU_PER_LAYER 10
51
52 /* Structs */
53 typedef struct nalu_info_t
54 {
55 NAL_UNIT_TYPE_T e_nalu_type;
56
57 WORD64 i8_num_bits;
58
59 bool b_is_vcl_nal;
60
61 bool b_is_idr;
62
63 UWORD8 u1_spatial_layer_id;
64
65 UWORD8 u1_temporal_layer_id;
66
67 UWORD8 u1_num_slices;
68 } nalu_info_t;
69
70 typedef struct nalu_descriptors_t
71 {
72 nalu_info_t as_nalu_info[MAX_NALU_PER_LAYER];
73
74 UWORD8 u1_num_nalus;
75
76 } nalu_descriptors_t;
77
78 /* Function declarations */
isvce_get_nalu_info_buf_size(UWORD8 u1_num_spatial_layers)79 static FORCEINLINE UWORD32 isvce_get_nalu_info_buf_size(UWORD8 u1_num_spatial_layers)
80 {
81 return MAX_NALU_PER_LAYER * u1_num_spatial_layers * MAX_BYTES_PER_NALU_INFO;
82 }
83
84 extern void isvce_nalu_info_au_init(nalu_descriptors_t *ps_nalu_descriptor,
85 UWORD8 u1_num_spatial_layers);
86
87 extern void isvce_nalu_info_csv_translator(nalu_descriptors_t *ps_nalu_descriptor,
88 isvce_nalu_info_buf_t *ps_csv_buf);
89
90 extern nalu_info_t *isvce_get_next_nalu_info_buf(nalu_descriptors_t *ps_nalu_descriptor);
91
92 extern void isvce_nalu_info_buf_init(nalu_info_t *ps_nalu_info, WORD64 i8_init_bytes,
93 NAL_UNIT_TYPE_T e_nalu_type, UWORD8 u1_spatial_layer_id,
94 UWORD8 u1_temporal_layer_id, UWORD8 u1_num_slices,
95 bool b_is_idr);
96
97 extern void isvce_update_nalu_count(nalu_descriptors_t *ps_nalu_descriptor);
98
99 #endif
100