]> git.sesse.net Git - ffmpeg/blob - libavcodec/pixlet.c
Merge commit '4fb311c804098d78e5ce5f527f9a9c37536d3a08'
[ffmpeg] / libavcodec / pixlet.c
1 /*
2  * Apple Pixlet decoder
3  * Copyright (c) 2016 Paul B Mahol
4  *
5  * This file is part of FFmpeg.
6  *
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.
11  *
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.
16  *
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
20  */
21
22 #include <stdint.h>
23
24 #include "libavutil/imgutils.h"
25 #include "libavutil/intmath.h"
26 #include "libavutil/opt.h"
27
28 #include "avcodec.h"
29 #include "bytestream.h"
30 #include "get_bits.h"
31 #include "unary.h"
32 #include "internal.h"
33 #include "thread.h"
34
35 #define NB_LEVELS 4
36
37 #define H 0
38 #define V 1
39
40 typedef struct SubBand {
41     unsigned width, height;
42     unsigned size;
43     unsigned x, y;
44 } SubBand;
45
46 typedef struct PixletContext {
47     AVClass *class;
48
49     GetByteContext gb;
50     GetBitContext gbit;
51
52     int levels;
53     int depth;
54     int h, w;
55
56     int16_t *filter[2];
57     int16_t *prediction;
58     int64_t scaling[4][2][NB_LEVELS];
59     SubBand band[4][NB_LEVELS * 3 + 1];
60 } PixletContext;
61
62 static int init_decoder(AVCodecContext *avctx)
63 {
64     PixletContext *ctx = avctx->priv_data;
65     int i, plane;
66
67     ctx->filter[0]  = av_malloc_array(ctx->h, sizeof(int16_t));
68     ctx->filter[1]  = av_malloc_array(FFMAX(ctx->h, ctx->w) + 16, sizeof(int16_t));
69     ctx->prediction = av_malloc_array((ctx->w >> NB_LEVELS), sizeof(int16_t));
70     if (!ctx->filter[0] || !ctx->filter[1] || !ctx->prediction)
71         return AVERROR(ENOMEM);
72
73     for (plane = 0; plane < 3; plane++) {
74         unsigned shift = plane > 0;
75         unsigned w = ctx->w >> shift;
76         unsigned h = ctx->h >> shift;
77
78         ctx->band[plane][0].width  = w >> NB_LEVELS;
79         ctx->band[plane][0].height = h >> NB_LEVELS;
80         ctx->band[plane][0].size = (w >> NB_LEVELS) * (h >> NB_LEVELS);
81
82         for (i = 0; i < NB_LEVELS * 3; i++) {
83             unsigned scale = ctx->levels - (i / 3);
84
85             ctx->band[plane][i + 1].width  = w >> scale;
86             ctx->band[plane][i + 1].height = h >> scale;
87             ctx->band[plane][i + 1].size = (w >> scale) * (h >> scale);
88
89             ctx->band[plane][i + 1].x = (w >> scale) * (((i + 1) % 3) != 2);
90             ctx->band[plane][i + 1].y = (h >> scale) * (((i + 1) % 3) != 1);
91         }
92     }
93
94     return 0;
95 }
96
97 static void free_buffers(AVCodecContext *avctx)
98 {
99     PixletContext *ctx = avctx->priv_data;
100
101     av_freep(&ctx->filter[0]);
102     av_freep(&ctx->filter[1]);
103     av_freep(&ctx->prediction);
104 }
105
106 static av_cold int pixlet_close(AVCodecContext *avctx)
107 {
108     PixletContext *ctx = avctx->priv_data;
109     free_buffers(avctx);
110     ctx->w = 0;
111     ctx->h = 0;
112     return 0;
113 }
114
115 static av_cold int pixlet_init(AVCodecContext *avctx)
116 {
117     avctx->pix_fmt = AV_PIX_FMT_YUV420P16;
118     avctx->color_range = AVCOL_RANGE_JPEG;
119     return 0;
120 }
121
122 static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size, int width, ptrdiff_t stride)
123 {
124     PixletContext *ctx = avctx->priv_data;
125     GetBitContext *b = &ctx->gbit;
126     unsigned cnt1, nbits, k, j = 0, i = 0;
127     int64_t value, state = 3;
128     int rlen, escape, flag = 0;
129
130     while (i < size) {
131         nbits = FFMIN(ff_clz((state >> 8) + 3) ^ 0x1F, 14);
132
133         cnt1 = get_unary(b, 0, 8);
134         if (cnt1 < 8) {
135             value = show_bits(b, nbits);
136             if (value <= 1) {
137                 skip_bits(b, nbits - 1);
138                 escape = ((1 << nbits) - 1) * cnt1;
139             } else {
140                 skip_bits(b, nbits);
141                 escape = value + ((1 << nbits) - 1) * cnt1 - 1;
142             }
143         } else {
144             escape = get_bits(b, 16);
145         }
146
147         value = -((escape + flag) & 1) | 1;
148         dst[j++] = value * ((escape + flag + 1) >> 1);
149         i++;
150         if (j == width) {
151             j = 0;
152             dst += stride;
153         }
154         state = 120 * (escape + flag) + state - (120 * state >> 8);
155         flag = 0;
156
157         if (state * 4 > 0xFF || i >= size)
158             continue;
159
160         nbits = ((state + 8) >> 5) + (state ? ff_clz(state) : 32) - 24;
161         escape = av_mod_uintp2(16383, nbits);
162         cnt1 = get_unary(b, 0, 8);
163         if (cnt1 > 7) {
164             rlen = get_bits(b, 16);
165         } else {
166             value = show_bits(b, nbits);
167             if (value > 1) {
168                 skip_bits(b, nbits);
169                 rlen = value + escape * cnt1 - 1;
170             } else {
171                 skip_bits(b, nbits - 1);
172                 rlen = escape * cnt1;
173             }
174         }
175
176         if (i + rlen > size)
177             return AVERROR_INVALIDDATA;
178         i += rlen;
179
180         for (k = 0; k < rlen; k++) {
181             dst[j++] = 0;
182             if (j == width) {
183                 j = 0;
184                 dst += stride;
185             }
186         }
187
188         state = 0;
189         flag = rlen < 0xFFFF ? 1 : 0;
190     }
191
192     align_get_bits(b);
193     return get_bits_count(b) >> 3;
194 }
195
196 static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst, int size,
197                             int c, int a, int d,
198                             int width, ptrdiff_t stride)
199 {
200     PixletContext *ctx = avctx->priv_data;
201     GetBitContext *b = &ctx->gbit;
202     unsigned cnt1, shbits, rlen, nbits, length, i = 0, j = 0, k;
203     int ret, escape, pfx, value, yflag, xflag, flag = 0;
204     int64_t state = 3, tmp;
205
206     if ((ret = init_get_bits8(b, src, bytestream2_get_bytes_left(&ctx->gb))) < 0)
207       return ret;
208
209     if ((a >= 0) + (a ^ (a >> 31)) - (a >> 31) != 1) {
210         nbits = 33 - ff_clz((a >= 0) + (a ^ (a >> 31)) - (a >> 31) - 1);
211         if (nbits > 16)
212             return AVERROR_INVALIDDATA;
213     } else {
214         nbits = 1;
215     }
216
217     length = 25 - nbits;
218
219     while (i < size) {
220         if (state >> 8 != -3) {
221             value = ff_clz((state >> 8) + 3) ^ 0x1F;
222         } else {
223             value = -1;
224         }
225
226         cnt1 = get_unary(b, 0, length);
227
228         if (cnt1 >= length) {
229             cnt1 = get_bits(b, nbits);
230         } else {
231             pfx = 14 + ((((uint64_t)(value - 14)) >> 32) & (value - 14));
232             cnt1 *= (1 << pfx) - 1;
233             shbits = show_bits(b, pfx);
234             if (shbits <= 1) {
235                 skip_bits(b, pfx - 1);
236             } else {
237                 skip_bits(b, pfx);
238                 cnt1 += shbits - 1;
239             }
240         }
241
242         xflag = flag + cnt1;
243         yflag = xflag;
244
245         if (flag + cnt1 == 0) {
246             value = 0;
247         } else {
248             xflag &= 1u;
249             tmp = (int64_t)c * ((yflag + 1) >> 1) + (c >> 1);
250             value = xflag + (tmp ^ -xflag);
251         }
252
253         i++;
254         dst[j++] = value;
255         if (j == width) {
256             j = 0;
257             dst += stride;
258         }
259         state += (int64_t)d * yflag - (d * state >> 8);
260
261         flag = 0;
262
263         if (state * 4 > 0xFF || i >= size)
264             continue;
265
266         pfx = ((state + 8) >> 5) + (state ? ff_clz(state): 32) - 24;
267         escape = av_mod_uintp2(16383, pfx);
268         cnt1 = get_unary(b, 0, 8);
269         if (cnt1 < 8) {
270             if (pfx < 1 || pfx > 25)
271                 return AVERROR_INVALIDDATA;
272             value = show_bits(b, pfx);
273             if (value > 1) {
274                 skip_bits(b, pfx);
275                 rlen = value + escape * cnt1 - 1;
276             } else {
277                 skip_bits(b, pfx - 1);
278                 rlen = escape * cnt1;
279             }
280         } else {
281             if (get_bits1(b))
282                 value = get_bits(b, 16);
283             else
284                 value = get_bits(b, 8);
285
286             rlen = value + 8 * escape;
287         }
288
289         if (rlen > 0xFFFF || i + rlen > size)
290             return AVERROR_INVALIDDATA;
291         i += rlen;
292
293         for (k = 0; k < rlen; k++) {
294             dst[j++] = 0;
295             if (j == width) {
296                 j = 0;
297                 dst += stride;
298             }
299         }
300
301         state = 0;
302         flag = rlen < 0xFFFF ? 1 : 0;
303     }
304
305     align_get_bits(b);
306     return get_bits_count(b) >> 3;
307 }
308
309 static int read_highpass(AVCodecContext *avctx, uint8_t *ptr, int plane, AVFrame *frame)
310 {
311     PixletContext *ctx = avctx->priv_data;
312     ptrdiff_t stride = frame->linesize[plane] / 2;
313     int i, ret;
314
315     for (i = 0; i < ctx->levels * 3; i++) {
316         int32_t a = bytestream2_get_be32(&ctx->gb);
317         int32_t b = bytestream2_get_be32(&ctx->gb);
318         int32_t c = bytestream2_get_be32(&ctx->gb);
319         int32_t d = bytestream2_get_be32(&ctx->gb);
320         int16_t *dest = (int16_t *)frame->data[plane] + ctx->band[plane][i + 1].x +
321                                                stride * ctx->band[plane][i + 1].y;
322         unsigned size = ctx->band[plane][i + 1].size;
323         uint32_t magic;
324
325         magic = bytestream2_get_be32(&ctx->gb);
326         if (magic != 0xDEADBEEF) {
327             av_log(avctx, AV_LOG_ERROR, "wrong magic number: 0x%08X for plane %d, band %d\n", magic, plane, i);
328             return AVERROR_INVALIDDATA;
329         }
330
331         ret = read_high_coeffs(avctx, ptr + bytestream2_tell(&ctx->gb), dest, size,
332                                c, (b >= FFABS(a)) ? b : a, d,
333                                ctx->band[plane][i + 1].width, stride);
334         if (ret < 0) {
335             av_log(avctx, AV_LOG_ERROR, "error in highpass coefficients for plane %d, band %d\n", plane, i);
336             return ret;
337         }
338         bytestream2_skip(&ctx->gb, ret);
339     }
340
341     return 0;
342 }
343
344 static void lowpass_prediction(int16_t *dst, int16_t *pred, int width, int height, ptrdiff_t stride)
345 {
346     int16_t val;
347     int i, j;
348
349     memset(pred, 0, width * sizeof(*pred));
350
351     for (i = 0; i < height; i++) {
352         val    = pred[0] + dst[0];
353         dst[0] = pred[0] = val;
354         for (j = 1; j < width; j++) {
355             val     = pred[j] + dst[j];
356             dst[j]  = pred[j] = val;
357             dst[j] += dst[j-1];
358         }
359         dst += stride;
360     }
361 }
362
363 static void filterfn(int16_t *dest, int16_t *tmp, unsigned size, int64_t scale)
364 {
365     int16_t *low, *high, *ll, *lh, *hl, *hh;
366     int hsize, i, j;
367     int64_t value;
368
369     hsize = size >> 1;
370     low = tmp + 4;
371     high = &low[hsize + 8];
372
373     memcpy(low, dest, size);
374     memcpy(high, dest + hsize, size);
375
376     ll = &low[hsize];
377     lh = &low[hsize];
378     hl = &high[hsize];
379     hh = hl;
380     for (i = 4, j = 2; i; i--, j++, ll--, hh++, lh++, hl--) {
381         low[i - 5]  = low[j - 1];
382         lh[0]       = ll[-1];
383         high[i - 5] = high[j - 2];
384         hh[0]       = hl[-2];
385     }
386
387     for (i = 0; i < hsize; i++) {
388         value = (int64_t) low [i + 1] * -INT64_C(325392907)  +
389                 (int64_t) low [i + 0] *  INT64_C(3687786320) +
390                 (int64_t) low [i - 1] * -INT64_C(325392907)  +
391                 (int64_t) high[i + 0] *  INT64_C(1518500249) +
392                 (int64_t) high[i - 1] *  INT64_C(1518500249);
393         dest[i * 2] = av_clip_int16(((value >> 32) * scale) >> 32);
394     }
395
396     for (i = 0; i < hsize; i++) {
397         value = (int64_t) low [i + 2] * -INT64_C(65078576)   +
398                 (int64_t) low [i + 1] *  INT64_C(1583578880) +
399                 (int64_t) low [i + 0] *  INT64_C(1583578880) +
400                 (int64_t) low [i - 1] * -INT64_C(65078576)   +
401                 (int64_t) high[i + 1] *  INT64_C(303700064)  +
402                 (int64_t) high[i + 0] * -INT64_C(3644400640) +
403                 (int64_t) high[i - 1] *  INT64_C(303700064);
404         dest[i * 2 + 1] = av_clip_int16(((value >> 32) * scale) >> 32);
405     }
406 }
407
408 static void reconstruction(AVCodecContext *avctx,
409                            int16_t *dest, unsigned width, unsigned height, ptrdiff_t stride, int nb_levels,
410                            int64_t *scaling_H, int64_t *scaling_V)
411 {
412     PixletContext *ctx = avctx->priv_data;
413     unsigned scaled_width, scaled_height;
414     int64_t scale_H, scale_V;
415     int16_t *ptr, *tmp;
416     int i, j, k;
417
418     scaled_height = height >> nb_levels;
419     scaled_width  = width  >> nb_levels;
420     tmp = ctx->filter[0];
421
422     for (i = 0; i < nb_levels; i++) {
423         scaled_width  <<= 1;
424         scaled_height <<= 1;
425         scale_H = scaling_H[i];
426         scale_V = scaling_V[i];
427
428         ptr = dest;
429         for (j = 0; j < scaled_height; j++) {
430             filterfn(ptr, ctx->filter[1], scaled_width, scale_V);
431             ptr += stride;
432         }
433
434         for (j = 0; j < scaled_width; j++) {
435             ptr = dest + j;
436             for (k = 0; k < scaled_height; k++) {
437                 tmp[k] = *ptr;
438                 ptr += stride;
439             }
440
441             filterfn(tmp, ctx->filter[1], scaled_height, scale_H);
442
443             ptr = dest + j;
444             for (k = 0; k < scaled_height; k++) {
445                 *ptr = tmp[k];
446                 ptr += stride;
447             }
448         }
449     }
450 }
451
452 static void postprocess_luma(AVFrame *frame, int w, int h, int depth)
453 {
454     uint16_t *dsty = (uint16_t *)frame->data[0];
455     int16_t *srcy  = (int16_t *)frame->data[0];
456     ptrdiff_t stridey = frame->linesize[0] / 2;
457     int i, j;
458
459     for (j = 0; j < h; j++) {
460         for (i = 0; i < w; i++) {
461             if (srcy[i] <= 0)
462                 dsty[i] = 0;
463             else if (srcy[i] > ((1 << depth) - 1))
464                 dsty[i] = 65535;
465             else
466                 dsty[i] = ((int64_t) srcy[i] * srcy[i] * 65535) /
467                           ((1 << depth) - 1) / ((1 << depth) - 1);
468         }
469         dsty += stridey;
470         srcy += stridey;
471     }
472 }
473
474 static void postprocess_chroma(AVFrame *frame, int w, int h, int depth)
475 {
476     uint16_t *dstu = (uint16_t *)frame->data[1];
477     uint16_t *dstv = (uint16_t *)frame->data[2];
478     int16_t *srcu  = (int16_t *)frame->data[1];
479     int16_t *srcv  = (int16_t *)frame->data[2];
480     ptrdiff_t strideu = frame->linesize[1] / 2;
481     ptrdiff_t stridev = frame->linesize[2] / 2;
482     const unsigned add = 1 << (depth - 1);
483     const unsigned shift = 16 - depth;
484     int i, j;
485
486     for (j = 0; j < h; j++) {
487         for (i = 0; i < w; i++) {
488             dstu[i] = av_clip_uintp2_c(add + srcu[i], depth) << shift;
489             dstv[i] = av_clip_uintp2_c(add + srcv[i], depth) << shift;
490         }
491         dstu += strideu;
492         dstv += stridev;
493         srcu += strideu;
494         srcv += stridev;
495     }
496 }
497
498 static int decode_plane(AVCodecContext *avctx, int plane, AVPacket *avpkt, AVFrame *frame)
499 {
500     PixletContext *ctx = avctx->priv_data;
501     ptrdiff_t stride = frame->linesize[plane] / 2;
502     unsigned shift = plane > 0;
503     int16_t *dst;
504     int i, ret;
505
506     for (i = ctx->levels - 1; i >= 0; i--) {
507         int32_t h = sign_extend(bytestream2_get_be32(&ctx->gb), 32);
508         int32_t v = sign_extend(bytestream2_get_be32(&ctx->gb), 32);
509
510         if (!h || !v)
511             return AVERROR_INVALIDDATA;
512
513         ctx->scaling[plane][H][i] = (1000000ULL << 32) / h;
514         ctx->scaling[plane][V][i] = (1000000ULL << 32) / v;
515     }
516
517     bytestream2_skip(&ctx->gb, 4);
518
519     dst = (int16_t *)frame->data[plane];
520     dst[0] = sign_extend(bytestream2_get_be16(&ctx->gb), 16);
521
522     if ((ret = init_get_bits8(&ctx->gbit, avpkt->data + bytestream2_tell(&ctx->gb),
523                               bytestream2_get_bytes_left(&ctx->gb))) < 0)
524         return ret;
525
526     ret = read_low_coeffs(avctx, dst + 1, ctx->band[plane][0].width - 1, ctx->band[plane][0].width - 1, 0);
527     if (ret < 0) {
528         av_log(avctx, AV_LOG_ERROR, "error in lowpass coefficients for plane %d, top row\n", plane);
529         return ret;
530     }
531
532     ret = read_low_coeffs(avctx, dst + stride, ctx->band[plane][0].height - 1, 1, stride);
533     if (ret < 0) {
534         av_log(avctx, AV_LOG_ERROR, "error in lowpass coefficients for plane %d, left column\n", plane);
535         return ret;
536     }
537
538     ret = read_low_coeffs(avctx, dst + stride + 1,
539                           (ctx->band[plane][0].width - 1) * (ctx->band[plane][0].height - 1),
540                           ctx->band[plane][0].width - 1, stride);
541     if (ret < 0) {
542         av_log(avctx, AV_LOG_ERROR, "error in lowpass coefficients for plane %d, rest\n", plane);
543         return ret;
544     }
545
546     bytestream2_skip(&ctx->gb, ret);
547     if (bytestream2_get_bytes_left(&ctx->gb) <= 0) {
548         av_log(avctx, AV_LOG_ERROR, "no bytes left\n");
549         return AVERROR_INVALIDDATA;
550     }
551
552     ret = read_highpass(avctx, avpkt->data, plane, frame);
553     if (ret < 0)
554         return ret;
555
556     lowpass_prediction(dst, ctx->prediction,
557                        ctx->band[plane][0].width, ctx->band[plane][0].height, stride);
558
559     reconstruction(avctx, (int16_t *)frame->data[plane], ctx->w >> shift, ctx->h >> shift,
560                    stride, NB_LEVELS, ctx->scaling[plane][H], ctx->scaling[plane][V]);
561
562     return 0;
563 }
564
565 static int pixlet_decode_frame(AVCodecContext *avctx, void *data,
566                                int *got_frame, AVPacket *avpkt)
567 {
568     PixletContext *ctx = avctx->priv_data;
569     int i, w, h, width, height, ret, version;
570     AVFrame *p = data;
571     ThreadFrame frame = { .f = data };
572     uint32_t pktsize;
573
574     bytestream2_init(&ctx->gb, avpkt->data, avpkt->size);
575
576     pktsize = bytestream2_get_be32(&ctx->gb);
577     if (pktsize <= 44 || pktsize - 4 > bytestream2_get_bytes_left(&ctx->gb)) {
578         av_log(avctx, AV_LOG_ERROR, "Invalid packet size %u.\n", pktsize);
579         return AVERROR_INVALIDDATA;
580     }
581
582     version = bytestream2_get_le32(&ctx->gb);
583     if (version != 1)
584         avpriv_request_sample(avctx, "Version %d", version);
585
586     bytestream2_skip(&ctx->gb, 4);
587     if (bytestream2_get_be32(&ctx->gb) != 1)
588         return AVERROR_INVALIDDATA;
589     bytestream2_skip(&ctx->gb, 4);
590
591     width  = bytestream2_get_be32(&ctx->gb);
592     height = bytestream2_get_be32(&ctx->gb);
593
594     w = FFALIGN(width,  1 << (NB_LEVELS + 1));
595     h = FFALIGN(height, 1 << (NB_LEVELS + 1));
596
597     ctx->levels = bytestream2_get_be32(&ctx->gb);
598     if (ctx->levels != NB_LEVELS)
599         return AVERROR_INVALIDDATA;
600     ctx->depth = bytestream2_get_be32(&ctx->gb);
601     if (ctx->depth < 8 || ctx->depth > 15) {
602         avpriv_request_sample(avctx, "Depth %d", ctx->depth);
603         return AVERROR_INVALIDDATA;
604     }
605
606     ret = ff_set_dimensions(avctx, w, h);
607     if (ret < 0)
608         return ret;
609     avctx->width  = width;
610     avctx->height = height;
611
612     if (ctx->w != w || ctx->h != h) {
613         free_buffers(avctx);
614         ctx->w = w;
615         ctx->h = h;
616
617         ret = init_decoder(avctx);
618         if (ret < 0) {
619             free_buffers(avctx);
620             ctx->w = 0;
621             ctx->h = 0;
622             return ret;
623         }
624     }
625
626     bytestream2_skip(&ctx->gb, 8);
627
628     p->pict_type = AV_PICTURE_TYPE_I;
629     p->key_frame = 1;
630     p->color_range = AVCOL_RANGE_JPEG;
631
632     ret = ff_thread_get_buffer(avctx, &frame, 0);
633     if (ret < 0)
634         return ret;
635
636     for (i = 0; i < 3; i++) {
637         ret = decode_plane(avctx, i, avpkt, frame.f);
638         if (ret < 0)
639             return ret;
640         if (avctx->flags & AV_CODEC_FLAG_GRAY)
641             break;
642     }
643
644     postprocess_luma(frame.f, ctx->w, ctx->h, ctx->depth);
645     postprocess_chroma(frame.f, ctx->w >> 1, ctx->h >> 1, ctx->depth);
646
647     *got_frame = 1;
648
649     return pktsize;
650 }
651
652 #if HAVE_THREADS
653 static int pixlet_init_thread_copy(AVCodecContext *avctx)
654 {
655     PixletContext *ctx = avctx->priv_data;
656
657     ctx->filter[0] = NULL;
658     ctx->filter[1] = NULL;
659     ctx->prediction = NULL;
660     ctx->w = ctx->h = 0;
661
662     return 0;
663 }
664 #endif
665
666 AVCodec ff_pixlet_decoder = {
667     .name             = "pixlet",
668     .long_name        = NULL_IF_CONFIG_SMALL("Apple Pixlet"),
669     .type             = AVMEDIA_TYPE_VIDEO,
670     .id               = AV_CODEC_ID_PIXLET,
671     .init             = pixlet_init,
672     .init_thread_copy = ONLY_IF_THREADS_ENABLED(pixlet_init_thread_copy),
673     .close            = pixlet_close,
674     .decode           = pixlet_decode_frame,
675     .priv_data_size   = sizeof(PixletContext),
676     .capabilities     = AV_CODEC_CAP_DR1 |
677                         AV_CODEC_CAP_FRAME_THREADS,
678     .caps_internal    = FF_CODEC_CAP_INIT_THREADSAFE |
679                         FF_CODEC_CAP_INIT_CLEANUP,
680 };