From 20571d6f6870dab84624cc6b6fbac82cde204f16 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 2 Oct 2008 05:01:36 +0300 Subject: Revert "add outdir sub-option to vo png" This reverts commit 22322409ddb527ac855ba71d10dadcb9da415f81. The reverted commit had at least the following problems: - It adds a lot of filesystem handling code to an individual VO. - The added code is duplicated from vo_jpeg.c. - The added code has exit_player() calls. A VO should not exit the whole program. Even if vo_jpeg still has those calls they are a bug that shouldn't spread elsewhere. - The functionality benefit of automatic directory creation is questionable. It was probably only included in vo_jpeg because of the option to automatically create multiple subdirectories (though the utility of that is also questionable); vo_png does not have that. --- DOCS/man/en/mplayer.1 | 2 -- DOCS/man/fr/mplayer.1 | 2 -- libvo/vo_png.c | 66 ++------------------------------------------------- 3 files changed, 2 insertions(+), 68 deletions(-) diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 92febf4f3e..a169cbe613 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -4200,8 +4200,6 @@ Each file takes the frame number padded with leading zeros as name. .IPs z=<0\-9> Specifies the compression level. 0 is no compression, 9 is maximum compression. -.IPs outdir= -Specify the directory to save the PNG files to (default: ./). .RE .PD 1 . diff --git a/DOCS/man/fr/mplayer.1 b/DOCS/man/fr/mplayer.1 index 5bce784185..eacff95201 100644 --- a/DOCS/man/fr/mplayer.1 +++ b/DOCS/man/fr/mplayer.1 @@ -4436,8 +4436,6 @@ Ne g .IPs z=<0\-9> Définit le taux de compression. 0 équivaut à pas de compression et 9 à la compression maximale. -.IPs outdir= -Définit le répertoire où sauver les fichiers PNG (par défaut\ ./). .RE .PD 1 . diff --git a/libvo/vo_png.c b/libvo/vo_png.c index f5cdfe8f3b..791dfd515d 100644 --- a/libvo/vo_png.c +++ b/libvo/vo_png.c @@ -11,9 +11,6 @@ #include #include #include -#include -#include -#include #include @@ -25,8 +22,6 @@ #include "video_out_internal.h" #include "subopt-helper.h" -#define BUFLENGTH 512 - static const vo_info_t info = { "PNG file", @@ -38,7 +33,6 @@ static const vo_info_t info = const LIBVO_EXTERN (png) static int z_compression = Z_NO_COMPRESSION; -static char *png_outdir = NULL; static int framenum = 0; struct pngdata { @@ -48,56 +42,9 @@ struct pngdata { enum {OK,ERROR} status; }; -static void png_mkdir(char *buf, int verbose) { - struct stat stat_p; - -#ifndef __MINGW32__ - if ( mkdir(buf, 0755) < 0 ) { -#else - if ( mkdir(buf) < 0 ) { -#endif - switch (errno) { /* use switch in case other errors need to be caught - and handled in the future */ - case EEXIST: - if ( stat(buf, &stat_p ) < 0 ) { - mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, - MSGTR_VO_GenericError, strerror(errno) ); - mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, - MSGTR_VO_UnableToAccess,buf); - exit_player(MSGTR_Exit_error); - } - if ( !S_ISDIR(stat_p.st_mode) ) { - mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, - buf, MSGTR_VO_ExistsButNoDirectory); - exit_player(MSGTR_Exit_error); - } - if ( !(stat_p.st_mode & S_IWUSR) ) { - mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, - buf, MSGTR_VO_DirExistsButNotWritable); - exit_player(MSGTR_Exit_error); - } - - mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, - buf, MSGTR_VO_DirExistsAndIsWritable); - break; - - default: - mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, - MSGTR_VO_GenericError, strerror(errno) ); - mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, - buf, MSGTR_VO_CantCreateDirectory); - exit_player(MSGTR_Exit_error); - } /* end switch */ - } else if ( verbose ) { - mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, - buf, MSGTR_VO_DirectoryCreateSuccess); - } /* end if */ -} - static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { - char buf[BUFLENGTH]; if(z_compression == 0) { mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning1); @@ -105,8 +52,6 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning3); } - snprintf(buf, BUFLENGTH, "%s", png_outdir); - png_mkdir(buf, 1); mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression); return 0; @@ -203,7 +148,7 @@ static uint32_t draw_image(mp_image_t* mpi){ // if -dr or -slices then do nothing: if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE; - snprintf (buf, 100, "%s/%08d.png", png_outdir, ++framenum); + snprintf (buf, 100, "%08d.png", ++framenum); png = create_png(buf, mpi->w, mpi->h, IMGFMT_IS_BGR(mpi->imgfmt)); @@ -253,12 +198,7 @@ query_format(uint32_t format) return 0; } -static void uninit(void){ - if (png_outdir) { - free(png_outdir); - png_outdir = NULL; - } -} +static void uninit(void){} static void check_events(void){} @@ -271,14 +211,12 @@ static int int_zero_to_nine(int *sh) static opt_t subopts[] = { {"z", OPT_ARG_INT, &z_compression, (opt_test_f)int_zero_to_nine}, - {"outdir", OPT_ARG_MSTRZ, &png_outdir, NULL, 0}, {NULL} }; static int preinit(const char *arg) { z_compression = 0; - png_outdir = strdup("."); if (subopt_parse(arg, subopts) != 0) { return -1; } -- cgit v1.2.3