static int tiff_decode_tag(TiffContext *s, const uint8_t *start,

                           const uint8_t *buf, const uint8_t *end_buf)

{

    unsigned tag, type, count, off, value = 0;

    int i, j;

    int ret;

    uint32_t *pal;

    const uint8_t *rp, *gp, *bp;

    double *dp;



    if (end_buf - buf < 12)

        return -1;

    tag = tget_short(&buf, s->le);

    type = tget_short(&buf, s->le);

    count = tget_long(&buf, s->le);

    off = tget_long(&buf, s->le);



    if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {

        av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",

               type);

        return 0;

    }



    if (count == 1) {

        switch (type) {

        case TIFF_BYTE:

        case TIFF_SHORT:

            buf -= 4;

            value = tget(&buf, type, s->le);

            buf = NULL;

            break;

        case TIFF_LONG:

            value = off;

            buf = NULL;

            break;

        case TIFF_STRING:

            if (count <= 4) {

                buf -= 4;

                break;

            }

        default:

            value = UINT_MAX;

            buf = start + off;

        }

    } else {

        if (count <= 4 && type_sizes[type] * count <= 4) {

            buf -= 4;

        } else {

            buf = start + off;

        }

    }



    if (buf && (buf < start || buf > end_buf)) {

        av_log(s->avctx, AV_LOG_ERROR,

               "Tag referencing position outside the image\n");

        return -1;

    }



    switch (tag) {

    case TIFF_WIDTH:

        s->width = value;

        break;

    case TIFF_HEIGHT:

        s->height = value;

        break;

    case TIFF_BPP:

        s->bppcount = count;

        if (count > 4) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "This format is not supported (bpp=%d, %d components)\n",

                   s->bpp, count);

            return -1;

        }

        if (count == 1)

            s->bpp = value;

        else {

            switch (type) {

            case TIFF_BYTE:

                s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +

                         ((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);

                break;

            case TIFF_SHORT:

            case TIFF_LONG:

                s->bpp = 0;

                for (i = 0; i < count && buf < end_buf; i++)

                    s->bpp += tget(&buf, type, s->le);

                break;

            default:

                s->bpp = -1;

            }

        }

        break;

    case TIFF_SAMPLES_PER_PIXEL:

        if (count != 1) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Samples per pixel requires a single value, many provided\n");

            return AVERROR_INVALIDDATA;

        }

        if (s->bppcount == 1)

            s->bpp *= value;

        s->bppcount = value;

        break;

    case TIFF_COMPR:

        s->compr = value;

        s->predictor = 0;

        switch (s->compr) {

        case TIFF_RAW:

        case TIFF_PACKBITS:

        case TIFF_LZW:

        case TIFF_CCITT_RLE:

            break;

        case TIFF_G3:

        case TIFF_G4:

            s->fax_opts = 0;

            break;

        case TIFF_DEFLATE:

        case TIFF_ADOBE_DEFLATE:

#if CONFIG_ZLIB

            break;

#else

            av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");

            return -1;

#endif

        case TIFF_JPEG:

        case TIFF_NEWJPEG:

            av_log(s->avctx, AV_LOG_ERROR,

                   "JPEG compression is not supported\n");

            return -1;

        default:

            av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",

                   s->compr);

            return -1;

        }

        break;

    case TIFF_ROWSPERSTRIP:

        if (type == TIFF_LONG && value == UINT_MAX)

            value = s->avctx->height;

        if (value < 1) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Incorrect value of rows per strip\n");

            return -1;

        }

        s->rps = value;

        break;

    case TIFF_STRIP_OFFS:

        if (count == 1) {

            s->stripdata = NULL;

            s->stripoff = value;

        } else

            s->stripdata = start + off;

        s->strips = count;

        if (s->strips == 1)

            s->rps = s->height;

        s->sot = type;

        if (s->stripdata > end_buf) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Tag referencing position outside the image\n");

            return -1;

        }

        break;

    case TIFF_STRIP_SIZE:

        if (count == 1) {

            s->stripsizes = NULL;

            s->stripsize = value;

            s->strips = 1;

        } else {

            s->stripsizes = start + off;

        }

        s->strips = count;

        s->sstype = type;

        if (s->stripsizes > end_buf) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Tag referencing position outside the image\n");

            return -1;

        }

        break;

    case TIFF_TILE_BYTE_COUNTS:

    case TIFF_TILE_LENGTH:

    case TIFF_TILE_OFFSETS:

    case TIFF_TILE_WIDTH:

        av_log(s->avctx, AV_LOG_ERROR, "Tiled images are not supported\n");

        return AVERROR_PATCHWELCOME;

        break;

    case TIFF_PREDICTOR:

        s->predictor = value;

        break;

    case TIFF_INVERT:

        switch (value) {

        case 0:

            s->invert = 1;

            break;

        case 1:

            s->invert = 0;

            break;

        case 2:

        case 3:

            break;

        default:

            av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",

                   value);

            return -1;

        }

        break;

    case TIFF_FILL_ORDER:

        if (value < 1 || value > 2) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Unknown FillOrder value %d, trying default one\n", value);

            value = 1;

        }

        s->fill_order = value - 1;

        break;

    case TIFF_PAL:

        pal = (uint32_t *) s->palette;

        off = type_sizes[type];

        if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3)

            return -1;

        rp = buf;

        gp = buf + count / 3 * off;

        bp = buf + count / 3 * off * 2;

        off = (type_sizes[type] - 1) << 3;

        for (i = 0; i < count / 3; i++) {

            j = 0xff << 24;

            j |= (tget(&rp, type, s->le) >> off) << 16;

            j |= (tget(&gp, type, s->le) >> off) << 8;

            j |=  tget(&bp, type, s->le) >> off;

            pal[i] = j;

        }

        s->palette_is_set = 1;

        break;

    case TIFF_PLANAR:

        if (value == 2) {

            av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n");

            return -1;

        }

        break;

    case TIFF_T4OPTIONS:

        if (s->compr == TIFF_G3)

            s->fax_opts = value;

        break;

    case TIFF_T6OPTIONS:

        if (s->compr == TIFF_G4)

            s->fax_opts = value;

        break;

