Hallo

I got that pathche from Jindrich.

Could someone please have a look at them an apply them.

> Hello,
> 
> here is a patch for mpeg2dec CVS fixing the following issues:
> 
> - unused variables throughout the code
> - object member initializers in an order different than the members
> themselves
> - missing system header #includes
> - forgotten variable initializations making valgrind go crazy
> - aligned attribute not working for local variable on stack causing
> SIGSEGV on movaps instruction in idct_sse
> - signed vs unsigned comparisons
> - missing virtual destructor
> 
> With the patch applied, mpeg2enc now compiles without any warnings from
> either gcc 4.1.2 and runs withhout complaints from valgrind 3.2.1.
> 
> Regards,
> -- Jindrich Makovicka 

-- 
auf hoffentlich bald,

Berni the Chaos of Woodquarter

Email: [EMAIL PROTECTED]
www: http://www.lysator.liu.se/~gz/bernhard
Index: channel.hh
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/channel.hh,v
retrieving revision 1.7
diff -u -r1.7 channel.hh
--- channel.hh	7 Jan 2006 19:55:21 -0000	1.7
+++ channel.hh	21 Nov 2006 16:56:56 -0000
@@ -36,8 +36,8 @@
             fullness(0),
             read(0),
             write(0),
-            producers_waiting(0),
-            consumers_waiting(0)
+            consumers_waiting(0),
+            producers_waiting(0)
     {
 #ifdef PTHREAD_MUTEX_ERRORCHECK
         pthread_mutexattr_t mu_attr;
@@ -140,7 +140,7 @@
             abort();
         }
 #endif
