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
29 */29 */
30 30
31#include "avcodec.h"31#include "avcodec.h"
32#include "bytestream.h"
32#include "bswapdsp.h"33#include "bswapdsp.h"
33#include "get_bits.h"34#include "get_bits.h"
34#include "aandcttab.h"35#include "aandcttab.h"
@@ -243,30 +244,32 @@ static int decode_frame(AVCodecContext *avctx, · 208 unmodified lines
243{244{
244 const uint8_t *buf = avpkt->data;245 const uint8_t *buf = avpkt->data;
245 int buf_size = avpkt->size;246 int buf_size = avpkt->size;
246 const uint8_t *buf_end = buf+buf_size;
247 MadContext *s = avctx->priv_data;247 MadContext *s = avctx->priv_data;
248 AVFrame *frame = data;248 AVFrame *frame = data;
249 GetByteContext gb;
249 int width, height;250 int width, height;
250 int chunk_type;251 int chunk_type;
251 int inter, ret;252 int inter, ret;
252 253
253 if (buf_size < 26) {254 bytestream2_init(&gb, buf, buf_size);
254 av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
255 *got_frame = 0;
256 return AVERROR_INVALIDDATA;
257 }
258 255
259 chunk_type = AV_RL32(&buf[0]);256 chunk_type = bytestream2_get_le32(&gb);
260 inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG);257 inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG);
261 buf += 8;258 bytestream2_skip(&gb, 10);
262 259
263 av_reduce(&avctx->time_base.num, &avctx->time_base.den,260 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);
265 268
266 width = AV_RL16(&buf[8]);269 if (bytestream2_get_bytes_left(&gb) < 2) {
267 height = AV_RL16(&buf[10]);270 av_log(avctx, AV_LOG_ERROR, "Input data too small\n");
268 calc_quant_matrix(s, buf[13]);271 return AVERROR_INVALIDDATA;
269 buf += 16;272 }
270 273
271 if (width < 16 || height < 16) {274 if (width < 16 || height < 16) {
272 av_log(avctx, AV_LOG_ERROR, "Dimensions too small\n");275 av_log(avctx, AV_LOG_ERROR, "Dimensions too small\n");
@@ -275,7 +278,7 @@ static int decode_frame(AVCodecContext *avctx, · 2 unmodified lines
275 278
276 if (avctx->width != width || avctx->height != height) {279 if (avctx->width != width || avctx->height != height) {
277 av_frame_unref(s->last_frame);280 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))
279 return AVERROR_INVALIDDATA;282 return AVERROR_INVALIDDATA;
280 if ((ret = ff_set_dimensions(avctx, width, height)) < 0)283 if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
281 return ret;284 return ret;
@@ -298,13 +301,13 @@ static int decode_frame(AVCodecContext *avctx, · 16 unmodified lines
298 }301 }
299 302
300 av_fast_padded_malloc(&s->bitstream_buf, &s->bitstream_buf_size,303 av_fast_padded_malloc(&s->bitstream_buf, &s->bitstream_buf_size,
301 buf_end - buf);304 bytestream2_get_bytes_left(&gb));
302 if (!s->bitstream_buf)305 if (!s->bitstream_buf)
303 return AVERROR(ENOMEM);306 return AVERROR(ENOMEM);
304 s->bbdsp.bswap16_buf(s->bitstream_buf, (const uint16_t *) buf,307 s->bbdsp.bswap16_buf(s->bitstream_buf, (const uint16_t *)(buf + bytestream2_tell(&gb)),
305 (buf_end - buf) / 2);308 bytestream2_get_bytes_left(&gb) / 2);
306 memset((uint8_t*)s->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE);309 memset((uint8_t*)s->bitstream_buf + bytestream2_get_bytes_left(&gb), 0, FF_INPUT_BUFFER_PADDING_SIZE);
307 init_get_bits(&s->gb, s->bitstream_buf, 8*(buf_end-buf));310 init_get_bits(&s->gb, s->bitstream_buf, 8*(bytestream2_get_bytes_left(&gb)));
308 311
309 for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)312 for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)
310 for (s->mb_x=0; s->mb_x < (avctx->width +15)/16; s->mb_x++)313 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