|
18 | 18 | /* Size with u32 units. */ |
19 | 19 | #define RKV_CABAC_INIT_BUFFER_SIZE (3680 + 128) |
20 | 20 | #define RKV_RPS_SIZE ((128 + 128) / 4) |
21 | | -#define RKV_SCALING_LIST_SIZE (6 * 16 + 6 * 64 + 128) |
22 | 21 | #define RKV_ERROR_INFO_SIZE (256 * 144 * 4) |
23 | 22 |
|
24 | 23 | #define RKVDEC_NUM_REFLIST 3 |
25 | 24 |
|
| 25 | +struct rkvdec_h264_scaling_list { |
| 26 | + u8 scaling_list_4x4[6][16]; |
| 27 | + u8 scaling_list_8x8[6][64]; |
| 28 | + u8 padding[128]; |
| 29 | +}; |
| 30 | + |
26 | 31 | struct rkvdec_sps_pps_packet { |
27 | 32 | u32 info[8]; |
28 | 33 | }; |
@@ -86,7 +91,7 @@ struct rkvdec_ps_field { |
86 | 91 | /* Data structure describing auxiliary buffer format. */ |
87 | 92 | struct rkvdec_h264_priv_tbl { |
88 | 93 | s8 cabac_table[4][464][2]; |
89 | | - u8 scaling_list[RKV_SCALING_LIST_SIZE]; |
| 94 | + struct rkvdec_h264_scaling_list scaling_list; |
90 | 95 | u32 rps[RKV_RPS_SIZE]; |
91 | 96 | struct rkvdec_sps_pps_packet param_set[256]; |
92 | 97 | u8 err_info[RKV_ERROR_INFO_SIZE]; |
@@ -785,56 +790,25 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, |
785 | 790 | } |
786 | 791 | } |
787 | 792 |
|
788 | | -/* |
789 | | - * NOTE: The values in a scaling list are in zig-zag order, apply inverse |
790 | | - * scanning process to get the values in matrix order. |
791 | | - */ |
792 | | -static const u32 zig_zag_4x4[16] = { |
793 | | - 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15 |
794 | | -}; |
795 | | - |
796 | | -static const u32 zig_zag_8x8[64] = { |
797 | | - 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, |
798 | | - 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, |
799 | | - 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, |
800 | | - 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 |
801 | | -}; |
802 | | - |
803 | | -static void reorder_scaling_list(struct rkvdec_ctx *ctx, |
804 | | - struct rkvdec_h264_run *run) |
| 793 | +static void assemble_hw_scaling_list(struct rkvdec_ctx *ctx, |
| 794 | + struct rkvdec_h264_run *run) |
805 | 795 | { |
806 | 796 | const struct v4l2_ctrl_h264_scaling_matrix *scaling = run->scaling_matrix; |
807 | | - const size_t num_list_4x4 = ARRAY_SIZE(scaling->scaling_list_4x4); |
808 | | - const size_t list_len_4x4 = ARRAY_SIZE(scaling->scaling_list_4x4[0]); |
809 | | - const size_t num_list_8x8 = ARRAY_SIZE(scaling->scaling_list_8x8); |
810 | | - const size_t list_len_8x8 = ARRAY_SIZE(scaling->scaling_list_8x8[0]); |
811 | 797 | struct rkvdec_h264_ctx *h264_ctx = ctx->priv; |
812 | 798 | struct rkvdec_h264_priv_tbl *tbl = h264_ctx->priv_tbl.cpu; |
813 | | - u8 *dst = tbl->scaling_list; |
814 | | - const u8 *src; |
815 | | - int i, j; |
816 | | - |
817 | | - BUILD_BUG_ON(ARRAY_SIZE(zig_zag_4x4) != list_len_4x4); |
818 | | - BUILD_BUG_ON(ARRAY_SIZE(zig_zag_8x8) != list_len_8x8); |
819 | | - BUILD_BUG_ON(ARRAY_SIZE(tbl->scaling_list) < |
820 | | - num_list_4x4 * list_len_4x4 + |
821 | | - num_list_8x8 * list_len_8x8); |
822 | | - |
823 | | - src = &scaling->scaling_list_4x4[0][0]; |
824 | | - for (i = 0; i < num_list_4x4; ++i) { |
825 | | - for (j = 0; j < list_len_4x4; ++j) |
826 | | - dst[zig_zag_4x4[j]] = src[j]; |
827 | | - src += list_len_4x4; |
828 | | - dst += list_len_4x4; |
829 | | - } |
830 | 799 |
|
831 | | - src = &scaling->scaling_list_8x8[0][0]; |
832 | | - for (i = 0; i < num_list_8x8; ++i) { |
833 | | - for (j = 0; j < list_len_8x8; ++j) |
834 | | - dst[zig_zag_8x8[j]] = src[j]; |
835 | | - src += list_len_8x8; |
836 | | - dst += list_len_8x8; |
837 | | - } |
| 800 | + BUILD_BUG_ON(sizeof(tbl->scaling_list.scaling_list_4x4) != |
| 801 | + sizeof(scaling->scaling_list_4x4)); |
| 802 | + BUILD_BUG_ON(sizeof(tbl->scaling_list.scaling_list_8x8) != |
| 803 | + sizeof(scaling->scaling_list_8x8)); |
| 804 | + |
| 805 | + memcpy(tbl->scaling_list.scaling_list_4x4, |
| 806 | + scaling->scaling_list_4x4, |
| 807 | + sizeof(scaling->scaling_list_4x4)); |
| 808 | + |
| 809 | + memcpy(tbl->scaling_list.scaling_list_8x8, |
| 810 | + scaling->scaling_list_8x8, |
| 811 | + sizeof(scaling->scaling_list_8x8)); |
838 | 812 | } |
839 | 813 |
|
840 | 814 | /* |
@@ -1126,7 +1100,7 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx) |
1126 | 1100 | v4l2_h264_build_b_ref_lists(&reflist_builder, h264_ctx->reflists.b0, |
1127 | 1101 | h264_ctx->reflists.b1); |
1128 | 1102 |
|
1129 | | - reorder_scaling_list(ctx, &run); |
| 1103 | + assemble_hw_scaling_list(ctx, &run); |
1130 | 1104 | assemble_hw_pps(ctx, &run); |
1131 | 1105 | assemble_hw_rps(ctx, &run); |
1132 | 1106 | config_registers(ctx, &run); |
|
0 commit comments