Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibras committed Aug 12, 2018
2 parents 5fee86c + 303c484 commit d418b64
Show file tree
Hide file tree
Showing 53 changed files with 1,196 additions and 643 deletions.
21 changes: 6 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ OBJEXAMPLE =

CONFIG := $(shell cat config.h)

# GPL-only files
ifneq ($(findstring HAVE_GPL 1, $(CONFIG)),)
SRCCLI +=
endif

# Optional module sources
ifneq ($(findstring HAVE_AVS 1, $(CONFIG)),)
SRCCLI += input/avs.c
Expand Down Expand Up @@ -358,8 +353,7 @@ fprofiled:
@echo 'where infiles are anything that x264 understands,'
@echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
else
fprofiled:
$(MAKE) clean
fprofiled: clean
$(MAKE) x264$(EXE) CFLAGS="$(CFLAGS) $(PROF_GEN_CC)" LDFLAGS="$(LDFLAGS) $(PROF_GEN_LD)"
$(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./x264$(EXE) $(OPT$I) --threads 1 $(V) -o $(DEVNULL) ;))
ifeq ($(COMPILER),CL)
Expand Down Expand Up @@ -388,18 +382,17 @@ install-cli: cli
$(INSTALL) x264$(EXE) $(DESTDIR)$(bindir)

