Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Rebuilding index.vdr files



Today I've played a little bit around to generate the index.vdr file.

I think, now it works

compile it with gcc genindex.c -o genindex
change to the directory that contains 001.vdr
run /<path>/genindex
wait ....

Roland



#include <stdio.h>

#define readbuffersize  1024*32
#define SC_VIDEO 0xE0
#define SC_PICTURE 0x00

unsigned char ringbuf[readbuffersize];
int offset;
FILE* fp ;
FILE* idx;
int Foffset;

unsigned char buf(int p)
{
    if ((p >= Foffset) && ( p < (Foffset+readbuffersize)) )
 {return ringbuf[p-Foffset];}
    Foffset=p;
    if (fseek(fp,p,SEEK_SET)==0)
    {
 fread(ringbuf, 1, readbuffersize, fp);
 return ringbuf[p-Foffset];
    }
    return 0;
}


int readfile(const unsigned char number )
{ 
int filesize; 
int length;
int c;
int d;
char fname[20];
sprintf(fname,"%03d.vdr",number);
printf("\nReading:");
printf(fname);
printf("\n");
fp = fopen(fname, "r");
if(!fp) { printf("Could not open the file\n"); return -1;} 
fseek(fp, 0, SEEK_END);
filesize = ftell(fp);
Foffset=filesize;
    for (c=0;c < filesize-32;c++)
    {
    if (buf(c) == 0 && buf(c+1) == 0 && buf(c+2) == 1 && buf(c+3)==SC_VIDEO) 
 {  
     d= c+8;
     d+= buf(d)+1;
     length=(buf(c+4)<< 8) + buf(Foffset +5)+6;
     length+=d;
  // d is starting SC_Video
     for (;(d < length) && (d < filesize -32);d++)
     {
  if (buf(d) == 0 && buf(d+1) == 0 && buf(d+2) == 1 && buf(d+3)==SC_PICTURE) 
  {
          char i[8]={c,c>>8,c>>16,c>>24,(buf(d+5)>>3) & 0x07,number,0};
      if(fwrite(i, 1, 8, idx) != 8) 
      { printf("Error writing index file\n"); return -1;} 
      if (((buf(d+5)>>3) & 0x07)==1)
   {     printf("IFrame found at: %d kB \r",(c/1024)); 
             fflush(stdout);}

  }
     }
        }
    }

fclose(fp);
return 0; 
} 

int main()
{
int c;
idx = fopen("index.vdr", "w");
for (c=1;readfile(c)==0;c++) { }
fclose(idx);
return 0;
}

// p.s. I think OjE has deleted some tabs ;-)






-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index