#define ADD_METADATA(count, name, sep)\

    if (ret = add_metadata(&buf, count, type, name, sep, s) < 0) {\

        av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\

        return ret;\

    }

    case TIFF_MODEL_PIXEL_SCALE:

        ADD_METADATA(count, "ModelPixelScaleTag", NULL);

        break;

    case TIFF_MODEL_TRANSFORMATION:

        ADD_METADATA(count, "ModelTransformationTag", NULL);

        break;

    case TIFF_MODEL_TIEPOINT:

        ADD_METADATA(count, "ModelTiepointTag", NULL);

        break;

    case TIFF_GEO_KEY_DIRECTORY:

        ADD_METADATA(1, "GeoTIFF_Version", NULL);

        ADD_METADATA(2, "GeoTIFF_Key_Revision", ".");

        s->geotag_count   = tget_short(&buf, s->le);

        if (s->geotag_count > count / 4 - 1) {

            s->geotag_count = count / 4 - 1;

            av_log(s->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n");

        }

        s->geotags = av_mallocz(sizeof(TiffGeoTag) * s->geotag_count);

        if (!s->geotags) {

            av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

            return AVERROR(ENOMEM);

        }

        for (i = 0; i < s->geotag_count; i++) {

            s->geotags[i].key    = tget_short(&buf, s->le);

            s->geotags[i].type   = tget_short(&buf, s->le);

            s->geotags[i].count  = tget_short(&buf, s->le);



            if (!s->geotags[i].type)

                s->geotags[i].val  = get_geokey_val(s->geotags[i].key, tget_short(&buf, s->le));

            else

                s->geotags[i].offset = tget_short(&buf, s->le);

        }

        break;

    case TIFF_GEO_DOUBLE_PARAMS:

        dp = av_malloc(count * sizeof(double));

        if (!dp) {

            av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

            return AVERROR(ENOMEM);

        }

        for (i = 0; i < count; i++)

            dp[i] = tget_double(&buf, s->le);

        for (i = 0; i < s->geotag_count; i++) {

            if (s->geotags[i].type == TIFF_GEO_DOUBLE_PARAMS) {

                if (s->geotags[i].count == 0

                    || s->geotags[i].offset + s->geotags[i].count > count) {

                    av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);

                } else {

                    char *ap = doubles2str(&dp[s->geotags[i].offset], s->geotags[i].count, ", ");

                    if (!ap) {

                        av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

                        av_freep(&dp);

                        return AVERROR(ENOMEM);

                    }

                    s->geotags[i].val = ap;

                }

            }

        }

        av_freep(&dp);

        break;

    case TIFF_GEO_ASCII_PARAMS:

        for (i = 0; i < s->geotag_count; i++) {

            if (s->geotags[i].type == TIFF_GEO_ASCII_PARAMS) {

                if (s->geotags[i].count == 0

                    || s->geotags[i].offset +  s->geotags[i].count > count) {

                    av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);

                } else {

                    char *ap = av_malloc(s->geotags[i].count);

                    if (!ap) {

                        av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

                        return AVERROR(ENOMEM);

                    }

                    memcpy(ap, &buf[s->geotags[i].offset], s->geotags[i].count);

                    ap[s->geotags[i].count - 1] = '\0'; //replace the "|" delimiter with a 0 byte

                    s->geotags[i].val = ap;

                }

            }

        }

        break;

    default:

        av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n",

               tag, tag);

    }

    return 0;

}

static int tiff_decode_tag(TiffContext *s, const uint8_t *start,

                           const uint8_t *buf, const uint8_t *end_buf)

