Commit a2245645 authored by Loren Merritt's avatar Loren Merritt

write VUI bitstream restrictions


git-svn-id: svn://svn.videolan.org/x264/trunk@162 df754926-b1dd-0310-bc7b-ec298dee348c
parent 29dee22a
...@@ -83,6 +83,15 @@ typedef struct ...@@ -83,6 +83,15 @@ typedef struct
int i_time_scale; int i_time_scale;
int b_fixed_frame_rate; int b_fixed_frame_rate;
int b_bitstream_restriction;
int b_motion_vectors_over_pic_boundaries;
int i_max_bytes_per_pic_denom;
int i_max_bits_per_mb_denom;
int i_log2_max_mv_length_horizontal;
int i_log2_max_mv_length_vertical;
int i_num_reorder_frames;
int i_max_dec_frame_buffering;
/* FIXME to complete */ /* FIXME to complete */
} vui; } vui;
} x264_sps_t; } x264_sps_t;
......
...@@ -396,6 +396,7 @@ x264_t *x264_encoder_open ( x264_param_t *param ) ...@@ -396,6 +396,7 @@ x264_t *x264_encoder_open ( x264_param_t *param )
if( h->param.analyse.inter & X264_ANALYSE_PSUB8x8 ) if( h->param.analyse.inter & X264_ANALYSE_PSUB8x8 )
h->param.analyse.inter |= X264_ANALYSE_PSUB16x16; h->param.analyse.inter |= X264_ANALYSE_PSUB16x16;
h->param.analyse.i_chroma_qp_offset = x264_clip3(h->param.analyse.i_chroma_qp_offset, -12, 12); h->param.analyse.i_chroma_qp_offset = x264_clip3(h->param.analyse.i_chroma_qp_offset, -12, 12);
h->param.analyse.i_mv_range = x264_clip3(h->param.analyse.i_mv_range, 32, 2048);
if( h->param.rc.f_qblur < 0 ) if( h->param.rc.f_qblur < 0 )
h->param.rc.f_qblur = 0; h->param.rc.f_qblur = 0;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <math.h>
#include "x264.h" #include "x264.h"
#include "common/bs.h" #include "common/bs.h"
...@@ -132,6 +133,19 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param ) ...@@ -132,6 +133,19 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
sps->vui.b_fixed_frame_rate = 1; sps->vui.b_fixed_frame_rate = 1;
} }
sps->b_vui |= sps->vui.b_timing_info_present; sps->b_vui |= sps->vui.b_timing_info_present;
sps->vui.b_bitstream_restriction = param->i_bframe > 0;
if( sps->vui.b_bitstream_restriction )
{
sps->vui.b_motion_vectors_over_pic_boundaries = 1;
sps->vui.i_max_bytes_per_pic_denom = 0;
sps->vui.i_max_bits_per_mb_denom = 0;
sps->vui.i_log2_max_mv_length_horizontal =
sps->vui.i_log2_max_mv_length_vertical = (int)(log(param->analyse.i_mv_range*4-1)/log(2)) + 1;
sps->vui.i_num_reorder_frames = param->b_bframe_pyramid ? 2 : param->i_bframe ? 1 : 0;
sps->vui.i_max_dec_frame_buffering = param->i_frame_reference + sps->vui.i_num_reorder_frames + 1;
}
sps->b_vui |= sps->vui.b_bitstream_restriction;
} }
...@@ -240,7 +254,17 @@ void x264_sps_write( bs_t *s, x264_sps_t *sps ) ...@@ -240,7 +254,17 @@ void x264_sps_write( bs_t *s, x264_sps_t *sps )
bs_write1( s, 0 ); /* nal_hrd_parameters_present_flag */ bs_write1( s, 0 ); /* nal_hrd_parameters_present_flag */
bs_write1( s, 0 ); /* vcl_hrd_parameters_present_flag */ bs_write1( s, 0 ); /* vcl_hrd_parameters_present_flag */
bs_write1( s, 0 ); /* pic_struct_present_flag */ bs_write1( s, 0 ); /* pic_struct_present_flag */
bs_write1( s, 0 ); /* bitstream_restriction_flag */ bs_write1( s, sps->vui.b_bitstream_restriction );
if( sps->vui.b_bitstream_restriction )
{
bs_write1( s, sps->vui.b_motion_vectors_over_pic_boundaries );
bs_write_ue( s, sps->vui.i_max_bytes_per_pic_denom );
bs_write_ue( s, sps->vui.i_max_bits_per_mb_denom );
bs_write_ue( s, sps->vui.i_log2_max_mv_length_horizontal );
bs_write_ue( s, sps->vui.i_log2_max_mv_length_vertical );
bs_write_ue( s, sps->vui.i_num_reorder_frames );
bs_write_ue( s, sps->vui.i_max_dec_frame_buffering );
}
} }
bs_rbsp_trailing( s ); bs_rbsp_trailing( s );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment