# HG changeset patch # User michael # Date 1106503746 0 # Node ID f67b63ed036dfb252e232e0ca7a3490c67812647 # Parent 73a66a4a6ab4c9371f424ac5c6d33d27a2142b21 avoid buf_size == 0 checks in every decoder diff -r 73a66a4a6ab4 -r f67b63ed036d 4xm.c --- a/4xm.c Sun Jan 23 17:59:01 2005 +0000 +++ b/4xm.c Sun Jan 23 18:09:06 2005 +0000 @@ -605,11 +605,6 @@ 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)); diff -r 73a66a4a6ab4 -r f67b63ed036d 8bps.c --- a/8bps.c Sun Jan 23 17:59:01 2005 +0000 +++ b/8bps.c Sun Jan 23 18:09:06 2005 +0000 @@ -70,11 +70,6 @@ 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); diff -r 73a66a4a6ab4 -r f67b63ed036d asv1.c --- a/asv1.c Sun Jan 23 17:59:01 2005 +0000 +++ b/asv1.c Sun Jan 23 18:09:06 2005 +0000 @@ -409,11 +409,6 @@ 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); diff -r 73a66a4a6ab4 -r f67b63ed036d avcodec.h --- a/avcodec.h Sun Jan 23 17:59:01 2005 +0000 +++ b/avcodec.h Sun Jan 23 18:09:06 2005 +0000 @@ -338,7 +338,10 @@ #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 diff -r 73a66a4a6ab4 -r f67b63ed036d cljr.c --- a/cljr.c Sun Jan 23 17:59:01 2005 +0000 +++ b/cljr.c Sun Jan 23 18:09:06 2005 +0000 @@ -43,11 +43,6 @@ 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); diff -r 73a66a4a6ab4 -r f67b63ed036d dv.c --- a/dv.c Sun Jan 23 17:59:01 2005 +0000 +++ b/dv.c Sun Jan 23 18:09:06 2005 +0000 @@ -888,10 +888,6 @@ { 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 */ diff -r 73a66a4a6ab4 -r f67b63ed036d ffv1.c --- a/ffv1.c Sun Jan 23 17:59:01 2005 +0000 +++ b/ffv1.c Sun Jan 23 18:09:06 2005 +0000 @@ -952,10 +952,6 @@ 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); diff -r 73a66a4a6ab4 -r f67b63ed036d h261.c --- a/h261.c Sun Jan 23 17:59:01 2005 +0000 +++ b/h261.c Sun Jan 23 18:09:06 2005 +0000 @@ -925,11 +925,6 @@ s->flags= avctx->flags; s->flags2= avctx->flags2; - /* no supplementary picture */ - if (buf_size == 0) { - return 0; - } - h->gob_start_code_skipped=0; retry: diff -r 73a66a4a6ab4 -r f67b63ed036d h263dec.c --- a/h263dec.c Sun Jan 23 17:59:01 2005 +0000 +++ b/h263dec.c Sun Jan 23 18:09:06 2005 +0000 @@ -793,7 +793,7 @@ 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 @@ 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, }; diff -r 73a66a4a6ab4 -r f67b63ed036d h264.c --- a/h264.c Sun Jan 23 17:59:01 2005 +0000 +++ b/h264.c Sun Jan 23 18:09:06 2005 +0000 @@ -6592,7 +6592,7 @@ 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 = { diff -r 73a66a4a6ab4 -r f67b63ed036d huffyuv.c --- a/huffyuv.c Sun Jan 23 17:59:01 2005 +0000 +++ b/huffyuv.c Sun Jan 23 18:09:06 2005 +0000 @@ -770,10 +770,6 @@ 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); diff -r 73a66a4a6ab4 -r f67b63ed036d indeo3.c --- a/indeo3.c Sun Jan 23 17:59:01 2005 +0000 +++ b/indeo3.c Sun Jan 23 18:09:06 2005 +0000 @@ -1066,11 +1066,6 @@ 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]) diff -r 73a66a4a6ab4 -r f67b63ed036d lcl.c --- a/lcl.c Sun Jan 23 17:59:01 2005 +0000 +++ b/lcl.c Sun Jan 23 18:09:06 2005 +0000 @@ -214,10 +214,6 @@ #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); diff -r 73a66a4a6ab4 -r f67b63ed036d mdec.c --- a/mdec.c Sun Jan 23 17:59:01 2005 +0000 +++ b/mdec.c Sun Jan 23 18:09:06 2005 +0000 @@ -163,11 +163,6 @@ 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); diff -r 73a66a4a6ab4 -r f67b63ed036d mjpeg.c --- a/mjpeg.c Sun Jan 23 17:59:01 2005 +0000 +++ b/mjpeg.c Sun Jan 23 18:09:06 2005 +0000 @@ -1826,10 +1826,6 @@ 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 @@ 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 @@ 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; diff -r 73a66a4a6ab4 -r f67b63ed036d mpeg12.c --- a/mpeg12.c Sun Jan 23 17:59:01 2005 +0000 +++ b/mpeg12.c Sun Jan 23 18:09:06 2005 +0000 @@ -3100,7 +3100,7 @@ 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 @@ 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 @@ 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 @@ 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, }; diff -r 73a66a4a6ab4 -r f67b63ed036d msrle.c --- a/msrle.c Sun Jan 23 17:59:01 2005 +0000 +++ b/msrle.c Sun Jan 23 18:09:06 2005 +0000 @@ -254,10 +254,6 @@ { MsrleContext *s = (MsrleContext *)avctx->priv_data; - /* no supplementary picture */ - if (buf_size == 0) - return 0; - s->buf = buf; s->size = buf_size; diff -r 73a66a4a6ab4 -r f67b63ed036d msvideo1.c --- a/msvideo1.c Sun Jan 23 17:59:01 2005 +0000 +++ b/msvideo1.c Sun Jan 23 18:09:06 2005 +0000 @@ -302,10 +302,6 @@ { Msvideo1Context *s = (Msvideo1Context *)avctx->priv_data; - /* no supplementary picture */ - if (buf_size == 0) - return 0; - s->buf = buf; s->size = buf_size; diff -r 73a66a4a6ab4 -r f67b63ed036d png.c --- a/png.c Sun Jan 23 17:59:01 2005 +0000 +++ b/png.c Sun Jan 23 18:09:06 2005 +0000 @@ -479,11 +479,6 @@ 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; diff -r 73a66a4a6ab4 -r f67b63ed036d pnm.c --- a/pnm.c Sun Jan 23 17:59:01 2005 +0000 +++ b/pnm.c Sun Jan 23 18:09:06 2005 +0000 @@ -165,11 +165,6 @@ 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; diff -r 73a66a4a6ab4 -r f67b63ed036d qdrw.c --- a/qdrw.c Sun Jan 23 17:59:01 2005 +0000 +++ b/qdrw.c Sun Jan 23 18:09:06 2005 +0000 @@ -42,11 +42,6 @@ int colors; int i; - /* special case for last picture */ - if (buf_size == 0) { - return 0; - } - if(p->data[0]) avctx->release_buffer(avctx, p); diff -r 73a66a4a6ab4 -r f67b63ed036d qpeg.c --- a/qpeg.c Sun Jan 23 17:59:01 2005 +0000 +++ b/qpeg.c Sun Jan 23 18:09:06 2005 +0000 @@ -237,11 +237,6 @@ 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); diff -r 73a66a4a6ab4 -r f67b63ed036d qtrle.c --- a/qtrle.c Sun Jan 23 17:59:01 2005 +0000 +++ b/qtrle.c Sun Jan 23 18:09:06 2005 +0000 @@ -530,10 +530,6 @@ { QtrleContext *s = (QtrleContext *)avctx->priv_data; - /* no supplementary picture */ - if (buf_size == 0) - return 0; - s->buf = buf; s->size = buf_size; diff -r 73a66a4a6ab4 -r f67b63ed036d rpza.c --- a/rpza.c Sun Jan 23 17:59:01 2005 +0000 +++ b/rpza.c Sun Jan 23 18:09:06 2005 +0000 @@ -248,10 +248,6 @@ { RpzaContext *s = (RpzaContext *)avctx->priv_data; - /* no supplementary picture */ - if (buf_size == 0) - return 0; - s->buf = buf; s->size = buf_size; diff -r 73a66a4a6ab4 -r f67b63ed036d rv10.c --- a/rv10.c Sun Jan 23 17:59:01 2005 +0000 +++ b/rv10.c Sun Jan 23 18:09:06 2005 +0000 @@ -763,7 +763,7 @@ NULL, rv10_decode_end, rv10_decode_frame, - CODEC_CAP_DR1, + CODEC_CAP_DR1 | CODEC_CAP_DELAY, .flush= ff_mpeg_flush, }; diff -r 73a66a4a6ab4 -r f67b63ed036d smc.c --- a/smc.c Sun Jan 23 17:59:01 2005 +0000 +++ b/smc.c Sun Jan 23 18:09:06 2005 +0000 @@ -448,10 +448,6 @@ { SmcContext *s = (SmcContext *)avctx->priv_data; - /* no supplementary picture */ - if (buf_size == 0) - return 0; - s->buf = buf; s->size = buf_size; diff -r 73a66a4a6ab4 -r f67b63ed036d snow.c --- a/snow.c Sun Jan 23 17:59:01 2005 +0000 +++ b/snow.c Sun Jan 23 18:09:06 2005 +0000 @@ -2911,11 +2911,6 @@ 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); diff -r 73a66a4a6ab4 -r f67b63ed036d svq1.c --- a/svq1.c Sun Jan 23 17:59:01 2005 +0000 +++ b/svq1.c Sun Jan 23 18:09:06 2005 +0000 @@ -713,10 +713,6 @@ 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); diff -r 73a66a4a6ab4 -r f67b63ed036d svq3.c --- a/svq3.c Sun Jan 23 17:59:01 2005 +0000 +++ b/svq3.c Sun Jan 23 18:09:06 2005 +0000 @@ -1004,5 +1004,5 @@ 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, }; diff -r 73a66a4a6ab4 -r f67b63ed036d truemotion1.c --- a/truemotion1.c Sun Jan 23 17:59:01 2005 +0000 +++ b/truemotion1.c Sun Jan 23 18:09:06 2005 +0000 @@ -873,10 +873,6 @@ s->buf = buf; s->size = buf_size; - /* no supplementary picture */ - if (buf_size == 0) - return 0; - if (truemotion1_decode_header(s) == -1) return -1; diff -r 73a66a4a6ab4 -r f67b63ed036d tscc.c --- a/tscc.c Sun Jan 23 17:59:01 2005 +0000 +++ b/tscc.c Sun Jan 23 18:09:06 2005 +0000 @@ -155,10 +155,6 @@ #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); diff -r 73a66a4a6ab4 -r f67b63ed036d utils.c --- a/utils.c Sun Jan 23 17:59:01 2005 +0000 +++ b/utils.c Sun Jan 23 18:09:06 2005 +0000 @@ -587,13 +587,17 @@ *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; } diff -r 73a66a4a6ab4 -r f67b63ed036d vc9.c --- a/vc9.c Sun Jan 23 17:59:01 2005 +0000 +++ b/vc9.c Sun Jan 23 18:09:06 2005 +0000 @@ -1705,7 +1705,7 @@ NULL, vc9_decode_end, vc9_decode_frame, - 0, + CODEC_CAP_DELAY, NULL }; @@ -1718,6 +1718,6 @@ NULL, vc9_decode_end, vc9_decode_frame, - 0, + CODEC_CAP_DELAY, NULL }; diff -r 73a66a4a6ab4 -r f67b63ed036d vcr1.c --- a/vcr1.c Sun Jan 23 17:59:01 2005 +0000 +++ b/vcr1.c Sun Jan 23 18:09:06 2005 +0000 @@ -45,11 +45,6 @@ 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); diff -r 73a66a4a6ab4 -r f67b63ed036d xl.c --- a/xl.c Sun Jan 23 17:59:01 2005 +0000 +++ b/xl.c Sun Jan 23 18:09:06 2005 +0000 @@ -48,12 +48,6 @@ 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);