You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

675 lines
19KB

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