{

    unsigned tag, type, count, off, value = 0;

    int i, j;

    int ret;

    uint32_t *pal;

    const uint8_t *rp, *gp, *bp;

    double *dp;



    if (end_buf - buf < 12)

        return -1;

    tag = tget_short(&buf, s->le);

    type = tget_short(&buf, s->le);

    count = tget_long(&buf, s->le);

    off = tget_long(&buf, s->le);



    if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {

        av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",

               type);

        return 0;

    }



    if (count == 1) {

        switch (type) {

        case TIFF_BYTE:

        case TIFF_SHORT:

            buf -= 4;

            value = tget(&buf, type, s->le);

            buf = NULL;

            break;

        case TIFF_LONG:

            value = off;

            buf = NULL;

            break;

        case TIFF_STRING:

            if (count <= 4) {

                buf -= 4;

                break;

            }

        default:

            value = UINT_MAX;

            buf = start + off;

        }

    } else {

        if (count <= 4 && type_sizes[type] * count <= 4) {

            buf -= 4;

        } else {

            buf = start + off;

        }

    }



    if (buf && (buf < start || buf > end_buf)) {

        av_log(s->avctx, AV_LOG_ERROR,

               "Tag referencing position outside the image\n");

        return -1;

    }



    switch (tag) {

    case TIFF_WIDTH:

        s->width = value;

        break;

    case TIFF_HEIGHT:

        s->height = value;

        break;

    case TIFF_BPP:

        s->bppcount = count;

        if (count > 4) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "This format is not supported (bpp=%d, %d components)\n",

                   s->bpp, count);

            return -1;

        }

        if (count == 1)

            s->bpp = value;

        else {

            switch (type) {

            case TIFF_BYTE:

                s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +

                         ((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);

                break;

            case TIFF_SHORT:

            case TIFF_LONG:

                s->bpp = 0;

                for (i = 0; i < count && buf < end_buf; i++)

                    s->bpp += tget(&buf, type, s->le);

                break;

            default:

                s->bpp = -1;

            }

        }

        break;

    case TIFF_SAMPLES_PER_PIXEL:

        if (count != 1) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Samples per pixel requires a single value, many provided\n");

            return AVERROR_INVALIDDATA;

        }

        if (s->bppcount == 1)

            s->bpp *= value;

        s->bppcount = value;

        break;

    case TIFF_COMPR:

        s->compr = value;

        s->predictor = 0;

        switch (s->compr) {

        case TIFF_RAW:

        case TIFF_PACKBITS:

        case TIFF_LZW:

        case TIFF_CCITT_RLE:

            break;

        case TIFF_G3:

        case TIFF_G4:

            s->fax_opts = 0;

            break;

        case TIFF_DEFLATE:

        case TIFF_ADOBE_DEFLATE:

#if CONFIG_ZLIB

            break;

#else

            av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");

            return -1;

#endif

        case TIFF_JPEG:

        case TIFF_NEWJPEG:

            av_log(s->avctx, AV_LOG_ERROR,

                   "JPEG compression is not supported\n");

            return -1;

        default:

            av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",

                   s->compr);

            return -1;

        }

        break;

    case TIFF_ROWSPERSTRIP:

        if (type == TIFF_LONG && value == UINT_MAX)

            value = s->avctx->height;

        if (value < 1) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Incorrect value of rows per strip\n");

            return -1;

        }

        s->rps = value;

        break;

    case TIFF_STRIP_OFFS:

        if (count == 1) {

            s->stripdata = NULL;

            s->stripoff = value;

        } else

            s->stripdata = start + off;

        s->strips = count;

        if (s->strips == 1)

            s->rps = s->height;

        s->sot = type;

        if (s->stripdata > end_buf) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Tag referencing position outside the image\n");

            return -1;

        }

        break;

    case TIFF_STRIP_SIZE:

        if (count == 1) {

            s->stripsizes = NULL;

            s->stripsize = value;

            s->strips = 1;

        } else {

            s->stripsizes = start + off;

        }

        s->strips = count;

        s->sstype = type;

        if (s->stripsizes > end_buf) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Tag referencing position outside the image\n");

            return -1;

        }

        break;

    case TIFF_TILE_BYTE_COUNTS:

    case TIFF_TILE_LENGTH:

    case TIFF_TILE_OFFSETS:

    case TIFF_TILE_WIDTH:

        av_log(s->avctx, AV_LOG_ERROR, "Tiled images are not supported\n");

        return AVERROR_PATCHWELCOME;

        break;

    case TIFF_PREDICTOR:

        s->predictor = value;

        break;

    case TIFF_INVERT:

        switch (value) {

        case 0:

            s->invert = 1;

            break;

        case 1:

            s->invert = 0;

            break;

        case 2:

        case 3:

            break;

        default:

            av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",

                   value);

            return -1;

        }

        break;

    case TIFF_FILL_ORDER:

        if (value < 1 || value > 2) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Unknown FillOrder value %d, trying default one\n", value);

            value = 1;

        }

        s->fill_order = value - 1;

        break;

    case TIFF_PAL:

        pal = (uint32_t *) s->palette;

        off = type_sizes[type];

        if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3)

            return -1;

        rp = buf;

        gp = buf + count / 3 * off;

        bp = buf + count / 3 * off * 2;

        off = (type_sizes[type] - 1) << 3;

        for (i = 0; i < count / 3; i++) {

            j = 0xff << 24;

            j |= (tget(&rp, type, s->le) >> off) << 16;

            j |= (tget(&gp, type, s->le) >> off) << 8;

            j |=  tget(&bp, type, s->le) >> off;

            pal[i] = j;

        }

        s->palette_is_set = 1;

        break;

    case TIFF_PLANAR:

        if (value == 2) {

            av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n");

            return -1;

        }

        break;

    case TIFF_T4OPTIONS:

        if (s->compr == TIFF_G3)

            s->fax_opts = value;

        break;

    case TIFF_T6OPTIONS:

        if (s->compr == TIFF_G4)

            s->fax_opts = value;

        break;

