[x264-devel] Update level dpb size calculation to match newer H.264 spec
Jason Garrett-Glaser
git at videolan.org
Thu Nov 8 00:55:03 CET 2012
x264 | branch: master | Jason Garrett-Glaser <jason at x264.com> | Thu Oct 11 13:27:48 2012 -0700| [d2d8364ff48f789ef92135d24c6f185c4eccbeba] | committer: Jason Garrett-Glaser
Update level dpb size calculation to match newer H.264 spec
Doesn't actually change encoding behavior, but makes it more correct.
Warning messages should now be accurate at higher bit depths and non-4:2:0.
Technically, since it redefines x264_level_t, this is an API version increment.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=d2d8364ff48f789ef92135d24c6f185c4eccbeba
---
encoder/set.c | 40 ++++++++++++++++++++--------------------
x264.c | 5 +----
x264.h | 4 ++--
3 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/encoder/set.c b/encoder/set.c
index 531bca0..7c7983e 100644
--- a/encoder/set.c
+++ b/encoder/set.c
@@ -727,23 +727,23 @@ void x264_sei_dec_ref_pic_marking_write( x264_t *h, bs_t *s )
const x264_level_t x264_levels[] =
{
- { 10, 1485, 99, 152064, 64, 175, 64, 64, 0, 2, 0, 0, 1 },
- { 9, 1485, 99, 152064, 128, 350, 64, 64, 0, 2, 0, 0, 1 }, /* "1b" */
- { 11, 3000, 396, 345600, 192, 500, 128, 64, 0, 2, 0, 0, 1 },
- { 12, 6000, 396, 912384, 384, 1000, 128, 64, 0, 2, 0, 0, 1 },
- { 13, 11880, 396, 912384, 768, 2000, 128, 64, 0, 2, 0, 0, 1 },
- { 20, 11880, 396, 912384, 2000, 2000, 128, 64, 0, 2, 0, 0, 1 },
- { 21, 19800, 792, 1824768, 4000, 4000, 256, 64, 0, 2, 0, 0, 0 },
- { 22, 20250, 1620, 3110400, 4000, 4000, 256, 64, 0, 2, 0, 0, 0 },
- { 30, 40500, 1620, 3110400, 10000, 10000, 256, 32, 22, 2, 0, 1, 0 },
- { 31, 108000, 3600, 6912000, 14000, 14000, 512, 16, 60, 4, 1, 1, 0 },
- { 32, 216000, 5120, 7864320, 20000, 20000, 512, 16, 60, 4, 1, 1, 0 },
- { 40, 245760, 8192, 12582912, 20000, 25000, 512, 16, 60, 4, 1, 1, 0 },
- { 41, 245760, 8192, 12582912, 50000, 62500, 512, 16, 24, 2, 1, 1, 0 },
- { 42, 522240, 8704, 13369344, 50000, 62500, 512, 16, 24, 2, 1, 1, 1 },
- { 50, 589824, 22080, 42393600, 135000, 135000, 512, 16, 24, 2, 1, 1, 1 },
- { 51, 983040, 36864, 70778880, 240000, 240000, 512, 16, 24, 2, 1, 1, 1 },
- { 52, 2073600, 36864, 70778880, 240000, 240000, 512, 16, 24, 2, 1, 1, 1 },
+ { 10, 1485, 99, 396, 64, 175, 64, 64, 0, 2, 0, 0, 1 },
+ { 9, 1485, 99, 396, 128, 350, 64, 64, 0, 2, 0, 0, 1 }, /* "1b" */
+ { 11, 3000, 396, 900, 192, 500, 128, 64, 0, 2, 0, 0, 1 },
+ { 12, 6000, 396, 2376, 384, 1000, 128, 64, 0, 2, 0, 0, 1 },
+ { 13, 11880, 396, 2376, 768, 2000, 128, 64, 0, 2, 0, 0, 1 },
+ { 20, 11880, 396, 2376, 2000, 2000, 128, 64, 0, 2, 0, 0, 1 },
+ { 21, 19800, 792, 4752, 4000, 4000, 256, 64, 0, 2, 0, 0, 0 },
+ { 22, 20250, 1620, 8100, 4000, 4000, 256, 64, 0, 2, 0, 0, 0 },
+ { 30, 40500, 1620, 8100, 10000, 10000, 256, 32, 22, 2, 0, 1, 0 },
+ { 31, 108000, 3600, 18000, 14000, 14000, 512, 16, 60, 4, 1, 1, 0 },
+ { 32, 216000, 5120, 20480, 20000, 20000, 512, 16, 60, 4, 1, 1, 0 },
+ { 40, 245760, 8192, 32786, 20000, 25000, 512, 16, 60, 4, 1, 1, 0 },
+ { 41, 245760, 8192, 32786, 50000, 62500, 512, 16, 24, 2, 1, 1, 0 },
+ { 42, 522240, 8704, 34816, 50000, 62500, 512, 16, 24, 2, 1, 1, 1 },
+ { 50, 589824, 22080, 110400, 135000, 135000, 512, 16, 24, 2, 1, 1, 1 },
+ { 51, 983040, 36864, 184320, 240000, 240000, 512, 16, 24, 2, 1, 1, 1 },
+ { 52, 2073600, 36864, 184320, 240000, 240000, 512, 16, 24, 2, 1, 1, 1 },
{ 0 }
};
@@ -758,7 +758,7 @@ int x264_validate_levels( x264_t *h, int verbose )
{
int ret = 0;
int mbs = h->sps->i_mb_width * h->sps->i_mb_height;
- int dpb = mbs * 384 * h->sps->vui.i_max_dec_frame_buffering;
+ int dpb = mbs * h->sps->vui.i_max_dec_frame_buffering;
int cbp_factor = h->sps->i_profile_idc>=PROFILE_HIGH422 ? 16 :
h->sps->i_profile_idc==PROFILE_HIGH10 ? 12 :
h->sps->i_profile_idc==PROFILE_HIGH ? 5 : 4;
@@ -773,8 +773,8 @@ int x264_validate_levels( x264_t *h, int verbose )
ERROR( "frame MB size (%dx%d) > level limit (%d)\n",
h->sps->i_mb_width, h->sps->i_mb_height, l->frame_size );
if( dpb > l->dpb )
- ERROR( "DPB size (%d frames, %d bytes) > level limit (%d frames, %d bytes)\n",
- h->sps->vui.i_max_dec_frame_buffering, dpb, (int)(l->dpb / (384*mbs)), l->dpb );
+ ERROR( "DPB size (%d frames, %d mbs) > level limit (%d frames, %d mbs)\n",
+ h->sps->vui.i_max_dec_frame_buffering, dpb, l->dpb / mbs, l->dpb );
#define CHECK( name, limit, val ) \
if( (val) > (limit) ) \
diff --git a/x264.c b/x264.c
index 8dcc655..833cf0e 100644
--- a/x264.c
+++ b/x264.c
@@ -1616,11 +1616,8 @@ generic_option:
for( int i = 0; x264_levels[i].level_idc != 0; i++ )
if( param->i_level_idc == x264_levels[i].level_idc )
{
- while( mbs * 384 * param->i_frame_reference > x264_levels[i].dpb &&
- param->i_frame_reference > 1 )
- {
+ while( mbs * param->i_frame_reference > x264_levels[i].dpb && param->i_frame_reference > 1 )
param->i_frame_reference--;
- }
break;
}
}
diff --git a/x264.h b/x264.h
index 8e96b7c..f0fbbd6 100644
--- a/x264.h
+++ b/x264.h
@@ -41,7 +41,7 @@
#include "x264_config.h"
-#define X264_BUILD 128
+#define X264_BUILD 129
/* Application developers planning to link against a shared library version of
* libx264 from a Microsoft Visual Studio or similar development environment
@@ -523,7 +523,7 @@ typedef struct
int level_idc;
int mbps; /* max macroblock processing rate (macroblocks/sec) */
int frame_size; /* max frame size (macroblocks) */
- int dpb; /* max decoded picture buffer (bytes) */
+ int dpb; /* max decoded picture buffer (mbs) */
int bitrate; /* max bitrate (kbit/sec) */
int cpb; /* max vbv buffer (kbit) */
int mv_range; /* max vertical mv component range (pixels) */
More information about the x264-devel
mailing list