[MPlayer-dev-eng] [PATCH] muxer_mpeg bff_mask should be malloced

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Jan 13 16:28:24 CET 2008


Hello,
bff_mask is nearly 2 MB large and it currently is a global variable in
.bss.
This means that upon program startup this memory must be initialized to
0.
Attached patch just moves it into the priv structure.
I doubt that speed matters, since otherwise someone would have chosen
MAX_PATTERN_LENGTH to be a power of 2 instead of using %-operation ;-)

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/muxer_mpeg.c
===================================================================
--- libmpdemux/muxer_mpeg.c	(revision 25732)
+++ libmpdemux/muxer_mpeg.c	(working copy)
@@ -59,9 +59,6 @@
 static char ftypes[] = {'?', 'I', 'P', 'B'}; 
 #define FTYPE(x) (ftypes[(x)])
 
-#define MAX_PATTERN_LENGTH 2000000
-static unsigned char bff_mask[MAX_PATTERN_LENGTH];	//2 million frames are enough
-
 static const char *framerates[] = {
 	"unchanged", "23.976", "24", "25", "29.97", "30", "50", "59.94", "60"
 };
@@ -155,6 +152,10 @@
 	uint32_t vbitrate;
 	int patch_seq, patch_sde;
 	int psm_streams_cnt;
+
+//2 million frames are enough
+#define MAX_PATTERN_LENGTH 2000000
+	uint8_t bff_mask[MAX_PATTERN_LENGTH];
 } muxer_priv_t;
 
 
@@ -1611,7 +1612,7 @@
 		se_ptr[1] &= 0xf7;
 	
 	//disable tff and rff and overwrite them with the value in bff_mask
-	pce_ptr[3] = (pce_ptr[3] & 0x7d) | bff_mask[vpriv->display_frame % MAX_PATTERN_LENGTH];
+	pce_ptr[3] = (pce_ptr[3] & 0x7d) | priv->bff_mask[vpriv->display_frame % MAX_PATTERN_LENGTH];
 	pce_ptr[4] |= 0x80;	//sets progressive frame
 	
 	vpriv->display_frame += n;
@@ -2459,7 +2460,7 @@
 }
 
 /* excerpt from DGPulldown Copyright (C) 2005-2006, Donald Graft */
-static void generate_flags(int source, int target)
+static void generate_flags(uint8_t *bff_mask, int source, int target)
 {
 	unsigned int i, trfp;
 	uint64_t dfl,tfl;
@@ -2616,7 +2617,7 @@
 		}
 		else
 		{
-			generate_flags(sfps, tfps);
+			generate_flags(priv->bff_mask, sfps, tfps);
 			conf_telecine = TELECINE_DGPULLDOWN;
 			conf_vframerate = conf_telecine_dest;
 		}


More information about the MPlayer-dev-eng mailing list