From fb49973b17e2cc639fec6f8ec683c48af54493fe Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 17 Jul 2004 11:22:14 +0000 Subject: [PATCH] 1, killed some 100l's (no error checking). 2, added subotion for output filename. 3, fallback to 'md5' in case 'md5sum' is not available - this is the case on Darwin git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12841 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_md5.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/libvo/vo_md5.c b/libvo/vo_md5.c index ab3de18181..17334c384b 100644 --- a/libvo/vo_md5.c +++ b/libvo/vo_md5.c @@ -35,12 +35,15 @@ LIBVO_EXTERN (md5) extern vo_functions_t video_out_pgm; extern char vo_pgm_filename[24]; -static FILE * md5_file; +static FILE * md5_file = NULL; +static char * md5_filename = NULL; static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format) { - md5_file = fopen ("md5", "w"); + md5_file = fopen (md5_filename?md5_filename:"md5", "w"); + if (!md5_file) + return -1; return video_out_pgm.config (width, height, d_width,d_height,fullscreen, title, format); } @@ -58,12 +61,16 @@ static void flip_page (void) snprintf (buf2, 100, "md5sum %s", vo_pgm_filename); f = popen (buf2, "r"); + if (!f) { + snprintf (buf2, 100, "md5 %s", vo_pgm_filename); + f = popen(buf2, "r"); + } + if (f) { i = fread (buf2, 1, sizeof(buf2), f); pclose (f); fwrite (buf2, 1, i, md5_file); - + } remove (vo_pgm_filename); - } //static uint32_t draw_slice(uint8_t * src[], uint32_t slice_num) @@ -90,7 +97,17 @@ static void uninit(void) { video_out_pgm.uninit(); - fclose(md5_file); + if (md5_file) + { + fflush(md5_file); + fclose(md5_file); + md5_file = NULL; + } + if (md5_filename) + { + free(md5_filename); + md5_filename = NULL; + } } @@ -101,10 +118,7 @@ static void check_events(void) static uint32_t preinit(const char *arg) { if(arg) - { - printf("vo_md5: Unknown subdevice: %s\n",arg); - return ENOSYS; - } + md5_filename = strdup(arg); return 0; }