]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h261.c
Original Commit: r110 | ods15 | 2006-10-01 19:17:32 +0200 (Sun, 01 Oct 2006) | 2...
[ffmpeg] / libavcodec / h261.c
index c6218c8b9d0ed2054043c847a092be630d8f2f38..337d479cbd10dbeb42fbdd387fb9542b7a64c6b6 100644 (file)
@@ -264,6 +264,7 @@ void ff_h261_encode_mb(MpegEncContext * s,
     h->previous_mba = h->current_mba;
 
     if(HAS_CBP(h->mtype)){
+        assert(cbp>0);
         put_bits(&s->pb,h261_cbp_tab[cbp-1][1],h261_cbp_tab[cbp-1][0]);
     }
     for(i=0; i<6; i++) {
@@ -372,8 +373,6 @@ static VLC h261_mtype_vlc;
 static VLC h261_mv_vlc;
 static VLC h261_cbp_vlc;
 
-void init_vlc_rl(RLTable *rl, int use_static);
-
 static void h261_decode_init_vlc(H261Context *h){
     static int done = 0;
 
@@ -780,7 +779,14 @@ static int h261_decode_picture_header(H261Context *h){
     }
 
     /* temporal reference */
-    s->picture_number = get_bits(&s->gb, 5); /* picture timestamp */
+    i= get_bits(&s->gb, 5); /* picture timestamp */
+    if(i < (s->picture_number&31))
+        i += 32;
+    s->picture_number = (s->picture_number&~31) + i;
+
+    s->avctx->time_base= (AVRational){1001, 30000};
+    s->current_picture.pts= s->picture_number;
+
 
     /* PTYPE starts here */
     skip_bits1(&s->gb); /* split screen off */
@@ -846,6 +852,7 @@ static int h261_decode_gob(H261Context *h){
     return -1;
 }
 
+#ifdef CONFIG_H261_PARSER
 static int h261_find_frame_end(ParseContext *pc, AVCodecContext* avctx, const uint8_t *buf, int buf_size){
     int vop_found, i, j;
     uint32_t state;
@@ -857,7 +864,6 @@ static int h261_find_frame_end(ParseContext *pc, AVCodecContext* avctx, const ui
         state= (state<<8) | buf[i];
         for(j=0; j<8; j++){
             if(((state>>j)&0xFFFFF) == 0x00010){
-                i++;
                 vop_found=1;
                 break;
             }
@@ -899,6 +905,7 @@ static int h261_parse(AVCodecParserContext *s,
     *poutbuf_size = buf_size;
     return next;
 }
+#endif
 
 /**
  * returns the number of bytes consumed for building the current frame
@@ -921,8 +928,8 @@ static int h261_decode_frame(AVCodecContext *avctx,
     AVFrame *pict = data;
 
 #ifdef DEBUG
-    printf("*****frame %d size=%d\n", avctx->frame_number, buf_size);
-    printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
+    av_log(avctx, AV_LOG_DEBUG, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
+    av_log(avctx, AV_LOG_DEBUG, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
 #endif
     s->flags= avctx->flags;
     s->flags2= avctx->flags2;
@@ -996,10 +1003,6 @@ assert(s->current_picture.pict_type == s->pict_type);
     *pict= *(AVFrame*)s->current_picture_ptr;
     ff_print_debug_info(s, pict);
 
-    /* Return the Picture timestamp as the frame number */
-    /* we substract 1 because it is added on utils.c    */
-    avctx->frame_number = s->picture_number - 1;
-
     *data_size = sizeof(AVFrame);
 
     return get_consumed_bytes(s, buf_size);
@@ -1023,6 +1026,7 @@ AVCodec h261_encoder = {
     MPV_encode_init,
     MPV_encode_picture,
     MPV_encode_end,
+    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
 };
 #endif
 
@@ -1038,6 +1042,7 @@ AVCodec h261_decoder = {
     CODEC_CAP_DR1,
 };
 
+#ifdef CONFIG_H261_PARSER
 AVCodecParser h261_parser = {
     { CODEC_ID_H261 },
     sizeof(ParseContext),
@@ -1045,3 +1050,4 @@ AVCodecParser h261_parser = {
     h261_parse,
     ff_parse_close,
 };
+#endif