diff -urN dvdauthor-0.6.10.orig/src/da-internal.h dvdauthor-0.6.10.ivtv/src/da-internal.h --- dvdauthor-0.6.10.orig/src/da-internal.h 2004-03-13 01:57:39.000000000 -0600 +++ dvdauthor-0.6.10.ivtv/src/da-internal.h 2004-04-18 00:44:16.000000000 -0500 @@ -163,6 +163,7 @@ extern char *entries[]; extern int jumppad; +extern int printWarnings; extern char *pstypes[]; void write8(unsigned char *p,unsigned char d0,unsigned char d1, diff -urN dvdauthor-0.6.10.orig/src/dvdauthor.c dvdauthor-0.6.10.ivtv/src/dvdauthor.c --- dvdauthor-0.6.10.orig/src/dvdauthor.c 2004-03-14 13:31:10.000000000 -0600 +++ dvdauthor-0.6.10.ivtv/src/dvdauthor.c 2004-04-18 00:44:16.000000000 -0500 @@ -38,6 +38,10 @@ // jumping/calling to a wider number of destinations int jumppad=0; +// this flag allows the user to turn off any WARNings that we might not +// want to see. Audio discontinuity and re-muxing come to mind. +int printWarnings=1; + static char *vmpegdesc[4]={"","mpeg1","mpeg2",0}; static char *vresdesc[6]={"","720xfull","704xfull","352xfull","352xhalf",0}; static char *vformatdesc[4]={"","ntsc","pal",0}; @@ -1039,6 +1043,11 @@ jumppad=1; } +void dvdauthor_disable_warnings() +{ + printWarnings=0; +} + void dvdauthor_vmgm_gen(struct pgc *fpc,struct menugroup *menus,char *fbase) { DIR *d; diff -urN dvdauthor-0.6.10.orig/src/dvdauthor.h dvdauthor-0.6.10.ivtv/src/dvdauthor.h --- dvdauthor-0.6.10.orig/src/dvdauthor.h 2004-03-13 01:57:39.000000000 -0600 +++ dvdauthor-0.6.10.ivtv/src/dvdauthor.h 2004-04-18 00:44:16.000000000 -0500 @@ -63,6 +63,7 @@ void source_set_filename(struct source *v,const char *s); void dvdauthor_enable_jumppad(); +void dvdauthor_disable_warnings(); void dvdauthor_vts_gen(struct menugroup *menus,struct pgcgroup *titles,char *fbase); void dvdauthor_vmgm_gen(struct pgc *fpc,struct menugroup *menus,char *fbase); diff -urN dvdauthor-0.6.10.orig/src/dvdcli.c dvdauthor-0.6.10.ivtv/src/dvdcli.c --- dvdauthor-0.6.10.orig/src/dvdcli.c 2004-03-13 12:00:33.000000000 -0600 +++ dvdauthor-0.6.10.ivtv/src/dvdcli.c 2004-04-18 00:44:16.000000000 -0500 @@ -230,6 +230,8 @@ "\n\t-x XMLFILE where XMLFILE is a configuration file describing the\n" "\t structure of the DVD to create. If you use a config file, then you\n" "\t do not need to specify any other options, except -o.\n" + "\n\t-w will turn off the WARN: messages telling you to re-multiplex\n" + "\t the audio and/or video.\n" "\n\t" LONGOPT("--video=VOPTS or ") "-v VOPTS where VOPTS is a plus (+) separated list of\n" "\t video options. dvdauthor will try to infer any unspecified options.\n" "\t\tpal, ntsc, 4:3, 16:9, 720xfull, 720x576, 720x480, 704xfull,\n" @@ -358,7 +360,7 @@ while(1) { struct pgcgroup *vc=va[curva]; - int c=GETOPTFUNC(argc,argv,"f:o:v:a:s:hc:Cp:Pmtb:Ti:e:x:"); + int c=GETOPTFUNC(argc,argv,"f:o:v:a:s:hc:Cp:Pmtb:Ti:e:x:w"); if( c == -1 ) break; switch(c) { @@ -490,6 +492,10 @@ source_add_cell(curvob,0,-1,1,0,0); break; + case 'w': + dvdauthor_disable_warnings(); + break; + default: fprintf(stderr,"ERR: getopt returned bad code %d\n",c); return 1; diff -urN dvdauthor-0.6.10.orig/src/dvdvob.c dvdauthor-0.6.10.ivtv/src/dvdvob.c --- dvdauthor-0.6.10.orig/src/dvdvob.c 2004-03-14 15:13:26.000000000 -0600 +++ dvdauthor-0.6.10.ivtv/src/dvdvob.c 2004-04-18 00:44:49.000000000 -0500 @@ -211,7 +211,7 @@ return dflt; } -static void transpose_ts(unsigned char *buf,int tsoffs) +static void transpose_ts(unsigned char *buf,int scroffs, int tsoffs) { // pack scr if( buf[0] == 0 && @@ -219,25 +219,52 @@ buf[2] == 1 && buf[3] == 0xba ) { - writescr(buf+4,readscr(buf+4)+tsoffs); + int offs = (buf[17] == 0xbb) ? 24 : 0; + + writescr(buf+4,readscr(buf+4)+scroffs); // video/audio? // pts? - if( buf[14] == 0 && - buf[15] == 0 && - buf[16] == 1 && - (buf[17]==0xbd || (buf[17]>=0xc0 && buf[17]<=0xef)) && - (buf[21] & 128)) + if( buf[offs+14] == 0 && + buf[offs+15] == 0 && + buf[offs+16] == 1 && + (buf[offs+17]==0xbd || (buf[offs+17]>=0xc0 && buf[offs+17]<=0xef)) && + (buf[offs+21] & 128)) { - writepts(buf+23,readpts(buf+23)+tsoffs); + writepts(buf+offs+23,readpts(buf+offs+23)+tsoffs); // dts? - if( buf[21] & 64 ) { - writepts(buf+28,readpts(buf+28)+tsoffs); + if( buf[offs+21] & 64 ) { + writepts(buf+offs+28,readpts(buf+offs+28)+tsoffs); } } } } +int find_gop(unsigned char *buf) +{ + if (buf[14] == 0 && + buf[15] == 0 && + buf[16] == 1 && + buf[17] == 0xbb && + buf[38] == 0 && + buf[39] == 0 && + buf[40] == 1 && + buf[41] == 0xe0) + { + int i = 42; + while (i < 1024) + { + if (buf[i] == 0 && + buf[i+1] == 0 && + buf[i+2] == 1 && + buf[i+3] == 0xb8) + return 1; + i += 4; + } + } + return 0; +} + static int mpa_valid(unsigned char *b) { unsigned int v=(b[0]<<24)|(b[1]<<16)|(b[2]<<8)|b[3]; @@ -795,6 +822,7 @@ int FindVobus(char *fbase,struct vobgroup *va,int ismenu) { unsigned char *buf; + unsigned char *buf_copy = (unsigned char*) malloc(2048);; FILE *h; int cursect=0,fsect=-1,vnum,outnum=-ismenu+1; int ispipe,vobid=0; @@ -808,6 +836,7 @@ for( vnum=0; vnumnumvobs; vnum++ ) { int i,j; int hadfirstvobu=0,backoffs=0,lastscr=0; + int generate_vobu=0,copy_packet=0,tsoffs=0; struct vob *s=va->vobs[vnum]; int prevvidsect=-1; struct vscani vsi; @@ -834,7 +863,9 @@ fsect=-1; } buf=writegrabbuf(); - if( 2048 != fread(buf,1,2048,h) ) { + if (copy_packet == 1 ) { + memcpy( buf, buf_copy, 2048); + } else if( 2048 != fread(buf,1,2048,h) ) { writeundo(); break; } @@ -934,6 +965,39 @@ writeundo(); continue; } + if( fsect == -1 ) { + char newname[200]; + fsect=0; + if( outnum >= 0) + sprintf(newname, "%s_%d.VOB", fbase,outnum); + else + strcpy(newname,fbase); + writeopen(newname); + } + + // we should get a VOBU before a video with GOP + if( (generate_vobu == 1 || hadfirstvobu == 0) && + copy_packet == 0 && find_gop(buf) ) + { + // create VOBU + // fprintf(stderr,"Found GOP with no VOBU, creating VOBU...\n"); + generate_vobu = 1; + copy_packet = 1; + memcpy( buf_copy, buf, 2048); + + buf[41] = 0xbf; + buf[42] = 0x03; + buf[43] = 0xd4; + buf[44] = 0x81; + memset( buf+45, 0, 2048-45); + buf[1026] = 1; + buf[1027] = 0xbf; + buf[1028] = 0x03; + buf[1029] = 0xfa; + buf[1030] = 0x81; + } else if (copy_packet == 1) + copy_packet = 0; + if( buf[0]==0 && buf[1]==0 && buf[2]==1 && buf[3]==0xba ) { int newscr=readscr(buf+4); if( newscr < lastscr ) { @@ -944,16 +1008,18 @@ if( !hadfirstvobu ) backoffs=newscr; } - transpose_ts(buf,-backoffs); - if( fsect == -1 ) { - char newname[200]; - fsect=0; - if( outnum>=0 ) - sprintf(newname,"%s_%d.VOB",fbase,outnum); - else - strcpy(newname,fbase); - writeopen(newname); + if( !hadfirstvobu && buf[0]==0 && buf[1]==0 && buf[2]==1 && buf[3]==0xba ) + { + int offs = (buf[17] == 0xbb) ? 24 : 0; + if( buf[offs+14] == 0 && + buf[offs+15] == 0 && + buf[offs+16] == 1 && + (buf[offs+17]==0xbd || (buf[offs+17]>=0xc0 && buf[offs+17]<=0xef)) && + (buf[offs+21] & 128)) + tsoffs = readpts(buf+offs+23); } + transpose_ts(buf,-backoffs,-tsoffs); + if( buf[14] == 0 && buf[15] == 0 && buf[16] == 1 && @@ -998,12 +1064,12 @@ printvobustatus(va,cursect); vsi.lastrefsect=0; vsi.firstgop=1; - } else { + } else if (generate_vobu == 0 || copy_packet == 1) { fprintf(stderr,"WARN: System header found, but PCI/DSI information is not where expected\n\t(make sure your system header is 18 bytes!)\n"); } } if( !hadfirstvobu ) { - fprintf(stderr,"WARN: Skipping sector, waiting for first VOBU...\n"); + // fprintf(stderr,"WARN: Skipping sector, waiting for first VOBU...\n"); writeundo(); continue; } @@ -1133,20 +1199,26 @@ if( ach->audpts[ach->numaudpts-1].pts[1]=32 ) goto noshow; - fprintf(stderr,"WARN: Discontinuity in audio channel %d; please remultiplex input.\n",audch); - } else if( ach->audpts[ach->numaudpts-1].pts[1]>pts0 ) - fprintf(stderr,"WARN: Audio pts for channel %d moves backwards; please remultiplex input.\n",audch); + if (printWarnings) + fprintf(stderr,"WARN: Discontinuity in audio channel %d; please remultiplex input.\n",audch); + } else if( ach->audpts[ach->numaudpts-1].pts[1]>pts0 ) { + if (printWarnings) + fprintf(stderr,"WARN: Audio pts for channel %d moves backwards; please remultiplex input.\n",audch); + } else goto noshow; - fprintf(stderr,"WARN: Previous sector: "); - printpts(ach->audpts[ach->numaudpts-1].pts[0]); - fprintf(stderr," - "); - printpts(ach->audpts[ach->numaudpts-1].pts[1]); - fprintf(stderr,"\nWARN: Current sector: "); - printpts(pts0); - fprintf(stderr," - "); - printpts(pts1); - fprintf(stderr,"\n"); + if (printWarnings) + { + fprintf(stderr,"WARN: Previous sector: "); + printpts(ach->audpts[ach->numaudpts-1].pts[0]); + fprintf(stderr," - "); + printpts(ach->audpts[ach->numaudpts-1].pts[1]); + fprintf(stderr,"\nWARN: Current sector: "); + printpts(pts0); + fprintf(stderr," - "); + printpts(pts1); + fprintf(stderr,"\n"); + } ach->audpts[ach->numaudpts-1].pts[1]=pts0; noshow: } @@ -1279,6 +1351,7 @@ } } writeclose(); + free(buf_copy); printvobustatus(va,cursect); fprintf(stderr,"\n"); free(crs);