65 Node *nodes,
int node,
66 uint32_t pfx,
int pl,
int *pos)
72 bits[*pos] = (~pfx) & ((1ULL <<
FFMAX(pl, 1)) - 1);
73 lens[*pos] =
FFMAX(pl, 1);
74 xlat[*pos] = s + (pl == 0);
93 int cur_node, i, j, pos = 0;
97 for (i = 0; i < 256; i++) {
98 nodes[i].
count = table[i];
110 int first_node = cur_node;
111 int second_node = cur_node;
114 nodes[cur_node].
count = -1;
118 if (val && (val < nodes[first_node].
count)) {
119 if (val >= nodes[second_node].count) {
120 first_node = new_node;
122 first_node = second_node;
123 second_node = new_node;
127 }
while (new_node != cur_node);
129 if (first_node == cur_node)
132 nd = nodes[second_node].
count;
133 st = nodes[first_node].
count;
134 nodes[second_node].
count = 0;
135 nodes[first_node].
count = 0;
136 if (nd >= UINT32_MAX - st) {
140 nodes[cur_node].
count = nd + st;
141 nodes[cur_node].
sym = -1;
142 nodes[cur_node].
n0 = cur_node;
143 nodes[cur_node].
l = first_node;
144 nodes[cur_node].
r = second_node;
148 }
while (cur_node - 256 == j);
150 get_tree_codes(bits, lens, xlat, nodes, cur_node - 1, 0, 0, &pos);
152 return ff_init_vlc_sparse(vlc, 10, pos, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0);
156 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
157 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
158 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
159 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
160 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
161 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF,
162 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
163 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
164 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
165 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
166 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
167 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
168 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
169 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
170 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
173 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
174 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
175 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
176 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
177 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
178 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
179 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
180 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
181 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
182 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
183 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
188 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
189 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
191 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
192 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
193 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0xFF,
194 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
195 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,
198 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
199 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
200 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
201 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
203 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
204 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF,
205 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
206 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
209 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
210 0x01, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF,
211 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
212 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
214 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
215 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
220 0xFC, 0xFC, 0xFC, 0xFD, 0xFD, 0xFD, 0xFE, 0xFE,
221 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFC,
222 0xFC, 0xFC, 0xFD, 0xFD, 0xFD, 0xFE, 0xFE, 0xFE,
223 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFC, 0xFC,
224 0xFC, 0xFD, 0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF,
225 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFD, 0xFD, 0xFD,
226 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
227 0x00, 0x01, 0x01, 0x01, 0xFD, 0xFD, 0xFD, 0xFE,
228 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
229 0x01, 0x01, 0x01, 0xFD, 0xFD, 0xFD, 0xFE, 0xFE,
230 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01,
231 0x01, 0x01, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF,
232 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02,
233 0x02, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x00,
234 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02,
235 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
236 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0xFF,
237 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
238 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0xFF, 0xFF,
239 0xFF, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02,
240 0x02, 0x02, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0xFF,
241 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02,
242 0x02, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x01,
243 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03,
244 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01,
245 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04,
246 0x04, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
247 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04,
252 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00,
253 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF,
254 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01,
255 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00,
256 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF,
257 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01,
258 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00,
259 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF,
260 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01,
261 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00,
262 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF,
263 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01,
264 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00,
265 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF,
266 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01,
267 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00,
268 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF,
269 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01,
270 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00,
271 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF,
272 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01,
273 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00,
274 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF,
275 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01,
276 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00,
277 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF,
278 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01,
279 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00,
284 void *
data,
int *got_frame,
287 int TL[4] = { 128, 128, 128, 128 };
288 int L[4] = { 128, 128, 128, 128 };
292 int ret, x, y, toffset, boffset;
297 if (avpkt->
size <= 16)
305 if (toffset < 16 || toffset >= avpkt->
size)
309 if (toffset >= boffset || boffset >= avpkt->
size)
324 (boffset - toffset + 3) >> 2);
328 for (x = 0; x < 1024; x++) {
357 (avpkt->
size - boffset) >> 2);
362 for (y = 0; y < avctx->
height; y++) {
363 memset(dst, 0, avctx->
width * 2);
368 for (y = 0; y < avctx->
height; y++) {
369 for (x = 0; x < avctx->
width * 2 && y < avctx->
height;) {
377 }
else if (val < 0xE1) {
384 int incr = (val - 0xDF) * 4;
385 if (x + incr >= avctx->
width * 2) {
386 int iy = ((x + incr) / (avctx->
width * 2));
387 x = (x + incr) % (avctx->
width * 2);
401 if (y1 < 0 || y2 < 0 || u < 0 || v < 0)
405 dst[x + 2] = y1 + y2;
414 for (x = 0; x < avctx->
width * 2; x += 4) {
415 dst[x ] = dst[x ] + L[0];
416 dst[x + 2] = L[0] = dst[x + 2] + L[0];
417 L[1] = dst[x + 1] + L[1];
419 L[2] = dst[x + 3] + L[2];
424 for (y = 1; y < avctx->
height; y++) {
426 dst[x ] = dst[x ] + L[0] + dst[x + 0 - p->
linesize[0]] - TL[0];
427 dst[x + 2] = L[0] = dst[x + 2] + L[0] + dst[x + 2 - p->
linesize[0]] - TL[0];
428 TL[0] = dst[x + 2 - p->
linesize[0]];
429 L[1] = dst[x + 1] + L[1] + dst[x + 1 - p->
linesize[0]] - TL[1];
431 TL[1] = dst[x + 1 - p->
linesize[0]];
432 L[2] = dst[x + 3] + L[2] + dst[x + 3 - p->
linesize[0]] - TL[2];
434 TL[2] = dst[x + 3 - p->
linesize[0]];
435 for (x = 4; x < avctx->
width * 2; x += 4) {
436 dst[x ] = dst[x ] + L[0] + dst[x + 0 - p->
linesize[0]] - TL[0];
437 dst[x + 2] = L[0] = dst[x + 2] + L[0] + dst[x + 2 - p->
linesize[0]] - TL[0];
438 TL[0] = dst[x + 2 - p->
linesize[0]];
439 L[1] = dst[x + 1] + L[1] + dst[x + 1 - p->
linesize[0]] - TL[1];
441 TL[1] = dst[x + 1 - p->
linesize[0]];
442 L[2] = dst[x + 3] + L[2] + dst[x + 3 - p->
linesize[0]] - TL[2];
444 TL[2] = dst[x + 3 - p->
linesize[0]];
461 memset(&s->
vlc[0], 0,
sizeof(
VLC));
462 memset(&s->
vlc[1], 0,
sizeof(
VLC));
463 memset(&s->
vlc[2], 0,
sizeof(
VLC));
464 memset(&s->
vlc[3], 0,
sizeof(
VLC));
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static av_cold int decode_init(AVCodecContext *avctx)
ptrdiff_t const GLvoid * data
static const uint8_t table_y1[]
static int init_thread_copy(AVCodecContext *avctx)
Memory handling functions.
static const uint8_t table_y2[]
static av_cold int init(AVCodecContext *avctx)
int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static const uint8_t table_u[]
static const uint8_t table_v[]
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Multithreading support functions.
#define u(width, name, range_min, range_max)
static av_cold int decode_end(AVCodecContext *avctx)
bitstream reader API header.
static const uint16_t table[]
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * name
Name of the codec implementation.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat, Node *nodes, int node, uint32_t pfx, int pl, int *pos)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
common internal API header
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
static unsigned int get_bits1(GetBitContext *s)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
#define MKTAG(a, b, c, d)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
static int build_vlc(AVCodecContext *avctx, VLC *vlc, const uint32_t *table)
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.