[Mp4-tech] B frame bit-rate in H.264 stream

Tourapis, Alexis alexis.tourapis dolby.com
Thu Sep 20 20:37:16 EDT 2007


Dear Changfeng,
I would actually first provide some concerns on the version of the software you are using which is very old. We have corrected several bugs from version 8.6 to the current version which include better support and bug fixes for reference B coded pictures and I would be very cautious using the software you are currently using. I understand that you might not be interested in high profile encoding or the use of more sophisticated hierarchical structures that are supported in the new version, but the bug corrections and enhancements that may exist in the new versions are in my opinion well worth it.
In any case, I would agree with Gary's comments (my interpretation is like the one in his original email). Since now your second frame is closer to its references from both directions, then it makes sense that you are getting a lower number of bits (higher temporal correlation). As Gary suggested, such performance relates strongly not only on this factor but also on the quantization values you are using for each level (i.e. it is likely that you are using a lower QP for the reference B coded picture, but also lower lagrangian parameters as is done in newer versions), but also on how many references you are considering (i.e. if you are using 2 references for list0 then for the second B coded picture you could use blocks from either the P coded picture from the past or the B coded picture depending on which one results in better performance. This benefit is obviously not available for the first B), and direct modes. Btw, I would encourage you to also examine not only the I0, P3, B1, B2, P6, ..., Pn+3, Bn+1, Bn+2, Pn+6, ... but also the I0, P3, B2, B1, P6, ..., Pn+3, Bn+2, Bn+1, Pn+6, ... structure as well. In fact, you may find that the second structure in many scenarios could perform better than the first since B2 (which is a reference) is also closer to P6 which may also use it as a reference. There are other benefits which might be a good exercise to discover on your own. Btw, I would suggest that you also make sure that your software uses proper MMCO and reordering commands to ensure that you have the right references at any step of your encoding process. Without reordering commands for example, P6 would be using B1 (or B2 in my example) as the first reference in list0 and not P3, while without MMCO instructions and depending on how many references you have available in your reference buffer you may have lost some key references which could again hurt performance (i.e. with only 2 references available after encoding P6 your encoder would remove P3 from the buffer. Then B4 would be using P6 and B1 for prediction which may further impair the performance of coding that picture.) My guess is that you may not be using such tools considering that these were not implemented (from what I recall) in that version of the software.
In any case, I hope this information is useful. 
Best regards,
Alexis
________________________________
From: mp4-tech-bounces lists.mpegif.org [mailto:mp4-tech-bounces lists.mpegif.org] On Behalf Of Gary Sullivan
Sent: Thursday, September 20, 2023 11:57 AM
To: changfeng niu; mp4-tech lists.mpegif.org
Subject: RE: [Mp4-tech] B frame bit-rate in H.264 stream
Chanfeng et al,
After re-reading your orginal message, I am not sure whether or not the question that you were asking is the one that I was answering.  I thought you were commenting on differences in behavior depending on whether the first of two consecutive B frames is used as a reference or not.  But now I think maybe your question was different.
Some things to think about include the ordering of the reference picture lists (which is determined by the encoder) and the potential effects of the entropy coding mode -- you didn't say which mode you were using.  CABAC has a greater ability to adapt to the statistics of what the encoder is actually doing, while VLC operation may cause excess overhead if the statistics of the macroblock/sub-macroblock prediction modes and reference picture index values are not well matched to the ue(v) Exp-Golomb VLC code that is used to represent them.
Best Regards,
Gary Sullivan
________________________________
	From: mp4-tech-bounces lists.mpegif.org [mailto:mp4-tech-bounces lists.mpegif.org] On Behalf Of Gary Sullivan
	Sent: Thursday, September 20, 2023 10:42 AM
	To: changfeng niu; mp4-tech lists.mpegif.org
	Subject: RE: [Mp4-tech] B frame bit-rate in H.264 stream
	Chanfeng et al,
	You didn't say exactly what bitstream order and output order these frames are following.  
	If I make the old-fashioned MPEG-2-style assumption, it would look like this temporally:
	I0, B1, B2, P3, B4, ..., Pn, Bn+1, Bn+2, Pn+3, ...
	and would look like this in bitstream order
	I0, P3, B1, B2, P6, ..., Pn+3, Bn+1, Bn+2, Pn+6, ...
	Where, in the MPEG-2 case, Bn+1 and Bn+2 use Pn and Pn+3 as references.
	I think what you are saying is that you see a lower bit rate for Bn+2 when Bn+1 and Pn+3 are used as references than when Pn and Pn+3 are used as references.
	This only makes sense, because Bn+1 is temporally much closer to Bn+2 than Pn is.  
	The temporal prediction distance to Bn+1 is cut in half, so it should be obvious that Bn+2 should be a better predictor than Pn.
	This may somewhat depend, however, on the fidelity used for the encoding of the different pictures.  For overall average PSNR optimization, it is typically better to decrease fidelity somewhat as one moves upward in the prediction structure.  So ordinarily, when using B frames as reference pictures, I0 would use the highest fidelity, Pn+3 would have the next highest fidelity, Bn+1 would have the next highest fidelity, and Bn+2 would have the lowest fidelity.  However, that rule of thumb might need some adjustment for perceptual optimization purposes.
	Best Regards,
	Gary Sullivan
________________________________
		From: mp4-tech-bounces lists.mpegif.org [mailto:mp4-tech-bounces lists.mpegif.org] On Behalf Of changfeng niu
		Sent: Wednesday, September 19, 2023 6:48 PM
		To: mp4-tech lists.mpegif.org
		Subject: [Mp4-tech] B frame bit-rate in H.264 stream
		Hello everyone:
		 First, I would like to ask a question about H.264 video coding. When I use JM
		8.6 to code, I find that for almost all sequences the second one of  two
		successive B frames mostly has fewer bits than the first one without B frame as a 
		reference. Why? 
		  Now, I am working on transcoding from MPEG2 to H.264. I meet such a similar
		question. When coding with MPEG2 decoder reconstruction picture as JM 8.6
		inputfile, I frame, P frame and the first one of two successive B frames without B 
		frame as a reference have almost the same bits and PSNR as tanscoing procedure and
		coding bits of the second one of two successive B frames are fewer notably than
		the first one of two successive B frames .However two successive B frames mostly 
		have the same bits without B frame as a reference in our transcoding procedure . 
		  Our transcoding procedure has the same configuration parameters except following
		two differences  with JM 8.6.
		1. Whether a macroblock is coded as a intra one or a inter one lies on MPEG2 
		encoder in transcoding  procedure while it is decided by mode selection in JM 8.6.
		2. In transcoing procedure mv of a macroblock constitutes of MPEG2 mv integer and
		inserted subpixell using H.264 arithmetic while it is get by full searching 
		restricted to 16 pixels in JM 8.6.
		I don't know whether mv makes an influence or not.
		Waiting for your answer.Thanks very much!
-----------------------------------------
This message (including any attachments) may contain confidential
information intended for a specific individual and purpose.  If you
are not the intended recipient, delete this message.  If you are
not the intended recipient, disclosing, copying, distributing, or
taking any action based on this message is strictly prohibited.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/mp4-tech/attachments/20070920/dba02236/attachment.html


More information about the Mp4-tech mailing list