-        int wait_for = consumers_waiting+1;
+        unsigned int wait_for = consumers_waiting+1;
         while( fullness > 0 || consumers_waiting < wait_for )
         {
             pthread_cond_wait( &waiting, &atomic);
Index: encoderparams.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/encoderparams.cc,v
retrieving revision 1.16
diff -u -r1.16 encoderparams.cc
--- encoderparams.cc	13 Jun 2006 20:38:45 -0000	1.16
+++ encoderparams.cc	21 Nov 2006 16:56:56 -0000
@@ -115,7 +115,7 @@
     static const int MARGIN = 0;
 #endif
     
-#ifdef HAVE_ALTIVEC
+#if defined(HAVE_ALTIVEC) || defined(HAVE_ASM_MMX)
 	/* Pad phy_width to 64 so that the rowstride of 4*4
 	 * sub-sampled data will be a multiple of 16 (ideal for AltiVec)
 	 * and the rowstride of 2*2 sub-sampled data will be a multiple
Index: idct_mmx.c
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/idct_mmx.c,v
retrieving revision 1.5
diff -u -r1.5 idct_mmx.c
--- idct_mmx.c	27 Jun 2006 20:49:21 -0000	1.5
+++ idct_mmx.c	21 Nov 2006 16:56:56 -0000
@@ -210,11 +210,14 @@
 
 void idct_mmx(int16_t *block)
 {
-    int16_t temp[64], *src, *dst;
+    uint8_t temp[64*2+8];
+    int16_t *src, *dst;
     int i;
 
+    int align = (-(size_t)(temp))&7;
+
     src=block;
-    dst=temp;
+    dst=(int16_t*)(temp+align);
     for( i=0; i<4; src+=16, dst+=2, i++ ) {
 
 #define STOREMM(r, d, s)    \
@@ -349,7 +352,7 @@
         STOREMM(mm2, dst[6*8], Wrshift);
     }
 
-    src=temp;
+    src=(int16_t*)(temp+align);
     dst=block;
     for( i=0; i<4; src+=16, dst+=2, i++ ) {
 
@@ -483,15 +486,15 @@
 
 void idct_sse(int16_t *block)
 {
-    float temp[64] __attribute__((aligned(16)));
+    uint8_t temp[64*4+16];
     float *dst;
     int i;
     int16_t *src;
 
-    
+    int align = (-(size_t)(temp))&15;
 
     src=block;
-    dst=temp;
+    dst=(float*)(temp+align);
     for( i=0; i<2; src+=32, dst+=4, i++) {
 #define MM2XMMl(mm,x0,x1)          \
         movq_r2r     ( mm,  mm6);  \
@@ -579,7 +582,7 @@
     }
 
     src=block;
-    dst=temp;
+    dst=(float*)(temp+align);
     for( i=0; i<2; src+=4, dst+=32, i++) {
 
 #define LOADROTATEff(src, t, x0, x1, x2, x3)           \
Index: motionest.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/motionest.cc,v
retrieving revision 1.27
diff -u -r1.27 motionest.cc
--- motionest.cc	27 Jun 2006 20:49:21 -0000	1.27
+++ motionest.cc	21 Nov 2006 16:56:57 -0000
@@ -51,7 +51,7 @@
 #include <limits.h>
 #include <cassert>
 #include <math.h>
-#include <mpeg2syntaxcodes.h>
+#include "mpeg2syntaxcodes.h"
 #include "cpu_accel.h"
 #include "simd.h"
 #include "fastintfns.h"
@@ -431,7 +431,6 @@
                       int &measure
     )
 {
-    bool all_legal = true;
     Coord cross;
     int part_meas = 0;
 
Index: ontheflyratectl.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/ontheflyratectl.cc,v
retrieving revision 1.7
diff -u -r1.7 ontheflyratectl.cc
--- ontheflyratectl.cc	12 Aug 2006 20:55:53 -0000	1.7
+++ ontheflyratectl.cc	21 Nov 2006 16:56:57 -0000
@@ -79,7 +79,12 @@
 	sum_avg_act = 0.0;
 	sum_avg_var = 0.0;
 	sum_avg_quant = 0.0;
-
+	per_pict_bits = 0;
+	vbuf_fullness = 0;
+	fb_gain = 1;
+	Xhi[I_TYPE] = Xhi[P_TYPE] = Xhi[B_TYPE] = 0.0;
+	sum_size[I_TYPE] = sum_size[P_TYPE] = sum_size[B_TYPE] = 0.0;
+	pict_count[I_TYPE] = pict_count[P_TYPE] = pict_count[B_TYPE] = 1;
 }
 
 
@@ -276,7 +281,6 @@
 
 bool OnTheFlyPass1::InitPict(Picture &picture)
 {
-	double target_Q;
 	int available_bits;
 	double Xsum,varsum;
 
@@ -378,7 +382,7 @@
  	mjpeg_debug( "Frame %c T=%05d A=%06d  Xi=%.2f Xp=%.2f Xb=%.2f", 
                  pict_type_char[picture.pict_type],
                  (int)target_bits/8, (int)available_bits/8, 
-                 Xhi[I_TYPE], Xhi[P_TYPE],Xhi[B_TYPE] );
+                 Xhi[I_TYPE], Xhi[P_TYPE], Xhi[B_TYPE] );
 
 
 	/* 
@@ -438,9 +442,7 @@
 
 void OnTheFlyPass1::PictUpdate( Picture &picture, int &padding_needed)
 {
-	double K;
 	int32_t actual_bits;		/* Actual (inc. padding) picture bit counts */
-	int    i;
 	int frame_overshoot;
 	actual_bits = picture.EncodedSize();
 	frame_overshoot = (int)actual_bits-(int)target_bits;
@@ -721,8 +723,11 @@
         buffer_variation = 0;
         bits_transported = 0;
         bits_used = 0;
+        per_pict_bits = 0;
+        target_bits = 0;
         sum_avg_act = 0.0;
         sum_avg_var = 0.0;
+        overshoot_gain = 0.0;
         
         /* TODO: These values should are really MPEG-1/2 and material type
            dependent.  The encoder should probably run over the first 100
@@ -732,6 +737,15 @@
 
         sum_avg_quant = 0.0;
 
+        gop_Xhi = 0.0;
+        gop_bitrate = 0.0;
+        base_Q = 0.0;
+        fields_in_gop = 0;
+        field_rate = 1.0;
+        
+        sum_size[I_TYPE] = sum_size[P_TYPE] = sum_size[B_TYPE] = 0.0;
+        pict_count[I_TYPE] = pict_count[P_TYPE] = pict_count[B_TYPE] = 0;
+        
 }
 
 
@@ -768,7 +782,6 @@
 
 void OnTheFlyPass2::InitSeq()
 {
-  double init_quant;
   /* If its stills with a size we have to hit then make the
      guesstimates of for initial quantisation pessimistic...
   */
@@ -803,9 +816,6 @@
   */
   gop_buffer_correction = 0;
   mjpeg_debug( "PASS2 GOP Rate Lookead" );
-  double recovery_fraction = field_rate/(overshoot_gain * fields_in_gop);
-
-
 
   std::deque<Picture *>::iterator i;
   gop_Xhi = 0.0;
@@ -862,8 +872,7 @@
 
 bool OnTheFlyPass2::InitPict(Picture &picture)
 {
-  double target_Q;
-  double Xsum,varsum;
+  double varsum;
 
   actsum = picture.ActivityBestMotionComp();
   varsum = picture.VarSumBestMotionComp();
@@ -938,10 +947,7 @@
 
 void OnTheFlyPass2::PictUpdate( Picture &picture, int &padding_needed)
 {
-  double K;
   int32_t actual_bits;            /* Actual (inc. padding) picture bit counts */
-  int    i;
-  int    Qsum;
   int frame_overshoot;
   actual_bits = picture.EncodedSize();
   frame_overshoot = (int)actual_bits-(int)target_bits;
Index: pass1ratectl.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/pass1ratectl.cc,v
retrieving revision 1.9
diff -u -r1.9 pass1ratectl.cc
--- pass1ratectl.cc	14 Jun 2006 23:40:39 -0000	1.9
+++ pass1ratectl.cc	21 Nov 2006 16:56:57 -0000
@@ -259,7 +259,6 @@
 
 bool LookaheadRCPass1::InitPict(Picture &picture)
 {
-    double target_Q;
     int available_bits;
     double Xsum,varsum;
 
@@ -409,9 +408,7 @@
 
 void LookaheadRCPass1::PictUpdate( Picture &picture, int &padding_needed)
 {
-    double K;
     int32_t actual_bits;        /* Actual (inc. padding) picture bit counts */
-    int    i;
     int frame_overshoot;
     actual_bits = picture.EncodedSize();
     frame_overshoot = (int)actual_bits-(int)target_bits;
Index: pass2ratectl.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/pass2ratectl.cc,v
retrieving revision 1.5
diff -u -r1.5 pass2ratectl.cc
--- pass2ratectl.cc	13 Jun 2006 20:38:46 -0000	1.5
+++ pass2ratectl.cc	21 Nov 2006 16:56:57 -0000
@@ -178,9 +178,6 @@
     */
 	gop_buffer_correction = 0;
     mjpeg_debug( "PASS2 GOP INIT" );
-    double recovery_fraction = field_rate/(overshoot_gain * fields_in_gop);
-
-
     
     int i;
     gop_Xhi = 0.0;
@@ -218,8 +215,7 @@
 void XhiPass2RC::InitNewPict(Picture &picture)
 {
 
-    double target_Q;
-    double Xsum,varsum;
+    double varsum;
 
     actsum = picture.ActivityBestMotionComp();
     varsum = picture.VarSumBestMotionComp();
@@ -277,7 +273,6 @@
 
 void XhiPass2RC::UpdatePict( Picture &picture, int &padding_needed)
 {
-	double K;
 	int32_t actual_bits;		/* Actual (inc. padding) picture bit counts */
 	int    i;
 	int    Qsum;
@@ -363,7 +358,6 @@
 int XhiPass2RC::MacroBlockQuant( const MacroBlock &mb )
 {
     int lum_variance = mb.BaseLumVariance();
-    int mquant;
     if( lum_variance < encparams.boost_var_ceil )
     {
         const Picture &picture = mb.ParentPicture();
Index: picture.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/picture.cc,v
retrieving revision 1.21
diff -u -r1.21 picture.cc
--- picture.cc	12 Aug 2006 20:55:53 -0000	1.21
+++ picture.cc	21 Nov 2006 16:56:57 -0000
@@ -77,6 +77,8 @@
             bufalloc(encparams.mb_per_pict*BLOCK_COUNT*sizeof(DCTblock)));
     DCTblock *block = blocks;
     DCTblock *qblock = qblocks;
+    memset(block, 0, encparams.mb_per_pict*BLOCK_COUNT*sizeof(DCTblock));
+    memset(qblock, 0, encparams.mb_per_pict*BLOCK_COUNT*sizeof(DCTblock));
     for (j=0; j<encparams.enc_height2; j+=16)
     {
         for (i=0; i<encparams.enc_width; i+=16)
@@ -100,7 +102,6 @@
 
 Picture::~Picture()
 {
-    int i;
     delete rec_img;
     delete pred;
     delete coding;
@@ -271,6 +272,8 @@
             sxb = encparams.motion_data[bgrp_decode].sxb;
             syb = encparams.motion_data[bgrp_decode].syb;
             break;
+        default :
+            break;
     }
 
     /* We currently don't support frame-only DCT/Motion Est.  for non
Index: picturereader.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/picturereader.cc,v
retrieving revision 1.17
diff -u -r1.17 picturereader.cc
--- picturereader.cc	20 Nov 2005 18:13:48 -0000	1.17
+++ picturereader.cc	21 Nov 2006 16:56:57 -0000
@@ -47,7 +47,7 @@
 
 PictureReader::~PictureReader()
 {
-    for( int i = 0; i < input_imgs_buf.size(); ++i )
+    for( unsigned int i = 0; i < input_imgs_buf.size(); ++i )
         delete input_imgs_buf[i];
 
 }
Index: rate_complexity_model.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/rate_complexity_model.cc,v
retrieving revision 1.2
diff -u -r1.2 rate_complexity_model.cc
--- rate_complexity_model.cc	14 Jun 2006 23:40:39 -0000	1.2
+++ rate_complexity_model.cc	21 Nov 2006 16:56:57 -0000
@@ -114,7 +114,7 @@
     // population or very different image complexities
     std::vector<Bucket>::iterator r = l + 1;
     double distance = (r->min - l->max) * log( l->instances + r->instances ) ;
-  
+    return distance;
   }
 
 
@@ -307,8 +307,6 @@
                                                  double tolerance )
 {
   double rate_coefficient = init_rate_coefficient;
-  double incr = 1.0 + tolerance;
-  double decr = 1.0 - tolerance;
   double rate = PredictedBitrate(rate_coefficient);
 
   // Find the correct initial direction and a reasonable initial step-size
Index: ratectl.hh
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/ratectl.hh,v
retrieving revision 1.17
diff -u -r1.17 ratectl.hh
--- ratectl.hh	17 Jun 2006 00:18:57 -0000	1.17
+++ ratectl.hh	21 Nov 2006 16:56:57 -0000
@@ -51,6 +51,7 @@
 {
 public:
     RateCtl( EncoderParams &_encparams, RateCtlState &_state );
+    virtual ~RateCtl() {}
 
     /*********************
     *
Index: seqencoder.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/seqencoder.cc,v
retrieving revision 1.21
diff -u -r1.21 seqencoder.cc
--- seqencoder.cc	12 Aug 2006 20:55:53 -0000	1.21
+++ seqencoder.cc	21 Nov 2006 16:56:57 -0000
@@ -150,7 +150,7 @@
         pattr = &attr;
 #endif
         worker_threads = new pthread_t[parallelism];
-        for(int i = 0; i < parallelism; ++i )
+        for(unsigned int i = 0; i < parallelism; ++i )
         {
             jobpool[i].working = false;
             jobpool[i].stripe = i;
@@ -265,7 +265,7 @@
 {
     if( parallelism > 0 )
     {
-        for( int stripe = 0; stripe < parallelism; ++stripe )
+        for( unsigned int stripe = 0; stripe < parallelism; ++stripe )
         {
             EncoderJob *job = &jobpool[stripe];
             // We guanratee a previously despatched stripe has completed before it is redespatched
@@ -329,8 +329,8 @@
     pass1ratectl( _p1ratectl ),
     pass2ratectl( _p2ratectl ),
     p1_despatcher( *new Despatcher ),
-    pass1_ss( _encparams, _reader ),
-    pass1_rcstate( pass1ratectl.NewState() )
+    pass1_rcstate( pass1ratectl.NewState() ),
+    pass1_ss( _encparams, _reader )
 {
 }
 
@@ -579,10 +579,10 @@
                picture.decode, 
                picture.present,
                picture.temp_ref,
-               pict_type_char[pass1_ss.frame_type],
-               picture.ABQ,
-               picture.pad ? "PAD" : "   ",
-               picture.IntraCodedBlocks() * 100.0
+               'a',//pict_type_char[pass1_ss.frame_type],
+               0.0,/*picture.ABQ,*/
+               "",/*picture.pad ? "PAD" : "   ",*/
+               0.0/*picture.IntraCodedBlocks() * 100.0*/
         );
             
 }
@@ -755,8 +755,8 @@
 
 
     // Find pictures that can now safely be pass 2 encoded
-    int to_queue = 0;
-    int i;
+    unsigned int to_queue = 0;
+    unsigned int i;
 
     if( last_pic->end_seq )
     {
@@ -914,7 +914,7 @@
     uint64_t bits_after_mux = BitsAfterMux();
     mjpeg_info( "Guesstimated final muxed size = %lld\n", bits_after_mux/8 );
     
-    int i;
+    unsigned int i;
     for( i = 0; i < free_pictures.size(); ++i )
     {
         delete free_pictures[i];
Index: streamstate.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/streamstate.cc,v
retrieving revision 1.13
diff -u -r1.13 streamstate.cc
--- streamstate.cc	27 Jun 2006 20:49:21 -0000	1.13
+++ streamstate.cc	21 Nov 2006 16:56:58 -0000
@@ -107,7 +107,7 @@
   Update ss to the next sequence state.
 */
 
-void StreamState::Next(  int64_t bits_after_mux )   // Estimate of how much output would have been produced
+void StreamState::Next(  uint64_t bits_after_mux )   // Estimate of how much output would have been produced
 {
     ++frame_num;    
     ++s_idx;
@@ -221,8 +221,6 @@
 
 void StreamState::GopStart(  )
 {
-    uint64_t bits_after_mux;
-    double frame_periods;
     /* If   we're starting a GOP and have gone past the current
        sequence splitting point split the sequence and
        set the next splitting point.
Index: streamstate.h
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/mpeg2enc/streamstate.h,v
retrieving revision 1.9
diff -u -r1.9 streamstate.h
--- streamstate.h	17 Jun 2006 00:18:57 -0000	1.9
+++ streamstate.h	21 Nov 2006 16:56:58 -0000
@@ -39,7 +39,7 @@
 public:
     StreamState( EncoderParams &encparams, PictureReader &reader );
     void Init( );
-    void Next( int64_t bits_after_mux );
+    void Next( uint64_t bits_after_mux );
     void ForceIFrame();
     void SuppressBFrames();
 
Index: cpu_accel.c
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/utils/cpu_accel.c,v
retrieving revision 1.28
diff -u -r1.28 cpu_accel.c
--- cpu_accel.c	18 May 2006 18:19:05 -0000	1.28
+++ cpu_accel.c	21 Nov 2006 17:31:14 -0000
@@ -21,6 +21,7 @@
 
 #include <config.h>
 #include <stdio.h>
+#include <malloc.h>
 #include <signal.h>
 #include <setjmp.h>
 #include <stdlib.h>
Index: cpuinfo.c
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/utils/cpuinfo.c,v
retrieving revision 1.3
diff -u -r1.3 cpuinfo.c
--- cpuinfo.c	11 Feb 2006 05:34:04 -0000	1.3
+++ cpuinfo.c	21 Nov 2006 17:31:14 -0000
@@ -10,6 +10,8 @@
 #include <stdio.h>
 #include <sys/time.h>
 #include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
 #ifdef __MINGW32__
 #include <sys/timeb.h>
Index: motionsearch.c
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/utils/motionsearch.c,v
retrieving revision 1.27
diff -u -r1.27 motionsearch.c
--- motionsearch.c	30 Jan 2005 01:48:57 -0000	1.27
+++ motionsearch.c	21 Nov 2006 17:31:14 -0000
@@ -968,7 +968,9 @@
 
 void init_motion_search(void)
 {
+#if defined(HAVE_ALTIVEC) || defined(HAVE_ASM_MMX)
 	int cpucap = cpu_accel();
+#endif
 
 	/* Initialize function pointers. This allows partial acceleration
 	 * implementations to update only the function pointers they support.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users

Reply via email to