wmv1 header parser (unfinished)
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 6 Apr 2002 22:29:37 +0000 (22:29 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 6 Apr 2002 22:29:37 +0000 (22:29 +0000)
Originally committed as revision 380 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/avcodec.h
libavcodec/h263dec.c
libavcodec/mpegvideo.c
libavcodec/msmpeg4.c
libavcodec/utils.c

index 41bd49eff56931927ecc261afc83e5f12cd135f4..499cff7cff06d4c0385f033bac0e445ca7047fdb 100644 (file)
@@ -17,6 +17,7 @@ enum CodecID {
     CODEC_ID_MSMPEG4V1,
     CODEC_ID_MSMPEG4V2,
     CODEC_ID_MSMPEG4V3,
     CODEC_ID_MSMPEG4V1,
     CODEC_ID_MSMPEG4V2,
     CODEC_ID_MSMPEG4V3,
+    CODEC_ID_WMV1,
     CODEC_ID_H263P,
     CODEC_ID_H263I,
 
     CODEC_ID_H263P,
     CODEC_ID_H263I,
 
@@ -212,6 +213,7 @@ extern AVCodec mpeg4_decoder;
 extern AVCodec msmpeg4v1_decoder;
 extern AVCodec msmpeg4v2_decoder;
 extern AVCodec msmpeg4v3_decoder;
 extern AVCodec msmpeg4v1_decoder;
 extern AVCodec msmpeg4v2_decoder;
 extern AVCodec msmpeg4v3_decoder;
+extern AVCodec wmv1_decoder;
 extern AVCodec mpeg_decoder;
 extern AVCodec h263i_decoder;
 extern AVCodec rv10_decoder;
 extern AVCodec mpeg_decoder;
 extern AVCodec h263i_decoder;
 extern AVCodec rv10_decoder;
index 50440d18a8e8e336be49162dfd15f1d230fe03de..5a3d331865c320cd6025e1e7936ed30e3f7c4c6c 100644 (file)
@@ -62,6 +62,11 @@ static int h263_decode_init(AVCodecContext *avctx)
         s->h263_pred = 1;
         s->msmpeg4_version=3;
         break;
         s->h263_pred = 1;
         s->msmpeg4_version=3;
         break;
+    case CODEC_ID_WMV1:
+        s->h263_msmpeg4 = 1;
+        s->h263_pred = 1;
+        s->msmpeg4_version=4;
+        break;
     case CODEC_ID_H263I:
         s->h263_intel = 1;
         break;
     case CODEC_ID_H263I:
         s->h263_intel = 1;
         break;
@@ -234,7 +239,7 @@ static int h263_decode_frame(AVCodecContext *avctx,
         }
     }
     
         }
     }
     
-    if (s->h263_msmpeg4 && s->pict_type==I_TYPE)
+    if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE)
         if(msmpeg4_decode_ext_header(s, buf_size) < 0) return -1;
 
     MPV_frame_end(s);
         if(msmpeg4_decode_ext_header(s, buf_size) < 0) return -1;
 
     MPV_frame_end(s);
@@ -322,6 +327,18 @@ AVCodec msmpeg4v3_decoder = {
     CODEC_CAP_DRAW_HORIZ_BAND,
 };
 
     CODEC_CAP_DRAW_HORIZ_BAND,
 };
 
+AVCodec wmv1_decoder = {
+    "wmv1",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_WMV1,
+    sizeof(MpegEncContext),
+    h263_decode_init,
+    NULL,
+    h263_decode_end,
+    h263_decode_frame,
+    CODEC_CAP_DRAW_HORIZ_BAND,
+};
+
 AVCodec h263i_decoder = {
     "h263i",
     CODEC_TYPE_VIDEO,
 AVCodec h263i_decoder = {
     "h263i",
     CODEC_TYPE_VIDEO,
index 521e06f902c3425fc01e58e6ae2b3420f907f547..f35483e3a19ae7abc3febf5d4a22af9036a3ca74 100644 (file)
@@ -1652,7 +1652,7 @@ static void encode_picture(MpegEncContext *s, int picture_number)
     }
     emms_c();
 
     }
     emms_c();
 
-    if (s->h263_msmpeg4 && s->pict_type == I_TYPE)
+    if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type == I_TYPE)
         msmpeg4_encode_ext_header(s);
 
     //if (s->gob_number)
         msmpeg4_encode_ext_header(s);
 
     //if (s->gob_number)
