Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obe #8

Open
wants to merge 93 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
fcc3087
Add speedcontrol file.
kierank Jan 20, 2011
aad01e1
Merge speedcontrol.
kierank Feb 21, 2011
772a3b7
Add "Fake HRD". This writes Buffering Period SEI but sets nal_hrd_par…
kierank Nov 9, 2010
394c8b9
Use a better API for speedcontrol on Linux.
kierank Feb 27, 2011
86cca25
Pass through user data.
kierank Mar 3, 2011
ebeed24
Turn off warning temporarily.
kierank Mar 7, 2011
36070c5
Export profile and actual vbv values.
kierank Mar 7, 2011
4ce2a2e
Start counting when the first frame is encoded, not when x264_encoder…
kierank Mar 8, 2011
14234b9
Fix 10L
kierank Mar 8, 2011
3b628bb
Fix Linux timing function and build.
kierank Mar 8, 2011
0a39eda
Change defaults and use x264_log
kierank Mar 9, 2011
e8de85d
Fix merge problem.
kierank Mar 10, 2011
e39fe19
Fix Fake CBR
kierank May 12, 2011
d15a888
Add new speedcontrol timings.
kierank Jul 19, 2011
40d893f
Make speedcontrol idle an informational log message.
kierank Jul 27, 2011
c015eed
Only use 10 speedcontrol presets for now.
kierank Jul 29, 2011
17e72e7
Pre-place keyframes to fix long stalls when PB... becomes IP... and a…
kierank Jul 29, 2011
3444043
Fix typo in previous patch.
kierank Jul 29, 2011
7114558
Use a 27MHz clock for HRD timing output. There was accumulation of er…
kierank Aug 24, 2011
c39d086
Fix issues with HRD timings.
kierank Aug 24, 2011
543137f
Get rid of hardcoded parameters in speedcontrol. This allows SAR chan…
kierank Aug 29, 2011
37a647c
Fix bad merge.
kierank Oct 22, 2011
2c33d28
Fix error with rebasing.
kierank Oct 25, 2011
3ffaa2b
Output the arrival time of the AU into the CPB.
kierank Dec 3, 2011
ccf4f20
Set CBR HRD flags correctly.
kierank Dec 5, 2011
c444d2b
Make single frame vbv code, correct the actual buffer size.
kierank Dec 5, 2011
36dc854
Merge git://git.videolan.org/x264
kierank Dec 6, 2011
f88f880
Merge git://git.videolan.org/x264
kierank Dec 8, 2011
97bb99f
Add missing lines in hrd output.
kierank Dec 13, 2011
6787ff9
Including cpb removal delay offset in the initial arrival time is wrong.
kierank Dec 15, 2011
f3cfa4f
Make HRD timings work acceptable for single frame vbv
kierank Dec 19, 2011
d244441
Make HRD output timings more accurate
kierank Dec 20, 2011
5ef09c7
Have a safe cpb initial arrival time field so that single frame vbv
kierank Dec 23, 2011
284ff3f
Add speedcontrol file.
kierank Jan 20, 2011
8deeec8
Merge speedcontrol.
kierank Feb 21, 2011
91d8a81
Add "Fake HRD". This writes Buffering Period SEI but sets nal_hrd_par…
kierank Nov 9, 2010
ab79ff2
Use a better API for speedcontrol on Linux.
kierank Feb 27, 2011
2dfa98f
Turn off warning temporarily.
kierank Mar 7, 2011
b65fd9f
Export profile and actual vbv values.
kierank Mar 7, 2011
5dff104
Start counting when the first frame is encoded, not when x264_encoder…
kierank Mar 8, 2011
e9e8134
Fix 10L
kierank Mar 8, 2011
37db7a3
Fix Linux timing function and build.
kierank Mar 8, 2011
9a4f969
Change defaults and use x264_log
kierank Mar 9, 2011
e7e953e
Fix merge problem.
kierank Mar 10, 2011
7258c34
Fix Fake CBR
kierank May 12, 2011
d48697e
Add new speedcontrol timings.
kierank Jul 19, 2011
198c887
Make speedcontrol idle an informational log message.
kierank Jul 27, 2011
67c00ed
Only use 10 speedcontrol presets for now.
kierank Jul 29, 2011
168a2af
Pre-place keyframes to fix long stalls when PB... becomes IP... and a…
kierank Jul 29, 2011
1bd5984
Fix typo in previous patch.
kierank Jul 29, 2011
683fd7b
Use a 27MHz clock for HRD timing output. There was accumulation of er…
kierank Aug 24, 2011
7c063d4
Fix issues with HRD timings.
kierank Aug 24, 2011
e6bb06f
Get rid of hardcoded parameters in speedcontrol. This allows SAR chan…
kierank Aug 29, 2011
c425bb7
Fix bad merge.
kierank Oct 22, 2011
30ead41
Fix error with rebasing.
kierank Oct 25, 2011
35a640b
Output the arrival time of the AU into the CPB.
kierank Dec 3, 2011
d7684b1
Set CBR HRD flags correctly.
kierank Dec 5, 2011
7852047
Make single frame vbv code, correct the actual buffer size.
kierank Dec 5, 2011
753f8c4
Add missing lines in hrd output.
kierank Dec 13, 2011
6f8745e
Including cpb removal delay offset in the initial arrival time is wrong.
kierank Dec 15, 2011
724f2e6
Make HRD timings work acceptable for single frame vbv
kierank Dec 19, 2011
06191ad
Make HRD output timings more accurate
kierank Dec 20, 2011
3d0a3ce
Have a safe cpb initial arrival time field so that single frame vbv
kierank Dec 23, 2011
8f8ace2
Merge branch 'master' of github.com:kierank/x264-obe
kierank Jan 16, 2012
27861fe
Merge branch 'master' of git://git.videolan.org/x264
Jan 21, 2012
da0c2ad
Disable BFF signalling using POC. Fixes playback on a set top box.
kierank Jan 24, 2012
f312b41
Merge branch 'master' of git://git.videolan.org/x264
kierank Feb 7, 2012
49226f9
Fix hrd timings with intra-refresh
kierank Feb 11, 2012
60b8f8a
Export the earliest arrival time correctly.
kierank Feb 23, 2012
c525ca3
Fix typo (didn't affect OBE-RT)
kierank Feb 25, 2012
c9b768c
Merge branch 'master' of git://git.videolan.org/x264
kierank Mar 7, 2012
8505949
Revert "Sliced-threads: do hpel and deblock after returning"
kierank Mar 9, 2012
0ee492b
Merge branch 'master' of git://git.videolan.org/x264
kierank Mar 13, 2012
90c8271
Merge git://github.com/DarkShikari/x264-devel
kierank Mar 15, 2012
6180eed
Revert "Fix clobbering of mutex/cvs"
kierank Mar 15, 2012
475c62d
Fix build temporarily.
kierank Mar 19, 2012
788efde
Fix intra-refresh + hrd.
Mar 27, 2012
48de317
Sliced-threads: do hpel and deblock after returning
Feb 24, 2012
575c11a
Fix clobbering of mutex/cvs
MasterNobody Mar 12, 2012
5cfb491
Merge git://github.com/DarkShikari/x264-devel
kierank Mar 27, 2012
21fed51
Move the pir_offset code back to its original place.
kierank Mar 27, 2012
87c617d
Turn down verbosity of speedcontrol
kierank Mar 30, 2012
40b8756
Add ability to signal to x264 when speedcontrol buffering is complete
kierank Mar 30, 2012
6e14252
Set the default number of presets to be used to the maximum
kierank Mar 30, 2012
0f8a002
Revert "Pre-place keyframes to fix long stalls when PB... becomes IP.…
Mar 1, 2013
e2eec40
Merge x264 git
Mar 1, 2013
13f0616
Merge branch 'master' of git://git.videolan.org/x264 into newmerge
Mar 10, 2013
20f91fc
Merge branch 'newmerge' of github.com:kierank/x264-obe into obe
Mar 10, 2013
f53b90d
Temporarily disable speedcontrol for x262. Causes a lot of artefacts.
Mar 11, 2013
bd3331c
update low delay flag when no bframes are used
Mar 13, 2013
1d81db2
Merge branch 'master' into obe
kierank Mar 26, 2013
6938fa3
Merge branch 'master' into obe
kierank Mar 15, 2015
9679f15
Disable crashing AVX2
kierank May 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SRCS = common/mc.c common/predict.c common/pixel.c common/macroblock.c \
common/mvpred.c common/bitstream.c \
encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
encoder/set.c encoder/macroblock.c encoder/cabac.c \
encoder/speed.c \
encoder/cavlc.c encoder/encoder.c encoder/lookahead.c

SRCCLI = x264.c input/input.c input/timecode.c input/raw.c input/y4m.c \
Expand Down
16 changes: 16 additions & 0 deletions common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ void x264_param_default( x264_param_t *param )
param->rc.i_zones = 0;
param->rc.b_mb_tree = 1;

// speedcontrol
param->sc.f_speed = 0;
param->sc.i_buffer_size = 12;
param->sc.f_buffer_init = 0.75;
param->sc.max_preset = SC_PRESETS;

/* Log */
param->pf_log = x264_log_default;
param->p_log_private = NULL;
Expand Down Expand Up @@ -1145,6 +1151,14 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
p->rc.f_complexity_blur = atof(value);
OPT("zones")
p->rc.psz_zones = strdup(value);
OPT("speed")
p->sc.f_speed = atof(value);
OPT("speed-bufsize")
p->sc.i_buffer_size = atoi(value);
OPT("speed-init")
p->sc.f_buffer_init = atof(value);
OPT("speed-alt-timer")
p->sc.b_alt_timer = atobool(value);
OPT("crop-rect")
b_error |= sscanf( value, "%u,%u,%u,%u", &p->crop_rect.i_left, &p->crop_rect.i_top,
&p->crop_rect.i_right, &p->crop_rect.i_bottom ) != 4;
Expand Down Expand Up @@ -1474,6 +1488,8 @@ char *x264_param2string( x264_param_t *p, int b_res )
s += sprintf( s, "bitdepth=%d ", BIT_DEPTH );
}

