19 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: vop_type_decision.c,v 1.1.2.1 2003-09-10 22:19:00 edgomez Exp $ |
* $Id: vop_type_decision.c,v 1.1.2.4 2003-11-16 15:32:38 edgomez Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
33 |
#include "motion_inlines.h" |
#include "motion_inlines.h" |
34 |
|
|
35 |
|
|
36 |
#define INTRA_THRESH 2200 |
#define INTRA_THRESH 2000 |
37 |
#define INTER_THRESH 40 |
#define INTER_THRESH 40 |
38 |
#define INTRA_THRESH2 95 |
#define INTRA_THRESH2 90 |
39 |
|
|
40 |
static void |
static void |
41 |
CheckCandidate32I(const int x, const int y, const SearchData * const data, const unsigned int Direction) |
CheckCandidate32I(const int x, const int y, const SearchData * const data, const unsigned int Direction) |
137 |
MEanalysis( const IMAGE * const pRef, |
MEanalysis( const IMAGE * const pRef, |
138 |
const FRAMEINFO * const Current, |
const FRAMEINFO * const Current, |
139 |
const MBParam * const pParam, |
const MBParam * const pParam, |
140 |
const int maxIntra, //maximum number if non-I frames |
const int maxIntra, /* maximum number if non-I frames */ |
141 |
const int intraCount, //number of non-I frames after last I frame; 0 if we force P/B frame |
const int intraCount, /* number of non-I frames after last I frame; 0 if we force P/B frame */ |
142 |
const int bCount, // number of B frames in a row |
const int bCount, /* number of B frames in a row */ |
143 |
const int b_thresh) |
const int b_thresh, |
144 |
|
const MACROBLOCK * const prev_mbs) |
145 |
{ |
{ |
146 |
uint32_t x, y, intra = 0; |
uint32_t x, y, intra = 0; |
147 |
int sSAD = 0; |
int sSAD = 0; |
148 |
MACROBLOCK * const pMBs = Current->mbs; |
MACROBLOCK * const pMBs = Current->mbs; |
149 |
const IMAGE * const pCurrent = &Current->image; |
const IMAGE * const pCurrent = &Current->image; |
150 |
int IntraThresh = INTRA_THRESH, InterThresh = INTER_THRESH + b_thresh; |
int IntraThresh = INTRA_THRESH, InterThresh = INTER_THRESH + b_thresh; |
151 |
int blocks = 0; |
int blocks = 10; |
152 |
int complexity = 0; |
int complexity = 0; |
153 |
|
|
154 |
int32_t iMinSAD[5], temp[5]; |
int32_t iMinSAD[5], temp[5]; |
165 |
Data.qpel_precision = 0; |
Data.qpel_precision = 0; |
166 |
|
|
167 |
if (intraCount != 0) { |
if (intraCount != 0) { |
168 |
if (intraCount < 10) // we're right after an I frame |
if (intraCount < 10) /* we're right after an I frame */ |
169 |
IntraThresh += 15* (intraCount - 10) * (intraCount - 10); |
IntraThresh += 15* (intraCount - 10) * (intraCount - 10); |
170 |
else |
else |
171 |
if ( 5*(maxIntra - intraCount) < maxIntra) // we're close to maximum. 2 sec when max is 10 sec |
if ( 5*(maxIntra - intraCount) < maxIntra) /* we're close to maximum. 2 sec when max is 10 sec */ |
172 |
IntraThresh -= (IntraThresh * (maxIntra - 8*(maxIntra - intraCount)))/maxIntra; |
IntraThresh -= (IntraThresh * (maxIntra - 8*(maxIntra - intraCount)))/maxIntra; |
173 |
} |
} |
174 |
|
|
183 |
blocks += 10; |
blocks += 10; |
184 |
|
|
185 |
if (bCount == 0) pMBs[x + y * pParam->mb_width].mvs[0] = zeroMV; |
if (bCount == 0) pMBs[x + y * pParam->mb_width].mvs[0] = zeroMV; |
186 |
else { //extrapolation of the vector found for last frame |
else { /* extrapolation of the vector found for last frame */ |
187 |
pMBs[x + y * pParam->mb_width].mvs[0].x = |
pMBs[x + y * pParam->mb_width].mvs[0].x = |
188 |
(pMBs[x + y * pParam->mb_width].mvs[0].x * (bCount+1) ) / bCount; |
(prev_mbs[x + y * pParam->mb_width].mvs[0].x * (bCount+1) ) / bCount; |
189 |
pMBs[x + y * pParam->mb_width].mvs[0].y = |
pMBs[x + y * pParam->mb_width].mvs[0].y = |
190 |
(pMBs[x + y * pParam->mb_width].mvs[0].y * (bCount+1) ) / bCount; |
(prev_mbs[x + y * pParam->mb_width].mvs[0].y * (bCount+1) ) / bCount; |
191 |
} |
} |
192 |
|
|
193 |
MEanalyzeMB(pRef->y, pCurrent->y, x, y, pParam, pMBs, &Data); |
MEanalyzeMB(pRef->y, pCurrent->y, x, y, pParam, pMBs, &Data); |
216 |
|
|
217 |
sSAD /= complexity + 4*blocks; |
sSAD /= complexity + 4*blocks; |
218 |
|
|
219 |
if (intraCount > 80 && sSAD > INTRA_THRESH2 ) return I_VOP; |
if (intraCount > 60 && sSAD > INTRA_THRESH2 ) return I_VOP; |
220 |
if (sSAD > InterThresh ) return P_VOP; |
if (sSAD > InterThresh ) return P_VOP; |
221 |
emms(); |
emms(); |
222 |
return B_VOP; |
return B_VOP; |