#define ADD_METADATA(count, name, sep)\

    if (ret = add_metadata(&buf, count, type, name, sep, s) < 0) {\

        av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\

        return ret;\

    }

    case TIFF_MODEL_PIXEL_SCALE:

        ADD_METADATA(count, "ModelPixelScaleTag", NULL);

        break;

    case TIFF_MODEL_TRANSFORMATION:

        ADD_METADATA(count, "ModelTransformationTag", NULL);

        break;

    case TIFF_MODEL_TIEPOINT:

        ADD_METADATA(count, "ModelTiepointTag", NULL);

        break;

    case TIFF_GEO_KEY_DIRECTORY:

        ADD_METADATA(1, "GeoTIFF_Version", NULL);

        ADD_METADATA(2, "GeoTIFF_Key_Revision", ".");

        s->geotag_count   = tget_short(&buf, s->le);

        if (s->geotag_count > count / 4 - 1) {

            s->geotag_count = count / 4 - 1;

            av_log(s->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n");

        }

        s->geotags = av_mallocz(sizeof(TiffGeoTag) * s->geotag_count);

        if (!s->geotags) {

            av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

            return AVERROR(ENOMEM);

        }

        for (i = 0; i < s->geotag_count; i++) {

            s->geotags[i].key    = tget_short(&buf, s->le);

            s->geotags[i].type   = tget_short(&buf, s->le);

            s->geotags[i].count  = tget_short(&buf, s->le);



            if (!s->geotags[i].type)

                s->geotags[i].val  = get_geokey_val(s->geotags[i].key, tget_short(&buf, s->le));

            else

                s->geotags[i].offset = tget_short(&buf, s->le);

        }

        break;

    case TIFF_GEO_DOUBLE_PARAMS:

        dp = av_malloc(count * sizeof(double));

        if (!dp) {

            av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

            return AVERROR(ENOMEM);

        }

        for (i = 0; i < count; i++)

            dp[i] = tget_double(&buf, s->le);

        for (i = 0; i < s->geotag_count; i++) {

            if (s->geotags[i].type == TIFF_GEO_DOUBLE_PARAMS) {

                if (s->geotags[i].count == 0

                    || s->geotags[i].offset + s->geotags[i].count > count) {

                    av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);

                } else {

                    char *ap = doubles2str(&dp[s->geotags[i].offset], s->geotags[i].count, ", ");

                    if (!ap) {

                        av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

                        av_freep(&dp);

                        return AVERROR(ENOMEM);

                    }

                    s->geotags[i].val = ap;

                }

            }

        }

        av_freep(&dp);

        break;

    case TIFF_GEO_ASCII_PARAMS:

        for (i = 0; i < s->geotag_count; i++) {

            if (s->geotags[i].type == TIFF_GEO_ASCII_PARAMS) {

                if (s->geotags[i].count == 0

                    || s->geotags[i].offset +  s->geotags[i].count > count) {

                    av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);

                } else {

                    char *ap = av_malloc(s->geotags[i].count);

                    if (!ap) {

                        av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

                        return AVERROR(ENOMEM);

                    }

                    memcpy(ap, &buf[s->geotags[i].offset], s->geotags[i].count);

                    ap[s->geotags[i].count - 1] = '\0'; 

                    s->geotags[i].val = ap;

                }

            }

        }

        break;

    default:

        av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n",

               tag, tag);

    }

    return 0;

}

static int FUNC_0(TiffContext *VAR_0, const uint8_t *VAR_1,

                           const uint8_t *VAR_2, const uint8_t *VAR_3)

