static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt,

                                GetBitContext *gb, int block_size,

                                int width, int height, int x_pos, int y_pos,

                                int blk_idx)

{

    struct FlashSVContext *s = avctx->priv_data;

    uint8_t *line = s->tmpblock;

    int k;

    int ret = inflateReset(&s->zstream);

    if (ret != Z_OK) {

        av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);

        return AVERROR_UNKNOWN;

    }

    if (s->zlibprime_curr || s->zlibprime_prev) {

        ret = flashsv2_prime(s,

                             s->blocks[blk_idx].pos,

                             s->blocks[blk_idx].size);

        if (ret < 0)

            return ret;

    }

    s->zstream.next_in   = avpkt->data + get_bits_count(gb) / 8;

    s->zstream.avail_in  = block_size;

    s->zstream.next_out  = s->tmpblock;

    s->zstream.avail_out = s->block_size * 3;

    ret = inflate(&s->zstream, Z_FINISH);

    if (ret == Z_DATA_ERROR) {

        av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n");

        inflateSync(&s->zstream);

        ret = inflate(&s->zstream, Z_FINISH);

    }



    if (ret != Z_OK && ret != Z_STREAM_END) {

        //return -1;

    }



    if (s->is_keyframe) {

        s->blocks[blk_idx].pos  = s->keyframedata + (get_bits_count(gb) / 8);

        s->blocks[blk_idx].size = block_size;

    }



    y_pos += s->diff_start;



    if (!s->color_depth) {

        /* Flash Screen Video stores the image upside down, so copy

         * lines to destination in reverse order. */

        for (k = 1; k <= s->diff_height; k++) {

            memcpy(s->frame->data[0] + x_pos * 3 +

                   (s->image_height - y_pos - k) * s->frame->linesize[0],

                   line, width * 3);

            /* advance source pointer to next line */

            line += width * 3;

        }

    } else {

        /* hybrid 15-bit/palette mode */

        decode_hybrid(s->tmpblock, s->frame->data[0],

                      s->image_height - (y_pos + 1 + s->diff_height),

                      x_pos, s->diff_height, width,

                      s->frame->linesize[0], s->pal);

    }

    skip_bits_long(gb, 8 * block_size); /* skip the consumed bits */

    return 0;

}

static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt,

                                GetBitContext *gb, int block_size,

                                int width, int height, int x_pos, int y_pos,

                                int blk_idx)

{

    struct FlashSVContext *s = avctx->priv_data;

    uint8_t *line = s->tmpblock;

    int k;

    int ret = inflateReset(&s->zstream);

    if (ret != Z_OK) {

        av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);

        return AVERROR_UNKNOWN;

    }

    if (s->zlibprime_curr || s->zlibprime_prev) {

        ret = flashsv2_prime(s,

                             s->blocks[blk_idx].pos,

                             s->blocks[blk_idx].size);

        if (ret < 0)

            return ret;

    }

    s->zstream.next_in   = avpkt->data + get_bits_count(gb) / 8;

    s->zstream.avail_in  = block_size;

    s->zstream.next_out  = s->tmpblock;

    s->zstream.avail_out = s->block_size * 3;

    ret = inflate(&s->zstream, Z_FINISH);

    if (ret == Z_DATA_ERROR) {

        av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n");

        inflateSync(&s->zstream);

        ret = inflate(&s->zstream, Z_FINISH);

    }



    if (ret != Z_OK && ret != Z_STREAM_END) {

        

    }



    if (s->is_keyframe) {

        s->blocks[blk_idx].pos  = s->keyframedata + (get_bits_count(gb) / 8);

        s->blocks[blk_idx].size = block_size;

    }



    y_pos += s->diff_start;



    if (!s->color_depth) {

        



        for (k = 1; k <= s->diff_height; k++) {

            memcpy(s->frame->data[0] + x_pos * 3 +

                   (s->image_height - y_pos - k) * s->frame->linesize[0],

                   line, width * 3);

            

            line += width * 3;

        }

    } else {

        

        decode_hybrid(s->tmpblock, s->frame->data[0],

                      s->image_height - (y_pos + 1 + s->diff_height),

                      x_pos, s->diff_height, width,

                      s->frame->linesize[0], s->pal);

    }

    skip_bits_long(gb, 8 * block_size); 

    return 0;

}

        decode_hybrid(s->tmpblock, s->frame->data[0],
static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,

                                GetBitContext *VAR_2, int VAR_3,

                                int VAR_4, int VAR_5, int VAR_6, int VAR_7,

                                int VAR_8)

