[x264-devel] commit: Fix some possible overflows in VFR ratecontrol with extreme timebases ( Anton Mitrofanov )
git at videolan.org
git at videolan.org
Mon Jan 10 22:00:53 CET 2011
x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Fri Dec 24 14:52:57 2010 -0500| [cb15f76189a21d6234086a0cbda7357fd5cfa524] | committer: Jason Garrett-Glaser
Fix some possible overflows in VFR ratecontrol with extreme timebases
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=cb15f76189a21d6234086a0cbda7357fd5cfa524
---
common/common.h | 14 +++++++-------
common/frame.h | 14 +++++++-------
encoder/ratecontrol.c | 8 ++++----
encoder/slicetype.c | 2 +-
4 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/common/common.h b/common/common.h
index 119508c..75913cb 100644
--- a/common/common.h
+++ b/common/common.h
@@ -429,16 +429,16 @@ struct x264_t
int i_nal_type;
int i_nal_ref_idc;
- int i_disp_fields; /* Number of displayed fields (both coded and implied via pic_struct) */
+ int64_t i_disp_fields; /* Number of displayed fields (both coded and implied via pic_struct) */
int i_disp_fields_last_frame;
- int i_prev_duration; /* Duration of previous frame */
- int i_coded_fields; /* Number of coded fields (both coded and implied via pic_struct) */
- int i_cpb_delay; /* Equal to number of fields preceding this field
+ int64_t i_prev_duration; /* Duration of previous frame */
+ int64_t i_coded_fields; /* Number of coded fields (both coded and implied via pic_struct) */
+ int64_t i_cpb_delay; /* Equal to number of fields preceding this field
* since last buffering_period SEI */
- int i_coded_fields_lookahead; /* Use separate counters for lookahead */
- int i_cpb_delay_lookahead;
+ int64_t i_coded_fields_lookahead; /* Use separate counters for lookahead */
+ int64_t i_cpb_delay_lookahead;
- int i_cpb_delay_pir_offset;
+ int64_t i_cpb_delay_pir_offset;
int b_queued_intra_refresh;
int64_t i_last_idr_pts;
diff --git a/common/frame.h b/common/frame.h
index 0804fb2..09ccfcd 100644
--- a/common/frame.h
+++ b/common/frame.h
@@ -41,16 +41,16 @@ typedef struct x264_frame
int64_t i_pts;
int64_t i_dts;
int64_t i_reordered_pts;
- int i_duration; /* in SPS time_scale units (i.e 2 * timebase units) used for vfr */
+ int64_t i_duration; /* in SPS time_scale units (i.e 2 * timebase units) used for vfr */
float f_duration; /* in seconds */
- int i_cpb_duration;
- int i_cpb_delay; /* in SPS time_scale units (i.e 2 * timebase units) */
- int i_dpb_output_delay;
+ int64_t i_cpb_duration;
+ int64_t i_cpb_delay; /* in SPS time_scale units (i.e 2 * timebase units) */
+ int64_t i_dpb_output_delay;
x264_param_t *param;
int i_frame; /* Presentation frame number */
int i_coded; /* Coded frame number */
- int i_field_cnt; /* Presentation field count */
+ int64_t i_field_cnt; /* Presentation field count */
int i_frame_num; /* 7.4.3 frame_num */
int b_kept_as_ref;
int i_pic_struct;
@@ -134,8 +134,8 @@ typedef struct x264_frame
uint8_t i_planned_type[X264_LOOKAHEAD_MAX+1];
int i_planned_satd[X264_LOOKAHEAD_MAX+1];
double f_planned_cpb_duration[X264_LOOKAHEAD_MAX+1];
- int i_coded_fields_lookahead;
- int i_cpb_delay_lookahead;
+ int64_t i_coded_fields_lookahead;
+ int64_t i_cpb_delay_lookahead;
/* threading */
int i_lines_completed; /* in pixels */
diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index d8aff9e..162100a 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -57,8 +57,8 @@ typedef struct
int16_t i_weight_denom[2];
int refcount[16];
int refs;
- int i_duration;
- int i_cpb_duration;
+ int64_t i_duration;
+ int64_t i_cpb_duration;
} ratecontrol_entry_t;
typedef struct
@@ -834,7 +834,7 @@ int x264_ratecontrol_new( x264_t *h )
rce = &rc->entry[frame_number];
rce->direct_mode = 0;
- e += sscanf( p, " in:%*d out:%*d type:%c dur:%d cpbdur:%d q:%f tex:%d mv:%d misc:%d imb:%d pmb:%d smb:%d d:%c",
+ e += sscanf( p, " in:%*d out:%*d type:%c dur:%"SCNd64" cpbdur:%"SCNd64" q:%f tex:%d mv:%d misc:%d imb:%d pmb:%d smb:%d d:%c",
&pict_type, &rce->i_duration, &rce->i_cpb_duration, &qp, &rce->tex_bits,
&rce->mv_bits, &rce->misc_bits, &rce->i_count, &rce->p_count,
&rce->s_count, &rce->direct_mode );
@@ -1534,7 +1534,7 @@ int x264_ratecontrol_end( x264_t *h, int bits, int *filler )
dir_avg>0 ? 's' : dir_avg<0 ? 't' : '-' )
: '-';
if( fprintf( rc->p_stat_file_out,
- "in:%d out:%d type:%c dur:%d cpbdur:%d q:%.2f tex:%d mv:%d misc:%d imb:%d pmb:%d smb:%d d:%c ref:",
+ "in:%d out:%d type:%c dur:%"PRId64" cpbdur:%"PRId64" q:%.2f tex:%d mv:%d misc:%d imb:%d pmb:%d smb:%d d:%c ref:",
h->fenc->i_frame, h->i_frame,
c_type, h->fenc->i_duration,
h->fenc->i_cpb_duration, rc->qpa_rc,
diff --git a/encoder/slicetype.c b/encoder/slicetype.c
index 9d5718c..149737d 100644
--- a/encoder/slicetype.c
+++ b/encoder/slicetype.c
@@ -955,7 +955,7 @@ static int x264_vbv_frame_cost( x264_t *h, x264_mb_analysis_t *a, x264_frame_t *
return cost;
}
-static void x264_calculate_durations( x264_t *h, x264_frame_t *cur_frame, x264_frame_t *prev_frame, int *i_cpb_delay, int *i_coded_fields )
+static void x264_calculate_durations( x264_t *h, x264_frame_t *cur_frame, x264_frame_t *prev_frame, int64_t *i_cpb_delay, int64_t *i_coded_fields )
{
cur_frame->i_cpb_delay = *i_cpb_delay;
cur_frame->i_dpb_output_delay = cur_frame->i_field_cnt - *i_coded_fields;
More information about the x264-devel
mailing list