changeset 1162:8c15d82c1893 libavcodec

some static -> dynamic alloc & 16->8 bit
author michaelni
date Mon, 31 Mar 2003 11:13:14 +0000
parents 556b5d0b5228
children 0951691c4225
files h263.c motion_est.c motion_est_template.c mpeg12.c mpegvideo.c mpegvideo.h
diffstat 6 files changed, 32 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/h263.c	Mon Mar 31 01:49:18 2003 +0000
+++ b/h263.c	Mon Mar 31 11:13:14 2003 +0000
@@ -87,7 +87,7 @@
 static uint16_t uni_DCtab_lum_bits[512];
 static uint16_t uni_DCtab_chrom_bits[512];
 
-static uint16_t (*mv_penalty)[MAX_MV*2+1]= NULL;
+static uint8_t (*mv_penalty)[MAX_MV*2+1]= NULL;
 static uint8_t fcode_tab[MAX_MV*2+1];
 static uint8_t umv_fcode_tab[MAX_MV*2+1];
 
@@ -1255,7 +1255,7 @@
     int mv;
     
     if(mv_penalty==NULL)
-        mv_penalty= av_mallocz( sizeof(uint16_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
+        mv_penalty= av_mallocz( sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
     
     for(f_code=1; f_code<=MAX_FCODE; f_code++){
         for(mv=-MAX_MV; mv<=MAX_MV; mv++){
--- a/motion_est.c	Mon Mar 31 01:49:18 2003 +0000
+++ b/motion_est.c	Mon Mar 31 11:13:14 2003 +0000
@@ -47,7 +47,7 @@
 				  int *mx_ptr, int *my_ptr, int dmin,
 				  int xmin, int ymin, int xmax, int ymax,
                                   int pred_x, int pred_y, Picture *picture,
-                                  int n, int size, uint16_t * const mv_penalty);
+                                  int n, int size, uint8_t * const mv_penalty);
 
 static inline int update_map_generation(MpegEncContext * s)
 {
@@ -657,7 +657,7 @@
 				  int *mx_ptr, int *my_ptr, int dmin,
 				  int xmin, int ymin, int xmax, int ymax,
                                   int pred_x, int pred_y, Picture *picture,
-                                  int n, int size, uint16_t * const mv_penalty)
+                                  int n, int size, uint8_t * const mv_penalty)
 {
     uint8_t *ref_picture= picture->data[0];
     uint32_t *score_map= s->me.score_map;
@@ -831,7 +831,7 @@
     int block;
     int P[10][2];
     int dmin_sum=0, mx4_sum=0, my4_sum=0;
-    uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
+    uint8_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
 
     for(block=0; block<4; block++){
         int mx4, my4;
@@ -982,7 +982,7 @@
     int mb_type=0;
     uint8_t *ref_picture= s->last_picture.data[0];
     Picture * const pic= &s->current_picture;
-    uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
+    uint8_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
     
     assert(s->quarter_sample==0 || s->quarter_sample==1);
 
@@ -1151,7 +1151,7 @@
     int pred_x=0, pred_y=0;
     int P[10][2];
     const int shift= 1+s->quarter_sample;
-    uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
+    uint8_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
     const int mv_stride= s->mb_width + 2;
     const int xy= mb_x + 1 + (mb_y + 1)*mv_stride;
     
@@ -1213,7 +1213,7 @@
     const int mot_stride = s->mb_width + 2;
     const int mot_xy = (mb_y + 1)*mot_stride + mb_x + 1;
     uint8_t * const ref_picture= picture->data[0];
-    uint16_t * const mv_penalty= s->me.mv_penalty[f_code] + MAX_MV;
+    uint8_t * const mv_penalty= s->me.mv_penalty[f_code] + MAX_MV;
     int mv_scale;
         
     s->me.penalty_factor    = get_penalty_factor(s, s->avctx->me_cmp);
@@ -1310,7 +1310,7 @@
     //FIXME optimize?
     //FIXME move into template?
     //FIXME better f_code prediction (max mv & distance)
-    uint16_t *mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame
+    uint8_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame
     uint8_t *dest_y = s->me.scratchpad;
     uint8_t *ptr;
     int dxy;
@@ -1405,7 +1405,7 @@
     const int time_pb= s->pb_time;
     int mx, my, xmin, xmax, ymin, ymax;
     int16_t (*mv_table)[2]= s->b_direct_mv_table;
-    uint16_t * const mv_penalty= s->me.mv_penalty[1] + MAX_MV;
+    uint8_t * const mv_penalty= s->me.mv_penalty[1] + MAX_MV;
     
     ymin= xmin=(-32)>>shift;
     ymax= xmax=   31>>shift;
--- a/motion_est_template.c	Mon Mar 31 01:49:18 2003 +0000
+++ b/motion_est_template.c	Mon Mar 31 11:13:14 2003 +0000
@@ -72,7 +72,7 @@
 				  int *mx_ptr, int *my_ptr, int dmin,
 				  int xmin, int ymin, int xmax, int ymax,
                                   int pred_x, int pred_y, Picture *ref_picture, 
-                                  int n, int size, uint16_t * const mv_penalty)
+                                  int n, int size, uint8_t * const mv_penalty)
 {
     const int xx = 16 * s->mb_x + 8*(n&1);
     const int yy = 16 * s->mb_y + 8*(n>>1);
@@ -141,7 +141,7 @@
 				  int *mx_ptr, int *my_ptr, int dmin,
 				  int xmin, int ymin, int xmax, int ymax,
                                   int pred_x, int pred_y, Picture *ref_picture, 
-                                  int n, int size, uint16_t * const mv_penalty)
+                                  int n, int size, uint8_t * const mv_penalty)
 {
     const int xx = 16 * s->mb_x + 8*(n&1);
     const int yy = 16 * s->mb_y + 8*(n>>1);
@@ -246,7 +246,7 @@
 #endif
 
 static int RENAME(hpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pred_x, int pred_y, Picture *ref_picture, 
-                                  uint16_t * const mv_penalty)
+                                  uint8_t * const mv_penalty)
 {
 //    const int check_luma= s->dsp.me_sub_cmp != s->dsp.mb_cmp;
     const int size= 0;
@@ -295,7 +295,7 @@
 				  int *mx_ptr, int *my_ptr, int dmin,
 				  int xmin, int ymin, int xmax, int ymax,
                                   int pred_x, int pred_y, Picture *ref_picture, 
-                                  int n, int size, uint16_t * const mv_penalty)
+                                  int n, int size, uint8_t * const mv_penalty)
 {
     const int xx = 16 * s->mb_x + 8*(n&1);
     const int yy = 16 * s->mb_y + 8*(n>>1);
@@ -513,7 +513,7 @@
 }
 
 static int RENAME(qpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pred_x, int pred_y, Picture *ref_picture, 
-                                  uint16_t * const mv_penalty)
+                                  uint8_t * const mv_penalty)
 {
     const int size= 0;
     const int xx = 16 * s->mb_x;
@@ -598,7 +598,7 @@
                                        Picture *ref_picture,
                                        int const pred_x, int const pred_y, int const penalty_factor,
                                        int const xmin, int const ymin, int const xmax, int const ymax, int const shift,
-                                       uint32_t *map, int map_generation, int size, uint16_t * const mv_penalty
+                                       uint32_t *map, int map_generation, int size, uint8_t * const mv_penalty
                                        )
 {
     me_cmp_func cmp, chroma_cmp;
@@ -640,7 +640,7 @@
                                        Picture *ref_picture,
                                        int const pred_x, int const pred_y, int const penalty_factor,
                                        int const xmin, int const ymin, int const xmax, int const ymax, int const shift,
-                                       uint32_t *map, int map_generation, int size, uint16_t * const mv_penalty
+                                       uint32_t *map, int map_generation, int size, uint8_t * const mv_penalty
                                        )
 {
     me_cmp_func cmp, chroma_cmp;
@@ -731,7 +731,7 @@
                                        Picture *ref_picture,
                                        int const pred_x, int const pred_y, int const penalty_factor,
                                        int const xmin, int const ymin, int const xmax, int const ymax, int const shift,
-                                       uint32_t *map, int map_generation, int size, uint16_t * const mv_penalty
+                                       uint32_t *map, int map_generation, int size, uint8_t * const mv_penalty
                                        )
 {
     me_cmp_func cmp, chroma_cmp;
@@ -811,7 +811,7 @@
                                        Picture *ref_picture,
                                        int const pred_x, int const pred_y, int const penalty_factor,
                                        int const xmin, int const ymin, int const xmax, int const ymax, int const shift,
-                                       uint32_t *map, int map_generation, int size, uint16_t * const mv_penalty
+                                       uint32_t *map, int map_generation, int size, uint8_t * const mv_penalty
                                        )
 {
     me_cmp_func cmp, chroma_cmp;
@@ -888,7 +888,7 @@
                              int *mx_ptr, int *my_ptr,
                              int P[10][2], int pred_x, int pred_y,
                              int xmin, int ymin, int xmax, int ymax, Picture *ref_picture, int16_t (*last_mv)[2], 
-                             int ref_mv_scale, uint16_t * const mv_penalty)
+                             int ref_mv_scale, uint8_t * const mv_penalty)
 {
     int best[2]={0, 0};
     int d, dmin; 
@@ -1000,7 +1000,7 @@
                              int *mx_ptr, int *my_ptr,
                              int P[10][2], int pred_x, int pred_y,
                              int xmin, int ymin, int xmax, int ymax, Picture *ref_picture, int16_t (*last_mv)[2], 
-                             int ref_mv_scale, uint16_t * const mv_penalty)
+                             int ref_mv_scale, uint8_t * const mv_penalty)
 {
     int best[2]={0, 0};
     int d, dmin; 
--- a/mpeg12.c	Mon Mar 31 01:49:18 2003 +0000
+++ b/mpeg12.c	Mon Mar 31 11:13:14 2003 +0000
@@ -73,7 +73,7 @@
 static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred);
 
 #ifdef CONFIG_ENCODERS
