* /author Zachary Drew, Copyright 2005
*
* Currently only uses Gamma data for comparisonon (bug or feature?)
- * Vector optimization coming soon.
+ * SSE optimized where available.
*
* Vector orientation: The vector data that is generated for the current frame specifies
* the motion from the previous frame to the current frame. To know how a macroblock
#include <sys/time.h>
#include <unistd.h>
+#ifndef __DARWIN__
#include "sad_sse.h"
+#endif
#define NDEBUG
#include <assert.h>
#define ABS(a) ((a) >= 0 ? (a) : (-(a)))
-typedef struct motion_vector_s motion_vector;
-
struct motion_est_context_s
{
int initialized; // true if filter has been initialized
/** /brief Reference Sum of Absolute Differences comparison function
*
*/
-inline static int sad_reference( uint8_t *block1, uint8_t *block2, const int xstride, const int ystride, const int w, const int h )
+static int sad_reference( uint8_t *block1, uint8_t *block2, const int xstride, const int ystride, const int w, const int h )
{
int i, j, score = 0;
for ( j = 0; j < h; j++ ){
// Keep track of best and former best candidates
motion_vector best, former;
+ best.dx = 0;
+ best.dy = 0;
+ former.dx = 0;
+ former.dy = 0;
// The direction of the refinement needs to be known
motion_vector current;
} /* End column loop */
} /* End row loop */
+#ifndef __DARWIN__
asm volatile ( "emms" );
+#endif
#ifdef COUNT_COMPARES
fprintf(stderr, "%d comparisons per block were made", compares/count);
static void init_optimizations( struct motion_est_context_s *c )
{
switch(c->mb_w){
+#ifndef __DARWIN__
case 4: if(c->mb_h == 4) c->compare_optimized = sad_sse_422_luma_4x4;
else c->compare_optimized = sad_sse_422_luma_4w;
break;
break;
case 64: c->compare_optimized = sad_sse_422_luma_64w;
break;
+#endif
default: c->compare_optimized = sad_reference;
break;
}
mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.macroblock_width", c->mb_w );
mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.macroblock_height", c->mb_h );
+ mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.left_mb", c->left_mb );
+ mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.right_mb", c->right_mb );
+ mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.top_mb", c->top_mb );
+ mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.bottom_mb", c->bottom_mb );
#ifdef BENCHMARK
struct timeval finish; gettimeofday(&finish, NULL ); int difference = (finish.tv_sec - start.tv_sec) * 1000000 + (finish.tv_usec - start.tv_usec);
/** Constructor for the filter.
*/
-mlt_filter filter_motion_est_init( char *arg )
+mlt_filter filter_motion_est_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
mlt_filter this = mlt_filter_new( );
if ( this != NULL )