34 |
#include "../image/image.h" |
#include "../image/image.h" |
35 |
|
|
36 |
|
|
37 |
|
/* This preprocessor constant controls wheteher or not, first pass is done |
38 |
|
* using fast ME routines to speed up the 2pass process at the expense of |
39 |
|
* less precise first pass stats */ |
40 |
|
#define FAST1PASS |
41 |
|
#define FAST1PASS_QPEL_TOO |
42 |
|
|
43 |
|
|
44 |
/* context struct */ |
/* context struct */ |
45 |
typedef struct |
typedef struct |
46 |
{ |
{ |
132 |
{ |
{ |
133 |
if (data->quant <= 0) { |
if (data->quant <= 0) { |
134 |
if (data->zone && data->zone->mode == XVID_ZONE_QUANT) { |
if (data->zone && data->zone->mode == XVID_ZONE_QUANT) { |
135 |
|
/* We disable no options in quant zones, as their implementation is |
136 |
|
* based on the fact we do first pass exactly the same way as the |
137 |
|
* second one to have exact zone size */ |
138 |
rc->fq_error += (double)data->zone->increment / (double)data->zone->base; |
rc->fq_error += (double)data->zone->increment / (double)data->zone->base; |
139 |
data->quant = (int)rc->fq_error; |
data->quant = (int)rc->fq_error; |
140 |
rc->fq_error -= data->quant; |
rc->fq_error -= data->quant; |
141 |
} else { |
} else { |
142 |
data->quant = 2; |
data->quant = 2; |
143 |
|
|
144 |
|
#ifdef FAST1PASS |
145 |
|
/* Given the fact our 2pass algorithm is based on very simple |
146 |
|
* rules, we can disable some options that are too CPU intensive |
147 |
|
* and do not provide the 2nd pass any benefit */ |
148 |
|
|
149 |
|
/* First disable some motion flags */ |
150 |
|
data->motion_flags &= ~XVID_ME_CHROMA_PVOP; |
151 |
|
data->motion_flags &= ~XVID_ME_CHROMA_BVOP; |
152 |
|
data->motion_flags &= ~XVID_ME_USESQUARES16; |
153 |
|
data->motion_flags &= ~XVID_ME_ADVANCEDDIAMOND16; |
154 |
|
data->motion_flags &= ~XVID_ME_EXTSEARCH16; |
155 |
|
|
156 |
|
/* And enable fast replacements */ |
157 |
|
data->motion_flags |= XVID_ME_FAST_MODEINTERPOLATE; |
158 |
|
data->motion_flags |= XVID_ME_SKIP_DELTASEARCH; |
159 |
|
data->motion_flags |= XVID_ME_FASTREFINE16; |
160 |
|
data->motion_flags |= XVID_ME_BFRAME_EARLYSTOP; |
161 |
|
|
162 |
|
/* Now VOP flags (no fast replacements) */ |
163 |
|
data->vop_flags &= ~XVID_VOP_MODEDECISION_RD; |
164 |
|
data->vop_flags &= ~XVID_VOP_FAST_MODEDECISION_RD; |
165 |
|
data->vop_flags &= ~XVID_VOP_TRELLISQUANT; |
166 |
|
data->vop_flags &= ~XVID_VOP_INTER4V; |
167 |
|
data->vop_flags &= ~XVID_VOP_HQACPRED; |
168 |
|
|
169 |
|
/* Finnaly VOL flags |
170 |
|
* |
171 |
|
* NB: Qpel cannot be disable because this option really changes |
172 |
|
* too much the texture data compressibility, and thus the |
173 |
|
* second pass gets confused by too much impredictability |
174 |
|
* of frame sizes, and actually hurts quality */ |
175 |
|
#ifdef FAST1PASS_QPEL_TOO |
176 |
|
/* or maybe we can disable it after all? */ |
177 |
|
data->vol_flags &= ~XVID_VOL_QUARTERPEL; |
178 |
|
#endif |
179 |
|
data->vol_flags &= ~XVID_VOL_GMC; |
180 |
|
#endif |
181 |
} |
} |
182 |
} |
} |
183 |
return(0); |
return(0); |