[Mjpeg-users] mpeg2enc cleanups

2006-11-22 Thread Bernhard Praschinger
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 -	1.7
+++ channel.hh	21 Nov 2006 16:56:56 -
@@ -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 -	1.16
+++ encoderparams.cc	21 Nov 2006 16:56:56 -
@@ -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 -	1.5
+++ idct_mmx.c	21 Nov 2006 16:56:56 -
@@ -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 -	1.27
+++ motionest.cc	21 Nov 2006 16:56:57 -
@@ -51,7 +51,7 @@
 #include 
 #include 
 #include 
-#include 
+#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 -	1.7
+++ ontheflyratectl.cc	21 Nov 2006 16:56:57 -
@@ -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

Re: [Mjpeg-users] mpeg2enc cleanups

2006-11-22 Thread Steven M. Schultz

On Wed, 22 Nov 2006, Bernhard Praschinger wrote:

> Hallo
> 
> I got that pathche from Jindrich.
> 
> Could someone please have a look at them an apply them.

As a courtesy I forwarded a copy to Andrew (and he's also the most
familiar with C++ and mpeg2enc ;))

Hopefully he has a few free  minutes and can look at the patch and
OK it.

Cheers,
Steven Schultz


-
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


[Mjpeg-users] mplex problem with audio

2006-11-22 Thread Bernhard Frühmesser
Hello,

I have a mpeg2 (m2v) video file and a ac3 aufiofile which i would like 
to multiplex but when i try i get this:

INFO: [mplex] mplex version 1.9.0 (2.2.7 $Date: 2006/02/01 22:23:01 $)
INFO: [mplex] File Test.m2v looks like an MPEG Video stream.
**ERROR: [mplex] File Test.ac3 unrecogniseable!
**ERROR: [mplex] Unrecogniseable file(s)... exiting.

When i play the ac3 audiofile with mplayer it plays normally with this 
output:

Playing Test.ac3.
libavformat file format detected.
==
Opening audio decoder: [liba52] AC3 decoding with liba52
Using SSE optimized IMDCT transform
AC3: 1.0 (mono)  48000 Hz  192.0 kbit/s
Using MMX optimized resampler
AUDIO: 48000 Hz, 2 ch, s16le, 192.0 kbit/12.50% (ratio: 24000->192000)
Selected audio codec: [a52] afm: liba52 (AC3-liba52)
==
AO: [oss] 48000Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...

Any ideas why mplex can´t recognize the ac3 audio file?

Thanks,

BF.


-
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


Re: [Mjpeg-users] mplex problem with audio

2006-11-22 Thread Steven M. Schultz

On Wed, 22 Nov 2006, [UTF-8] Bernhard Fr??hmesser wrote:

> I have a mpeg2 (m2v) video file and a ac3 aufiofile which i would like 
> to multiplex but when i try i get this:

> INFO: [mplex] mplex version 1.9.0 (2.2.7 $Date: 2006/02/01 22:23:01 $)
> INFO: [mplex] File Test.m2v looks like an MPEG Video stream.
> **ERROR: [mplex] File Test.ac3 unrecogniseable!
> **ERROR: [mplex] Unrecogniseable file(s)... exiting.

How was the ac3 file produced?  Which program created it?

> When i play the ac3 audiofile with mplayer it plays normally with this 
> output:

the player might be skipping over an invalid or incorrect header.  
I had similar problems at one time with AC3 files created with ffmpeg.
ffmpeg/Mplayer/liba52 would play them but programs such as DVD Studio
Pro would reject them OR the files would not play correctly in
the DVD player.

> Any ideas why mplex can??t recognize the ac3 audio file?

Invalid or incomplete header is my guess.  

When you run mplex do you see lines like this:

   INFO: [mplex] Scanning for header info: AC3 Audio stream 00 (world.ac3)
   INFO: [mplex] AC3 frame size = 768
   INFO: [mplex] AC3 AUDIO STREAM:
   INFO: [mplex] Bit rate   :24576 bytes/sec (192 kbit/sec)
   INFO: [mplex] Frequency  : 48000 Hz
   INFO: [mplex] SYSTEMS/PROGRAM stream:

