diff options
Diffstat (limited to 'src/libffmpeg/libavcodec')
-rw-r--r-- | src/libffmpeg/libavcodec/error_resilience.c | 8 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/h263.c | 11 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/motion_est.c | 5 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/ratecontrol.c | 65 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/svq1.c | 5 |
5 files changed, 59 insertions, 35 deletions
diff --git a/src/libffmpeg/libavcodec/error_resilience.c b/src/libffmpeg/libavcodec/error_resilience.c index 3cb8d40bc..5a8df74d2 100644 --- a/src/libffmpeg/libavcodec/error_resilience.c +++ b/src/libffmpeg/libavcodec/error_resilience.c @@ -18,6 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <alloca.h> + #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" @@ -295,14 +297,16 @@ static void v_block_filter(MpegEncContext *s, UINT8 *dst, int w, int h, int stri } static void guess_mv(MpegEncContext *s){ - UINT8 fixed[s->mb_num]; + UINT8 *fixed; #define MV_FROZEN 3 #define MV_CHANGED 2 #define MV_UNCHANGED 1 const int mb_width = s->mb_width; const int mb_height= s->mb_height; int i, depth, num_avail; - + + fixed = alloca(s->mb_num); + num_avail=0; for(i=0; i<s->mb_num; i++){ int f=0; diff --git a/src/libffmpeg/libavcodec/h263.c b/src/libffmpeg/libavcodec/h263.c index 98b29ad0b..0d0799bb5 100644 --- a/src/libffmpeg/libavcodec/h263.c +++ b/src/libffmpeg/libavcodec/h263.c @@ -3887,7 +3887,7 @@ static void mpeg4_decode_sprite_trajectory(MpegEncContext * s) int a= 2<<s->sprite_warping_accuracy; int rho= 3-s->sprite_warping_accuracy; int r=16/a; - const int vop_ref[4][2]= {{0,0}, {s->width,0}, {0, s->height}, {s->width, s->height}}; // only true for rectangle shapes + int vop_ref[4][2]; int d[4][2]={{0,0}, {0,0}, {0,0}, {0,0}}; int sprite_ref[4][2]; int virtual_ref[2][2]; @@ -3897,6 +3897,15 @@ static void mpeg4_decode_sprite_trajectory(MpegEncContext * s) int h= s->height; int min_ab; + vop_ref[0][0] = 0; + vop_ref[0][1] = 0; + vop_ref[1][0] = s->width; + vop_ref[1][1] = 0; + vop_ref[2][0] = 0; + vop_ref[2][1] = s->height; + vop_ref[3][0] = s->width; + vop_ref[3][1] = s->height; + for(i=0; i<s->num_sprite_warping_points; i++){ int length; int x=0, y=0; diff --git a/src/libffmpeg/libavcodec/motion_est.c b/src/libffmpeg/libavcodec/motion_est.c index fa6c3ee6b..547f4cdc5 100644 --- a/src/libffmpeg/libavcodec/motion_est.c +++ b/src/libffmpeg/libavcodec/motion_est.c @@ -417,7 +417,7 @@ static inline int snake_search(MpegEncContext * s, int *best, int dmin, static int x_dir[8]= {1,1,0,-1,-1,-1, 0, 1}; static int y_dir[8]= {0,1,1, 1, 0,-1,-1,-1}; int fails=0; - int last_d[2]={dmin, dmin}; + int last_d[2]; /*static int good=0; static int bad=0; @@ -429,6 +429,9 @@ if(256*256*256*64%point==0) printf("%d %d %d\n", good, bad, point); }*/ + last_d[0] = dmin; + last_d[1] = dmin; + for(;;){ int x= best[0]; int y= best[1]; diff --git a/src/libffmpeg/libavcodec/ratecontrol.c b/src/libffmpeg/libavcodec/ratecontrol.c index caea09b24..63c45c82a 100644 --- a/src/libffmpeg/libavcodec/ratecontrol.c +++ b/src/libffmpeg/libavcodec/ratecontrol.c @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <math.h> +#include <alloca.h> #include "common.h" #include "avcodec.h" #include "dsputil.h" @@ -229,33 +230,8 @@ static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_f const double mb_num= s->mb_num; int i; - double const_values[]={ - M_PI, - M_E, - rce->i_tex_bits*rce->qscale, - rce->p_tex_bits*rce->qscale, - (rce->i_tex_bits + rce->p_tex_bits)*(double)rce->qscale, - rce->mv_bits/mb_num, - rce->pict_type == B_TYPE ? (rce->f_code + rce->b_code)*0.5 : rce->f_code, - rce->i_count/mb_num, - rce->mc_mb_var_sum/mb_num, - rce->mb_var_sum/mb_num, - rce->pict_type == I_TYPE, - rce->pict_type == P_TYPE, - rce->pict_type == B_TYPE, - rcc->qscale_sum[pict_type] / (double)rcc->frame_count[pict_type], - s->qcompress, -/* rcc->last_qscale_for[I_TYPE], - rcc->last_qscale_for[P_TYPE], - rcc->last_qscale_for[B_TYPE], - rcc->next_non_b_qscale,*/ - rcc->i_cplx_sum[I_TYPE] / (double)rcc->frame_count[I_TYPE], - rcc->i_cplx_sum[P_TYPE] / (double)rcc->frame_count[P_TYPE], - rcc->p_cplx_sum[P_TYPE] / (double)rcc->frame_count[P_TYPE], - rcc->p_cplx_sum[B_TYPE] / (double)rcc->frame_count[B_TYPE], - (rcc->i_cplx_sum[pict_type] + rcc->p_cplx_sum[pict_type]) / (double)rcc->frame_count[pict_type], - 0 - }; + double const_values[20]; + char *const_names[]={ "PI", "E", @@ -294,6 +270,32 @@ static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_f NULL }; + const_values[0] = M_PI; + const_values[1] = M_E; + const_values[2] = rce->i_tex_bits*rce->qscale; + const_values[3] = rce->p_tex_bits*rce->qscale; + const_values[4] = (rce->i_tex_bits + rce->p_tex_bits)*(double)rce->qscale; + const_values[5] = rce->mv_bits/mb_num; + const_values[6] = rce->pict_type == B_TYPE ? (rce->f_code + rce->b_code)*0.5 : rce->f_code; + const_values[7] = rce->i_count/mb_num; + const_values[8] = rce->mc_mb_var_sum/mb_num; + const_values[9] = rce->mb_var_sum/mb_num; + const_values[10] = rce->pict_type == I_TYPE; + const_values[11] = rce->pict_type == P_TYPE; + const_values[12] = rce->pict_type == B_TYPE; + const_values[13] = rcc->qscale_sum[pict_type] / (double)rcc->frame_count[pict_type]; + const_values[14] = s->qcompress; + /*const_values[] = rcc->last_qscale_for[I_TYPE]; + const_values[] = rcc->last_qscale_for[P_TYPE]; + const_values[] = rcc->last_qscale_for[B_TYPE]; + const_values[] = rcc->next_non_b_qscale;*/ + const_values[15] = rcc->i_cplx_sum[I_TYPE] / (double)rcc->frame_count[I_TYPE]; + const_values[16] = rcc->i_cplx_sum[P_TYPE] / (double)rcc->frame_count[P_TYPE]; + const_values[17] = rcc->p_cplx_sum[P_TYPE] / (double)rcc->frame_count[P_TYPE]; + const_values[18] = rcc->p_cplx_sum[B_TYPE] / (double)rcc->frame_count[B_TYPE]; + const_values[19] = (rcc->i_cplx_sum[pict_type] + rcc->p_cplx_sum[pict_type]) / (double)rcc->frame_count[pict_type]; + const_values[20] = 0; + bits= ff_eval(s->avctx->rc_eq, const_values, const_names, func1, func1_names, NULL, NULL, rce); rcc->pass1_rc_eq_output_sum+= bits; @@ -471,12 +473,15 @@ static void adaptive_quantization(MpegEncContext *s, double q){ const float p_masking = s->avctx->p_masking; float bits_sum= 0.0; float cplx_sum= 0.0; - float cplx_tab[s->mb_num]; - float bits_tab[s->mb_num]; + float *cplx_tab; + float *bits_tab; const int qmin= 2; //s->avctx->mb_qmin; const int qmax= 31; //s->avctx->mb_qmax; Picture * const pic= &s->current_picture; - + + cplx_tab = alloca(s->mb_num * sizeof(float)); + bits_tab = alloca(s->mb_num * sizeof(float)); + for(i=0; i<s->mb_num; i++){ float temp_cplx= sqrt(pic->mc_mb_var[i]); float spat_cplx= sqrt(pic->mb_var[i]); diff --git a/src/libffmpeg/libavcodec/svq1.c b/src/libffmpeg/libavcodec/svq1.c index 86ebd7382..6abccf403 100644 --- a/src/libffmpeg/libavcodec/svq1.c +++ b/src/libffmpeg/libavcodec/svq1.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <alloca.h> #include "common.h" #include "avcodec.h" @@ -1136,7 +1137,9 @@ static int svq1_decode_frame(AVCodecContext *avctx, current += 16*linesize; } } else { - svq1_pmv_t pmv[width/8+3]; + svq1_pmv_t *pmv; + + pmv = alloca((width/8+3) * sizeof(svq1_pmv_t)); /* delta frame */ memset (pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv_t)); |