User Tools

Site Tools


tech:multimedia:avi_parser

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tech:multimedia:avi_parser [2010/08/12 09:16]
admin
tech:multimedia:avi_parser [2014/11/10 08:22] (current)
Line 22: Line 22:
     int (*parser)(FILE *fp, const avitag_t *tag);     int (*parser)(FILE *fp, const avitag_t *tag);
 } parser_map_t;​ } parser_map_t;​
- + 
 +int null_parser(FILE *fp, const avitag_t* tag); 
 parser_map_t parser_list[] =  parser_map_t parser_list[] = 
 { {
Line 129: Line 130:
     }     }
     return;     return;
 +}
 +
 +int main(int argc, char**argv)
 +{
 +    FILE *fp; 
 +
 +    if (argc <= 1)
 +    {
 +        printf("​Usage:​ %s filename",​ argv[0]);
 +        return 0;
 +    }
 +
 +    fp = fopen(argv[1],​ "​wb"​);​
 +    if (fp == NULL)
 +    {
 +        printf("​Error in opening file %s", argv[1]);
 +        return -1;
 +    }
 +
 +    parse_riff(fp);​
 +    fclose(fp);
 +
 +    return 0;
 } }
 </​code>​ </​code>​
Line 264: Line 288:
     unsigned int v2;     unsigned int v2;
     unsigned long pos = ftell(fp);     unsigned long pos = ftell(fp);
-    int idx= tag->​nested+1;;​+    int idx= tag->​nested+1;​ 
 +    int type = -1;
  
-    if (tag->​size >= 40) /* guessed to be video */+    if (20 != fread(&​header,​ 1, 20, fp)) 
 +        return -1; 
 +    v1 = header[0] | (header[1]<<​8);​ 
 +    if (v1 == 40 && ​tag->​size >= 40) type = 1; /* guessed to be video */ 
 +    else  
 +    { 
 +        v1 = header[16] | (header[17]<<​8);​ 
 +     if (tag->​size >= v1+18) type = 2; /* guessed to be audio */ 
 +    }  
 +  
 +    if (type == 1) 
     {     {
-        if (20 != fread(&​header,​ 1, 20, fp)) 
-            return -1; 
         while (idx-- >= 0)         while (idx-- >= 0)
         {         {
Line 289: Line 322:
   
  }  }
-    else if (tag->​size >18/* guessed to be audio */+    else if (type == 2
     {     {
-        if (16 != fread(&​header,​ 1, 16, fp)) 
-            return -1; 
         while (idx-- >= 0)         while (idx-- >= 0)
         {         {
Line 299: Line 330:
         putchar('​{'​);​         putchar('​{'​);​
         v1 = header[0] | (header[1]<<​8);​          v1 = header[0] | (header[1]<<​8);​
-        printf("​id=%d, ", v1);+        printf("​id=0x%x, ", v1);
         v1 = header[2] | (header[3]<<​8);​         v1 = header[2] | (header[3]<<​8);​
         printf("​%d ch, ", v1);         printf("​%d ch, ", v1);
tech/multimedia/avi_parser.1281604583.txt.gz · Last modified: 2014/11/10 08:32 (external edit)