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;
213 int motion_x,
int motion_y,
int h,
int is_mpeg12,
int mb_y)
215 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
216 int dxy, uvdxy, mx, my, src_x, src_y,
232 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
233 src_x = s->
mb_x* 16 + (motion_x >> 1);
234 src_y =( mb_y<<(4-field_based)) + (motion_y >> 1);
238 mx = (motion_x>>1)|(motion_x&1);
240 uvdxy = ((my & 1) << 1) | (mx & 1);
241 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
242 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
244 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
252 uvsrc_x = s->
mb_x*8 + mx;
253 uvsrc_y = mb_y*8 + my;
258 uvdxy = ((my & 1) << 1) | (mx & 1);
259 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
260 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
265 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
266 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
277 ptr_y = ref_picture[0] + src_y * linesize + src_x;
278 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
279 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
282 || (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y&1) - h , 0)){
286 "MPEG motion vector out of boundary (%d %d)\n", src_x, src_y);
291 src_x, src_y<<field_based,
299 uvsrc_x, uvsrc_y<<field_based,
304 uvsrc_x, uvsrc_y<<field_based,
323 pix_op[0][dxy](dest_y, ptr_y,
linesize, h);
339 int field_select,
uint8_t **ref_picture,
341 int motion_x,
int motion_y,
int h,
int mb_y)
346 field_select, ref_picture, pix_op,
347 motion_x, motion_y, h, 1, mb_y);
351 field_select, ref_picture, pix_op,
352 motion_x, motion_y, h, 0, mb_y);
357 int bottom_field,
int field_select,
360 int motion_x,
int motion_y,
int h,
int mb_y)
365 bottom_field, field_select, ref_picture, pix_op,
366 motion_x, motion_y, h, 1, mb_y);
370 bottom_field, field_select, ref_picture, pix_op,
371 motion_x, motion_y, h, 0, mb_y);
380 uint8_t *
const right = src[3];
381 uint8_t *
const bottom= src[4];
382 #define OBMC_FILTER(x, t, l, m, r, b)\
383 dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
384 #define OBMC_FILTER4(x, t, l, m, r, b)\
385 OBMC_FILTER(x , t, l, m, r, b);\
386 OBMC_FILTER(x+1 , t, l, m, r, b);\
387 OBMC_FILTER(x +stride, t, l, m, r, b);\
388 OBMC_FILTER(x+1+stride, t, l, m, r, b);
429 int src_x,
int src_y,
440 if(i && mv[i][0]==mv[
MID][0] && mv[i][1]==mv[
MID][1]){
456 int field_based,
int bottom_field,
int field_select,
459 int motion_x,
int motion_y,
int h)
461 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
462 int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y,
v_edge_pos,
linesize,
uvlinesize;
464 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
465 src_x = s->
mb_x * 16 + (motion_x >> 2);
466 src_y = s->
mb_y * (16 >> field_based) + (motion_y >> 2);
469 linesize = s->
linesize << field_based;
476 static const int rtab[8]= {0,0,1,1,0,0,0,1};
477 mx= (motion_x>>1) + rtab[motion_x&7];
478 my= (motion_y>>1) + rtab[motion_y&7];
480 mx= (motion_x>>1)|(motion_x&1);
481 my= (motion_y>>1)|(motion_y&1);
489 uvdxy= (mx&1) | ((my&1)<<1);
493 uvsrc_x = s->
mb_x * 8 + mx;
494 uvsrc_y = s->
mb_y * (8 >> field_based) + my;
496 ptr_y = ref_picture[0] + src_y * linesize + src_x;
497 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
498 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
501 || (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y&3) - h , 0)){
503 17, 17+field_based, src_x, src_y<<field_based,
510 uvsrc_x, uvsrc_y<<field_based,
514 uvsrc_x, uvsrc_y<<field_based,
522 qpix_op[0][dxy](dest_y, ptr_y,
linesize);
537 qpix_op[1][dxy](dest_y , ptr_y ,
linesize);
538 qpix_op[1][dxy](dest_y+8, ptr_y+8,
linesize);
541 pix_op[1][uvdxy](dest_cr, ptr_cr,
uvlinesize, h >> 1);
542 pix_op[1][uvdxy](dest_cb, ptr_cb,
uvlinesize, h >> 1);
555 int dxy, emu=0, src_x, src_y, offset;
563 dxy = ((my & 1) << 1) | (mx & 1);
567 src_x = s->
mb_x * 8 + mx;
568 src_y = s->
mb_y * 8 + my;
569 src_x = av_clip(src_x, -8, (s->
width >> 1));
570 if (src_x == (s->
width >> 1))
572 src_y = av_clip(src_y, -8, (s->
height >> 1));
573 if (src_y == (s->
height >> 1))
577 ptr = ref_picture[1] + offset;
590 ptr = ref_picture[2] + offset;
604 const int mx= (s->
mv[dir][0][0]>>shift) + 16*s->
mb_x + 8;
605 const int my= (s->
mv[dir][0][1]>>shift) + 16*s->
mb_y;
631 int dxy, mx, my, src_x, src_y, motion_x, motion_y;
645 const int mot_xy= mb_x*2 + mb_y*2*mot_stride;
659 AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
660 AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
667 AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
668 AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
675 AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
676 AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
685 const int x= (i&1)+1;
686 const int y= (i>>1)+1;
688 {mv_cache[y][x ][0], mv_cache[y][x ][1]},
689 {mv_cache[y-1][x][0], mv_cache[y-1][x][1]},
690 {mv_cache[y][x-1][0], mv_cache[y][x-1][1]},
691 {mv_cache[y][x+1][0], mv_cache[y][x+1][1]},
692 {mv_cache[y+1][x][0], mv_cache[y+1][x][1]}};
696 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
722 ref_picture, pix_op, qpix_op,
723 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
728 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
733 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y);
742 motion_x = s->
mv[dir][i][0];
743 motion_y = s->
mv[dir][i][1];
745 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
746 src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
747 src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8;
750 src_x = av_clip(src_x, -16, s->
width);
751 if (src_x == s->
width)
753 src_y = av_clip(src_y, -16, s->
height);
757 ptr = ref_picture[0] + (src_y * s->
linesize) + (src_x);
768 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize;
769 qpix_op[1][dxy](dest, ptr, s->
linesize);
771 mx += s->
mv[dir][i][0]/2;
772 my += s->
mv[dir][i][1]/2;
778 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
780 s->
mv[dir][i][0], s->
mv[dir][i][1]);
782 mx += s->
mv[dir][i][0];
783 my += s->
mv[dir][i][1];
797 ref_picture, pix_op, qpix_op,
798 s->
mv[dir][i][0], s->
mv[dir][i][1], 8);
805 s->
mv[dir][0][0], s->
mv[dir][0][1], 8, mb_y);
810 s->
mv[dir][1][0], s->
mv[dir][1][1], 8, mb_y);
820 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y>>1);
829 ref2picture= ref_picture;
837 s->
mv[dir][i][0], s->
mv[dir][i][1] + 16*i, 8, mb_y>>1);
850 j, j^i, ref_picture, pix_op,
851 s->
mv[dir][2*i + j][0],
852 s->
mv[dir][2*i + j][1], 8, mb_y);
861 s->
mv[dir][2*i][0],s->
mv[dir][2*i][1],16, mb_y>>1);
887 ref_picture, pix_op, qpix_op, 1);
891 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.
int unrestricted_mv
mv can point outside of the coded picture
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)