[MPlayer-cvslog] r36607 - trunk/libvo/vo_bl.c

reimar subversion at mplayerhq.hu
Sat Jan 18 14:55:52 CET 2014


Author: reimar
Date: Sat Jan 18 14:55:52 2014
New Revision: 36607

Log:
vo_bl: Simplify/avoid duplicating size calculations.

Modified:
   trunk/libvo/vo_bl.c

Modified: trunk/libvo/vo_bl.c
==============================================================================
--- trunk/libvo/vo_bl.c	Sat Jan 18 14:49:18 2014	(r36606)
+++ trunk/libvo/vo_bl.c	Sat Jan 18 14:55:52 2014	(r36607)
@@ -237,16 +237,17 @@ static int config(uint32_t width, uint32
 	if (reset_width) bl->width = width; /* use width of movie */
 	if (reset_height) bl->height = height; /* use height of movie */
 
+	bl_size = 12 + bl->width*bl->height*bl->channels;
+
 	/* check for maximum size of UDP packet */
-	if (12 + bl->width*bl->height*bl->channels > 65507) {
+	if (bl_size > 65507) {
 		mp_msg(MSGT_VO, MSGL_ERR, "bl: %dx%d-%d does not fit into an UDP packet\n",
 				bl->width, bl->height, bl->channels);
 		goto err_out;
 	}
 
 	/* resize or allocate frame and tmp buffers */
-	bl_size = 12 + bl->width*bl->height*bl->channels;
-	ptr = realloc(bl_packet, 12 + bl->width*bl->height*3); /* space for header and image data */
+	ptr = realloc(bl_packet, bl_size); /* space for header and image data */
 	if (!ptr) {
 		mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n");
 		goto err_out;
@@ -254,7 +255,7 @@ static int config(uint32_t width, uint32
 	bl_packet = ptr;
 
 	image = ((unsigned char*)bl_packet + 12); /* pointer to image data */
-	ptr = realloc(tmp, bl->width*bl->height*3); /* space for image data only */
+	ptr = realloc(tmp, bl_size); /* space for image data only, could be slightly smaller */
 	if (!ptr) {
 		mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n");
 		goto err_out;
@@ -284,7 +285,7 @@ static int config(uint32_t width, uint32
 		mp_msg(MSGT_VO, MSGL_ERR, "bl: image should be initialized, internal error\n");
 		goto err_out;
 	}
-	memset(image, 0, bl->width*bl->height*3); /* blank the image */
+	memset(image, 0, bl_size - 12); /* blank the image */
 	mp_msg(MSGT_VO, MSGL_V, "vo_config bl called\n");
 	return 0;
 err_out:


More information about the MPlayer-cvslog mailing list