Mercurial > mplayer.hg
comparison mplayer.c @ 8531:1aa2c9b460af
Merged EDL 0.5 patch - it's something like Quicktime's edit lists.
(skip sections listed in a text file. it also supports creating them)
patch by Michael Halcrow <mah69@email.byu.edu>
author | arpi |
---|---|
date | Mon, 23 Dec 2002 00:33:22 +0000 |
parents | 47cf94058137 |
children | 922ce27eb683 |
comparison
equal
deleted
inserted
replaced
8530:f667ebaec04e | 8531:1aa2c9b460af |
---|---|
52 #include "libmpdemux/dvdauth.h" | 52 #include "libmpdemux/dvdauth.h" |
53 #endif | 53 #endif |
54 | 54 |
55 #ifdef USE_DVDNAV | 55 #ifdef USE_DVDNAV |
56 #include <dvdnav.h> | 56 #include <dvdnav.h> |
57 #endif | |
58 | |
59 #ifdef USE_EDL | |
60 #include "edl.h" | |
57 #endif | 61 #endif |
58 | 62 |
59 #include "spudec.h" | 63 #include "spudec.h" |
60 #include "vobsub.h" | 64 #include "vobsub.h" |
61 | 65 |
294 #endif | 298 #endif |
295 | 299 |
296 | 300 |
297 #ifdef HAVE_RTC | 301 #ifdef HAVE_RTC |
298 static int nortc; | 302 static int nortc; |
303 #endif | |
304 | |
305 #ifdef USE_EDL | |
306 struct edl_record edl_records[ MAX_EDL_ENTRIES ]; | |
307 int num_edl_records = 0; | |
308 FILE* edl_fd = NULL; | |
309 edl_record_ptr next_edl_record = NULL; | |
310 static char* edl_filename = NULL; | |
311 static char* edl_output_filename = NULL; | |
312 short edl_decision = 0; | |
299 #endif | 313 #endif |
300 | 314 |
301 static unsigned int inited_flags=0; | 315 static unsigned int inited_flags=0; |
302 #define INITED_VO 1 | 316 #define INITED_VO 1 |
303 #define INITED_AO 2 | 317 #define INITED_AO 2 |
723 afm_help(); | 737 afm_help(); |
724 printf("\n"); | 738 printf("\n"); |
725 exit(0); | 739 exit(0); |
726 } | 740 } |
727 | 741 |
742 #ifdef USE_EDL | |
743 { | |
744 FILE* fd; | |
745 char line[ 100 ]; | |
746 float start, stop, duration; | |
747 int action; | |
748 int next_edl_array_index = 0; | |
749 int lineCount = 0; | |
750 next_edl_record = edl_records; | |
751 if( edl_filename ) { | |
752 if( ( fd = fopen( edl_filename, "r" ) ) == NULL ) { | |
753 printf( "Error opening EDL file [%s]!\n", edl_filename ); | |
754 next_edl_record->next = NULL; | |
755 } else { | |
756 while( fgets( line, 99, fd ) != NULL ) { | |
757 lineCount++; | |
758 if( ( sscanf( line, "%f %f %d", &start, &stop, &action ) ) == 0 ) { | |
759 printf( "Invalid EDL line: [%s]\n", line ); | |
760 } else { | |
761 if( next_edl_array_index > 0 ) { | |
762 edl_records[ next_edl_array_index-1 ].next = &edl_records[ next_edl_array_index ]; | |
763 if( start <= edl_records[ next_edl_array_index-1 ].stop_sec ) { | |
764 printf( "Invalid EDL line [%d]: [%s]\n", lineCount, line ); | |
765 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 ); | |
766 continue; | |
767 } | |
768 } | |
769 if( stop <= start ) { | |
770 printf( "Invalid EDL line [%d]: [%s]\n", lineCount, line ); | |
771 printf( "Stop time must follow start time. Discarding EDL entry.\n" ); | |
772 continue; | |
773 } | |
774 edl_records[ next_edl_array_index ].action = action; | |
775 if( action == EDL_MUTE ) { | |
776 edl_records[ next_edl_array_index ].length_sec = 0; | |
777 edl_records[ next_edl_array_index ].start_sec = start; | |
778 edl_records[ next_edl_array_index ].stop_sec = start; | |
779 next_edl_array_index++; | |
780 if( next_edl_array_index >= MAX_EDL_ENTRIES-1 ) { | |
781 break; | |
782 } | |
783 edl_records[ next_edl_array_index-1 ].next = &edl_records[ next_edl_array_index ]; | |
784 edl_records[ next_edl_array_index ].action = EDL_MUTE; | |
785 edl_records[ next_edl_array_index ].length_sec = 0; | |
786 edl_records[ next_edl_array_index ].start_sec = stop; | |
787 edl_records[ next_edl_array_index ].stop_sec = stop; | |
788 } else { | |
789 edl_records[ next_edl_array_index ].length_sec = stop - start; | |
790 edl_records[ next_edl_array_index ].start_sec = start; | |
791 edl_records[ next_edl_array_index ].stop_sec = stop; | |
792 } | |
793 next_edl_array_index++; | |
794 if( next_edl_array_index >= MAX_EDL_ENTRIES-1 ) { | |
795 break; | |
796 } | |
797 } | |
798 } | |
799 if( next_edl_array_index > 0 ) { | |
800 edl_records[ next_edl_array_index-1 ].next = &edl_records[ next_edl_array_index ]; | |
801 } | |
802 edl_records[ next_edl_array_index ].start_sec = -1; | |
803 edl_records[ next_edl_array_index ].next = NULL; | |
804 num_edl_records = ( next_edl_array_index ); | |
805 } | |
806 fclose( fd ); | |
807 } else { | |
808 next_edl_record->next = NULL; | |
809 } | |
810 if( edl_output_filename ) { | |
811 if( edl_filename ) { | |
812 printf( "Sorry; EDL mode and EDL output mode are mutually exclusive! Disabling all EDL functions.\n" ); | |
813 edl_output_filename = NULL; | |
814 edl_filename = NULL; | |
815 next_edl_record->next = NULL; | |
816 } else { | |
817 if( ( edl_fd = fopen( edl_output_filename, "w" ) ) == NULL ) { | |
818 printf( "Error opening file [%s] for writing!\n" ); | |
819 edl_output_filename = NULL; | |
820 next_edl_record->next = NULL; | |
821 } | |
822 } | |
823 } | |
824 #ifdef DEBUG_EDL | |
825 { | |
826 printf( "EDL Records:\n" ); | |
827 if( next_edl_record->next != NULL ) { | |
828 while( next_edl_record->next != NULL ) { | |
829 printf( "EDL: start [%f], stop [%f], action [%d]\n", next_edl_record->start_sec, next_edl_record->stop_sec, next_edl_record->action ); | |
830 next_edl_record = next_edl_record->next; | |
831 } | |
832 next_edl_record = edl_records; | |
833 } | |
834 } | |
835 #endif | |
836 } | |
837 #endif | |
728 | 838 |
729 if(!filename && !vcd_track && !dvd_title && !dvd_nav && !tv_param_on){ | 839 if(!filename && !vcd_track && !dvd_title && !dvd_nav && !tv_param_on){ |
730 if(!use_gui){ | 840 if(!use_gui){ |
731 // no file/vcd/dvd -> show HELP: | 841 // no file/vcd/dvd -> show HELP: |
732 mp_msg(MSGT_CPLAYER, MSGL_INFO, help_text); | 842 mp_msg(MSGT_CPLAYER, MSGL_INFO, help_text); |
1953 #ifdef USE_DVDNAV | 2063 #ifdef USE_DVDNAV |
1954 if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still) | 2064 if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still) |
1955 dvdnav_stream_sleeping((dvdnav_priv_t*)stream->priv); | 2065 dvdnav_stream_sleeping((dvdnav_priv_t*)stream->priv); |
1956 #endif | 2066 #endif |
1957 | 2067 |
2068 //================= EDL ========================================= | |
2069 | |
2070 #ifdef USE_EDL | |
2071 if( next_edl_record->next ) { // Are we (still?) doing EDL? | |
2072 if( d_video->pts >= next_edl_record->start_sec ) { | |
2073 if( next_edl_record->action == EDL_SKIP ) { | |
2074 osd_function = OSD_FFW; | |
2075 abs_seek_pos = 0; | |
2076 rel_seek_secs = next_edl_record->length_sec; | |
2077 #ifdef DEBUG_EDL | |
2078 printf( "\nEDL_SKIP: start [%f], stop [%f], length [%f]\n", next_edl_record->start_sec, next_edl_record->stop_sec, next_edl_record->length_sec ); | |
2079 #endif | |
2080 edl_decision = 1; | |
2081 next_edl_record = next_edl_record->next; | |
2082 } else if( next_edl_record->action == EDL_MUTE ) { | |
2083 mixer_mute(); | |
2084 #ifdef DEBUG_EDL | |
2085 printf( "\nEDL_MUTE: [%f]\n", next_edl_record->start_sec ); | |
2086 #endif | |
2087 edl_decision = 1; | |
2088 next_edl_record = next_edl_record->next; | |
2089 } | |
2090 } | |
2091 } | |
2092 #endif | |
2093 | |
1958 //================= Keyboard events, SEEKing ==================== | 2094 //================= Keyboard events, SEEKing ==================== |
1959 | 2095 |
1960 current_module="key_events"; | 2096 current_module="key_events"; |
1961 | 2097 |
1962 { | 2098 { |
1983 else { | 2119 else { |
1984 rel_seek_secs+= v; | 2120 rel_seek_secs+= v; |
1985 osd_function= (v > 0) ? OSD_FFW : OSD_REW; | 2121 osd_function= (v > 0) ? OSD_FFW : OSD_REW; |
1986 } | 2122 } |
1987 } break; | 2123 } break; |
2124 #ifdef USE_EDL | |
2125 case MP_CMD_EDL_MARK: | |
2126 if( edl_fd ) { | |
2127 float v = d_video->pts; | |
2128 fprintf( edl_fd, "%f %f %d\n", v-2, v, 0 ); | |
2129 } | |
2130 break; | |
2131 #endif | |
1988 case MP_CMD_AUDIO_DELAY : { | 2132 case MP_CMD_AUDIO_DELAY : { |
1989 float v = cmd->args[0].v.f; | 2133 float v = cmd->args[0].v.f; |
1990 audio_delay += v; | 2134 audio_delay += v; |
1991 osd_show_av_delay = 9; | 2135 osd_show_av_delay = 9; |
1992 if(sh_audio) sh_audio->delay+= v; | 2136 if(sh_audio) sh_audio->delay+= v; |
2663 audio_out->reset(); // stop audio, throwing away buffered data | 2807 audio_out->reset(); // stop audio, throwing away buffered data |
2664 } | 2808 } |
2665 #ifdef USE_OSD | 2809 #ifdef USE_OSD |
2666 // Set OSD: | 2810 // Set OSD: |
2667 if(osd_level){ | 2811 if(osd_level){ |
2668 int len=((demuxer->movi_end-demuxer->movi_start)>>8); | 2812 #ifdef USE_EDL |
2669 if (len>0 && sh_video){ | 2813 if( !edl_decision ) { |
2670 osd_visible=sh_video->fps; // 1 sec | 2814 #else |
2671 vo_osd_progbar_type=0; | 2815 if( 1 ) { // Let the compiler optimize this out |
2672 vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len; | 2816 #endif |
2673 vo_osd_changed(OSDTYPE_PROGBAR); | 2817 int len=((demuxer->movi_end-demuxer->movi_start)>>8); |
2818 if (len>0 && sh_video){ | |
2819 osd_visible=sh_video->fps; // 1 sec | |
2820 vo_osd_progbar_type=0; | |
2821 vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len; | |
2822 vo_osd_changed(OSDTYPE_PROGBAR); | |
2823 } | |
2674 } | 2824 } |
2675 } | 2825 } |
2676 #endif | 2826 #endif |
2677 if(sh_video) { | 2827 if(sh_video) { |
2678 c_total=0; | 2828 c_total=0; |
2684 too_fast_frame_cnt=0; | 2834 too_fast_frame_cnt=0; |
2685 | 2835 |
2686 if(vo_spudec) spudec_reset(vo_spudec); | 2836 if(vo_spudec) spudec_reset(vo_spudec); |
2687 } | 2837 } |
2688 } | 2838 } |
2839 #ifdef USE_EDL | |
2840 { | |
2841 int x; | |
2842 if( !edl_decision ) { | |
2843 for( x = 0; x < num_edl_records; x++ ) { // FIXME: do binary search | |
2844 // Find first EDL entry where start follows current time | |
2845 if( edl_records[ x ].start_sec >= d_video->pts && edl_records[ x ].action != EDL_MUTE ) { | |
2846 next_edl_record = &edl_records[ x ]; | |
2847 break; | |
2848 } | |
2849 } | |
2850 } else { | |
2851 edl_decision = 0; | |
2852 } | |
2853 } | |
2854 #endif | |
2689 rel_seek_secs=0; | 2855 rel_seek_secs=0; |
2690 abs_seek_pos=0; | 2856 abs_seek_pos=0; |
2691 frame_time_remaining=0; | 2857 frame_time_remaining=0; |
2692 current_module=NULL; | 2858 current_module=NULL; |
2693 } | 2859 } |