I wrote function to extract SSEI from H.264 file, just as it is in Spec. (Pg. 580 - G.13.1.1 Scalability information SEI message syntax) but for some reason I'm getting wrong values. Has any of you implemented similar function?

I believe I made mistake at the beginningm here's how I did it:
Code:
nal_size = AVC_NextStartCode(bs);
nal_start  = gf_bs_get_position(bs);
gf_bs_seek(bs, nal_start);
nal_hdr		= gf_bs_read_int(bs, 8);
sei_type	= gf_bs_read_int(bs, 8);
sei_size	= gf_bs_read_int(bs, 8);
and the rest of the code exactly as it is described in spec.

Code:
gf_bs_read_int(bs, 1);  /* sei__scalability_info__temporal_id_nesting_flag */
gf_bs_read_int(bs, 1);  /* sei__scalability_info__priority_layer_info_flag */
gf_bs_read_int(bs, 1);  /* sei__scalability_info__priority_id_setting_flag */    
num_layers = avc_get_ue(bs) + 1;   /* sei__scalability_info__num_layers_minus1 */

for( i = 0; i <= num_layers_minus1; i++ )
{
etc...
I'm getting really weird Avg Bitrate value. If anyone has done something similar, I'd appreciate sharing the experience. If you need more details on my implementation I'd be glad to provide

thanks