{

    unsigned VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0;

    int VAR_9, VAR_10;

    int VAR_11;

    uint32_t *pal;

    const uint8_t *VAR_12, *gp, *bp;

    double *VAR_13;



    if (VAR_3 - VAR_2 < 12)

        return -1;

    VAR_4 = tget_short(&VAR_2, VAR_0->le);

    VAR_5 = tget_short(&VAR_2, VAR_0->le);

    VAR_6 = tget_long(&VAR_2, VAR_0->le);

    VAR_7 = tget_long(&VAR_2, VAR_0->le);



    if (VAR_5 == 0 || VAR_5 >= FF_ARRAY_ELEMS(type_sizes)) {

        av_log(VAR_0->avctx, AV_LOG_DEBUG, "Unknown tiff VAR_5 (%u) encountered\n",

               VAR_5);

        return 0;

    }



    if (VAR_6 == 1) {

        switch (VAR_5) {

        case TIFF_BYTE:

        case TIFF_SHORT:

            VAR_2 -= 4;

            VAR_8 = tget(&VAR_2, VAR_5, VAR_0->le);

            VAR_2 = NULL;

            break;

        case TIFF_LONG:

            VAR_8 = VAR_7;

            VAR_2 = NULL;

            break;

        case TIFF_STRING:

            if (VAR_6 <= 4) {

                VAR_2 -= 4;

                break;

            }

        default:

            VAR_8 = UINT_MAX;

            VAR_2 = VAR_1 + VAR_7;

        }

    } else {

        if (VAR_6 <= 4 && type_sizes[VAR_5] * VAR_6 <= 4) {

            VAR_2 -= 4;

        } else {

            VAR_2 = VAR_1 + VAR_7;

        }

    }



    if (VAR_2 && (VAR_2 < VAR_1 || VAR_2 > VAR_3)) {

        av_log(VAR_0->avctx, AV_LOG_ERROR,

               "Tag referencing position outside the image\n");

        return -1;

    }



    switch (VAR_4) {

    case TIFF_WIDTH:

        VAR_0->width = VAR_8;

        break;

    case TIFF_HEIGHT:

        VAR_0->height = VAR_8;

        break;

    case TIFF_BPP:

        VAR_0->bppcount = VAR_6;

        if (VAR_6 > 4) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "This format is not supported (bpp=%d, %d components)\n",

                   VAR_0->bpp, VAR_6);

            return -1;

        }

        if (VAR_6 == 1)

            VAR_0->bpp = VAR_8;

        else {

            switch (VAR_5) {

            case TIFF_BYTE:

                VAR_0->bpp = (VAR_7 & 0xFF) + ((VAR_7 >> 8) & 0xFF) +

                         ((VAR_7 >> 16) & 0xFF) + ((VAR_7 >> 24) & 0xFF);

                break;

            case TIFF_SHORT:

            case TIFF_LONG:

                VAR_0->bpp = 0;

                for (VAR_9 = 0; VAR_9 < VAR_6 && VAR_2 < VAR_3; VAR_9++)

                    VAR_0->bpp += tget(&VAR_2, VAR_5, VAR_0->le);

                break;

            default:

                VAR_0->bpp = -1;

            }

        }

        break;

    case TIFF_SAMPLES_PER_PIXEL:

        if (VAR_6 != 1) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "Samples per pixel requires a single VAR_8, many provided\n");

            return AVERROR_INVALIDDATA;

        }

        if (VAR_0->bppcount == 1)

            VAR_0->bpp *= VAR_8;

        VAR_0->bppcount = VAR_8;

        break;

    case TIFF_COMPR:

        VAR_0->compr = VAR_8;

        VAR_0->predictor = 0;

        switch (VAR_0->compr) {

        case TIFF_RAW:

        case TIFF_PACKBITS:

        case TIFF_LZW:

        case TIFF_CCITT_RLE:

            break;

        case TIFF_G3:

        case TIFF_G4:

            VAR_0->fax_opts = 0;

            break;

        case TIFF_DEFLATE:

        case TIFF_ADOBE_DEFLATE:

#if CONFIG_ZLIB

            break;

#else

            av_log(VAR_0->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");

            return -1;

#endif

        case TIFF_JPEG:

        case TIFF_NEWJPEG:

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "JPEG compression is not supported\n");

            return -1;

        default:

            av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown compression method %VAR_9\n",

                   VAR_0->compr);

            return -1;

        }

        break;

    case TIFF_ROWSPERSTRIP:

        if (VAR_5 == TIFF_LONG && VAR_8 == UINT_MAX)

            VAR_8 = VAR_0->avctx->height;

        if (VAR_8 < 1) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "Incorrect VAR_8 of rows per strip\n");

            return -1;

        }

        VAR_0->rps = VAR_8;

        break;

    case TIFF_STRIP_OFFS:

        if (VAR_6 == 1) {

            VAR_0->stripdata = NULL;

            VAR_0->stripoff = VAR_8;

        } else

            VAR_0->stripdata = VAR_1 + VAR_7;

        VAR_0->strips = VAR_6;

        if (VAR_0->strips == 1)

            VAR_0->rps = VAR_0->height;

        VAR_0->sot = VAR_5;

        if (VAR_0->stripdata > VAR_3) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "Tag referencing position outside the image\n");

            return -1;

        }

        break;

    case TIFF_STRIP_SIZE:

        if (VAR_6 == 1) {

            VAR_0->stripsizes = NULL;

            VAR_0->stripsize = VAR_8;

            VAR_0->strips = 1;

        } else {

            VAR_0->stripsizes = VAR_1 + VAR_7;

        }

        VAR_0->strips = VAR_6;

        VAR_0->sstype = VAR_5;

        if (VAR_0->stripsizes > VAR_3) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "Tag referencing position outside the image\n");

            return -1;

        }

        break;

    case TIFF_TILE_BYTE_COUNTS:

    case TIFF_TILE_LENGTH:

    case TIFF_TILE_OFFSETS:

    case TIFF_TILE_WIDTH:

        av_log(VAR_0->avctx, AV_LOG_ERROR, "Tiled images are not supported\n");

        return AVERROR_PATCHWELCOME;

        break;

    case TIFF_PREDICTOR:

        VAR_0->predictor = VAR_8;

        break;

    case TIFF_INVERT:

        switch (VAR_8) {

        case 0:

            VAR_0->invert = 1;

            break;

        case 1:

            VAR_0->invert = 0;

            break;

        case 2:

        case 3:

            break;

        default:

            av_log(VAR_0->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",

                   VAR_8);

            return -1;

        }

        break;

    case TIFF_FILL_ORDER:

        if (VAR_8 < 1 || VAR_8 > 2) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "Unknown FillOrder VAR_8 %d, trying default one\n", VAR_8);

            VAR_8 = 1;

        }

        VAR_0->fill_order = VAR_8 - 1;

        break;

    case TIFF_PAL:

        pal = (uint32_t *) VAR_0->palette;

        VAR_7 = type_sizes[VAR_5];

        if (VAR_6 / 3 > 256 || VAR_3 - VAR_2 < VAR_6 / 3 * VAR_7 * 3)

            return -1;

        VAR_12 = VAR_2;

        gp = VAR_2 + VAR_6 / 3 * VAR_7;

        bp = VAR_2 + VAR_6 / 3 * VAR_7 * 2;

        VAR_7 = (type_sizes[VAR_5] - 1) << 3;

        for (VAR_9 = 0; VAR_9 < VAR_6 / 3; VAR_9++) {

            VAR_10 = 0xff << 24;

            VAR_10 |= (tget(&VAR_12, VAR_5, VAR_0->le) >> VAR_7) << 16;

            VAR_10 |= (tget(&gp, VAR_5, VAR_0->le) >> VAR_7) << 8;

            VAR_10 |=  tget(&bp, VAR_5, VAR_0->le) >> VAR_7;

            pal[VAR_9] = VAR_10;

        }

        VAR_0->palette_is_set = 1;

        break;

    case TIFF_PLANAR:

        if (VAR_8 == 2) {

            av_log(VAR_0->avctx, AV_LOG_ERROR, "Planar format is not supported\n");

            return -1;

        }

        break;

    case TIFF_T4OPTIONS:

        if (VAR_0->compr == TIFF_G3)

            VAR_0->fax_opts = VAR_8;

        break;

    case TIFF_T6OPTIONS:

        if (VAR_0->compr == TIFF_G4)

            VAR_0->fax_opts = VAR_8;

        break;

