@@ -140,56 +140,26 @@ static void set_ref_poc(struct rkvdec_rps_short_term_ref_set *set, int poc, int
140140 }
141141}
142142
143- /*
144- * Flip one or more matrices along their main diagonal and flatten them
145- * before writing it to the memory.
146- * Convert:
147- * ABCD AEIM
148- * EFGH => BFJN => AEIMBFJNCGKODHLP
149- * IJKL CGKO
150- * MNOP DHLP
151- */
152- static void transpose_and_flatten_matrices (u8 * output , const u8 * input ,
153- int matrices , int row_length )
154- {
155- int i , j , row , x_offset , matrix_offset , rot_index , y_offset , matrix_size , new_value ;
156-
157- matrix_size = row_length * row_length ;
158- for (i = 0 ; i < matrices ; i ++ ) {
159- row = 0 ;
160- x_offset = 0 ;
161- matrix_offset = i * matrix_size ;
162- for (j = 0 ; j < matrix_size ; j ++ ) {
163- y_offset = j - (row * row_length );
164- rot_index = y_offset * row_length + x_offset ;
165- new_value = * (input + i * matrix_size + j );
166- output [matrix_offset + rot_index ] = new_value ;
167- if ((j + 1 ) % row_length == 0 ) {
168- row += 1 ;
169- x_offset += 1 ;
170- }
171- }
172- }
173- }
174-
175- static void assemble_scalingfactor0 (u8 * output , const struct v4l2_ctrl_hevc_scaling_matrix * input )
143+ static void assemble_scalingfactor0 (struct rkvdec_ctx * ctx , u8 * output ,
144+ const struct v4l2_ctrl_hevc_scaling_matrix * input )
176145{
146+ const struct rkvdec_variant * variant = ctx -> dev -> variant ;
177147 int offset = 0 ;
178148
179- transpose_and_flatten_matrices (output , (const u8 * )input -> scaling_list_4x4 , 6 , 4 );
149+ variant -> ops -> flatten_matrices (output , (const u8 * )input -> scaling_list_4x4 , 6 , 4 );
180150 offset = 6 * 16 * sizeof (u8 );
181- transpose_and_flatten_matrices (output + offset , (const u8 * )input -> scaling_list_8x8 , 6 , 8 );
151+ variant -> ops -> flatten_matrices (output + offset , (const u8 * )input -> scaling_list_8x8 , 6 , 8 );
182152 offset += 6 * 64 * sizeof (u8 );
183- transpose_and_flatten_matrices (output + offset ,
184- ( const u8 * ) input -> scaling_list_16x16 , 6 , 8 );
153+ variant -> ops -> flatten_matrices (output + offset , ( const u8 * ) input -> scaling_list_16x16 ,
154+ 6 , 8 );
185155 offset += 6 * 64 * sizeof (u8 );
186156 /* Add a 128 byte padding with 0s between the two 32x32 matrices */
187- transpose_and_flatten_matrices (output + offset ,
188- ( const u8 * ) input -> scaling_list_32x32 , 1 , 8 );
157+ variant -> ops -> flatten_matrices (output + offset , ( const u8 * ) input -> scaling_list_32x32 ,
158+ 1 , 8 );
189159 offset += 64 * sizeof (u8 );
190160 memset (output + offset , 0 , 128 );
191161 offset += 128 * sizeof (u8 );
192- transpose_and_flatten_matrices (output + offset ,
162+ variant -> ops -> flatten_matrices (output + offset ,
193163 (const u8 * )input -> scaling_list_32x32 + (64 * sizeof (u8 )),
194164 1 , 8 );
195165 offset += 64 * sizeof (u8 );
@@ -214,16 +184,17 @@ static void assemble_scalingdc(u8 *output, const struct v4l2_ctrl_hevc_scaling_m
214184 memcpy (output + 6 * sizeof (u8 ), list_32x32 , 6 * sizeof (u8 ));
215185}
216186
217- static void translate_scaling_list (struct scaling_factor * output ,
187+ static void translate_scaling_list (struct rkvdec_ctx * ctx , struct scaling_factor * output ,
218188 const struct v4l2_ctrl_hevc_scaling_matrix * input )
219189{
220- assemble_scalingfactor0 (output -> scalingfactor0 , input );
190+ assemble_scalingfactor0 (ctx , output -> scalingfactor0 , input );
221191 memcpy (output -> scalingfactor1 , (const u8 * )input -> scaling_list_4x4 , 96 );
222192 assemble_scalingdc (output -> scalingdc , input );
223193 memset (output -> reserved , 0 , 4 * sizeof (u8 ));
224194}
225195
226- void rkvdec_hevc_assemble_hw_scaling_list (struct rkvdec_hevc_run * run ,
196+ void rkvdec_hevc_assemble_hw_scaling_list (struct rkvdec_ctx * ctx ,
197+ struct rkvdec_hevc_run * run ,
227198 struct scaling_factor * scaling_factor ,
228199 struct v4l2_ctrl_hevc_scaling_matrix * cache )
229200{
@@ -233,7 +204,7 @@ void rkvdec_hevc_assemble_hw_scaling_list(struct rkvdec_hevc_run *run,
233204 sizeof (struct v4l2_ctrl_hevc_scaling_matrix )))
234205 return ;
235206
236- translate_scaling_list (scaling_factor , scaling );
207+ translate_scaling_list (ctx , scaling_factor , scaling );
237208
238209 memcpy (cache , scaling ,
239210 sizeof (struct v4l2_ctrl_hevc_scaling_matrix ));
0 commit comments