38 int motion_x, motion_y;
47 src_x = av_clip(src_x, -16, s->
width);
48 if (src_x == s->
width)
50 src_y = av_clip(src_y, -16, s->
height);
57 ptr = ref_picture[0] + (src_y *
linesize) + src_x;
67 if((motion_x|motion_y)&7){
68 s->
dsp.
gmc1(dest_y , ptr , linesize, 16, motion_x&15, motion_y&15, 128 - s->
no_rounding);
69 s->
dsp.
gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->
no_rounding);
73 dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2);
89 src_x = av_clip(src_x, -8, s->
width>>1);
90 if (src_x == s->
width>>1)
92 src_y = av_clip(src_y, -8, s->
height>>1);
97 ptr = ref_picture[1] + offset;
106 s->
dsp.
gmc1(dest_cb, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->
no_rounding);
108 ptr = ref_picture[2] + offset;
113 s->
dsp.
gmc1(dest_cr, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->
no_rounding);
130 ptr = ref_picture[0];
135 s->
dsp.
gmc(dest_y, ptr, linesize, 16,
142 s->
dsp.
gmc(dest_y+8, ptr, linesize, 16,
155 ptr = ref_picture[1];
156 s->
dsp.
gmc(dest_cb, ptr, uvlinesize, 8,
164 ptr = ref_picture[2];
165 s->
dsp.
gmc(dest_cr, ptr, uvlinesize, 8,
176 int src_x,
int src_y,
178 int motion_x,
int motion_y)
183 src_x += motion_x >> 1;
184 src_y += motion_y >> 1;
187 src_x = av_clip(src_x, -16, s->
width);
188 if (src_x != s->
width)
190 src_y = av_clip(src_y, -16, s->
height);
192 dxy |= (motion_y & 1) << 1;
211 int motion_x,
int motion_y,
int h,
int is_mpeg12,
int mb_y)
213 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
214 int dxy, uvdxy, mx, my, src_x, src_y,
230 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
231 src_x = s->
mb_x* 16 + (motion_x >> 1);
232 src_y =( mb_y<<(4-field_based)) + (motion_y >> 1);
236 mx = (motion_x>>1)|(motion_x&1);
238 uvdxy = ((my & 1) << 1) | (mx & 1);
239 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
240 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
242 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
250 uvsrc_x = s->
mb_x*8 + mx;
251 uvsrc_y = mb_y*8 + my;
256 uvdxy = ((my & 1) << 1) | (mx & 1);
257 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
258 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
263 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
264 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
275 ptr_y = ref_picture[0] + src_y * linesize + src_x;
276 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
277 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
280 || (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y&1) - h , 0)){
284 "MPEG motion vector out of boundary (%d %d)\n", src_x, src_y);
289 src_x, src_y * (1 << field_based),
297 uvsrc_x, uvsrc_y * (1 << field_based),
302 uvsrc_x, uvsrc_y * (1 << field_based),
321 pix_op[0][dxy](dest_y, ptr_y,
linesize, h);
337 int field_select,
uint8_t **ref_picture,
339 int motion_x,
int motion_y,
int h,
int mb_y)
344 field_select, ref_picture, pix_op,
345 motion_x, motion_y, h, 1, mb_y);
349 field_select, ref_picture, pix_op,
350 motion_x, motion_y, h, 0, mb_y);
355 int bottom_field,
int field_select,
358 int motion_x,
int motion_y,
int h,
int mb_y)
363 bottom_field, field_select, ref_picture, pix_op,
364 motion_x, motion_y, h, 1, mb_y);
368 bottom_field, field_select, ref_picture, pix_op,
369 motion_x, motion_y, h, 0, mb_y);
378 uint8_t *
const right = src[3];
379 uint8_t *
const bottom= src[4];
380 #define OBMC_FILTER(x, t, l, m, r, b)\
381 dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
382 #define OBMC_FILTER4(x, t, l, m, r, b)\
383 OBMC_FILTER(x , t, l, m, r, b);\
384 OBMC_FILTER(x+1 , t, l, m, r, b);\
385 OBMC_FILTER(x +stride, t, l, m, r, b);\
386 OBMC_FILTER(x+1+stride, t, l, m, r, b);
427 int src_x,
int src_y,
438 if(i && mv[i][0]==mv[
MID][0] && mv[i][1]==mv[
MID][1]){
454 int field_based,
int bottom_field,
int field_select,
457 int motion_x,
int motion_y,
int h)
459 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
460 int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y,
v_edge_pos,
linesize,
uvlinesize;
462 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
463 src_x = s->
mb_x * 16 + (motion_x >> 2);
464 src_y = s->
mb_y * (16 >> field_based) + (motion_y >> 2);
467 linesize = s->
linesize << field_based;
474 static const int rtab[8]= {0,0,1,1,0,0,0,1};
475 mx= (motion_x>>1) + rtab[motion_x&7];
476 my= (motion_y>>1) + rtab[motion_y&7];
478 mx= (motion_x>>1)|(motion_x&1);
479 my= (motion_y>>1)|(motion_y&1);
487 uvdxy= (mx&1) | ((my&1)<<1);
491 uvsrc_x = s->
mb_x * 8 + mx;
492 uvsrc_y = s->
mb_y * (8 >> field_based) + my;
494 ptr_y = ref_picture[0] + src_y * linesize + src_x;
495 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
496 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
499 || (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y&3) - h , 0)){
502 src_x, src_y * (1 << field_based),
509 uvsrc_x, uvsrc_y * (1 << field_based),
513 uvsrc_x, uvsrc_y * (1 << field_based),
521 qpix_op[0][dxy](dest_y, ptr_y,
linesize);
536 qpix_op[1][dxy](dest_y , ptr_y ,
linesize);
537 qpix_op[1][dxy](dest_y+8, ptr_y+8,
linesize);
540 pix_op[1][uvdxy](dest_cr, ptr_cr,
uvlinesize, h >> 1);
541 pix_op[1][uvdxy](dest_cb, ptr_cb,
uvlinesize, h >> 1);
554 int dxy, emu=0, src_x, src_y, offset;
562 dxy = ((my & 1) << 1) | (mx & 1);
566 src_x = s->
mb_x * 8 + mx;
567 src_y = s->
mb_y * 8 + my;
568 src_x = av_clip(src_x, -8, (s->
width >> 1));
569 if (src_x == (s->
width >> 1))
571 src_y = av_clip(src_y, -8, (s->
height >> 1));
572 if (src_y == (s->
height >> 1))
576 ptr = ref_picture[1] + offset;
589 ptr = ref_picture[2] + offset;
603 const int mx= (s->
mv[dir][0][0]>>shift) + 16*s->
mb_x + 8;
604 const int my= (s->
mv[dir][0][1]>>shift) + 16*s->
mb_y;
630 int dxy, mx, my, src_x, src_y, motion_x, motion_y;
644 const int mot_xy= mb_x*2 + mb_y*2*mot_stride;
658 AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
659 AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
666 AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
667 AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
674 AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
675 AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
684 const int x= (i&1)+1;
685 const int y= (i>>1)+1;
687 {mv_cache[y][x ][0], mv_cache[y][x ][1]},
688 {mv_cache[y-1][x][0], mv_cache[y-1][x][1]},
689 {mv_cache[y][x-1][0], mv_cache[y][x-1][1]},
690 {mv_cache[y][x+1][0], mv_cache[y][x+1][1]},
691 {mv_cache[y+1][x][0], mv_cache[y+1][x][1]}};
695 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
721 ref_picture, pix_op, qpix_op,
722 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
727 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
732 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y);
741 motion_x = s->
mv[dir][i][0];
742 motion_y = s->
mv[dir][i][1];
744 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
745 src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
746 src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8;
749 src_x = av_clip(src_x, -16, s->
width);
750 if (src_x == s->
width)
752 src_y = av_clip(src_y, -16, s->
height);
756 ptr = ref_picture[0] + (src_y * s->
linesize) + (src_x);
767 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize;
768 qpix_op[1][dxy](dest, ptr, s->
linesize);
770 mx += s->
mv[dir][i][0]/2;
771 my += s->
mv[dir][i][1]/2;
777 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
779 s->
mv[dir][i][0], s->
mv[dir][i][1]);
781 mx += s->
mv[dir][i][0];
782 my += s->
mv[dir][i][1];
796 ref_picture, pix_op, qpix_op,
797 s->
mv[dir][i][0], s->
mv[dir][i][1], 8);
804 s->
mv[dir][0][0], s->
mv[dir][0][1], 8, mb_y);
809 s->
mv[dir][1][0], s->
mv[dir][1][1], 8, mb_y);
819 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y>>1);
828 ref2picture= ref_picture;
836 s->
mv[dir][i][0], s->
mv[dir][i][1] + 16*i, 8, mb_y>>1);
849 j, j^i, ref_picture, pix_op,
850 s->
mv[dir][2*i + j][0],
851 s->
mv[dir][2*i + j][1], 8, mb_y);
860 s->
mv[dir][2*i][0],s->
mv[dir][2*i][1],16, mb_y>>1);
886 ref_picture, pix_op, qpix_op, 1);
890 ref_picture, pix_op, qpix_op, 0);
#define LOCAL_ALIGNED_8(t, v,...)
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
void(* prefetch)(uint8_t *buf, ptrdiff_t stride, int h)
Prefetch memory into cache (if supported by hardware).
This structure describes decoded (raw) audio or video data.
static void gmc_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture)
#define MV_TYPE_FIELD
2 vectors, one per field
int sprite_warping_accuracy
#define FF_BUG_QPEL_CHROMA
int v_edge_pos
horizontal / vertical position of the right/bottom edge (pixel replication)
int obmc
overlapped block motion compensation
int real_sprite_warping_points
#define CONFIG_WMV2_DECODER
void(* emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t 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...
#define CONFIG_WMV2_ENCODER
static void chroma_4mv_motion(MpegEncContext *s, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture, op_pixels_func *pix_op, int mx, int my)
h263 chroma 4mv motion compensation.
enum OutputFormat out_format
output format
void(* qpel_mc_func)(uint8_t *dst, uint8_t *src, int stride)
int no_rounding
apply no rounding to motion compensation (MPEG4, msmpeg4, ...) for b-frames rounding mode is always 0...
Picture current_picture
copy of the current picture structure.
op_pixels_func avg_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
#define CONFIG_H261_ENCODER
int sprite_offset[2][2]
sprite offset[isChroma][isMVY]
static void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir)
static int ff_h263_round_chroma(int x)
int mb_skipped
MUST BE SET only during DECODING.
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
void av_log(void *avcl, int level, const char *fmt,...)
int quarter_sample
1->qpel, 0->half pel ME/MC
op_pixels_func put_no_rnd_pixels_tab[4][4]
Halfpel motion compensation with no rounding (a+b)>>1.
#define CODEC_FLAG_EMU_EDGE
int sprite_delta[2][2]
sprite_delta [isY][isMVY]
Picture * current_picture_ptr
pointer to the current picture
void ff_mspel_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture, op_pixels_func(*pix_op)[4], int motion_x, int motion_y, int h)
static void gmc1_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture)
preferred ID for MPEG-1/2 video decoding
static av_always_inline void mpeg_motion_internal(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_based, int bottom_field, int field_select, uint8_t **ref_picture, op_pixels_func(*pix_op)[4], int motion_x, int motion_y, int h, int is_mpeg12, int mb_y)
#define OBMC_FILTER4(x, t, l, m, r, b)
static av_always_inline void MPV_motion_internal(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, op_pixels_func(*pix_op)[4], qpel_mc_func(*qpix_op)[16], int is_mpeg12)
motion compensation of a single macroblock
int first_field
is 1 for the first field of a field picture 0 otherwise
void(* op_pixels_func)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
static const int8_t mv[256][2]
uint32_t * mb_type
macroblock type table mb_type_base + mb_width + 2
#define MV_TYPE_16X16
1 vector for the whole mb
static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int bottom_field, int field_select, uint8_t **ref_picture, op_pixels_func(*pix_op)[4], int motion_x, int motion_y, int h, int mb_y)
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
int height
picture size. must be a multiple of 16
int16_t(*[2] motion_val)[2]
motion vector table
#define MV_TYPE_16X8
2 vectors, one per 16x8 block
void(* gmc1)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x16, int y16, int rounder)
translational global motion compensation.
DSPContext dsp
pointers for accelerated dsp functions
static void mpeg_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_select, uint8_t **ref_picture, op_pixels_func(*pix_op)[4], int motion_x, int motion_y, int h, int mb_y)
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
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...
int b8_stride
2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
struct AVCodecContext * avctx
static void qpel_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_based, int bottom_field, int field_select, uint8_t **ref_picture, op_pixels_func(*pix_op)[4], qpel_mc_func(*qpix_op)[16], int motion_x, int motion_y, int h)
#define FF_BUG_QPEL_CHROMA2
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
void ff_MPV_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, op_pixels_func(*pix_op)[4], qpel_mc_func(*qpix_op)[16])
void(* gmc)(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
global motion compensation.
uint8_t * obmc_scratchpad
#define MV_TYPE_DMV
2 vectors, special mpeg2 Dual Prime Vectors
int linesize
line size, in bytes, may be different from width
int flags
AVCodecContext.flags (HQ, MV4, ...)
#define FF_BUG_HPEL_CHROMA
int workaround_bugs
workaround bugs in encoders which cannot be detected automatically
void ff_h261_loop_filter(MpegEncContext *s)
static int hpel_motion(MpegEncContext *s, uint8_t *dest, uint8_t *src, int src_x, int src_y, op_pixels_func *pix_op, int motion_x, int motion_y)
static void obmc_motion(MpegEncContext *s, uint8_t *dest, uint8_t *src, int src_x, int src_y, op_pixels_func *pix_op, int16_t mv[5][2])
#define MV_TYPE_8X8
4 vectors (h263, mpeg4 4MV)
int uvlinesize
line size, for chroma in bytes, may be different from width
#define CONFIG_H261_DECODER
static void put_obmc(uint8_t *dst, uint8_t *src[5], int stride)
#define OBMC_FILTER(x, t, l, m, r, b)