From f36b6cd3a1883f7d4be8c7f9c7276c1d79704df2 Mon Sep 17 00:00:00 2001 From: ivo Date: Sat, 4 Sep 2004 22:59:33 +0000 Subject: [PATCH] Removal of -jpeg commandline option. It's replaced by an options parser in the module itself. Instead of mplayer -vo jpeg -jpeg options one now has to use mplayer -vo jpeg:options. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13248 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/man/en/mplayer.1 | 59 ++++++------- cfg-mplayer.h | 29 +------ help/help_mp-en.h | 9 ++ libvo/vo_jpeg.c | 188 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 225 insertions(+), 60 deletions(-) diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 4c20dc6a25..a9f85b7bfc 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -2074,39 +2074,6 @@ You can get a colored negative of the image with this option. Not supported by all video output drivers. . .TP -.B \-jpeg (\-vo jpeg only) -Specify options for the jpeg video output driver. -.sp 1 -Available options are: -.sp 1 -.PD 0 -.RSs -.IPs [no]progressive -Specify standard or progressive JPEG (default: noprogressive). -.IPs [no]baseline -Specify use of baseline or not (default: baseline). -.IPs optimize=<0\-100> -optimization factor (default: 100) -.IPs smooth=<0\-100> -smooth factor (default: 0) -.IPs quality=<0\-100> -quality factor (default: 75) -.IPs outdir= -Specify the directory to save the JPEG files to. -If not specified, all JPEG files are written to the current directory. -.IPs subdirs= -If specified, MPlayer will create numbered subdirectories with the -specified prefix. -If it's not specified, no subdirectories are created -and all JPEG files are written to the same directory. -.IPs maxfiles= -Maximum number of JPEG files to be saved per subdirectory in case subdirs -is specified. -Must be equal to or larger than 1 (default: 1000). -.RE -.PD 1 -. -.TP .B \-monitor-dotclock (\-vo fbdev and vesa only) Specify the dotclock or pixelclock range of the monitor. . @@ -2724,6 +2691,32 @@ Each file takes the frame number padded with leading zeros as name. .B jpeg\ \ \ Output each frame into a JPEG file in the current directory. Each file takes the frame number padded with leading zeros as name. +.PD 0 +.RSs +.IPs [no]progressive +Specify standard or progressive JPEG (default: noprogressive). +.IPs [no]baseline +Specify use of baseline or not (default: baseline). +.IPs optimize=<0\-100> +optimization factor (default: 100) +.IPs smooth=<0\-100> +smooth factor (default: 0) +.IPs quality=<0\-100> +quality factor (default: 75) +.IPs outdir= +Specify the directory to save the JPEG files to. +If not specified, all JPEG files are written to the current directory. +.IPs subdirs= +If specified, MPlayer will create numbered subdirectories with the +specified prefix. +If it's not specified, no subdirectories are created +and all JPEG files are written to the same directory. +.IPs maxfiles= +Maximum number of JPEG files to be saved per subdirectory in case subdirs +is specified. +Must be equal to or larger than 1 (default: 1000). +.RE +.PD 1 . .TP .B pgm\ \ \ \ diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 0536f592f8..b0498a4552 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -29,16 +29,6 @@ extern char *dfb_params; #ifdef HAVE_PNG extern int z_compression; #endif -#ifdef HAVE_JPEG -extern int jpeg_baseline; -extern int jpeg_progressive_mode; -extern int jpeg_optimize; -extern int jpeg_smooth; -extern int jpeg_quality; -extern char * jpeg_outdir; -extern char * jpeg_subdirs; -extern int jpeg_maxfiles; -#endif #ifdef HAVE_SDL //extern char *sdl_driver; extern int sdl_noxv; @@ -144,22 +134,6 @@ m_option_t ao_plugin_conf[]={ {NULL, NULL, 0, 0, 0, 0, NULL} }; -#ifdef HAVE_JPEG -m_option_t jpeg_conf[]={ - {"progressive", &jpeg_progressive_mode, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - {"noprogressive", &jpeg_progressive_mode, CONF_TYPE_FLAG, 0, 1, 0, NULL}, - {"baseline", &jpeg_baseline, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - {"nobaseline", &jpeg_baseline, CONF_TYPE_FLAG, 0, 1, 0, NULL}, - {"optimize", &jpeg_optimize, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, - {"smooth", &jpeg_smooth, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, - {"quality", &jpeg_quality, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, - {"outdir", &jpeg_outdir, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"subdirs", &jpeg_subdirs, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"maxfiles", &jpeg_maxfiles, CONF_TYPE_INT, CONF_MIN, 1, 0, NULL}, - {NULL, NULL, 0, 0, 0, 0, NULL} -}; -#endif - extern int sws_flags; extern int readPPOpt(void *conf, char *arg); extern void revertPPOpt(void *conf, char* opt); @@ -228,7 +202,8 @@ m_option_t mplayer_opts[]={ #endif // -vo jpeg only: #ifdef HAVE_JPEG - {"jpeg", jpeg_conf, CONF_TYPE_SUBCONFIG, 0,0,0, NULL}, + {"jpeg", "-jpeg is deprecated. Use -vo jpeg:options instead.\n", + CONF_TYPE_PRINT, 0, 0, 0, NULL}, #endif // -vo sdl only: #ifdef HAVE_SDL diff --git a/help/help_mp-en.h b/help/help_mp-en.h index ccc563e68a..2649dc0c9e 100644 --- a/help/help_mp-en.h +++ b/help/help_mp-en.h @@ -758,4 +758,13 @@ static char help_text[]= #define MSGTR_VO_JPEG_DirExistsAndIsWritable "Output directory already exists and is writable." #define MSGTR_VO_JPEG_CantCreateDirectory "Unable to create ouput directory." #define MSGTR_VO_JPEG_DirectoryCreateSuccess "Output directory successfully created." +#define MSGTR_VO_JPEG_ParsingSuboptions "Parsing suboptions." +#define MSGTR_VO_JPEG_SuboptionsParsedOK "Suboptions parsed OK." +#define MSGTR_VO_JPEG_ProgressiveJPEG "Progressive JPEG enabled." +#define MSGTR_VO_JPEG_NoProgressiveJPEG "Progressive JPEG disabled." +#define MSGTR_VO_JPEG_BaselineJPEG "Baseline JPEG enabled." +#define MSGTR_VO_JPEG_NoBaselineJPEG "Baseline JPEG disabled." +#define MSGTR_VO_JPEG_ValueOutOfRange "Value out of range" +#define MSGTR_VO_JPEG_NoValueSpecified "No value specified." +#define MSGTR_VO_JPEG_UnknownOptions "Unknown option(s)" diff --git a/libvo/vo_jpeg.c b/libvo/vo_jpeg.c index 5a2c865e6c..0b40c14b8a 100644 --- a/libvo/vo_jpeg.c +++ b/libvo/vo_jpeg.c @@ -25,6 +25,7 @@ #include #include #include +#include /* for log10() */ /* ------------------------------------------------------------------------- */ @@ -305,6 +306,193 @@ static void check_events(void) static uint32_t preinit(const char *arg) { + char *buf; /* buf is used to store parsed string values */ + int length; /* length is used when calculating the length of buf */ + int value; /* storage for parsed integer values */ + + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, + MSGTR_VO_JPEG_ParsingSuboptions); + + if (arg) { + + while (*arg != '\0') { + if (!strncmp(arg, ":", 1)) { + arg++; + continue; /* multiple ':' is not really an error */ + } if (!strncmp(arg, "progressive", 11)) { + arg += 11; + jpeg_progressive_mode = 1; + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, + MSGTR_VO_JPEG_ProgressiveJPEG); + } else if (!strncmp(arg, "noprogressive", 13)) { + arg += 13; + jpeg_progressive_mode = 0; + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, + MSGTR_VO_JPEG_NoProgressiveJPEG); + } else if (!strncmp(arg, "baseline", 8)) { + arg += 8; + jpeg_baseline = 1; + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, + MSGTR_VO_JPEG_BaselineJPEG); + } else if (!strncmp(arg, "nobaseline", 10)) { + arg += 10; + jpeg_baseline = 0; + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, + MSGTR_VO_JPEG_NoBaselineJPEG); + } else if (!strncmp(arg, "optimize=", 9)) { + arg += 9; + if (sscanf(arg, "%d", &value) == 1) { + if ( (value < 0 ) || (value > 100) ) { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", + info.short_name, "optimize", + MSGTR_VO_JPEG_ValueOutOfRange, "[0-100]"); + exit_player(MSGTR_Exit_error); + } else { + jpeg_optimize = value; + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", + info.short_name, "optimize", value); + } + } else { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", + info.short_name, "optimize", + MSGTR_VO_JPEG_NoValueSpecified); + exit_player(MSGTR_Exit_error); + } + /* only here if value is set and sane */ + if (value) { + arg += (int)log10(value) + 1; + } else { + arg++; /* log10(0) fails */ + } + } else if (!strncmp(arg, "smooth=", 7)) { + arg += 7; + if (sscanf(arg, "%d", &value) == 1 ) { + if ( (value < 0) || (value > 100) ) { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", + info.short_name, "smooth", + MSGTR_VO_JPEG_ValueOutOfRange, "[0-100]"); + exit_player(MSGTR_Exit_error); + } else { + jpeg_smooth = value; + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", + info.short_name, "smooth", value); + } + } else { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", + info.short_name, "smooth", + MSGTR_VO_JPEG_NoValueSpecified); + exit_player(MSGTR_Exit_error); + } + /* only here if value is set and sane */ + if (value) { + arg += (int)log10(value) + 1; + } else { + arg++; /* log10(0) fails */ + } + } else if (!strncmp(arg, "quality=", 8)) { + arg += 8; + if (sscanf(arg, "%d", &value) == 1) { + if ( (value < 0) || (value > 100) ) { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", + info.short_name, "quality", + MSGTR_VO_JPEG_ValueOutOfRange, "[0-100]"); + exit_player(MSGTR_Exit_error); + } else { + jpeg_quality = value; + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", + info.short_name, "quality", value); + } + } else { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", + info.short_name, "quality", + MSGTR_VO_JPEG_NoValueSpecified); + exit_player(MSGTR_Exit_error); + } + /* only here if value is set and sane */ + if (value) { + arg += (int)log10(value) + 1; + } else { + arg++; /* log10(0) fails */ + } + } else if (!strncmp(arg, "outdir=", 7)) { + arg += 7; + buf = malloc(strlen(arg)+1); /* maximum length possible */ + if (!buf) { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s\n", info.short_name, + MSGTR_MemAllocFailed); + exit_player(MSGTR_Exit_error); + } + if (sscanf(arg, "%[^:]", buf) == 1) { + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %s\n", + info.short_name, "outdir", buf); + length = strlen(buf); + arg += length; + jpeg_outdir = malloc(length+1); + strncpy(jpeg_outdir, buf, length+1); + free(buf); + } else { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", + info.short_name, "outdir", + MSGTR_VO_JPEG_NoValueSpecified); + exit_player(MSGTR_Exit_error); + } + } else if (!strncmp(arg, "subdirs=", 8)) { + arg += 8; + buf = malloc(strlen(arg)+1); /* maximum length possible */ + if (!buf) { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s\n", info.short_name, + MSGTR_MemAllocFailed); + exit_player(MSGTR_Exit_error); + } + if (sscanf(arg, "%[^:]", buf) == 1) { + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %s\n", + info.short_name, "subdirs", buf); + length = strlen(buf); + arg += length; + jpeg_subdirs = malloc(length+1); + strncpy(jpeg_subdirs, buf, length+1); + free(buf); + } else { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", + info.short_name, "subdirs", + MSGTR_VO_JPEG_NoValueSpecified); + exit_player(MSGTR_Exit_error); + } + } else if (!strncmp(arg, "maxfiles=", 9)) { + arg += 9; + if (sscanf(arg, "%d", &value) == 1) { + if (value < 1) { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", + info.short_name, "maxfiles", + MSGTR_VO_JPEG_ValueOutOfRange, ">=1"); + exit_player(MSGTR_Exit_error); + } else { + jpeg_maxfiles = value; + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", + info.short_name, "maxfiles", value); + } + } else { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", + info.short_name, "maxfiles", + MSGTR_VO_JPEG_NoValueSpecified); + exit_player(MSGTR_Exit_error); + } + /* only here if value is set and sane */ + if (value) { + arg += (int)log10(value) + 1; + } else { + arg++; /* log10(0) fails */ + } + } else { + mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %-20s...\n", info.short_name, + MSGTR_VO_JPEG_UnknownOptions, arg); + exit_player(MSGTR_Exit_error); + } + } /* end while */ + } /* endif */ + + mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, + MSGTR_VO_JPEG_SuboptionsParsedOK); return 0; }