From f36b6cd3a1883f7d4be8c7f9c7276c1d79704df2 Mon Sep 17 00:00:00 2001 From: ivo Date: Sat, 4 Sep 2004 22:59:33 +0000 Subject: 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 --- libvo/vo_jpeg.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) (limited to 'libvo') 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; } -- cgit v1.2.3