• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "jpeg_ll.h"
16 
17 #define JPEG_QUANT_TABLE_LEN    32
18 
19 #if 0
20 static const uint32_t jpeg_quant_table[JPEG_QUANT_TABLE_LEN] = {
21 	0x07060608, 0x07080506, 0x09090707, 0x140c0a08,
22 	0x0b0b0c0d, 0x1312190c, 0x1a1d140f, 0x1a1d1e1f,
23 	0x24201c1c, 0x2220272e, 0x1c1c232c, 0x2c293728,
24 	0x34343130, 0x39271f34, 0x3c32383d, 0x3234332e,
25 	0x0c090909, 0x0d180c0b, 0x2132180d, 0x3232211c,
26 	0x32323232, 0x32323232, 0x32323232, 0x32323232,
27 	0x32323232, 0x32323232, 0x32323232, 0x32323232,
28 	0x32323232, 0x32323232, 0x32323232, 0x32323232
29 };
30 #else
31 static const uint32_t jpeg_quant_table[JPEG_QUANT_TABLE_LEN] = {
32     0x120f0e14, 0x12140d0f, 0x15171210, 0x321e1814,
33     0x1c1c1e21, 0x2e2c3d1e, 0x40493224, 0x40474b4c,
34     0x5a504546, 0x55506273, 0x4645566d, 0x6d658864,
35     0x82817b77, 0x8d604e81, 0x967d8c97, 0x7c817e73,
36     0x1e171715, 0x213b1e1a, 0x537c3b21, 0x7c7c5346,
37     0x7c7c7c7c, 0x7c7c7c7c, 0x7c7c7c7c, 0x7c7c7c7c,
38     0x7c7c7c7c, 0x7c7c7c7c, 0x7c7c7c7c, 0x7c7c7c7c,
39     0x7c7c7c7c, 0x7c7c7c7c, 0x7c7c7c7c, 0x7c7c7c7c,
40 };
41 #endif
42 
jpeg_ll_init_quant_table(jpeg_hw_t * hw)43 void jpeg_ll_init_quant_table(jpeg_hw_t *hw)
44 {
45     uint32_t reg_addr;
46 
47     for (uint32_t i = 0; i < JPEG_QUANT_TABLE_LEN; i++)
48     {
49         reg_addr = JPEG_R_QUANT_TABLE + i * 4;
50         REG_WRITE(reg_addr, (uint32_t)jpeg_quant_table[i]);
51     }
52 }
53 
54