Merge commit 'a84616b736fca5ebd6b87489dd41bc06ccdf7860'
* commit 'a84616b736fca5ebd6b87489dd41bc06ccdf7860': mpegvideo: K&R formatting cosmetics Conflicts: libavcodec/mpegvideo_motion.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
8610751d07
@ -58,19 +58,23 @@ static void gmc1_motion(MpegEncContext *s,
|
||||
linesize = s->linesize;
|
||||
uvlinesize = s->uvlinesize;
|
||||
|
||||
ptr = ref_picture[0] + (src_y * linesize) + src_x;
|
||||
ptr = ref_picture[0] + src_y * linesize + src_x;
|
||||
|
||||
if( (unsigned)src_x >= FFMAX(s->h_edge_pos - 17, 0)
|
||||
|| (unsigned)src_y >= FFMAX(s->v_edge_pos - 17, 0)){
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, linesize,
|
||||
ptr, linesize, 17, 17, src_x, src_y,
|
||||
if ((unsigned)src_x >= FFMAX(s->h_edge_pos - 17, 0) ||
|
||||
(unsigned)src_y >= FFMAX(s->v_edge_pos - 17, 0)) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, linesize, ptr,
|
||||
linesize,
|
||||
17, 17,
|
||||
src_x, src_y,
|
||||
s->h_edge_pos, s->v_edge_pos);
|
||||
ptr = s->edge_emu_buffer;
|
||||
}
|
||||
|
||||
if ((motion_x | motion_y) & 7) {
|
||||
s->dsp.gmc1(dest_y , ptr , linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
|
||||
s->dsp.gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
|
||||
s->dsp.gmc1(dest_y, ptr, linesize, 16,
|
||||
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
|
||||
s->dsp.gmc1(dest_y + 8, ptr + 8, linesize, 16,
|
||||
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
|
||||
} else {
|
||||
int dxy;
|
||||
|
||||
@ -82,7 +86,8 @@ static void gmc1_motion(MpegEncContext *s,
|
||||
}
|
||||
}
|
||||
|
||||
if(CONFIG_GRAY && s->flags&CODEC_FLAG_GRAY) return;
|
||||
if (CONFIG_GRAY && s->flags & CODEC_FLAG_GRAY)
|
||||
return;
|
||||
|
||||
motion_x = s->sprite_offset[1][0];
|
||||
motion_y = s->sprite_offset[1][1];
|
||||
@ -99,26 +104,30 @@ static void gmc1_motion(MpegEncContext *s,
|
||||
|
||||
offset = (src_y * uvlinesize) + src_x;
|
||||
ptr = ref_picture[1] + offset;
|
||||
if( (unsigned)src_x >= FFMAX((s->h_edge_pos>>1) - 9, 0)
|
||||
|| (unsigned)src_y >= FFMAX((s->v_edge_pos>>1) - 9, 0)){
|
||||
if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - 9, 0) ||
|
||||
(unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - 9, 0)) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, uvlinesize,
|
||||
ptr, uvlinesize, 9, 9, src_x, src_y,
|
||||
ptr, uvlinesize,
|
||||
9, 9,
|
||||
src_x, src_y,
|
||||
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
|
||||
ptr = s->edge_emu_buffer;
|
||||
emu = 1;
|
||||
}
|
||||
s->dsp.gmc1(dest_cb, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
|
||||
s->dsp.gmc1(dest_cb, ptr, uvlinesize, 8,
|
||||
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
|
||||
|
||||
ptr = ref_picture[2] + offset;
|
||||
if (emu) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, uvlinesize,
|
||||
ptr, uvlinesize, 9, 9, src_x, src_y,
|
||||
ptr, uvlinesize,
|
||||
9, 9,
|
||||
src_x, src_y,
|
||||
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
|
||||
ptr = s->edge_emu_buffer;
|
||||
}
|
||||
s->dsp.gmc1(dest_cr, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
|
||||
|
||||
return;
|
||||
s->dsp.gmc1(dest_cr, ptr, uvlinesize, 8,
|
||||
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
|
||||
}
|
||||
|
||||
static void gmc_motion(MpegEncContext *s,
|
||||
@ -135,12 +144,13 @@ static void gmc_motion(MpegEncContext *s,
|
||||
|
||||
ptr = ref_picture[0];
|
||||
|
||||
ox= s->sprite_offset[0][0] + s->sprite_delta[0][0]*s->mb_x*16 + s->sprite_delta[0][1]*s->mb_y*16;
|
||||
oy= s->sprite_offset[0][1] + s->sprite_delta[1][0]*s->mb_x*16 + s->sprite_delta[1][1]*s->mb_y*16;
|
||||
ox = s->sprite_offset[0][0] + s->sprite_delta[0][0] * s->mb_x * 16 +
|
||||
s->sprite_delta[0][1] * s->mb_y * 16;
|
||||
oy = s->sprite_offset[0][1] + s->sprite_delta[1][0] * s->mb_x * 16 +
|
||||
s->sprite_delta[1][1] * s->mb_y * 16;
|
||||
|
||||
s->dsp.gmc(dest_y, ptr, linesize, 16,
|
||||
ox,
|
||||
oy,
|
||||
ox, oy,
|
||||
s->sprite_delta[0][0], s->sprite_delta[0][1],
|
||||
s->sprite_delta[1][0], s->sprite_delta[1][1],
|
||||
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
|
||||
@ -153,15 +163,17 @@ static void gmc_motion(MpegEncContext *s,
|
||||
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
|
||||
s->h_edge_pos, s->v_edge_pos);
|
||||
|
||||
if(CONFIG_GRAY && s->flags&CODEC_FLAG_GRAY) return;
|
||||
if (CONFIG_GRAY && s->flags & CODEC_FLAG_GRAY)
|
||||
return;
|
||||
|
||||
ox= s->sprite_offset[1][0] + s->sprite_delta[0][0]*s->mb_x*8 + s->sprite_delta[0][1]*s->mb_y*8;
|
||||
oy= s->sprite_offset[1][1] + s->sprite_delta[1][0]*s->mb_x*8 + s->sprite_delta[1][1]*s->mb_y*8;
|
||||
ox = s->sprite_offset[1][0] + s->sprite_delta[0][0] * s->mb_x * 8 +
|
||||
s->sprite_delta[0][1] * s->mb_y * 8;
|
||||
oy = s->sprite_offset[1][1] + s->sprite_delta[1][0] * s->mb_x * 8 +
|
||||
s->sprite_delta[1][1] * s->mb_y * 8;
|
||||
|
||||
ptr = ref_picture[1];
|
||||
s->dsp.gmc(dest_cb, ptr, uvlinesize, 8,
|
||||
ox,
|
||||
oy,
|
||||
ox, oy,
|
||||
s->sprite_delta[0][0], s->sprite_delta[0][1],
|
||||
s->sprite_delta[1][0], s->sprite_delta[1][1],
|
||||
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
|
||||
@ -169,8 +181,7 @@ static void gmc_motion(MpegEncContext *s,
|
||||
|
||||
ptr = ref_picture[2];
|
||||
s->dsp.gmc(dest_cr, ptr, uvlinesize, 8,
|
||||
ox,
|
||||
oy,
|
||||
ox, oy,
|
||||
s->sprite_delta[0][0], s->sprite_delta[0][1],
|
||||
s->sprite_delta[1][0], s->sprite_delta[1][1],
|
||||
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
|
||||
@ -199,11 +210,13 @@ static inline int hpel_motion(MpegEncContext *s,
|
||||
src += src_y * s->linesize + src_x;
|
||||
|
||||
if (s->unrestricted_mv && (s->flags & CODEC_FLAG_EMU_EDGE)) {
|
||||
if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&1) - 8, 0)
|
||||
|| (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y&1) - 8, 0)){
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, s->linesize,
|
||||
src, s->linesize, 9, 9,
|
||||
src_x, src_y, s->h_edge_pos, s->v_edge_pos);
|
||||
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 8, 0) ||
|
||||
(unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 1) - 8, 0)) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, s->linesize, src,
|
||||
s->linesize,
|
||||
9, 9,
|
||||
src_x, src_y,
|
||||
s->h_edge_pos, s->v_edge_pos);
|
||||
src = s->edge_emu_buffer;
|
||||
emu = 1;
|
||||
}
|
||||
@ -214,10 +227,19 @@ static inline int hpel_motion(MpegEncContext *s,
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
|
||||
int dxy, uvdxy, mx, my, src_x, src_y,
|
||||
@ -225,8 +247,7 @@ void mpeg_motion_internal(MpegEncContext *s,
|
||||
ptrdiff_t uvlinesize, linesize;
|
||||
|
||||
#if 0
|
||||
if(s->quarter_sample)
|
||||
{
|
||||
if (s->quarter_sample) {
|
||||
motion_x >>= 1;
|
||||
motion_y >>= 1;
|
||||
}
|
||||
@ -252,7 +273,8 @@ if(s->quarter_sample)
|
||||
uvsrc_x = src_x >> 1;
|
||||
uvsrc_y = src_y >> 1;
|
||||
}
|
||||
}else if(!is_mpeg12 && s->out_format == FMT_H261){//even chroma mv's are full pel in H261
|
||||
// Even chroma mv's are full pel in H261
|
||||
} else if (!is_mpeg12 && s->out_format == FMT_H261) {
|
||||
mx = motion_x / 4;
|
||||
my = motion_y / 4;
|
||||
uvdxy = 0;
|
||||
@ -285,28 +307,31 @@ if(s->quarter_sample)
|
||||
ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
|
||||
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
|
||||
|
||||
if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&1) - 16, 0)
|
||||
|| (unsigned)src_y > FFMAX( v_edge_pos - (motion_y&1) - h , 0)){
|
||||
if(is_mpeg12 || s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
|
||||
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 16, 0) ||
|
||||
(unsigned)src_y > FFMAX( v_edge_pos - (motion_y & 1) - h , 0)) {
|
||||
if (is_mpeg12 ||
|
||||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
|
||||
s->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
|
||||
av_log(s->avctx, AV_LOG_DEBUG,
|
||||
"MPEG motion vector out of boundary (%d %d)\n", src_x, src_y);
|
||||
"MPEG motion vector out of boundary (%d %d)\n", src_x,
|
||||
src_y);
|
||||
return;
|
||||
}
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, s->linesize,
|
||||
ptr_y, s->linesize, 17, 17+field_based,
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, s->linesize, ptr_y,
|
||||
s->linesize,
|
||||
17, 17 + field_based,
|
||||
src_x, src_y << field_based,
|
||||
s->h_edge_pos, s->v_edge_pos);
|
||||
ptr_y = s->edge_emu_buffer;
|
||||
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
|
||||
uint8_t *uvbuf = s->edge_emu_buffer + 18 * s->linesize;
|
||||
s->vdsp.emulated_edge_mc(uvbuf, s->uvlinesize,
|
||||
ptr_cb, s->uvlinesize,
|
||||
s->vdsp.emulated_edge_mc(uvbuf, s->uvlinesize, ptr_cb,
|
||||
s->uvlinesize,
|
||||
9, 9 + field_based,
|
||||
uvsrc_x, uvsrc_y << field_based,
|
||||
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
|
||||
s->vdsp.emulated_edge_mc(uvbuf+16, s->uvlinesize,
|
||||
ptr_cr, s->uvlinesize,
|
||||
s->vdsp.emulated_edge_mc(uvbuf + 16, s->uvlinesize, ptr_cr,
|
||||
s->uvlinesize,
|
||||
9, 9 + field_based,
|
||||
uvsrc_x, uvsrc_y << field_based,
|
||||
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
|
||||
@ -315,7 +340,9 @@ if(s->quarter_sample)
|
||||
}
|
||||
}
|
||||
|
||||
if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.data
|
||||
/* FIXME use this for field pix too instead of the obnoxious hack which
|
||||
* changes picture.data */
|
||||
if (bottom_field) {
|
||||
dest_y += s->linesize;
|
||||
dest_cb += s->uvlinesize;
|
||||
dest_cr += s->uvlinesize;
|
||||
@ -379,7 +406,8 @@ static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y,
|
||||
}
|
||||
|
||||
// FIXME move to dsputil, avg variant, 16x16 version
|
||||
static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride){
|
||||
static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride)
|
||||
{
|
||||
int x;
|
||||
uint8_t *const top = src[1];
|
||||
uint8_t *const left = src[2];
|
||||
@ -447,10 +475,9 @@ static inline void obmc_motion(MpegEncContext *s,
|
||||
if (i && mv[i][0] == mv[MID][0] && mv[i][1] == mv[MID][1]) {
|
||||
ptr[i] = ptr[MID];
|
||||
} else {
|
||||
ptr[i]= s->obmc_scratchpad + 8*(i&1) + s->linesize*8*(i>>1);
|
||||
hpel_motion(s, ptr[i], src,
|
||||
src_x, src_y,
|
||||
pix_op,
|
||||
ptr[i] = s->obmc_scratchpad + 8 * (i & 1) +
|
||||
s->linesize * 8 * (i >> 1);
|
||||
hpel_motion(s, ptr[i], src, src_x, src_y, pix_op,
|
||||
mv[i][0], mv[i][1]);
|
||||
}
|
||||
}
|
||||
@ -459,9 +486,12 @@ static inline void obmc_motion(MpegEncContext *s,
|
||||
}
|
||||
|
||||
static inline 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],
|
||||
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)
|
||||
{
|
||||
@ -470,6 +500,7 @@ static inline void qpel_motion(MpegEncContext *s,
|
||||
ptrdiff_t linesize, uvlinesize;
|
||||
|
||||
dxy = ((motion_y & 3) << 2) | (motion_x & 3);
|
||||
|
||||
src_x = s->mb_x * 16 + (motion_x >> 2);
|
||||
src_y = s->mb_y * (16 >> field_based) + (motion_y >> 2);
|
||||
|
||||
@ -505,22 +536,26 @@ static inline void qpel_motion(MpegEncContext *s,
|
||||
ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
|
||||
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
|
||||
|
||||
if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&3) - 16, 0)
|
||||
|| (unsigned)src_y > FFMAX( v_edge_pos - (motion_y&3) - h , 0)){
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, s->linesize,
|
||||
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 3) - 16, 0) ||
|
||||
(unsigned)src_y > FFMAX( v_edge_pos - (motion_y & 3) - h, 0)) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
|
||||
s->linesize,
|
||||
ptr_y, s->linesize,
|
||||
17, 17+field_based, src_x, src_y<<field_based,
|
||||
17, 17 + field_based,
|
||||
src_x, src_y << field_based,
|
||||
s->h_edge_pos, s->v_edge_pos);
|
||||
ptr_y = s->edge_emu_buffer;
|
||||
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
|
||||
uint8_t *uvbuf = s->edge_emu_buffer + 18 * s->linesize;
|
||||
s->vdsp.emulated_edge_mc(uvbuf, s->uvlinesize,
|
||||
ptr_cb, s->uvlinesize,
|
||||
ptr_cb,
|
||||
s->uvlinesize,
|
||||
9, 9 + field_based,
|
||||
uvsrc_x, uvsrc_y << field_based,
|
||||
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
|
||||
s->vdsp.emulated_edge_mc(uvbuf + 16, s->uvlinesize,
|
||||
ptr_cr, s->uvlinesize,
|
||||
ptr_cr,
|
||||
s->uvlinesize,
|
||||
9, 9 + field_based,
|
||||
uvsrc_x, uvsrc_y << field_based,
|
||||
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
|
||||
@ -568,7 +603,7 @@ static void chroma_4mv_motion(MpegEncContext *s,
|
||||
ptrdiff_t offset;
|
||||
|
||||
/* In case of 8X8, we construct a single chroma motion vector
|
||||
with a special rounding */
|
||||
* with a special rounding */
|
||||
mx = ff_h263_round_chroma(mx);
|
||||
my = ff_h263_round_chroma(my);
|
||||
|
||||
@ -588,10 +623,11 @@ static void chroma_4mv_motion(MpegEncContext *s,
|
||||
offset = src_y * s->uvlinesize + src_x;
|
||||
ptr = ref_picture[1] + offset;
|
||||
if (s->flags & CODEC_FLAG_EMU_EDGE) {
|
||||
if( (unsigned)src_x > FFMAX((s->h_edge_pos>>1) - (dxy &1) - 8, 0)
|
||||
|| (unsigned)src_y > FFMAX((s->v_edge_pos>>1) - (dxy>>1) - 8, 0)){
|
||||
if ((unsigned)src_x > FFMAX((s->h_edge_pos >> 1) - (dxy & 1) - 8, 0) ||
|
||||
(unsigned)src_y > FFMAX((s->v_edge_pos >> 1) - (dxy >> 1) - 8, 0)) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, s->uvlinesize,
|
||||
ptr, s->uvlinesize, 9, 9, src_x, src_y,
|
||||
ptr, s->uvlinesize,
|
||||
9, 9, src_x, src_y,
|
||||
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
|
||||
ptr = s->edge_emu_buffer;
|
||||
emu = 1;
|
||||
@ -602,20 +638,23 @@ static void chroma_4mv_motion(MpegEncContext *s,
|
||||
ptr = ref_picture[2] + offset;
|
||||
if (emu) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, s->uvlinesize,
|
||||
ptr, s->uvlinesize, 9, 9, src_x, src_y,
|
||||
ptr, s->uvlinesize,
|
||||
9, 9, src_x, src_y,
|
||||
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
|
||||
ptr = s->edge_emu_buffer;
|
||||
}
|
||||
pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
|
||||
}
|
||||
|
||||
static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir){
|
||||
static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir)
|
||||
{
|
||||
/* fetch pixels for estimated mv 4 macroblocks ahead
|
||||
* optimized for 64byte cache lines */
|
||||
const int shift = s->quarter_sample ? 2 : 1;
|
||||
const int mx = (s->mv[dir][0][0] >> shift) + 16 * s->mb_x + 8;
|
||||
const int my = (s->mv[dir][0][1] >> shift) + 16 * s->mb_y;
|
||||
int off = mx + (my + (s->mb_x & 3) * 4) * s->linesize + 64;
|
||||
|
||||
s->vdsp.prefetch(pix[0] + off, s->linesize, 4);
|
||||
off = (mx >> 1) + ((my >> 1) + (s->mb_x & 7)) * s->uvlinesize + 64;
|
||||
s->vdsp.prefetch(pix[1] + off, pix[2] - pix[1], 2);
|
||||
@ -634,11 +673,14 @@ static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir){
|
||||
* the motion vectors are taken from s->mv and the MV type from s->mv_type
|
||||
*/
|
||||
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 *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)
|
||||
qpel_mc_func (*qpix_op)[16],
|
||||
int is_mpeg12)
|
||||
{
|
||||
int dxy, mx, my, src_x, src_y, motion_x, motion_y;
|
||||
int mb_x, mb_y, i;
|
||||
@ -661,18 +703,24 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
AV_COPY32(mv_cache[1][1], cur_frame->motion_val[0][mot_xy]);
|
||||
AV_COPY32(mv_cache[1][2], cur_frame->motion_val[0][mot_xy + 1]);
|
||||
|
||||
AV_COPY32(mv_cache[2][1], cur_frame->motion_val[0][mot_xy + mot_stride ]);
|
||||
AV_COPY32(mv_cache[2][2], cur_frame->motion_val[0][mot_xy + mot_stride + 1]);
|
||||
AV_COPY32(mv_cache[2][1],
|
||||
cur_frame->motion_val[0][mot_xy + mot_stride]);
|
||||
AV_COPY32(mv_cache[2][2],
|
||||
cur_frame->motion_val[0][mot_xy + mot_stride + 1]);
|
||||
|
||||
AV_COPY32(mv_cache[3][1], cur_frame->motion_val[0][mot_xy + mot_stride ]);
|
||||
AV_COPY32(mv_cache[3][2], cur_frame->motion_val[0][mot_xy + mot_stride + 1]);
|
||||
AV_COPY32(mv_cache[3][1],
|
||||
cur_frame->motion_val[0][mot_xy + mot_stride]);
|
||||
AV_COPY32(mv_cache[3][2],
|
||||
cur_frame->motion_val[0][mot_xy + mot_stride + 1]);
|
||||
|
||||
if (mb_y == 0 || IS_INTRA(cur_frame->mb_type[xy - s->mb_stride])) {
|
||||
AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
|
||||
AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
|
||||
} else {
|
||||
AV_COPY32(mv_cache[0][1], cur_frame->motion_val[0][mot_xy - mot_stride ]);
|
||||
AV_COPY32(mv_cache[0][2], cur_frame->motion_val[0][mot_xy - mot_stride + 1]);
|
||||
AV_COPY32(mv_cache[0][1],
|
||||
cur_frame->motion_val[0][mot_xy - mot_stride]);
|
||||
AV_COPY32(mv_cache[0][2],
|
||||
cur_frame->motion_val[0][mot_xy - mot_stride + 1]);
|
||||
}
|
||||
|
||||
if (mb_x == 0 || IS_INTRA(cur_frame->mb_type[xy - 1])) {
|
||||
@ -680,7 +728,8 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
|
||||
} else {
|
||||
AV_COPY32(mv_cache[1][0], cur_frame->motion_val[0][mot_xy - 1]);
|
||||
AV_COPY32(mv_cache[2][0], cur_frame->motion_val[0][mot_xy - 1 + mot_stride]);
|
||||
AV_COPY32(mv_cache[2][0],
|
||||
cur_frame->motion_val[0][mot_xy - 1 + mot_stride]);
|
||||
}
|
||||
|
||||
if (mb_x + 1 >= s->mb_width || IS_INTRA(cur_frame->mb_type[xy + 1])) {
|
||||
@ -688,7 +737,8 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
|
||||
} else {
|
||||
AV_COPY32(mv_cache[1][3], cur_frame->motion_val[0][mot_xy + 2]);
|
||||
AV_COPY32(mv_cache[2][3], cur_frame->motion_val[0][mot_xy + 2 + mot_stride]);
|
||||
AV_COPY32(mv_cache[2][3],
|
||||
cur_frame->motion_val[0][mot_xy + 2 + mot_stride]);
|
||||
}
|
||||
|
||||
mx = 0;
|
||||
@ -701,7 +751,8 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
{ mv_cache[y - 1][x][0], mv_cache[y - 1][x][1] },
|
||||
{ mv_cache[y][x - 1][0], mv_cache[y][x - 1][1] },
|
||||
{ mv_cache[y][x + 1][0], mv_cache[y][x + 1][1] },
|
||||
{mv_cache[y+1][x][0], mv_cache[y+1][x][1]}};
|
||||
{ mv_cache[y + 1][x][0], mv_cache[y + 1][x][1] }
|
||||
};
|
||||
// FIXME cleanup
|
||||
obmc_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
|
||||
ref_picture[0],
|
||||
@ -713,7 +764,9 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
my += mv[0][1];
|
||||
}
|
||||
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY))
|
||||
chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my);
|
||||
chroma_4mv_motion(s, dest_cb, dest_cr,
|
||||
ref_picture, pix_op[1],
|
||||
mx, my);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -738,8 +791,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
|
||||
ref_picture, pix_op,
|
||||
s->mv[dir][0][0], s->mv[dir][0][1], 16);
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
|
||||
ref_picture, pix_op,
|
||||
s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y);
|
||||
@ -768,12 +820,15 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
|
||||
ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
|
||||
if (s->flags & CODEC_FLAG_EMU_EDGE) {
|
||||
if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&3) - 8, 0)
|
||||
|| (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y&3) - 8, 0)){
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, s->linesize,
|
||||
ptr, s->linesize, 9, 9,
|
||||
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 3) - 8, 0) ||
|
||||
(unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 3) - 8, 0)) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
|
||||
s->linesize, ptr,
|
||||
s->linesize,
|
||||
9, 9,
|
||||
src_x, src_y,
|
||||
s->h_edge_pos, s->v_edge_pos);
|
||||
s->h_edge_pos,
|
||||
s->v_edge_pos);
|
||||
ptr = s->edge_emu_buffer;
|
||||
}
|
||||
}
|
||||
@ -785,11 +840,14 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < 4; i++) {
|
||||
hpel_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
|
||||
hpel_motion(s,
|
||||
dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
|
||||
ref_picture[0],
|
||||
mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
|
||||
mb_x * 16 + (i & 1) * 8,
|
||||
mb_y * 16 + (i >> 1) * 8,
|
||||
pix_op[1],
|
||||
s->mv[dir][i][0], s->mv[dir][i][1]);
|
||||
s->mv[dir][i][0],
|
||||
s->mv[dir][i][1]);
|
||||
|
||||
mx += s->mv[dir][i][0];
|
||||
my += s->mv[dir][i][1];
|
||||
@ -797,18 +855,18 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
}
|
||||
|
||||
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY))
|
||||
chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my);
|
||||
chroma_4mv_motion(s, dest_cb, dest_cr,
|
||||
ref_picture, pix_op[1], mx, my);
|
||||
}
|
||||
break;
|
||||
case MV_TYPE_FIELD:
|
||||
if (s->picture_structure == PICT_FRAME) {
|
||||
if (!is_mpeg12 && s->quarter_sample) {
|
||||
for(i=0; i<2; i++){
|
||||
for (i = 0; i < 2; i++)
|
||||
qpel_motion(s, dest_y, dest_cb, dest_cr,
|
||||
1, i, s->field_select[dir][i],
|
||||
ref_picture, pix_op, qpix_op,
|
||||
s->mv[dir][i][0], s->mv[dir][i][1], 8);
|
||||
}
|
||||
} else {
|
||||
/* top field */
|
||||
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
|
||||
@ -847,7 +905,8 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
mpeg_motion(s, dest_y, dest_cb, dest_cr,
|
||||
s->field_select[dir][i],
|
||||
ref2picture, pix_op,
|
||||
s->mv[dir][i][0], s->mv[dir][i][1] + 16*i, 8, mb_y>>1);
|
||||
s->mv[dir][i][0], s->mv[dir][i][1] + 16 * i,
|
||||
8, mb_y >> 1);
|
||||
|
||||
dest_y += 16 * s->linesize;
|
||||
dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
|
||||
@ -858,12 +917,11 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
if (s->picture_structure == PICT_FRAME) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
int j;
|
||||
for(j=0; j<2; j++){
|
||||
for (j = 0; j < 2; j++)
|
||||
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
|
||||
j, j ^ i, ref_picture, pix_op,
|
||||
s->mv[dir][2 * i + j][0],
|
||||
s->mv[dir][2 * i + j][1], 8, mb_y);
|
||||
}
|
||||
pix_op = s->hdsp.avg_pixels_tab;
|
||||
}
|
||||
} else {
|
||||
@ -874,12 +932,14 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
mpeg_motion(s, dest_y, dest_cb, dest_cr,
|
||||
s->picture_structure != i + 1,
|
||||
ref_picture, pix_op,
|
||||
s->mv[dir][2*i][0],s->mv[dir][2*i][1],16, mb_y>>1);
|
||||
s->mv[dir][2 * i][0], s->mv[dir][2 * i][1],
|
||||
16, mb_y >> 1);
|
||||
|
||||
// after put we make avg of the same block
|
||||
pix_op = s->hdsp.avg_pixels_tab;
|
||||
|
||||
//opposite parity is always in the same frame if this is second field
|
||||
/* opposite parity is always in the same frame if this is
|
||||
* second field */
|
||||
if (!s->first_field) {
|
||||
ref_picture = s->current_picture_ptr->f.data;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user