diff options
Diffstat (limited to 'libvo/vo_png.c')
-rw-r--r-- | libvo/vo_png.c | 79 |
1 files changed, 8 insertions, 71 deletions
diff --git a/libvo/vo_png.c b/libvo/vo_png.c index 8110f859df..3d7d33927a 100644 --- a/libvo/vo_png.c +++ b/libvo/vo_png.c @@ -26,9 +26,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> #include <png.h> @@ -39,9 +36,6 @@ #include "video_out.h" #include "video_out_internal.h" #include "subopt-helper.h" -#include "mplayer.h" - -#define BUFLENGTH 512 static const vo_info_t info = { @@ -54,7 +48,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; static int use_alpha; @@ -65,65 +58,16 @@ 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); - mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning2); - mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning3); + mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_PNG] Warning: compression level set to 0, compression disabled!\n"); + mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_PNG] Info: Use -vo png:z=<n> to set compression level from 0 to 9.\n"); + mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_PNG] Info: (0 = no compression, 1 = fastest, lowest - 9 best, slowest compression)\n"); } - 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; @@ -167,7 +111,7 @@ static struct pngdata create_png (char * fname, int image_width, int image_heigh png.fp = fopen (fname, "wb"); if (png.fp == NULL) { - mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorOpeningForWriting, strerror(errno)); + mp_tmsg(MSGT_VO,MSGL_WARN, "\n[VO_PNG] Error opening '%s' for writing!\n", strerror(errno)); png.status = ERROR; return png; } @@ -220,12 +164,12 @@ 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)); if(png.status){ - mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorInCreatePng); + mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_PNG] Error in create_png.\n"); return 1; } @@ -274,12 +218,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){} @@ -293,14 +232,12 @@ static int int_zero_to_nine(int *sh) static const opt_t subopts[] = { {"alpha", OPT_ARG_BOOL, &use_alpha, NULL}, {"z", OPT_ARG_INT, &z_compression, (opt_test_f)int_zero_to_nine}, - {"outdir", OPT_ARG_MSTRZ, &png_outdir, NULL}, {NULL} }; static int preinit(const char *arg) { z_compression = 0; - png_outdir = strdup("."); use_alpha = 0; if (subopt_parse(arg, subopts) != 0) { return -1; @@ -308,7 +245,7 @@ static int preinit(const char *arg) return 0; } -static int control(uint32_t request, void *data, ...) +static int control(uint32_t request, void *data) { switch (request) { case VOCTRL_DRAW_IMAGE: |