install-lib-dev:
$(INSTALL) -d $(DESTDIR)$(includedir)
$(INSTALL) -d $(DESTDIR)$(libdir)
$(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig
$(INSTALL) -m 644 $(SRCPATH)/x264.h $(DESTDIR)$(includedir)
$(INSTALL) -m 644 x264_config.h $(DESTDIR)$(includedir)
$(INSTALL) -d $(DESTDIR)$(includedir) $(DESTDIR)$(libdir)/pkgconfig
$(INSTALL) -m 644 $(SRCPATH)/x264.h x264_config.h $(DESTDIR)$(includedir)
$(INSTALL) -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig

install-lib-static: lib-static install-lib-dev
$(INSTALL) -d $(DESTDIR)$(libdir)
$(INSTALL) -m 644 $(LIBX264) $(DESTDIR)$(libdir)
$(if $(RANLIB), $(RANLIB) $(DESTDIR)$(libdir)/$(LIBX264))

install-lib-shared: lib-shared install-lib-dev
$(INSTALL) -d $(DESTDIR)$(libdir)
ifneq ($(IMPLIBNAME),)
$(INSTALL) -d $(DESTDIR)$(bindir)
$(INSTALL) -m 755 $(SONAME) $(DESTDIR)$(bindir)
Expand All @@ -418,7 +411,5 @@ else ifneq ($(SONAME),)
rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
endif

etags: TAGS

TAGS:
etags TAGS:
etags $(SRCS) $(SRCS_X) $(SRCS_8)
69 changes: 59 additions & 10 deletions common/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,23 @@ char *x264_slurp_file( const char *filename )
/****************************************************************************
* x264_picture_init:
****************************************************************************/
void x264_picture_init( x264_picture_t *pic )
static void picture_init( x264_picture_t *pic )
{
memset( pic, 0, sizeof( x264_picture_t ) );
pic->i_type = X264_TYPE_AUTO;
pic->i_qpplus1 = X264_QP_AUTO;
pic->i_pic_struct = PIC_STRUCT_AUTO;
}

void x264_picture_init( x264_picture_t *pic )
{
x264_stack_align( picture_init, pic );
}

/****************************************************************************
* x264_picture_alloc:
****************************************************************************/
int x264_picture_alloc( x264_picture_t *pic, int i_csp, int i_width, int i_height )
static int picture_alloc( x264_picture_t *pic, int i_csp, int i_width, int i_height )
{
typedef struct
{
Expand Down Expand Up @@ -237,7 +242,7 @@ int x264_picture_alloc( x264_picture_t *pic, int i_csp, int i_width, int i_heigh
int csp = i_csp & X264_CSP_MASK;
if( csp <= X264_CSP_NONE || csp >= X264_CSP_MAX || csp == X264_CSP_V210 )
return -1;
x264_picture_init( pic );
picture_init( pic );
pic->img.i_csp = i_csp;
pic->img.i_plane = csp_tab[csp].planes;
int depth_factor = i_csp & X264_CSP_HIGH_DEPTH ? 2 : 1;
Expand All @@ -259,21 +264,31 @@ int x264_picture_alloc( x264_picture_t *pic, int i_csp, int i_width, int i_heigh
return 0;
}

int x264_picture_alloc( x264_picture_t *pic, int i_csp, int i_width, int i_height )
{
return x264_stack_align( picture_alloc, pic, i_csp, i_width, i_height );
}

/****************************************************************************
* x264_picture_clean:
****************************************************************************/
void x264_picture_clean( x264_picture_t *pic )
static void picture_clean( x264_picture_t *pic )
{
x264_free( pic->img.plane[0] );

/* just to be safe */
memset( pic, 0, sizeof( x264_picture_t ) );
}

void x264_picture_clean( x264_picture_t *pic )
{
x264_stack_align( picture_clean, pic );
}

/****************************************************************************
* x264_param_default:
****************************************************************************/
void x264_param_default( x264_param_t *param )
static void param_default( x264_param_t *param )
{
/* */
memset( param, 0, sizeof( x264_param_t ) );
Expand Down Expand Up @@ -414,6 +429,13 @@ void x264_param_default( x264_param_t *param )
param->i_opencl_device = 0;
param->opencl_device_id = NULL;
param->psz_clbin_file = NULL;
param->i_avcintra_class = 0;
param->i_avcintra_flavor = X264_AVCINTRA_FLAVOR_PANASONIC;
}

void x264_param_default( x264_param_t *param )
{
x264_stack_align( param_default, param );
}

static int param_apply_preset( x264_param_t *param, const char *preset )
Expand Down Expand Up @@ -643,9 +665,9 @@ static int param_apply_tune( x264_param_t *param, const char *tune )
return 0;
}

int x264_param_default_preset( x264_param_t *param, const char *preset, const char *tune )
static int param_default_preset( x264_param_t *param, const char *preset, const char *tune )
{
x264_param_default( param );
param_default( param );

if( preset && param_apply_preset( param, preset ) < 0 )
return -1;
Expand All @@ -654,7 +676,12 @@ int x264_param_default_preset( x264_param_t *param, const char *preset, const ch
return 0;
}

void x264_param_apply_fastfirstpass( x264_param_t *param )
int x264_param_default_preset( x264_param_t *param, const char *preset, const char *tune )
{
return x264_stack_align( param_default_preset, param, preset, tune );
}

static void param_apply_fastfirstpass( x264_param_t *param )
{
/* Set faster options in case of turbo firstpass. */
if( param->rc.b_stat_write && !param->rc.b_stat_read )
Expand All @@ -669,6 +696,11 @@ void x264_param_apply_fastfirstpass( x264_param_t *param )
}
}

void x264_param_apply_fastfirstpass( x264_param_t *param )
{
x264_stack_align( param_apply_fastfirstpass, param );
}

static int profile_string_to_int( const char *str )
{
if( !strcasecmp( str, "baseline" ) )
Expand All @@ -686,7 +718,7 @@ static int profile_string_to_int( const char *str )
return -1;
}

int x264_param_apply_profile( x264_param_t *param, const char *profile )
static int param_apply_profile( x264_param_t *param, const char *profile )
{
if( !profile )
return 0;
Expand Down Expand Up @@ -719,6 +751,11 @@ int x264_param_apply_profile( x264_param_t *param, const char *profile )
x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support a bit depth of %d\n", profile, param->i_bitdepth );
return -1;
}
if( p < PROFILE_HIGH && (param->i_csp & X264_CSP_MASK) == X264_CSP_I400 )
{
x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support 4:0:0\n", profile );
return -1;
}

if( p == PROFILE_BASELINE )
{
Expand Down Expand Up @@ -748,6 +785,11 @@ int x264_param_apply_profile( x264_param_t *param, const char *profile )
return 0;
}

int x264_param_apply_profile( x264_param_t *param, const char *profile )
{
return x264_stack_align( param_apply_profile, param, profile );
}

static int parse_enum( const char *arg, const char * const *names, int *dst )
{
for( int i = 0; names[i]; i++ )
Expand Down Expand Up @@ -809,7 +851,7 @@ static double atof_internal( const char *str, int *b_error )
#define atoi(str) atoi_internal( str, &b_error )
#define atof(str) atof_internal( str, &b_error )

int x264_param_parse( x264_param_t *p, const char *name, const char *value )
static int param_parse( x264_param_t *p, const char *name, const char *value )
{
char *name_buf = NULL;
int b_error = 0;
Expand Down Expand Up @@ -915,6 +957,8 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
p->b_bluray_compat = atobool(value);
OPT("avcintra-class")
p->i_avcintra_class = atoi(value);
OPT("avcintra-flavor")
b_error |= parse_enum( value, x264_avcintra_flavor_names, &p->i_avcintra_flavor );
OPT("sar")
{
b_error = ( 2 != sscanf( value, "%d:%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) &&
Expand Down Expand Up @@ -1308,6 +1352,11 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
return b_error ? errortype : 0;
}

int x264_param_parse( x264_param_t *param, const char *name, const char *value )
{
return x264_stack_align( param_parse, param, name, value );
}

/****************************************************************************
* x264_param2string:
****************************************************************************/
Expand Down
10 changes: 8 additions & 2 deletions common/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ static inline void bs_init( bs_t *s, void *p_data, int i_data )
s->p = s->p_start = (uint8_t*)p_data - offset;
s->p_end = (uint8_t*)p_data + i_data;
s->i_left = (WORD_SIZE - offset)*8;
s->cur_bits = endian_fix32( M32(s->p) );
s->cur_bits >>= (4-offset)*8;
if( offset )
{
s->cur_bits = endian_fix32( M32(s->p) );
s->cur_bits >>= (4-offset)*8;
}
else
s->cur_bits = 0;
}
static inline int bs_pos( bs_t *s )
{
Expand Down Expand Up @@ -188,6 +193,7 @@ static inline void bs_align_10( bs_t *s )
{
if( s->i_left&7 )
bs_write( s, s->i_left&7, 1 << ( (s->i_left&7) - 1 ) );
bs_flush( s );
}

/* golomb functions */
Expand Down
6 changes: 3 additions & 3 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
# define CHROMA_V_SHIFT h->mb.chroma_v_shift
#endif

#define CHROMA_SIZE(s) ((s)>>(CHROMA_H_SHIFT+CHROMA_V_SHIFT))
#define CHROMA_SIZE(s) (CHROMA_FORMAT ? (s)>>(CHROMA_H_SHIFT+CHROMA_V_SHIFT) : 0)
#define FRAME_SIZE(s) ((s)+2*CHROMA_SIZE(s))
#define CHROMA444 (CHROMA_FORMAT == CHROMA_444)

Expand Down Expand Up @@ -767,7 +767,7 @@ typedef struct
// included at the end because it needs x264_t
#include "macroblock.h"

static int ALWAYS_INLINE x264_predictor_roundclip( int16_t (*dst)[2], int16_t (*mvc)[2], int i_mvc, int16_t mv_limit[2][2], uint32_t pmv )
static ALWAYS_INLINE int x264_predictor_roundclip( int16_t (*dst)[2], int16_t (*mvc)[2], int i_mvc, int16_t mv_limit[2][2], uint32_t pmv )
{
int cnt = 0;
for( int i = 0; i < i_mvc; i++ )
Expand All @@ -783,7 +783,7 @@ static int ALWAYS_INLINE x264_predictor_roundclip( int16_t (*dst)[2], int16_t (*
return cnt;
}

static int ALWAYS_INLINE x264_predictor_clip( int16_t (*dst)[2], int16_t (*mvc)[2], int i_mvc, int16_t mv_limit[2][2], uint32_t pmv )
static ALWAYS_INLINE int x264_predictor_clip( int16_t (*dst)[2], int16_t (*mvc)[2], int i_mvc, int16_t mv_limit[2][2], uint32_t pmv )
{
int cnt = 0;
int qpel_limit[4] = {mv_limit[0][0] << 2, mv_limit[0][1] << 2, mv_limit[1][0] << 2, mv_limit[1][1] << 2};
Expand Down
3 changes: 2 additions & 1 deletion common/dct.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ static void add16x16_idct8( pixel *dst, dctcoef dct[4][64] )
add8x8_idct8( &dst[8*FDEC_STRIDE+8], dct[3] );
}

static void inline add4x4_idct_dc( pixel *p_dst, dctcoef dc )
static inline void add4x4_idct_dc( pixel *p_dst, dctcoef dc )
{
dc = (dc + 32) >> 6;
for( int i = 0; i < 4; i++, p_dst += FDEC_STRIDE )
Expand Down Expand Up @@ -667,6 +667,7 @@ void x264_dct_init( int cpu, x264_dct_function_t *dctf )
dctf->sub16x16_dct = x264_sub16x16_dct_altivec;

dctf->add8x8_idct_dc = x264_add8x8_idct_dc_altivec;
dctf->add16x16_idct_dc = x264_add16x16_idct_dc_altivec;

dctf->add4x4_idct = x264_add4x4_idct_altivec;
dctf->add8x8_idct = x264_add8x8_idct_altivec;
Expand Down
Loading

0 comments on commit d418b64

Please sign in to comment.