// FIXME speedcontrol stuff

if( p->b_opencl )
s += sprintf( s, "opencl=%d ", p->b_opencl );
s += sprintf( s, "cabac=%d", p->b_cabac );
Expand Down
3 changes: 3 additions & 0 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ do {\

#define LOG2_16(x) (31 - x264_clz((x)|1))

#define SC_PRESETS 13
/****************************************************************************
* Includes
****************************************************************************/
Expand Down Expand Up @@ -514,6 +515,7 @@ typedef struct x264_lookahead_t
} x264_lookahead_t;

typedef struct x264_ratecontrol_t x264_ratecontrol_t;
typedef struct x264_speedcontrol_t x264_speedcontrol_t;

typedef struct x264_left_table_t
{
Expand Down Expand Up @@ -969,6 +971,7 @@ struct x264_t

/* rate control encoding only */
x264_ratecontrol_t *rc;
x264_speedcontrol_t *sc;

/* stats */
struct
Expand Down
6 changes: 5 additions & 1 deletion common/osdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ extern int ptw32_processInitialized;

int64_t x264_mdate( void )
{
#if SYS_WINDOWS
#ifdef __MINGW32__
struct timeb tb;
ftime( &tb );
return ((int64_t)tb.time * 1000 + (int64_t)tb.millitm) * 1000;
#elif SYS_LINUX
struct timespec ts_current;
clock_gettime( CLOCK_MONOTONIC, &ts_current );
return (int64_t)ts_current.tv_sec * 1000000 + (int64_t)ts_current.tv_nsec / 1000;
#else
struct timeval tv_date;
gettimeofday( &tv_date, NULL );
Expand Down
2 changes: 1 addition & 1 deletion common/quant.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf )
{
pf->quant_4x4 = x264_quant_4x4_avx2;
pf->quant_4x4_dc = x264_quant_4x4_dc_avx2;
pf->quant_8x8 = x264_quant_8x8_avx2;
//pf->quant_8x8 = x264_quant_8x8_avx2;
pf->quant_4x4x4 = x264_quant_4x4x4_avx2;
pf->dequant_4x4 = x264_dequant_4x4_avx2;
pf->dequant_8x8 = x264_dequant_8x8_avx2;
Expand Down
4 changes: 4 additions & 0 deletions common/x86/mc-a.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,10 @@ AVG16_CACHELINE_LOOP_SSSE3 j, k
%endrep
%endif ; !HIGH_BIT_DEPTH

;=============================================================================
; hpel_filter_c
;=============================================================================

;=============================================================================
; pixel copy
;=============================================================================
Expand Down
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ case $host_os in
SYS="LINUX"
define HAVE_MALLOC_H
libm="-lm"
LDFLAGS="$LDFLAGS -lrt"
;;
gnu*)
SYS="HURD"
Expand Down
38 changes: 30 additions & 8 deletions encoder/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1328,24 +1328,31 @@ static int x264_validate_parameters( x264_t *h, int b_open )
h->param.rc.f_qblur = 0;
if( h->param.rc.f_complexity_blur < 0 )
h->param.rc.f_complexity_blur = 0;
if( h->param.sc.i_buffer_size < 0 || h->param.sc.f_speed <= 0 )
h->param.sc.i_buffer_size = 0;

h->param.i_sps_id &= 31;

h->param.i_nal_hrd = x264_clip3( h->param.i_nal_hrd, X264_NAL_HRD_NONE, X264_NAL_HRD_CBR );
if( PARAM_INTERLACED )
h->param.b_pic_struct = 1;

h->param.i_nal_hrd = x264_clip3( h->param.i_nal_hrd, X264_NAL_HRD_NONE, X264_NAL_HRD_FAKE_CBR );

if( h->param.i_nal_hrd && !h->param.rc.i_vbv_buffer_size )
{
x264_log( h, X264_LOG_WARNING, "NAL HRD parameters require VBV parameters\n" );
h->param.i_nal_hrd = X264_NAL_HRD_NONE;
}

if( h->param.i_nal_hrd == X264_NAL_HRD_CBR &&
(h->param.rc.i_bitrate != h->param.rc.i_vbv_max_bitrate || !h->param.rc.i_vbv_max_bitrate) )
if( (h->param.i_nal_hrd == X264_NAL_HRD_CBR || h->param.i_nal_hrd == X264_NAL_HRD_FAKE_CBR) &&
(h->param.rc.i_bitrate != h->param.rc.i_vbv_max_bitrate || !h->param.rc.i_vbv_max_bitrate) )
{
x264_log( h, X264_LOG_WARNING, "CBR HRD requires constant bitrate\n" );
h->param.i_nal_hrd = X264_NAL_HRD_VBR;
h->param.i_nal_hrd = h->param.i_nal_hrd == X264_NAL_HRD_CBR ? X264_NAL_HRD_VBR : X264_NAL_HRD_FAKE_CBR;
}

h->param.sc.max_preset = x264_clip3( h->param.sc.max_preset, 1, SC_PRESETS );

if( h->param.i_nal_hrd == X264_NAL_HRD_CBR )
h->param.rc.b_filler = 1;

Expand Down Expand Up @@ -1580,6 +1587,7 @@ x264_t *x264_encoder_open( x264_param_t *param )
x264_set_aspect_ratio( h, &h->param, 1 );

x264_sps_init( h->sps, h->param.i_sps_id, &h->param );
h->param.i_profile = h->sps->i_profile_idc;
x264_pps_init( h, h->pps, h->param.i_sps_id, &h->param, h->sps );

x264_validate_levels( h, 1 );
Expand Down Expand Up @@ -1680,6 +1688,10 @@ x264_t *x264_encoder_open( x264_param_t *param )
mbcmp_init( h );
chroma_dsp_init( h );

if( h->param.sc.i_buffer_size )
x264_speedcontrol_new( h );


p = buf + sprintf( buf, "using cpu capabilities:" );
for( int i = 0; x264_cpu_names[i].flags; i++ )
{
Expand Down Expand Up @@ -2674,7 +2686,7 @@ static inline void x264_slice_init( x264_t *h, int i_nal_type, int i_global_qp )
if( h->sps->i_poc_type == 0 )
{
h->sh.i_poc = h->fdec->i_poc;
if( PARAM_INTERLACED )
if( PARAM_INTERLACED && h->pps->b_pic_order )
{
h->sh.i_delta_poc_bottom = h->param.b_tff ? 1 : -1;
h->sh.i_poc += h->sh.i_delta_poc_bottom == -1;
Expand Down Expand Up @@ -3853,7 +3865,7 @@ int x264_encoder_encode( x264_t *h,
}

/* when frame threading is used, buffering period sei is written in x264_encoder_frame_end */
if( h->i_thread_frames == 1 && h->sps->vui.b_nal_hrd_parameters_present )
if( h->i_thread_frames == 1 && h->param.i_nal_hrd )
{
x264_hrd_fullness( h );
x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
Expand Down Expand Up @@ -3946,6 +3958,10 @@ int x264_encoder_encode( x264_t *h,
overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
}

/* Init the speed control */
if( h->param.sc.i_buffer_size )
x264_speedcontrol_frame( h );

if( h->fenc->b_keyframe && h->param.b_intra_refresh )
h->i_cpb_delay_pir_offset_next = h->fenc->i_cpb_delay;

Expand Down Expand Up @@ -4061,7 +4077,7 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,
x264_emms();

/* generate buffering period sei and insert it into place */
if( h->i_thread_frames > 1 && h->fenc->b_keyframe && h->sps->vui.b_nal_hrd_parameters_present )
if( h->i_thread_frames > 1 && h->fenc->b_keyframe && h->param.i_nal_hrd )
{
x264_hrd_fullness( h );
x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
Expand All @@ -4085,7 +4101,6 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,

/* Set output picture properties */
pic_out->i_type = h->fenc->i_type;

pic_out->b_keyframe = h->fenc->b_keyframe;
pic_out->i_pic_struct = h->fenc->i_pic_struct;

Expand Down Expand Up @@ -4162,6 +4177,9 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,
}
}

if( h->fenc->b_keyframe && h->param.b_intra_refresh )
h->i_cpb_delay_pir_offset = h->fenc->i_cpb_delay;

/* End bitstream, set output */
*pi_nal = h->out.i_nal;
*pp_nal = h->out.nal;
Expand All @@ -4170,6 +4188,9 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,

x264_noise_reduction_update( h );

if( h->param.sc.i_buffer_size )
x264_speedcontrol_frame_end( h );

/* ---------------------- Compute/Print statistics --------------------- */
x264_thread_sync_stat( h, h->thread[0] );

Expand Down Expand Up @@ -4622,6 +4643,7 @@ void x264_encoder_close ( x264_t *h )

/* rc */
x264_ratecontrol_delete( h );
x264_speedcontrol_delete( h );

/* param */
if( h->param.rc.psz_stat_out )
Expand Down
Loading