Browse Source

avoid buf_size == 0 checks in every decoder

Originally committed as revision 3872 to svn://svn.ffmpeg.org/ffmpeg/trunk
tags/v0.5
Michael Niedermayer 21 years ago
parent
commit
934982c4ac
35 changed files with 24 additions and 148 deletions
  1. +0
    -5
      libavcodec/4xm.c
  2. +0
    -5
      libavcodec/8bps.c
  3. +0
    -5
      libavcodec/asv1.c
  4. +4
    -1
      libavcodec/avcodec.h
  5. +0
    -5
      libavcodec/cljr.c
  6. +0
    -4
      libavcodec/dv.c
  7. +0
    -4
      libavcodec/ffv1.c
  8. +0
    -5
      libavcodec/h261.c
  9. +2
    -2
      libavcodec/h263dec.c
  10. +1
    -1
      libavcodec/h264.c
  11. +0
    -4
      libavcodec/huffyuv.c
  12. +0
    -5
      libavcodec/indeo3.c
  13. +0
    -4
      libavcodec/lcl.c
  14. +0
    -5
      libavcodec/mdec.c
  15. +0
    -12
      libavcodec/mjpeg.c
  16. +4
    -4
      libavcodec/mpeg12.c
  17. +0
    -4
      libavcodec/msrle.c
  18. +0
    -4
      libavcodec/msvideo1.c
  19. +0
    -5
      libavcodec/png.c
  20. +0
    -5
      libavcodec/pnm.c
  21. +0
    -5
      libavcodec/qdrw.c
  22. +0
    -5
      libavcodec/qpeg.c
  23. +0
    -4
      libavcodec/qtrle.c
  24. +0
    -4
      libavcodec/rpza.c
  25. +1
    -1
      libavcodec/rv10.c
  26. +0
    -4
      libavcodec/smc.c
  27. +0
    -5
      libavcodec/snow.c
  28. +0
    -4
      libavcodec/svq1.c
  29. +1
    -1
      libavcodec/svq3.c
  30. +0
    -4
      libavcodec/truemotion1.c
  31. +0
    -4
      libavcodec/tscc.c
  32. +9
    -5
      libavcodec/utils.c
  33. +2
    -2
      libavcodec/vc9.c
  34. +0
    -5
      libavcodec/vcr1.c
  35. +0
    -6
      libavcodec/xl.c

+ 0
- 5
libavcodec/4xm.c 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));


+ 0
- 5
libavcodec/8bps.c 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);



+ 0
- 5
libavcodec/asv1.c 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);



+ 4
- 1
libavcodec/avcodec.h 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


+ 0
- 5
libavcodec/cljr.c 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);



+ 0
- 4
libavcodec/dv.c 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 */


+ 0
- 4
libavcodec/ffv1.c 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);



+ 0
- 5
libavcodec/h261.c 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:


+ 2
- 2
libavcodec/h263dec.c 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,
};



+ 1
- 1
libavcodec/h264.c 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 = {


+ 0
- 4
libavcodec/huffyuv.c 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);


+ 0
- 5
libavcodec/indeo3.c 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])


+ 0
- 4
libavcodec/lcl.c 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);



+ 0
- 5
libavcodec/mdec.c 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);



+ 0
- 12
libavcodec/mjpeg.c 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;



+ 4
- 4
libavcodec/mpeg12.c 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,
};



+ 0
- 4
libavcodec/msrle.c 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;



+ 0
- 4
libavcodec/msvideo1.c 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;



+ 0
- 5
libavcodec/png.c 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;


+ 0
- 5
libavcodec/pnm.c 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;


+ 0
- 5
libavcodec/qdrw.c 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);



+ 0
- 5
libavcodec/qpeg.c 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);



+ 0
- 4
libavcodec/qtrle.c 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;



+ 0
- 4
libavcodec/rpza.c 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;



+ 1
- 1
libavcodec/rv10.c 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,
};


+ 0
- 4
libavcodec/smc.c 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;



+ 0
- 5
libavcodec/snow.c 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);


+ 0
- 4
libavcodec/svq1.c 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);



+ 1
- 1
libavcodec/svq3.c 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,
};

+ 0
- 4
libavcodec/truemotion1.c 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;



+ 0
- 4
libavcodec/tscc.c 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);



+ 9
- 5
libavcodec/utils.c 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;
}



+ 2
- 2
libavcodec/vc9.c 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
};

+ 0
- 5
libavcodec/vcr1.c 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);



+ 0
- 6
libavcodec/xl.c 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);


Loading…
Cancel
Save