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) * (1 << hpel);
188 int refdist, scaleopp;
203 refdist =
FFMIN(refdist, 3);
206 n = (n * scaleopp >> 8) * (1 << hpel);
213 int mv1,
int r_x,
int r_y,
uint8_t* is_intra,
214 int pred_flag,
int dir)
217 int xy,
wrap, off = 0;
221 int mixedmv_pic, num_samefield = 0, num_oppfield = 0;
222 int opposite, a_f, b_f, c_f;
223 int16_t field_predA[2];
224 int16_t field_predB[2];
225 int16_t field_predC[2];
226 int a_valid, b_valid, c_valid;
227 int hybridmv_thresh, y_bias = 0;
268 c_valid = s->
mb_x || (n == 1 || n == 3);
274 b_valid = b_valid && s->
mb_width > 1;
280 off = s->
mb_x ? -1 : 1;
294 b_valid = b_valid && c_valid;
298 a_valid = a_valid && !is_intra[xy -
wrap];
299 b_valid = b_valid && !is_intra[xy - wrap + off];
300 c_valid = c_valid && !is_intra[xy - 1];
307 num_samefield += 1 - a_f;
308 field_predA[0] = A[0];
309 field_predA[1] = A[1];
311 field_predA[0] = field_predA[1] = 0;
318 num_samefield += 1 - b_f;
319 field_predB[0] = B[0];
320 field_predB[1] = B[1];
322 field_predB[0] = field_predB[1] = 0;
329 num_samefield += 1 - c_f;
330 field_predC[0] = C[0];
331 field_predC[1] = C[1];
333 field_predC[0] = field_predC[1] = 0;
343 if (num_samefield <= num_oppfield)
344 opposite = 1 - pred_flag;
346 opposite = pred_flag;
353 if (a_valid && !a_f) {
354 field_predA[0] =
scaleforopp(v, field_predA[0], 0, dir);
355 field_predA[1] =
scaleforopp(v, field_predA[1], 1, dir);
357 if (b_valid && !b_f) {
358 field_predB[0] =
scaleforopp(v, field_predB[0], 0, dir);
359 field_predB[1] =
scaleforopp(v, field_predB[1], 1, dir);
361 if (c_valid && !c_f) {
362 field_predC[0] =
scaleforopp(v, field_predC[0], 0, dir);
363 field_predC[1] =
scaleforopp(v, field_predC[1], 1, dir);
368 if (a_valid && a_f) {
369 field_predA[0] =
scaleforsame(v, n, field_predA[0], 0, dir);
370 field_predA[1] =
scaleforsame(v, n, field_predA[1], 1, dir);
372 if (b_valid && b_f) {
373 field_predB[0] =
scaleforsame(v, n, field_predB[0], 0, dir);
374 field_predB[1] =
scaleforsame(v, n, field_predB[1], 1, dir);
376 if (c_valid && c_f) {
377 field_predC[0] =
scaleforsame(v, n, field_predC[0], 0, dir);
378 field_predC[1] =
scaleforsame(v, n, field_predC[1], 1, dir);
385 }
else if (c_valid) {
388 }
else if (b_valid) {
396 if (num_samefield + num_oppfield > 1) {
397 px =
mid_pred(field_predA[0], field_predB[0], field_predC[0]);
398 py =
mid_pred(field_predA[1], field_predB[1], field_predC[1]);
404 int MV = mv1 ? -60 : -28;
405 qx = (s->
mb_x << 6) + ((n == 1 || n == 3) ? 32 : 0);
406 qy = (s->
mb_y << 6) + ((n == 2 || n == 3) ? 32 : 0);
409 if (qx + px < MV) px = MV - qx;
410 if (qy + py < MV) py = MV - qy;
411 if (qx + px > X) px = X - qx;
412 if (qy + py > Y) py = Y - qy;
417 hybridmv_thresh = 32;
418 if (a_valid && c_valid) {
419 if (is_intra[xy - wrap])
422 sum =
FFABS(px - field_predA[0]) +
FFABS(py - field_predA[1]);
423 if (sum > hybridmv_thresh) {
432 if (is_intra[xy - 1])
435 sum =
FFABS(px - field_predC[0]) +
FFABS(py - field_predC[1]);
436 if (sum > hybridmv_thresh) {
471 int mvn,
int r_x,
int r_y,
uint8_t* is_intra,
int dir)
474 int xy,
wrap, off = 0;
475 int A[2],
B[2],
C[2];
477 int a_valid = 0, b_valid = 0, c_valid = 0;
478 int field_a, field_b, field_c;
479 int total_valid, num_samefield, num_oppfield;
480 int pos_c, pos_b, n_adj;
508 off = ((n == 0) || (n == 1)) ? 1 : -1;
510 if (s->
mb_x || (n == 1) || (n == 3)) {
530 B[0] = B[1] = C[0] = C[1] = 0;
538 n_adj = (n & 2) | (n & 1);
592 total_valid = a_valid + b_valid + c_valid;
594 if (!s->
mb_x && !(n == 1 || n == 3)) {
599 B[0] = B[1] = C[0] = C[1] = 0;
606 if (total_valid >= 2) {
609 }
else if (total_valid) {
610 if (a_valid) { px = A[0]; py = A[1]; }
611 else if (b_valid) { px = B[0]; py = B[1]; }
612 else { px = C[0]; py = C[1]; }
617 field_a = (A[1] & 4) ? 1 : 0;
621 field_b = (B[1] & 4) ? 1 : 0;
625 field_c = (C[1] & 4) ? 1 : 0;
629 num_oppfield = field_a + field_b + field_c;
630 num_samefield = total_valid - num_oppfield;
631 if (total_valid == 3) {
632 if ((num_samefield == 3) || (num_oppfield == 3)) {
635 }
else if (num_samefield >= num_oppfield) {
638 px = !field_a ? A[0] : B[0];
639 py = !field_a ? A[1] : B[1];
641 px = field_a ? A[0] : B[0];
642 py = field_a ? A[1] : B[1];
644 }
else if (total_valid == 2) {
645 if (num_samefield >= num_oppfield) {
646 if (!field_a && a_valid) {
649 }
else if (!field_b && b_valid) {
658 if (field_a && a_valid) {
667 }
else if (total_valid == 1) {
668 px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);
669 py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]);
683 }
else if (mvn == 2) {
686 s->
mv[dir][n + 1][0] = s->
mv[dir][n][0];
687 s->
mv[dir][n + 1][1] = s->
mv[dir][n][1];
695 int xy,
wrap, off = 0;
751 if (!s->
mb_x) C[0] = C[1] = 0;
760 }
else if (s->
mb_x) {
770 int MV = 4 - (1 << sh);
771 qx = (s->
mb_x << sh);
772 qy = (s->
mb_y << sh);
775 if (qx + px < MV) px = MV - qx;
776 if (qy + py < MV) py = MV - qy;
777 if (qx + px > X) px = X - qx;
778 if (qy + py > Y) py = Y - qy;
782 if (is_intra[xy - wrap])
795 if (is_intra[xy - 2])
811 s->
mv[0][0][0] = ((px + dmv_x[0] + r_x) & ((r_x << 1) - 1)) - r_x;
812 s->
mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y;
830 }
else if (s->
mb_x) {
840 int MV = 4 - (1 << sh);
841 qx = (s->
mb_x << sh);
842 qy = (s->
mb_y << sh);
845 if (qx + px < MV) px = MV - qx;
846 if (qy + py < MV) py = MV - qy;
847 if (qx + px > X) px = X - qx;
848 if (qy + py > Y) py = Y - qy;
852 if (is_intra[xy - wrap])
865 if (is_intra[xy - 2])
882 s->
mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x;
883 s->
mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y;
892 int mv1,
int *pred_flag)
914 f = (total_opp > 2) ? 1 : 0;
916 s->
mv[0][0][0] = s->
mv[0][0][1] = 0;
917 s->
mv[1][0][0] = s->
mv[1][0][1] = 0;
921 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)
static void direct(const float *in, const FFTComplex *ir, int len, float *out)
int quarter_sample
1->qpel, 0->half pel ME/MC
int res_rtm_flag
reserved, set to 1
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]
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
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
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
int first_slice_line
used in MPEG-4 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)