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.

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