39 for (j = 0; j < k; j++) {
40 for (i = 0; i < k; i++)
41 srcY[i] = ((srcY[i] - 128) >> 1) + 128;
47 int k,
int uvlinesize)
50 for (j = 0; j < k; j++) {
51 for (i = 0; i < k; i++) {
52 srcU[i] = ((srcU[i] - 128) >> 1) + 128;
53 srcV[i] = ((srcV[i] - 128) >> 1) + 128;
66 for (j = 0; j < k; j += 2) {
67 for (i = 0; i < k; i++)
68 srcY[i] = lut1[srcY[i]];
74 for (i = 0; i < k; i++)
75 srcY[i] = lut2[srcY[i]];
82 int k,
int uvlinesize)
86 for (j = 0; j < k; j += 2) {
87 for (i = 0; i < k; i++) {
88 srcU[i] = lut1[srcU[i]];
89 srcV[i] = lut1[srcV[i]];
97 for (i = 0; i < k; i++) {
98 srcU[i] = lut2[srcU[i]];
99 srcV[i] = lut2[srcV[i]];
106 static const uint8_t popcount4[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
115 static const uint8_t index2[16] = { 0, 0, 0, 0x23, 0, 0x13, 0x03, 0, 0, 0x12, 0x02, 0, 0x01, 0, 0, 0 };
121 *tx =
median4(s->
mv[dir][0][0], s->
mv[dir][1][0], s->
mv[dir][2][0], s->
mv[dir][3][0]);
122 *ty =
median4(s->
mv[dir][0][1], s->
mv[dir][1][1], s->
mv[dir][2][1], s->
mv[dir][3][1]);
125 *tx =
mid_pred(s->
mv[dir][idx < 2][0], s->
mv[dir][1 + (idx < 4)][0], s->
mv[dir][2 + (idx < 8)][0]);
126 *ty =
mid_pred(s->
mv[dir][idx < 2][1], s->
mv[dir][1 + (idx < 4)][1], s->
mv[dir][2 + (idx < 8)][1]);
129 *tx =
mid_pred(s->
mv[dir][idx > 0xd][0], s->
mv[dir][1 + (idx > 0xb)][0], s->
mv[dir][2 + (idx > 0x7)][0]);
130 *ty =
mid_pred(s->
mv[dir][idx > 0xd][1], s->
mv[dir][1 + (idx > 0xb)][1], s->
mv[dir][2 + (idx > 0x7)][1]);
133 *tx = (s->
mv[dir][index2[idx] >> 4][0] + s->
mv[dir][index2[idx] & 0xf][0]) / 2;
134 *ty = (s->
mv[dir][index2[idx] >> 4][1] + s->
mv[dir][index2[idx] & 0xf][1]) / 2;
147 static const uint8_t index2[16] = { 0, 0, 0, 0x01, 0, 0x02, 0x12, 0, 0, 0x03, 0x13, 0, 0x23, 0, 0, 0 };
150 switch (valid_count) {
152 *tx =
median4(s->
mv[dir][0][0], s->
mv[dir][1][0], s->
mv[dir][2][0], s->
mv[dir][3][0]);
153 *ty =
median4(s->
mv[dir][0][1], s->
mv[dir][1][1], s->
mv[dir][2][1], s->
mv[dir][3][1]);
156 *tx =
mid_pred(s->
mv[dir][idx > 0xd][0], s->
mv[dir][1 + (idx > 0xb)][0], s->
mv[dir][2 + (idx > 0x7)][0]);
157 *ty =
mid_pred(s->
mv[dir][idx > 0xd][1], s->
mv[dir][1 + (idx > 0xb)][1], s->
mv[dir][2 + (idx > 0x7)][1]);
160 *tx = (s->
mv[dir][index2[idx] >> 4][0] + s->
mv[dir][index2[idx] & 0xf][0]) / 2;
161 *ty = (s->
mv[dir][index2[idx] >> 4][1] + s->
mv[dir][index2[idx] & 0xf][1]) / 2;
177 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
180 uint8_t (*luty)[256], (*lutuv)[256];
188 mx = s->
mv[dir][0][0];
189 my = s->
mv[dir][0][1];
193 for (i = 0; i < 4; i++) {
199 uvmx = (mx + ((mx & 3) == 3)) >> 1;
200 uvmy = (my + ((my & 3) == 3)) >> 1;
212 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
213 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
240 if (!srcY || !srcU) {
245 src_x = s->
mb_x * 16 + (mx >> 2);
246 src_y = s->
mb_y * 16 + (my >> 2);
247 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
248 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
251 src_x = av_clip( src_x, -16, s->
mb_width * 16);
252 src_y = av_clip( src_y, -16, s->
mb_height * 16);
253 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
254 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
262 srcY += src_y * s->
linesize + src_x;
281 || (
unsigned)(src_y - 1) > v_edge_pos - (my&3) - 16 - 3) {
284 const int k = 17 + s->
mspel * 2;
325 dxy = ((my & 3) << 2) | (mx & 3);
328 dxy = (my & 2) | ((mx & 2) >> 1);
338 uvmx = (uvmx & 3) << 1;
339 uvmy = (uvmy & 3) << 1;
355 int dxy, mx, my, src_x, src_y;
367 mx = s->
mv[dir][
n][0];
368 my = s->
mv[dir][
n][1];
400 int k, f = opp_count > 2;
401 for (k = 0; k < 4; k++)
413 qx = (s->
mb_x * 16) + (mx >> 2);
414 qy = (s->
mb_y * 8) + (my >> 3);
419 mx -= 4 * (qx -
width);
422 else if (qy > height + 1)
423 my -= 8 * (qy - height - 1);
427 off = ((n > 1) ? s->
linesize : 0) + (n & 1) * 8;
429 off = s->
linesize * 4 * (n & 2) + (n & 1) * 8;
431 src_x = s->
mb_x * 16 + (n & 1) * 8 + (mx >> 2);
433 src_y = s->
mb_y * 16 + (n & 2) * 4 + (my >> 2);
435 src_y = s->
mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
438 src_x = av_clip(src_x, -16, s->
mb_width * 16);
439 src_y = av_clip(src_y, -16, s->
mb_height * 16);
452 srcY += src_y * s->
linesize + src_x;
460 src_y -= (src_y < 4);
465 || (unsigned)(src_y - (s->
mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->
mspel * 2) << fieldmv)) {
466 const int k = 9 + s->
mspel * 2;
473 src_x - s->
mspel, src_y - (s->
mspel << fieldmv),
491 dxy = ((my & 3) << 2) | (mx & 3);
497 dxy = (my & 2) | ((mx & 2) >> 1);
512 int uvmx, uvmy, uvsrc_x, uvsrc_y;
542 uvmx = (tx + ((tx & 3) == 3)) >> 1;
543 uvmy = (ty + ((ty & 3) == 3)) >> 1;
549 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
550 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
554 uvmy += 2 - 4 * chroma_ref_type;
556 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
557 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
560 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
561 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
595 if (chroma_ref_type) {
603 || (
unsigned)uvsrc_x > (s->
h_edge_pos >> 1) - 9
604 || (
unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
607 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
611 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
623 lutuv[v->
field_mode ? chroma_ref_type : ((0 + uvsrc_y) & 1)],
624 lutuv[v->
field_mode ? chroma_ref_type : ((1 + uvsrc_y) & 1)],
630 uvmx = (uvmx & 3) << 1;
631 uvmy = (uvmy & 3) << 1;
648 int uvsrc_x, uvsrc_y;
649 int uvmx_field[4], uvmy_field[4];
652 static const uint8_t s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 };
653 int v_dist = fieldmv ? 1 : 4;
661 for (i = 0; i < 4; i++) {
662 int d = i < 2 ? dir: dir2;
664 uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1;
667 uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF];
669 uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1;
672 for (i = 0; i < 4; i++) {
673 off = (i & 1) * 4 + ((i & 2) ? v_dist * s->
uvlinesize : 0);
674 uvsrc_x = s->
mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2);
675 uvsrc_y = s->
mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2);
679 if (i < 2 ? dir : dir2) {
694 uvmx_field[i] = (uvmx_field[i] & 3) << 1;
695 uvmy_field[i] = (uvmy_field[i] & 3) << 1;
701 uvsrc_y -= (uvsrc_y < 2);
704 || s->
h_edge_pos < 10 || v_edge_pos < (5 << fieldmv)
705 || (unsigned)uvsrc_x > (s->
h_edge_pos >> 1) - 5
706 || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) {
709 5, (5 << fieldmv), uvsrc_x, uvsrc_y,
713 5, (5 << fieldmv), uvsrc_x, uvsrc_y,
721 lutuv[(uvsrc_y + (0 << fieldmv)) & 1],
722 lutuv[(uvsrc_y + (1 << fieldmv)) & 1],
753 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
762 uvmx = (mx + ((mx & 3) == 3)) >> 1;
763 uvmy = (my + ((my & 3) == 3)) >> 1;
769 uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
770 uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1));
776 src_x = s->
mb_x * 16 + (mx >> 2);
777 src_y = s->
mb_y * 16 + (my >> 2);
778 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
779 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
782 src_x = av_clip( src_x, -16, s->
mb_width * 16);
783 src_y = av_clip( src_y, -16, s->
mb_height * 16);
784 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
785 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
793 srcY += src_y * s->
linesize + src_x;
810 || (
unsigned)(src_x - 1) > s->
h_edge_pos - (mx & 3) - 16 - 3
811 || (
unsigned)(src_y - 1) > v_edge_pos - (my & 3) - 16 - 3) {
814 const int k = 17 + s->
mspel * 2;
857 dxy = ((my & 3) << 2) | (mx & 3);
860 dxy = (my & 2) | ((mx & 2) >> 1);
871 uvmx = (uvmx & 3) << 1;
872 uvmy = (uvmy & 3) << 1;
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.
static av_always_inline void vc1_lut_scale_luma(uint8_t *srcY, uint8_t *lut1, uint8_t *lut2, int k, int linesize)
int v_edge_pos
horizontal / vertical position of the right/bottom edge (pixel replication)
h264_chroma_mc_func put_h264_chroma_pixels_tab[4]
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)
vc1op_pixels_func put_vc1_mspel_pixels_tab[2][16]
static const uint8_t popcount4[16]
static av_always_inline void vc1_scale_luma(uint8_t *srcY, int k, int linesize)
void(* emulated_edge_mc)(uint8_t *dst, const uint8_t *src, ptrdiff_t dst_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...
void ff_vc1_interp_mc(VC1Context *v)
Motion compensation for direct or interpolated blocks in B-frames.
static av_always_inline int get_luma_mv(VC1Context *v, int dir, int16_t *tx, int16_t *ty)
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
static av_always_inline int get_chroma_mv(VC1Context *v, int dir, int16_t *tx, int16_t *ty)
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.
static av_always_inline void vc1_scale_chroma(uint8_t *srcU, uint8_t *srcV, int k, int uvlinesize)
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
vc1op_pixels_func avg_vc1_mspel_pixels_tab[2][16]
BYTE int const BYTE int int int height
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 avg_h264_chroma_pixels_tab[4]
static av_always_inline void vc1_lut_scale_chroma(uint8_t *srcU, uint8_t *srcV, uint8_t *lut1, uint8_t *lut2, int k, int uvlinesize)
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.
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]