From: Loren Merritt Date: Fri, 6 Jul 2007 17:08:26 +0000 (+0000) Subject: cosmetics X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=d5ddf40b1ae1c267ea3f9e998d6ac1e3a4004e07;p=x264.git cosmetics git-svn-id: svn://svn.videolan.org/x264/trunk@664 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/common/common.h b/common/common.h index 0d6e8310..0b8f8f79 100644 --- a/common/common.h +++ b/common/common.h @@ -121,7 +121,10 @@ #define X264_THREAD_MAX 128 #define X264_SLICE_MAX 4 #define X264_NAL_MAX (4 + X264_SLICE_MAX) -#define X264_THREAD_HEIGHT 24 // number of pixels (per thread) in progress at any given time. could theoretically be as low as 22 + +// number of pixels (per thread) in progress at any given time. +// 16 for the macroblock in progress + 3 for deblocking + 3 for motion compensation filter + 2 for extra safety +#define X264_THREAD_HEIGHT 24 /**************************************************************************** * Includes @@ -142,9 +145,7 @@ * Generals functions ****************************************************************************/ /* x264_malloc : will do or emulate a memalign - * XXX you HAVE TO use x264_free for buffer allocated - * with x264_malloc - */ + * you have to use x264_free for buffers allocated with x264_malloc */ void *x264_malloc( int ); void *x264_realloc( void *p, int i_size ); void x264_free( void * ); @@ -332,10 +333,13 @@ struct x264_t x264_pps_t *pps; int i_idr_pic_id; + /* quantization matrix for decoding, [cqm][qp%6][coef_y][coef_x] */ int (*dequant4_mf[4])[4][4]; /* [4][6][4][4] */ int (*dequant8_mf[2])[8][8]; /* [2][6][8][8] */ + /* quantization matrix for trellis, [cqm][qp][coef] */ int (*unquant4_mf[4])[16]; /* [4][52][16] */ int (*unquant8_mf[2])[64]; /* [2][52][64] */ + /* quantization matrix for deadzone */ uint16_t (*quant4_mf[4])[16]; /* [4][52][16] */ uint16_t (*quant8_mf[2])[64]; /* [2][52][64] */ uint16_t (*quant4_bias[4])[16]; /* [4][52][16] */ diff --git a/common/cpu.c b/common/cpu.c index 9640e10f..1668a6fa 100644 --- a/common/cpu.c +++ b/common/cpu.c @@ -37,7 +37,7 @@ #include "common.h" -#if ( defined(ARCH_X86) || defined(ARCH_X86_64) ) && defined(HAVE_MMX) +#ifdef HAVE_MMX extern int x264_cpu_cpuid_test( void ); extern uint32_t x264_cpu_cpuid( uint32_t op, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx ); extern void x264_emms( void ); diff --git a/common/i386/mc-c.c b/common/i386/mc-c.c index 207c0c67..f025a50d 100644 --- a/common/i386/mc-c.c +++ b/common/i386/mc-c.c @@ -91,7 +91,7 @@ static const int hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; void mc_luma_mmx( uint8_t *src[4], int i_src_stride, uint8_t *dst, int i_dst_stride, - int mvx,int mvy, + int mvx, int mvy, int i_width, int i_height ) { int qpel_idx = ((mvy&3)<<2) + (mvx&3); @@ -114,7 +114,7 @@ void mc_luma_mmx( uint8_t *src[4], int i_src_stride, uint8_t *get_ref_mmx( uint8_t *src[4], int i_src_stride, uint8_t *dst, int *i_dst_stride, - int mvx,int mvy, + int mvx, int mvy, int i_width, int i_height ) { int qpel_idx = ((mvy&3)<<2) + (mvx&3); @@ -128,7 +128,6 @@ uint8_t *get_ref_mmx( uint8_t *src[4], int i_src_stride, dst, *i_dst_stride, src1, i_src_stride, src2, i_src_stride, i_height ); return dst; - } else { diff --git a/common/mc.c b/common/mc.c index 5227ecae..9a498caa 100644 --- a/common/mc.c +++ b/common/mc.c @@ -228,7 +228,7 @@ static const int hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; static void mc_luma( uint8_t *src[4], int i_src_stride, uint8_t *dst, int i_dst_stride, - int mvx,int mvy, + int mvx, int mvy, int i_width, int i_height ) { int qpel_idx = ((mvy&3)<<2) + (mvx&3); @@ -238,7 +238,6 @@ static void mc_luma( uint8_t *src[4], int i_src_stride, if( qpel_idx & 5 ) /* qpel interpolation needed */ { uint8_t *src2 = src[hpel_ref1[qpel_idx]] + offset + ((mvx&3) == 3); - pixel_avg( dst, i_dst_stride, src1, i_src_stride, src2, i_src_stride, i_width, i_height ); } @@ -249,8 +248,8 @@ static void mc_luma( uint8_t *src[4], int i_src_stride, } static uint8_t *get_ref( uint8_t *src[4], int i_src_stride, - uint8_t *dst, int * i_dst_stride, - int mvx,int mvy, + uint8_t *dst, int *i_dst_stride, + int mvx, int mvy, int i_width, int i_height ) { int qpel_idx = ((mvy&3)<<2) + (mvx&3); @@ -260,10 +259,8 @@ static uint8_t *get_ref( uint8_t *src[4], int i_src_stride, if( qpel_idx & 5 ) /* qpel interpolation needed */ { uint8_t *src2 = src[hpel_ref1[qpel_idx]] + offset + ((mvx&3) == 3); - pixel_avg( dst, *i_dst_stride, src1, i_src_stride, src2, i_src_stride, i_width, i_height ); - return dst; } else diff --git a/configure b/configure index 8b833e34..1d1aeb7c 100755 --- a/configure +++ b/configure @@ -332,7 +332,7 @@ if test "$pthread" = "auto" ; then libpthread="-lpthreadGC2" elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then pthread="yes" - libpthread="-lpthreadGC2 -lwsock32"\ + libpthread="-lpthreadGC2 -lwsock32" CFLAGS="$CFLAGS -DPTW32_STATIC_LIB" fi ;; diff --git a/encoder/me.c b/encoder/me.c index a901326d..ffd18140 100644 --- a/encoder/me.c +++ b/encoder/me.c @@ -55,7 +55,7 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite COPY3_IF_LT( bcost, cost, bmx, mx, bmy, my );\ } -#define COST_MV_PRED( mx, my ) \ +#define COST_MV_HPEL( mx, my ) \ { \ int stride = 16; \ uint8_t *src = h->mc.get_ref( m->p_fref, m->i_stride[0], pix, &stride, mx, my, bw, bh ); \ @@ -184,13 +184,13 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int (*mvc)[2], int i_mvc, int /* try extra predictors if provided */ if( h->mb.i_subpel_refine >= 3 ) { - COST_MV_PRED( bmx, bmy ); + COST_MV_HPEL( bmx, bmy ); for( i = 0; i < i_mvc; i++ ) { const int mx = x264_clip3( mvc[i][0], mv_x_min*4, mv_x_max*4 ); const int my = x264_clip3( mvc[i][1], mv_y_min*4, mv_y_max*4 ); if( mx != bpred_mx || my != bpred_my ) - COST_MV_PRED( mx, my ); + COST_MV_HPEL( mx, my ); } bmx = ( bpred_mx + 2 ) >> 2; bmy = ( bpred_my + 2 ) >> 2; diff --git a/muxers.c b/muxers.c index f9d0b3db..6a7f76e2 100644 --- a/muxers.c +++ b/muxers.c @@ -43,6 +43,18 @@ #include #endif +static int64_t gcd( int64_t a, int64_t b ) +{ + while (1) + { + int64_t c = a % b; + if( !c ) + return b; + a = b; + b = c; + } +} + typedef struct { FILE *fh; int width, height; @@ -322,20 +334,6 @@ typedef struct { int width, height; } avis_input_t; -int gcd(int a, int b) -{ - int c; - - while (1) - { - c = a % b; - if (!c) - return b; - a = b; - b = c; - } -} - int open_file_avis( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param ) { avis_input_t *h = malloc(sizeof(avis_input_t)); @@ -899,19 +897,9 @@ int set_param_mkv( hnd_t handle, x264_param_t *p_param ) if( dw > 0 && dh > 0 ) { - int64_t a = dw, b = dh; - - for (;;) - { - int64_t c = a % b; - if( c == 0 ) - break; - a = b; - b = c; - } - - dw /= b; - dh /= b; + int64_t x = gcd( dw, dh ); + dw /= x; + dh /= x; } p_mkv->d_width = (int)dw; diff --git a/x264.c b/x264.c index 5fb6dc96..d864b513 100644 --- a/x264.c +++ b/x264.c @@ -711,7 +711,7 @@ static void parse_qpfile( cli_opt_t *opt, x264_picture_t *pic, int i_frame ) } /***************************************************************************** - * Decode: + * Encode: *****************************************************************************/ static int Encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic ) @@ -747,9 +747,6 @@ static int Encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic ) return i_file; } -/***************************************************************************** - * Encode: - *****************************************************************************/ static int Encode( x264_param_t *param, cli_opt_t *opt ) { x264_t *h;