Commit d5ddf40b authored by Loren Merritt's avatar Loren Merritt

cosmetics


git-svn-id: svn://svn.videolan.org/x264/trunk@664 df754926-b1dd-0310-bc7b-ec298dee348c
parent ee62378f
...@@ -121,7 +121,10 @@ ...@@ -121,7 +121,10 @@
#define X264_THREAD_MAX 128 #define X264_THREAD_MAX 128
#define X264_SLICE_MAX 4 #define X264_SLICE_MAX 4
#define X264_NAL_MAX (4 + X264_SLICE_MAX) #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 * Includes
...@@ -142,9 +145,7 @@ ...@@ -142,9 +145,7 @@
* Generals functions * Generals functions
****************************************************************************/ ****************************************************************************/
/* x264_malloc : will do or emulate a memalign /* x264_malloc : will do or emulate a memalign
* XXX you HAVE TO use x264_free for buffer allocated * you have to use x264_free for buffers allocated with x264_malloc */
* with x264_malloc
*/
void *x264_malloc( int ); void *x264_malloc( int );
void *x264_realloc( void *p, int i_size ); void *x264_realloc( void *p, int i_size );
void x264_free( void * ); void x264_free( void * );
...@@ -332,10 +333,13 @@ struct x264_t ...@@ -332,10 +333,13 @@ struct x264_t
x264_pps_t *pps; x264_pps_t *pps;
int i_idr_pic_id; 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 (*dequant4_mf[4])[4][4]; /* [4][6][4][4] */
int (*dequant8_mf[2])[8][8]; /* [2][6][8][8] */ 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 (*unquant4_mf[4])[16]; /* [4][52][16] */
int (*unquant8_mf[2])[64]; /* [2][52][64] */ int (*unquant8_mf[2])[64]; /* [2][52][64] */
/* quantization matrix for deadzone */
uint16_t (*quant4_mf[4])[16]; /* [4][52][16] */ uint16_t (*quant4_mf[4])[16]; /* [4][52][16] */
uint16_t (*quant8_mf[2])[64]; /* [2][52][64] */ uint16_t (*quant8_mf[2])[64]; /* [2][52][64] */
uint16_t (*quant4_bias[4])[16]; /* [4][52][16] */ uint16_t (*quant4_bias[4])[16]; /* [4][52][16] */
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "common.h" #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 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 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 ); extern void x264_emms( void );
......
...@@ -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}; ...@@ -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, void mc_luma_mmx( uint8_t *src[4], int i_src_stride,
uint8_t *dst, int i_dst_stride, uint8_t *dst, int i_dst_stride,
int mvx,int mvy, int mvx, int mvy,
int i_width, int i_height ) int i_width, int i_height )
{ {
int qpel_idx = ((mvy&3)<<2) + (mvx&3); int qpel_idx = ((mvy&3)<<2) + (mvx&3);
...@@ -114,7 +114,7 @@ void mc_luma_mmx( uint8_t *src[4], int i_src_stride, ...@@ -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 *get_ref_mmx( uint8_t *src[4], int i_src_stride,
uint8_t *dst, int *i_dst_stride, uint8_t *dst, int *i_dst_stride,
int mvx,int mvy, int mvx, int mvy,
int i_width, int i_height ) int i_width, int i_height )
{ {
int qpel_idx = ((mvy&3)<<2) + (mvx&3); 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, ...@@ -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, dst, *i_dst_stride, src1, i_src_stride,
src2, i_src_stride, i_height ); src2, i_src_stride, i_height );
return dst; return dst;
} }
else else
{ {
......
...@@ -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}; ...@@ -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, static void mc_luma( uint8_t *src[4], int i_src_stride,
uint8_t *dst, int i_dst_stride, uint8_t *dst, int i_dst_stride,
int mvx,int mvy, int mvx, int mvy,
int i_width, int i_height ) int i_width, int i_height )
{ {
int qpel_idx = ((mvy&3)<<2) + (mvx&3); int qpel_idx = ((mvy&3)<<2) + (mvx&3);
...@@ -238,7 +238,6 @@ static void mc_luma( uint8_t *src[4], int i_src_stride, ...@@ -238,7 +238,6 @@ static void mc_luma( uint8_t *src[4], int i_src_stride,
if( qpel_idx & 5 ) /* qpel interpolation needed */ if( qpel_idx & 5 ) /* qpel interpolation needed */
{ {
uint8_t *src2 = src[hpel_ref1[qpel_idx]] + offset + ((mvx&3) == 3); uint8_t *src2 = src[hpel_ref1[qpel_idx]] + offset + ((mvx&3) == 3);
pixel_avg( dst, i_dst_stride, src1, i_src_stride, pixel_avg( dst, i_dst_stride, src1, i_src_stride,
src2, i_src_stride, i_width, i_height ); src2, i_src_stride, i_width, i_height );
} }
...@@ -249,8 +248,8 @@ static void mc_luma( uint8_t *src[4], int i_src_stride, ...@@ -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, static uint8_t *get_ref( uint8_t *src[4], int i_src_stride,
uint8_t *dst, int * i_dst_stride, uint8_t *dst, int *i_dst_stride,
int mvx,int mvy, int mvx, int mvy,
int i_width, int i_height ) int i_width, int i_height )
{ {
int qpel_idx = ((mvy&3)<<2) + (mvx&3); 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, ...@@ -260,10 +259,8 @@ static uint8_t *get_ref( uint8_t *src[4], int i_src_stride,
if( qpel_idx & 5 ) /* qpel interpolation needed */ if( qpel_idx & 5 ) /* qpel interpolation needed */
{ {
uint8_t *src2 = src[hpel_ref1[qpel_idx]] + offset + ((mvx&3) == 3); uint8_t *src2 = src[hpel_ref1[qpel_idx]] + offset + ((mvx&3) == 3);
pixel_avg( dst, *i_dst_stride, src1, i_src_stride, pixel_avg( dst, *i_dst_stride, src1, i_src_stride,
src2, i_src_stride, i_width, i_height ); src2, i_src_stride, i_width, i_height );
return dst; return dst;
} }
else else
......
...@@ -332,7 +332,7 @@ if test "$pthread" = "auto" ; then ...@@ -332,7 +332,7 @@ if test "$pthread" = "auto" ; then
libpthread="-lpthreadGC2" libpthread="-lpthreadGC2"
elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
pthread="yes" pthread="yes"
libpthread="-lpthreadGC2 -lwsock32"\ libpthread="-lpthreadGC2 -lwsock32"
CFLAGS="$CFLAGS -DPTW32_STATIC_LIB" CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
fi fi
;; ;;
......
...@@ -55,7 +55,7 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite ...@@ -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 );\ COPY3_IF_LT( bcost, cost, bmx, mx, bmy, my );\
} }
#define COST_MV_PRED( mx, my ) \ #define COST_MV_HPEL( mx, my ) \
{ \ { \
int stride = 16; \ int stride = 16; \
uint8_t *src = h->mc.get_ref( m->p_fref, m->i_stride[0], pix, &stride, mx, my, bw, bh ); \ 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 ...@@ -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 */ /* try extra predictors if provided */
if( h->mb.i_subpel_refine >= 3 ) if( h->mb.i_subpel_refine >= 3 )
{ {
COST_MV_PRED( bmx, bmy ); COST_MV_HPEL( bmx, bmy );
for( i = 0; i < i_mvc; i++ ) 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 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 ); const int my = x264_clip3( mvc[i][1], mv_y_min*4, mv_y_max*4 );
if( mx != bpred_mx || my != bpred_my ) if( mx != bpred_mx || my != bpred_my )
COST_MV_PRED( mx, my ); COST_MV_HPEL( mx, my );
} }
bmx = ( bpred_mx + 2 ) >> 2; bmx = ( bpred_mx + 2 ) >> 2;
bmy = ( bpred_my + 2 ) >> 2; bmy = ( bpred_my + 2 ) >> 2;
......
...@@ -43,6 +43,18 @@ ...@@ -43,6 +43,18 @@
#include <gpac/isomedia.h> #include <gpac/isomedia.h>
#endif #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 { typedef struct {
FILE *fh; FILE *fh;
int width, height; int width, height;
...@@ -322,20 +334,6 @@ typedef struct { ...@@ -322,20 +334,6 @@ typedef struct {
int width, height; int width, height;
} avis_input_t; } 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 ) 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)); 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 ) ...@@ -899,19 +897,9 @@ int set_param_mkv( hnd_t handle, x264_param_t *p_param )
if( dw > 0 && dh > 0 ) if( dw > 0 && dh > 0 )
{ {
int64_t a = dw, b = dh; int64_t x = gcd( dw, dh );
dw /= x;
for (;;) dh /= x;
{
int64_t c = a % b;
if( c == 0 )
break;
a = b;
b = c;
}
dw /= b;
dh /= b;
} }
p_mkv->d_width = (int)dw; p_mkv->d_width = (int)dw;
......
...@@ -711,7 +711,7 @@ static void parse_qpfile( cli_opt_t *opt, x264_picture_t *pic, int i_frame ) ...@@ -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 ) 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 ) ...@@ -747,9 +747,6 @@ static int Encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic )
return i_file; return i_file;
} }
/*****************************************************************************
* Encode:
*****************************************************************************/
static int Encode( x264_param_t *param, cli_opt_t *opt ) static int Encode( x264_param_t *param, cli_opt_t *opt )
{ {
x264_t *h; x264_t *h;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment