| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Flash Screen Video decoder | 2 * Flash Screen Video decoder |
| 3 * Copyright (C) 2004 Alex Beregszaszi | 3 * Copyright (C) 2004 Alex Beregszaszi |
| 4 * Copyright (C) 2006 Benjamin Larsson | 4 * Copyright (C) 2006 Benjamin Larsson |
| 5 * | 5 * |
| 6 * This file is part of FFmpeg. | 6 * This file is part of FFmpeg. |
| 7 * | 7 * |
| 8 * FFmpeg is free software; you can redistribute it and/or | 8 * FFmpeg is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 { | 106 { |
| 107 const uint8_t *buf = avpkt->data; | 107 const uint8_t *buf = avpkt->data; |
| 108 int buf_size = avpkt->size; | 108 int buf_size = avpkt->size; |
| 109 FlashSVContext *s = avctx->priv_data; | 109 FlashSVContext *s = avctx->priv_data; |
| 110 int h_blocks, v_blocks, h_part, v_part, i, j; | 110 int h_blocks, v_blocks, h_part, v_part, i, j; |
| 111 GetBitContext gb; | 111 GetBitContext gb; |
| 112 | 112 |
| 113 /* no supplementary picture */ | 113 /* no supplementary picture */ |
| 114 if (buf_size == 0) | 114 if (buf_size == 0) |
| 115 return 0; | 115 return 0; |
| 116 if (buf_size < 4) |
| 117 return -1; |
| 116 | 118 |
| 117 init_get_bits(&gb, buf, buf_size * 8); | 119 init_get_bits(&gb, buf, buf_size * 8); |
| 118 | 120 |
| 119 /* start to parse the bitstream */ | 121 /* start to parse the bitstream */ |
| 120 s->block_width = 16* (get_bits(&gb, 4)+1); | 122 s->block_width = 16* (get_bits(&gb, 4)+1); |
| 121 s->image_width = get_bits(&gb,12); | 123 s->image_width = get_bits(&gb,12); |
| 122 s->block_height= 16* (get_bits(&gb, 4)+1); | 124 s->block_height= 16* (get_bits(&gb, 4)+1); |
| 123 s->image_height= get_bits(&gb,12); | 125 s->image_height= get_bits(&gb,12); |
| 124 | 126 |
| 125 /* calculate amount of blocks and the size of the border blocks */ | 127 /* calculate amount of blocks and the size of the border blocks */ |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 176 |
| 175 | 177 |
| 176 /* loop over all block rows */ | 178 /* loop over all block rows */ |
| 177 for (i = 0; i < h_blocks + (h_part?1:0); i++) | 179 for (i = 0; i < h_blocks + (h_part?1:0); i++) |
| 178 { | 180 { |
| 179 int wp = i*s->block_width; // vert position in frame | 181 int wp = i*s->block_width; // vert position in frame |
| 180 int ws = (i<h_blocks)?s->block_width:h_part; // size of block | 182 int ws = (i<h_blocks)?s->block_width:h_part; // size of block |
| 181 | 183 |
| 182 /* get the size of the compressed zlib chunk */ | 184 /* get the size of the compressed zlib chunk */ |
| 183 int size = get_bits(&gb, 16); | 185 int size = get_bits(&gb, 16); |
| 186 if (8 * size > get_bits_left(&gb)) { |
| 187 avctx->release_buffer(avctx, &s->frame); |
| 188 s->frame.data[0] = NULL; |
| 189 return -1; |
| 190 } |
| 184 | 191 |
| 185 if (size == 0) { | 192 if (size == 0) { |
| 186 /* no change, don't do anything */ | 193 /* no change, don't do anything */ |
| 187 } else { | 194 } else { |
| 188 /* decompress block */ | 195 /* decompress block */ |
| 189 int ret = inflateReset(&(s->zstream)); | 196 int ret = inflateReset(&(s->zstream)); |
| 190 if (ret != Z_OK) | 197 if (ret != Z_OK) |
| 191 { | 198 { |
| 192 av_log(avctx, AV_LOG_ERROR, "error in decompression (reset)
of block %dx%d\n", i, j); | 199 av_log(avctx, AV_LOG_ERROR, "error in decompression (reset)
of block %dx%d\n", i, j); |
| 193 /* return -1; */ | 200 /* return -1; */ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 CODEC_ID_FLASHSV, | 256 CODEC_ID_FLASHSV, |
| 250 sizeof(FlashSVContext), | 257 sizeof(FlashSVContext), |
| 251 flashsv_decode_init, | 258 flashsv_decode_init, |
| 252 NULL, | 259 NULL, |
| 253 flashsv_decode_end, | 260 flashsv_decode_end, |
| 254 flashsv_decode_frame, | 261 flashsv_decode_frame, |
| 255 CODEC_CAP_DR1, | 262 CODEC_CAP_DR1, |
| 256 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_NONE}, | 263 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_NONE}, |
| 257 .long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video v1"), | 264 .long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video v1"), |
| 258 }; | 265 }; |
| OLD | NEW |