#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
* 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 * );
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] */
#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 );
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);
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);
dst, *i_dst_stride, src1, i_src_stride,
src2, i_src_stride, i_height );
return dst;
-
}
else
{
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);
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 );
}
}
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);
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
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
;;
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 ); \
/* 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;
#include <gpac/isomedia.h>
#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;
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));
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;
}
/*****************************************************************************
- * Decode:
+ * Encode:
*****************************************************************************/
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;