2 * BitJazz SheerVideo decoder
3 * Copyright (c) 2016 Paul B Mahol
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include "libavutil/intreadwrite.h"
32 typedef struct SheerVideoContext {
35 void (*decode_frame)(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb);
38 static const uint8_t l_r_rgb[256] = {
39 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 8,
40 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
41 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12,
42 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13,
43 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
44 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
45 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
46 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
47 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
48 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15,
49 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14,
50 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13,
51 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12,
52 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10,
53 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8,
54 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 5, 5, 4, 4, 4,
57 static const uint8_t l_r_rgbi[256] = {
58 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 7,
59 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,
60 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11,
61 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12,
62 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
63 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14,
64 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15,
65 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
66 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
67 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
68 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13,
69 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12,
70 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11,
71 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10,
72 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8,
73 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 4, 4, 4,
76 static const uint8_t l_g_rgbi[256] = {
77 1, 3, 4, 5, 6, 7, 7, 8, 9, 9, 10, 10, 10, 10, 11, 11,
78 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14,
79 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16,
80 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
81 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
82 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
83 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
84 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
85 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
86 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
87 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
88 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
89 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
90 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14,
91 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12,
92 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 7, 6, 5, 5, 3,
95 static const uint8_t l_g_rgb[256] = {
96 2, 2, 4, 4, 6, 7, 9, 9, 10, 11, 11, 11, 12, 12, 12, 13,
97 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15,
98 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
99 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
100 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
101 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
102 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
103 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
104 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
105 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
106 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
107 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
108 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
109 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15,
110 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13,
111 13, 13, 12, 12, 12, 11, 11, 11, 10, 9, 9, 8, 6, 4, 3, 3,
114 static const uint8_t l_y_ybr[256] = {
115 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8,
116 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10,
117 10, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12,
118 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14,
119 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15,
120 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16,
121 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
122 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
123 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
124 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
125 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
126 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
127 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12,
128 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
129 11, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8,
130 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 4, 4, 3,
133 static const uint8_t l_u_ybr[256] = {
134 1, 2, 4, 6, 9, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14,
135 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
136 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
137 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
138 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
139 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
140 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
141 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
142 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
143 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
144 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
145 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
146 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
147 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
148 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15,
149 14, 14, 14, 14, 14, 13, 13, 13, 12, 12, 11, 11, 10, 8, 5, 3,
152 static const uint8_t l_y_ybyr[256] = {
153 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 8,
154 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
155 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12,
156 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13,
157 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
158 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
159 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
160 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
161 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
162 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15,
163 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14,
164 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13,
165 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12,
166 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10,
167 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8,
168 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 5, 5, 4, 4, 4,
171 static const uint8_t l_u_ybyr[256] = {
172 1, 2, 4, 6, 8, 9, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14,
173 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16,
174 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
175 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
176 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
177 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
178 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
179 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
180 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
181 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
182 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
183 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
184 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
185 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
186 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 14, 14,
187 14, 14, 13, 13, 13, 12, 12, 11, 11, 10, 10, 9, 8, 7, 6, 3,
190 static const uint8_t l_y_byry[256] = {
191 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8,
192 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10,
193 10, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12,
194 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14,
195 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15,
196 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16,
197 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
198 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
199 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
200 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
201 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
202 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
203 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12,
204 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11,
205 11, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8,
206 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 4, 4, 3,
209 static const uint8_t l_u_byry[256] = {
210 1, 2, 4, 6, 8, 9, 9, 10, 11, 11, 12, 12, 13, 13, 13, 14,
211 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16,
212 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
213 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
214 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
215 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
216 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
217 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
218 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
219 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
220 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
221 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
222 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
223 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
224 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14,
225 14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 10, 9, 8, 7, 6, 3,
228 static const uint8_t l_y_ybr10i[1024] = {
229 3, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7,
230 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
231 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
232 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
233 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11,
234 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
235 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12,
236 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
237 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
238 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
239 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
240 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
241 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
242 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
243 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
244 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
245 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
246 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
247 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
248 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
249 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
250 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16,
251 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
252 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
253 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
254 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
255 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
256 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
257 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
258 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
259 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
260 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
261 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
262 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
263 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
264 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
265 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
266 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
267 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
268 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
269 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
270 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
271 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15,
272 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
273 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
274 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
275 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
276 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
277 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
278 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
279 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
280 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
281 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
282 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
283 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
284 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
285 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
286 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
287 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
288 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
289 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9,
290 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
291 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7,
292 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5,
295 static const uint8_t l_y_ybr10[1024] = {
296 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7,
297 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
298 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
299 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
300 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11,
301 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
302 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
303 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
304 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
305 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
306 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
307 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
308 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
309 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
310 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
311 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
312 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
313 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16,
314 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
315 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
316 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
317 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
318 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
319 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
320 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
321 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
322 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
323 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
324 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
325 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
326 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
327 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
328 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
329 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
330 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
331 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
332 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
333 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
334 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
335 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
336 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
337 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
338 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
339 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
340 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
341 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
342 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15,
343 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
344 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
345 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
346 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
347 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
348 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
349 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13,
350 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
351 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
352 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
353 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11,
354 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
355 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10,
356 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9,
357 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
358 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7,
359 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5,
362 static const uint8_t l_u_ybr10i[1024] = {
363 2, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, 9, 9, 10,
364 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12,
365 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14,
366 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
367 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
368 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
369 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
370 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
371 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
372 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
373 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
374 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
375 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
376 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
377 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
378 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
379 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
380 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
381 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
382 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
383 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
384 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
385 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
386 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
387 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
388 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
389 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
390 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
391 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
392 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
393 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
394 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
395 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
396 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
397 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
398 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
399 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
400 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
401 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
402 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
403 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
404 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
405 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
406 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
407 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
408 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
409 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
410 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
411 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
412 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
413 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
414 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
415 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
416 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
417 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
418 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
419 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
420 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
421 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15,
422 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
423 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14,
424 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
425 13, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 10, 10,
426 10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 6, 5, 5, 4, 4, 3,
429 static const uint8_t l_u_ybr10[1024] = {
430 2, 3, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 10, 10, 11, 11,
431 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14,
432 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
433 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16,
434 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
435 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
436 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
437 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
438 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
439 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
440 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
441 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
442 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
443 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
444 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
445 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
446 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
447 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
448 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
449 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
450 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
451 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
452 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
453 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
454 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
455 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
456 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
457 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
458 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
459 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
460 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
461 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
462 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
463 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
464 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
465 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
466 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
467 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
468 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
469 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
470 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
471 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
472 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
473 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
474 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
475 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
476 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
477 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
478 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
479 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
480 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
481 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
482 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
483 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
484 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
485 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
486 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
487 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
488 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
489 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
490 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15,
491 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14,
492 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 12, 12, 12,
493 12, 11, 11, 11, 10, 10, 9, 9, 8, 8, 7, 6, 5, 4, 4, 3,
496 static const uint8_t l_r_rgbx[1024] = {
497 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7,
498 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8,
499 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
500 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10,
501 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
502 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
503 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12,
504 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
505 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
506 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
507 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
508 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14,
509 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
510 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
511 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15,
512 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
513 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
514 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
515 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
516 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16,
517 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
518 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
519 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
520 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
521 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
522 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
523 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
524 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
525 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
526 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
527 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
528 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
529 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
530 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
531 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
532 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
533 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
534 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
535 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
536 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
537 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
538 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
539 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
540 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
541 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15,
542 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
543 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
544 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
545 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
546 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14,
547 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
548 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
549 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13,
550 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
551 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
552 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
553 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
554 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
555 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
556 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
557 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9,
558 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8,
559 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7,
560 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5,
563 static const uint8_t l_g_rgbx[1024] = {
564 3, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7,
565 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12,
566 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13,
567 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
568 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
569 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
570 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16,
571 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
572 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
573 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
574 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
575 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
576 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
577 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
578 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
579 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
580 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
581 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
582 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
583 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
584 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
585 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
586 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
587 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
588 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
589 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
590 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
591 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
592 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
593 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
594 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
595 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
596 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
597 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
598 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
599 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
600 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
601 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
602 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
603 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
604 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
605 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
606 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
607 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
608 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
609 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
610 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
611 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
612 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
613 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
614 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
615 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
616 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
617 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
618 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
619 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
620 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
621 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
622 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
623 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14,
624 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13,
625 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12,
626 12, 12, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9,
627 8, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4,
630 static const uint8_t l_y_yry10[1024] = {
631 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7,
632 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
633 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
634 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
635 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11,
636 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
637 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
638 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
639 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
640 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
641 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
642 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
643 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
644 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
645 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
646 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
647 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
648 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16,
649 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
650 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
651 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
652 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
653 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
654 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
655 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
656 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
657 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
658 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
659 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
660 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
661 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
662 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
663 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
664 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
665 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
666 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
667 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
668 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
669 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
670 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
671 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
672 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
673 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
674 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
675 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
676 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
677 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15,
678 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
679 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
680 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
681 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
682 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
683 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
684 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13,
685 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
686 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
687 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
688 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11,
689 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
690 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10,
691 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9,
692 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
693 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7,
694 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5,
697 static const uint8_t l_y_yry10i[1024] = {
698 3, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7,
699 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
700 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
701 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
702 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11,
703 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
704 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12,
705 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
706 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
707 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
708 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
709 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
710 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
711 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
712 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
713 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
714 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
715 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
716 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
717 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
718 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
719 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16,
720 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
721 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
722 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
723 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
724 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
725 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
726 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
727 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
728 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
729 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
730 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
731 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
732 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
733 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
734 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
735 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
736 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
737 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
738 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
739 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
740 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15,
741 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
742 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
743 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
744 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
745 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
746 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
747 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
748 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
749 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
750 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
751 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
752 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
753 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
754 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
755 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
756 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
757 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
758 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9,
759 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
760 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7,
761 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5,
764 static const uint8_t l_u_yry10[1024] = {
765 2, 3, 3, 4, 5, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10,
766 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13,
767 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
768 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
769 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
770 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
771 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
772 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
773 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
774 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
775 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
776 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
777 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
778 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
779 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
780 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
781 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
782 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
783 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
784 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
785 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
786 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
787 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
788 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
789 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
790 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
791 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
792 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
793 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
794 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
795 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
796 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
797 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
798 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
799 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
800 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
801 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
802 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
803 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
804 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
805 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
806 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
807 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
808 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
809 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
810 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
811 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
812 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
813 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
814 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
815 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
816 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
817 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
818 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
819 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
820 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
821 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
822 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
823 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
824 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
825 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
826 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13,
827 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11,
828 10, 10, 10, 10, 9, 9, 9, 8, 8, 7, 7, 6, 5, 4, 4, 3,
831 static const uint8_t l_u_yry10i[1024] = {
832 2, 4, 4, 4, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9,
833 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11,
834 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13,
835 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14,
836 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15,
837 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
838 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
839 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
840 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
841 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
842 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
843 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
844 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
845 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
846 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
847 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
848 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
849 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
850 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
851 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
852 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
853 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
854 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
855 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
856 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
857 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
858 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
859 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
860 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
861 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
862 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
863 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
864 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
865 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
866 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
867 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
868 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
869 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
870 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
871 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
872 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
873 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
874 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
875 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
876 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
877 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
878 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
879 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
880 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
881 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
882 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
883 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
884 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
885 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
886 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
887 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
888 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
889 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
890 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
891 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
892 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13,
893 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11,
894 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 9, 9, 9,
895 9, 9, 8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 5, 4, 4, 3,
898 static const uint8_t l_y_ybri[256] = {
899 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8,
900 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10,
901 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
902 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
903 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14,
904 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
905 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
906 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
907 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
908 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
909 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
910 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
911 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12,
912 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10,
913 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 8,
914 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 3,
917 static const uint8_t l_u_ybri[256] = {
918 1, 3, 5, 6, 8, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13,
919 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
920 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
921 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
922 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
923 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
924 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
925 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
926 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
927 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
928 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
929 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
930 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
931 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
932 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14,
933 14, 13, 13, 13, 12, 12, 11, 11, 10, 10, 9, 8, 8, 6, 5, 2,
936 static const uint8_t l_y_byryi[256] = {
937 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8,
938 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10,
939 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
940 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13,
941 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14,
942 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15,
943 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
944 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
945 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
946 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
947 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
948 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
949 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12,
950 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10,
951 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 8,
952 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 5, 4, 4, 3,
955 static const uint8_t l_u_byryi[256] = {
956 1, 3, 4, 6, 6, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11,
957 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15,
958 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
959 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
960 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
961 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
962 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
963 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
964 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
965 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
966 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
967 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
968 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
969 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15,
970 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12,
971 12, 11, 11, 11, 10, 10, 10, 9, 9, 8, 8, 7, 7, 5, 4, 3,
974 static const uint8_t l_r_rgbxi[1024] = {
975 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8,
976 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
977 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
978 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
979 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
980 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
981 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
982 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
983 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14,
984 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
985 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15,
986 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
987 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
988 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
989 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
990 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
991 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
992 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
993 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
994 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
995 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
996 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
997 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
998 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
999 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1000 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1001 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1002 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1003 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1004 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1005 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1006 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1007 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1008 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1009 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1010 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1011 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1012 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1013 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1014 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1015 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1016 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1017 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1018 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1019 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1020 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1021 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1022 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1023 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
1024 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
1025 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
1026 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
1027 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
1028 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14,
1029 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
1030 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13,
1031 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12,
1032 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
1033 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11,
1034 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
1035 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10,
1036 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9,
1037 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8,
1038 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 5, 5, 4, 4, 4,
1041 static const uint8_t l_g_rgbxi[1024] = {
1042 2, 3, 4, 4, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
1043 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11,
1044 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13,
1045 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14,
1046 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15,
1047 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
1048 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16,
1049 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1050 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1051 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1052 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1053 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1054 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1055 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1056 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1057 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1058 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1059 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1060 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1061 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1062 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1063 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1064 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1065 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1066 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1067 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1068 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1069 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1070 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1071 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1072 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1073 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1074 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1075 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1076 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1077 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1078 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1079 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1080 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1081 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1082 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1083 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1084 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1085 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1086 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1087 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1088 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1089 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1090 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1091 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1092 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1093 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1094 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1095 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1096 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1097 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1098 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1099 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
1100 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
1101 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
1102 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
1103 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11,
1104 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9,
1105 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 4, 4, 3,
1108 static void decode_ca4i(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1110 SheerVideoContext *s = avctx->priv_data;
1111 uint16_t *dst_y, *dst_u, *dst_v, *dst_a;
1114 dst_a = (uint16_t *)p->data[3];
1115 dst_y = (uint16_t *)p->data[0];
1116 dst_u = (uint16_t *)p->data[1];
1117 dst_v = (uint16_t *)p->data[2];
1119 for (y = 0; y < avctx->height; y++) {
1120 if (get_bits1(gb)) {
1121 for (x = 0; x < avctx->width; x++) {
1122 dst_a[x] = get_bits(gb, 10);
1123 dst_y[x] = get_bits(gb, 10);
1124 dst_u[x] = get_bits(gb, 10);
1125 dst_v[x] = get_bits(gb, 10);
1128 int pred[4] = { 502, 512, 512, 502 };
1130 for (x = 0; x < avctx->width; x++) {
1133 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1134 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1135 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1136 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1138 dst_a[x] = pred[3] = (a + pred[3]) & 0x3ff;
1139 dst_y[x] = pred[0] = (y + pred[0]) & 0x3ff;
1140 dst_u[x] = pred[1] = (u + pred[1]) & 0x3ff;
1141 dst_v[x] = pred[2] = (v + pred[2]) & 0x3ff;
1145 dst_y += p->linesize[0] / 2;
1146 dst_u += p->linesize[1] / 2;
1147 dst_v += p->linesize[2] / 2;
1148 dst_a += p->linesize[3] / 2;
1152 static void decode_ca4p(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1154 SheerVideoContext *s = avctx->priv_data;
1155 uint16_t *dst_y, *dst_u, *dst_v, *dst_a;
1158 dst_a = (uint16_t *)p->data[3];
1159 dst_y = (uint16_t *)p->data[0];
1160 dst_u = (uint16_t *)p->data[1];
1161 dst_v = (uint16_t *)p->data[2];
1163 if (get_bits1(gb)) {
1164 for (x = 0; x < avctx->width; x++) {
1165 dst_a[x] = get_bits(gb, 10);
1166 dst_y[x] = get_bits(gb, 10);
1167 dst_u[x] = get_bits(gb, 10);
1168 dst_v[x] = get_bits(gb, 10);
1171 int pred[4] = { 502, 512, 512, 502 };
1173 for (x = 0; x < avctx->width; x++) {
1176 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1177 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1178 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1179 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1181 dst_a[x] = pred[3] = (a + pred[3]) & 0x3ff;
1182 dst_y[x] = pred[0] = (y + pred[0]) & 0x3ff;
1183 dst_u[x] = pred[1] = (u + pred[1]) & 0x3ff;
1184 dst_v[x] = pred[2] = (v + pred[2]) & 0x3ff;
1188 dst_y += p->linesize[0] / 2;
1189 dst_u += p->linesize[1] / 2;
1190 dst_v += p->linesize[2] / 2;
1191 dst_a += p->linesize[3] / 2;
1193 for (y = 1; y < avctx->height; y++) {
1194 if (get_bits1(gb)) {
1195 for (x = 0; x < avctx->width; x++) {
1196 dst_a[x] = get_bits(gb, 10);
1197 dst_y[x] = get_bits(gb, 10);
1198 dst_u[x] = get_bits(gb, 10);
1199 dst_v[x] = get_bits(gb, 10);
1202 int pred_TL[4], pred_L[4], pred_T[4];
1205 pred_TL[0] = pred_L[0] = dst_y[-p->linesize[0] / 2];
1206 pred_TL[1] = pred_L[1] = dst_u[-p->linesize[1] / 2];
1207 pred_TL[2] = pred_L[2] = dst_v[-p->linesize[2] / 2];
1208 pred_TL[3] = pred_L[3] = dst_a[-p->linesize[3] / 2];
1210 for (x = 0; x < avctx->width; x++) {
1211 pred_T[0] = dst_y[-p->linesize[0] / 2 + x];
1212 pred_T[1] = dst_u[-p->linesize[1] / 2 + x];
1213 pred_T[2] = dst_v[-p->linesize[2] / 2 + x];
1214 pred_T[3] = dst_a[-p->linesize[3] / 2 + x];
1216 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1217 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1218 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1219 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1221 dst_a[x] = pred_L[3] = (a + ((3 * (pred_T[3] + pred_L[3]) - 2 * pred_TL[3]) >> 2)) & 0x3ff;
1222 dst_y[x] = pred_L[0] = (y + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0x3ff;
1223 dst_u[x] = pred_L[1] = (u + ((3 * (pred_T[1] + pred_L[1]) - 2 * pred_TL[1]) >> 2)) & 0x3ff;
1224 dst_v[x] = pred_L[2] = (v + ((3 * (pred_T[2] + pred_L[2]) - 2 * pred_TL[2]) >> 2)) & 0x3ff;
1226 pred_TL[0] = pred_T[0];
1227 pred_TL[1] = pred_T[1];
1228 pred_TL[2] = pred_T[2];
1229 pred_TL[3] = pred_T[3];
1233 dst_y += p->linesize[0] / 2;
1234 dst_u += p->linesize[1] / 2;
1235 dst_v += p->linesize[2] / 2;
1236 dst_a += p->linesize[3] / 2;
1240 static void decode_ybr10i(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1242 SheerVideoContext *s = avctx->priv_data;
1243 uint16_t *dst_y, *dst_u, *dst_v;
1246 dst_y = (uint16_t *)p->data[0];
1247 dst_u = (uint16_t *)p->data[1];
1248 dst_v = (uint16_t *)p->data[2];
1250 for (y = 0; y < avctx->height; y++) {
1251 if (get_bits1(gb)) {
1252 for (x = 0; x < avctx->width; x++) {
1253 dst_y[x] = get_bits(gb, 10);
1254 dst_u[x] = get_bits(gb, 10);
1255 dst_v[x] = get_bits(gb, 10);
1258 int pred[4] = { 502, 512, 512, 512 };
1260 for (x = 0; x < avctx->width; x++) {
1263 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1264 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1265 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1267 dst_y[x] = pred[0] = (y + pred[0]) & 0x3ff;
1268 dst_u[x] = pred[1] = (u + pred[1]) & 0x3ff;
1269 dst_v[x] = pred[2] = (v + pred[2]) & 0x3ff;
1273 dst_y += p->linesize[0] / 2;
1274 dst_u += p->linesize[1] / 2;
1275 dst_v += p->linesize[2] / 2;
1279 static void decode_ybr10(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1281 SheerVideoContext *s = avctx->priv_data;
1282 uint16_t *dst_y, *dst_u, *dst_v;
1285 dst_y = (uint16_t *)p->data[0];
1286 dst_u = (uint16_t *)p->data[1];
1287 dst_v = (uint16_t *)p->data[2];
1289 if (get_bits1(gb)) {
1290 for (x = 0; x < avctx->width; x++) {
1291 dst_y[x] = get_bits(gb, 10);
1292 dst_u[x] = get_bits(gb, 10);
1293 dst_v[x] = get_bits(gb, 10);
1296 int pred[4] = { 502, 512, 512, 512 };
1298 for (x = 0; x < avctx->width; x++) {
1301 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1302 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1303 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1305 dst_y[x] = pred[0] = (y + pred[0]) & 0x3ff;
1306 dst_u[x] = pred[1] = (u + pred[1]) & 0x3ff;
1307 dst_v[x] = pred[2] = (v + pred[2]) & 0x3ff;
1311 dst_y += p->linesize[0] / 2;
1312 dst_u += p->linesize[1] / 2;
1313 dst_v += p->linesize[2] / 2;
1315 for (y = 1; y < avctx->height; y++) {
1316 if (get_bits1(gb)) {
1317 for (x = 0; x < avctx->width; x++) {
1318 dst_y[x] = get_bits(gb, 10);
1319 dst_u[x] = get_bits(gb, 10);
1320 dst_v[x] = get_bits(gb, 10);
1323 int pred_TL[4], pred_L[4], pred_T[4];
1326 pred_TL[0] = pred_L[0] = dst_y[-p->linesize[0] / 2];
1327 pred_TL[1] = pred_L[1] = dst_u[-p->linesize[1] / 2];
1328 pred_TL[2] = pred_L[2] = dst_v[-p->linesize[2] / 2];
1330 for (x = 0; x < avctx->width; x++) {
1331 pred_T[0] = dst_y[-p->linesize[0] / 2 + x];
1332 pred_T[1] = dst_u[-p->linesize[1] / 2 + x];
1333 pred_T[2] = dst_v[-p->linesize[2] / 2 + x];
1335 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1336 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1337 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1339 dst_y[x] = pred_L[0] = (y + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0x3ff;
1340 dst_u[x] = pred_L[1] = (u + ((3 * (pred_T[1] + pred_L[1]) - 2 * pred_TL[1]) >> 2)) & 0x3ff;
1341 dst_v[x] = pred_L[2] = (v + ((3 * (pred_T[2] + pred_L[2]) - 2 * pred_TL[2]) >> 2)) & 0x3ff;
1343 pred_TL[0] = pred_T[0];
1344 pred_TL[1] = pred_T[1];
1345 pred_TL[2] = pred_T[2];
1349 dst_y += p->linesize[0] / 2;
1350 dst_u += p->linesize[1] / 2;
1351 dst_v += p->linesize[2] / 2;
1355 static void decode_yry10i(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1357 SheerVideoContext *s = avctx->priv_data;
1358 uint16_t *dst_y, *dst_u, *dst_v;
1361 dst_y = (uint16_t *)p->data[0];
1362 dst_u = (uint16_t *)p->data[1];
1363 dst_v = (uint16_t *)p->data[2];
1365 for (y = 0; y < avctx->height; y++) {
1366 if (get_bits1(gb)) {
1367 for (x = 0; x < avctx->width; x += 2) {
1368 dst_y[x ] = get_bits(gb, 10);
1369 dst_u[x / 2] = get_bits(gb, 10);
1370 dst_y[x + 1] = get_bits(gb, 10);
1371 dst_v[x / 2] = get_bits(gb, 10);
1374 int pred[4] = { 502, 512, 512, 0 };
1376 for (x = 0; x < avctx->width; x += 2) {
1379 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1380 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1381 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1382 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1384 dst_y[x ] = pred[0] = (y1 + pred[0]) & 0x3ff;
1385 dst_u[x / 2] = pred[1] = (u + pred[1]) & 0x3ff;
1386 dst_y[x + 1] = pred[0] = (y2 + pred[0]) & 0x3ff;
1387 dst_v[x / 2] = pred[2] = (v + pred[2]) & 0x3ff;
1391 dst_y += p->linesize[0] / 2;
1392 dst_u += p->linesize[1] / 2;
1393 dst_v += p->linesize[2] / 2;
1397 static void decode_yry10(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1399 SheerVideoContext *s = avctx->priv_data;
1400 uint16_t *dst_y, *dst_u, *dst_v;
1403 dst_y = (uint16_t *)p->data[0];
1404 dst_u = (uint16_t *)p->data[1];
1405 dst_v = (uint16_t *)p->data[2];
1407 if (get_bits1(gb)) {
1408 for (x = 0; x < avctx->width; x += 2) {
1409 dst_y[x ] = get_bits(gb, 10);
1410 dst_u[x / 2] = get_bits(gb, 10);
1411 dst_y[x + 1] = get_bits(gb, 10);
1412 dst_v[x / 2] = get_bits(gb, 10);
1415 int pred[4] = { 502, 512, 512, 0 };
1417 for (x = 0; x < avctx->width; x += 2) {
1420 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1421 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1422 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1423 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1425 dst_y[x ] = pred[0] = (y1 + pred[0]) & 0x3ff;
1426 dst_u[x / 2] = pred[1] = (u + pred[1]) & 0x3ff;
1427 dst_y[x + 1] = pred[0] = (y2 + pred[0]) & 0x3ff;
1428 dst_v[x / 2] = pred[2] = (v + pred[2]) & 0x3ff;
1432 dst_y += p->linesize[0] / 2;
1433 dst_u += p->linesize[1] / 2;
1434 dst_v += p->linesize[2] / 2;
1436 for (y = 1; y < avctx->height; y++) {
1437 if (get_bits1(gb)) {
1438 for (x = 0; x < avctx->width; x += 2) {
1439 dst_y[x ] = get_bits(gb, 10);
1440 dst_u[x / 2] = get_bits(gb, 10);
1441 dst_y[x + 1] = get_bits(gb, 10);
1442 dst_v[x / 2] = get_bits(gb, 10);
1445 int pred_TL[6], pred_L[6], pred_T[6];
1448 pred_TL[0] = pred_L[0] = dst_y[-p->linesize[0] / 2];
1449 pred_TL[1] = pred_L[1] = dst_u[-p->linesize[1] / 2];
1450 pred_TL[2] = pred_L[2] = dst_v[-p->linesize[2] / 2];
1452 for (x = 0; x < avctx->width; x += 2) {
1453 pred_T[0] = dst_y[-p->linesize[0] / 2 + x];
1454 pred_T[3] = dst_y[-p->linesize[0] / 2 + x + 1];
1455 pred_T[1] = dst_u[-p->linesize[1] / 2 + x / 2];
1456 pred_T[2] = dst_v[-p->linesize[2] / 2 + x / 2];
1458 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1459 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1460 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1461 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1463 dst_y[x ] = pred_L[0] = (y1 + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0x3ff;
1464 dst_u[x / 2] = pred_L[1] = (u + (((pred_L[1] - pred_TL[1]) >> 1) + pred_T[1])) & 0x3ff;
1465 dst_y[x + 1] = pred_L[0] = (y2 + ((3 * (pred_T[3] + pred_L[0]) - 2 * pred_T[0]) >> 2)) & 0x3ff;
1466 dst_v[x / 2] = pred_L[2] = (v + (((pred_L[2] - pred_TL[2]) >> 1) + pred_T[2])) & 0x3ff;
1468 pred_TL[0] = pred_T[3];
1469 pred_TL[1] = pred_T[1];
1470 pred_TL[2] = pred_T[2];
1474 dst_y += p->linesize[0] / 2;
1475 dst_u += p->linesize[1] / 2;
1476 dst_v += p->linesize[2] / 2;
1480 static void decode_ca2i(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1482 SheerVideoContext *s = avctx->priv_data;
1483 uint16_t *dst_y, *dst_u, *dst_v, *dst_a;
1486 dst_y = (uint16_t *)p->data[0];
1487 dst_u = (uint16_t *)p->data[1];
1488 dst_v = (uint16_t *)p->data[2];
1489 dst_a = (uint16_t *)p->data[3];
1491 for (y = 0; y < avctx->height; y++) {
1492 if (get_bits1(gb)) {
1493 for (x = 0; x < avctx->width; x += 2) {
1494 dst_a[x ] = get_bits(gb, 10);
1495 dst_y[x ] = get_bits(gb, 10);
1496 dst_u[x / 2] = get_bits(gb, 10);
1497 dst_a[x + 1] = get_bits(gb, 10);
1498 dst_y[x + 1] = get_bits(gb, 10);
1499 dst_v[x / 2] = get_bits(gb, 10);
1502 int pred[4] = { 502, 512, 512, 502 };
1504 for (x = 0; x < avctx->width; x += 2) {
1505 int y1, y2, u, v, a1, a2;
1507 a1 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1508 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1509 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1510 a2 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1511 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1512 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1514 dst_y[x ] = pred[0] = (y1 + pred[0]) & 0x3ff;
1515 dst_u[x / 2] = pred[1] = (u + pred[1]) & 0x3ff;
1516 dst_y[x + 1] = pred[0] = (y2 + pred[0]) & 0x3ff;
1517 dst_a[x ] = pred[3] = (a1 + pred[3]) & 0x3ff;
1518 dst_v[x / 2] = pred[2] = (v + pred[2]) & 0x3ff;
1519 dst_a[x + 1] = pred[3] = (a2 + pred[3]) & 0x3ff;
1523 dst_y += p->linesize[0] / 2;
1524 dst_u += p->linesize[1] / 2;
1525 dst_v += p->linesize[2] / 2;
1526 dst_a += p->linesize[3] / 2;
1530 static void decode_ca2p(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1532 SheerVideoContext *s = avctx->priv_data;
1533 uint16_t *dst_y, *dst_u, *dst_v, *dst_a;
1536 dst_y = (uint16_t *)p->data[0];
1537 dst_u = (uint16_t *)p->data[1];
1538 dst_v = (uint16_t *)p->data[2];
1539 dst_a = (uint16_t *)p->data[3];
1541 if (get_bits1(gb)) {
1542 for (x = 0; x < avctx->width; x += 2) {
1543 dst_a[x ] = get_bits(gb, 10);
1544 dst_y[x ] = get_bits(gb, 10);
1545 dst_u[x / 2] = get_bits(gb, 10);
1546 dst_a[x + 1] = get_bits(gb, 10);
1547 dst_y[x + 1] = get_bits(gb, 10);
1548 dst_v[x / 2] = get_bits(gb, 10);
1551 int pred[4] = { 502, 512, 512, 502 };
1553 for (x = 0; x < avctx->width; x += 2) {
1554 int y1, y2, u, v, a1, a2;
1556 a1 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1557 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1558 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1559 a2 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1560 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1561 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1563 dst_y[x ] = pred[0] = (y1 + pred[0]) & 0x3ff;
1564 dst_u[x / 2] = pred[1] = (u + pred[1]) & 0x3ff;
1565 dst_y[x + 1] = pred[0] = (y2 + pred[0]) & 0x3ff;
1566 dst_a[x ] = pred[3] = (a1 + pred[3]) & 0x3ff;
1567 dst_v[x / 2] = pred[2] = (v + pred[2]) & 0x3ff;
1568 dst_a[x + 1] = pred[3] = (a2 + pred[3]) & 0x3ff;
1572 dst_y += p->linesize[0] / 2;
1573 dst_u += p->linesize[1] / 2;
1574 dst_v += p->linesize[2] / 2;
1575 dst_a += p->linesize[3] / 2;
1577 for (y = 1; y < avctx->height; y++) {
1578 if (get_bits1(gb)) {
1579 for (x = 0; x < avctx->width; x += 2) {
1580 dst_a[x ] = get_bits(gb, 10);
1581 dst_y[x ] = get_bits(gb, 10);
1582 dst_u[x / 2] = get_bits(gb, 10);
1583 dst_a[x + 1] = get_bits(gb, 10);
1584 dst_y[x + 1] = get_bits(gb, 10);
1585 dst_v[x / 2] = get_bits(gb, 10);
1588 int pred_TL[6], pred_L[6], pred_T[6];
1589 int y1, y2, u, v, a1, a2;
1591 pred_TL[0] = pred_L[0] = dst_y[-p->linesize[0] / 2];
1592 pred_TL[1] = pred_L[1] = dst_u[-p->linesize[1] / 2];
1593 pred_TL[2] = pred_L[2] = dst_v[-p->linesize[2] / 2];
1594 pred_TL[4] = pred_L[4] = dst_a[-p->linesize[3] / 2];
1596 for (x = 0; x < avctx->width; x += 2) {
1597 pred_T[0] = dst_y[-p->linesize[0] / 2 + x];
1598 pred_T[3] = dst_y[-p->linesize[0] / 2 + x + 1];
1599 pred_T[1] = dst_u[-p->linesize[1] / 2 + x / 2];
1600 pred_T[2] = dst_v[-p->linesize[2] / 2 + x / 2];
1601 pred_T[4] = dst_a[-p->linesize[3] / 2 + x];
1602 pred_T[5] = dst_a[-p->linesize[3] / 2 + x + 1];
1604 a1 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1605 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1606 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1607 a2 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1608 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1609 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1611 dst_y[x ] = pred_L[0] = (y1 + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0x3ff;
1612 dst_u[x / 2] = pred_L[1] = (u + (((pred_L[1] - pred_TL[1]) >> 1) + pred_T[1])) & 0x3ff;
1613 dst_y[x + 1] = pred_L[0] = (y2 + ((3 * (pred_T[3] + pred_L[0]) - 2 * pred_T[0]) >> 2)) & 0x3ff;
1614 dst_v[x / 2] = pred_L[2] = (v + (((pred_L[2] - pred_TL[2]) >> 1) + pred_T[2])) & 0x3ff;
1615 dst_a[x ] = pred_L[4] = (a1 + ((3 * (pred_T[4] + pred_L[4]) - 2 * pred_TL[4]) >> 2)) & 0x3ff;
1616 dst_a[x + 1] = pred_L[4] = (a2 + ((3 * (pred_T[5] + pred_L[4]) - 2 * pred_T[4]) >> 2)) & 0x3ff;
1618 pred_TL[0] = pred_T[3];
1619 pred_TL[1] = pred_T[1];
1620 pred_TL[2] = pred_T[2];
1621 pred_TL[4] = pred_T[5];
1625 dst_y += p->linesize[0] / 2;
1626 dst_u += p->linesize[1] / 2;
1627 dst_v += p->linesize[2] / 2;
1628 dst_a += p->linesize[3] / 2;
1632 static void decode_c82i(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1634 SheerVideoContext *s = avctx->priv_data;
1635 uint8_t *dst_y, *dst_u, *dst_v, *dst_a;
1643 for (y = 0; y < avctx->height; y += 1) {
1644 if (get_bits1(gb)) {
1645 for (x = 0; x < avctx->width; x += 2) {
1646 dst_a[x ] = get_bits(gb, 8);
1647 dst_y[x ] = get_bits(gb, 8);
1648 dst_u[x / 2] = get_bits(gb, 8);
1649 dst_a[x + 1] = get_bits(gb, 8);
1650 dst_y[x + 1] = get_bits(gb, 8);
1651 dst_v[x / 2] = get_bits(gb, 8);
1654 int pred[4] = { 125, -128, -128, 125 };
1656 for (x = 0; x < avctx->width; x += 2) {
1657 int y1, y2, u, v, a1, a2;
1659 a1 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1660 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1661 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1662 a2 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1663 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1664 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1666 dst_y[x ] = pred[0] = (y1 + pred[0]) & 0xff;
1667 dst_y[x + 1] = pred[0] = (y2 + pred[0]) & 0xff;
1668 dst_u[x / 2] = pred[1] = (u + pred[1]) & 0xff;
1669 dst_v[x / 2] = pred[2] = (v + pred[2]) & 0xff;
1670 dst_a[x ] = pred[3] = (a1 + pred[3]) & 0xff;
1671 dst_a[x + 1] = pred[3] = (a2 + pred[3]) & 0xff;
1675 dst_y += p->linesize[0];
1676 dst_u += p->linesize[1];
1677 dst_v += p->linesize[2];
1678 dst_a += p->linesize[3];
1682 static void decode_c82p(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1684 SheerVideoContext *s = avctx->priv_data;
1685 uint8_t *dst_y, *dst_u, *dst_v, *dst_a;
1693 if (get_bits1(gb)) {
1694 for (x = 0; x < avctx->width; x += 2) {
1695 dst_a[x ] = get_bits(gb, 8);
1696 dst_y[x ] = get_bits(gb, 8);
1697 dst_u[x / 2] = get_bits(gb, 8);
1698 dst_a[x + 1] = get_bits(gb, 8);
1699 dst_y[x + 1] = get_bits(gb, 8);
1700 dst_v[x / 2] = get_bits(gb, 8);
1703 int pred[4] = { 125, -128, -128, 125 };
1705 for (x = 0; x < avctx->width; x += 2) {
1706 int y1, y2, u, v, a1, a2;
1708 a1 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1709 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1710 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1711 a2 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1712 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1713 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1715 dst_y[x ] = pred[0] = (y1 + pred[0]) & 0xff;
1716 dst_u[x / 2] = pred[1] = (u + pred[1]) & 0xff;
1717 dst_y[x + 1] = pred[0] = (y2 + pred[0]) & 0xff;
1718 dst_a[x ] = pred[3] = (a1 + pred[3]) & 0xff;
1719 dst_v[x / 2] = pred[2] = (v + pred[2]) & 0xff;
1720 dst_a[x + 1] = pred[3] = (a2 + pred[3]) & 0xff;
1724 dst_y += p->linesize[0];
1725 dst_u += p->linesize[1];
1726 dst_v += p->linesize[2];
1727 dst_a += p->linesize[3];
1729 for (y = 1; y < avctx->height; y++) {
1730 if (get_bits1(gb)) {
1731 for (x = 0; x < avctx->width; x += 2) {
1732 dst_a[x ] = get_bits(gb, 8);
1733 dst_y[x ] = get_bits(gb, 8);
1734 dst_u[x / 2] = get_bits(gb, 8);
1735 dst_a[x + 1] = get_bits(gb, 8);
1736 dst_y[x + 1] = get_bits(gb, 8);
1737 dst_v[x / 2] = get_bits(gb, 8);
1740 int pred_TL[6], pred_L[6], pred_T[6];
1741 int y1, y2, u, v, a1, a2;
1743 pred_TL[0] = pred_L[0] = dst_y[-p->linesize[0]];
1744 pred_TL[1] = pred_L[1] = dst_u[-p->linesize[1]];
1745 pred_TL[2] = pred_L[2] = dst_v[-p->linesize[2]];
1746 pred_TL[4] = pred_L[4] = dst_a[-p->linesize[3]];
1748 for (x = 0; x < avctx->width; x += 2) {
1749 pred_T[0] = dst_y[-p->linesize[0] + x];
1750 pred_T[3] = dst_y[-p->linesize[0] + x + 1];
1751 pred_T[1] = dst_u[-p->linesize[1] + x / 2];
1752 pred_T[2] = dst_v[-p->linesize[2] + x / 2];
1753 pred_T[4] = dst_a[-p->linesize[3] + x];
1754 pred_T[5] = dst_a[-p->linesize[3] + x + 1];
1756 a1 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1757 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1758 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1759 a2 = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1760 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1761 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1763 dst_y[x ] = pred_L[0] = (y1 + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0xff;
1764 dst_u[x / 2] = pred_L[1] = (u + (((pred_L[1] - pred_TL[1]) >> 1) + pred_T[1])) & 0xff;
1765 dst_y[x + 1] = pred_L[0] = (y2 + ((3 * (pred_T[3] + pred_L[0]) - 2 * pred_T[0]) >> 2)) & 0xff;
1766 dst_v[x / 2] = pred_L[2] = (v + (((pred_L[2] - pred_TL[2]) >> 1) + pred_T[2])) & 0xff;
1767 dst_a[x ] = pred_L[4] = (a1 + ((3 * (pred_T[4] + pred_L[4]) - 2 * pred_TL[4]) >> 2)) & 0xff;
1768 dst_a[x + 1] = pred_L[4] = (a2 + ((3 * (pred_T[5] + pred_L[4]) - 2 * pred_T[4]) >> 2)) & 0xff;
1770 pred_TL[0] = pred_T[3];
1771 pred_TL[1] = pred_T[1];
1772 pred_TL[2] = pred_T[2];
1773 pred_TL[4] = pred_T[5];
1777 dst_y += p->linesize[0];
1778 dst_u += p->linesize[1];
1779 dst_v += p->linesize[2];
1780 dst_a += p->linesize[3];
1784 static void decode_ybyr(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1786 SheerVideoContext *s = avctx->priv_data;
1787 uint8_t *dst_y, *dst_u, *dst_v;
1794 if (get_bits1(gb)) {
1795 for (x = 0; x < avctx->width; x += 2) {
1796 dst_y[x ] = get_bits(gb, 8);
1797 dst_u[x / 2] = get_bits(gb, 8) + 128;
1798 dst_y[x + 1] = get_bits(gb, 8);
1799 dst_v[x / 2] = get_bits(gb, 8) + 128;
1802 int pred[4] = { -128, 128, 128, 0 };
1804 for (x = 0; x < avctx->width; x += 2) {
1807 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1808 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1809 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1810 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1812 dst_y[x ] = pred[0] = (y1 + pred[0]) & 0xff;
1813 dst_u[x / 2] = pred[1] = (u + pred[1]) & 0xff;
1814 dst_y[x + 1] = pred[0] = (y2 + pred[0]) & 0xff;
1815 dst_v[x / 2] = pred[2] = (v + pred[2]) & 0xff;
1819 dst_y += p->linesize[0];
1820 dst_u += p->linesize[1];
1821 dst_v += p->linesize[2];
1823 for (y = 1; y < avctx->height; y++) {
1824 if (get_bits1(gb)) {
1825 for (x = 0; x < avctx->width; x += 2) {
1826 dst_y[x ] = get_bits(gb, 8);
1827 dst_u[x / 2] = get_bits(gb, 8) + 128;
1828 dst_y[x + 1] = get_bits(gb, 8);
1829 dst_v[x / 2] = get_bits(gb, 8) + 128;
1832 int pred_TL[4], pred_L[4], pred_T[4];
1835 pred_TL[0] = pred_L[0] = dst_y[-p->linesize[0]];
1836 pred_TL[1] = pred_L[1] = dst_u[-p->linesize[1]];
1837 pred_TL[2] = pred_L[2] = dst_v[-p->linesize[2]];
1839 for (x = 0; x < avctx->width; x += 2) {
1840 pred_T[0] = dst_y[-p->linesize[0] + x];
1841 pred_T[3] = dst_y[-p->linesize[0] + x + 1];
1842 pred_T[1] = dst_u[-p->linesize[1] + x / 2];
1843 pred_T[2] = dst_v[-p->linesize[2] + x / 2];
1845 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1846 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1847 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1848 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1850 dst_y[x ] = pred_L[0] = (y1 + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0xff;
1851 dst_u[x / 2] = pred_L[1] = (u + (((pred_L[1] - pred_TL[1]) >> 1) + pred_T[1])) & 0xff;
1852 dst_y[x + 1] = pred_L[0] = (y2 + ((3 * (pred_T[3] + pred_L[0]) - 2 * pred_T[0]) >> 2)) & 0xff;
1853 dst_v[x / 2] = pred_L[2] = (v + (((pred_L[2] - pred_TL[2]) >> 1) + pred_T[2])) & 0xff;
1855 pred_TL[0] = pred_T[3];
1856 pred_TL[1] = pred_T[1];
1857 pred_TL[2] = pred_T[2];
1861 dst_y += p->linesize[0];
1862 dst_u += p->linesize[1];
1863 dst_v += p->linesize[2];
1867 static void decode_byryi(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1869 SheerVideoContext *s = avctx->priv_data;
1870 uint8_t *dst_y, *dst_u, *dst_v;
1877 if (get_bits1(gb)) {
1878 for (x = 0; x < avctx->width; x += 2) {
1879 dst_y[x ] = get_bits(gb, 8);
1880 dst_u[x / 2] = get_bits(gb, 8);
1881 dst_y[x + 1] = get_bits(gb, 8);
1882 dst_v[x / 2] = get_bits(gb, 8);
1885 int pred[4] = { 125, -128, -128, 0 };
1887 for (x = 0; x < avctx->width; x += 2) {
1890 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1891 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1892 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1893 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1895 dst_y[x ] = pred[0] = (y1 + pred[0]) & 0xff;
1896 dst_u[x / 2] = pred[1] = (u + pred[1]) & 0xff;
1897 dst_y[x + 1] = pred[0] = (y2 + pred[0]) & 0xff;
1898 dst_v[x / 2] = pred[2] = (v + pred[2]) & 0xff;
1902 dst_y += p->linesize[0];
1903 dst_u += p->linesize[1];
1904 dst_v += p->linesize[2];
1906 for (y = 1; y < avctx->height; y++) {
1907 if (get_bits1(gb)) {
1908 for (x = 0; x < avctx->width; x += 2) {
1909 dst_y[x ] = get_bits(gb, 8);
1910 dst_u[x / 2] = get_bits(gb, 8);
1911 dst_y[x + 1] = get_bits(gb, 8);
1912 dst_v[x / 2] = get_bits(gb, 8);
1918 pred_L[0] = dst_y[-p->linesize[0]];
1919 pred_L[1] = dst_u[-p->linesize[1]];
1920 pred_L[2] = dst_v[-p->linesize[2]];
1922 for (x = 0; x < avctx->width; x += 2) {
1923 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1924 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1925 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1926 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1928 dst_y[x ] = pred_L[0] = (y1 + pred_L[0]) & 0xff;
1929 dst_u[x / 2] = pred_L[1] = (u + pred_L[1]) & 0xff;
1930 dst_y[x + 1] = pred_L[0] = (y2 + pred_L[0]) & 0xff;
1931 dst_v[x / 2] = pred_L[2] = (v + pred_L[2]) & 0xff;
1935 dst_y += p->linesize[0];
1936 dst_u += p->linesize[1];
1937 dst_v += p->linesize[2];
1941 static void decode_byry(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
1943 SheerVideoContext *s = avctx->priv_data;
1944 uint8_t *dst_y, *dst_u, *dst_v;
1951 if (get_bits1(gb)) {
1952 for (x = 0; x < avctx->width; x += 2) {
1953 dst_y[x ] = get_bits(gb, 8);
1954 dst_u[x / 2] = get_bits(gb, 8);
1955 dst_y[x + 1] = get_bits(gb, 8);
1956 dst_v[x / 2] = get_bits(gb, 8);
1959 int pred[4] = { 125, -128, -128, 0 };
1961 for (x = 0; x < avctx->width; x += 2) {
1964 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1965 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1966 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
1967 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
1969 dst_y[x ] = pred[0] = (y1 + pred[0]) & 0xff;
1970 dst_u[x / 2] = pred[1] = (u + pred[1]) & 0xff;
1971 dst_y[x + 1] = pred[0] = (y2 + pred[0]) & 0xff;
1972 dst_v[x / 2] = pred[2] = (v + pred[2]) & 0xff;
1976 dst_y += p->linesize[0];
1977 dst_u += p->linesize[1];
1978 dst_v += p->linesize[2];
1980 for (y = 1; y < avctx->height; y++) {
1981 if (get_bits1(gb)) {
1982 for (x = 0; x < avctx->width; x += 2) {
1983 dst_y[x ] = get_bits(gb, 8);
1984 dst_u[x / 2] = get_bits(gb, 8);
1985 dst_y[x + 1] = get_bits(gb, 8);
1986 dst_v[x / 2] = get_bits(gb, 8);
1989 int pred_TL[4], pred_L[4], pred_T[4];
1992 pred_TL[0] = pred_L[0] = dst_y[-p->linesize[0]];
1993 pred_TL[1] = pred_L[1] = dst_u[-p->linesize[1]];
1994 pred_TL[2] = pred_L[2] = dst_v[-p->linesize[2]];
1996 for (x = 0; x < avctx->width; x += 2) {
1997 pred_T[0] = dst_y[-p->linesize[0] + x];
1998 pred_T[3] = dst_y[-p->linesize[0] + x + 1];
1999 pred_T[1] = dst_u[-p->linesize[1] + x / 2];
2000 pred_T[2] = dst_v[-p->linesize[2] + x / 2];
2002 y1 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2003 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2004 y2 = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2005 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2007 dst_y[x ] = pred_L[0] = (y1 + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0xff;
2008 dst_u[x / 2] = pred_L[1] = (u + (((pred_L[1] - pred_TL[1]) >> 1) + pred_T[1])) & 0xff;
2009 dst_y[x + 1] = pred_L[0] = (y2 + ((3 * (pred_T[3] + pred_L[0]) - 2 * pred_T[0]) >> 2)) & 0xff;
2010 dst_v[x / 2] = pred_L[2] = (v + (((pred_L[2] - pred_TL[2]) >> 1) + pred_T[2])) & 0xff;
2012 pred_TL[0] = pred_T[3];
2013 pred_TL[1] = pred_T[1];
2014 pred_TL[2] = pred_T[2];
2018 dst_y += p->linesize[0];
2019 dst_u += p->linesize[1];
2020 dst_v += p->linesize[2];
2024 static void decode_ybri(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2026 SheerVideoContext *s = avctx->priv_data;
2027 uint8_t *dst_y, *dst_u, *dst_v;
2034 if (get_bits1(gb)) {
2035 for (x = 0; x < avctx->width; x++) {
2036 dst_y[x] = get_bits(gb, 8);
2037 dst_u[x] = get_bits(gb, 8);
2038 dst_v[x] = get_bits(gb, 8);
2041 int pred[4] = { 125, -128, -128, -128 };
2043 for (x = 0; x < avctx->width; x++) {
2046 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2047 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2048 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2050 dst_y[x] = pred[0] = (y + pred[0]) & 0xff;
2051 dst_u[x] = pred[1] = (u + pred[1]) & 0xff;
2052 dst_v[x] = pred[2] = (v + pred[2]) & 0xff;
2056 dst_y += p->linesize[0];
2057 dst_u += p->linesize[1];
2058 dst_v += p->linesize[2];
2060 for (y = 1; y < avctx->height; y++) {
2061 if (get_bits1(gb)) {
2062 for (x = 0; x < avctx->width; x++) {
2063 dst_y[x] = get_bits(gb, 8);
2064 dst_u[x] = get_bits(gb, 8);
2065 dst_v[x] = get_bits(gb, 8);
2071 pred_L[0] = dst_y[-p->linesize[0]];
2072 pred_L[1] = dst_u[-p->linesize[1]];
2073 pred_L[2] = dst_v[-p->linesize[2]];
2075 for (x = 0; x < avctx->width; x++) {
2076 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2077 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2078 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2080 dst_y[x] = pred_L[0] = (y + pred_L[0]) & 0xff;
2081 dst_u[x] = pred_L[1] = (u + pred_L[1]) & 0xff;
2082 dst_v[x] = pred_L[2] = (v + pred_L[2]) & 0xff;
2086 dst_y += p->linesize[0];
2087 dst_u += p->linesize[1];
2088 dst_v += p->linesize[2];
2092 static void decode_ybr(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2094 SheerVideoContext *s = avctx->priv_data;
2095 uint8_t *dst_y, *dst_u, *dst_v;
2102 if (get_bits1(gb)) {
2103 for (x = 0; x < avctx->width; x++) {
2104 dst_y[x] = get_bits(gb, 8);
2105 dst_u[x] = get_bits(gb, 8);
2106 dst_v[x] = get_bits(gb, 8);
2109 int pred[4] = { 125, -128, -128, -128 };
2111 for (x = 0; x < avctx->width; x++) {
2114 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2115 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2116 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2118 dst_y[x] = pred[0] = (y + pred[0]) & 0xff;
2119 dst_u[x] = pred[1] = (u + pred[1]) & 0xff;
2120 dst_v[x] = pred[2] = (v + pred[2]) & 0xff;
2124 dst_y += p->linesize[0];
2125 dst_u += p->linesize[1];
2126 dst_v += p->linesize[2];
2128 for (y = 1; y < avctx->height; y++) {
2129 if (get_bits1(gb)) {
2130 for (x = 0; x < avctx->width; x++) {
2131 dst_y[x] = get_bits(gb, 8);
2132 dst_u[x] = get_bits(gb, 8);
2133 dst_v[x] = get_bits(gb, 8);
2136 int pred_TL[4], pred_L[4], pred_T[4];
2139 pred_TL[0] = pred_L[0] = dst_y[-p->linesize[0]];
2140 pred_TL[1] = pred_L[1] = dst_u[-p->linesize[1]];
2141 pred_TL[2] = pred_L[2] = dst_v[-p->linesize[2]];
2143 for (x = 0; x < avctx->width; x++) {
2144 pred_T[0] = dst_y[-p->linesize[0] + x];
2145 pred_T[1] = dst_u[-p->linesize[1] + x];
2146 pred_T[2] = dst_v[-p->linesize[2] + x];
2148 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2149 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2150 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2152 dst_y[x] = pred_L[0] = (y + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0xff;
2153 dst_u[x] = pred_L[1] = (u + ((3 * (pred_T[1] + pred_L[1]) - 2 * pred_TL[1]) >> 2)) & 0xff;
2154 dst_v[x] = pred_L[2] = (v + ((3 * (pred_T[2] + pred_L[2]) - 2 * pred_TL[2]) >> 2)) & 0xff;
2156 pred_TL[0] = pred_T[0];
2157 pred_TL[1] = pred_T[1];
2158 pred_TL[2] = pred_T[2];
2162 dst_y += p->linesize[0];
2163 dst_u += p->linesize[1];
2164 dst_v += p->linesize[2];
2168 static void decode_aybri(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2170 SheerVideoContext *s = avctx->priv_data;
2171 uint8_t *dst_a, *dst_y, *dst_u, *dst_v;
2179 if (get_bits1(gb)) {
2180 for (x = 0; x < avctx->width; x++) {
2181 dst_a[x] = get_bits(gb, 8);
2182 dst_y[x] = get_bits(gb, 8);
2183 dst_u[x] = get_bits(gb, 8);
2184 dst_v[x] = get_bits(gb, 8);
2187 int pred[4] = { 125, 125, -128, -128 };
2189 for (x = 0; x < avctx->width; x++) {
2192 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2193 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2194 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2195 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2197 dst_a[x] = pred[0] = (a + pred[0]) & 0xff;
2198 dst_y[x] = pred[1] = (y + pred[1]) & 0xff;
2199 dst_u[x] = pred[2] = (u + pred[2]) & 0xff;
2200 dst_v[x] = pred[3] = (v + pred[3]) & 0xff;
2204 dst_a += p->linesize[3];
2205 dst_y += p->linesize[0];
2206 dst_u += p->linesize[1];
2207 dst_v += p->linesize[2];
2209 for (y = 1; y < avctx->height; y++) {
2210 if (get_bits1(gb)) {
2211 for (x = 0; x < avctx->width; x++) {
2212 dst_a[x] = get_bits(gb, 8);
2213 dst_y[x] = get_bits(gb, 8);
2214 dst_u[x] = get_bits(gb, 8);
2215 dst_v[x] = get_bits(gb, 8);
2221 pred_L[0] = dst_a[-p->linesize[3]];
2222 pred_L[1] = dst_y[-p->linesize[0]];
2223 pred_L[2] = dst_u[-p->linesize[1]];
2224 pred_L[3] = dst_v[-p->linesize[2]];
2226 for (x = 0; x < avctx->width; x++) {
2227 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2228 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2229 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2230 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2232 dst_a[x] = pred_L[0] = (a + pred_L[0]) & 0xff;
2233 dst_y[x] = pred_L[1] = (y + pred_L[1]) & 0xff;
2234 dst_u[x] = pred_L[2] = (u + pred_L[2]) & 0xff;
2235 dst_v[x] = pred_L[3] = (v + pred_L[3]) & 0xff;
2239 dst_a += p->linesize[3];
2240 dst_y += p->linesize[0];
2241 dst_u += p->linesize[1];
2242 dst_v += p->linesize[2];
2246 static void decode_aybr(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2248 SheerVideoContext *s = avctx->priv_data;
2249 uint8_t *dst_a, *dst_y, *dst_u, *dst_v;
2257 if (get_bits1(gb)) {
2258 for (x = 0; x < avctx->width; x++) {
2259 dst_a[x] = get_bits(gb, 8);
2260 dst_y[x] = get_bits(gb, 8);
2261 dst_u[x] = get_bits(gb, 8);
2262 dst_v[x] = get_bits(gb, 8);
2265 int pred[4] = { 125, 125, -128, -128 };
2267 for (x = 0; x < avctx->width; x++) {
2270 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2271 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2272 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2273 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2275 dst_a[x] = pred[0] = (a + pred[0]) & 0xff;
2276 dst_y[x] = pred[1] = (y + pred[1]) & 0xff;
2277 dst_u[x] = pred[2] = (u + pred[2]) & 0xff;
2278 dst_v[x] = pred[3] = (v + pred[3]) & 0xff;
2282 dst_a += p->linesize[3];
2283 dst_y += p->linesize[0];
2284 dst_u += p->linesize[1];
2285 dst_v += p->linesize[2];
2287 for (y = 1; y < avctx->height; y++) {
2288 if (get_bits1(gb)) {
2289 for (x = 0; x < avctx->width; x++) {
2290 dst_a[x] = get_bits(gb, 8);
2291 dst_y[x] = get_bits(gb, 8);
2292 dst_u[x] = get_bits(gb, 8);
2293 dst_v[x] = get_bits(gb, 8);
2296 int pred_TL[4], pred_L[4], pred_T[4];
2299 pred_TL[0] = pred_L[0] = dst_a[-p->linesize[3]];
2300 pred_TL[1] = pred_L[1] = dst_y[-p->linesize[0]];
2301 pred_TL[2] = pred_L[2] = dst_u[-p->linesize[1]];
2302 pred_TL[3] = pred_L[3] = dst_v[-p->linesize[2]];
2304 for (x = 0; x < avctx->width; x++) {
2305 pred_T[0] = dst_a[-p->linesize[3] + x];
2306 pred_T[1] = dst_y[-p->linesize[0] + x];
2307 pred_T[2] = dst_u[-p->linesize[1] + x];
2308 pred_T[3] = dst_v[-p->linesize[2] + x];
2310 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2311 y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2312 u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2313 v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2315 dst_a[x] = pred_L[0] = (a + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0xff;
2316 dst_y[x] = pred_L[1] = (y + ((3 * (pred_T[1] + pred_L[1]) - 2 * pred_TL[1]) >> 2)) & 0xff;
2317 dst_u[x] = pred_L[2] = (u + ((3 * (pred_T[2] + pred_L[2]) - 2 * pred_TL[2]) >> 2)) & 0xff;
2318 dst_v[x] = pred_L[3] = (v + ((3 * (pred_T[3] + pred_L[3]) - 2 * pred_TL[3]) >> 2)) & 0xff;
2320 pred_TL[0] = pred_T[0];
2321 pred_TL[1] = pred_T[1];
2322 pred_TL[2] = pred_T[2];
2323 pred_TL[3] = pred_T[3];
2327 dst_a += p->linesize[3];
2328 dst_y += p->linesize[0];
2329 dst_u += p->linesize[1];
2330 dst_v += p->linesize[2];
2334 static void decode_argxi(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2336 SheerVideoContext *s = avctx->priv_data;
2337 uint16_t *dst_r, *dst_g, *dst_b, *dst_a;
2340 dst_r = (uint16_t *)p->data[2];
2341 dst_g = (uint16_t *)p->data[0];
2342 dst_b = (uint16_t *)p->data[1];
2343 dst_a = (uint16_t *)p->data[3];
2345 for (y = 0; y < avctx->height; y++) {
2346 if (get_bits1(gb)) {
2347 for (x = 0; x < avctx->width; x++) {
2348 dst_a[x] = get_bits(gb, 10);
2349 dst_r[x] = get_bits(gb, 10);
2350 dst_g[x] = get_bits(gb, 10);
2351 dst_b[x] = get_bits(gb, 10);
2354 int pred[4] = { 512, 512, 512, 512 };
2356 for (x = 0; x < avctx->width; x++) {
2359 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2360 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2361 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2362 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2364 dst_a[x] = pred[3] = (a + pred[3]) & 0x3ff;
2365 dst_r[x] = pred[0] = (r + pred[0]) & 0x3ff;
2366 dst_g[x] = pred[1] = (r + g + pred[1]) & 0x3ff;
2367 dst_b[x] = pred[2] = (r + g + b + pred[2]) & 0x3ff;
2371 dst_r += p->linesize[2] / 2;
2372 dst_g += p->linesize[0] / 2;
2373 dst_b += p->linesize[1] / 2;
2374 dst_a += p->linesize[3] / 2;
2378 static void decode_argx(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2380 SheerVideoContext *s = avctx->priv_data;
2381 uint16_t *dst_r, *dst_g, *dst_b, *dst_a;
2384 dst_r = (uint16_t *)p->data[2];
2385 dst_g = (uint16_t *)p->data[0];
2386 dst_b = (uint16_t *)p->data[1];
2387 dst_a = (uint16_t *)p->data[3];
2389 if (get_bits1(gb)) {
2390 for (x = 0; x < avctx->width; x++) {
2391 dst_a[x] = get_bits(gb, 10);
2392 dst_r[x] = get_bits(gb, 10);
2393 dst_g[x] = get_bits(gb, 10);
2394 dst_b[x] = get_bits(gb, 10);
2397 int pred[4] = { 512, 512, 512, 512 };
2399 for (x = 0; x < avctx->width; x++) {
2402 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2403 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2404 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2405 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2407 dst_a[x] = pred[3] = (a + pred[3]) & 0x3ff;
2408 dst_r[x] = pred[0] = (r + pred[0]) & 0x3ff;
2409 dst_g[x] = pred[1] = (r + g + pred[1]) & 0x3ff;
2410 dst_b[x] = pred[2] = (r + g + b + pred[2]) & 0x3ff;
2414 dst_r += p->linesize[2] / 2;
2415 dst_g += p->linesize[0] / 2;
2416 dst_b += p->linesize[1] / 2;
2417 dst_a += p->linesize[3] / 2;
2419 for (y = 1; y < avctx->height; y++) {
2420 if (get_bits1(gb)) {
2421 for (x = 0; x < avctx->width; x++) {
2422 dst_a[x] = get_bits(gb, 10);
2423 dst_r[x] = get_bits(gb, 10);
2424 dst_g[x] = get_bits(gb, 10);
2425 dst_b[x] = get_bits(gb, 10);
2428 int pred_TL[4], pred_L[4], pred_T[4];
2431 pred_TL[0] = pred_L[0] = dst_r[-p->linesize[2] / 2];
2432 pred_TL[1] = pred_L[1] = dst_g[-p->linesize[0] / 2];
2433 pred_TL[2] = pred_L[2] = dst_b[-p->linesize[1] / 2];
2434 pred_TL[3] = pred_L[3] = dst_a[-p->linesize[3] / 2];
2436 for (x = 0; x < avctx->width; x++) {
2437 pred_T[0] = dst_r[-p->linesize[2] / 2 + x];
2438 pred_T[1] = dst_g[-p->linesize[0] / 2 + x];
2439 pred_T[2] = dst_b[-p->linesize[1] / 2 + x];
2440 pred_T[3] = dst_a[-p->linesize[3] / 2 + x];
2442 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2443 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2444 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2445 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2447 dst_a[x] = pred_L[3] = (a + ((3 * (pred_T[3] + pred_L[3]) - 2 * pred_TL[3]) >> 2)) & 0x3ff;
2448 dst_r[x] = pred_L[0] = (r + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0x3ff;
2449 dst_g[x] = pred_L[1] = (r + g + ((3 * (pred_T[1] + pred_L[1]) - 2 * pred_TL[1]) >> 2)) & 0x3ff;
2450 dst_b[x] = pred_L[2] = (r + g + b + ((3 * (pred_T[2] + pred_L[2]) - 2 * pred_TL[2]) >> 2)) & 0x3ff;
2452 pred_TL[0] = pred_T[0];
2453 pred_TL[1] = pred_T[1];
2454 pred_TL[2] = pred_T[2];
2455 pred_TL[3] = pred_T[3];
2459 dst_r += p->linesize[2] / 2;
2460 dst_g += p->linesize[0] / 2;
2461 dst_b += p->linesize[1] / 2;
2462 dst_a += p->linesize[3] / 2;
2466 static void decode_rgbxi(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2468 SheerVideoContext *s = avctx->priv_data;
2469 uint16_t *dst_r, *dst_g, *dst_b;
2472 dst_r = (uint16_t *)p->data[2];
2473 dst_g = (uint16_t *)p->data[0];
2474 dst_b = (uint16_t *)p->data[1];
2476 for (y = 0; y < avctx->height; y++) {
2477 if (get_bits1(gb)) {
2478 for (x = 0; x < avctx->width; x++) {
2479 dst_r[x] = get_bits(gb, 10);
2480 dst_g[x] = get_bits(gb, 10);
2481 dst_b[x] = get_bits(gb, 10);
2484 int pred[4] = { 512, 512, 512, 0 };
2486 for (x = 0; x < avctx->width; x++) {
2489 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2490 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2491 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2493 dst_r[x] = pred[0] = (r + pred[0]) & 0x3ff;
2494 dst_g[x] = pred[1] = (r + g + pred[1]) & 0x3ff;
2495 dst_b[x] = pred[2] = (r + g + b + pred[2]) & 0x3ff;
2499 dst_r += p->linesize[2] / 2;
2500 dst_g += p->linesize[0] / 2;
2501 dst_b += p->linesize[1] / 2;
2505 static void decode_rgbx(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2507 SheerVideoContext *s = avctx->priv_data;
2508 uint16_t *dst_r, *dst_g, *dst_b;
2511 dst_r = (uint16_t *)p->data[2];
2512 dst_g = (uint16_t *)p->data[0];
2513 dst_b = (uint16_t *)p->data[1];
2515 if (get_bits1(gb)) {
2516 for (x = 0; x < avctx->width; x++) {
2517 dst_r[x] = get_bits(gb, 10);
2518 dst_g[x] = get_bits(gb, 10);
2519 dst_b[x] = get_bits(gb, 10);
2522 int pred[4] = { 512, 512, 512, 0 };
2524 for (x = 0; x < avctx->width; x++) {
2527 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2528 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2529 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2531 dst_r[x] = pred[0] = (r + pred[0]) & 0x3ff;
2532 dst_g[x] = pred[1] = (r + g + pred[1]) & 0x3ff;
2533 dst_b[x] = pred[2] = (r + g + b + pred[2]) & 0x3ff;
2537 dst_r += p->linesize[2] / 2;
2538 dst_g += p->linesize[0] / 2;
2539 dst_b += p->linesize[1] / 2;
2541 for (y = 1; y < avctx->height; y++) {
2542 if (get_bits1(gb)) {
2543 for (x = 0; x < avctx->width; x++) {
2544 dst_r[x] = get_bits(gb, 10);
2545 dst_g[x] = get_bits(gb, 10);
2546 dst_b[x] = get_bits(gb, 10);
2549 int pred_TL[4], pred_L[4], pred_T[4];
2552 pred_TL[0] = pred_L[0] = dst_r[-p->linesize[2] / 2];
2553 pred_TL[1] = pred_L[1] = dst_g[-p->linesize[0] / 2];
2554 pred_TL[2] = pred_L[2] = dst_b[-p->linesize[1] / 2];
2556 for (x = 0; x < avctx->width; x++) {
2557 pred_T[0] = dst_r[-p->linesize[2] / 2 + x];
2558 pred_T[1] = dst_g[-p->linesize[0] / 2 + x];
2559 pred_T[2] = dst_b[-p->linesize[1] / 2 + x];
2561 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2562 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2563 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2565 dst_r[x] = pred_L[0] = (r + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0x3ff;
2566 dst_g[x] = pred_L[1] = (r + g + ((3 * (pred_T[1] + pred_L[1]) - 2 * pred_TL[1]) >> 2)) & 0x3ff;
2567 dst_b[x] = pred_L[2] = (r + g + b + ((3 * (pred_T[2] + pred_L[2]) - 2 * pred_TL[2]) >> 2)) & 0x3ff;
2569 pred_TL[0] = pred_T[0];
2570 pred_TL[1] = pred_T[1];
2571 pred_TL[2] = pred_T[2];
2575 dst_r += p->linesize[2] / 2;
2576 dst_g += p->linesize[0] / 2;
2577 dst_b += p->linesize[1] / 2;
2581 static void decode_argbi(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2583 SheerVideoContext *s = avctx->priv_data;
2588 if (get_bits1(gb)) {
2589 for (x = 0; x < avctx->width; x++) {
2590 dst[x * 4 + 0] = get_bits(gb, 8);
2591 dst[x * 4 + 1] = get_bits(gb, 8);
2592 dst[x * 4 + 2] = get_bits(gb, 8);
2593 dst[x * 4 + 3] = get_bits(gb, 8);
2596 int pred[4] = { -128, -128, -128, -128 };
2598 for (x = 0; x < avctx->width; x++) {
2601 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2602 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2603 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2604 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2606 dst[4 * x + 0] = pred[0] = (a + pred[0]) & 0xff;
2607 dst[4 * x + 1] = pred[1] = (r + pred[1]) & 0xff;
2608 dst[4 * x + 2] = pred[2] = (r + g + pred[2]) & 0xff;
2609 dst[4 * x + 3] = pred[3] = (r + g + b + pred[3]) & 0xff;
2613 dst += p->linesize[0];
2614 for (y = 1; y < avctx->height; y++) {
2615 if (get_bits1(gb)) {
2616 for (x = 0; x < avctx->width; x++) {
2617 dst[x * 4 + 0] = get_bits(gb, 8);
2618 dst[x * 4 + 1] = get_bits(gb, 8);
2619 dst[x * 4 + 2] = get_bits(gb, 8);
2620 dst[x * 4 + 3] = get_bits(gb, 8);
2626 pred_L[0] = dst[-p->linesize[0] + 0];
2627 pred_L[1] = dst[-p->linesize[0] + 1];
2628 pred_L[2] = dst[-p->linesize[0] + 2];
2629 pred_L[3] = dst[-p->linesize[0] + 3];
2631 for (x = 0; x < avctx->width; x++) {
2632 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2633 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2634 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2635 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2637 dst[4 * x + 0] = pred_L[0] = (a + pred_L[0]) & 0xff;
2638 dst[4 * x + 1] = pred_L[1] = (r + pred_L[1]) & 0xff;
2639 dst[4 * x + 2] = pred_L[2] = (r + g + pred_L[2]) & 0xff;
2640 dst[4 * x + 3] = pred_L[3] = (r + g + b + pred_L[3]) & 0xff;
2643 dst += p->linesize[0];
2647 static void decode_argb(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2649 SheerVideoContext *s = avctx->priv_data;
2654 if (get_bits1(gb)) {
2655 for (x = 0; x < avctx->width; x++) {
2656 dst[x * 4 + 0] = get_bits(gb, 8);
2657 dst[x * 4 + 1] = get_bits(gb, 8);
2658 dst[x * 4 + 2] = get_bits(gb, 8);
2659 dst[x * 4 + 3] = get_bits(gb, 8);
2662 int pred[4] = { -128, -128, -128, -128 };
2664 for (x = 0; x < avctx->width; x++) {
2667 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2668 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2669 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2670 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2672 dst[4 * x + 0] = pred[0] = (a + pred[0]) & 0xff;
2673 dst[4 * x + 1] = pred[1] = (r + pred[1]) & 0xff;
2674 dst[4 * x + 2] = pred[2] = (r + g + pred[2]) & 0xff;
2675 dst[4 * x + 3] = pred[3] = (r + g + b + pred[3]) & 0xff;
2679 dst += p->linesize[0];
2680 for (y = 1; y < avctx->height; y++) {
2681 if (get_bits1(gb)) {
2682 for (x = 0; x < avctx->width; x++) {
2683 dst[x * 4 + 0] = get_bits(gb, 8);
2684 dst[x * 4 + 1] = get_bits(gb, 8);
2685 dst[x * 4 + 2] = get_bits(gb, 8);
2686 dst[x * 4 + 3] = get_bits(gb, 8);
2689 int pred_TL[4], pred_L[4], pred_T[4];
2692 pred_TL[0] = pred_L[0] = dst[-p->linesize[0] + 0];
2693 pred_TL[1] = pred_L[1] = dst[-p->linesize[0] + 1];
2694 pred_TL[2] = pred_L[2] = dst[-p->linesize[0] + 2];
2695 pred_TL[3] = pred_L[3] = dst[-p->linesize[0] + 3];
2697 for (x = 0; x < avctx->width; x++) {
2698 pred_T[0] = dst[-p->linesize[0] + 4 * x + 0];
2699 pred_T[1] = dst[-p->linesize[0] + 4 * x + 1];
2700 pred_T[2] = dst[-p->linesize[0] + 4 * x + 2];
2701 pred_T[3] = dst[-p->linesize[0] + 4 * x + 3];
2703 a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2704 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2705 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2706 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2708 dst[4 * x + 0] = pred_L[0] = (a + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0xff;
2709 dst[4 * x + 1] = pred_L[1] = (r + ((3 * (pred_T[1] + pred_L[1]) - 2 * pred_TL[1]) >> 2)) & 0xff;
2710 dst[4 * x + 2] = pred_L[2] = (r + g + ((3 * (pred_T[2] + pred_L[2]) - 2 * pred_TL[2]) >> 2)) & 0xff;
2711 dst[4 * x + 3] = pred_L[3] = (r + g + b + ((3 * (pred_T[3] + pred_L[3]) - 2 * pred_TL[3]) >> 2)) & 0xff;
2713 pred_TL[0] = pred_T[0];
2714 pred_TL[1] = pred_T[1];
2715 pred_TL[2] = pred_T[2];
2716 pred_TL[3] = pred_T[3];
2719 dst += p->linesize[0];
2723 static void decode_rgbi(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2725 SheerVideoContext *s = avctx->priv_data;
2730 if (get_bits1(gb)) {
2731 for (x = 0; x < avctx->width; x++) {
2732 dst[x * 4 + 0] = get_bits(gb, 8);
2733 dst[x * 4 + 1] = get_bits(gb, 8);
2734 dst[x * 4 + 2] = get_bits(gb, 8);
2737 int pred[4] = { -128, -128, -128, -128 };
2739 for (x = 0; x < avctx->width; x++) {
2742 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2743 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2744 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2746 dst[4 * x + 0] = pred[0] = (r + pred[0]) & 0xff;
2747 dst[4 * x + 1] = pred[1] = (r + g + pred[1]) & 0xff;
2748 dst[4 * x + 2] = pred[2] = (r + g + b + pred[2]) & 0xff;
2752 dst += p->linesize[0];
2753 for (y = 1; y < avctx->height; y++) {
2754 if (get_bits1(gb)) {
2755 for (x = 0; x < avctx->width; x++) {
2756 dst[x * 4 + 0] = get_bits(gb, 8);
2757 dst[x * 4 + 1] = get_bits(gb, 8);
2758 dst[x * 4 + 2] = get_bits(gb, 8);
2764 pred_L[0] = dst[-p->linesize[0] + 0];
2765 pred_L[1] = dst[-p->linesize[0] + 1];
2766 pred_L[2] = dst[-p->linesize[0] + 2];
2768 for (x = 0; x < avctx->width; x++) {
2769 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2770 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2771 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2773 dst[4 * x + 0] = pred_L[0] = (r + pred_L[0]) & 0xff;
2774 dst[4 * x + 1] = pred_L[1] = (r + g + pred_L[1]) & 0xff;
2775 dst[4 * x + 2] = pred_L[2] = (r + g + b + pred_L[2]) & 0xff;
2778 dst += p->linesize[0];
2782 static void decode_rgb(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
2784 SheerVideoContext *s = avctx->priv_data;
2789 if (get_bits1(gb)) {
2790 for (x = 0; x < avctx->width; x++) {
2791 dst[x * 4 + 0] = get_bits(gb, 8);
2792 dst[x * 4 + 1] = get_bits(gb, 8);
2793 dst[x * 4 + 2] = get_bits(gb, 8);
2796 int pred[4] = { -128, -128, -128, -128 };
2798 for (x = 0; x < avctx->width; x++) {
2801 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2802 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2803 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2805 dst[4 * x + 0] = pred[0] = (r + pred[0]) & 0xff;
2806 dst[4 * x + 1] = pred[1] = (r + g + pred[1]) & 0xff;
2807 dst[4 * x + 2] = pred[2] = (r + g + b + pred[2]) & 0xff;
2811 dst += p->linesize[0];
2812 for (y = 1; y < avctx->height; y++) {
2813 if (get_bits1(gb)) {
2814 for (x = 0; x < avctx->width; x++) {
2815 dst[x * 4 + 0] = get_bits(gb, 8);
2816 dst[x * 4 + 1] = get_bits(gb, 8);
2817 dst[x * 4 + 2] = get_bits(gb, 8);
2820 int pred_TL[4], pred_L[4], pred_T[4];
2823 pred_TL[0] = pred_L[0] = dst[-p->linesize[0] + 0];
2824 pred_TL[1] = pred_L[1] = dst[-p->linesize[0] + 1];
2825 pred_TL[2] = pred_L[2] = dst[-p->linesize[0] + 2];
2827 for (x = 0; x < avctx->width; x++) {
2828 pred_T[0] = dst[-p->linesize[0] + 4 * x + 0];
2829 pred_T[1] = dst[-p->linesize[0] + 4 * x + 1];
2830 pred_T[2] = dst[-p->linesize[0] + 4 * x + 2];
2832 r = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2);
2833 g = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2834 b = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2);
2836 dst[4 * x + 0] = pred_L[0] = (r + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0xff;
2837 dst[4 * x + 1] = pred_L[1] = (r + g + ((3 * (pred_T[1] + pred_L[1]) - 2 * pred_TL[1]) >> 2)) & 0xff;
2838 dst[4 * x + 2] = pred_L[2] = (r + g + b + ((3 * (pred_T[2] + pred_L[2]) - 2 * pred_TL[2]) >> 2)) & 0xff;
2840 pred_TL[0] = pred_T[0];
2841 pred_TL[1] = pred_T[1];
2842 pred_TL[2] = pred_T[2];
2845 dst += p->linesize[0];
2849 static int build_vlc(VLC *vlc, const uint8_t *len, int count)
2851 uint32_t codes[1024];
2853 uint16_t syms[1024];
2858 for (i = 0; i < count; i++) {
2859 codes[i] = index >> (32 - len[i]);
2862 index += 1ULL << (32 - len[i]);
2866 return ff_init_vlc_sparse(vlc, 16, count,
2867 bits, sizeof(*bits), sizeof(*bits),
2868 codes, sizeof(*codes), sizeof(*codes),
2869 syms, sizeof(*syms), sizeof(*syms), 0);
2872 static int decode_frame(AVCodecContext *avctx,
2873 void *data, int *got_frame,
2876 SheerVideoContext *s = avctx->priv_data;
2877 ThreadFrame frame = { .f = data };
2883 if (avpkt->size <= 20)
2884 return AVERROR_INVALIDDATA;
2886 if (AV_RL32(avpkt->data) != MKTAG('S','h','i','r') &&
2887 AV_RL32(avpkt->data) != MKTAG('Z','w','a','k'))
2888 return AVERROR_INVALIDDATA;
2890 format = AV_RL32(avpkt->data + 16);
2892 case MKTAG(' ', 'R', 'G', 'B'):
2893 avctx->pix_fmt = AV_PIX_FMT_RGB0;
2894 s->decode_frame = decode_rgb;
2895 if (s->format != format) {
2896 ret = build_vlc(&s->vlc[0], l_r_rgb, 256);
2897 ret |= build_vlc(&s->vlc[1], l_g_rgb, 256);
2900 case MKTAG(' ', 'r', 'G', 'B'):
2901 avctx->pix_fmt = AV_PIX_FMT_RGB0;
2902 s->decode_frame = decode_rgbi;
2903 if (s->format != format) {
2904 ret = build_vlc(&s->vlc[0], l_r_rgbi, 256);
2905 ret |= build_vlc(&s->vlc[1], l_g_rgbi, 256);
2908 case MKTAG('A', 'R', 'G', 'X'):
2909 avctx->pix_fmt = AV_PIX_FMT_GBRAP10;
2910 s->decode_frame = decode_argx;
2911 if (s->format != format) {
2912 ret = build_vlc(&s->vlc[0], l_r_rgbx, 1024);
2913 ret |= build_vlc(&s->vlc[1], l_g_rgbx, 1024);
2916 case MKTAG('A', 'r', 'G', 'X'):
2917 avctx->pix_fmt = AV_PIX_FMT_GBRAP10;
2918 s->decode_frame = decode_argxi;
2919 if (s->format != format) {
2920 ret = build_vlc(&s->vlc[0], l_r_rgbxi, 1024);
2921 ret |= build_vlc(&s->vlc[1], l_g_rgbxi, 1024);
2924 case MKTAG('R', 'G', 'B', 'X'):
2925 avctx->pix_fmt = AV_PIX_FMT_GBRP10;
2926 s->decode_frame = decode_rgbx;
2927 if (s->format != format) {
2928 ret = build_vlc(&s->vlc[0], l_r_rgbx, 1024);
2929 ret |= build_vlc(&s->vlc[1], l_g_rgbx, 1024);
2932 case MKTAG('r', 'G', 'B', 'X'):
2933 avctx->pix_fmt = AV_PIX_FMT_GBRP10;
2934 s->decode_frame = decode_rgbxi;
2935 if (s->format != format) {
2936 ret = build_vlc(&s->vlc[0], l_r_rgbxi, 1024);
2937 ret |= build_vlc(&s->vlc[1], l_g_rgbxi, 1024);
2940 case MKTAG('A', 'R', 'G', 'B'):
2941 avctx->pix_fmt = AV_PIX_FMT_ARGB;
2942 s->decode_frame = decode_argb;
2943 if (s->format != format) {
2944 ret = build_vlc(&s->vlc[0], l_r_rgb, 256);
2945 ret |= build_vlc(&s->vlc[1], l_g_rgb, 256);
2948 case MKTAG('A', 'r', 'G', 'B'):
2949 avctx->pix_fmt = AV_PIX_FMT_ARGB;
2950 s->decode_frame = decode_argbi;
2951 if (s->format != format) {
2952 ret = build_vlc(&s->vlc[0], l_r_rgbi, 256);
2953 ret |= build_vlc(&s->vlc[1], l_g_rgbi, 256);
2956 case MKTAG('A', 'Y', 'B', 'R'):
2957 case MKTAG('A', 'Y', 'b', 'R'):
2958 avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
2959 s->decode_frame = decode_aybr;
2960 if (s->format != format) {
2961 ret = build_vlc(&s->vlc[0], l_y_ybr, 256);
2962 ret |= build_vlc(&s->vlc[1], l_u_ybr, 256);
2965 case MKTAG('A', 'y', 'B', 'R'):
2966 case MKTAG('A', 'y', 'b', 'R'):
2967 avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
2968 s->decode_frame = decode_aybri;
2969 if (s->format != format) {
2970 ret = build_vlc(&s->vlc[0], l_y_ybri, 256);
2971 ret |= build_vlc(&s->vlc[1], l_u_ybri, 256);
2974 case MKTAG(' ', 'Y', 'B', 'R'):
2975 case MKTAG(' ', 'Y', 'b', 'R'):
2976 avctx->pix_fmt = AV_PIX_FMT_YUV444P;
2977 s->decode_frame = decode_ybr;
2978 if (s->format != format) {
2979 ret = build_vlc(&s->vlc[0], l_y_ybr, 256);
2980 ret |= build_vlc(&s->vlc[1], l_u_ybr, 256);
2983 case MKTAG(' ', 'y', 'B', 'R'):
2984 case MKTAG(' ', 'y', 'b', 'R'):
2985 avctx->pix_fmt = AV_PIX_FMT_YUV444P;
2986 s->decode_frame = decode_ybri;
2987 if (s->format != format) {
2988 ret = build_vlc(&s->vlc[0], l_y_ybri, 256);
2989 ret |= build_vlc(&s->vlc[1], l_u_ybri, 256);
2992 case MKTAG('Y', 'B', 'R', 0x0a):
2993 avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
2994 s->decode_frame = decode_ybr10;
2995 if (s->format != format) {
2996 ret = build_vlc(&s->vlc[0], l_y_ybr10, 1024);
2997 ret |= build_vlc(&s->vlc[1], l_u_ybr10, 1024);
3000 case MKTAG('y', 'B', 'R', 0x0a):
3001 avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
3002 s->decode_frame = decode_ybr10i;
3003 if (s->format != format) {
3004 ret = build_vlc(&s->vlc[0], l_y_ybr10i, 1024);
3005 ret |= build_vlc(&s->vlc[1], l_u_ybr10i, 1024);
3008 case MKTAG('C', 'A', '4', 'p'):
3009 avctx->pix_fmt = AV_PIX_FMT_YUVA444P10;
3010 s->decode_frame = decode_ca4p;
3011 if (s->format != format) {
3012 ret = build_vlc(&s->vlc[0], l_y_ybr10, 1024);
3013 ret |= build_vlc(&s->vlc[1], l_u_ybr10, 1024);
3016 case MKTAG('C', 'A', '4', 'i'):
3017 avctx->pix_fmt = AV_PIX_FMT_YUVA444P10;
3018 s->decode_frame = decode_ca4i;
3019 if (s->format != format) {
3020 ret = build_vlc(&s->vlc[0], l_y_ybr10i, 1024);
3021 ret |= build_vlc(&s->vlc[1], l_u_ybr10i, 1024);
3024 case MKTAG('B', 'Y', 'R', 'Y'):
3025 avctx->pix_fmt = AV_PIX_FMT_YUV422P;
3026 s->decode_frame = decode_byry;
3027 if (s->format != format) {
3028 ret = build_vlc(&s->vlc[0], l_y_byry, 256);
3029 ret |= build_vlc(&s->vlc[1], l_u_byry, 256);
3032 case MKTAG('B', 'Y', 'R', 'y'):
3033 avctx->pix_fmt = AV_PIX_FMT_YUV422P;
3034 s->decode_frame = decode_byryi;
3035 if (s->format != format) {
3036 ret = build_vlc(&s->vlc[0], l_y_byryi, 256);
3037 ret |= build_vlc(&s->vlc[1], l_u_byryi, 256);
3040 case MKTAG('Y', 'b', 'Y', 'r'):
3041 avctx->pix_fmt = AV_PIX_FMT_YUV422P;
3042 s->decode_frame = decode_ybyr;
3043 if (s->format != format) {
3044 ret = build_vlc(&s->vlc[0], l_y_ybyr, 256);
3045 ret |= build_vlc(&s->vlc[1], l_u_ybyr, 256);
3048 case MKTAG('C', '8', '2', 'p'):
3049 avctx->pix_fmt = AV_PIX_FMT_YUVA422P;
3050 s->decode_frame = decode_c82p;
3051 if (s->format != format) {
3052 ret = build_vlc(&s->vlc[0], l_y_byry, 256);
3053 ret |= build_vlc(&s->vlc[1], l_u_byry, 256);
3056 case MKTAG('C', '8', '2', 'i'):
3057 avctx->pix_fmt = AV_PIX_FMT_YUVA422P;
3058 s->decode_frame = decode_c82i;
3059 if (s->format != format) {
3060 ret = build_vlc(&s->vlc[0], l_y_byryi, 256);
3061 ret |= build_vlc(&s->vlc[1], l_u_byryi, 256);
3064 case MKTAG(0xa2, 'Y', 'R', 'Y'):
3065 avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
3066 s->decode_frame = decode_yry10;
3067 if (s->format != format) {
3068 ret = build_vlc(&s->vlc[0], l_y_yry10, 1024);
3069 ret |= build_vlc(&s->vlc[1], l_u_yry10, 1024);
3072 case MKTAG(0xa2, 'Y', 'R', 'y'):
3073 avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
3074 s->decode_frame = decode_yry10i;
3075 if (s->format != format) {
3076 ret = build_vlc(&s->vlc[0], l_y_yry10i, 1024);
3077 ret |= build_vlc(&s->vlc[1], l_u_yry10i, 1024);
3080 case MKTAG('C', 'A', '2', 'p'):
3081 avctx->pix_fmt = AV_PIX_FMT_YUVA422P10;
3082 s->decode_frame = decode_ca2p;
3083 if (s->format != format) {
3084 ret = build_vlc(&s->vlc[0], l_y_yry10, 1024);
3085 ret |= build_vlc(&s->vlc[1], l_u_yry10, 1024);
3088 case MKTAG('C', 'A', '2', 'i'):
3089 avctx->pix_fmt = AV_PIX_FMT_YUVA422P10;
3090 s->decode_frame = decode_ca2i;
3091 if (s->format != format) {
3092 ret = build_vlc(&s->vlc[0], l_y_yry10i, 1024);
3093 ret |= build_vlc(&s->vlc[1], l_u_yry10i, 1024);
3097 avpriv_request_sample(avctx, "unsupported format: 0x%X", format);
3098 return AVERROR_PATCHWELCOME;
3101 if (s->format != format) {
3107 p->pict_type = AV_PICTURE_TYPE_I;
3110 if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
3113 if ((ret = init_get_bits8(&gb, avpkt->data + 20, avpkt->size - 20)) < 0)
3116 s->decode_frame(avctx, p, &gb);
3124 static int decode_init_thread_copy(AVCodecContext *avctx)
3126 SheerVideoContext *s = avctx->priv_data;
3129 memset(&s->vlc[0], 0, sizeof(s->vlc[0]));
3130 memset(&s->vlc[1], 0, sizeof(s->vlc[1]));
3136 static av_cold int decode_end(AVCodecContext *avctx)
3138 SheerVideoContext *s = avctx->priv_data;
3140 ff_free_vlc(&s->vlc[0]);
3141 ff_free_vlc(&s->vlc[1]);
3146 AVCodec ff_sheervideo_decoder = {
3147 .name = "sheervideo",
3148 .long_name = NULL_IF_CONFIG_SMALL("BitJazz SheerVideo"),
3149 .type = AVMEDIA_TYPE_VIDEO,
3150 .id = AV_CODEC_ID_SHEERVIDEO,
3151 .priv_data_size = sizeof(SheerVideoContext),
3152 .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
3153 .close = decode_end,
3154 .decode = decode_frame,
3155 .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,