43 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
46 uint8_t (*luty)[256], (*lutuv)[256];
54 mx = s->
mv[dir][0][0];
55 my = s->
mv[dir][0][1];
59 for (i = 0; i < 4; i++) {
65 uvmx = (mx + ((mx & 3) == 3)) >> 1;
66 uvmy = (my + ((my & 3) == 3)) >> 1;
78 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
79 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
106 if (!srcY || !srcU) {
111 src_x = s->
mb_x * 16 + (mx >> 2);
112 src_y = s->
mb_y * 16 + (my >> 2);
113 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
114 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
117 src_x = av_clip( src_x, -16, s->
mb_width * 16);
118 src_y = av_clip( src_y, -16, s->
mb_height * 16);
119 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
120 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
128 srcY += src_y * s->
linesize + src_x;
147 || (
unsigned)(src_y - 1) > v_edge_pos - (my&3) - 16 - 3) {
160 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
164 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
173 for (j = 0; j < 17 + s->
mspel * 2; j++) {
174 for (i = 0; i < 17 + s->
mspel * 2; i++)
175 src[i] = ((src[i] - 128) >> 1) + 128;
180 for (j = 0; j < 9; j++) {
181 for (i = 0; i < 9; i++) {
182 src[i] = ((src[i] - 128) >> 1) + 128;
183 src2[i] = ((src2[i] - 128) >> 1) + 128;
195 for (j = 0; j < 17 + s->
mspel * 2; j++) {
197 for (i = 0; i < 17 + s->
mspel * 2; i++)
198 src[i] = luty[f][src[i]];
203 for (j = 0; j < 9; j++) {
205 for (i = 0; i < 9; i++) {
206 src[i] = lutuv[f][src[i]];
207 src2[i] = lutuv[f][src2[i]];
217 dxy = ((my & 3) << 2) | (mx & 3);
224 dxy = (my & 2) | ((mx & 2) >> 1);
234 uvmx = (uvmx & 3) << 1;
235 uvmy = (uvmy & 3) << 1;
248 if (c < d)
return (
FFMIN(b, d) +
FFMAX(a, c)) / 2;
251 if (c < d)
return (
FFMIN(a, d) +
FFMAX(b, c)) / 2;
262 int dxy, mx, my, src_x, src_y;
274 mx = s->
mv[dir][n][0];
275 my = s->
mv[dir][n][1];
304 int same_count = 0, opp_count = 0, k;
305 int chosen_mv[2][4][2], f;
307 for (k = 0; k < 4; k++) {
309 chosen_mv[f][f ? opp_count : same_count][0] = s->
mv[0][k][0];
310 chosen_mv[f][f ? opp_count : same_count][1] = s->
mv[0][k][1];
314 f = opp_count > same_count;
315 switch (f ? opp_count : same_count) {
317 tx =
median4(chosen_mv[f][0][0], chosen_mv[f][1][0],
318 chosen_mv[f][2][0], chosen_mv[f][3][0]);
319 ty =
median4(chosen_mv[f][0][1], chosen_mv[f][1][1],
320 chosen_mv[f][2][1], chosen_mv[f][3][1]);
323 tx =
mid_pred(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0]);
324 ty =
mid_pred(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1]);
327 tx = (chosen_mv[f][0][0] + chosen_mv[f][1][0]) / 2;
328 ty = (chosen_mv[f][0][1] + chosen_mv[f][1][1]) / 2;
333 for (k = 0; k < 4; k++)
345 qx = (s->
mb_x * 16) + (mx >> 2);
346 qy = (s->
mb_y * 8) + (my >> 3);
351 mx -= 4 * (qx -
width);
354 else if (qy > height + 1)
355 my -= 8 * (qy - height - 1);
359 off = ((n > 1) ? s->
linesize : 0) + (n & 1) * 8;
361 off = s->
linesize * 4 * (n & 2) + (n & 1) * 8;
363 src_x = s->
mb_x * 16 + (n & 1) * 8 + (mx >> 2);
365 src_y = s->
mb_y * 16 + (n & 2) * 4 + (my >> 2);
367 src_y = s->
mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
370 src_x = av_clip(src_x, -16, s->
mb_width * 16);
371 src_y = av_clip(src_y, -16, s->
mb_height * 16);
384 srcY += src_y * s->
linesize + src_x;
388 if (fieldmv && !(src_y & 1))
390 if (fieldmv && (src_y & 1) && src_y < 4)
395 || (
unsigned)(src_y - (s->
mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->
mspel * 2) << fieldmv)) {
400 9 + s->
mspel * 2, (9 + s->
mspel * 2) << fieldmv,
401 src_x - s->
mspel, src_y - (s->
mspel << fieldmv),
410 for (j = 0; j < 9 + s->
mspel * 2; j++) {
411 for (i = 0; i < 9 + s->
mspel * 2; i++)
412 src[i] = ((src[i] - 128) >> 1) + 128;
422 for (j = 0; j < 9 + s->
mspel * 2; j++) {
424 for (i = 0; i < 9 + s->
mspel * 2; i++)
425 src[i] = luty[f][src[i]];
433 dxy = ((my & 3) << 2) | (mx & 3);
439 dxy = (my & 2) | ((mx & 2) >> 1);
450 static const int count[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
452 idx = ((a[3] !=
flag) << 3)
453 | ((a[2] !=
flag) << 2)
454 | ((a[1] !=
flag) << 1)
457 *tx =
median4(mvx[0], mvx[1], mvx[2], mvx[3]);
458 *ty =
median4(mvy[0], mvy[1], mvy[2], mvy[3]);
460 }
else if (count[idx] == 1) {
463 *tx =
mid_pred(mvx[1], mvx[2], mvx[3]);
464 *ty =
mid_pred(mvy[1], mvy[2], mvy[3]);
467 *tx =
mid_pred(mvx[0], mvx[2], mvx[3]);
468 *ty =
mid_pred(mvy[0], mvy[2], mvy[3]);
471 *tx =
mid_pred(mvx[0], mvx[1], mvx[3]);
472 *ty =
mid_pred(mvy[0], mvy[1], mvy[3]);
475 *tx =
mid_pred(mvx[0], mvx[1], mvx[2]);
476 *ty =
mid_pred(mvy[0], mvy[1], mvy[2]);
479 }
else if (count[idx] == 2) {
481 for (i = 0; i < 3; i++)
486 for (i = t1 + 1; i < 4; i++)
491 *tx = (mvx[t1] + mvx[t2]) / 2;
492 *ty = (mvy[t1] + mvy[t2]) / 2;
507 int uvmx, uvmy, uvsrc_x, uvsrc_y;
508 int k, tx = 0, ty = 0;
509 int mvx[4], mvy[4], intra[4], mv_f[4];
521 for (k = 0; k < 4; k++) {
522 mvx[k] = s->
mv[dir][k][0];
523 mvy[k] = s->
mv[dir][k][1];
541 if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2)
543 valid_count =
get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty);
551 uvmx = (tx + ((tx & 3) == 3)) >> 1;
552 uvmy = (ty + ((ty & 3) == 3)) >> 1;
558 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
559 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
563 uvmy += 2 - 4 * chroma_ref_type;
565 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
566 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
569 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
570 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
604 if (chroma_ref_type) {
612 || (
unsigned)uvsrc_x > (s->
h_edge_pos >> 1) - 9
613 || (
unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
616 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
620 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
632 for (j = 0; j < 9; j++) {
633 for (i = 0; i < 9; i++) {
634 src[i] = ((src[i] - 128) >> 1) + 128;
635 src2[i] = ((src2[i] - 128) >> 1) + 128;
648 for (j = 0; j < 9; j++) {
649 int f = v->
field_mode ? chroma_ref_type : ((j + uvsrc_y) & 1);
650 for (i = 0; i < 9; i++) {
651 src[i] = lutuv[f][src[i]];
652 src2[i] = lutuv[f][src2[i]];
661 uvmx = (uvmx & 3) << 1;
662 uvmy = (uvmy & 3) << 1;
679 int uvsrc_x, uvsrc_y;
680 int uvmx_field[4], uvmy_field[4];
683 static const int s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 };
684 int v_dist = fieldmv ? 1 : 4;
692 for (i = 0; i < 4; i++) {
693 int d = i < 2 ? dir: dir2;
695 uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1;
698 uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF];
700 uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1;
703 for (i = 0; i < 4; i++) {
704 off = (i & 1) * 4 + ((i & 2) ? v_dist * s->
uvlinesize : 0);
705 uvsrc_x = s->
mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2);
706 uvsrc_y = s->
mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2);
710 if (i < 2 ? dir : dir2) {
721 uvmx_field[i] = (uvmx_field[i] & 3) << 1;
722 uvmy_field[i] = (uvmy_field[i] & 3) << 1;
724 if (fieldmv && !(uvsrc_y & 1))
726 if (fieldmv && (uvsrc_y & 1) && uvsrc_y < 2)
729 || s->
h_edge_pos < 10 || v_edge_pos < (5 << fieldmv)
730 || (unsigned)uvsrc_x > (s->
h_edge_pos >> 1) - 5
731 || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) {
734 5, (5 << fieldmv), uvsrc_x, uvsrc_y,
738 5, (5 << fieldmv), uvsrc_x, uvsrc_y,
750 for (j = 0; j < 5; j++) {
751 int f = (uvsrc_y + (j << fieldmv)) & 1;
752 for (i = 0; i < 5; i++) {
753 src[i] = lutuv[f][src[i]];
754 src2[i] = lutuv[f][src2[i]];
788 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
798 uvmx = (mx + ((mx & 3) == 3)) >> 1;
799 uvmy = (my + ((my & 3) == 3)) >> 1;
805 uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
806 uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1));
812 src_x = s->
mb_x * 16 + (mx >> 2);
813 src_y = s->
mb_y * 16 + (my >> 2);
814 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
815 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
818 src_x = av_clip( src_x, -16, s->
mb_width * 16);
819 src_y = av_clip( src_y, -16, s->
mb_height * 16);
820 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
821 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
829 srcY += src_y * s->
linesize + src_x;
846 || (
unsigned)(src_x - 1) > s->
h_edge_pos - (mx & 3) - 16 - 3
847 || (
unsigned)(src_y - 1) > v_edge_pos - (my & 3) - 16 - 3) {
860 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
864 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
873 for (j = 0; j < 17 + s->
mspel * 2; j++) {
874 for (i = 0; i < 17 + s->
mspel * 2; i++)
875 src[i] = ((src[i] - 128) >> 1) + 128;
880 for (j = 0; j < 9; j++) {
881 for (i = 0; i < 9; i++) {
882 src[i] = ((src[i] - 128) >> 1) + 128;
883 src2[i] = ((src2[i] - 128) >> 1) + 128;
897 for (j = 0; j < 17 + s->
mspel * 2; j++) {
899 for (i = 0; i < 17 + s->
mspel * 2; i++)
900 src[i] = luty[f][src[i]];
905 for (j = 0; j < 9; j++) {
907 for (i = 0; i < 9; i++) {
908 src[i] = lutuv[f][src[i]];
909 src2[i] = lutuv[f][src2[i]];
922 dxy = ((my & 3) << 2) | (mx & 3);
929 dxy = (my & 2) | ((mx & 2) >> 1);
940 uvmx = (uvmx & 3) << 1;
941 uvmy = (uvmy & 3) << 1;
op_pixels_func avg_vc1_mspel_pixels_tab[16]
int reffield
if numref = 0 (1 reference) then reffield decides which
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
int coded_width
Bitstream width / height, may be different from width/height e.g.
op_pixels_func avg_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
int v_edge_pos
horizontal / vertical position of the right/bottom edge (pixel replication)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
uint8_t rangeredfrm
Frame decoding info for S/M profiles only.
uint8_t * mv_f[2]
0: MV obtained from same field, 1: opposite field
int fastuvmc
Rounding of qpel vector to hpel ? (not in Simple)
void ff_vc1_interp_mc(VC1Context *v)
Motion compensation for direct or interpolated blocks in B-frames.
Picture current_picture
copy of the current picture structure.
int profile
Sequence header data for all Profiles TODO: choose between ints, uint8_ts and monobit flags...
void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
Do motion compensation for 4-MV macroblock - luminance block.
uint8_t last_luty[2][256]
int mb_height
number of MBs horizontally & vertically
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
uint8_t last_lutuv[2][256]
lookup tables used for intensity compensation
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int flags
AV_CODEC_FLAG_*.
uint8_t * blk_mv_type
0: frame MV, 1: field MV (interlaced frame)
int cur_field_type
0: top, 1: bottom
int field_mode
1 for interlaced field pictures
int16_t(*[2] motion_val)[2]
Picture * current_picture_ptr
pointer to the current picture
void(* emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t buf_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
static av_always_inline int get_chroma_mv(int *mvx, int *mvy, int *a, int flag, int *tx, int *ty)
h264_chroma_mc_func avg_h264_chroma_pixels_tab[3]
int block_index[6]
index to current MB in block based arrays with edges
h264_chroma_mc_func avg_no_rnd_vc1_chroma_pixels_tab[3]
Libavcodec external API header.
ptrdiff_t linesize
line size, in bytes, may be different from width
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
op_pixels_func put_no_rnd_pixels_tab[4][4]
Halfpel motion compensation with no rounding (a+b)>>1.
void ff_vc1_mc_1mv(VC1Context *v, int dir)
Do motion compensation over 1 macroblock Mostly adapted hpel_motion and qpel_motion from mpegvideo...
void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg)
Do motion compensation for 4-MV interlaced frame chroma macroblock (both U and V) ...
ptrdiff_t uvlinesize
line size, for chroma in bytes, may be different from width
uint8_t next_lutuv[2][256]
lookup tables used for intensity compensation
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
h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int mv[2][4][2]
motion vectors for a macroblock first coordinate : 0 = forward 1 = backward second " : depend...
in the bitstream is reported as 10b
struct AVCodecContext * avctx
enum FrameCodingMode fcm
Frame decoding info for Advanced profile.
Picture last_picture
copy of the previous picture structure.
uint8_t next_luty[2][256]
h264_chroma_mc_func put_h264_chroma_pixels_tab[3]
op_pixels_func avg_no_rnd_pixels_tab[4]
Halfpel motion compensation with no rounding (a+b)>>1.
uint8_t(* curr_luty)[256]
Picture next_picture
copy of the next picture structure.
static int median4(int a, int b, int c, int d)
H264ChromaContext h264chroma
void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir)
Do motion compensation for 4-MV macroblock - both chroma blocks.
uint8_t((* curr_lutuv)[256]
op_pixels_func put_vc1_mspel_pixels_tab[16]