{

    struct FlashSVContext *VAR_9 = VAR_0->priv_data;

    uint8_t *line = VAR_9->tmpblock;

    int VAR_10;

    int VAR_11 = inflateReset(&VAR_9->zstream);

    if (VAR_11 != Z_OK) {

        av_log(VAR_0, AV_LOG_ERROR, "Inflate reset error: %d\n", VAR_11);

        return AVERROR_UNKNOWN;

    }

    if (VAR_9->zlibprime_curr || VAR_9->zlibprime_prev) {

        VAR_11 = flashsv2_prime(VAR_9,

                             VAR_9->blocks[VAR_8].pos,

                             VAR_9->blocks[VAR_8].size);

        if (VAR_11 < 0)

            return VAR_11;

    }

    VAR_9->zstream.next_in   = VAR_1->data + get_bits_count(VAR_2) / 8;

    VAR_9->zstream.avail_in  = VAR_3;

    VAR_9->zstream.next_out  = VAR_9->tmpblock;

    VAR_9->zstream.avail_out = VAR_9->VAR_3 * 3;

    VAR_11 = inflate(&VAR_9->zstream, Z_FINISH);

    if (VAR_11 == Z_DATA_ERROR) {

        av_log(VAR_0, AV_LOG_ERROR, "Zlib resync occurred\n");

        inflateSync(&VAR_9->zstream);

        VAR_11 = inflate(&VAR_9->zstream, Z_FINISH);

    }



    if (VAR_11 != Z_OK && VAR_11 != Z_STREAM_END) {

        

    }



    if (VAR_9->is_keyframe) {

        VAR_9->blocks[VAR_8].pos  = VAR_9->keyframedata + (get_bits_count(VAR_2) / 8);

        VAR_9->blocks[VAR_8].size = VAR_3;

    }



    VAR_7 += VAR_9->diff_start;



    if (!VAR_9->color_depth) {

        



        for (VAR_10 = 1; VAR_10 <= VAR_9->diff_height; VAR_10++) {

            memcpy(VAR_9->frame->data[0] + VAR_6 * 3 +

                   (VAR_9->image_height - VAR_7 - VAR_10) * VAR_9->frame->linesize[0],

                   line, VAR_4 * 3);

            

            line += VAR_4 * 3;

        }

    } else {

        

        decode_hybrid(VAR_9->tmpblock, VAR_9->frame->data[0],

                      VAR_9->image_height - (VAR_7 + 1 + VAR_9->diff_height),

                      VAR_6, VAR_9->diff_height, VAR_4,

                      VAR_9->frame->linesize[0], VAR_9->pal);

    }

    skip_bits_long(VAR_2, 8 * VAR_3); 

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
GetBitContext *VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6, int VAR_7,
int VAR_8)
{ struct FlashSVContext *VAR_9 = VAR_0->priv_data; uint8_t *line = VAR_9->tmpblock; int VAR_10; int VAR_11 = inflateReset(&VAR_9->zstream); if (VAR_11 != Z_OK) { av_log(VAR_0, AV_LOG_ERROR, "Inflate reset error: %d\n", VAR_11); return AVERROR_UNKNOWN; } if (VAR_9->zlibprime_curr || VAR_9->zlibprime_prev) { VAR_11 = flashsv2_prime(VAR_9,
VAR_9->blocks[VAR_8].pos,
VAR_9->blocks[VAR_8].size); if (VAR_11 < 0)
return VAR_11; } VAR_9->zstream.next_in   = VAR_1->data + get_bits_count(VAR_2) / 8; VAR_9->zstream.avail_in  = VAR_3; VAR_9->zstream.next_out  = VAR_9->tmpblock; VAR_9->zstream.avail_out = VAR_9->VAR_3 * 3; VAR_11 = inflate(&VAR_9->zstream, Z_FINISH); if (VAR_11 == Z_DATA_ERROR) { av_log(VAR_0, AV_LOG_ERROR, "Zlib resync occurred\n"); inflateSync(&VAR_9->zstream); VAR_11 = inflate(&VAR_9->zstream, Z_FINISH); } if (VAR_11 != Z_OK && VAR_11 != Z_STREAM_END) { } if (VAR_9->is_keyframe) { VAR_9->blocks[VAR_8].pos  = VAR_9->keyframedata + (get_bits_count(VAR_2) / 8); VAR_9->blocks[VAR_8].size = VAR_3; } VAR_7 += VAR_9->diff_start; if (!VAR_9->color_depth) { for (VAR_10 = 1; VAR_10 <= VAR_9->diff_height; VAR_10++) { memcpy(VAR_9->frame->data[0] + VAR_6 * 3 +
(VAR_9->image_height - VAR_7 - VAR_10) * VAR_9->frame->linesize[0],
line, VAR_4 * 3); line += VAR_4 * 3; } } else { decode_hybrid(VAR_9->tmpblock, VAR_9->frame->data[0],
VAR_9->image_height - (VAR_7 + 1 + VAR_9->diff_height),
VAR_6, VAR_9->diff_height, VAR_4,
VAR_9->frame->linesize[0], VAR_9->pal); } skip_bits_long(VAR_2, 8 * VAR_3); return 0; }