static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s,

                             uint32_t length)

{

    if (length != 13)

        return AVERROR_INVALIDDATA;



    if (s->state & PNG_IDAT) {

        av_log(avctx, AV_LOG_ERROR, "IHDR after IDAT\n");

        return AVERROR_INVALIDDATA;




    if (s->state & PNG_IHDR) {

        av_log(avctx, AV_LOG_ERROR, "Multiple IHDR\n");

        return AVERROR_INVALIDDATA;




    s->width  = s->cur_w = bytestream2_get_be32(&s->gb);

    s->height = s->cur_h = bytestream2_get_be32(&s->gb);

    if (av_image_check_size(s->width, s->height, 0, avctx)) {

        s->cur_w = s->cur_h = s->width = s->height = 0;

        av_log(avctx, AV_LOG_ERROR, "Invalid image size\n");

        return AVERROR_INVALIDDATA;


    s->bit_depth        = bytestream2_get_byte(&s->gb);






    s->color_type       = bytestream2_get_byte(&s->gb);

    s->compression_type = bytestream2_get_byte(&s->gb);

    s->filter_type      = bytestream2_get_byte(&s->gb);

    s->interlace_type   = bytestream2_get_byte(&s->gb);

    bytestream2_skip(&s->gb, 4); /* crc */

    s->state |= PNG_IHDR;

    if (avctx->debug & FF_DEBUG_PICT_INFO)

        av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d "

                "compression_type=%d filter_type=%d interlace_type=%d\n",

                s->width, s->height, s->bit_depth, s->color_type,

                s->compression_type, s->filter_type, s->interlace_type);



    return 0;

error:

    s->cur_w = s->cur_h = s->width = s->height = 0;

    s->bit_depth = 8;

    return AVERROR_INVALIDDATA;

static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s,

                             uint32_t length)

{

    if (length != 13)

        return AVERROR_INVALIDDATA;



    if (s->state & PNG_IDAT) {

        av_log(avctx, AV_LOG_ERROR, "IHDR after IDAT\n");

        return AVERROR_INVALIDDATA;




    if (s->state & PNG_IHDR) {

        av_log(avctx, AV_LOG_ERROR, "Multiple IHDR\n");

        return AVERROR_INVALIDDATA;




    s->width  = s->cur_w = bytestream2_get_be32(&s->gb);

    s->height = s->cur_h = bytestream2_get_be32(&s->gb);

    if (av_image_check_size(s->width, s->height, 0, avctx)) {

        s->cur_w = s->cur_h = s->width = s->height = 0;

        av_log(avctx, AV_LOG_ERROR, "Invalid image size\n");

        return AVERROR_INVALIDDATA;


    s->bit_depth        = bytestream2_get_byte(&s->gb);






    s->color_type       = bytestream2_get_byte(&s->gb);

    s->compression_type = bytestream2_get_byte(&s->gb);

    s->filter_type      = bytestream2_get_byte(&s->gb);

    s->interlace_type   = bytestream2_get_byte(&s->gb);

    bytestream2_skip(&s->gb, 4); 

    s->state |= PNG_IHDR;

    if (avctx->debug & FF_DEBUG_PICT_INFO)

        av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d "

                "compression_type=%d filter_type=%d interlace_type=%d\n",

                s->width, s->height, s->bit_depth, s->color_type,

                s->compression_type, s->filter_type, s->interlace_type);



    return 0;

error:

    s->cur_w = s->cur_h = s->width = s->height = 0;

    s->bit_depth = 8;

    return AVERROR_INVALIDDATA;

static int FUNC_0(AVCodecContext *VAR_0, PNGDecContext *VAR_1,

                             uint32_t VAR_2)

{

    if (VAR_2 != 13)

        return AVERROR_INVALIDDATA;



    if (VAR_1->state & PNG_IDAT) {

        av_log(VAR_0, AV_LOG_ERROR, "IHDR after IDAT\n");

        return AVERROR_INVALIDDATA;




    if (VAR_1->state & PNG_IHDR) {

        av_log(VAR_0, AV_LOG_ERROR, "Multiple IHDR\n");

        return AVERROR_INVALIDDATA;




    VAR_1->width  = VAR_1->cur_w = bytestream2_get_be32(&VAR_1->gb);

    VAR_1->height = VAR_1->cur_h = bytestream2_get_be32(&VAR_1->gb);

    if (av_image_check_size(VAR_1->width, VAR_1->height, 0, VAR_0)) {

        VAR_1->cur_w = VAR_1->cur_h = VAR_1->width = VAR_1->height = 0;

        av_log(VAR_0, AV_LOG_ERROR, "Invalid image size\n");

        return AVERROR_INVALIDDATA;


    VAR_1->bit_depth        = bytestream2_get_byte(&VAR_1->gb);






    VAR_1->color_type       = bytestream2_get_byte(&VAR_1->gb);

    VAR_1->compression_type = bytestream2_get_byte(&VAR_1->gb);

    VAR_1->filter_type      = bytestream2_get_byte(&VAR_1->gb);

    VAR_1->interlace_type   = bytestream2_get_byte(&VAR_1->gb);

    bytestream2_skip(&VAR_1->gb, 4); 

    VAR_1->state |= PNG_IHDR;

    if (VAR_0->debug & FF_DEBUG_PICT_INFO)

        av_log(VAR_0, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d "

                "compression_type=%d filter_type=%d interlace_type=%d\n",

                VAR_1->width, VAR_1->height, VAR_1->bit_depth, VAR_1->color_type,

                VAR_1->compression_type, VAR_1->filter_type, VAR_1->interlace_type);



    return 0;

error:

    VAR_1->cur_w = VAR_1->cur_h = VAR_1->width = VAR_1->height = 0;

    VAR_1->bit_depth = 8;

    return AVERROR_INVALIDDATA;

static int FUNC_0(AVCodecContext *VAR_0, PNGDecContext *VAR_1,
uint32_t VAR_2)
{ if (VAR_2 != 13)
return AVERROR_INVALIDDATA; if (VAR_1->state & PNG_IDAT) { av_log(VAR_0, AV_LOG_ERROR, "IHDR after IDAT\n"); return AVERROR_INVALIDDATA; if (VAR_1->state & PNG_IHDR) { av_log(VAR_0, AV_LOG_ERROR, "Multiple IHDR\n"); return AVERROR_INVALIDDATA; VAR_1->width  = VAR_1->cur_w = bytestream2_get_be32(&VAR_1->gb); VAR_1->height = VAR_1->cur_h = bytestream2_get_be32(&VAR_1->gb); if (av_image_check_size(VAR_1->width, VAR_1->height, 0, VAR_0)) { VAR_1->cur_w = VAR_1->cur_h = VAR_1->width = VAR_1->height = 0; av_log(VAR_0, AV_LOG_ERROR, "Invalid image size\n"); return AVERROR_INVALIDDATA; VAR_1->bit_depth        = bytestream2_get_byte(&VAR_1->gb); VAR_1->color_type       = bytestream2_get_byte(&VAR_1->gb); VAR_1->compression_type = bytestream2_get_byte(&VAR_1->gb); VAR_1->filter_type      = bytestream2_get_byte(&VAR_1->gb); VAR_1->interlace_type   = bytestream2_get_byte(&VAR_1->gb); bytestream2_skip(&VAR_1->gb, 4); VAR_1->state |= PNG_IHDR; if (VAR_0->debug & FF_DEBUG_PICT_INFO)
av_log(VAR_0, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d "
"compression_type=%d filter_type=%d interlace_type=%d\n",
VAR_1->width, VAR_1->height, VAR_1->bit_depth, VAR_1->color_type,
VAR_1->compression_type, VAR_1->filter_type, VAR_1->interlace_type); return 0; error:
VAR_1->cur_w = VAR_1->cur_h = VAR_1->width = VAR_1->height = 0; VAR_1->bit_depth = 8; return AVERROR_INVALIDDATA;