Index: cfg-common.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-common.h,v
retrieving revision 1.139
diff -u -r1.139 cfg-common.h
--- cfg-common.h	24 Feb 2005 15:00:47 -0000	1.139
+++ cfg-common.h	25 Feb 2005 05:27:41 -0000
@@ -74,6 +74,11 @@
 	{"sb", &seek_to_byte, CONF_TYPE_POSITION, CONF_MIN, 0, 0, NULL},
 	{"ss", &seek_to_sec, CONF_TYPE_STRING, CONF_MIN, 0, 0, NULL},
 
+#ifdef USE_EDL
+	{"edl", &edl_filename,  CONF_TYPE_STRING, 0, 0, 0, NULL}, 
+#else
+	{"edl", "MPlayer was compiled without EDL support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
+#endif
 	// AVI specific: force non-interleaved mode
 	{"ni", &force_ni, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"noni", &force_ni, CONF_TYPE_FLAG, 0, 1, 0, NULL},
Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.242
diff -u -r1.242 cfg-mplayer.h
--- cfg-mplayer.h	23 Feb 2005 01:43:15 -0000	1.242
+++ cfg-mplayer.h	25 Feb 2005 05:27:43 -0000
@@ -181,10 +181,8 @@
 	{"noalsa", "-noalsa has been removed. Remove it from your config file.\n",
             CONF_TYPE_PRINT, 0, 0, 0, NULL},
 #ifdef USE_EDL
-	{"edl", &edl_filename,  CONF_TYPE_STRING, 0, 0, 0, NULL}, 
 	{"edlout", &edl_output_filename,  CONF_TYPE_STRING, 0, 0, 0, NULL}, 
 #else
-	{"edl", "MPlayer was compiled without EDL support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
 	{"edlout", "MPlayer was compiled without EDL support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
 #endif
 
Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.265
diff -u -r1.265 mencoder.c
--- mencoder.c	25 Feb 2005 02:32:29 -0000	1.265
+++ mencoder.c	25 Feb 2005 05:27:50 -0000
@@ -350,6 +350,14 @@
 
 extern void print_wave_header(WAVEFORMATEX *h);
 
+#ifdef USE_EDL
+#include "edl.h"
+static edl_record_ptr edl_records = NULL; ///< EDL entries memory area
+static edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records
+static short edl_muted; ///< Stores whether EDL is currently in muted mode.
+static short edl_seeking; ///< When non-zero, stream is seekable.
+#endif
+
 int main(int argc,char* argv[]){
 
 stream_t* stream=NULL;
@@ -1301,6 +1309,15 @@
 play_n_frames=play_n_frames_mf;
 if (curfile && end_at_type == END_AT_TIME) end_at += mux_v->timer;
 
+#ifdef USE_EDL
+if (edl_filename) {
+    if (edl_records) free_edl(edl_records);
+    next_edl_record = edl_records = edl_parse_file();
+}
+edl_muted = 0;
+edl_seeking = 1;
+#endif
+
 while(!at_eof){
 
     float frame_time=0;
@@ -1319,6 +1336,49 @@
       --play_n_frames;
       if(play_n_frames<0) break;
     }
+    
+#ifdef USE_EDL
+goto_redo_edl:
+    if (next_edl_record) {
+        if (d_video && d_video->pts >= next_edl_record->start_sec) {
+            if (next_edl_record->action == EDL_SKIP && edl_seeking) {
+                float last_pos = d_video->pts;
+                mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_SKIP: start [%f], stop [%f], length [%f]\n", 
+                       next_edl_record->start_sec, next_edl_record->stop_sec, next_edl_record->length_sec);
+                if(demux_seek(demuxer, next_edl_record->stop_sec - d_video->pts, 0)){
+                    sh_video->pts=d_video->pts;
+                    //if (vo_vobsub) vobsub_seek(vo_vobsub,sh_video->pts);
+                    resync_video_stream(sh_video);
+                    //if(vo_spudec) spudec_reset(vo_spudec);  
+                }
+                else { // eep, non-seekable stream.
+                    edl_seeking = 0;
+                }
+                edl_muted = 0;
+                if (last_pos >= d_video->pts) {
+                    // backwards seek detected!! Forget about this EDL skip altogether.
+                    next_edl_record = next_edl_record->next;
+                }
+                else for (next_edl_record = edl_records; next_edl_record; next_edl_record = next_edl_record->next) {
+                    /* note the use of stop_sec,
+                       meaning if by some magical way we landed in the MIDDLE of a censored area,
+                       in the next loop it will jump out of it.
+                    */ 
+                    if (next_edl_record->stop_sec > d_video->pts) break; // we got to the right place.
+                    if (next_edl_record->action == EDL_MUTE) edl_muted = !edl_muted; // toggle mute each time.
+                }
+                /* for a pedantic EDL, that doesn't show even a single
+                   frame from the "censored" area, uncomment next line. */
+                goto goto_redo_edl;
+            } else if (next_edl_record->action == EDL_MUTE) {
+                edl_muted = !edl_muted;  // This variable does nothing for now.
+                mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_MUTE: [%f]\n", next_edl_record->start_sec );
+                next_edl_record=next_edl_record->next;
+            }
+        }
+    }
+#endif
+
 
 if(sh_audio){
     // get audio:
@@ -2030,9 +2090,22 @@
 #endif
 
 static float stop_time(demuxer_t* demuxer, muxer_stream_t* mux_v) {
-	// demuxer is for future support for EDL
 	float timeleft = -1;
 	if (play_n_frames >= 0) timeleft = mux_v->timer + play_n_frames * (double)(mux_v->h.dwScale) / mux_v->h.dwRate;
 	if (end_at_type == END_AT_TIME && (timeleft > end_at || timeleft == -1)) timeleft = end_at;
+#ifdef USE_EDL
+	if (next_edl_record && demuxer && demuxer->video) { // everything is OK to be checked
+		int tmp = mux_v->timer + next_edl_record->start_sec - demuxer->video->pts;
+		if (timeleft == -1 || timeleft > tmp) {
+			// There's less time in EDL than what we already know
+			if (next_edl_record->action == EDL_SKIP && edl_seeking) {
+				timeleft = tmp;
+			} else if (next_edl_record->action == EDL_MUTE) {
+				//timeleft = next_edl_record->start_sec - demuxer->video->pts;
+				// For the moment (and probably forever) EDL mute doesn't work in MEncoder
+			}
+		}
+	}
+#endif
 	return timeleft;
 }
