Here are some hacks to MPlayer to play a little nicer with some
DVD's.  Chapter-offset values are now supported (and are optional).
The Filmwatch site will be updated to support this as soon as the
patch is submitted to mplayer-dev.  Muting is done a little more
nicely too.  Patch against the CVS head:

Index: edl.h
===================================================================
RCS file: /cvsroot/mplayer/main/edl.h,v
retrieving revision 1.2
diff -r1.2 edl.h
1c1
< // EDL version 0.5
---
> // EDL version 0.6
17a18
>   int chapter;
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.708
diff -r1.708 mplayer.c
344a345,390
> 
> enum MuteStates {
>   NOT_MUTED, MUTED_BY_EDL_ONLY, MUTED_BY_USER_ONLY, MUTED_BY_BOTH_EDL_AND_USER
> };
> 
> enum MuteRequestors {
>   EDL_MUTE_REQUESTOR, USER_MUTE_REQUESTOR
> };
> 
> void toggleMute( enum MuteRequestors muteRequestor ) {
>   static enum MuteStates mute_state = NOT_MUTED;
>   switch( mute_state ) {
>   case NOT_MUTED:
>     if( muteRequestor == EDL_MUTE_REQUESTOR ) {
>       mute_state = MUTED_BY_EDL_ONLY;
>     } else {
>       mute_state = MUTED_BY_USER_ONLY;
>     }
>     mixer_mute();
>     break;
>   case MUTED_BY_EDL_ONLY:
>     if( muteRequestor == EDL_MUTE_REQUESTOR ) {
>       mute_state = NOT_MUTED;
>       mixer_mute();
>     } else {
>       mute_state = MUTED_BY_BOTH_EDL_AND_USER;
>     }
>     break;
>   case MUTED_BY_BOTH_EDL_AND_USER:
>     if( muteRequestor == EDL_MUTE_REQUESTOR ) {
>       mute_state = MUTED_BY_USER_ONLY;
>     } else {
>       mute_state = MUTED_BY_EDL_ONLY;
>     }    
>     break;
>   case MUTED_BY_USER_ONLY:
>     if( muteRequestor == EDL_MUTE_REQUESTOR ) {
>       mute_state = MUTED_BY_BOTH_EDL_AND_USER;      
>     } else {
>       mute_state = NOT_MUTED;
>       mixer_mute();
>     }
>     break;
>   }
> }
> 
914a961,965
> 
> #ifndef MAX_EDL_LINE_LENGTH
> #define MAX_EDL_LINE_LENGTH 100
> #endif
> 
917c968
<    char line[ 100 ];
---
>    char line[ MAX_EDL_LINE_LENGTH ];
919c970
<    int action;
---
>    int chapter, action;
928c979,982
<        while( fgets( line, 99, fd ) != NULL ) {
---
>        while( fgets( line, ( MAX_EDL_LINE_LENGTH - 1 ), fd ) != NULL ) {
>        int tokenIdx = 0;
>        char* token;
>        float vals[ 4 ];
930,939c984,993
<        if( ( sscanf( line, "%f %f %d", &start, &stop, &action ) ) == 0 ) {
<          printf( "Invalid EDL line: [%s]\n", line );
<        } else {
<          if( next_edl_array_index > 0 ) {
<            edl_records[ next_edl_array_index-1 ].next = &edl_records[ 
next_edl_array_index ];
<            if( start <= edl_records[ next_edl_array_index-1 ].stop_sec ) {
<              printf( "Invalid EDL line [%d]: [%s]\n", lineCount, line );
<              printf( "Last stop position was [%f]; next start is [%f]. Entries must 
be in chronological order and cannot overlap. Discarding EDL entry.\n", edl_records[ 
next_edl_array_index-1 ].stop_sec, start );
<              continue;
<            }
---
>        chapter = -1;
> 
>        // Read all the tokens
>        if( ( token = strtok( line, " " ) ) == NULL ) {
>          printf( "Unable to parse EDL line: [%s]\n", line );
>          continue;
>        }
>        while( token && tokenIdx < 5 ) {
>          if( strcmp( token, "#" ) == 0 ) {
>            break;
941c995,1020
<          if( stop <= start ) {
---
>          vals[ tokenIdx ] = atof( token );
>          tokenIdx++;
>          token = strtok( NULL, " " );
>        }       
>        if( tokenIdx < 3 ) {
>          printf( "EDL line contains too few tokens: [%s]\n", line );
>          continue;
>        }
>        if( tokenIdx == 3 ) {
>          // Traditional format
>          start = vals[ 0 ];
>          stop = vals[ 1 ];
>          duration = stop - start;
>          action = vals[ 2 ];
>        } else {
>          // DVD format
>          chapter = vals[ 0 ];
>          start = vals[ 1 ];
>          stop = vals[ 2 ];
>          duration = stop - start;
>          action = vals[ 3 ];     
>        }
> 
>        if( next_edl_array_index > 0 ) {
>          edl_records[ next_edl_array_index-1 ].next = &edl_records[ 
> next_edl_array_index ];
>          if( start <= edl_records[ next_edl_array_index-1 ].stop_sec ) {
943c1022
<            printf( "Stop time must follow start time. Discarding EDL entry.\n" );
---
>            printf( "Last stop position was [%f]; next start is [%f]. Entries must be 
> in chronological order and cannot overlap. Discarding EDL entry.\n", edl_records[ 
> next_edl_array_index-1 ].stop_sec, start );
946,964c1025,1036
<          edl_records[ next_edl_array_index ].action = action;
<          if( action == EDL_MUTE ) {
<            edl_records[ next_edl_array_index ].length_sec = 0;
<            edl_records[ next_edl_array_index ].start_sec = start;
<            edl_records[ next_edl_array_index ].stop_sec = start;
<            next_edl_array_index++;
<            if( next_edl_array_index >= MAX_EDL_ENTRIES-1 ) {
<              break;
<            }
<            edl_records[ next_edl_array_index-1 ].next = &edl_records[ 
next_edl_array_index ];
<            edl_records[ next_edl_array_index ].action = EDL_MUTE;
<            edl_records[ next_edl_array_index ].length_sec = 0;
<            edl_records[ next_edl_array_index ].start_sec = stop;
<            edl_records[ next_edl_array_index ].stop_sec = stop;
<          } else {
<            edl_records[ next_edl_array_index ].length_sec = stop - start;
<            edl_records[ next_edl_array_index ].start_sec = start;
<            edl_records[ next_edl_array_index ].stop_sec = stop;
<          }
---
>        }
>        if( stop <= start ) {
>          printf( "Invalid EDL line [%d]: [%s]\n", lineCount, line );
>          printf( "Stop time must follow start time. Discarding EDL entry.\n" );
>          continue;
>        }
>        edl_records[ next_edl_array_index ].action = action;
>        edl_records[ next_edl_array_index ].chapter = chapter;
>        if( action == EDL_MUTE ) {
>          edl_records[ next_edl_array_index ].length_sec = 0;
>          edl_records[ next_edl_array_index ].start_sec = start;
>          edl_records[ next_edl_array_index ].stop_sec = start;
968a1041,1054
>          edl_records[ next_edl_array_index-1 ].next = &edl_records[ 
> next_edl_array_index ];
>          edl_records[ next_edl_array_index ].action = EDL_MUTE;
>          edl_records[ next_edl_array_index ].chapter = edl_records[ 
> next_edl_array_index-1 ].chapter;
>          edl_records[ next_edl_array_index ].length_sec = 0;
>          edl_records[ next_edl_array_index ].start_sec = stop;
>          edl_records[ next_edl_array_index ].stop_sec = stop;
>        } else {
>          edl_records[ next_edl_array_index ].length_sec = stop - start;
>          edl_records[ next_edl_array_index ].start_sec = start;
>          edl_records[ next_edl_array_index ].stop_sec = stop;
>        }
>        next_edl_array_index++;
>        if( next_edl_array_index >= MAX_EDL_ENTRIES-1 ) {
>          break;
1001c1087
<        printf( "EDL: start [%f], stop [%f], action [%d]\n", 
next_edl_record->start_sec, next_edl_record->stop_sec, next_edl_record->action );
---
>        printf( "EDL: chapter [%d], start [%f], stop [%f], action [%d]\n", 
> next_edl_record->chapter, next_edl_record->start_sec, next_edl_record->stop_sec, 
> next_edl_record->action );
1010d1095
< 
2395a2481,2490
> #ifdef USE_DVDREAD
>    dvd_priv_t* dvdp = stream->priv;
>    if( ( ( stream->type == STREAMTYPE_DVD ) && 
>        ( ( ( next_edl_record->chapter == -1 ) || 
>          ( ( dvd_chapter_from_cell( dvdp, 0, dvdp->cur_cell ) + 1 ) ==
>          next_edl_record->chapter ) ) &&
>        sh_video->pts >= next_edl_record->start_sec ) ) ||
>        ( stream->type != STREAMTYPE_DVD && 
>        sh_video->pts >= next_edl_record->start_sec ) ) {
> #else
2396a2492
> #endif
2407c2503
<        mixer_mute();
---
>        toggleMute( EDL_MUTE_REQUESTOR );
2454a2551,2559
> #ifdef USE_DVDREAD
>       if( stream->type == STREAMTYPE_DVD ) {
>         dvd_priv_t* dvdp = stream->priv;
>         int chapter = ( dvd_chapter_from_cell( dvdp, 0, dvdp->cur_cell ) + 1 );
>         fprintf( edl_fd, "%d %f %f %d\n", chapter, v-2, v, 0 );         
>       } else {
>         fprintf( edl_fd, "%f %f %d\n", v-2, v, 0 );
>       }
> #else
2455a2561
> #endif
2582a2689,2691
> #ifdef USE_EDL
>       toggleMute( USER_MUTE_REQUESTOR );
> #else
2583a2693
> #endif
3264c3374,3387
<           if( edl_records[ x ].start_sec >= sh_video->pts && edl_records[ x ].action 
!= EDL_MUTE ) {
---
> #ifdef USE_DVDREAD
>           dvd_priv_t* dvdp = stream->priv;
>           // I should be a Perl programmer...
>           if( ( ( edl_records[ x ].action != EDL_MUTE ) && 
>                 ( edl_records[ x ].start_sec >= sh_video->pts ) ) && 
>               ( ( stream->type != STREAMTYPE_DVD ) || 
>                 ( ( stream->type == STREAMTYPE_DVD ) && 
>                   ( ( edl_records[ x ].chapter == -1 ) || 
>                     ( ( dvd_chapter_from_cell( dvdp, 0, dvdp->cur_cell ) + 1 ) ==
>                     edl_records[ x ].chapter ) ) ) ) ) {
> #else
>           if( ( edl_records[ x ].start_sec >= sh_video->pts ) &&
>               (edl_records[ x ].action != EDL_MUTE ) ) {
> #endif // USE_DVDREAD
3273c3396
< #endif
---
> #endif // USE_EDL

-- 
------------------------------------------- | ---------------------
Michael Halcrow                             | [EMAIL PROTECTED]     
Developer, IBM Linux Technology Center      |                      
                                            |
Want to make $$$$ really quick? It's easy:  |
Hold down Shift and hit '4' four times.     |
------------------------------------------- | ---------------------
GnuPG Keyprint:  05B5 08A8 713A 64C1 D35D  2371 2D3C FDDA 3EB6 601D

Attachment: pgp00000.pgp
Description: PGP signature

____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to