1
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 06:03:45 +01:00

Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch

by "Reynaldo H. Verdejo Pinochet" <reynaldo at opendot dot cl>, spelling
and wording corrections by me.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13359 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
diego 2004-09-17 02:28:44 +00:00
parent 6068c1846e
commit a42fd601ef
5 changed files with 83 additions and 47 deletions

43
edl.c
View File

@ -3,9 +3,18 @@
#include "config.h"
#include "mp_msg.h"
#include "edl.h"
#include "help_mp.h"
#ifdef USE_EDL
/**
* We can't do -edl and -edlout at the same time
* so we check that here.
*
* \return EDL_ERROR on error and 1 otherwise.
* \brief Makes sure EDL has been called correctly.
*/
int edl_check_mode(void)
{
if (edl_filename && edl_output_filename)
@ -16,6 +25,13 @@ int edl_check_mode(void)
return (1);
}
/** Calculates the total amount of edl_records we will need
* to hold the EDL operations queue, we need one edl_record
* for each SKIP and two for each MUTE.
* \return Number of necessary EDL entries, EDL_ERROR when file can't be read.
* \brief Counts needed EDL entries.
*/
int edl_count_entries(void)
{
FILE *fd = NULL;
@ -29,8 +45,7 @@ int edl_count_entries(void)
{
if ((fd = fopen(edl_filename, "r")) == NULL)
{
mp_msg(MSGT_CPLAYER, MSGL_WARN,
"Invalid EDL file, cant open '%s' for reading!\n",
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlCantOpenForRead,
edl_filename);
return (EDL_ERROR);
} else
@ -46,8 +61,7 @@ int edl_count_entries(void)
entries += 2;
} else
{
mp_msg(MSGT_CPLAYER, MSGL_WARN,
"Invalid EDL line: %s\n", line);
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line);
return (EDL_ERROR);
}
@ -61,6 +75,11 @@ int edl_count_entries(void)
return (entries);
}
/** Parses edl_filename to fill EDL operations queue.
* \return Number of stored EDL records or EDL_ERROR when file can't be read.
* \brief Fills EDL operations queue.
*/
int edl_parse_file(edl_record_ptr edl_records)
{
FILE *fd;
@ -84,9 +103,8 @@ int edl_parse_file(edl_record_ptr edl_records)
if ((sscanf(line, "%f %f %d", &start, &stop, &action))
!= 3)
{
mp_msg(MSGT_CPLAYER, MSGL_WARN,
"Badly formated EDL line [%d]. Discarding!\n",
lineCount + 1, line);
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadlyFormattedLine,
lineCount + 1);
continue;
} else
{
@ -95,21 +113,18 @@ int edl_parse_file(edl_record_ptr edl_records)
if (start <= (next_edl_record - 1)->stop_sec)
{
mp_msg(MSGT_CPLAYER, MSGL_WARN,
"Invalid EDL line [%d]: %s",
lineCount, line);
MSGTR_EdlNOValidLine, line);
mp_msg(MSGT_CPLAYER, MSGL_WARN,
"Last stop position was [%f]; next start is [%f]. Entries must be in chronological order and cannot overlap. Discarding!\n",
MSGTR_EdlBadLineOverlap,
(next_edl_record - 1)->stop_sec, start);
continue;
}
}
if (stop <= start)
{
mp_msg(MSGT_CPLAYER, MSGL_WARN,
"Invalid EDL line [%d]: %s", lineCount,
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine,
line);
mp_msg(MSGT_CPLAYER, MSGL_WARN,
"Stop time must follow start time. Discarding!\n");
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop);
continue;
}
next_edl_record->action = action;

8
edl.h
View File