#define ADD_METADATA(VAR_6, name, sep)\

    if (VAR_11 = add_metadata(&VAR_2, VAR_6, VAR_5, name, sep, VAR_0) < 0) {\

        av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\

        return VAR_11;\

    }

    case TIFF_MODEL_PIXEL_SCALE:

        ADD_METADATA(VAR_6, "ModelPixelScaleTag", NULL);

        break;

    case TIFF_MODEL_TRANSFORMATION:

        ADD_METADATA(VAR_6, "ModelTransformationTag", NULL);

        break;

    case TIFF_MODEL_TIEPOINT:

        ADD_METADATA(VAR_6, "ModelTiepointTag", NULL);

        break;

    case TIFF_GEO_KEY_DIRECTORY:

        ADD_METADATA(1, "GeoTIFF_Version", NULL);

        ADD_METADATA(2, "GeoTIFF_Key_Revision", ".");

        VAR_0->geotag_count   = tget_short(&VAR_2, VAR_0->le);

        if (VAR_0->geotag_count > VAR_6 / 4 - 1) {

            VAR_0->geotag_count = VAR_6 / 4 - 1;

            av_log(VAR_0->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n");

        }

        VAR_0->geotags = av_mallocz(sizeof(TiffGeoTag) * VAR_0->geotag_count);

        if (!VAR_0->geotags) {

            av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

            return AVERROR(ENOMEM);

        }

        for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) {

            VAR_0->geotags[VAR_9].key    = tget_short(&VAR_2, VAR_0->le);

            VAR_0->geotags[VAR_9].VAR_5   = tget_short(&VAR_2, VAR_0->le);

            VAR_0->geotags[VAR_9].VAR_6  = tget_short(&VAR_2, VAR_0->le);



            if (!VAR_0->geotags[VAR_9].VAR_5)

                VAR_0->geotags[VAR_9].val  = get_geokey_val(VAR_0->geotags[VAR_9].key, tget_short(&VAR_2, VAR_0->le));

            else

                VAR_0->geotags[VAR_9].offset = tget_short(&VAR_2, VAR_0->le);

        }

        break;

    case TIFF_GEO_DOUBLE_PARAMS:

        VAR_13 = av_malloc(VAR_6 * sizeof(double));

        if (!VAR_13) {

            av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

            return AVERROR(ENOMEM);

        }

        for (VAR_9 = 0; VAR_9 < VAR_6; VAR_9++)

            VAR_13[VAR_9] = tget_double(&VAR_2, VAR_0->le);

        for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) {

            if (VAR_0->geotags[VAR_9].VAR_5 == TIFF_GEO_DOUBLE_PARAMS) {

                if (VAR_0->geotags[VAR_9].VAR_6 == 0

                    || VAR_0->geotags[VAR_9].offset + VAR_0->geotags[VAR_9].VAR_6 > VAR_6) {

                    av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", VAR_0->geotags[VAR_9].key);

                } else {

                    char *ap = doubles2str(&VAR_13[VAR_0->geotags[VAR_9].offset], VAR_0->geotags[VAR_9].VAR_6, ", ");

                    if (!ap) {

                        av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

                        av_freep(&VAR_13);

                        return AVERROR(ENOMEM);

                    }

                    VAR_0->geotags[VAR_9].val = ap;

                }

            }

        }

        av_freep(&VAR_13);

        break;

    case TIFF_GEO_ASCII_PARAMS:

        for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) {

            if (VAR_0->geotags[VAR_9].VAR_5 == TIFF_GEO_ASCII_PARAMS) {

                if (VAR_0->geotags[VAR_9].VAR_6 == 0

                    || VAR_0->geotags[VAR_9].offset +  VAR_0->geotags[VAR_9].VAR_6 > VAR_6) {

                    av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", VAR_0->geotags[VAR_9].key);

                } else {

                    char *ap = av_malloc(VAR_0->geotags[VAR_9].VAR_6);

                    if (!ap) {

                        av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

                        return AVERROR(ENOMEM);

                    }

                    memcpy(ap, &VAR_2[VAR_0->geotags[VAR_9].offset], VAR_0->geotags[VAR_9].VAR_6);

                    ap[VAR_0->geotags[VAR_9].VAR_6 - 1] = '\0'; 

                    VAR_0->geotags[VAR_9].val = ap;

                }

            }

        }

        break;

    default:

        av_log(VAR_0->avctx, AV_LOG_DEBUG, "Unknown or unsupported VAR_4 %d/0X%0X\n",

               VAR_4, VAR_4);

    }

    return 0;

}

