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];
183 int linesize, uvlinesize;
193 mx = s->
mv[dir][0][0];
194 my = s->
mv[dir][0][1];
198 for (i = 0; i < 4; i++) {
204 uvmx = (mx + ((mx & 3) == 3)) >> 1;
205 uvmy = (my + ((my & 3) == 3)) >> 1;
217 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
218 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
248 if (!srcY || !srcU) {
253 src_x = s->
mb_x * 16 + (mx >> 2);
254 src_y = s->
mb_y * 16 + (my >> 2);
255 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
256 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
259 src_x = av_clip( src_x, -16, s->
mb_width * 16);
260 src_y = av_clip( src_y, -16, s->
mb_height * 16);
261 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
262 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
268 uvsrc_y = av_clip(uvsrc_y, -8 + (uvsrc_y & 1), (s->
avctx->
coded_height >> 1) + (uvsrc_y & 1));
275 srcY += src_y * s->
linesize + src_x;
294 || (
unsigned)(src_y - 1) > v_edge_pos - (my&3) - 16 - 3) {
297 const int k = 17 + s->
mspel * 2;
319 src_y - s->
mspel + 1 >> 1,
422 dxy = ((my & 3) << 2) | (mx & 3);
425 dxy = (my & 2) | ((mx & 2) >> 1);
435 uvmx = (uvmx & 3) << 1;
436 uvmy = (uvmy & 3) << 1;
456 int dxy, mx, my, src_x, src_y;
472 mx = s->
mv[dir][
n][0];
473 my = s->
mv[dir][
n][1];
508 int k,
f = opp_count > 2;
509 for (k = 0; k < 4; k++)
521 qx = (s->
mb_x * 16) + (mx >> 2);
522 qy = (s->
mb_y * 8) + (my >> 3);
527 mx -= 4 * (qx -
width);
530 else if (qy > height + 1)
531 my -= 8 * (qy - height - 1);
535 off = ((n > 1) ? s->
linesize : 0) + (n & 1) * 8;
537 off = s->
linesize * 4 * (n & 2) + (n & 1) * 8;
539 src_x = s->
mb_x * 16 + (n & 1) * 8 + (mx >> 2);
541 src_y = s->
mb_y * 16 + (n & 2) * 4 + (my >> 2);
543 src_y = s->
mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
546 src_x = av_clip(src_x, -16, s->
mb_width * 16);
547 src_y = av_clip(src_y, -16, s->
mb_height * 16);
556 srcY += src_y * s->
linesize + src_x;
563 || (
unsigned)(src_y - (s->
mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->
mspel * 2) << fieldmv)) {
564 const int k = 9 + s->
mspel * 2;
587 src_y - s->
mspel + 1 >> 1,
599 src_y - (s->
mspel << fieldmv),
618 dxy = ((my & 3) << 2) | (mx & 3);
624 dxy = (my & 2) | ((mx & 2) >> 1);
639 int uvmx, uvmy, uvsrc_x, uvsrc_y;
674 uvmx = (tx + ((tx & 3) == 3)) >> 1;
675 uvmy = (ty + ((ty & 3) == 3)) >> 1;
681 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
682 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
686 uvmy += 2 - 4 * chroma_ref_type;
688 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
689 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
692 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
693 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
730 if (chroma_ref_type) {
738 || (
unsigned)uvsrc_x > (s->
h_edge_pos >> 1) - 9
739 || (
unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
791 v->
field_mode ? 2 * uvsrc_y + chroma_ref_type : uvsrc_y,
801 v->
field_mode ? 2 * uvsrc_y + chroma_ref_type : uvsrc_y,
815 lutuv[v->
field_mode ? chroma_ref_type : ((0 + uvsrc_y) & 1)],
816 lutuv[v->
field_mode ? chroma_ref_type : ((1 + uvsrc_y) & 1)],
822 uvmx = (uvmx & 3) << 1;
823 uvmy = (uvmy & 3) << 1;
844 int uvsrc_x, uvsrc_y;
845 int uvmx_field[4], uvmy_field[4];
848 static const uint8_t s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 };
849 int v_dist = fieldmv ? 1 : 4;
861 for (i = 0; i < 4; i++) {
862 int d = i < 2 ? dir: dir2;
864 uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1;
867 uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF];
869 uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1;
872 for (i = 0; i < 4; i++) {
873 off = (i & 1) * 4 + ((i & 2) ? v_dist * s->
uvlinesize : 0);
874 uvsrc_x = s->
mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2);
875 uvsrc_y = s->
mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2);
879 uvsrc_y = av_clip(uvsrc_y, -8 + (uvsrc_y & 1), (s->
avctx->
coded_height >> 1) + (uvsrc_y & 1));
882 if (i < 2 ? dir : dir2) {
899 uvmx_field[i] = (uvmx_field[i] & 3) << 1;
900 uvmy_field[i] = (uvmy_field[i] & 3) << 1;
903 || s->
h_edge_pos < 10 || v_edge_pos < (5 << fieldmv)
904 || (unsigned)uvsrc_x > (s->
h_edge_pos >> 1) - 5
905 || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) {
912 (5 << fieldmv) + 1 >> 1,
922 (5 << fieldmv) + 1 >> 1,
977 lutuv[(uvsrc_y + (0 << fieldmv)) & 1],
978 lutuv[(uvsrc_y + (1 << fieldmv)) & 1],
1009 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
1013 int linesize, uvlinesize;
1021 mx = s->
mv[1][0][0];
1022 my = s->
mv[1][0][1];
1023 uvmx = (mx + ((mx & 3) == 3)) >> 1;
1024 uvmy = (my + ((my & 3) == 3)) >> 1;
1030 uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
1031 uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1));
1039 src_x = s->
mb_x * 16 + (mx >> 2);
1040 src_y = s->
mb_y * 16 + (my >> 2);
1041 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
1042 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
1045 src_x = av_clip( src_x, -16, s->
mb_width * 16);
1046 src_y = av_clip( src_y, -16, s->
mb_height * 16);
1047 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
1048 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
1053 src_y = av_clip(src_y, -18 + (src_y & 1), s->
avctx->
coded_height + (src_y & 1));
1054 uvsrc_y = av_clip(uvsrc_y, -8 + (uvsrc_y & 1), (s->
avctx->
coded_height >> 1) + (uvsrc_y & 1));
1061 srcY += src_y * s->
linesize + src_x;
1078 || (
unsigned)(src_x - 1) > s->
h_edge_pos - (mx & 3) - 16 - 3
1079 || (
unsigned)(src_y - 1) > v_edge_pos - (my & 3) - 16 - 3) {
1082 const int k = 17 + s->
mspel * 2;
1104 src_y - s->
mspel + 1 >> 1,
1209 dxy = ((my & 3) << 2) | (mx & 3);
1212 dxy = (my & 2) | ((mx & 2) >> 1);
1223 uvmx = (uvmx & 3) << 1;
1224 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 interlaced_frame
The content of the picture is interlaced.
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]
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]