85 #define RET_GEOKEY(TYPE, array, element)\ 
   86     if (key >= TIFF_##TYPE##_KEY_ID_OFFSET &&\ 
   87         key - TIFF_##TYPE##_KEY_ID_OFFSET < FF_ARRAY_ELEMS(ff_tiff_##array##_name_type_map))\ 
   88         return ff_tiff_##array##_name_type_map[key - TIFF_##TYPE##_KEY_ID_OFFSET].element; 
  133 #define RET_GEOKEY_VAL(TYPE, array)\ 
  134     if (val >= TIFF_##TYPE##_OFFSET &&\ 
  135         val - TIFF_##TYPE##_OFFSET < FF_ARRAY_ELEMS(ff_tiff_##array##_codes))\ 
  136         return av_strdup(ff_tiff_##array##_codes[val - TIFF_##TYPE##_OFFSET]); 
  188         snprintf(ap, 14, 
"Unknown-%d", val);
 
  196     uint64_t component_len;
 
  197     if (!sep) sep = 
", ";
 
  198     component_len = 24LL + strlen(sep);
 
  199     if (count >= (INT_MAX - 1)/component_len)
 
  201     ap = 
av_malloc(component_len * count + 1);
 
  206     for (i = 0; i < 
count; i++) {
 
  207         unsigned l = 
snprintf(ap, component_len, 
"%.15g%s", dp[i], sep);
 
  208         if(l >= component_len) {
 
  214     ap0[strlen(ap0) - strlen(sep)] = 
'\0';
 
  235         while (--width >= 0) {
 
  236             dst[(width+
offset)*8+7] = (usePtr ? src[width] : c)      & 0x1;
 
  237             dst[(width+
offset)*8+6] = (usePtr ? src[width] : c) >> 1 & 0x1;
 
  238             dst[(width+
offset)*8+5] = (usePtr ? src[width] : c) >> 2 & 0x1;
 
  239             dst[(width+
offset)*8+4] = (usePtr ? src[width] : c) >> 3 & 0x1;
 
  240             dst[(width+
offset)*8+3] = (usePtr ? src[width] : c) >> 4 & 0x1;
 
  241             dst[(width+
offset)*8+2] = (usePtr ? src[width] : c) >> 5 & 0x1;
 
  242             dst[(width+
offset)*8+1] = (usePtr ? src[width] : c) >> 6 & 0x1;
 
  243             dst[(width+
offset)*8+0] = (usePtr ? src[width] : c) >> 7;
 
  247         while (--width >= 0) {
 
  248             dst[(width+
offset)*4+3] = (usePtr ? src[width] : c) & 0x3;
 
  249             dst[(width+
offset)*4+2] = (usePtr ? src[width] : c) >> 2 & 0x3;
 
  250             dst[(width+
offset)*4+1] = (usePtr ? src[width] : c) >> 4 & 0x3;
 
  251             dst[(width+
offset)*4+0] = (usePtr ? src[width] : c) >> 6;
 
  255         while (--width >= 0) {
 
  256             dst[(width+
offset)*2+1] = (usePtr ? src[width] : c) & 0xF;
 
  257             dst[(width+
offset)*2+0] = (usePtr ? src[width] : c) >> 4;
 
  262             memcpy(dst + offset, src, width);
 
  264             memset(dst + offset, c, width);
 
  276     for (i = 0; i < 
size; i++)
 
  286     z_stream zstream = { 0 };
 
  289     zstream.next_in   = (
uint8_t *)src;
 
  290     zstream.avail_in  = 
size;
 
  291     zstream.next_out  = dst;
 
  292     zstream.avail_out = *
len;
 
  293     zret              = inflateInit(&zstream);
 
  298     zret = inflate(&zstream, Z_SYNC_FLUSH);
 
  299     inflateEnd(&zstream);
 
  300     *len = zstream.total_out;
 
  301     return zret == Z_STREAM_END ? Z_OK : zret;
 
  306                             int width, 
int lines)
 
  309     unsigned long outlen;
 
  311     outlen = width * lines;
 
  322     ret = tiff_uncompress(zbuf, &outlen, src, size);
 
  325                "Uncompressing failed (%lu of %lu) with error %d\n", outlen,
 
  326                (
unsigned long)width * lines, ret);
 
  331     for (line = 0; line < lines; line++) {
 
  335             memcpy(dst, src, width);
 
  347                            const uint8_t *src, 
int size, 
int width, 
int lines)
 
  356                "Error allocating temporary buffer\n");
 
  365         memcpy(src2, src, size);
 
  367         for (i = 0; i < 
size; i++)
 
  374         for (line = 0; line < lines; line++) {
 
  383                              const uint8_t *src, 
int size, 
int lines)
 
  385     int c, line, pixels, code, 
ret;
 
  387     int width           = ((s->
width * s->
bpp) + 7) >> 3;
 
  397         return tiff_unpack_zlib(s, dst, stride, src, size, width, lines);
 
  400                "zlib support not enabled, " 
  401                "deflate compression not supported\n");
 
  411         if (size > 1 && !src[0] && (src[1]&1)) {
 
  424     for (line = 0; line < lines; line++) {
 
  425         if (src - ssrc > size) {
 
  431             if (ssrc + size - src < width)
 
  435                                 dst, 1, src, 0, width, 0);
 
  438                 for (i = 0; i < 
width; i++)
 
  444             for (pixels = 0; pixels < 
width;) {
 
  445                 if (ssrc + size - src < 2) {
 
  452                     if (pixels + code > width ||
 
  453                         ssrc + size - src < code) {
 
  455                                "Copy went out of bounds\n");
 
  459                                     dst, 1, src, 0, code, pixels);
 
  462                 } 
else if (code != -128) { 
 
  464                     if (pixels + code > width) {
 
  466                                "Run went out of bounds\n");
 
  471                                     dst, 0, NULL, c, code, pixels);
 
  477                 for (i = 0; i < 
width; i++)
 
  483             if (pixels < width) {
 
  545                "This format is not supported (bpp=%d, bppcount=%d)\n",
 
  561             pal = (uint32_t *) frame->
f->
data[1];
 
  562             for (i = 0; i < 1<<s->
bpp; i++)
 
  563                 pal[i] = 0xFFU << 24 | i * 255 / ((1<<s->
bpp) - 1) * 0x010101;
 
  572     int i, j, k, pos, 
start;
 
  610                    "This format is not supported (bpp=%d, %d components)\n",
 
  624                 for (i = 0; i < 
count; i++)
 
  635                    "Samples per pixel requires a single value, many provided\n");
 
  640                    "Samples per pixel %d is too large\n", value);
 
  679         if (type == 
TIFF_LONG && value == UINT_MAX)
 
  683                    "Incorrect value of rows per strip\n");
 
  700                    "Tag referencing position outside the image\n");
 
  716                    "Tag referencing position outside the image\n");
 
  750                    "Unknown FillOrder value %d, trying default one\n", value);
 
  761         for (k = 2; k >= 0; k--) {
 
  762             for (i = 0; i < count / 3; i++) {
 
  764                     pal[i] = 0xFF
U << 24;
 
  782 #define ADD_METADATA(count, name, sep)\ 
  783     if ((ret = add_metadata(count, type, name, sep, s, frame)) < 0) {\ 
  784         av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\ 
  826         if (count >= INT_MAX / 
sizeof(int64_t))
 
  835         for (i = 0; i < 
count; i++)
 
  916                    "Unknown or unsupported tag %d/0X%0X\n",
 
  933     int le, 
ret, plane, planes;
 
  934     int i, j, entries, stride;
 
  935     unsigned soff, ssize;
 
  946     } 
else if (off >= UINT_MAX - 14 || avpkt->
size < off + 14) {
 
  965     for (i = 0; i < entries; i++) {
 
 1017     for (plane = 0; plane < planes; plane++) {
 
 1019         dst    = p->
data[plane];
 
 1020     for (i = 0; i < s->
height; i += s->
rps) {
 
 1031         if (soff > avpkt->
size || ssize > avpkt->
size - soff) {
 
 1041         dst += s->
rps * stride;
 
 1044         dst   = p->
data[plane];
 
 1048         ssize = s->
width * soff;
 
 1053             for (i = 0; i < s->
height; i++) {
 
 1054                 for (j = soff; j < ssize; j += 2)
 
 1062             for (i = 0; i < s->
height; i++) {
 
 1063                 for (j = soff; j < ssize; j += 2)
 
 1068             for (i = 0; i < s->
height; i++) {
 
 1069                 for (j = soff; j < ssize; j++)
 
 1070                     dst[j] += dst[j - soff];
 
 1077         dst = p->
data[plane];
 
 1078         for (i = 0; i < s->
height; i++) {
 
 1079             for (j = 0; j < p->
linesize[plane]; j++)