add binfolder path relative filters, fix gbrp color model, vwdw timebar tweaks, title...
[goodguy/history.git] / cinelerra-5.1 / mpeg2enc / motion.c
index 2ff48d931df5e9ab11f0736b5328f1f3ddaacdd3..995597af73aff6c439a8f2e12c2ae6849caf2cd0 100644 (file)
@@ -30,6 +30,7 @@
 #include <limits.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include "config.h"
 #include "global.h"
 #include "cpu_accel.h"
@@ -107,7 +108,7 @@ static void field_estimate (motion_engine_t *engine,
                                                        mb_motion_s *best8u,
                                                        mb_motion_s *best8l,
                                                        mb_motion_s *bestsp);
-
+#if 0
 static void dpframe_estimate (motion_engine_t *engine,
        pict_data_s *picture,
        uint8_t *ref,
@@ -126,7 +127,7 @@ static void dpfield_estimate (motion_engine_t *engine,
        int imins, int jmins, 
        mb_motion_s *dpbest,
        int *vmcp);
-
+#endif
 static void fullsearch (motion_engine_t *engine, 
        uint8_t *org, uint8_t *ref,
        subsampled_mb_s *ssblk,
@@ -630,7 +631,7 @@ static void field_estimate (motion_engine_t *engine,
                *best8l = botfld_mc;
        }
 }
-
+#if 0
 static void dpframe_estimate (motion_engine_t *engine,
        pict_data_s *picture,
        uint8_t *ref,
@@ -810,7 +811,7 @@ static void dpfield_estimate(motion_engine_t *engine,
 {
        uint8_t *sameref, *oppref;
        int io0,jo0,io,jo,delta_x,delta_y,mvxs,mvys,mvxo0,mvyo0;
-       int imino,jmino,imindmv,jmindmv,vmc_dp,local_dist;
+       int imino,jmino,imindmv,vmc_dp,local_dist;
 
        /* Calculate Dual Prime distortions for 9 delta candidates */
        /* Note: only for P pictures! */
@@ -876,7 +877,6 @@ static void dpfield_estimate(motion_engine_t *engine,
                                        imino = io;
                                        jmino = jo;
                                        imindmv = delta_x;
-                                       jmindmv = delta_y;
                                        vmc_dp = local_dist;
                                }
                        }
@@ -897,7 +897,7 @@ static void dpfield_estimate(motion_engine_t *engine,
        bestdp_mc->pos.x = imindmv;
        *vmcp = vmc_dp;
 }
-
+#endif
 
 /* 
  *   Vectors of motion compensations 
@@ -915,7 +915,6 @@ static void sub_mean_reduction( mc_result_s *matches, int len,
        int i,j;
        int weight_sum;
        int mean_weight;
-       int min_weight = 100000;
        if( len == 0 )
        {
                *minweight_res = 100000;
@@ -938,10 +937,6 @@ static void sub_mean_reduction( mc_result_s *matches, int len,
                {
                        if( matches[i].weight <= mean_weight )
                        {
-                               if( times == 1)
-                               {
-                                       min_weight = matches[i].weight ;
-                               }
                                matches[j] = matches[i];
                                ++j;
                        }
@@ -1228,12 +1223,8 @@ static void find_best_one_pel(motion_engine_t *engine,
        int dmin = INT_MAX;
        uint8_t *orgblk;
        int penalty;
-       int init_search;
-       int init_size;
        blockxy matchrec;
  
-       init_search = searched_size;
-       init_size = engine->sub22_num_mcomps;
        for( k = 0; k < searched_size; ++k )
        {       
                matchrec.x = i0 + engine->sub22_mcomps[k].x;
@@ -1291,14 +1282,10 @@ void find_best_one_pel_mmxe(motion_engine_t *engine,
        int dmin = INT_MAX;
        uint8_t *orgblk;
        int penalty;
-       int init_search;
-       int init_size;
        blockxy matchrec;
        int resvec[4];
 
  
-       init_search = searched_size;
-       init_size = engine->sub22_num_mcomps;
        for( k = 0; k < searched_size; ++k )
        {       
                matchrec.x = i0 + engine->sub22_mcomps[k].x;
@@ -1694,10 +1681,10 @@ void fast_motion_data(uint8_t *blk, int picture_struct )
        uint8_t *pb;
        uint8_t *qb;
        uint8_t *start_s22blk, *start_s44blk;
-       uint16_t *start_rowblk, *start_colblk;
        int i;
        int nextfieldline;
 #ifdef TEST_RCSEARCH
+       uint16_t *start_rowblk, *start_colblk;
        uint16_t *pc, *pr,*p;
        int rowsum;
        int j,s;
@@ -1705,6 +1692,8 @@ void fast_motion_data(uint8_t *blk, int picture_struct )
        uint16_t sums[32];
        uint16_t rowsums[2048];
        uint16_t colsums[2048];  /* TODO: BUG: should resize with width */
+       start_rowblk = (uint16_t *)blk+rowsums_offset;
+       start_colblk = (uint16_t *)blk+colsums_offset;
 #endif 
   
 
@@ -1722,8 +1711,6 @@ void fast_motion_data(uint8_t *blk, int picture_struct )
 
        start_s22blk   = blk+fsubsample_offset;
        start_s44blk   = blk+qsubsample_offset;
-       start_rowblk = (uint16_t *)blk+rowsums_offset;
-       start_colblk = (uint16_t *)blk+colsums_offset;
        b = blk;
        nb = (blk+nextfieldline);
        /* Sneaky stuff here... we can do lines in both fields at once */
@@ -2227,7 +2214,11 @@ static void frame_ME(motion_engine_t *engine,
        int vmcfieldf,vmcfieldr,vmcfieldi;
        subsampled_mb_s ssmb;
        int imins[2][2],jmins[2][2];
-       int imindmv,jmindmv,vmc_dp;
+//     int vmc_dp;
+       int imindmv,jmindmv;
+       imindmv = 0;  jmindmv = 0;
+       memset(&dualpf_mc,0,sizeof(dualpf_mc));
+
 //printf("frame_ME 1\n");
 
 
@@ -2621,11 +2612,12 @@ static void field_ME(motion_engine_t *engine,
        mb_motion_s fieldf_mc, fieldb_mc;
        mb_motion_s field8uf_mc, field8lf_mc;
        mb_motion_s field8ub_mc, field8lb_mc;
-       int var,vmc,v0,dmc,dmcfieldi,dmcfield,dmcfieldf,dmcfieldr,dmc8i;
+       int var,vmc,v0,dmcfieldi,dmcfield,dmcfieldf,dmcfieldr,dmc8i;
        int imins,jmins;
        int dmc8f,dmc8r;
-       int vmc_dp,dmc_dp;
-
+//     int vmc_dp,dmc_dp,dmc;
+       imins = 0;  jmins = 0;
+       memset(&dualp_mc,0,sizeof(dualp_mc));
        w2 = width<<1;
 
        /* Fast motion data sits at the end of the luminance buffer */