1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avoid buf_size == 0 checks in every decoder

Originally committed as revision 3872 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2005-01-23 18:09:06 +00:00
parent 884182b383
commit 934982c4ac
35 changed files with 24 additions and 148 deletions

View File

@ -605,11 +605,6 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame *p, temp;
int i, frame_4cc, frame_size;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
frame_4cc= get32(buf);
if(buf_size != get32(buf+4)+8){
av_log(f->avctx, AV_LOG_ERROR, "size missmatch %d %d\n", buf_size, get32(buf+4));

View File

@ -70,11 +70,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
unsigned int planes = c->planes;
unsigned char *planemap = c->planemap;
/* no supplementary picture */
if (buf_size == 0)
return 0;
if(c->pic.data[0])
avctx->release_buffer(avctx, &c->pic);

View File

@ -409,11 +409,6 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame * const p= (AVFrame*)&a->picture;
int mb_x, mb_y;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
if(p->data[0])
avctx->release_buffer(avctx, p);

View File

@ -338,7 +338,10 @@ extern int motion_estimation_method;
#define CODEC_CAP_TRUNCATED 0x0008
/* codec can export data for HW decoding (XvMC) */
#define CODEC_CAP_HWACCEL 0x0010
/** codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data */
/**
* codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data.
* if this is not set, the codec is guranteed to never be feeded with NULL data
*/
#define CODEC_CAP_DELAY 0x0020
//the following defines might change, so dont expect compatibility if u use them

View File

@ -43,11 +43,6 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame * const p= (AVFrame*)&a->picture;
int x, y;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
if(p->data[0])
avctx->release_buffer(avctx, p);

View File

@ -888,10 +888,6 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
{
DVVideoContext *s = avctx->priv_data;
/* special case for last picture */
if(buf_size==0)
return 0;
s->sys = dv_frame_profile(buf);
if (!s->sys || buf_size < s->sys->frame_size)
return -1; /* NOTE: we only accept several full frames */

View File

@ -952,10 +952,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
AVFrame *picture = data;
/* no supplementary picture */
if (buf_size == 0)
return 0;
ff_init_range_decoder(c, buf, buf_size);
ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);

View File

@ -925,11 +925,6 @@ static int h261_decode_frame(AVCodecContext *avctx,
s->flags= avctx->flags;
s->flags2= avctx->flags2;
/* no supplementary picture */
if (buf_size == 0) {
return 0;
}
h->gob_start_code_skipped=0;
retry:

View File

@ -793,7 +793,7 @@ AVCodec mpeg4_decoder = {
NULL,
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.options = mpeg4_decoptions,
.flush= ff_mpeg_flush,
};
@ -807,7 +807,7 @@ AVCodec h263_decoder = {
NULL,
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.flush= ff_mpeg_flush,
};

View File

@ -6592,7 +6592,7 @@ AVCodec h264_decoder = {
NULL,
decode_end,
decode_frame,
/*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
/*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
};
AVCodecParser h264_parser = {

View File

@ -770,10 +770,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
AVFrame *picture = data;
/* no supplementary picture */
if (buf_size == 0)
return 0;
s->bitstream_buffer= av_fast_realloc(s->bitstream_buffer, &s->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
s->dsp.bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4);

View File

@ -1066,11 +1066,6 @@ static int indeo3_decode_frame(AVCodecContext *avctx,
unsigned char *src, *dest;
int y;
/* no supplementary picture */
if (buf_size == 0) {
return 0;
}
iv_decode_frame(s, buf, buf_size);
if(s->frame.data[0])

View File

@ -214,10 +214,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
#endif
unsigned int len = buf_size;
/* no supplementary picture */
if (buf_size == 0)
return 0;
if(c->pic.data[0])
avctx->release_buffer(avctx, &c->pic);

View File

@ -163,11 +163,6 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame * const p= (AVFrame*)&a->picture;
int i;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
if(p->data[0])
avctx->release_buffer(avctx, p);

View File

@ -1826,10 +1826,6 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
int start_code;
AVFrame *picture = data;
/* no supplementary picture */
if (buf_size == 0)
return 0;
buf_ptr = buf;
buf_end = buf + buf_size;
while (buf_ptr < buf_end) {
@ -2002,10 +1998,6 @@ static int mjpegb_decode_frame(AVCodecContext *avctx,
uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;
uint32_t field_size, sod_offs;
/* no supplementary picture */
if (buf_size == 0)
return 0;
buf_ptr = buf;
buf_end = buf + buf_size;
@ -2115,10 +2107,6 @@ static int sp5x_decode_frame(AVCodecContext *avctx,
uint8_t *buf_ptr, *buf_end, *recoded;
int i = 0, j = 0;
/* no supplementary picture */
if (buf_size == 0)
return 0;
if (!avctx->width || !avctx->height)
return -1;

View File

@ -3100,7 +3100,7 @@ AVCodec mpeg1video_decoder = {
NULL,
mpeg_decode_end,
mpeg_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.flush= ff_mpeg_flush,
};
@ -3113,7 +3113,7 @@ AVCodec mpeg2video_decoder = {
NULL,
mpeg_decode_end,
mpeg_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.flush= ff_mpeg_flush,
};
@ -3127,7 +3127,7 @@ AVCodec mpegvideo_decoder = {
NULL,
mpeg_decode_end,
mpeg_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.flush= ff_mpeg_flush,
};
@ -3190,7 +3190,7 @@ AVCodec mpeg_xvmc_decoder = {
NULL,
mpeg_decode_end,
mpeg_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED| CODEC_CAP_HWACCEL,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED| CODEC_CAP_HWACCEL | CODEC_CAP_DELAY,
.flush= ff_mpeg_flush,
};

View File

@ -254,10 +254,6 @@ static int msrle_decode_frame(AVCodecContext *avctx,
{
MsrleContext *s = (MsrleContext *)avctx->priv_data;
/* no supplementary picture */
if (buf_size == 0)
return 0;
s->buf = buf;
s->size = buf_size;

View File

@ -302,10 +302,6 @@ static int msvideo1_decode_frame(AVCodecContext *avctx,
{
Msvideo1Context *s = (Msvideo1Context *)avctx->priv_data;
/* no supplementary picture */
if (buf_size == 0)
return 0;
s->buf = buf;
s->size = buf_size;

View File

@ -479,11 +479,6 @@ static int decode_frame(AVCodecContext *avctx,
uint32_t tag, length;
int ret, crc;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
s->bytestream_start=
s->bytestream= buf;
s->bytestream_end= buf + buf_size;

View File

@ -165,11 +165,6 @@ static int pnm_decode_frame(AVCodecContext *avctx,
int i, n, linesize, h;
unsigned char *ptr;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
s->bytestream_start=
s->bytestream= buf;
s->bytestream_end= buf + buf_size;

View File

@ -42,11 +42,6 @@ static int decode_frame(AVCodecContext *avctx,
int colors;
int i;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
if(p->data[0])
avctx->release_buffer(avctx, p);

View File

@ -237,11 +237,6 @@ static int decode_frame(AVCodecContext *avctx,
uint8_t* outdata;
int delta;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
if(p->data[0])
avctx->release_buffer(avctx, p);

View File

@ -530,10 +530,6 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
{
QtrleContext *s = (QtrleContext *)avctx->priv_data;
/* no supplementary picture */
if (buf_size == 0)
return 0;
s->buf = buf;
s->size = buf_size;

View File

@ -248,10 +248,6 @@ static int rpza_decode_frame(AVCodecContext *avctx,
{
RpzaContext *s = (RpzaContext *)avctx->priv_data;
/* no supplementary picture */
if (buf_size == 0)
return 0;
s->buf = buf;
s->size = buf_size;

View File

@ -763,7 +763,7 @@ AVCodec rv20_decoder = {
NULL,
rv10_decode_end,
rv10_decode_frame,
CODEC_CAP_DR1,
CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.flush= ff_mpeg_flush,
};

View File

@ -448,10 +448,6 @@ static int smc_decode_frame(AVCodecContext *avctx,
{
SmcContext *s = (SmcContext *)avctx->priv_data;
/* no supplementary picture */
if (buf_size == 0)
return 0;
s->buf = buf;
s->size = buf_size;

View File

@ -2911,11 +2911,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
int bytes_read;
AVFrame *picture = data;
int level, orientation, plane_index;
/* no supplementary picture */
if (buf_size == 0)
return 0;
ff_init_range_decoder(c, buf, buf_size);
ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);

View File

@ -713,10 +713,6 @@ static int svq1_decode_frame(AVCodecContext *avctx,
int result, i, x, y, width, height;
AVFrame *pict = data;
if(buf==NULL && buf_size==0){
return 0;
}
/* initialize bit buffer */
init_get_bits(&s->gb,buf,buf_size*8);

View File

@ -1004,5 +1004,5 @@ AVCodec svq3_decoder = {
NULL,
decode_end,
svq3_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_DELAY,
};

View File

@ -873,10 +873,6 @@ static int truemotion1_decode_frame(AVCodecContext *avctx,
s->buf = buf;
s->size = buf_size;
/* no supplementary picture */
if (buf_size == 0)
return 0;
if (truemotion1_decode_header(s) == -1)
return -1;

View File

@ -155,10 +155,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
#endif
int len = buf_size;
/* no supplementary picture */
if (buf_size == 0)
return 0;
if(c->pic.data[0])
avctx->release_buffer(avctx, &c->pic);

View File

@ -587,13 +587,17 @@ int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
*got_picture_ptr= 0;
if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
return -1;
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
buf, buf_size);
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
buf, buf_size);
emms_c(); //needed to avoid a emms_c() call before every return;
emms_c(); //needed to avoid a emms_c() call before every return;
if (*got_picture_ptr)
avctx->frame_number++;
if (*got_picture_ptr)
avctx->frame_number++;
}else
ret= 0;
return ret;
}

View File

@ -1705,7 +1705,7 @@ AVCodec vc9_decoder = {
NULL,
vc9_decode_end,
vc9_decode_frame,
0,
CODEC_CAP_DELAY,
NULL
};
@ -1718,6 +1718,6 @@ AVCodec wmv3_decoder = {
NULL,
vc9_decode_end,
vc9_decode_frame,
0,
CODEC_CAP_DELAY,
NULL
};

View File

@ -45,11 +45,6 @@ static int decode_frame(AVCodecContext *avctx,
uint8_t *bytestream= buf;
int i, x, y;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
if(p->data[0])
avctx->release_buffer(avctx, p);

View File

@ -48,12 +48,6 @@ static int decode_frame(AVCodecContext *avctx,
int stride;
uint32_t val;
int y0, y1, y2, y3, c0, c1;
/* special case for last picture */
if (buf_size == 0) {
return 0;
}
if(p->data[0])
avctx->release_buffer(avctx, p);