[XviD-devel] Questions / Bug fixes / Patches

Carl Eric Codere cecodere at yahoo.ca
Thu Aug 19 04:38:24 CEST 2010


> Subject: Re: [XviD-devel] Questions / Bug fixes / Patches
> how to do?
> To: xvid-devel at xvid.org
> Message-ID: <20100818105709.49xlmrj1k48kowck at www.lansco.de>
> Content-Type: text/plain;   
> charset=ISO-8859-1;    DelSp="Yes";
>     format="flowed"
> 
> Hi,
> 
> you can send your patches to this list. Either paste the
> patch in your
> mail body (note: the list strips attachments) or upload the
> patch somewhere
> and simply post a link here.
> 
> With regard to the frame-drop issue: I think the clipping
> of the
> frame_drop_ratio parameter to a minimum of zero is the
> intended behavior.
> The frame_drop_ratio parameter should be set to a value
> between 0 and 100
> (see xvid.h). -1 is used only internally.
> 
> When frame_drop_ratio is zero, no frame is dropped (in the
> sense that data
> is ommitted to save bits). There can be N_VOPs produced
> however nonetheless
> in case all macroblocks of a frame were encoded as skip MBs
> (e.g. when two
> consecutive frames were identical already in the source).
> 
> Writing a N_VOP instead of a P_VOP with all MBs skipped is
> not wrong
> (actually, it saves some bits) and imho doesn't make the
> stream variable
> framerate. But I can't comment on what problems mp4box
> might have with
> this - this should be verified.
> 
> Basically, it is possible to disable N_VOP creation
> completely. This will
> just cost some bits here and there because coding a P_VOP
> with all skip
> MBs is less efficient. To achieve this without changing the
> semantics of
> the API I'd say it should be sufficient to change the
> "<=" to a "<" in the
> if-clause around line 1891 in encoder.c:
> 
> if (current->sStat.kblks + current->sStat.mblks <
>          
> (pParam->frame_drop_ratio * mb_width * mb_height) / 100
> 
> With regard to adding additional simple profile presets to
> config.c in vfw
> I see no problem in doing so.
> 
> Best regards,
> Michael
> 

Greetings,
         Here are the patches for inclusion in xvidcore. Regarding the fix on the frame_drop_ratio equal to zero, you are correct in stating that the change suggested fixes the problem with mp4box, now the streams are at constant frame rate and the same number of frames in the mp4 stream exist.

Just for your information, with the unpatched behavior I was having the following issue in
mp4box:

F:\movies\outputs>..\tools\mp4box\MP4Box -fps 29.970 -nodrop -packed -new -add .\sherlock_intro_qvga_Xvid_L6.m4v .\sherlock_intro_qvga_Xvid_L6_256_Xvid.mp4
MPEG-4 Video import - 320 x 240 @ 29.9700 FPS
Indicated Profile: ISO Reserved Profile
Import results: 1224 VOPs (6 Is - 1218 Ps)
Removed 28 N-VOPs
Converting to ISMA Audio-Video MP4 file...
Saving .\sherlock_intro_qvga_Xvid_L6_256_Xvid.mp4: 0.500 secs Interleaving

As you see, the 28 N-VOPs were being removed, resulting in a variable frame rate mp4 stream. I am not familiar enough with the MPEG-4 stream to know why this happened. At least the patch fixes the problem.

On the other hand, the other patches for support of vfw config.c sp at l4a, sp at l5 and sp at l6 seem to work on the standard dll compiled using the generic build, I tested them summarily,  BUT with the debug version of xvidcore.dll compiled with Visual Studio 9.0 Express, when trying to encode  at sp at L6, I get no problem, but at sp at L4a at max bitrate of 4000 kbps, I get an assertion error, is that normal? 

Information on the assertion error (I was encoding from virtualdub 1.9.9):
mbcoding.c : line 595:
estimated_length == coded_length

If you need the test video (It is 135 Mbytes in size) let me know.

Patches:

Frame drop ratio fix:

diff U3ib C:/MinGW/home/Carl/xvidcore/src/encoder.original C:/MinGW/home/Carl/xvidcore/src/encoder.c
--- C:/MinGW/home/Carl/xvidcore/src/encoder.original	Thu Feb 08 09:10:24 2007
+++ C:/MinGW/home/Carl/xvidcore/src/encoder.c	Wed Aug 18 21:18:45 2010
@@ -1884,7 +1884,7 @@
 #if 0
 	DPRINTF(XVID_DEBUG_DEBUG, "kmu %i %i %i\n", current->sStat.kblks, current->sStat.mblks, current->sStat.ublks);
 #endif
-	if (current->sStat.kblks + current->sStat.mblks <=
+	if (current->sStat.kblks + current->sStat.mblks <
 		(pParam->frame_drop_ratio * mb_width * mb_height) / 100 &&
 		( (pEnc->bframenum_head >= pEnc->bframenum_tail) || !(pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP)) )
 	{

Additional Simple Profile Levels:

diff U3ib C:/MinGW/home/Carl/xvidcore/vfw/src/config.c C:/MinGW/home/Carl/xvidcore/vfw/src/config.original
--- C:/MinGW/home/Carl/xvidcore/vfw/src/config.c	Wed Aug 18 21:53:29 2010
+++ C:/MinGW/home/Carl/xvidcore/vfw/src/config.original	Sun Nov 30 13:57:14 2008
@@ -122,11 +122,6 @@
   { "Simple @ L1",      0x01,  176, 144, 15,  4,  198,   99,   1485, 100,  10*16368,  2048,   64000,        0, -1, PROFILE_S|PROFILE_ADAPTQUANT },
   { "Simple @ L2",      0x02,  352, 288, 15,  4,  792,  396,   5940, 100,  40*16368,  4096,  128000,        0, -1, PROFILE_S|PROFILE_ADAPTQUANT },
   { "Simple @ L3",      0x03,  352, 288, 15,  4,  792,  396,  11880, 100,  40*16368,  8192,  384000,        0, -1, PROFILE_S|PROFILE_ADAPTQUANT },
-  /* From ISO/IEC 14496-2:2004/FPDAM 2: New Levels for Simple Profile */
-  { "Simple @ L4a",     0x04,  640, 480, 30,  4, 2400, 1200,  36000, 100,  80*16368, 16384, 4000000,        0, -1, PROFILE_S|PROFILE_ADAPTQUANT },
-  { "Simple @ L5",      0x05,  720, 576, 30,  4, 3240, 1620,  40500, 100, 112*16368, 16384, 8000000,        0, -1, PROFILE_S|PROFILE_ADAPTQUANT },
-  /* From ISO/IEC 14496-2:2004/FPDAM 4: Simple profile level 6 */
-  { "Simple @ L6",      0x06, 1280, 720, 30,  4, 7200, 3600, 108000, 100, 248*16368, 16384,12000000,        0, -1, PROFILE_S|PROFILE_ADAPTQUANT },
 
 #if 0 /* since rrv encoding is no longer support, these profiles have little use */
   { "ARTS @ L1",        0x91,  176, 144, 15,  4,  198,   99,   1485, 100,  10*16368,  8192,   64000,        0, -1, PROFILE_ARTS },


Sorry if the text is wrapped, my mailer is kind of limited, if it causes problems, let me know and will upload them somewhere else!

Best regards,
Carl


More information about the Xvid-devel mailing list