[MPlayer-cvslog] r32528 - in trunk: Makefile command.c

cigaes subversion at mplayerhq.hu
Fri Oct 22 22:39:43 CEST 2010


Author: cigaes
Date: Fri Oct 22 22:39:43 2010
New Revision: 32528

Log:
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
Add the b flag to fopen.
Separate the fopen and the if to make it more readable.

Modified:
   trunk/Makefile
   trunk/command.c

Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile	Fri Oct 22 19:46:12 2010	(r32527)
+++ trunk/Makefile	Fri Oct 22 22:39:43 2010	(r32528)
@@ -550,8 +550,7 @@ SRCS_MPLAYER-$(FFMPEG)       += libvo/vo
 SRCS_MPLAYER-$(GGI)          += libvo/vo_ggi.c
 SRCS_MPLAYER-$(GIF)          += libvo/vo_gif89a.c
 SRCS_MPLAYER-$(GL)           += libvo/gl_common.c libvo/vo_gl.c \
-                                libvo/vo_gl2.c libvo/csputils.c \
-                                pnm_loader.c
+                                libvo/vo_gl2.c libvo/csputils.c
 SRCS_MPLAYER-$(GL_SDL)       += libvo/sdl_common.c
 SRCS_MPLAYER-$(GL_WIN32)     += libvo/w32_common.c
 SRCS_MPLAYER-$(GL_X11)       += libvo/x11_common.c
@@ -675,6 +674,7 @@ SRCS_MPLAYER = command.c \
                mp_fifo.c \
                mplayer.c \
                parser-mpcmd.c \
+               pnm_loader.c \
                input/input.c \
                libao2/ao_mpegpes.c \
                libao2/ao_null.c \

Modified: trunk/command.c
==============================================================================
--- trunk/command.c	Fri Oct 22 19:46:12 2010	(r32527)
+++ trunk/command.c	Fri Oct 22 22:39:43 2010	(r32528)
@@ -63,6 +63,7 @@
 #include "libmenu/menu.h"
 #include "gui/interface.h"
 #include "eosd.h"
+#include "pnm_loader.h"
 
 #include "mp_core.h"
 #include "mp_fifo.h"
@@ -2546,23 +2547,24 @@ static struct mp_eosd_source overlay_sou
 static void overlay_add(char *file, int id, int x, int y, unsigned col)
 {
     FILE *f;
-    unsigned w, h, nc;
-    unsigned char *data;
+    unsigned w, h, bpp, maxval;
+    uint8_t *data;
     struct mp_eosd_image *img;
 
-    if (!(f = fopen(file, "r"))) {
+    f = fopen(file, "rb");
+    if (!f) {
         mp_msg(MSGT_CPLAYER, MSGL_ERR, "overlay_add: unable to open file.\n");
         return;
     }
-    if (fscanf(f, "P5\n%d %d\n%d\n", &w, &h, &nc) != 3 || nc != 255) {
-        mp_msg(MSGT_CPLAYER, MSGL_ERR, "overlay_add: unable to parse file.\n");
-        fclose(f);
+    data = read_pnm(f, &w, &h, &bpp, &maxval);
+    fclose(f);
+    if (!data) {
+        mp_msg(MSGT_CPLAYER, MSGL_ERR, "overlay_add: unable to load file.\n");
         return;
     }
-    data = malloc(w * h);
-    if (fread(data, 1, w * h, f) != w * h) {
-        mp_msg(MSGT_CPLAYER, MSGL_ERR, "overlay_add: unable to read file.\n");
-        fclose(f);
+    if (bpp != 1 || maxval != 255) {
+        mp_msg(MSGT_CPLAYER, MSGL_ERR,
+               "overlay_add: file format not supported.\n");
         return;
     }
     if (!overlay_source_registered) {
@@ -2570,7 +2572,6 @@ static void overlay_add(char *file, int 
         eosd_image_remove_all(&overlay_source);
         overlay_source_registered = 1;
     }
-    fclose(f);
     img = eosd_image_alloc();
     img->w      = w;
     img->h      = h;


More information about the MPlayer-cvslog mailing list