Commit 89146fc6 authored by Rico Tzschichholz's avatar Rico Tzschichholz

New upstream version 0.157.2945+git72db437

parent fe793f50
...@@ -53,11 +53,6 @@ OBJEXAMPLE = ...@@ -53,11 +53,6 @@ OBJEXAMPLE =
CONFIG := $(shell cat config.h) CONFIG := $(shell cat config.h)
# GPL-only files
ifneq ($(findstring HAVE_GPL 1, $(CONFIG)),)
SRCCLI +=
endif
# Optional module sources # Optional module sources
ifneq ($(findstring HAVE_AVS 1, $(CONFIG)),) ifneq ($(findstring HAVE_AVS 1, $(CONFIG)),)
SRCCLI += input/avs.c SRCCLI += input/avs.c
...@@ -358,8 +353,7 @@ fprofiled: ...@@ -358,8 +353,7 @@ fprofiled:
@echo 'where infiles are anything that x264 understands,' @echo 'where infiles are anything that x264 understands,'
@echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.' @echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
else else
fprofiled: fprofiled: clean
$(MAKE) clean
$(MAKE) x264$(EXE) CFLAGS="$(CFLAGS) $(PROF_GEN_CC)" LDFLAGS="$(LDFLAGS) $(PROF_GEN_LD)" $(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) ;)) $(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) ifeq ($(COMPILER),CL)
...@@ -388,18 +382,17 @@ install-cli: cli ...@@ -388,18 +382,17 @@ install-cli: cli
$(INSTALL) x264$(EXE) $(DESTDIR)$(bindir) $(INSTALL) x264$(EXE) $(DESTDIR)$(bindir)
install-lib-dev: install-lib-dev:
$(INSTALL) -d $(DESTDIR)$(includedir) $(INSTALL) -d $(DESTDIR)$(includedir) $(DESTDIR)$(libdir)/pkgconfig
$(INSTALL) -d $(DESTDIR)$(libdir) $(INSTALL) -m 644 $(SRCPATH)/x264.h x264_config.h $(DESTDIR)$(includedir)
$(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig
$(INSTALL) -m 644 $(SRCPATH)/x264.h $(DESTDIR)$(includedir)
$(INSTALL) -m 644 x264_config.h $(DESTDIR)$(includedir)
$(INSTALL) -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig $(INSTALL) -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
install-lib-static: lib-static install-lib-dev install-lib-static: lib-static install-lib-dev
$(INSTALL) -d $(DESTDIR)$(libdir)
$(INSTALL) -m 644 $(LIBX264) $(DESTDIR)$(libdir) $(INSTALL) -m 644 $(LIBX264) $(DESTDIR)$(libdir)
$(if $(RANLIB), $(RANLIB) $(DESTDIR)$(libdir)/$(LIBX264)) $(if $(RANLIB), $(RANLIB) $(DESTDIR)$(libdir)/$(LIBX264))
install-lib-shared: lib-shared install-lib-dev install-lib-shared: lib-shared install-lib-dev
$(INSTALL) -d $(DESTDIR)$(libdir)
ifneq ($(IMPLIBNAME),) ifneq ($(IMPLIBNAME),)
$(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) -d $(DESTDIR)$(bindir)
$(INSTALL) -m 755 $(SONAME) $(DESTDIR)$(bindir) $(INSTALL) -m 755 $(SONAME) $(DESTDIR)$(bindir)
...@@ -418,7 +411,5 @@ else ifneq ($(SONAME),) ...@@ -418,7 +411,5 @@ else ifneq ($(SONAME),)
rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX) rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
endif endif
etags: TAGS etags TAGS:
TAGS:
etags $(SRCS) $(SRCS_X) $(SRCS_8) etags $(SRCS) $(SRCS_X) $(SRCS_8)
...@@ -429,6 +429,8 @@ static void param_default( x264_param_t *param ) ...@@ -429,6 +429,8 @@ static void param_default( x264_param_t *param )
param->i_opencl_device = 0; param->i_opencl_device = 0;
param->opencl_device_id = NULL; param->opencl_device_id = NULL;
param->psz_clbin_file = 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 ) void x264_param_default( x264_param_t *param )
...@@ -457,6 +459,7 @@ static int param_apply_preset( x264_param_t *param, const char *preset ) ...@@ -457,6 +459,7 @@ static int param_apply_preset( x264_param_t *param, const char *preset )
param->analyse.i_subpel_refine = 0; param->analyse.i_subpel_refine = 0;
param->rc.i_aq_mode = 0; param->rc.i_aq_mode = 0;
param->analyse.b_mixed_references = 0; param->analyse.b_mixed_references = 0;
param->analyse.i_trellis = 0;
param->i_bframe_adaptive = X264_B_ADAPT_NONE; param->i_bframe_adaptive = X264_B_ADAPT_NONE;
param->rc.b_mb_tree = 0; param->rc.b_mb_tree = 0;
param->analyse.i_weighted_pred = X264_WEIGHTP_NONE; param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
...@@ -559,22 +562,17 @@ static int param_apply_preset( x264_param_t *param, const char *preset ) ...@@ -559,22 +562,17 @@ static int param_apply_preset( x264_param_t *param, const char *preset )
static int param_apply_tune( x264_param_t *param, const char *tune ) static int param_apply_tune( x264_param_t *param, const char *tune )
{ {
char *tmp = x264_malloc( strlen( tune ) + 1 );
if( !tmp )
return -1;
tmp = strcpy( tmp, tune );
char *s = strtok( tmp, ",./-+" );
int psy_tuning_used = 0; int psy_tuning_used = 0;
while( s ) for( int len; tune += strspn( tune, ",./-+" ), (len = strcspn( tune, ",./-+" )); tune += len )
{ {
if( !strncasecmp( s, "film", 4 ) ) if( len == 4 && !strncasecmp( tune, "film", 4 ) )
{ {
if( psy_tuning_used++ ) goto psy_failure; if( psy_tuning_used++ ) goto psy_failure;
param->i_deblocking_filter_alphac0 = -1; param->i_deblocking_filter_alphac0 = -1;
param->i_deblocking_filter_beta = -1; param->i_deblocking_filter_beta = -1;
param->analyse.f_psy_trellis = 0.15; param->analyse.f_psy_trellis = 0.15;
} }
else if( !strncasecmp( s, "animation", 9 ) ) else if( len == 9 && !strncasecmp( tune, "animation", 9 ) )
{ {
if( psy_tuning_used++ ) goto psy_failure; if( psy_tuning_used++ ) goto psy_failure;
param->i_frame_reference = param->i_frame_reference > 1 ? param->i_frame_reference*2 : 1; param->i_frame_reference = param->i_frame_reference > 1 ? param->i_frame_reference*2 : 1;
...@@ -584,7 +582,7 @@ static int param_apply_tune( x264_param_t *param, const char *tune ) ...@@ -584,7 +582,7 @@ static int param_apply_tune( x264_param_t *param, const char *tune )
param->rc.f_aq_strength = 0.6; param->rc.f_aq_strength = 0.6;
param->i_bframe += 2; param->i_bframe += 2;
} }
else if( !strncasecmp( s, "grain", 5 ) ) else if( len == 5 && !strncasecmp( tune, "grain", 5 ) )
{ {
if( psy_tuning_used++ ) goto psy_failure; if( psy_tuning_used++ ) goto psy_failure;
param->i_deblocking_filter_alphac0 = -2; param->i_deblocking_filter_alphac0 = -2;
...@@ -598,7 +596,7 @@ static int param_apply_tune( x264_param_t *param, const char *tune ) ...@@ -598,7 +596,7 @@ static int param_apply_tune( x264_param_t *param, const char *tune )
param->analyse.i_luma_deadzone[1] = 6; param->analyse.i_luma_deadzone[1] = 6;
param->rc.f_qcompress = 0.8; param->rc.f_qcompress = 0.8;
} }
else if( !strncasecmp( s, "stillimage", 10 ) ) else if( len == 10 && !strncasecmp( tune, "stillimage", 10 ) )
{ {
if( psy_tuning_used++ ) goto psy_failure; if( psy_tuning_used++ ) goto psy_failure;
param->i_deblocking_filter_alphac0 = -3; param->i_deblocking_filter_alphac0 = -3;
...@@ -607,26 +605,26 @@ static int param_apply_tune( x264_param_t *param, const char *tune ) ...@@ -607,26 +605,26 @@ static int param_apply_tune( x264_param_t *param, const char *tune )
param->analyse.f_psy_trellis = 0.7; param->analyse.f_psy_trellis = 0.7;
param->rc.f_aq_strength = 1.2; param->rc.f_aq_strength = 1.2;
} }
else if( !strncasecmp( s, "psnr", 4 ) ) else if( len == 4 && !strncasecmp( tune, "psnr", 4 ) )
{ {
if( psy_tuning_used++ ) goto psy_failure; if( psy_tuning_used++ ) goto psy_failure;
param->rc.i_aq_mode = X264_AQ_NONE; param->rc.i_aq_mode = X264_AQ_NONE;
param->analyse.b_psy = 0; param->analyse.b_psy = 0;
} }
else if( !strncasecmp( s, "ssim", 4 ) ) else if( len == 4 && !strncasecmp( tune, "ssim", 4 ) )
{ {
if( psy_tuning_used++ ) goto psy_failure; if( psy_tuning_used++ ) goto psy_failure;
param->rc.i_aq_mode = X264_AQ_AUTOVARIANCE; param->rc.i_aq_mode = X264_AQ_AUTOVARIANCE;
param->analyse.b_psy = 0; param->analyse.b_psy = 0;
} }
else if( !strncasecmp( s, "fastdecode", 10 ) ) else if( len == 10 && !strncasecmp( tune, "fastdecode", 10 ) )
{ {
param->b_deblocking_filter = 0; param->b_deblocking_filter = 0;
param->b_cabac = 0; param->b_cabac = 0;
param->analyse.b_weighted_bipred = 0; param->analyse.b_weighted_bipred = 0;
param->analyse.i_weighted_pred = X264_WEIGHTP_NONE; param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
} }
else if( !strncasecmp( s, "zerolatency", 11 ) ) else if( len == 11 && !strncasecmp( tune, "zerolatency", 11 ) )
{ {
param->rc.i_lookahead = 0; param->rc.i_lookahead = 0;
param->i_sync_lookahead = 0; param->i_sync_lookahead = 0;
...@@ -635,7 +633,7 @@ static int param_apply_tune( x264_param_t *param, const char *tune ) ...@@ -635,7 +633,7 @@ static int param_apply_tune( x264_param_t *param, const char *tune )
param->b_vfr_input = 0; param->b_vfr_input = 0;
param->rc.b_mb_tree = 0; param->rc.b_mb_tree = 0;
} }
else if( !strncasecmp( s, "touhou", 6 ) ) else if( len == 6 && !strncasecmp( tune, "touhou", 6 ) )
{ {
if( psy_tuning_used++ ) goto psy_failure; if( psy_tuning_used++ ) goto psy_failure;
param->i_frame_reference = param->i_frame_reference > 1 ? param->i_frame_reference*2 : 1; param->i_frame_reference = param->i_frame_reference > 1 ? param->i_frame_reference*2 : 1;
...@@ -648,18 +646,12 @@ static int param_apply_tune( x264_param_t *param, const char *tune ) ...@@ -648,18 +646,12 @@ static int param_apply_tune( x264_param_t *param, const char *tune )
} }
else else
{ {
x264_log_internal( X264_LOG_ERROR, "invalid tune '%s'\n", s ); x264_log_internal( X264_LOG_ERROR, "invalid tune '%.*s'\n", len, tune );
x264_free( tmp );
return -1; return -1;
}
if( 0 )
{
psy_failure: psy_failure:
x264_log_internal( X264_LOG_WARNING, "only 1 psy tuning can be used: ignoring tune %s\n", s ); x264_log_internal( X264_LOG_WARNING, "only 1 psy tuning can be used: ignoring tune %.*s\n", len, tune );
} }
s = strtok( NULL, ",./-+" );
} }
x264_free( tmp );
return 0; return 0;
} }
...@@ -749,6 +741,11 @@ static int param_apply_profile( x264_param_t *param, const char *profile ) ...@@ -749,6 +741,11 @@ static int 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 ); x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support a bit depth of %d\n", profile, param->i_bitdepth );
return -1; 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 ) if( p == PROFILE_BASELINE )
{ {
...@@ -950,6 +947,8 @@ static int param_parse( x264_param_t *p, const char *name, const char *value ) ...@@ -950,6 +947,8 @@ static int param_parse( x264_param_t *p, const char *name, const char *value )
p->b_bluray_compat = atobool(value); p->b_bluray_compat = atobool(value);
OPT("avcintra-class") OPT("avcintra-class")
p->i_avcintra_class = atoi(value); p->i_avcintra_class = atoi(value);
OPT("avcintra-flavor")
b_error |= parse_enum( value, x264_avcintra_flavor_names, &p->i_avcintra_flavor );
OPT("sar") OPT("sar")
{ {
b_error = ( 2 != sscanf( value, "%d:%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) && b_error = ( 2 != sscanf( value, "%d:%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) &&
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
# define CHROMA_V_SHIFT h->mb.chroma_v_shift # define CHROMA_V_SHIFT h->mb.chroma_v_shift
#endif #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 FRAME_SIZE(s) ((s)+2*CHROMA_SIZE(s))
#define CHROMA444 (CHROMA_FORMAT == CHROMA_444) #define CHROMA444 (CHROMA_FORMAT == CHROMA_444)
...@@ -767,7 +767,7 @@ typedef struct ...@@ -767,7 +767,7 @@ typedef struct
// included at the end because it needs x264_t // included at the end because it needs x264_t
#include "macroblock.h" #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; int cnt = 0;
for( int i = 0; i < i_mvc; i++ ) for( int i = 0; i < i_mvc; i++ )
...@@ -783,7 +783,7 @@ static int ALWAYS_INLINE x264_predictor_roundclip( int16_t (*dst)[2], int16_t (* ...@@ -783,7 +783,7 @@ static int ALWAYS_INLINE x264_predictor_roundclip( int16_t (*dst)[2], int16_t (*
return cnt; 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 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}; int qpel_limit[4] = {mv_limit[0][0] << 2, mv_limit[0][1] << 2, mv_limit[1][0] << 2, mv_limit[1][1] << 2};
......
...@@ -437,7 +437,7 @@ static void add16x16_idct8( pixel *dst, dctcoef dct[4][64] ) ...@@ -437,7 +437,7 @@ static void add16x16_idct8( pixel *dst, dctcoef dct[4][64] )
add8x8_idct8( &dst[8*FDEC_STRIDE+8], dct[3] ); 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; dc = (dc + 32) >> 6;
for( int i = 0; i < 4; i++, p_dst += FDEC_STRIDE ) for( int i = 0; i < 4; i++, p_dst += FDEC_STRIDE )
...@@ -667,6 +667,7 @@ void x264_dct_init( int cpu, x264_dct_function_t *dctf ) ...@@ -667,6 +667,7 @@ void x264_dct_init( int cpu, x264_dct_function_t *dctf )
dctf->sub16x16_dct = x264_sub16x16_dct_altivec; dctf->sub16x16_dct = x264_sub16x16_dct_altivec;
dctf->add8x8_idct_dc = x264_add8x8_idct_dc_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->add4x4_idct = x264_add4x4_idct_altivec;
dctf->add8x8_idct = x264_add8x8_idct_altivec; dctf->add8x8_idct = x264_add8x8_idct_altivec;
......
...@@ -383,6 +383,7 @@ void x264_frame_deblock_row( x264_t *h, int mb_y ) ...@@ -383,6 +383,7 @@ void x264_frame_deblock_row( x264_t *h, int mb_y )
int qp_thresh = 15 - X264_MIN( a, b ) - X264_MAX( 0, h->pps->i_chroma_qp_index_offset ); int qp_thresh = 15 - X264_MIN( a, b ) - X264_MAX( 0, h->pps->i_chroma_qp_index_offset );
int stridey = h->fdec->i_stride[0]; int stridey = h->fdec->i_stride[0];
int strideuv = h->fdec->i_stride[1]; int strideuv = h->fdec->i_stride[1];
int chroma_format = CHROMA_FORMAT;
int chroma444 = CHROMA444; int chroma444 = CHROMA444;
int chroma_height = 16 >> CHROMA_V_SHIFT; int chroma_height = 16 >> CHROMA_V_SHIFT;
intptr_t uvdiff = chroma444 ? h->fdec->plane[2] - h->fdec->plane[1] : 1; intptr_t uvdiff = chroma444 ? h->fdec->plane[2] - h->fdec->plane[1] : 1;
...@@ -420,7 +421,7 @@ void x264_frame_deblock_row( x264_t *h, int mb_y ) ...@@ -420,7 +421,7 @@ void x264_frame_deblock_row( x264_t *h, int mb_y )
deblock_edge##intra( h, pixy + 4*edge*(dir?stride2y:1),\ deblock_edge##intra( h, pixy + 4*edge*(dir?stride2y:1),\
stride2y, bs[dir][edge], qp, a, b, 0,\ stride2y, bs[dir][edge], qp, a, b, 0,\
h->loopf.deblock_luma##intra[dir] );\ h->loopf.deblock_luma##intra[dir] );\
if( CHROMA_FORMAT == CHROMA_444 )\ if( chroma_format == CHROMA_444 )\
{\ {\
deblock_edge##intra( h, pixuv + 4*edge*(dir?stride2uv:1),\ deblock_edge##intra( h, pixuv + 4*edge*(dir?stride2uv:1),\
stride2uv, bs[dir][edge], chroma_qp, a, b, 0,\ stride2uv, bs[dir][edge], chroma_qp, a, b, 0,\
...@@ -429,14 +430,14 @@ void x264_frame_deblock_row( x264_t *h, int mb_y ) ...@@ -429,14 +430,14 @@ void x264_frame_deblock_row( x264_t *h, int mb_y )
stride2uv, bs[dir][edge], chroma_qp, a, b, 0,\ stride2uv, bs[dir][edge], chroma_qp, a, b, 0,\
h->loopf.deblock_luma##intra[dir] );\ h->loopf.deblock_luma##intra[dir] );\
}\ }\
else if( CHROMA_FORMAT == CHROMA_420 && !(edge & 1) )\ else if( chroma_format == CHROMA_420 && !(edge & 1) )\
{\ {\
deblock_edge##intra( h, pixuv + edge*(dir?2*stride2uv:4),\ deblock_edge##intra( h, pixuv + edge*(dir?2*stride2uv:4),\
stride2uv, bs[dir][edge], chroma_qp, a, b, 1,\ stride2uv, bs[dir][edge], chroma_qp, a, b, 1,\
h->loopf.deblock_chroma##intra[dir] );\ h->loopf.deblock_chroma##intra[dir] );\
}\ }\
}\ }\
if( CHROMA_FORMAT == CHROMA_422 && (dir || !(edge & 1)) )\ if( chroma_format == CHROMA_422 && (dir || !(edge & 1)) )\
{\ {\
deblock_edge##intra( h, pixuv + edge*(dir?4*stride2uv:4),\ deblock_edge##intra( h, pixuv + edge*(dir?4*stride2uv:4),\
stride2uv, bs[dir][edge], chroma_qp, a, b, 1,\ stride2uv, bs[dir][edge], chroma_qp, a, b, 1,\
...@@ -463,16 +464,22 @@ void x264_frame_deblock_row( x264_t *h, int mb_y ) ...@@ -463,16 +464,22 @@ void x264_frame_deblock_row( x264_t *h, int mb_y )
if( intra_cur || IS_INTRA( h->mb.type[h->mb.i_mb_left_xy[0]] ) ) if( intra_cur || IS_INTRA( h->mb.type[h->mb.i_mb_left_xy[0]] ) )
{ {
deblock_edge_intra( h, pixy, 2*stridey, bs[0][0], luma_qp[0], a, b, 0, luma_intra_deblock ); deblock_edge_intra( h, pixy, 2*stridey, bs[0][0], luma_qp[0], a, b, 0, luma_intra_deblock );
deblock_edge_intra( h, pixuv, 2*strideuv, bs[0][0], chroma_qp[0], a, b, c, chroma_intra_deblock ); if( chroma_format )
if( chroma444 ) {
deblock_edge_intra( h, pixuv + uvdiff, 2*strideuv, bs[0][0], chroma_qp[0], a, b, c, chroma_intra_deblock ); deblock_edge_intra( h, pixuv, 2*strideuv, bs[0][0], chroma_qp[0], a, b, c, chroma_intra_deblock );
if( chroma444 )
deblock_edge_intra( h, pixuv + uvdiff, 2*strideuv, bs[0][0], chroma_qp[0], a, b, c, chroma_intra_deblock );
}
} }
else else
{ {
deblock_edge( h, pixy, 2*stridey, bs[0][0], luma_qp[0], a, b, 0, luma_deblock ); deblock_edge( h, pixy, 2*stridey, bs[0][0], luma_qp[0], a, b, 0, luma_deblock );
deblock_edge( h, pixuv, 2*strideuv, bs[0][0], chroma_qp[0], a, b, c, chroma_deblock ); if( chroma_format )
if( chroma444 ) {
deblock_edge( h, pixuv + uvdiff, 2*strideuv, bs[0][0], chroma_qp[0], a, b, c, chroma_deblock ); deblock_edge( h, pixuv, 2*strideuv, bs[0][0], chroma_qp[0], a, b, c, chroma_deblock );
if( chroma444 )
deblock_edge( h, pixuv + uvdiff, 2*strideuv, bs[0][0], chroma_qp[0], a, b, c, chroma_deblock );
}
} }
int offy = MB_INTERLACED ? 4 : 0; int offy = MB_INTERLACED ? 4 : 0;
...@@ -483,16 +490,22 @@ void x264_frame_deblock_row( x264_t *h, int mb_y ) ...@@ -483,16 +490,22 @@ void x264_frame_deblock_row( x264_t *h, int mb_y )
if( intra_cur || IS_INTRA( h->mb.type[h->mb.i_mb_left_xy[1]] ) ) if( intra_cur || IS_INTRA( h->mb.type[h->mb.i_mb_left_xy[1]] ) )
{ {
deblock_edge_intra( h, pixy + (stridey<<offy), 2*stridey, bs[0][4], luma_qp[1], a, b, 0, luma_intra_deblock ); deblock_edge_intra( h, pixy + (stridey<<offy), 2*stridey, bs[0][4], luma_qp[1], a, b, 0, luma_intra_deblock );
deblock_edge_intra( h, pixuv + (strideuv<<offuv), 2*strideuv, bs[0][4], chroma_qp[1], a, b, c, chroma_intra_deblock ); if( chroma_format )
if( chroma444 ) {
deblock_edge_intra( h, pixuv + uvdiff + (strideuv<<offuv), 2*strideuv, bs[0][4], chroma_qp[1], a, b, c, chroma_intra_deblock ); deblock_edge_intra( h, pixuv + (strideuv<<offuv), 2*strideuv, bs[0][4], chroma_qp[1], a, b, c, chroma_intra_deblock );
if( chroma444 )
deblock_edge_intra( h, pixuv + uvdiff + (strideuv<<offuv), 2*strideuv, bs[0][4], chroma_qp[1], a, b, c, chroma_intra_deblock );
}
} }
else else
{ {
deblock_edge( h, pixy + (stridey<<offy), 2*stridey, bs[0][4], luma_qp[1], a, b, 0, luma_deblock ); deblock_edge( h, pixy + (stridey<<offy), 2*stridey, bs[0][4], luma_qp[1], a, b, 0, luma_deblock );
deblock_edge( h, pixuv + (strideuv<<offuv), 2*strideuv, bs[0][4], chroma_qp[1], a, b, c, chroma_deblock ); if( chroma_format )
if( chroma444 ) {
deblock_edge( h, pixuv + uvdiff + (strideuv<<offuv), 2*strideuv, bs[0][4], chroma_qp[1], a, b, c, chroma_deblock ); deblock_edge( h, pixuv + (strideuv<<offuv), 2*strideuv, bs[0][4], chroma_qp[1], a, b, c, chroma_deblock );
if( chroma444 )
deblock_edge( h, pixuv + uvdiff + (strideuv<<offuv), 2*strideuv, bs[0][4], chroma_qp[1], a, b, c, chroma_deblock );
}
} }
} }
else else
...@@ -548,7 +561,7 @@ void x264_frame_deblock_row( x264_t *h, int mb_y ) ...@@ -548,7 +561,7 @@ void x264_frame_deblock_row( x264_t *h, int mb_y )
deblock_edge( h, pixuv + j*strideuv, 2*strideuv, bs[1][4*j], qpc_top, a, b, 0, h->loopf.deblock_luma[1] ); deblock_edge( h, pixuv + j*strideuv, 2*strideuv, bs[1][4*j], qpc_top, a, b, 0, h->loopf.deblock_luma[1] );
deblock_edge( h, pixuv + uvdiff + j*strideuv, 2*strideuv, bs[1][4*j], qpc_top, a, b, 0, h->loopf.deblock_luma[1] ); deblock_edge( h, pixuv + uvdiff + j*strideuv, 2*strideuv, bs[1][4*j], qpc_top, a, b, 0, h->loopf.deblock_luma[1] );
} }
else else if( chroma_format )
deblock_edge( h, pixuv + j*strideuv, 2*strideuv, bs[1][4*j], qpc_top, a, b, 1, h->loopf.deblock_chroma[1] ); deblock_edge( h, pixuv + j*strideuv, 2*strideuv, bs[1][4*j], qpc_top, a, b, 1, h->loopf.deblock_chroma[1] );
} }
} }
......
...@@ -44,29 +44,16 @@ static int align_plane_size( int x, int disalign ) ...@@ -44,29 +44,16 @@ static int align_plane_size( int x, int disalign )
static int frame_internal_csp( int external_csp ) static int frame_internal_csp( int external_csp )
{ {
switch( external_csp & X264_CSP_MASK ) int csp = external_csp & X264_CSP_MASK;
{ if( csp == X264_CSP_I400 )
case X264_CSP_NV12: return X264_CSP_I400;
case X264_CSP_NV21: if( csp >= X264_CSP_I420 && csp < X264_CSP_I422 )
case X264_CSP_I420: return X264_CSP_NV12;
case X264_CSP_YV12: if( csp >= X264_CSP_I422 && csp < X264_CSP_I444 )
return X264_CSP_NV12; return X264_CSP_NV16;
case X264_CSP_NV16: if( csp >= X264_CSP_I444 && csp <= X264_CSP_RGB )
case X264_CSP_I422: return X264_CSP_I444;
case X264_CSP_YV16: return X264_CSP_NONE;
case X264_CSP_YUYV:
case X264_CSP_UYVY:
case X264_CSP_V210:
return X264_CSP_NV16;
case X264_CSP_I444:
case X264_CSP_YV24:
case X264_CSP_BGR:
case X264_CSP_BGRA:
case X264_CSP_RGB:
return X264_CSP_I444;
default:
return X264_CSP_NONE;
}
} }
static x264_frame_t *frame_new( x264_t *h, int b_fdec ) static x264_frame_t *frame_new( x264_t *h, int b_fdec )
...@@ -89,6 +76,9 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec ) ...@@ -89,6 +76,9 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec )
int disalign = 1<<10; int disalign = 1<<10;
#endif #endif
/* ensure frame alignment after PADH is added */
int padh_align = X264_MAX( align - PADH * sizeof(pixel), 0 ) / sizeof(pixel);
CHECKED_MALLOCZERO( frame, sizeof(x264_frame_t) ); CHECKED_MALLOCZERO( frame, sizeof(x264_frame_t) );
PREALLOC_INIT PREALLOC_INIT
...@@ -119,6 +109,14 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec ) ...@@ -119,6 +109,14 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec )
frame->i_stride[i] = i_stride; frame->i_stride[i] = i_stride;
} }
} }
else if( i_csp == X264_CSP_I400 )
{
luma_plane_count = 1;
frame->i_plane = 1;
frame->i_width[0] = i_width;
frame->i_lines[0] = i_lines;
frame->i_stride[0] = i_stride;
}
else else
goto fail; goto fail;
...@@ -154,9 +152,9 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec ) ...@@ -154,9 +152,9 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec )
{ {
int chroma_padv = i_padv >> (i_csp == X264_CSP_NV12); int chroma_padv = i_padv >> (i_csp == X264_CSP_NV12);
int chroma_plane_size = (frame->i_stride[1] * (frame->i_lines[1] + 2*chroma_padv)); int chroma_plane_size = (frame->i_stride[1] * (frame->i_lines[1] + 2*chroma_padv));
PREALLOC( frame->buffer[1], chroma_plane_size * sizeof(pixel) ); PREALLOC( frame->buffer[1], (chroma_plane_size + padh_align) * sizeof(pixel) );
if( PARAM_INTERLACED ) if( PARAM_INTERLACED )
PREALLOC( frame->buffer_fld[1], chroma_plane_size * sizeof(pixel) ); PREALLOC( frame->buffer_fld[1], (chroma_plane_size + padh_align) * sizeof(pixel) );
} }
/* all 4 luma planes allocated together, since the cacheline split code /* all 4 luma planes allocated together, since the cacheline split code
...@@ -166,18 +164,12 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec ) ...@@ -166,18 +164,12 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec )
{ {
int luma_plane_size = align_plane_size( frame->i_stride[p] * (frame->i_lines[p] + 2*i_padv), disalign ); int luma_plane_size = align_plane_size( frame->i_stride[p] * (frame->i_lines[p] + 2*i_padv), disalign );
if( h->param.analyse.i_subpel_refine && b_fdec ) if( h->param.analyse.i_subpel_refine && b_fdec )
{ luma_plane_size *= 4;
/* FIXME: Don't allocate both buffers in non-adaptive MBAFF. */
PREALLOC( frame->buffer[p], 4*luma_plane_size * sizeof(pixel) ); /* FIXME: Don't allocate both buffers in non-adaptive MBAFF. */
if( PARAM_INTERLACED ) PREALLOC( frame->buffer[p], (luma_plane_size + padh_align) * sizeof(pixel) );
PREALLOC( frame->buffer_fld[p], 4*luma_plane_size * sizeof(pixel) ); if( PARAM_INTERLACED )
} PREALLOC( frame->buffer_fld[p], (luma_plane_size + padh_align) * sizeof(pixel) );
else
{
PREALLOC( frame->buffer[p], luma_plane_size * sizeof(pixel) );
if( PARAM_INTERLACED )
PREALLOC( frame->buffer_fld[p], luma_plane_size * sizeof(pixel) );
}
} }
frame->b_duplicate = 0; frame->b_duplicate = 0;
...@@ -215,7 +207,7 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec ) ...@@ -215,7 +207,7 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec )
{ {
int luma_plane_size = align_plane_size( frame->i_stride_lowres * (frame->i_lines[0]/2 + 2*PADV), disalign ); int luma_plane_size = align_plane_size( frame->i_stride_lowres * (frame->i_lines[0]/2 + 2*PADV), disalign );
PREALLOC( frame->buffer_lowres[0], 4 * luma_plane_size * sizeof(pixel) ); PREALLOC( frame->buffer_lowres, (4 * luma_plane_size + padh_align) * sizeof(pixel) );
for( int j = 0; j <= !!h->param.i_bframe; j++ ) for( int j = 0; j <= !!h->param.i_bframe; j++ )
for( int i = 0; i <= h->param.i_bframe; i++ ) for( int i = 0; i <= h->param.i_bframe; i++ )
...@@ -245,9 +237,9 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec ) ...@@ -245,9 +237,9 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec )
if( i_csp == X264_CSP_NV12 || i_csp == X264_CSP_NV16 ) if( i_csp == X264_CSP_NV12 || i_csp == X264_CSP_NV16 )
{ {
int chroma_padv = i_padv >> (i_csp == X264_CSP_NV12); int chroma_padv = i_padv >> (i_csp == X264_CSP_NV12);
frame->plane[1] = frame->buffer[1] + frame->i_stride[1] * chroma_padv + PADH; frame->plane[1] = frame->buffer[1] + frame->i_stride[1] * chroma_padv + PADH + padh_align;
if( PARAM_INTERLACED ) if( PARAM_INTERLACED )
frame->plane_fld[1] = frame->buffer_fld[1] + frame->i_stride[1] * chroma_padv + PADH; frame->plane_fld[1] = frame->buffer_fld[1] + frame->i_stride[1] * chroma_padv + PADH + padh_align;
} }
for( int p = 0; p < luma_plane_count; p++ ) for( int p = 0; p < luma_plane_count; p++ )
...@@ -257,16 +249,16 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec ) ...@@ -257,16 +249,16 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec )
{ {
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
frame->filtered[p][i] = frame->buffer[p] + i*luma_plane_size + frame->i_stride[p] * i_padv + PADH; frame->filtered[p][i] = frame->buffer[p] + i*luma_plane_size + frame->i_stride[p] * i_padv + PADH + padh_align;
frame->filtered_fld[p][i] = frame->buffer_fld[p] + i*luma_plane_size + frame->i_stride[p] * i_padv + PADH; frame->filtered_fld[p][i] = frame->buffer_fld[p] + i*luma_plane_size + frame->i_stride[p] * i_padv + PADH + padh_align;
} }
frame->plane[p] = frame->filtered[p][0]; frame->plane[p] = frame->filtered[p][0];
frame->plane_fld[p] = frame->filtered_fld[p][0]; frame->plane_fld[p] = frame->filtered_fld[p][0];
} }
else else
{ {
frame->filtered[p][0] = frame->plane[p] = frame->buffer[p] + frame->i_stride[p] * i_padv + PADH; frame->filtered[p][0] = frame->plane[p] = frame->buffer[p] + frame->i_stride[p] * i_padv + PADH + padh_align;
frame->filtered_fld[p][0] = frame->plane_fld[p] = frame->buffer_fld[p] + frame->i_stride[p] * i_padv + PADH; frame->filtered_fld[p][0] = frame->plane_fld[p] = frame->buffer_fld[p] + frame->i_stride[p] * i_padv + PADH + padh_align;
} }
} }
...@@ -284,7 +276,7 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec ) ...@@ -284,7 +276,7 @@ static x264_frame_t *frame_new( x264_t *h, int b_fdec )
{ {
int luma_plane_size = align_plane_size( frame->i_stride_lowres * (frame->i_lines[0]/2 + 2*PADV), disalign ); int luma_plane_size = align_plane_size( frame->i_stride_lowres * (frame->i_lines[0]/2 + 2*PADV), disalign );
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
frame->lowres[i] = frame->buffer_lowres[0] + (frame->i_stride_lowres * PADV + PADH) + i * luma_plane_size; frame->lowres[i] = frame->buffer_lowres + frame->i_stride_lowres * PADV + PADH + padh_align + i * luma_plane_size;
for( int j = 0; j <= !!h->param.i_bframe; j++ ) for( int j = 0; j <= !!h->param.i_bframe; j++ )
for( int i = 0; i <= h->param.i_bframe; i++ ) for( int i = 0; i <= h->param.i_bframe; i++ )
...@@ -470,7 +462,7 @@ int x264_frame_copy_picture( x264_t *h, x264_frame_t *dst, x264_picture_t *src ) ...@@ -470,7 +462,7 @@ int x264_frame_copy_picture( x264_t *h, x264_frame_t *dst, x264_picture_t *src )
(pixel*)pix[2], stride[2]/sizeof(pixel), (pixel*)pix[2], stride[2]/sizeof(pixel),
h->param.i_width>>1, h->param.i_height>>v_shift ); h->param.i_width>>1, h->param.i_height>>v_shift );
} }
else //if( i_csp == X264_CSP_I444 || i_csp == X264_CSP_YV24 ) else if( i_csp == X264_CSP_I444 || i_csp == X264_CSP_YV24 )