38 int scaledvalue, refdist;
39 int scalesame1, scalesame2;
40 int scalezone1_x, zone1offset_x;
57 if (
FFABS(n) < scalezone1_x)
58 scaledvalue = (n * scalesame1) >> 8;
61 scaledvalue = ((n * scalesame2) >> 8) - zone1offset_x;
63 scaledvalue = ((n * scalesame2) >> 8) + zone1offset_x;
71 int scaledvalue, refdist;
72 int scalesame1, scalesame2;
73 int scalezone1_y, zone1offset_y;
90 if (
FFABS(n) < scalezone1_y)
91 scaledvalue = (n * scalesame1) >> 8;
94 scaledvalue = ((n * scalesame2) >> 8) - zone1offset_y;
96 scaledvalue = ((n * scalesame2) >> 8) + zone1offset_y;
108 int scalezone1_x, zone1offset_x;
109 int scaleopp1, scaleopp2, brfd;
121 if (
FFABS(n) < scalezone1_x)
122 scaledvalue = (n * scaleopp1) >> 8;
125 scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_x;
127 scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_x;
135 int scalezone1_y, zone1offset_y;
136 int scaleopp1, scaleopp2, brfd;
148 if (
FFABS(n) < scalezone1_y)
149 scaledvalue = (n * scaleopp1) >> 8;
152 scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_y;
154 scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_y;
181 n = (n * scalesame >> 8) << hpel;
188 int refdist, scaleopp;
205 n = (n * scaleopp >> 8) * (1 << hpel);
212 int mv1,
int r_x,
int r_y,
uint8_t* is_intra,
213 int pred_flag,
int dir)
216 int xy,
wrap, off = 0;
220 int mixedmv_pic, num_samefield = 0, num_oppfield = 0;
221 int opposite, a_f, b_f, c_f;
222 int16_t field_predA[2];
223 int16_t field_predB[2];
224 int16_t field_predC[2];
225 int a_valid, b_valid, c_valid;
226 int hybridmv_thresh, y_bias = 0;
276 off = (s->
mb_x > 0) ? -1 : 1;
291 b_valid = a_valid && (s->
mb_width > 1);
292 c_valid = s->
mb_x || (n == 1 || n == 3);
294 a_valid = a_valid && !is_intra[xy -
wrap];
295 b_valid = b_valid && !is_intra[xy - wrap + off];
296 c_valid = c_valid && !is_intra[xy - 1];
302 num_samefield += 1 - a_f;
303 field_predA[0] = A[0];
304 field_predA[1] = A[1];
306 field_predA[0] = field_predA[1] = 0;
312 num_samefield += 1 - b_f;
313 field_predB[0] = B[0];
314 field_predB[1] = B[1];
316 field_predB[0] = field_predB[1] = 0;
322 num_samefield += 1 - c_f;
323 field_predC[0] = C[0];
324 field_predC[1] = C[1];
326 field_predC[0] = field_predC[1] = 0;
336 if (num_samefield <= num_oppfield)
337 opposite = 1 - pred_flag;
339 opposite = pred_flag;
344 if (a_valid && !a_f) {
345 field_predA[0] =
scaleforopp(v, field_predA[0], 0, dir);
346 field_predA[1] =
scaleforopp(v, field_predA[1], 1, dir);
348 if (b_valid && !b_f) {
349 field_predB[0] =
scaleforopp(v, field_predB[0], 0, dir);
350 field_predB[1] =
scaleforopp(v, field_predB[1], 1, dir);
352 if (c_valid && !c_f) {
353 field_predC[0] =
scaleforopp(v, field_predC[0], 0, dir);
354 field_predC[1] =
scaleforopp(v, field_predC[1], 1, dir);
359 if (a_valid && a_f) {
360 field_predA[0] =
scaleforsame(v, n, field_predA[0], 0, dir);
361 field_predA[1] =
scaleforsame(v, n, field_predA[1], 1, dir);
363 if (b_valid && b_f) {
364 field_predB[0] =
scaleforsame(v, n, field_predB[0], 0, dir);
365 field_predB[1] =
scaleforsame(v, n, field_predB[1], 1, dir);
367 if (c_valid && c_f) {
368 field_predC[0] =
scaleforsame(v, n, field_predC[0], 0, dir);
369 field_predC[1] =
scaleforsame(v, n, field_predC[1], 1, dir);
378 }
else if (c_valid) {
381 }
else if (b_valid) {
389 if (num_samefield + num_oppfield > 1) {
390 px =
mid_pred(field_predA[0], field_predB[0], field_predC[0]);
391 py =
mid_pred(field_predA[1], field_predB[1], field_predC[1]);
397 int MV = mv1 ? -60 : -28;
398 qx = (s->
mb_x << 6) + ((n == 1 || n == 3) ? 32 : 0);
399 qy = (s->
mb_y << 6) + ((n == 2 || n == 3) ? 32 : 0);
402 if (qx + px < MV) px = MV - qx;
403 if (qy + py < MV) py = MV - qy;
404 if (qx + px > X) px = X - qx;
405 if (qy + py > Y) py = Y - qy;
410 hybridmv_thresh = 32;
411 if (a_valid && c_valid) {
412 if (is_intra[xy - wrap])
415 sum =
FFABS(px - field_predA[0]) +
FFABS(py - field_predA[1]);
416 if (sum > hybridmv_thresh) {
425 if (is_intra[xy - 1])
428 sum =
FFABS(px - field_predC[0]) +
FFABS(py - field_predC[1]);
429 if (sum > hybridmv_thresh) {
464 int mvn,
int r_x,
int r_y,
uint8_t* is_intra,
int dir)
467 int xy,
wrap, off = 0;
468 int A[2],
B[2],
C[2];
470 int a_valid = 0, b_valid = 0, c_valid = 0;
471 int field_a, field_b, field_c;
472 int total_valid, num_samefield, num_oppfield;
473 int pos_c, pos_b, n_adj;
501 off = ((n == 0) || (n == 1)) ? 1 : -1;
503 if (s->
mb_x || (n == 1) || (n == 3)) {
523 B[0] = B[1] = C[0] = C[1] = 0;
531 n_adj = (n & 2) | (n & 1);
585 total_valid = a_valid + b_valid + c_valid;
587 if (!s->
mb_x && !(n == 1 || n == 3)) {
592 B[0] = B[1] = C[0] = C[1] = 0;
599 if (total_valid >= 2) {
602 }
else if (total_valid) {
603 if (a_valid) { px = A[0]; py = A[1]; }
604 else if (b_valid) { px = B[0]; py = B[1]; }
605 else { px = C[0]; py = C[1]; }
610 field_a = (A[1] & 4) ? 1 : 0;
614 field_b = (B[1] & 4) ? 1 : 0;
618 field_c = (C[1] & 4) ? 1 : 0;
622 num_oppfield = field_a + field_b + field_c;
623 num_samefield = total_valid - num_oppfield;
624 if (total_valid == 3) {
625 if ((num_samefield == 3) || (num_oppfield == 3)) {
628 }
else if (num_samefield >= num_oppfield) {
631 px = !field_a ? A[0] : B[0];
632 py = !field_a ? A[1] : B[1];
634 px = field_a ? A[0] : B[0];
635 py = field_a ? A[1] : B[1];
637 }
else if (total_valid == 2) {
638 if (num_samefield >= num_oppfield) {
639 if (!field_a && a_valid) {
642 }
else if (!field_b && b_valid) {
651 if (field_a && a_valid) {
660 }
else if (total_valid == 1) {
661 px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);
662 py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]);
676 }
else if (mvn == 2) {
679 s->
mv[dir][n + 1][0] = s->
mv[dir][
n][0];
680 s->
mv[dir][n + 1][1] = s->
mv[dir][
n][1];
685 int direct,
int mvtype)
688 int xy,
wrap, off = 0;
726 s->
mv[0][0][0] = av_clip(s->
mv[0][0][0], -60 - (s->
mb_x << 6), (s->
mb_width << 6) - 4 - (s->
mb_x << 6));
727 s->
mv[0][0][1] = av_clip(s->
mv[0][0][1], -60 - (s->
mb_y << 6), (s->
mb_height << 6) - 4 - (s->
mb_y << 6));
728 s->
mv[1][0][0] = av_clip(s->
mv[1][0][0], -60 - (s->
mb_x << 6), (s->
mb_width << 6) - 4 - (s->
mb_x << 6));
729 s->
mv[1][0][1] = av_clip(s->
mv[1][0][1], -60 - (s->
mb_y << 6), (s->
mb_height << 6) - 4 - (s->
mb_y << 6));
744 if (!s->
mb_x) C[0] = C[1] = 0;
753 }
else if (s->
mb_x) {
763 int MV = 4 - (1 << sh);
764 qx = (s->
mb_x << sh);
765 qy = (s->
mb_y << sh);
768 if (qx + px < MV) px = MV - qx;
769 if (qy + py < MV) py = MV - qy;
770 if (qx + px > X) px = X - qx;
771 if (qy + py > Y) py = Y - qy;
775 if (is_intra[xy - wrap])
788 if (is_intra[xy - 2])
804 s->
mv[0][0][0] = ((px + dmv_x[0] + r_x) & ((r_x << 1) - 1)) - r_x;
805 s->
mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y;
823 }
else if (s->
mb_x) {
833 int MV = 4 - (1 << sh);
834 qx = (s->
mb_x << sh);
835 qy = (s->
mb_y << sh);
838 if (qx + px < MV) px = MV - qx;
839 if (qy + py < MV) py = MV - qy;
840 if (qx + px > X) px = X - qx;
841 if (qy + py > Y) py = Y - qy;
845 if (is_intra[xy - wrap])
858 if (is_intra[xy - 2])
875 s->
mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x;
876 s->
mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y;
885 int mv1,
int *pred_flag)
907 f = (total_opp > 2) ? 1 : 0;
909 s->
mv[0][0][0] = s->
mv[0][0][1] = 0;
910 s->
mv[1][0][0] = s->
mv[1][0][1] = 0;
914 for (k = 0; k < 4; k++) {
void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int mv1, int r_x, int r_y, uint8_t *is_intra, int pred_flag, int dir)
Predict and set motion vector.
int reffield
if numref = 0 (1 reference) then reffield decides which
static av_always_inline int scaleforopp_x(VC1Context *v, int n)
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_always_inline int scaleforsame(VC1Context *v, int i, int n, int dim, int dir)
int field_picture
whether or not the picture was encoded in separate fields
uint8_t * mv_f[2]
0: MV obtained from same field, 1: opposite field
const uint16_t ff_vc1_b_field_mvpred_scales[7][4]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int refdist
distance of the current picture from reference
void ff_vc1_pred_b_mv_intfi(VC1Context *v, int n, int *dmv_x, int *dmv_y, int mv1, int *pred_flag)
static av_always_inline int scaleforopp_y(VC1Context *v, int n, int dir)
Picture current_picture
copy of the current picture structure.
int16_t bfraction
Relative position % anchors=> how to scale MVs.
int profile
Sequence header data for all Profiles TODO: choose between ints, uint8_ts and monobit flags...
int mb_height
number of MBs horizontally & vertically
static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n, int dir)
int quarter_sample
1->qpel, 0->half pel ME/MC
uint8_t * blk_mv_type
0: frame MV, 1: field MV (interlaced frame)
int cur_field_type
0: top, 1: bottom
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int field_mode
1 for interlaced field pictures
uint8_t mv_mode
Frame decoding info for all profiles.
int16_t(*[2] motion_val)[2]
const uint16_t ff_vc1_field_mvpred_scales[2][7][4]
int block_index[6]
index to current MB in block based arrays with edges
int first_slice_line
used in mpeg4 too to handle resync markers
static av_always_inline int scaleforsame_x(VC1Context *v, int n, int dir)
void ff_vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mvtype)
static unsigned int get_bits1(GetBitContext *s)
int ref_field_type[2]
forward and backward reference field type (top or bottom)
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
int numref
number of past field pictures used as reference
int mv[2][4][2]
motion vectors for a macroblock first coordinate : 0 = forward 1 = backward second " : depend...
int b8_stride
2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
Picture * next_picture_ptr
pointer to the next picture (for bidir pred)
struct AVCodecContext * avctx
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
void ff_vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y, int mvn, int r_x, int r_y, uint8_t *is_intra, int dir)
Predict and set motion vector for interlaced frame picture MBs.
Picture next_picture
copy of the next picture structure.
int brfd
reference frame distance (forward or backward)
uint32_t * mb_type
types and macros are defined in mpegutils.h
uint8_t mv_mode2
Secondary MV coding mode (B frames)
static av_always_inline int scaleforopp(VC1Context *v, int n, int dim, int dir)