I would expect to see at least the first line saying that mplex is
'Scanning for header info'.  If you don't see that then mplex isn't
even trying to interpret the file as AC3 - and I don't have any ideas
why that would happen.

Cheers,
Steven Schultz


-
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


Re: [Mjpeg-users] mplex problem with audio

2006-11-22 Thread Bernhard Frühmesser
Steven M. Schultz wrote:
> On Wed, 22 Nov 2006, [UTF-8] Bernhard Frühmesser wrote:
> 
>> I have a mpeg2 (m2v) video file and a ac3 aufiofile which i would like 
>> to multiplex but when i try i get this:
> 
>> INFO: [mplex] mplex version 1.9.0 (2.2.7 $Date: 2006/02/01 22:23:01 $)
>> INFO: [mplex] File Test.m2v looks like an MPEG Video stream.
>> **ERROR: [mplex] File Test.ac3 unrecogniseable!
>> **ERROR: [mplex] Unrecogniseable file(s)... exiting.
> 
>   How was the ac3 file produced?  Which program created it?

The ac3 file was created using ffmpeg.

>> When i play the ac3 audiofile with mplayer it plays normally with this 
>> output:
>   
>   the player might be skipping over an invalid or incorrect header.  
>   I had similar problems at one time with AC3 files created with ffmpeg.
>   ffmpeg/Mplayer/liba52 would play them but programs such as DVD Studio
>   Pro would reject them OR the files would not play correctly in
>   the DVD player.

Hmm, so i would get the same problem with mencoder then :-(

>> Any ideas why mplex can´t recognize the ac3 audio file?
> 
>   Invalid or incomplete header is my guess.  
> 
>   When you run mplex do you see lines like this:
> 
>INFO: [mplex] Scanning for header info: AC3 Audio stream 00 (world.ac3)
>INFO: [mplex] AC3 frame size = 768
>INFO: [mplex] AC3 AUDIO STREAM:
>INFO: [mplex] Bit rate   :24576 bytes/sec (192 kbit/sec)
>INFO: [mplex] Frequency  : 48000 Hz
>INFO: [mplex] SYSTEMS/PROGRAM stream:
> 
>   I would expect to see at least the first line saying that mplex is
>   'Scanning for header info'.  If you don't see that then mplex isn't
>   even trying to interpret the file as AC3 - and I don't have any ideas
>   why that would happen.

Thanks,

I´ll then work with mp2 which works so far.

BF.

>   Cheers,
>   Steven Schultz


-
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


Re: [Mjpeg-users] mplex problem with audio

2006-11-22 Thread Steven M. Schultz

On Wed, 22 Nov 2006, [UTF-8] Bernhard Fr??hmesser wrote:

> The ac3 file was created using ffmpeg.

Thought that would be the case.

> > the player might be skipping over an invalid or incorrect header.  
> > I had similar problems at one time with AC3 files created with ffmpeg...
> 
> Hmm, so i would get the same problem with mencoder then :-(

I thought the problems had been fixed.  I never had much success 
getting those ac3 files accepted by outside programs.

> I??ll then work with mp2 which works so far.

Yes, that is a good idea.  Technically speaking MPEG-1/LayerII audio
is not supported by NTSC players but I've never had a problem with
any of the hardware players I've had.

Cheers,
Steven Schultz


-
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


Re: [Mjpeg-users] Problem with mpeg generated with mjpegtools and mplayer and xine (2)

2006-11-22 Thread Delio Pereira Guimaraes
Sorry for being so late!

On Sunday 19 November 2006 22:31, Steven M. Schultz wrote:
> > Sure, I use an almost silent pentium 233mmx running a ltsp terminal to a
> > server that is an Athlon 800 with 512MB of memory. I run kmail, firefox
> > and
>
>   And I thought 1GB was small :)
>

I only buy used processors and mainboards. I think buying a new one is 
throwing money in the litter. Exceptions are HD and DVD recorder.

>
>   But how long does Xine need to play the file?
>

Yes, it plays correctly. After 17:45 minutes, I have an indication of 15:00 in 
xine. So, 33 minutes would spend about 40 minutes, which is correct.

>   "show a length" is not reliable for variable bitrate files!

That's it!

>
>   I think xine is dividing the file length by the the bitrate in
>   the MPEG-2 header and using that as the duration of the movie.  But
>   that calculation assumes a 'constant bitrate' and does not work
>   with variable bitrate files.
>
> > I'm now converting the file to a DV type2 using kino. I'll encode that
> > file
>
>   I always use 'raw'.  Less overhead (does not have a 2nd copy of the
>   audio data in the file) and, a little less disc space.  Also with 'raw'
>   you can do emergency or quick edits using dd" (raw DV has a frame
>   size of 12 bytes/frame for NTSC, 144000 for PAL)
>
>   If the DV file is OK and if mpeg2enc has no bugs then I would not
>   worry about the estimated times that xine is printing out.
>