static int FUNC_0(TiffContext *VAR_0, const uint8_t *VAR_1,
const uint8_t *VAR_2, const uint8_t *VAR_3)
{ unsigned VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0; int VAR_9, VAR_10; int VAR_11; uint32_t *pal; const uint8_t *VAR_12, *gp, *bp; double *VAR_13; if (VAR_3 - VAR_2 < 12)
return -1; VAR_4 = tget_short(&VAR_2, VAR_0->le); VAR_5 = tget_short(&VAR_2, VAR_0->le); VAR_6 = tget_long(&VAR_2, VAR_0->le); VAR_7 = tget_long(&VAR_2, VAR_0->le); if (VAR_5 == 0 || VAR_5 >= FF_ARRAY_ELEMS(type_sizes)) { av_log(VAR_0->avctx, AV_LOG_DEBUG, "Unknown tiff VAR_5 (%u) encountered\n",
VAR_5); return 0; } if (VAR_6 == 1) { switch (VAR_5) { case TIFF_BYTE:
case TIFF_SHORT:
VAR_2 -= 4; VAR_8 = tget(&VAR_2, VAR_5, VAR_0->le); VAR_2 = NULL; break; case TIFF_LONG:
VAR_8 = VAR_7; VAR_2 = NULL; break; case TIFF_STRING:
if (VAR_6 <= 4) { VAR_2 -= 4; break; } default:
VAR_8 = UINT_MAX; VAR_2 = VAR_1 + VAR_7; } } else { if (VAR_6 <= 4 && type_sizes[VAR_5] * VAR_6 <= 4) { VAR_2 -= 4; } else { VAR_2 = VAR_1 + VAR_7; } } if (VAR_2 && (VAR_2 < VAR_1 || VAR_2 > VAR_3)) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n"); return -1; } switch (VAR_4) { case TIFF_WIDTH:
VAR_0->width = VAR_8; break; case TIFF_HEIGHT:
VAR_0->height = VAR_8; break; case TIFF_BPP:
VAR_0->bppcount = VAR_6; if (VAR_6 > 4) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"This format is not supported (bpp=%d, %d components)\n",
VAR_0->bpp, VAR_6); return -1; } if (VAR_6 == 1)
VAR_0->bpp = VAR_8; else { switch (VAR_5) { case TIFF_BYTE:
VAR_0->bpp = (VAR_7 & 0xFF) + ((VAR_7 >> 8) & 0xFF) +
((VAR_7 >> 16) & 0xFF) + ((VAR_7 >> 24) & 0xFF); break; case TIFF_SHORT:
case TIFF_LONG:
VAR_0->bpp = 0; for (VAR_9 = 0; VAR_9 < VAR_6 && VAR_2 < VAR_3; VAR_9++) VAR_0->bpp += tget(&VAR_2, VAR_5, VAR_0->le); break; default:
VAR_0->bpp = -1; } } break; case TIFF_SAMPLES_PER_PIXEL:
if (VAR_6 != 1) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Samples per pixel requires a single VAR_8, many provided\n"); return AVERROR_INVALIDDATA; } if (VAR_0->bppcount == 1)
VAR_0->bpp *= VAR_8; VAR_0->bppcount = VAR_8; break; case TIFF_COMPR:
VAR_0->compr = VAR_8; VAR_0->predictor = 0; switch (VAR_0->compr) { case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break; case TIFF_G3:
case TIFF_G4:
VAR_0->fax_opts = 0; break; case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break; #else
av_log(VAR_0->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n"); return -1; #endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
av_log(VAR_0->avctx, AV_LOG_ERROR,
"JPEG compression is not supported\n"); return -1; default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown compression method %VAR_9\n",
VAR_0->compr); return -1; } break; case TIFF_ROWSPERSTRIP:
if (VAR_5 == TIFF_LONG && VAR_8 == UINT_MAX)
VAR_8 = VAR_0->avctx->height; if (VAR_8 < 1) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Incorrect VAR_8 of rows per strip\n"); return -1; } VAR_0->rps = VAR_8; break; case TIFF_STRIP_OFFS:
if (VAR_6 == 1) { VAR_0->stripdata = NULL; VAR_0->stripoff = VAR_8; } else VAR_0->stripdata = VAR_1 + VAR_7; VAR_0->strips = VAR_6; if (VAR_0->strips == 1)
VAR_0->rps = VAR_0->height; VAR_0->sot = VAR_5; if (VAR_0->stripdata > VAR_3) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n"); return -1; } break; case TIFF_STRIP_SIZE:
if (VAR_6 == 1) { VAR_0->stripsizes = NULL; VAR_0->stripsize = VAR_8; VAR_0->strips = 1; } else { VAR_0->stripsizes = VAR_1 + VAR_7; } VAR_0->strips = VAR_6; VAR_0->sstype = VAR_5; if (VAR_0->stripsizes > VAR_3) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n"); return -1; } break; case TIFF_TILE_BYTE_COUNTS:
case TIFF_TILE_LENGTH:
case TIFF_TILE_OFFSETS:
case TIFF_TILE_WIDTH:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Tiled images are not supported\n"); return AVERROR_PATCHWELCOME; break; case TIFF_PREDICTOR:
VAR_0->predictor = VAR_8; break; case TIFF_INVERT:
switch (VAR_8) { case 0:
VAR_0->invert = 1; break; case 1:
VAR_0->invert = 0; break; case 2:
case 3:
break; default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
VAR_8); return -1; } break; case TIFF_FILL_ORDER:
if (VAR_8 < 1 || VAR_8 > 2) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Unknown FillOrder VAR_8 %d, trying default one\n", VAR_8); VAR_8 = 1; } VAR_0->fill_order = VAR_8 - 1; break; case TIFF_PAL:
pal = (uint32_t *) VAR_0->palette; VAR_7 = type_sizes[VAR_5]; if (VAR_6 / 3 > 256 || VAR_3 - VAR_2 < VAR_6 / 3 * VAR_7 * 3)
return -1; VAR_12 = VAR_2; gp = VAR_2 + VAR_6 / 3 * VAR_7; bp = VAR_2 + VAR_6 / 3 * VAR_7 * 2; VAR_7 = (type_sizes[VAR_5] - 1) << 3; for (VAR_9 = 0; VAR_9 < VAR_6 / 3; VAR_9++) { VAR_10 = 0xff << 24; VAR_10 |= (tget(&VAR_12, VAR_5, VAR_0->le) >> VAR_7) << 16; VAR_10 |= (tget(&gp, VAR_5, VAR_0->le) >> VAR_7) << 8; VAR_10 |=  tget(&bp, VAR_5, VAR_0->le) >> VAR_7; pal[VAR_9] = VAR_10; } VAR_0->palette_is_set = 1; break; case TIFF_PLANAR:
if (VAR_8 == 2) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Planar format is not supported\n"); return -1; } break; case TIFF_T4OPTIONS:
if (VAR_0->compr == TIFF_G3)
VAR_0->fax_opts = VAR_8; break; case TIFF_T6OPTIONS:
if (VAR_0->compr == TIFF_G4)
VAR_0->fax_opts = VAR_8; break; #define ADD_METADATA(VAR_6, name, sep)\
if (VAR_11 = add_metadata(&VAR_2, VAR_6, VAR_5, name, sep, VAR_0) < 0) {\ av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\ return VAR_11;\ } case TIFF_MODEL_PIXEL_SCALE:
ADD_METADATA(VAR_6, "ModelPixelScaleTag", NULL); break; case TIFF_MODEL_TRANSFORMATION:
ADD_METADATA(VAR_6, "ModelTransformationTag", NULL); break; case TIFF_MODEL_TIEPOINT:
ADD_METADATA(VAR_6, "ModelTiepointTag", NULL); break; case TIFF_GEO_KEY_DIRECTORY:
ADD_METADATA(1, "GeoTIFF_Version", NULL); ADD_METADATA(2, "GeoTIFF_Key_Revision", "."); VAR_0->geotag_count   = tget_short(&VAR_2, VAR_0->le); if (VAR_0->geotag_count > VAR_6 / 4 - 1) { VAR_0->geotag_count = VAR_6 / 4 - 1; av_log(VAR_0->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n"); } VAR_0->geotags = av_mallocz(sizeof(TiffGeoTag) * VAR_0->geotag_count); if (!VAR_0->geotags) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return AVERROR(ENOMEM); } for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) { VAR_0->geotags[VAR_9].key    = tget_short(&VAR_2, VAR_0->le); VAR_0->geotags[VAR_9].VAR_5   = tget_short(&VAR_2, VAR_0->le); VAR_0->geotags[VAR_9].VAR_6  = tget_short(&VAR_2, VAR_0->le); if (!VAR_0->geotags[VAR_9].VAR_5)
VAR_0->geotags[VAR_9].val  = get_geokey_val(VAR_0->geotags[VAR_9].key, tget_short(&VAR_2, VAR_0->le)); else
VAR_0->geotags[VAR_9].offset = tget_short(&VAR_2, VAR_0->le); } break; case TIFF_GEO_DOUBLE_PARAMS:
VAR_13 = av_malloc(VAR_6 * sizeof(double)); if (!VAR_13) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return AVERROR(ENOMEM); } for (VAR_9 = 0; VAR_9 < VAR_6; VAR_9++) VAR_13[VAR_9] = tget_double(&VAR_2, VAR_0->le); for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) { if (VAR_0->geotags[VAR_9].VAR_5 == TIFF_GEO_DOUBLE_PARAMS) { if (VAR_0->geotags[VAR_9].VAR_6 == 0
|| VAR_0->geotags[VAR_9].offset + VAR_0->geotags[VAR_9].VAR_6 > VAR_6) { av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", VAR_0->geotags[VAR_9].key); } else { char *ap = doubles2str(&VAR_13[VAR_0->geotags[VAR_9].offset], VAR_0->geotags[VAR_9].VAR_6, ", "); if (!ap) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); av_freep(&VAR_13); return AVERROR(ENOMEM); } VAR_0->geotags[VAR_9].val = ap; } } } av_freep(&VAR_13); break; case TIFF_GEO_ASCII_PARAMS:
for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) { if (VAR_0->geotags[VAR_9].VAR_5 == TIFF_GEO_ASCII_PARAMS) { if (VAR_0->geotags[VAR_9].VAR_6 == 0
|| VAR_0->geotags[VAR_9].offset +  VAR_0->geotags[VAR_9].VAR_6 > VAR_6) { av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", VAR_0->geotags[VAR_9].key); } else { char *ap = av_malloc(VAR_0->geotags[VAR_9].VAR_6); if (!ap) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return AVERROR(ENOMEM); } memcpy(ap, &VAR_2[VAR_0->geotags[VAR_9].offset], VAR_0->geotags[VAR_9].VAR_6); ap[VAR_0->geotags[VAR_9].VAR_6 - 1] = '\0'; VAR_0->geotags[VAR_9].val = ap; } } } break; default:
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Unknown or unsupported VAR_4 %d/0X%0X\n",
VAR_4, VAR_4); } return 0; }