Ministry of English Composition, reporting for duty (and the word is "skipped", not...
[ffmpeg.git] / libavcodec / rv10.c
index 7dc3ea2..23106bc 100644 (file)
@@ -258,6 +258,36 @@ void rv10_encode_picture_header(MpegEncContext *s, int picture_number)
     put_bits(&s->pb, 3, 0);    /* ignored */
 }
 
+void rv20_encode_picture_header(MpegEncContext *s, int picture_number){
+    put_bits(&s->pb, 2, s->pict_type); //I 0 vs. 1 ?
+    put_bits(&s->pb, 1, 0);    /* unknown bit */
+    put_bits(&s->pb, 5, s->qscale);
+        
+    put_bits(&s->pb, 8, picture_number&0xFF); //FIXME wrong, but correct is not known
+    s->mb_x= s->mb_y= 0;
+    ff_h263_encode_mba(s);
+    
+    put_bits(&s->pb, 1, s->no_rounding);
+    
+    assert(s->f_code == 1);
+    assert(s->unrestricted_mv == 1);
+//    assert(s->h263_aic== (s->pict_type == I_TYPE));
+    assert(s->alt_inter_vlc == 0);
+    assert(s->umvplus == 0);
+    assert(s->modified_quant==1);
+    assert(s->loop_filter==1);
+
+    s->h263_aic= s->pict_type == I_TYPE;
+    if(s->h263_aic){
+        s->y_dc_scale_table= 
+        s->c_dc_scale_table= ff_aic_dc_scale_table;
+    }else{
+        s->y_dc_scale_table=
+        s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
+    }
+}
+
+#if 0 /* unused, remove? */
 static int get_num(GetBitContext *gb)
 {
     int n, n1;
@@ -270,6 +300,7 @@ static int get_num(GetBitContext *gb)
         return (n << 16) | n1;
     }
 }
+#endif
 
 #endif //CONFIG_ENCODERS
 
@@ -400,20 +431,21 @@ static int rv20_decode_picture_header(MpegEncContext *s)
     }
         
     if(s->avctx->has_b_frames){
+        int f=9;
+        int v= s->avctx->extradata_size >= 4 ? ((uint8_t*)s->avctx->extradata)[1] : 0;
+
         if (get_bits(&s->gb, 1)){
-//            av_log(s->avctx, AV_LOG_ERROR, "unknown bit3 set\n");
+            av_log(s->avctx, AV_LOG_ERROR, "unknown bit3 set\n");
 //            return -1;
         }
         seq= get_bits(&s->gb, 14)<<1;
-        
-        if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&1){
-            get_bits(&s->gb, 1);
-        }
-        if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&2){
-            get_bits(&s->gb, 1);
+
+        if(v>1 || (s->avctx->sub_id < 0x20201002 && v>0)){
+            f= get_bits(&s->gb, av_log2(v-1)+1);
         }
-        if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&4){
-            get_bits(&s->gb, 2);
+        
+        if(s->avctx->debug & FF_DEBUG_PICT_INFO){
+            av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, v);
         }
 
         mb_pos= get_bits(&s->gb, av_log2(s->mb_num-1)+1);
@@ -436,8 +468,8 @@ static int rv20_decode_picture_header(MpegEncContext *s)
             s->time= seq;
             s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
             if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){
-                av_log(s->avctx, AV_LOG_DEBUG, "messed up order, seeking?, skiping current b frame\n");
-                return FRAME_SKIPED;
+                av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible from seeking? skipping current b frame\n");
+                return FRAME_SKIPPED;
             }
         }
     }
@@ -511,6 +543,7 @@ static int rv10_decode_init(AVCodecContext *avctx)
         break;
     case 0x20200002:
     case 0x20201002:
+    case 0x20203002:
     case 0x30202002:
     case 0x30203002:
         s->low_delay=0;
@@ -733,6 +766,7 @@ AVCodec rv20_decoder = {
     NULL,
     rv10_decode_end,
     rv10_decode_frame,
-    CODEC_CAP_DR1
+    CODEC_CAP_DR1 | CODEC_CAP_DELAY,
+    .flush= ff_mpeg_flush,
 };