1818
1919/* Size with u32 units. */
2020#define RKV_CABAC_INIT_BUFFER_SIZE (3680 + 128)
21- #define RKV_RPS_SIZE ((128 + 128) / 4)
2221#define RKV_ERROR_INFO_SIZE (256 * 144 * 4)
2322
2423#define RKVDEC_NUM_REFLIST 3
@@ -33,6 +32,40 @@ struct rkvdec_sps_pps_packet {
3332 u32 info [8 ];
3433};
3534
35+ struct rkvdec_rps_entry {
36+ u32 dpb_info0 : 5 ;
37+ u32 bottom_flag0 : 1 ;
38+ u32 view_index_off0 : 1 ;
39+ u32 dpb_info1 : 5 ;
40+ u32 bottom_flag1 : 1 ;
41+ u32 view_index_off1 : 1 ;
42+ u32 dpb_info2 : 5 ;
43+ u32 bottom_flag2 : 1 ;
44+ u32 view_index_off2 : 1 ;
45+ u32 dpb_info3 : 5 ;
46+ u32 bottom_flag3 : 1 ;
47+ u32 view_index_off3 : 1 ;
48+ u32 dpb_info4 : 5 ;
49+ u32 bottom_flag4 : 1 ;
50+ u32 view_index_off4 : 1 ;
51+ u32 dpb_info5 : 5 ;
52+ u32 bottom_flag5 : 1 ;
53+ u32 view_index_off5 : 1 ;
54+ u32 dpb_info6 : 5 ;
55+ u32 bottom_flag6 : 1 ;
56+ u32 view_index_off6 : 1 ;
57+ u32 dpb_info7 : 5 ;
58+ u32 bottom_flag7 : 1 ;
59+ u32 view_index_off7 : 1 ;
60+ } __packed ;
61+
62+ struct rkvdec_rps {
63+ u16 frame_num [16 ];
64+ u32 reserved0 ;
65+ struct rkvdec_rps_entry entries [12 ];
66+ u32 reserved1 [66 ];
67+ } __packed ;
68+
3669struct rkvdec_ps_field {
3770 u16 offset ;
3871 u8 len ;
@@ -93,7 +126,7 @@ struct rkvdec_ps_field {
93126struct rkvdec_h264_priv_tbl {
94127 s8 cabac_table [4 ][464 ][2 ];
95128 struct rkvdec_h264_scaling_list scaling_list ;
96- u32 rps [ RKV_RPS_SIZE ] ;
129+ struct rkvdec_rps rps ;
97130 struct rkvdec_sps_pps_packet param_set [256 ];
98131 u8 err_info [RKV_ERROR_INFO_SIZE ];
99132};
@@ -259,6 +292,51 @@ static void lookup_ref_buf_idx(struct rkvdec_ctx *ctx,
259292 }
260293}
261294
295+ static void set_dpb_info (struct rkvdec_rps_entry * entries ,
296+ u8 reflist ,
297+ u8 refnum ,
298+ u8 info ,
299+ bool bottom )
300+ {
301+ struct rkvdec_rps_entry * entry = & entries [(reflist * 4 ) + refnum / 8 ];
302+ u8 idx = refnum % 8 ;
303+
304+ switch (idx ) {
305+ case 0 :
306+ entry -> dpb_info0 = info ;
307+ entry -> bottom_flag0 = bottom ;
308+ break ;
309+ case 1 :
310+ entry -> dpb_info1 = info ;
311+ entry -> bottom_flag1 = bottom ;
312+ break ;
313+ case 2 :
314+ entry -> dpb_info2 = info ;
315+ entry -> bottom_flag2 = bottom ;
316+ break ;
317+ case 3 :
318+ entry -> dpb_info3 = info ;
319+ entry -> bottom_flag3 = bottom ;
320+ break ;
321+ case 4 :
322+ entry -> dpb_info4 = info ;
323+ entry -> bottom_flag4 = bottom ;
324+ break ;
325+ case 5 :
326+ entry -> dpb_info5 = info ;
327+ entry -> bottom_flag5 = bottom ;
328+ break ;
329+ case 6 :
330+ entry -> dpb_info6 = info ;
331+ entry -> bottom_flag6 = bottom ;
332+ break ;
333+ case 7 :
334+ entry -> dpb_info7 = info ;
335+ entry -> bottom_flag7 = bottom ;
336+ break ;
337+ }
338+ }
339+
262340static void assemble_hw_rps (struct rkvdec_ctx * ctx ,
263341 struct v4l2_h264_reflist_builder * builder ,
264342 struct rkvdec_h264_run * run )
@@ -268,11 +346,10 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx,
268346 struct rkvdec_h264_ctx * h264_ctx = ctx -> priv ;
269347 struct rkvdec_h264_priv_tbl * priv_tbl = h264_ctx -> priv_tbl .cpu ;
270348
271- u32 * hw_rps = priv_tbl -> rps ;
349+ struct rkvdec_rps * hw_rps = & priv_tbl -> rps ;
272350 u32 i , j ;
273- u16 * p = (u16 * )hw_rps ;
274351
275- memset (hw_rps , 0 , sizeof (priv_tbl -> rps ));
352+ memset (hw_rps , 0 , sizeof (* hw_rps ));
276353
277354 /*
278355 * Assign an invalid pic_num if DPB entry at that position is inactive.
@@ -284,7 +361,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx,
284361 if (!(dpb [i ].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ))
285362 continue ;
286363
287- p [i ] = builder -> refs [i ].frame_num ;
364+ hw_rps -> frame_num [i ] = builder -> refs [i ].frame_num ;
288365 }
289366
290367 for (j = 0 ; j < RKVDEC_NUM_REFLIST ; j ++ ) {
@@ -311,9 +388,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx,
311388 dpb_valid = run -> ref_buf [ref -> index ] != NULL ;
312389 bottom = ref -> fields == V4L2_H264_BOTTOM_FIELD_REF ;
313390
314- set_ps_field (hw_rps , DPB_INFO (i , j ),
315- ref -> index | dpb_valid << 4 );
316- set_ps_field (hw_rps , BOTTOM_FLAG (i , j ), bottom );
391+ set_dpb_info (hw_rps -> entries , j , i , ref -> index | (dpb_valid << 4 ), bottom );
317392 }
318393 }
319394}
0 commit comments