index 66fc5255e488856fbb03ca67eafd5204982f0d99..188e2302f68f32772c57a2704dcefc8debb644df 100644 (file)
@@ -802,8 +802,18 @@ static int decode012(GetBitContext *gb)
 
 int msmpeg4_decode_picture_header(MpegEncContext * s)
 {
 
 int msmpeg4_decode_picture_header(MpegEncContext * s)
 {
-    int code;
+    int code, code2;
 
 
+#if 0
+{
+int i;
+for(i=0; i<s->gb.size*8; i++)
+    printf("%d", get_bits1(&s->gb));
+//    get_bits1(&s->gb);
+printf("END\n");
+return -1;
+}
+#endif
     s->pict_type = get_bits(&s->gb, 2) + 1;
     if (s->pict_type != I_TYPE &&
         s->pict_type != P_TYPE)
     s->pict_type = get_bits(&s->gb, 2) + 1;
     if (s->pict_type != I_TYPE &&
         s->pict_type != P_TYPE)
@@ -817,16 +827,34 @@ int msmpeg4_decode_picture_header(MpegEncContext * s)
         if (code < 0x17)
             return -1;
         s->slice_height = s->mb_height / (code - 0x16);
         if (code < 0x17)
             return -1;
         s->slice_height = s->mb_height / (code - 0x16);
-        if(s->msmpeg4_version==2){
+
+        switch(s->msmpeg4_version){
+        case 2:
             s->rl_chroma_table_index = 2;
             s->rl_table_index = 2;
 
             s->dc_table_index = 0; //not used
             s->rl_chroma_table_index = 2;
             s->rl_table_index = 2;
 
             s->dc_table_index = 0; //not used
-        }else{
+            break;
+        case 3:
             s->rl_chroma_table_index = decode012(&s->gb);
             s->rl_table_index = decode012(&s->gb);
 
             s->dc_table_index = get_bits1(&s->gb);
             s->rl_chroma_table_index = decode012(&s->gb);
             s->rl_table_index = decode012(&s->gb);
 
             s->dc_table_index = get_bits1(&s->gb);
+            break;
+        case 4:
+            msmpeg4_decode_ext_header(s, 999 /* bufer size (useless here) */);
+            printf("%X\n", show_bits(&s->gb, 24));
+            code= get_bits(&s->gb, 2);
+            if(code==1){
+                code2= get_bits(&s->gb, 3);
+                if(code2==7) skip_bits(&s->gb, 1);
+            }
+            printf("%X\n", show_bits(&s->gb, 24));
+            s->rl_chroma_table_index = 2;
+            s->rl_table_index = 2;
+
+            s->dc_table_index = 0;
+            break;
         }
         s->no_rounding = 1;
 /*     printf(" %d %d %d %d     \n", 
         }
         s->no_rounding = 1;
 /*     printf(" %d %d %d %d     \n", 
@@ -864,6 +892,7 @@ int msmpeg4_decode_picture_header(MpegEncContext * s)
            s->no_rounding = 0;
        }
 //     printf("%d", s->no_rounding);
            s->no_rounding = 0;
        }
 //     printf("%d", s->no_rounding);
+//return -1;
     }
     
 #if 0
     }
     
 #if 0
@@ -1250,6 +1279,7 @@ static int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
         i += run;
         if (i >= 64)
             return -1;
         i += run;
         if (i >= 64)
             return -1;
+//printf("RL:%d %d %d ", run, level, last);
        j = scan_table[i];
         block[j] = level;
         i++;
        j = scan_table[i];
         block[j] = level;
         i++;
index c0f640591addea0fdc07268bd6c98b69087a8524..9a4abaa9ba378810a7b742d285a2af5c333ba163 100644 (file)
@@ -429,6 +429,7 @@ void avcodec_register_all(void)
     register_avcodec(&msmpeg4v1_decoder);
     register_avcodec(&msmpeg4v2_decoder);
     register_avcodec(&msmpeg4v3_decoder);
     register_avcodec(&msmpeg4v1_decoder);
     register_avcodec(&msmpeg4v2_decoder);
     register_avcodec(&msmpeg4v3_decoder);
+    register_avcodec(&wmv1_decoder);
     register_avcodec(&mpeg_decoder);
     register_avcodec(&h263i_decoder);
     register_avcodec(&rv10_decoder);
     register_avcodec(&mpeg_decoder);
     register_avcodec(&h263i_decoder);
     register_avcodec(&rv10_decoder);