History

Merge commit '541427ab4d5b4b6f5a90a687a06decdb78e7bc3c'

* commit '541427ab4d5b4b6f5a90a687a06decdb78e7bc3c': eamad: use the bytestream2 API instead of AV_RL Conflicts: libavcodec/eamad.c

Michael Niedermayer committed 12 years ago

Commit c2ef8442 parents c437765 541427a1 file · +22 −19Browse files

Unified · Split

libavcodec/eamad.c+22−19
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 */
3030
3131 #include "avcodec.h"
32+#include "bytestream.h"
3233 #include "bswapdsp.h"
3334 #include "get_bits.h"
3435 #include "aandcttab.h"
@@ -243,30 +244,32 @@ static int decode_frame(AVCodecContext *avctx, · 208 unmodified lines
243244 {
244245 const uint8_t *buf = avpkt->data;
245246 int buf_size = avpkt->size;
246− const uint8_t *buf_end = buf+buf_size;
247247 MadContext *s = avctx->priv_data;
248248 AVFrame *frame = data;
249+ GetByteContext gb;
249250 int width, height;
250251 int chunk_type;
251252 int inter, ret;
252253
253− if (buf_size < 26) {
254− av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
255− *got_frame = 0;
256− return AVERROR_INVALIDDATA;
257− }
254+ bytestream2_init(&gb, buf, buf_size);
258255
259− chunk_type = AV_RL32(&buf[0]);
256+ chunk_type = bytestream2_get_le32(&gb);
260257 inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG);
261− buf += 8;
258+ bytestream2_skip(&gb, 10);
262259
263260 av_reduce(&avctx->time_base.num, &avctx->time_base.den,
264− AV_RL16(&buf[6]), 1000, 1<<30);
261+ bytestream2_get_le16(&gb), 1000, 1<<30);
262+
263+ width = bytestream2_get_le16(&gb);
264+ height = bytestream2_get_le16(&gb);
265+ bytestream2_skip(&gb, 1);
266+ calc_quant_matrix(s, bytestream2_get_byte(&gb));
267+ bytestream2_skip(&gb, 2);
265268
266− width = AV_RL16(&buf[8]);
267− height = AV_RL16(&buf[10]);
268− calc_quant_matrix(s, buf[13]);
269− buf += 16;
269+ if (bytestream2_get_bytes_left(&gb) < 2) {
270+ av_log(avctx, AV_LOG_ERROR, "Input data too small\n");
271+ return AVERROR_INVALIDDATA;
272+ }
270273
271274 if (width < 16 || height < 16) {
272275 av_log(avctx, AV_LOG_ERROR, "Dimensions too small\n");
@@ -275,7 +278,7 @@ static int decode_frame(AVCodecContext *avctx, · 2 unmodified lines
275278
276279 if (avctx->width != width || avctx->height != height) {
277280 av_frame_unref(s->last_frame);
278− if((width * height)/2048*7 > buf_end-buf)
281+ if((width * height)/2048*7 > bytestream2_get_bytes_left(&gb))
279282 return AVERROR_INVALIDDATA;
280283 if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
281284 return ret;
@@ -298,13 +301,13 @@ static int decode_frame(AVCodecContext *avctx, · 16 unmodified lines
298301 }
299302
300303 av_fast_padded_malloc(&s->bitstream_buf, &s->bitstream_buf_size,
301− buf_end - buf);
304+ bytestream2_get_bytes_left(&gb));
302305 if (!s->bitstream_buf)
303306 return AVERROR(ENOMEM);
304− s->bbdsp.bswap16_buf(s->bitstream_buf, (const uint16_t *) buf,
305− (buf_end - buf) / 2);
306− memset((uint8_t*)s->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE);
307− init_get_bits(&s->gb, s->bitstream_buf, 8*(buf_end-buf));
307+ s->bbdsp.bswap16_buf(s->bitstream_buf, (const uint16_t *)(buf + bytestream2_tell(&gb)),
308+ bytestream2_get_bytes_left(&gb) / 2);
309+ memset((uint8_t*)s->bitstream_buf + bytestream2_get_bytes_left(&gb), 0, FF_INPUT_BUFFER_PADDING_SIZE);
310+ init_get_bits(&s->gb, s->bitstream_buf, 8*(bytestream2_get_bytes_left(&gb)));
308311
309312 for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)
310313 for (s->mb_x=0; s->mb_x < (avctx->width +15)/16; s->mb_x++)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t