@ -23,11 +23,11 @@ struct edl_record {
typedef struct edl_record* edl_record_ptr;
char *edl_filename; // file to extract edl entries from (-edl)
char *edl_output_filename; // file to put edl entries in (-edlout)
char *edl_filename; // file to extract EDL entries from (-edl)
char *edl_output_filename; // file to put EDL entries in (-edlout)
int edl_check_mode(void); // we cannot do -edl and -edlout at the same time
int edl_count_entries(void); // returns total No of entries needed
int edl_parse_file(edl_record_ptr edl_records); // fills edl stack
int edl_count_entries(void); // returns total number of entries needed
int edl_parse_file(edl_record_ptr edl_records); // fills EDL stack
#endif

View File

@ -159,6 +159,18 @@ static char help_text[]=
" DOCS/HTML/en/bugreports.html and follow the instructions there. We can't and\n"\
" won't help unless you provide this information when reporting a possible bug.\n"
#define MSGTR_EdlCantUseBothModes "Can't use -edl and -edlout at the same time.\n"
#define MSGTR_EdlOutOfMem "Can't allocate enough memory to hold EDL data.\n"
#define MSGTR_EdlRecordsNo "Read %d EDL actions.\n"
#define MSGTR_EdlQueueEmpty "There are no EDL actions to take care of.\n"
#define MSGTR_EdlCantOpenForWrite "Error opening file [%s] for writing.\n"
#define MSGTR_EdlCantOpenForRead "Can't open EDL file [%s] for reading.\n"
#define MSGTR_EdlNOsh_video "Cannot use EDL without video, disabling.\n"
#define MSGTR_EdlNOValidLine "Invalid EDL line: %s\n"
#define MSGTR_EdlBadlyFormattedLine "Badly formatted EDL line [%d] Discarding.\n"
#define MSGTR_EdlBadLineOverlap "Last stop position was [%f]; next start is "\
"[%f]. Entries must be in chronological order, cannot overlap. Discarding.\n"
#define MSGTR_EdlBadLineBadStop "Stop time has to be after start time.\n"
// mencoder.c:

View File

@ -163,6 +163,21 @@ static char help_text[]=
" se encuentran. No podemos y no lo ayudaremos a menos que nos provea esa\n"\
" información cuando este reportando algún posible defecto.\n"
#define MSGTR_EdlCantUseBothModes "Imposible usar -edl y -edlout al mismo tiempo.\n"
#define MSGTR_EdlOutOfMem "No hay memoria suficiente para almacenar los datos EDL.\n"
#define MSGTR_EdlRecordsNo "Leidas %d acciones EDL.\n"
#define MSGTR_EdlQueueEmpty "No hay acciones EDL de las que ocuparse.\n"
#define MSGTR_EdlCantOpenForWrite "Error tratando de escribir en [%s].\n"
#define MSGTR_EdlCantOpenForRead "Error tratando de leer desde [%s].\n"
#define MSGTR_EdlNOsh_video "Imposible usar EDL sin video.\n"
#define MSGTR_EdlNOValidLine "Linea EDL inválida: %s\n"
#define MSGTR_EdlBadlyFormattedLine "Ignorando linea EDL mal formateada [%d].\n"
#define MSGTR_EdlBadLineOverlap "Ultima posición de parada fue [%f]; próxima "\
"posición de partida es [%f]. Las operaciones deben estar en orden cronológico"\
", sin sobreponerse, ignorando.\n"
#define MSGTR_EdlBadLineBadStop "La posición de parada debe ser posterior a la"\
" posición de partida.\n"
// mencoder.c:
#define MSGTR_UsingPass3ControllFile "Usando el archivo de control pass3: %s\n"

View File

@ -348,13 +348,13 @@ static char* rtc_device;
#endif
#ifdef USE_EDL
edl_record_ptr edl_records = NULL; // EDL entries memory area
edl_record_ptr next_edl_record = NULL; // only for traversing edl_records
int edl_memory_slots = 0; // No of EDL entries (1 for skip + 2 for each mute)
int edl_operations = 0; // No of EDL operations, skip + mute
short edl_decision = 0; // 1 when an EDL operation has been made
FILE* edl_fd = NULL; // fd to write to when in -edlout mode
int edl_mute_count = 0; // even number when mute has been matched mute/unmute
edl_record_ptr edl_records = NULL; /// EDL entries memory area
edl_record_ptr next_edl_record = NULL; /// only for traversing edl_records
int edl_memory_slots = 0; /// number of EDL entries (1 for skip + 2 for each mute)
int edl_operations = 0; /// number of EDL operations, skip + mute
short edl_decision = 0; /// 1 when an EDL operation has been made
FILE* edl_fd = NULL; /// fd to write to when in -edlout mode
int edl_mute_count = 0; /// even number when mute and unmute has been matched
#endif
static unsigned int inited_flags=0;
@ -476,6 +476,9 @@ static void exit_player_with_rc(char* how, int rc){
current_module="exit_player";
#ifdef USE_EDL
if(edl_records != NULL) free(edl_records); // free mem allocated for EDL
#endif
if(how) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_ExitingHow,mp_gettext(how));
mp_msg(MSGT_CPLAYER,MSGL_DBG2,"max framesize was %d bytes\n",max_framesize);
@ -975,13 +978,8 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
#ifdef USE_EDL
if (edl_check_mode() == EDL_ERROR && edl_filename)
{
mp_msg(MSGT_CPLAYER, MSGL_WARN,
"Cant use -edl and -edlout at the same time\n");
mp_msg(MSGT_CPLAYER, MSGL_WARN, "Not using EDL at all!!!\n");
edl_filename = NULL;
edl_output_filename = NULL;
edl_records = NULL;
next_edl_record = edl_records;
mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlCantUseBothModes);
exit_player(NULL);
} else if (edl_filename)
{
edl_memory_slots = edl_count_entries();
@ -990,20 +988,18 @@ if (edl_check_mode() == EDL_ERROR && edl_filename)
edl_records = calloc(edl_memory_slots, sizeof(struct edl_record));
if (edl_records == NULL)
{
mp_msg(MSGT_CPLAYER, MSGL_FATAL,
"Cant allocate enough memory to hold EDL data, exiting!\n");
mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_EdlOutOfMem);
exit_player(NULL);
} else
{
if ((edl_operations = edl_parse_file(edl_records)) > 0)
{
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Readed %d EDL actions\n",
mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlRecordsNo,
edl_operations);
} else
{
mp_msg(MSGT_CPLAYER, MSGL_INFO,
"There are no EDL actions to take care of\n");
mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlQueueEmpty);
}
}
}
@ -1014,11 +1010,9 @@ if (edl_check_mode() == EDL_ERROR && edl_filename)
{
if ((edl_fd = fopen(edl_output_filename, "w")) == NULL)
{
mp_msg(MSGT_CPLAYER, MSGL_WARN,
"Error opening file [%s] for writing!\n",
mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlCantOpenForWrite,
edl_output_filename);
edl_output_filename = NULL;
next_edl_record = edl_records;
exit_player(NULL);
}
}
#endif
@ -2450,7 +2444,7 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still)
#ifdef USE_EDL
if( next_edl_record ) { // Are we (still?) doing EDL?
if ( !sh_video ) {
mp_msg( MSGT_CPLAYER, MSGL_ERR, "Cannot use edit list without video. EDL disabled.\n" );
mp_msg( MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlNOsh_video );
next_edl_record->next = NULL;
} else {
if( sh_video->pts >= next_edl_record->start_sec ) {
@ -2464,7 +2458,7 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still)
edl_decision = 1;
} else if( next_edl_record->action == EDL_MUTE ) {
mixer_mute(&mixer);
edl_mute_count++; // new edl seek behavior need this
edl_mute_count++; // new EDL seek behavior needs this
#ifdef DEBUG_EDL
printf( "\nEDL_MUTE: [%f]\n", next_edl_record->start_sec );
#endif
@ -3524,16 +3518,16 @@ if(rel_seek_secs || abs_seek_pos){
}
#ifdef USE_EDL
/*
* We Saw a seek, have to rewind the edl operations stak
* and find the next edl action to take care off
* We saw a seek, have to rewind the EDL operations stack
* and find the next EDL action to take care of.
*/
next_edl_record = edl_records;
while (next_edl_record)
{
/* trying to remember if we need to mute/unmute first
* prior edl implementation lacks this
/* Trying to remember if we need to mute/unmute first;
* prior EDL implementation lacks this.
*/
if (next_edl_record->start_sec >= sh_video->pts)