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.

694 lines
20KB

  1. /*
  2. * TIFF image decoder
  3. * Copyright (c) 2006 Konstantin Shishkov
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * TIFF image decoder
  24. * @author Konstantin Shishkov
  25. */
  26. #include "config.h"
  27. #if CONFIG_ZLIB
  28. #include <zlib.h>
  29. #endif
  30. #include "libavutil/attributes.h"
  31. #include "libavutil/intreadwrite.h"
  32. #include "libavutil/imgutils.h"
  33. #include "avcodec.h"
  34. #include "faxcompr.h"
  35. #include "internal.h"
  36. #include "lzw.h"
  37. #include "mathops.h"
  38. #include "tiff.h"
  39. typedef struct TiffContext {
  40. AVCodecContext *avctx;
  41. int width, height;
  42. unsigned int bpp, bppcount;
  43. uint32_t palette[256];
  44. int palette_is_set;
  45. int le;
  46. enum TiffCompr compr;
  47. int invert;
  48. int fax_opts;
  49. int predictor;
  50. int fill_order;
  51. int strips, rps, sstype;
  52. int sot;
  53. const uint8_t *stripdata;
  54. const uint8_t *stripsizes;
  55. int stripsize, stripoff;
  56. LZWState *lzw;
  57. } TiffContext;
  58. static unsigned tget_short(const uint8_t **p, int le)
  59. {
  60. unsigned v = le ? AV_RL16(*p) : AV_RB16(*p);
  61. *p += 2;
  62. return v;
  63. }
  64. static unsigned tget_long(const uint8_t **p, int le)
  65. {
  66. unsigned v = le ? AV_RL32(*p) : AV_RB32(*p);
  67. *p += 4;
  68. return v;
  69. }
  70. static unsigned tget(const uint8_t **p, int type, int le)
  71. {
  72. switch (type) {
  73. case TIFF_BYTE:
  74. return *(*p)++;
  75. case TIFF_SHORT:
  76. return tget_short(p, le);
  77. case TIFF_LONG:
  78. return tget_long(p, le);
  79. default:
  80. return UINT_MAX;
  81. }
  82. }
  83. #if CONFIG_ZLIB
  84. static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src,
  85. int size)
  86. {
  87. z_stream zstream = { 0 };
  88. int zret;
  89. zstream.next_in = src;
  90. zstream.avail_in = size;
  91. zstream.next_out = dst;
  92. zstream.avail_out = *len;
  93. zret = inflateInit(&zstream);
  94. if (zret != Z_OK) {
  95. av_log(NULL, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
  96. return zret;
  97. }
  98. zret = inflate(&zstream, Z_SYNC_FLUSH);
  99. inflateEnd(&zstream);
  100. *len = zstream.total_out;
  101. return zret == Z_STREAM_END ? Z_OK : zret;
  102. }
  103. #endif
  104. static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
  105. const uint8_t *src, int size, int lines)
  106. {
  107. int c, line, pixels, code, ret;
  108. const uint8_t *ssrc = src;
  109. int width = ((s->width * s->bpp) + 7) >> 3;
  110. if (size <= 0)
  111. return AVERROR_INVALIDDATA;
  112. #if CONFIG_ZLIB
  113. if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {
  114. uint8_t *zbuf;
  115. unsigned long outlen;
  116. int ret;
  117. outlen = width * lines;
  118. zbuf = av_malloc(outlen);
  119. if (!zbuf)
  120. return AVERROR(ENOMEM);
  121. ret = tiff_uncompress(zbuf, &outlen, src, size);
  122. if (ret != Z_OK) {
  123. av_log(s->avctx, AV_LOG_ERROR,
  124. "Uncompressing failed (%lu of %lu) with error %d\n", outlen,
  125. (unsigned long)width * lines, ret);
  126. av_free(zbuf);
  127. return AVERROR_UNKNOWN;
  128. }
  129. src = zbuf;
  130. for (line = 0; line < lines; line++) {
  131. memcpy(dst, src, width);
  132. dst += stride;
  133. src += width;
  134. }
  135. av_free(zbuf);
  136. return 0;
  137. }
  138. #endif
  139. if (s->compr == TIFF_LZW) {
  140. if ((ret = ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF)) < 0) {
  141. av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n");
  142. return ret;
  143. }
  144. }
  145. if (s->compr == TIFF_CCITT_RLE ||
  146. s->compr == TIFF_G3 ||
  147. s->compr == TIFF_G4) {
  148. int i, ret = 0;
  149. uint8_t *src2 = av_malloc((unsigned)size +
  150. FF_INPUT_BUFFER_PADDING_SIZE);
  151. if (!src2) {
  152. av_log(s->avctx, AV_LOG_ERROR,
  153. "Error allocating temporary buffer\n");
  154. return AVERROR(ENOMEM);
  155. }
  156. if (s->fax_opts & 2) {
  157. av_log(s->avctx, AV_LOG_ERROR,
  158. "Uncompressed fax mode is not supported (yet)\n");
  159. av_free(src2);
  160. return AVERROR_INVALIDDATA;
  161. }
  162. if (!s->fill_order) {
  163. memcpy(src2, src, size);
  164. } else {
  165. for (i = 0; i < size; i++)
  166. src2[i] = ff_reverse[src[i]];
  167. }
  168. memset(src2 + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  169. switch (s->compr) {
  170. case TIFF_CCITT_RLE:
  171. case TIFF_G3:
  172. case TIFF_G4:
  173. ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride,
  174. s->compr, s->fax_opts);
  175. break;
  176. }
  177. av_free(src2);
  178. return ret;
  179. }
  180. for (line = 0; line < lines; line++) {
  181. if (src - ssrc > size) {
  182. av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
  183. return AVERROR_INVALIDDATA;
  184. }
  185. switch (s->compr) {
  186. case TIFF_RAW:
  187. if (ssrc + size - src < width)
  188. return AVERROR_INVALIDDATA;
  189. if (!s->fill_order) {
  190. memcpy(dst, src, width);
  191. } else {
  192. int i;
  193. for (i = 0; i < width; i++)
  194. dst[i] = ff_reverse[src[i]];
  195. }
  196. src += width;
  197. break;
  198. case TIFF_PACKBITS:
  199. for (pixels = 0; pixels < width;) {
  200. code = (int8_t) *src++;
  201. if (code >= 0) {
  202. code++;
  203. if (pixels + code > width) {
  204. av_log(s->avctx, AV_LOG_ERROR,
  205. "Copy went out of bounds\n");
  206. return AVERROR_INVALIDDATA;
  207. }
  208. memcpy(dst + pixels, src, code);
  209. src += code;
  210. pixels += code;
  211. } else if (code != -128) { // -127..-1
  212. code = (-code) + 1;
  213. if (pixels + code > width) {
  214. av_log(s->avctx, AV_LOG_ERROR,
  215. "Run went out of bounds\n");
  216. return AVERROR_INVALIDDATA;
  217. }
  218. c = *src++;
  219. memset(dst + pixels, c, code);
  220. pixels += code;
  221. }
  222. }
  223. break;
  224. case TIFF_LZW:
  225. pixels = ff_lzw_decode(s->lzw, dst, width);
  226. if (pixels < width) {
  227. av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n",
  228. pixels, width);
  229. return AVERROR_INVALIDDATA;
  230. }
  231. break;
  232. }
  233. dst += stride;
  234. }
  235. return 0;
  236. }
  237. static int init_image(TiffContext *s, AVFrame *frame)
  238. {
  239. int i, ret;
  240. uint32_t *pal;
  241. switch (s->bpp * 10 + s->bppcount) {
  242. case 11:
  243. s->avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
  244. break;
  245. case 81:
  246. s->avctx->pix_fmt = AV_PIX_FMT_PAL8;
  247. break;
  248. case 243:
  249. s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
  250. break;
  251. case 161:
  252. s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GRAY16LE : AV_PIX_FMT_GRAY16BE;
  253. break;
  254. case 324:
  255. s->avctx->pix_fmt = AV_PIX_FMT_RGBA;
  256. break;
  257. case 483:
  258. s->avctx->pix_fmt = s->le ? AV_PIX_FMT_RGB48LE : AV_PIX_FMT_RGB48BE;
  259. break;
  260. default:
  261. av_log(s->avctx, AV_LOG_ERROR,
  262. "This format is not supported (bpp=%d, bppcount=%d)\n",
  263. s->bpp, s->bppcount);
  264. return AVERROR_INVALIDDATA;
  265. }
  266. if (s->width != s->avctx->width || s->height != s->avctx->height) {
  267. if ((ret = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0)
  268. return ret;
  269. avcodec_set_dimensions(s->avctx, s->width, s->height);
  270. }
  271. if ((ret = ff_get_buffer(s->avctx, frame, 0)) < 0) {
  272. av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
  273. return ret;
  274. }
  275. if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) {
  276. if (s->palette_is_set) {
  277. memcpy(frame->data[1], s->palette, sizeof(s->palette));
  278. } else {
  279. /* make default grayscale pal */
  280. pal = (uint32_t *) frame->data[1];
  281. for (i = 0; i < 256; i++)
  282. pal[i] = i * 0x010101;
  283. }
  284. }
  285. return 0;
  286. }
  287. static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
  288. const uint8_t *buf, const uint8_t *end_buf)
  289. {
  290. unsigned tag, type, count, off, value = 0;
  291. int i, j;
  292. uint32_t *pal;
  293. const uint8_t *rp, *gp, *bp;
  294. if (end_buf - buf < 12)
  295. return AVERROR_INVALIDDATA;
  296. tag = tget_short(&buf, s->le);
  297. type = tget_short(&buf, s->le);
  298. count = tget_long(&buf, s->le);
  299. off = tget_long(&buf, s->le);
  300. if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {
  301. av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",
  302. type);
  303. return 0;
  304. }
  305. if (count == 1) {
  306. switch (type) {
  307. case TIFF_BYTE:
  308. case TIFF_SHORT:
  309. buf -= 4;
  310. value = tget(&buf, type, s->le);
  311. buf = NULL;
  312. break;
  313. case TIFF_LONG:
  314. value = off;
  315. buf = NULL;
  316. break;
  317. case TIFF_STRING:
  318. if (count <= 4) {
  319. buf -= 4;
  320. break;
  321. }
  322. default:
  323. value = UINT_MAX;
  324. buf = start + off;
  325. }
  326. } else {
  327. if (count <= 4 && type_sizes[type] * count <= 4)
  328. buf -= 4;
  329. else
  330. buf = start + off;
  331. }
  332. if (buf && (buf < start || buf > end_buf)) {
  333. av_log(s->avctx, AV_LOG_ERROR,
  334. "Tag referencing position outside the image\n");
  335. return AVERROR_INVALIDDATA;
  336. }
  337. switch (tag) {
  338. case TIFF_WIDTH:
  339. s->width = value;
  340. break;
  341. case TIFF_HEIGHT:
  342. s->height = value;
  343. break;
  344. case TIFF_BPP:
  345. s->bppcount = count;
  346. if (count > 4) {
  347. av_log(s->avctx, AV_LOG_ERROR,
  348. "This format is not supported (bpp=%d, %d components)\n",
  349. s->bpp, count);
  350. return AVERROR_INVALIDDATA;
  351. }
  352. if (count == 1)
  353. s->bpp = value;
  354. else {
  355. switch (type) {
  356. case TIFF_BYTE:
  357. s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +
  358. ((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
  359. break;
  360. case TIFF_SHORT:
  361. case TIFF_LONG:
  362. s->bpp = 0;
  363. for (i = 0; i < count && buf < end_buf; i++)
  364. s->bpp += tget(&buf, type, s->le);
  365. break;
  366. default:
  367. s->bpp = -1;
  368. }
  369. }
  370. break;
  371. case TIFF_SAMPLES_PER_PIXEL:
  372. if (count != 1) {
  373. av_log(s->avctx, AV_LOG_ERROR,
  374. "Samples per pixel requires a single value, many provided\n");
  375. return AVERROR_INVALIDDATA;
  376. }
  377. if (s->bppcount == 1)
  378. s->bpp *= value;
  379. s->bppcount = value;
  380. break;
  381. case TIFF_COMPR:
  382. s->compr = value;
  383. s->predictor = 0;
  384. switch (s->compr) {
  385. case TIFF_RAW:
  386. case TIFF_PACKBITS:
  387. case TIFF_LZW:
  388. case TIFF_CCITT_RLE:
  389. break;
  390. case TIFF_G3:
  391. case TIFF_G4:
  392. s->fax_opts = 0;
  393. break;
  394. case TIFF_DEFLATE:
  395. case TIFF_ADOBE_DEFLATE:
  396. #if CONFIG_ZLIB
  397. break;
  398. #else
  399. av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
  400. return AVERROR(ENOSYS);
  401. #endif
  402. case TIFF_JPEG:
  403. case TIFF_NEWJPEG:
  404. av_log(s->avctx, AV_LOG_ERROR,
  405. "JPEG compression is not supported\n");
  406. return AVERROR_PATCHWELCOME;
  407. default:
  408. av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",
  409. s->compr);
  410. return AVERROR_INVALIDDATA;
  411. }
  412. break;
  413. case TIFF_ROWSPERSTRIP:
  414. if (type == TIFF_LONG && value == UINT_MAX)
  415. value = s->avctx->height;
  416. if (value < 1) {
  417. av_log(s->avctx, AV_LOG_ERROR,
  418. "Incorrect value of rows per strip\n");
  419. return AVERROR_INVALIDDATA;
  420. }
  421. s->rps = value;
  422. break;
  423. case TIFF_STRIP_OFFS:
  424. if (count == 1) {
  425. s->stripdata = NULL;
  426. s->stripoff = value;
  427. } else
  428. s->stripdata = start + off;
  429. s->strips = count;
  430. if (s->strips == 1)
  431. s->rps = s->height;
  432. s->sot = type;
  433. if (s->stripdata > end_buf) {
  434. av_log(s->avctx, AV_LOG_ERROR,
  435. "Tag referencing position outside the image\n");
  436. return AVERROR_INVALIDDATA;
  437. }
  438. break;
  439. case TIFF_STRIP_SIZE:
  440. if (count == 1) {
  441. s->stripsizes = NULL;
  442. s->stripsize = value;
  443. s->strips = 1;
  444. } else {
  445. s->stripsizes = start + off;
  446. }
  447. s->strips = count;
  448. s->sstype = type;
  449. if (s->stripsizes > end_buf) {
  450. av_log(s->avctx, AV_LOG_ERROR,
  451. "Tag referencing position outside the image\n");
  452. return AVERROR_INVALIDDATA;
  453. }
  454. break;
  455. case TIFF_PREDICTOR:
  456. s->predictor = value;
  457. break;
  458. case TIFF_INVERT:
  459. switch (value) {
  460. case 0:
  461. s->invert = 1;
  462. break;
  463. case 1:
  464. s->invert = 0;
  465. break;
  466. case 2:
  467. case 3:
  468. break;
  469. default:
  470. av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
  471. value);
  472. return AVERROR_INVALIDDATA;
  473. }
  474. break;
  475. case TIFF_FILL_ORDER:
  476. if (value < 1 || value > 2) {
  477. av_log(s->avctx, AV_LOG_ERROR,
  478. "Unknown FillOrder value %d, trying default one\n", value);
  479. value = 1;
  480. }
  481. s->fill_order = value - 1;
  482. break;
  483. case TIFF_PAL:
  484. pal = (uint32_t *) s->palette;
  485. off = type_sizes[type];
  486. if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3)
  487. return AVERROR_INVALIDDATA;
  488. rp = buf;
  489. gp = buf + count / 3 * off;
  490. bp = buf + count / 3 * off * 2;
  491. off = (type_sizes[type] - 1) << 3;
  492. for (i = 0; i < count / 3; i++) {
  493. j = (tget(&rp, type, s->le) >> off) << 16;
  494. j |= (tget(&gp, type, s->le) >> off) << 8;
  495. j |= tget(&bp, type, s->le) >> off;
  496. pal[i] = j;
  497. }
  498. s->palette_is_set = 1;
  499. break;
  500. case TIFF_PLANAR:
  501. if (value == 2) {
  502. av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n");
  503. return AVERROR_PATCHWELCOME;
  504. }
  505. break;
  506. case TIFF_T4OPTIONS:
  507. if (s->compr == TIFF_G3)
  508. s->fax_opts = value;
  509. break;
  510. case TIFF_T6OPTIONS:
  511. if (s->compr == TIFF_G4)
  512. s->fax_opts = value;
  513. break;
  514. default:
  515. av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n",
  516. tag, tag);
  517. }
  518. return 0;
  519. }
  520. static int decode_frame(AVCodecContext *avctx,
  521. void *data, int *got_frame, AVPacket *avpkt)
  522. {
  523. const uint8_t *buf = avpkt->data;
  524. int buf_size = avpkt->size;
  525. TiffContext *const s = avctx->priv_data;
  526. AVFrame *const p = data;
  527. const uint8_t *orig_buf = buf, *end_buf = buf + buf_size;
  528. unsigned off;
  529. int id, le, ret;
  530. int i, j, entries, stride;
  531. unsigned soff, ssize;
  532. uint8_t *dst;
  533. // parse image header
  534. if (end_buf - buf < 8)
  535. return AVERROR_INVALIDDATA;
  536. id = AV_RL16(buf);
  537. buf += 2;
  538. if (id == 0x4949)
  539. le = 1;
  540. else if (id == 0x4D4D)
  541. le = 0;
  542. else {
  543. av_log(avctx, AV_LOG_ERROR, "TIFF header not found\n");
  544. return AVERROR_INVALIDDATA;
  545. }
  546. s->le = le;
  547. s->invert = 0;
  548. s->compr = TIFF_RAW;
  549. s->fill_order = 0;
  550. // As TIFF 6.0 specification puts it "An arbitrary but carefully chosen number
  551. // that further identifies the file as a TIFF file"
  552. if (tget_short(&buf, le) != 42) {
  553. av_log(avctx, AV_LOG_ERROR,
  554. "The answer to life, universe and everything is not correct!\n");
  555. return AVERROR_INVALIDDATA;
  556. }
  557. // Reset these pointers so we can tell if they were set this frame
  558. s->stripsizes = s->stripdata = NULL;
  559. /* parse image file directory */
  560. off = tget_long(&buf, le);
  561. if (off >= UINT_MAX - 14 || end_buf - orig_buf < off + 14) {
  562. av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image size\n");
  563. return AVERROR_INVALIDDATA;
  564. }
  565. buf = orig_buf + off;
  566. entries = tget_short(&buf, le);
  567. for (i = 0; i < entries; i++) {
  568. if ((ret = tiff_decode_tag(s, orig_buf, buf, end_buf)) < 0)
  569. return ret;
  570. buf += 12;
  571. }
  572. if (!s->stripdata && !s->stripoff) {
  573. av_log(avctx, AV_LOG_ERROR, "Image data is missing\n");
  574. return AVERROR_INVALIDDATA;
  575. }
  576. /* now we have the data and may start decoding */
  577. if ((ret = init_image(s, p)) < 0)
  578. return ret;
  579. if (s->strips == 1 && !s->stripsize) {
  580. av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
  581. s->stripsize = buf_size - s->stripoff;
  582. }
  583. stride = p->linesize[0];
  584. dst = p->data[0];
  585. for (i = 0; i < s->height; i += s->rps) {
  586. if (s->stripsizes) {
  587. if (s->stripsizes >= end_buf)
  588. return AVERROR_INVALIDDATA;
  589. ssize = tget(&s->stripsizes, s->sstype, s->le);
  590. } else
  591. ssize = s->stripsize;
  592. if (s->stripdata) {
  593. if (s->stripdata >= end_buf)
  594. return AVERROR_INVALIDDATA;
  595. soff = tget(&s->stripdata, s->sot, s->le);
  596. } else
  597. soff = s->stripoff;
  598. if (soff > buf_size || ssize > buf_size - soff) {
  599. av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n");
  600. return AVERROR_INVALIDDATA;
  601. }
  602. if (tiff_unpack_strip(s, dst, stride, orig_buf + soff, ssize,
  603. FFMIN(s->rps, s->height - i)) < 0)
  604. break;
  605. dst += s->rps * stride;
  606. }
  607. if (s->predictor == 2) {
  608. dst = p->data[0];
  609. soff = s->bpp >> 3;
  610. ssize = s->width * soff;
  611. for (i = 0; i < s->height; i++) {
  612. for (j = soff; j < ssize; j++)
  613. dst[j] += dst[j - soff];
  614. dst += stride;
  615. }
  616. }
  617. if (s->invert) {
  618. uint8_t *src;
  619. int j;
  620. src = p->data[0];
  621. for (j = 0; j < s->height; j++) {
  622. for (i = 0; i < p->linesize[0]; i++)
  623. src[i] = 255 - src[i];
  624. src += p->linesize[0];
  625. }
  626. }
  627. *got_frame = 1;
  628. return buf_size;
  629. }
  630. static av_cold int tiff_init(AVCodecContext *avctx)
  631. {
  632. TiffContext *s = avctx->priv_data;
  633. s->width = 0;
  634. s->height = 0;
  635. s->avctx = avctx;
  636. ff_lzw_decode_open(&s->lzw);
  637. ff_ccitt_unpack_init();
  638. return 0;
  639. }
  640. static av_cold int tiff_end(AVCodecContext *avctx)
  641. {
  642. TiffContext *const s = avctx->priv_data;
  643. ff_lzw_decode_close(&s->lzw);
  644. return 0;
  645. }
  646. AVCodec ff_tiff_decoder = {
  647. .name = "tiff",
  648. .long_name = NULL_IF_CONFIG_SMALL("TIFF image"),
  649. .type = AVMEDIA_TYPE_VIDEO,
  650. .id = AV_CODEC_ID_TIFF,
  651. .priv_data_size = sizeof(TiffContext),
  652. .init = tiff_init,
  653. .close = tiff_end,
  654. .decode = decode_frame,
  655. .capabilities = CODEC_CAP_DR1,
  656. };