Well, I have done some tests:

With kino, I exported raw DV to DV type 2 with "OpenDML AVI" so it could be 
read in avidemux.
In avidemux, I converted the above file to mpeg using the option of ffmpeg, 2 
pass and audio as AC3.
Now this file (is it cbr?) shows 40 minutes in mplayer *but* the same 33 
minutes in xine. But now I managed to make chapters in qdvdauthor as I see a 
duration of 40 minutes in it, so I managed to burn a DVD.

Still, mpeg2dec shows fewer frames of this file than original type2 DV which 
had 73313 frames.

[EMAIL PROTECTED] ~]$ mpeg2dec -o null ntavidemux.mpeg
mpeg2dec-0.4.0 - by Michel Lespinasse <[EMAIL PROTECTED]> and Aaron Holtzman
72605 frames in 274.29 sec (264.70 fps), 118 last 0.50 sec (236.00 fps)
72653 frames decoded in 274.45 seconds (264.72 fps)

I didn't manage to read the exported DV type2 with lav2yuv or smil2yuv, so I 
couldn't test this file with mpeg2enc:

==
[EMAIL PROTECTED] ~]$ lav2yuv /video/natype1001.avi | mpeg2enc -b 9570 -f 8 -q 
4 -4 1 -2 1 -r 32 -g 6 -G 18 -B 260 -K tmpgenc -o vid_natype1.m2v
**ERROR: [lav2yuv] Error opening /video/natype1001.avi
   INFO: [mpeg2enc] SETTING EXTENDED MMX for MOTION!
   INFO: [mpeg2enc] SETTING SSE and MMX for TRANSFORM!
   INFO: [mpeg2enc] SETTING EXTENDED MMX for PREDICTION!
**ERROR: [mpeg2enc] Could not read YUV4MPEG2 header: system error (failed 
read/write)!
[EMAIL PROTECTED] ~]$ smil2yuv /video/natype1001.avi | mpeg2enc -b 9570 -f 8 -q 
4 -4 1 -2 1 -r 32 -g 6 -G 18 -B 260 -K tmpgenc -o vid_natype1.m2v
   INFO: [mpeg2enc] SETTING EXTENDED MMX for MOTION!
   INFO: [mpeg2enc] SETTING SSE and MMX for TRANSFORM!
   INFO: [mpeg2enc] SETTING EXTENDED MMX for PREDICTION!
*** glibc detected *** smil2yuv: malloc(): memory corruption: 0x08937cd8 ***
**ERROR: [mpeg2enc] Could not read YUV4MPEG2 header: system error (failed 
read/write)!

-
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


Re: [Mjpeg-users] Problem with mpeg generated with mjpegtools and mplayer and xine (2)

2006-11-22 Thread Steven M. Schultz

On Wed, 22 Nov 2006, Delio Pereira Guimaraes wrote:

> > And I thought 1GB was small :)
> 
> I only buy used processors and mainboards. I think buying a new one is 

That's fine - just buy some used memory to go with the mainboard :)

