[MPlayer-dev-eng] [PATCH] clean up EDL code

Oded Shimon ods15 at ods15.dyndns.org
Fri Mar 10 12:41:30 CET 2006


I don't remember if I wrote this or someone else, but the way it is right 
now is quite ugly (safe, but is "tricky" in that it scares automatic 
scanners...). Any objections to this patch

- ods15
-------------- next part --------------
Index: edl.c
===================================================================
RCS file: /cvsroot/mplayer/main/edl.c,v
retrieving revision 1.6
diff -u -r1.6 edl.c
--- edl.c	9 Feb 2006 14:07:51 -0000	1.6
+++ edl.c	10 Mar 2006 11:40:11 -0000
@@ -28,6 +28,7 @@
     if (next_edl_record) // if this isn't the first record, tell the previous one what the new one is.
         next_edl_record->next = new_record;
     new_record->prev = next_edl_record;
+    new_record->next = NULL;
     
     return new_record;
 }
@@ -62,8 +63,8 @@
     int action;
     int record_count = 0;
     int lineCount = 0;
-    edl_record_ptr edl_records = edl_alloc_new(NULL);
-    edl_record_ptr next_edl_record = edl_records;
+    edl_record_ptr edl_records = NULL;
+    edl_record_ptr next_edl_record = NULL;
 
     if (edl_filename)
     {
@@ -83,7 +84,7 @@
                     continue;
                 } else
                 {
-                    if (next_edl_record->prev && start <= next_edl_record->prev->stop_sec)
+                    if (next_edl_record && start <= next_edl_record->stop_sec)
                     {
                         mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line);
                         mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineOverlap,
@@ -97,6 +98,9 @@
                         mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop);
                         continue;
                     }
+                    next_edl_record = edl_alloc_new(next_edl_record);
+                    if (!edl_records) edl_records = next_edl_record;
+
                     next_edl_record->action = action;
                     if (action == EDL_MUTE)
                     {
@@ -116,22 +120,15 @@
                         next_edl_record->start_sec = start;
                         next_edl_record->stop_sec = stop;
                     }
-                    next_edl_record = edl_alloc_new(next_edl_record);
                     record_count++;
                 }
             }
         }
         fclose(fd);
     }        
-    if (next_edl_record->prev) {
-        next_edl_record->prev->next = NULL; // a record was before me, i don't want them thinking i'm a real record.
-        mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlRecordsNo, record_count);
-    }
-    else {
-        mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlQueueEmpty);
-        edl_records = NULL; // there was no previous record, we only had one record, the empty one.
-    }
-    free(next_edl_record);
+    if (edl_records) mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlRecordsNo, record_count);
+    else mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlQueueEmpty);
+
     return edl_records;
 }
 


More information about the MPlayer-dev-eng mailing list