]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
avoid buf_size == 0 checks in every decoder
authormichael <michael@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 23 Jan 2005 18:09:06 +0000 (18:09 +0000)
committermichael <michael@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 23 Jan 2005 18:09:06 +0000 (18:09 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@3872 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

35 files changed:
libavcodec/4xm.c
libavcodec/8bps.c
libavcodec/asv1.c
libavcodec/avcodec.h
libavcodec/cljr.c
libavcodec/dv.c
libavcodec/ffv1.c
libavcodec/h261.c
libavcodec/h263dec.c
libavcodec/h264.c
libavcodec/huffyuv.c
libavcodec/indeo3.c
libavcodec/lcl.c
libavcodec/mdec.c
libavcodec/mjpeg.c
libavcodec/mpeg12.c
libavcodec/msrle.c
libavcodec/msvideo1.c
libavcodec/png.c
libavcodec/pnm.c
libavcodec/qdrw.c
libavcodec/qpeg.c
libavcodec/qtrle.c
libavcodec/rpza.c
libavcodec/rv10.c
libavcodec/smc.c
libavcodec/snow.c
libavcodec/svq1.c
libavcodec/svq3.c
libavcodec/truemotion1.c
libavcodec/tscc.c
libavcodec/utils.c
libavcodec/vc9.c
libavcodec/vcr1.c
libavcodec/xl.c

index 5cc5f575f0c0f81b9a2762dc30a7d29fea66d41a..6932d52ab82e0dd041e24234f0c0cda2ab0ad6e9 100644 (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));
index 48773a17449188acfa40c6ee12f41b37d4574cf9..3898ac5dd353e47314916bd833434aed3941d1c1 100644 (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);
 
index 95b15337bfa8a736c52729decb3b7c92e4f5ed21..b8030ef3ab3b2348abd6c8cd646bf48ae4209b2d 100644 (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);
 
index 8cf6500ca3eb39a507d499c9bc1bfd1355b5eb6a..503a04e0837addfcaadb7c63e8f8b72d88cff84d 100644 (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
index df1f798514ce8574d9f343dcde38e5e57a97592b..c17316b3e0951e5c01633938b634e5efc888df4a 100644 (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);
 
index f548bffd8bbc5071e14c32dc2f2a93fb3cc04b0c..01e1ce6842b3edc74e2d53d08d94e5c4f0442ede 100644 (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 */
index cc15d902b29ed1708be25cd95c613001c29f09c5..737e3f411431c4508610dfd7b85b7fbd36ed146c 100644 (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);
 
index 8536ea9c865db21cfec31ee7275b3b4af13120cb..aceebaa381416e3340725337cb4aa6fc55d2517d 100644 (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:
index da94aede5a17c7ca04b8225bcfec17d00343f8f2..272780da7af45a17eb4ffa4873eb936aa910b75e 100644 (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,
 };
 
index 466257adaab6815fbc06fecd2365a74ade20dd5b..856b0804a43493172ac7cca574d200fdad1e0302 100644 (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 = {
index fbc20ad5e2d5feadc4d4626ce9f6e80b490a3308..ac1a8b2c85504d82c741baf23ebcaed5c7ca4921 100644 (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);
index 24e2160e5aebfd9a10e62a9cd38b9ecf3b12f356..099522f33c0aa44d2d7b6077800898442ff345c3 100644 (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])
index bf04154a91b8b7a425843952faf5dba0f9876f11..e710f942a168283e6b41afff396b07d072538672 100644 (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);
 
index cf3a1d347b5085064beb636ccb7283e44315ef21..a71f050cdecc8ec95cf86181ff55b1ed6bea41c1 100644 (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);
 
index 2edd90bd43a6973ddd0c911e0d611d866e463ce4..6ea01b3b847ca7f24992e6333153693aaa218e41 100644 (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;
 
index cb24c514ad726a878f47857ab748a1949d983d51..57ce02ea6dd41fec67a5752dc0f0389619c87664 100644 (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,
 };
 
index b318faa77f86f459921c7251828109bccc0029b9..d95e3f79b5b68a9ed36a8ae638490fbe5e6049cd 100644 (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;
 
index b88bdab5de5f36b854d2900e46c2bba05d48a4eb..518df0e52d0d89454f77949870b57873980263c3 100644 (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;
 
index 2945d0cc54bdb0da7a01732973f80df1c3437b0a..637a2291713ca37fb764a11d2fb6e0d556e19d39 100644 (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;
index 51134ce3705a60be5d1afc51df1f0d74654ecebc..3751d114aa434a4ce016acb31ed81e90e70b09a0 100644 (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;
index 0adb5f49a1ccb443a4b73719c0aa9678118564dd..4fc9703227cf977bc6e03fec09cae810a4b131a6 100644 (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);
 
index bb6467b331c40026a0670bafd98bad920bc7d1e0..fa945858c25fc82281c5f977dfaa4d626fc1f5cc 100644 (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);
 
index 1fedaccf16620716bb1ebf487aea21b533ac916e..41e4120dbf3b126fd7d2d75ef9a2850c51bc6228 100644 (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;
 
index 2be26346a22693e76eb2bdb243b4adc182586e65..317c240b9b50096326e6b5dd7bd4d44a7d56557d 100644 (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;
 
index 1a8ab054e0d582a3a800dab02356124f0c173a5f..9fb1e8df1acc6b377f9626bffd2521803d7283a1 100644 (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,
 };
 
index 47c7d93d4c514f63fd2d2884db0257b5ca6285a7..dbb5adef1db98bd5ed3a1120525a6c65b00950dc 100644 (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;
 
index 13c596d36a69aceff1dce0a1d2d8ea3c4608608f..3566b72fba57fcf35b3244a1b72cbf8127279008 100644 (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);
index c719a8ef22a0064f67c29efe2efca28b7cc44f7e..f5c3c7774a497dd83e3a311b647ee251db34f150 100644 (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);
 
index 365125165d37cb0d6090af901e455cae99cb0565..6c189b5e9d965529cc4ee01775cb873df96d12e3 100644 (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,
 };
index 880ab8d2eee633a011017da63b2d12eb873d1407..0c3bb09cf10268d0ac0fae1e96e660634e917864 100644 (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;
 
index 0e97ee6d92da1a3e1eb550a8ff74551856535182..11d8b8308760c66fa127de43f48e51bd4e72280e 100644 (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);
 
index c51efd110fc47b0e49dd5c48e43d6ecf16854feb..325883cdb89d7913600e4788f2234c226c9c413a 100644 (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;
 }
 
index 8f469d074c0c218aad471035832b3cc0661264e7..df1f695ebd032ac5276fceb578d21ef361076bf4 100644 (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
 };
index 9a706af31513cb24c18c9fae613bd42f51b199e5..5a55d9f7faf687720f22d25ad0443902cf7ebc7d 100644 (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);
 
index 0f496017d9bcb227fed0f2d829b96b860ac48ece..2ba48eb2782c1c0aa152623bff6cc277645d99f9 100644 (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);