diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 5cc5f575f0..6932d52ab8 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -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)); diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index 48773a1744..3898ac5dd3 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -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); diff --git a/libavcodec/asv1.c b/libavcodec/asv1.c index 95b15337bf..b8030ef3ab 100644 --- a/libavcodec/asv1.c +++ b/libavcodec/asv1.c @@ -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); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 8cf6500ca3..503a04e083 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -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 diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c index df1f798514..c17316b3e0 100644 --- a/libavcodec/cljr.c +++ b/libavcodec/cljr.c @@ -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); diff --git a/libavcodec/dv.c b/libavcodec/dv.c index f548bffd8b..01e1ce6842 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -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 */ diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index cc15d902b2..737e3f4114 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -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); diff --git a/libavcodec/h261.c b/libavcodec/h261.c index 8536ea9c86..aceebaa381 100644 --- a/libavcodec/h261.c +++ b/libavcodec/h261.c @@ -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: diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index da94aede5a..272780da7a 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -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, }; diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 466257adaa..856b0804a4 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -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 = { diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index fbc20ad5e2..ac1a8b2c85 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -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); diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index 24e2160e5a..099522f33c 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -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]) diff --git a/libavcodec/lcl.c b/libavcodec/lcl.c index bf04154a91..e710f942a1 100644 --- a/libavcodec/lcl.c +++ b/libavcodec/lcl.c @@ -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); diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index cf3a1d347b..a71f050cde 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -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); diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c index 2edd90bd43..6ea01b3b84 100644 --- a/libavcodec/mjpeg.c +++ b/libavcodec/mjpeg.c @@ -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; diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index cb24c514ad..57ce02ea6d 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -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, }; diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c index b318faa77f..d95e3f79b5 100644 --- a/libavcodec/msrle.c +++ b/libavcodec/msrle.c @@ -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; diff --git a/libavcodec/msvideo1.c b/libavcodec/msvideo1.c index b88bdab5de..518df0e52d 100644 --- a/libavcodec/msvideo1.c +++ b/libavcodec/msvideo1.c @@ -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; diff --git a/libavcodec/png.c b/libavcodec/png.c index 2945d0cc54..637a229171 100644 --- a/libavcodec/png.c +++ b/libavcodec/png.c @@ -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; diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c index 51134ce370..3751d114aa 100644 --- a/libavcodec/pnm.c +++ b/libavcodec/pnm.c @@ -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; diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c index 0adb5f49a1..4fc9703227 100644 --- a/libavcodec/qdrw.c +++ b/libavcodec/qdrw.c @@ -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); diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index bb6467b331..fa945858c2 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -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); diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c index 1fedaccf16..41e4120dbf 100644 --- a/libavcodec/qtrle.c +++ b/libavcodec/qtrle.c @@ -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; diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c index 2be26346a2..317c240b9b 100644 --- a/libavcodec/rpza.c +++ b/libavcodec/rpza.c @@ -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; diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 1a8ab054e0..9fb1e8df1a 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -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, }; diff --git a/libavcodec/smc.c b/libavcodec/smc.c index 47c7d93d4c..dbb5adef1d 100644 --- a/libavcodec/smc.c +++ b/libavcodec/smc.c @@ -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; diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 13c596d36a..3566b72fba 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -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); diff --git a/libavcodec/svq1.c b/libavcodec/svq1.c index c719a8ef22..f5c3c7774a 100644 --- a/libavcodec/svq1.c +++ b/libavcodec/svq1.c @@ -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); diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 365125165d..6c189b5e9d 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -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, }; diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index 880ab8d2ee..0c3bb09cf1 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -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; diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index 0e97ee6d92..11d8b83087 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -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); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index c51efd110f..325883cdb8 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -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; } diff --git a/libavcodec/vc9.c b/libavcodec/vc9.c index 8f469d074c..df1f695ebd 100644 --- a/libavcodec/vc9.c +++ b/libavcodec/vc9.c @@ -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 }; diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c index 9a706af315..5a55d9f7fa 100644 --- a/libavcodec/vcr1.c +++ b/libavcodec/vcr1.c @@ -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); diff --git a/libavcodec/xl.c b/libavcodec/xl.c index 0f496017d9..2ba48eb278 100644 --- a/libavcodec/xl.c +++ b/libavcodec/xl.c @@ -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);