1/**************************************************************************
2 *
3 * Copyright 2021 Advanced Micro Devices, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28#ifndef _RADEON_TEMPORAL_H
29#define _RADEON_TEMPORAL_H
30
31#include "radeon_video.h"
32#include "radeon_vcn_enc.h"
33
34#define RENCODE_MAX_TEMPORAL_LAYER_PATTERN_SIZE                                     9
35
36typedef struct rvcn_temporal_layer_pattern_entry_s
37{
38   unsigned    temporal_id;
39   unsigned    reference_index_in_table;
40   bool        reference_modification;
41   unsigned    frame_num_offset;
42   unsigned    poc_offset;
43   bool        mark_as_reference;
44} rvcn_temporal_layer_pattern_entry_t;
45
46typedef struct rvcn_temporal_layer_pattern_table_s
47{
48   unsigned    pattern_size;
49   rvcn_temporal_layer_pattern_entry_t  pattern_table[RENCODE_MAX_TEMPORAL_LAYER_PATTERN_SIZE];
50} rvcn_temporal_layer_pattern_table_t;
51
52static const rvcn_temporal_layer_pattern_table_t  rvcn_temporal_layer_pattern_tables[RENCODE_MAX_NUM_TEMPORAL_LAYERS] =
53{
54   /* 1 temporal layer */
55   {
56      2,      /* temporal layer pattern size */
57      {
58         {
59            0,
60            0,
61            false,
62            0,
63            0,
64            true,
65         },
66         {
67            0,
68            0,
69            false,
70            1,
71            2,
72            true,
73         }
74      }
75   },
76   /* 2 temporal layers */
77   {
78      3,      /* temporal layer pattern size */
79      {
80         {
81            0,
82            0,
83            false,
84            0,
85            0,
86            true,
87         },
88         {
89            1,
90            0,
91            false,
92            1,
93            2,
94            false,
95         },
96         {
97            0,
98            0,
99            false,
100            1,
101            4,
102            true,
103         }
104      }
105   },
106   /* 3 temporal layers */
107   {
108      5,      /* temporal layer pattern size */
109      {
110         {
111            0,
112            0,
113            false,
114            0,
115            0,
116            true,
117         },
118         {
119            2,
120            0,
121            false,
122            1,
123            2,
124            false,
125         },
126         {
127            1,
128            0,
129            false,
130            1,
131            4,
132            true,
133         },
134         {
135            2,
136            2,
137            false,
138            2,
139            6,
140            false,
141         },
142         {
143            0,
144            0,
145            true,
146            2,
147            8,
148            true,
149         }
150      }
151   },
152   /* 4 temporal layers */
153   {
154      9,      /* temporal layer pattern size */
155      {
156         {
157            0,
158            0,
159            false,
160            0,
161            0,
162            true,
163         },
164         {
165            3,
166            0,
167            false,
168            1,
169            2,
170            false,
171         },
172         {
173            2,
174            0,
175            false,
176            1,
177            4,
178            true,
179         },
180         {
181            3,
182            2,
183            false,
184            2,
185            6,
186            false,
187         },
188         {
189            1,
190            0,
191            true,
192            2,
193            8,
194            true,
195         },
196         {
197            3,
198            4,
199            false,
200            3,
201            10,
202            false,
203         },
204         {
205            2,
206            4,
207            false,
208            3,
209            12,
210            true,
211         },
212         {
213            3,
214            6,
215            false,
216            4,
217            14,
218            false,
219         },
220         {
221            0,
222            0,
223            true,
224            4,
225            16,
226            true,
227         }
228      }
229   }
230};
231
232#endif // _RADEON_TEMPORAL_H