added DEFINEMOVIE to define tags
[swftools.git] / lib / h.263 / video.c
index 2376017..98fea24 100644 (file)
@@ -5,13 +5,13 @@
    
    Copyright (c) 2003 Matthias Kramm <kramm@quiss.org> */
 
-#include "../config.h"
+#include "../../config.h"
 #include <unistd.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <stdarg.h>
-#include "../lib/rfxswf.h"
-#include "../lib/args.h"
+#include "../rfxswf.h"
+#include "../args.h"
 #include "h263tables.c"
 
 static char * filename = 0;
@@ -241,10 +241,11 @@ void get_DC_TCOEF(TAG*tag, int t, int has_dc, int has_tcoef)
     }
 }
            
-void readMVD(TAG*tag)
+int readMVD(TAG*tag)
 {
     int index = gethuffvalue(tag, mvd);
     DEBUG printf("mvd index:%d\n", index);
+    return index;
 }
 
 char has_quant[] = {0,1,0,0,1};
@@ -259,12 +260,11 @@ void decode_block(TAG*tag, int pictype)
 {
     int t;
     int mb_type = -1, cbpc = -1;
-    int dbquant;
+    int dquant;
     int cbpy_index, cbpy_value;
     int intrablock = 0;
     int type;
     if(pictype == TYPE_INTER) /* non-intra pictures have a cod flag */
-    /* TODO: according to the flash spec, this field is always present */
     {
        int cod = swf_GetBits(tag, 1);
        DEBUG printf("cod=%d\n",cod);
@@ -302,8 +302,8 @@ void decode_block(TAG*tag, int pictype)
     {
        intrablock = 1;
     }
-       
-    printf("%d", intrablock);
+
+    printf("%c", "vqVii"[mb_type]);
 
     DEBUG printf("mcbpc type: %d mb_type:%d cbpc:%d\n", type, mb_type, cbpc);
 
@@ -324,13 +324,20 @@ void decode_block(TAG*tag, int pictype)
 
     /* quantizer */
     if(has_quant[mb_type]) {
-       dbquant = swf_GetBits(tag, 2);
-       DEBUG printf("quantizer: %d\n", dbquant);
+       dquant = swf_GetBits(tag, 2);
+       if(dquant == 0) dquant = -1;
+       else if(dquant == 1) dquant = -2;
+       else if(dquant == 2) dquant = +1;
+       else if(dquant == 3) dquant = +2;
+       DEBUG printf("dquant: %d\n", dquant);
     }
 
     if(has_mvd[mb_type]&1) {
-       readMVD(tag); //horizontal
-       readMVD(tag); //vertical
+       int x,y;
+       x = readMVD(tag); //horizontal
+       y = readMVD(tag); //vertical
+       if(x==32 && y==32)
+           printf("\b0");
     }
     if(has_mvd[mb_type]&2) {
        /* only in advanced prediction mode */
@@ -397,7 +404,7 @@ void handleVideoFrame(TAG*tag, char*prefix)
     sizeflags = swf_GetBits(tag, 3);
     switch(sizeflags)
     {
-       case 0: width = swf_GetU8(tag); height = swf_GetU8(tag); break;
+       case 0: width = swf_GetBits(tag,8); height = swf_GetBits(tag,8); break;
        case 1: width = swf_GetBits(tag, 16); height = swf_GetBits(tag, 16); break;
        case 2: width = 352; height = 288; break;
        case 3: width = 176; height = 144; break;
@@ -441,8 +448,8 @@ void handleVideoFrame(TAG*tag, char*prefix)
 
     /*if(pictype == TYPE_INTER)
        return;*/
-    if(pictype == TYPE_INTRA)
-       return;
+    /*if(pictype == TYPE_INTRA)
+       return;*/
 
     /*tagnr++;
     if(tagnr!=2)