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.

673 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. value = show_bits(b, pfx);
  226. if (value > 1) {
  227. skip_bits(b, pfx);
  228. rlen = value + escape * cnt1 - 1;
  229. } else {
  230. skip_bits(b, pfx - 1);
  231. rlen = escape * cnt1;
  232. }
  233. } else {
  234. if (get_bits1(b))
  235. value = get_bits(b, 16);
  236. else
  237. value = get_bits(b, 8);
  238. rlen = value + 8 * escape;
  239. }
  240. if (rlen > 0xFFFF || i + rlen > size)
  241. return AVERROR_INVALIDDATA;
  242. i += rlen;
  243. for (k = 0; k < rlen; k++) {
  244. dst[j++] = 0;
  245. if (j == width) {
  246. j = 0;
  247. dst += stride;
  248. }
  249. }
  250. state = 0;
  251. flag = rlen < 0xFFFF ? 1 : 0;
  252. }
  253. align_get_bits(b);
  254. return get_bits_count(b) >> 3;
  255. }
  256. static int read_highpass(AVCodecContext *avctx, uint8_t *ptr, int plane, AVFrame *frame)
  257. {
  258. PixletContext *ctx = avctx->priv_data;
  259. ptrdiff_t stride = frame->linesize[plane] / 2;
  260. int i, ret;
  261. for (i = 0; i < ctx->levels * 3; i++) {
  262. int32_t a = bytestream2_get_be32(&ctx->gb);
  263. int32_t b = bytestream2_get_be32(&ctx->gb);
  264. int32_t c = bytestream2_get_be32(&ctx->gb);
  265. int32_t d = bytestream2_get_be32(&ctx->gb);
  266. int16_t *dest = (int16_t *)frame->data[plane] + ctx->band[plane][i + 1].x +
  267. stride * ctx->band[plane][i + 1].y;
  268. unsigned size = ctx->band[plane][i + 1].size;
  269. uint32_t magic;
  270. magic = bytestream2_get_be32(&ctx->gb);
  271. if (magic != 0xDEADBEEF) {
  272. av_log(avctx, AV_LOG_ERROR, "wrong magic number: 0x%08X for plane %d, band %d\n", magic, plane, i);
  273. return AVERROR_INVALIDDATA;
  274. }
  275. ret = read_high_coeffs(avctx, ptr + bytestream2_tell(&ctx->gb), dest, size,
  276. c, (b >= FFABS(a)) ? b : a, d,
  277. ctx->band[plane][i + 1].width, stride);
  278. if (ret < 0) {
  279. av_log(avctx, AV_LOG_ERROR, "error in highpass coefficients for plane %d, band %d\n", plane, i);
  280. return ret;
  281. }
  282. bytestream2_skip(&ctx->gb, ret);
  283. }
  284. return 0;
  285. }
  286. static void lowpass_prediction(int16_t *dst, int16_t *pred, int width, int height, ptrdiff_t stride)
  287. {
  288. int16_t *next, val;
  289. int i, j;
  290. memset(pred, 0, width * sizeof(*pred));
  291. for (i = 0; i < height; i++) {
  292. val = pred[0] + dst[0];
  293. dst[0] = val;
  294. pred[0] = val;
  295. next = dst + 2;
  296. for (j = 1; j < width; j++, next++) {
  297. val = pred[j] + next[-1];
  298. next[-1] = val;
  299. pred[j] = val;
  300. next[-1] += next[-2];
  301. }
  302. dst += stride;
  303. }
  304. }
  305. static void filter(int16_t *dest, int16_t *tmp, unsigned size, float SCALE)
  306. {
  307. int16_t *low, *high, *ll, *lh, *hl, *hh;
  308. int hsize, i, j;
  309. float value;
  310. hsize = size >> 1;
  311. low = tmp + 4;
  312. high = &low[hsize + 8];
  313. memcpy(low, dest, size);
  314. memcpy(high, dest + hsize, size);
  315. ll = &low[hsize];
  316. lh = &low[hsize];
  317. hl = &high[hsize];
  318. hh = hl;
  319. for (i = 4, j = 2; i; i--, j++, ll--, hh++, lh++, hl--) {
  320. low[i - 5] = low[j - 1];
  321. lh[0] = ll[-1];
  322. high[i - 5] = high[j - 2];
  323. hh[0] = hl[-2];
  324. }
  325. for (i = 0; i < hsize; i++) {
  326. value = low [i+1] * -0.07576144003329376f +
  327. low [i ] * 0.8586296626673486f +
  328. low [i-1] * -0.07576144003329376f +
  329. high[i ] * 0.3535533905932737f +
  330. high[i-1] * 0.3535533905932737f;
  331. dest[i * 2] = av_clipf(value * SCALE, INT16_MIN, INT16_MAX);
  332. }
  333. for (i = 0; i < hsize; i++) {
  334. value = low [i+2] * -0.01515228715813062f +
  335. low [i+1] * 0.3687056777514043f +
  336. low [i ] * 0.3687056777514043f +
  337. low [i-1] * -0.01515228715813062f +
  338. high[i+1] * 0.07071067811865475f +
  339. high[i ] * -0.8485281374238569f +
  340. high[i-1] * 0.07071067811865475f;
  341. dest[i * 2 + 1] = av_clipf(value * SCALE, INT16_MIN, INT16_MAX);
  342. }
  343. }
  344. static void reconstruction(AVCodecContext *avctx,
  345. int16_t *dest, unsigned width, unsigned height, ptrdiff_t stride, int nb_levels,
  346. float *scaling_H, float *scaling_V)
  347. {
  348. PixletContext *ctx = avctx->priv_data;
  349. unsigned scaled_width, scaled_height;
  350. float scale_H, scale_V;
  351. int16_t *ptr, *tmp;
  352. int i, j, k;
  353. scaled_height = height >> nb_levels;
  354. scaled_width = width >> nb_levels;
  355. tmp = ctx->filter[0];
  356. for (i = 0; i < nb_levels; i++) {
  357. scaled_width <<= 1;
  358. scaled_height <<= 1;
  359. scale_H = scaling_H[i];
  360. scale_V = scaling_V[i];
  361. ptr = dest;
  362. for (j = 0; j < scaled_height; j++) {
  363. filter(ptr, ctx->filter[1], scaled_width, scale_V);
  364. ptr += stride;
  365. }
  366. for (j = 0; j < scaled_width; j++) {
  367. ptr = dest + j;
  368. for (k = 0; k < scaled_height; k++) {
  369. tmp[k] = *ptr;
  370. ptr += stride;
  371. }
  372. filter(tmp, ctx->filter[1], scaled_height, scale_H);
  373. ptr = dest + j;
  374. for (k = 0; k < scaled_height; k++) {
  375. *ptr = tmp[k];
  376. ptr += stride;
  377. }
  378. }
  379. }
  380. }
  381. #define SQR(a) ((a) * (a))
  382. static void postprocess_luma(AVFrame *frame, int w, int h, int depth)
  383. {
  384. uint16_t *dsty = (uint16_t *)frame->data[0];
  385. int16_t *srcy = (int16_t *)frame->data[0];
  386. ptrdiff_t stridey = frame->linesize[0] / 2;
  387. const float factor = 1.0f / ((1 << depth) - 1);
  388. int i, j;
  389. for (j = 0; j < h; j++) {
  390. for (i = 0; i < w; i++) {
  391. dsty[i] = SQR(FFMAX(srcy[i], 0) * factor) * 65535;
  392. }
  393. dsty += stridey;
  394. srcy += stridey;
  395. }
  396. }
  397. static void postprocess_chroma(AVFrame *frame, int w, int h, int depth)
  398. {
  399. uint16_t *dstu = (uint16_t *)frame->data[1];
  400. uint16_t *dstv = (uint16_t *)frame->data[2];
  401. int16_t *srcu = (int16_t *)frame->data[1];
  402. int16_t *srcv = (int16_t *)frame->data[2];
  403. ptrdiff_t strideu = frame->linesize[1] / 2;
  404. ptrdiff_t stridev = frame->linesize[2] / 2;
  405. const int add = 1 << (depth - 1);
  406. const int shift = 16 - depth;
  407. int i, j;
  408. for (j = 0; j < h; j++) {
  409. for (i = 0; i < w; i++) {
  410. dstu[i] = (add + srcu[i]) << shift;
  411. dstv[i] = (add + srcv[i]) << shift;
  412. }
  413. dstu += strideu;
  414. dstv += stridev;
  415. srcu += strideu;
  416. srcv += stridev;
  417. }
  418. }
  419. static int decode_plane(AVCodecContext *avctx, int plane, AVPacket *avpkt, AVFrame *frame)
  420. {
  421. PixletContext *ctx = avctx->priv_data;
  422. ptrdiff_t stride = frame->linesize[plane] / 2;
  423. unsigned shift = plane > 0;
  424. int16_t *dst;
  425. int i, ret;
  426. for (i = ctx->levels - 1; i >= 0; i--) {
  427. ctx->scaling[plane][H][i] = 1000000.0f / sign_extend(bytestream2_get_be32(&ctx->gb), 32);
  428. ctx->scaling[plane][V][i] = 1000000.0f / sign_extend(bytestream2_get_be32(&ctx->gb), 32);
  429. }
  430. bytestream2_skip(&ctx->gb, 4);
  431. dst = (int16_t *)frame->data[plane];
  432. dst[0] = sign_extend(bytestream2_get_be16(&ctx->gb), 16);
  433. if ((ret = init_get_bits8(&ctx->gbit, avpkt->data + bytestream2_tell(&ctx->gb),
  434. bytestream2_get_bytes_left(&ctx->gb))) < 0)
  435. return ret;
  436. ret = read_low_coeffs(avctx, dst + 1, ctx->band[plane][0].width - 1, ctx->band[plane][0].width - 1, 0);
  437. if (ret < 0) {
  438. av_log(avctx, AV_LOG_ERROR, "error in lowpass coefficients for plane %d, top row\n", plane);
  439. return ret;
  440. }
  441. ret = read_low_coeffs(avctx, dst + stride, ctx->band[plane][0].height - 1, 1, stride);
  442. if (ret < 0) {
  443. av_log(avctx, AV_LOG_ERROR, "error in lowpass coefficients for plane %d, left column\n", plane);
  444. return ret;
  445. }
  446. ret = read_low_coeffs(avctx, dst + stride + 1,
  447. (ctx->band[plane][0].width - 1) * (ctx->band[plane][0].height - 1),
  448. ctx->band[plane][0].width - 1, stride);
  449. if (ret < 0) {
  450. av_log(avctx, AV_LOG_ERROR, "error in lowpass coefficients for plane %d, rest\n", plane);
  451. return ret;
  452. }
  453. bytestream2_skip(&ctx->gb, ret);
  454. if (bytestream2_get_bytes_left(&ctx->gb) <= 0) {
  455. av_log(avctx, AV_LOG_ERROR, "no bytes left\n");
  456. return AVERROR_INVALIDDATA;
  457. }
  458. ret = read_highpass(avctx, avpkt->data, plane, frame);
  459. if (ret < 0)
  460. return ret;
  461. lowpass_prediction(dst, ctx->prediction,
  462. ctx->band[plane][0].width, ctx->band[plane][0].height, stride);
  463. reconstruction(avctx, (int16_t *)frame->data[plane], ctx->w >> shift, ctx->h >> shift,
  464. stride, NB_LEVELS, ctx->scaling[plane][H], ctx->scaling[plane][V]);
  465. return 0;
  466. }
  467. static int pixlet_decode_frame(AVCodecContext *avctx, void *data,
  468. int *got_frame, AVPacket *avpkt)
  469. {
  470. PixletContext *ctx = avctx->priv_data;
  471. int i, w, h, width, height, ret, version;
  472. AVFrame *p = data;
  473. ThreadFrame frame = { .f = data };
  474. uint32_t pktsize;
  475. bytestream2_init(&ctx->gb, avpkt->data, avpkt->size);
  476. pktsize = bytestream2_get_be32(&ctx->gb);
  477. if (pktsize <= 44 || pktsize - 4 > bytestream2_get_bytes_left(&ctx->gb)) {
  478. av_log(avctx, AV_LOG_ERROR, "Invalid packet size %u.\n", pktsize);
  479. return AVERROR_INVALIDDATA;
  480. }
  481. version = bytestream2_get_le32(&ctx->gb);
  482. if (version != 1)
  483. avpriv_request_sample(avctx, "Version %d", version);
  484. bytestream2_skip(&ctx->gb, 4);
  485. if (bytestream2_get_be32(&ctx->gb) != 1)
  486. return AVERROR_INVALIDDATA;
  487. bytestream2_skip(&ctx->gb, 4);
  488. width = bytestream2_get_be32(&ctx->gb);
  489. height = bytestream2_get_be32(&ctx->gb);
  490. w = FFALIGN(width, 1 << (NB_LEVELS + 1));
  491. h = FFALIGN(height, 1 << (NB_LEVELS + 1));
  492. ctx->levels = bytestream2_get_be32(&ctx->gb);
  493. if (ctx->levels != NB_LEVELS)
  494. return AVERROR_INVALIDDATA;
  495. ctx->depth = bytestream2_get_be32(&ctx->gb);
  496. if (ctx->depth < 8 || ctx->depth > 15) {
  497. avpriv_request_sample(avctx, "Depth %d", ctx->depth);
  498. return AVERROR_INVALIDDATA;
  499. }
  500. ret = ff_set_dimensions(avctx, w, h);
  501. if (ret < 0)
  502. return ret;
  503. avctx->width = width;
  504. avctx->height = height;
  505. if (ctx->w != w || ctx->h != h) {
  506. free_buffers(avctx);
  507. ctx->w = w;
  508. ctx->h = h;
  509. ret = init_decoder(avctx);
  510. if (ret < 0) {
  511. free_buffers(avctx);
  512. ctx->w = 0;
  513. ctx->h = 0;
  514. return ret;
  515. }
  516. }
  517. bytestream2_skip(&ctx->gb, 8);
  518. p->pict_type = AV_PICTURE_TYPE_I;
  519. p->key_frame = 1;
  520. p->color_range = AVCOL_RANGE_JPEG;
  521. ret = ff_thread_get_buffer(avctx, &frame, 0);
  522. if (ret < 0)
  523. return ret;
  524. for (i = 0; i < 3; i++) {
  525. ret = decode_plane(avctx, i, avpkt, frame.f);
  526. if (ret < 0)
  527. return ret;
  528. if (avctx->flags & AV_CODEC_FLAG_GRAY)
  529. break;
  530. }
  531. postprocess_luma(frame.f, ctx->w, ctx->h, ctx->depth);
  532. postprocess_chroma(frame.f, ctx->w >> 1, ctx->h >> 1, ctx->depth);
  533. *got_frame = 1;
  534. return pktsize;
  535. }
  536. #if HAVE_THREADS
  537. static int pixlet_init_thread_copy(AVCodecContext *avctx)
  538. {
  539. PixletContext *ctx = avctx->priv_data;
  540. ctx->filter[0] = NULL;
  541. ctx->filter[1] = NULL;
  542. ctx->prediction = NULL;
  543. ctx->w = ctx->h = 0;
  544. return 0;
  545. }
  546. #endif
  547. AVCodec ff_pixlet_decoder = {
  548. .name = "pixlet",
  549. .long_name = NULL_IF_CONFIG_SMALL("Apple Pixlet"),
  550. .type = AVMEDIA_TYPE_VIDEO,
  551. .id = AV_CODEC_ID_PIXLET,
  552. .init = pixlet_init,
  553. .init_thread_copy = ONLY_IF_THREADS_ENABLED(pixlet_init_thread_copy),
  554. .close = pixlet_close,
  555. .decode = pixlet_decode_frame,
  556. .priv_data_size = sizeof(PixletContext),
  557. .capabilities = AV_CODEC_CAP_DR1 |
  558. AV_CODEC_CAP_FRAME_THREADS,
  559. .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
  560. FF_CODEC_CAP_INIT_CLEANUP,
  561. };