21 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
* |
* |
24 |
* $Id: estimation_bvop.c,v 1.26 2010-11-28 15:18:21 Isibaar Exp $ |
* $Id: estimation_bvop.c,v 1.27 2010-12-18 16:02:00 Isibaar Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
1097 |
|
|
1098 |
|
|
1099 |
void |
void |
1100 |
SMPMotionEstimationBVOP(SMPmotionData * h) |
SMPMotionEstimationBVOP(SMPData * h) |
1101 |
{ |
{ |
1102 |
const MBParam * const pParam = h->pParam; |
Encoder *pEnc = (Encoder *) h->pEnc; |
1103 |
|
|
1104 |
|
const MBParam * const pParam = &pEnc->mbParam; |
1105 |
const FRAMEINFO * const frame = h->current; |
const FRAMEINFO * const frame = h->current; |
1106 |
const int32_t time_bp = h->time_bp; |
const int32_t time_bp = (int32_t)(pEnc->current->stamp - frame->stamp); |
1107 |
const int32_t time_pp = h->time_pp; |
const int32_t time_pp = (int32_t)(pEnc->current->stamp - pEnc->reference->stamp); |
1108 |
/* forward (past) reference */ |
/* forward (past) reference */ |
1109 |
const MACROBLOCK * const f_mbs = h->f_mbs; |
const IMAGE * const f_ref = &pEnc->reference->image; |
1110 |
const IMAGE * const f_ref = h->fRef; |
const IMAGE * const f_refH = &pEnc->f_refh; |
1111 |
const IMAGE * const f_refH = h->fRefH; |
const IMAGE * const f_refV = &pEnc->f_refv; |
1112 |
const IMAGE * const f_refV = h->fRefV; |
const IMAGE * const f_refHV = &pEnc->f_refhv; |
|
const IMAGE * const f_refHV = h->fRefHV; |
|
1113 |
/* backward (future) reference */ |
/* backward (future) reference */ |
1114 |
const FRAMEINFO * const b_reference = h->reference; |
const FRAMEINFO * const b_reference = pEnc->current; |
1115 |
const IMAGE * const b_ref = h->pRef; |
const IMAGE * const b_ref = &pEnc->current->image; |
1116 |
const IMAGE * const b_refH = h->pRefH; |
const IMAGE * const b_refH = &pEnc->vInterH; |
1117 |
const IMAGE * const b_refV = h->pRefV; |
const IMAGE * const b_refV = &pEnc->vInterV; |
1118 |
const IMAGE * const b_refHV = h->pRefHV; |
const IMAGE * const b_refHV = &pEnc->vInterHV; |
1119 |
|
|
1120 |
|
int y_row = h->y_row; |
1121 |
int y_step = h->y_step; |
int y_step = h->y_step; |
1122 |
int start_y = h->start_y; |
int start_y = h->start_y; |
1123 |
|
int stop_y = h->stop_y; |
1124 |
int * complete_count_self = h->complete_count_self; |
int * complete_count_self = h->complete_count_self; |
1125 |
const int * complete_count_above = h->complete_count_above; |
const int * complete_count_above = h->complete_count_above; |
1126 |
int max_mbs; |
int max_mbs; |
1164 |
|
|
1165 |
max_mbs = 0; |
max_mbs = 0; |
1166 |
|
|
1167 |
for (j = start_y; j < pParam->mb_height; j += y_step) { |
for (j = (start_y+y_row); j < stop_y; j += y_step) { |
1168 |
if (j == 0) max_mbs = pParam->mb_width; /* we can process all blocks of the first row */ |
if (j == start_y) max_mbs = pParam->mb_width; /* we can process all blocks of the first row */ |
1169 |
|
|
1170 |
f_predMV = b_predMV = zeroMV; /* prediction is reset at left boundary */ |
f_predMV = b_predMV = zeroMV; /* prediction is reset at left boundary */ |
1171 |
|
|
1172 |
for (i = 0; i < pParam->mb_width; i++) { |
for (i = 0; i < (int) pParam->mb_width; i++) { |
1173 |
MACROBLOCK * const pMB = frame->mbs + i + j * pParam->mb_width; |
MACROBLOCK * const pMB = frame->mbs + i + j * pParam->mb_width; |
1174 |
const MACROBLOCK * const b_mb = b_mbs + i + j * pParam->mb_width; |
const MACROBLOCK * const b_mb = b_mbs + i + j * pParam->mb_width; |
1175 |
pMB->mode = -1; |
pMB->mode = -1; |
1185 |
if (above_count == pParam->mb_width) { |
if (above_count == pParam->mb_width) { |
1186 |
/* full line above is ready */ |
/* full line above is ready */ |
1187 |
above_count = pParam->mb_width+1; |
above_count = pParam->mb_width+1; |
1188 |
if (j < pParam->mb_height-y_step) { |
if (j < stop_y-y_step) { |
1189 |
/* this is not last line, grab a portion of MBs from the next line too */ |
/* this is not last line, grab a portion of MBs from the next line too */ |
1190 |
above_count += MAX(0, complete_count_above[1] - 1); |
above_count += MAX(0, complete_count_above[1] - 1); |
1191 |
} |
} |