You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
Merge commit '541427ab4d5b4b6f5a90a687a06decdb78e7bc3c'
* commit '541427ab4d5b4b6f5a90a687a06decdb78e7bc3c': eamad: use the bytestream2 API instead of AV_RL Conflicts: libavcodec/eamad.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "bytestream.h"
|
||||||
#include "bswapdsp.h"
|
#include "bswapdsp.h"
|
||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "aandcttab.h"
|
#include "aandcttab.h"
|
||||||
@@ -243,30 +244,32 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
{
|
{
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
const uint8_t *buf_end = buf+buf_size;
|
|
||||||
MadContext *s = avctx->priv_data;
|
MadContext *s = avctx->priv_data;
|
||||||
AVFrame *frame = data;
|
AVFrame *frame = data;
|
||||||
|
GetByteContext gb;
|
||||||
int width, height;
|
int width, height;
|
||||||
int chunk_type;
|
int chunk_type;
|
||||||
int inter, ret;
|
int inter, ret;
|
||||||
|
|
||||||
if (buf_size < 26) {
|
bytestream2_init(&gb, buf, buf_size);
|
||||||
av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
|
|
||||||
*got_frame = 0;
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
chunk_type = AV_RL32(&buf[0]);
|
chunk_type = bytestream2_get_le32(&gb);
|
||||||
inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG);
|
inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG);
|
||||||
buf += 8;
|
bytestream2_skip(&gb, 10);
|
||||||
|
|
||||||
av_reduce(&avctx->time_base.num, &avctx->time_base.den,
|
av_reduce(&avctx->time_base.num, &avctx->time_base.den,
|
||||||
AV_RL16(&buf[6]), 1000, 1<<30);
|
bytestream2_get_le16(&gb), 1000, 1<<30);
|
||||||
|
|
||||||
width = AV_RL16(&buf[8]);
|
width = bytestream2_get_le16(&gb);
|
||||||
height = AV_RL16(&buf[10]);
|
height = bytestream2_get_le16(&gb);
|
||||||
calc_quant_matrix(s, buf[13]);
|
bytestream2_skip(&gb, 1);
|
||||||
buf += 16;
|
calc_quant_matrix(s, bytestream2_get_byte(&gb));
|
||||||
|
bytestream2_skip(&gb, 2);
|
||||||
|
|
||||||
|
if (bytestream2_get_bytes_left(&gb) < 2) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Input data too small\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
if (width < 16 || height < 16) {
|
if (width < 16 || height < 16) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Dimensions too small\n");
|
av_log(avctx, AV_LOG_ERROR, "Dimensions too small\n");
|
||||||
@@ -275,7 +278,7 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
|
|
||||||
if (avctx->width != width || avctx->height != height) {
|
if (avctx->width != width || avctx->height != height) {
|
||||||
av_frame_unref(s->last_frame);
|
av_frame_unref(s->last_frame);
|
||||||
if((width * height)/2048*7 > buf_end-buf)
|
if((width * height)/2048*7 > bytestream2_get_bytes_left(&gb))
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
|
if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -298,13 +301,13 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
av_fast_padded_malloc(&s->bitstream_buf, &s->bitstream_buf_size,
|
av_fast_padded_malloc(&s->bitstream_buf, &s->bitstream_buf_size,
|
||||||
buf_end - buf);
|
bytestream2_get_bytes_left(&gb));
|
||||||
if (!s->bitstream_buf)
|
if (!s->bitstream_buf)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
s->bbdsp.bswap16_buf(s->bitstream_buf, (const uint16_t *) buf,
|
s->bbdsp.bswap16_buf(s->bitstream_buf, (const uint16_t *)(buf + bytestream2_tell(&gb)),
|
||||||
(buf_end - buf) / 2);
|
bytestream2_get_bytes_left(&gb) / 2);
|
||||||
memset((uint8_t*)s->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
memset((uint8_t*)s->bitstream_buf + bytestream2_get_bytes_left(&gb), 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
init_get_bits(&s->gb, s->bitstream_buf, 8*(buf_end-buf));
|
init_get_bits(&s->gb, s->bitstream_buf, 8*(bytestream2_get_bytes_left(&gb)));
|
||||||
|
|
||||||
for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)
|
for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)
|
||||||
for (s->mb_x=0; s->mb_x < (avctx->width +15)/16; s->mb_x++)
|
for (s->mb_x=0; s->mb_x < (avctx->width +15)/16; s->mb_x++)
|
||||||
|
Reference in New Issue
Block a user