-static uint16_t mv_penalty[MAX_FCODE+1][MAX_MV*2+1];
+static uint8_t (*mv_penalty)[MAX_MV*2+1]= NULL;
 static uint8_t fcode_tab[MAX_MV*2+1];
 
 static uint32_t uni_mpeg1_ac_vlc_bits[64*64*2];
@@ -670,6 +670,8 @@
 		mpeg1_chr_dc_uni[i+255]= bits + (code<<8);
 	}
 
+        mv_penalty= av_mallocz( sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
+
         for(f_code=1; f_code<=MAX_FCODE; f_code++){
             for(mv=-MAX_MV; mv<=MAX_MV; mv++){
                 int len;
--- a/mpegvideo.c	Mon Mar 31 01:49:18 2003 +0000
+++ b/mpegvideo.c	Mon Mar 31 11:13:14 2003 +0000
@@ -82,7 +82,7 @@
 };
 
 #ifdef CONFIG_ENCODERS
-static uint16_t (*default_mv_penalty)[MAX_MV*2+1]=NULL;
+static uint8_t (*default_mv_penalty)[MAX_MV*2+1]=NULL;
 static uint8_t default_fcode_tab[MAX_MV*2+1];
 
 enum PixelFormat ff_yuv420p_list[2]= {PIX_FMT_YUV420P, -1};
@@ -680,8 +680,8 @@
             int i;
             done=1;
 
-            default_mv_penalty= av_mallocz( sizeof(uint16_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
-            memset(default_mv_penalty, 0, sizeof(uint16_t)*(MAX_FCODE+1)*(2*MAX_MV+1));
+            default_mv_penalty= av_mallocz( sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
+            memset(default_mv_penalty, 0, sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1));
             memset(default_fcode_tab , 0, sizeof(uint8_t)*(2*MAX_MV+1));
 
             for(i=-16; i<16; i++){
--- a/mpegvideo.h	Mon Mar 31 01:49:18 2003 +0000
+++ b/mpegvideo.h	Mon Mar 31 11:13:14 2003 +0000
@@ -164,24 +164,24 @@
     int mb_penalty_factor;
     int pre_pass;                      ///< = 1 for the pre pass 
     int dia_size;
-    uint16_t (*mv_penalty)[MAX_MV*2+1];  ///< amount of bits needed to encode a MV 
+    uint8_t (*mv_penalty)[MAX_MV*2+1];  ///< amount of bits needed to encode a MV 
     int (*sub_motion_search)(struct MpegEncContext * s,
 				  int *mx_ptr, int *my_ptr, int dmin,
 				  int xmin, int ymin, int xmax, int ymax,
                                   int pred_x, int pred_y, Picture *ref_picture, 
-                                  int n, int size, uint16_t * const mv_penalty);
+                                  int n, int size, uint8_t * const mv_penalty);
     int (*motion_search[7])(struct MpegEncContext * s, int block,
                              int *mx_ptr, int *my_ptr,
                              int P[10][2], int pred_x, int pred_y,
                              int xmin, int ymin, int xmax, int ymax, Picture *ref_picture, int16_t (*last_mv)[2], 
-                             int ref_mv_scale, uint16_t * const mv_penalty);
+                             int ref_mv_scale, uint8_t * const mv_penalty);
     int (*pre_motion_search)(struct MpegEncContext * s, int block,
                              int *mx_ptr, int *my_ptr,
                              int P[10][2], int pred_x, int pred_y,
                              int xmin, int ymin, int xmax, int ymax, Picture *ref_picture, int16_t (*last_mv)[2], 
-                             int ref_mv_scale, uint16_t * const mv_penalty);
+                             int ref_mv_scale, uint8_t * const mv_penalty);
     int (*get_mb_score)(struct MpegEncContext * s, int mx, int my, int pred_x, int pred_y, Picture *ref_picture, 
-                                  uint16_t * const mv_penalty);
+                                  uint8_t * const mv_penalty);
 }MotionEstContext;
 
 /**