It would make a huge difference in the speed of the system.

> > But how long does Xine need to play the file?
> 
> Yes, it plays correctly. After 17:45 minutes, I have an indication of 15:00 in
> xine. So, 33 minutes would spend about 40 minutes, which is correct.

Wow -that is strange, would see to indicate a possible problem with the
the file (timestamps).  Or a problem with Xine.  Does the 15:00 location
match a 'chapter point' perhaps?

> With kino, I exported raw DV to DV type 2 with "OpenDML AVI" so it could be 
> read in avidemux.
> In avidemux, I converted the above file to mpeg using the option of ffmpeg, 2 
> pass and audio as AC3.
> Now this file (is it cbr?) shows 40 minutes in mplayer *but* the same 33 

No, MPEG-2 is variable bitrate.  It is possible with some encoders
to force constant bitrate by placing padding bits into the stream but
usually that is not done (and just wastes space :))

> minutes in xine. But now I managed to make chapters in qdvdauthor as I see a 
> duration of 40 minutes in it, so I managed to burn a DVD.

I get the feeling that there is something not quite right with the
version of Xine that is being used. 

Hmmm, if you watch the DVD using MPlayer with the On Screen Display
of the time enabled what happens?

> Still, mpeg2dec shows fewer frames of this file than original type2 DV which 
> had 73313 frames.
> 72653 frames decoded in 274.45 seconds (264.72 fps)

2 seconds or ~60 frames.  I do not know where they are going.  One
theory would be that a process is buffering frames and exiting without
making sure the buffers are flushed - this would make the movie short
by a few frames but not affect the A/V sync during the movie.

Maybe the frames were lost during the conversion from 'raw' to 
Type 2 AVI.  I do not know.

> ==
> [EMAIL PROTECTED] ~]$ lav2yuv /video/natype1001.avi | mpeg2enc -b 9570 -f 8 
> -q 
> 4 -4 1 -2 1 -r 32 -g 6 -G 18 -B 260 -K tmpgenc -o vid_natype1.m2v
> **ERROR: [lav2yuv] Error opening /video/natype1001.avi
>INFO: [mpeg2enc] SETTING EXTENDED MMX for MOTION!
>INFO: [mpeg2enc] SETTING SSE and MMX for TRANSFORM!
>INFO: [mpeg2enc] SETTING EXTENDED MMX for PREDICTION!
> **ERROR: [mpeg2enc] Could not read YUV4MPEG2 header: system error (failed 
> read/write)!

Hmmm, is mjpegtools built with DV support?  You'll need to have 
libdv installed and detected during the ./configure of mjpegtools.

lav2yuv can't open the file probably because DV support is missing - at
least that's my guess.

> [EMAIL PROTECTED] ~]$ smil2yuv /video/natype1001.avi | mpeg2enc -b 9570 -f 8 
> -q 
> 4 -4 1 -2 1 -r 32 -g 6 -G 18 -B 260 -K tmpgenc -o vid_natype1.m2v
>INFO: [mpeg2enc] SETTING EXTENDED MMX for MOTION!
>INFO: [mpeg2enc] SETTING SSE and MMX for TRANSFORM!
>INFO: [mpeg2enc] SETTING EXTENDED MMX for PREDICTION!
> *** glibc detected *** smil2yuv: malloc(): memory corruption: 0x08937cd8 ***
> **ERROR: [mpeg2enc] Could not read YUV4MPEG2 header: system error (failed 
> read/write)!

Which version of smilutils do you have?  If you already mention this
I forgot (memory failure ;)).  Is smilutils built to use libdv or
ffmpeg's libavcodec for DV decoding?

*** glibc detected *** smil2yuv: malloc(): memory corruption: 0x08937cd8 **

means smil2yuv is corrupting malloc'd buffers somewhere and the
program is aborting. 

If you're not using the latest smilutils from CVS then  maybe that
would fix the problem.  smil2yuv should be able to read the file 
without a problem.

Good Luck.

Cheers,
Steven Schultz


-
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