[MPlayer-cvslog] r37767 - in trunk/sub: font_load.c font_load.h

reimar subversion at mplayerhq.hu
Sat Feb 20 13:48:21 CET 2016


Author: reimar
Date: Sat Feb 20 13:48:21 2016
New Revision: 37767

Log:
font_load: simplify bitmap font parsing.

Modified:
   trunk/sub/font_load.c
   trunk/sub/font_load.h

Modified: trunk/sub/font_load.c
==============================================================================
--- trunk/sub/font_load.c	Sat Feb 20 13:44:21 2016	(r37766)
+++ trunk/sub/font_load.c	Sat Feb 20 13:48:21 2016	(r37767)
@@ -28,6 +28,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include "libavutil/intreadwrite.h"
+
 #include "font_load.h"
 #include "sub.h"
 #include "mp_msg.h"
@@ -41,11 +43,11 @@ raw_file* load_raw(char *name,int verbos
     if(!f) goto err_out;                        // can't open
     if(fread(head,32,1,f)<1) goto err_out;        // too small
     if(memcmp(head,"mhwanh",6)) goto err_out;        // not raw file
-    raw->w=head[8]*256+head[9];
-    raw->h=head[10]*256+head[11];
-    raw->c=head[12]*256+head[13];
+    raw->w=AV_RB16(head + 8);
+    raw->h=AV_RB16(head + 10);
+    raw->c=AV_RB16(head + 12);
     if(raw->w == 0) // 2 bytes were not enough for the width... read 4 bytes from the end of the header
-    	raw->w = ((head[28]*0x100 + head[29])*0x100 + head[30])*0x100 + head[31];
+    	raw->w = AV_RB32(head + 28);
     if(raw->c>256) goto err_out;                 // too many colors!?
     if (raw->w > INT_MAX / 4 || (uint64_t)raw->w * raw->h > INT_MAX / 4)
         goto err_out;

Modified: trunk/sub/font_load.h
==============================================================================
--- trunk/sub/font_load.h	Sat Feb 20 13:44:21 2016	(r37766)
+++ trunk/sub/font_load.h	Sat Feb 20 13:48:21 2016	(r37767)
@@ -29,7 +29,7 @@
 typedef struct {
     unsigned char *bmp;
     unsigned char *pal;
-    int w,h,c;
+    unsigned w,h,c;
 #ifdef CONFIG_FREETYPE
     int charwidth,charheight,pen,baseline,padding;
     int current_count, current_alloc;


More information about the MPlayer-cvslog mailing list