X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmpegvideo_motion.c;h=427bc968877f7e28706b990572dacb724f52c779;hb=6e30b35b85b81c802e52a1078ec7a3097e353c6d;hp=5624c1062974c64ca739087276074fa70fd78beb;hpb=41cd5af3250ef976f0a48adeb6dbccc9b2683e58;p=ffmpeg diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c index 5624c106297..427bc968877 100644 --- a/libavcodec/mpegvideo_motion.c +++ b/libavcodec/mpegvideo_motion.c @@ -21,19 +21,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - #include "libavutil/avassert.h" #include "libavutil/internal.h" +#include "libavutil/mem_internal.h" + #include "avcodec.h" #include "h261.h" #include "mpegutils.h" #include "mpegvideo.h" -#include "mjpegenc.h" -#include "msmpeg4.h" #include "qpeldsp.h" #include "wmv2.h" -#include static void gmc1_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, @@ -211,16 +208,16 @@ static inline int hpel_motion(MpegEncContext *s, dxy |= (motion_y & 1) << 1; src += src_y * s->linesize + src_x; - if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 7, 0) || - (unsigned)src_y >= FFMAX(s->v_edge_pos - (motion_y & 1) - 7, 0)) { - s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src, - s->linesize, s->linesize, - 9, 9, - src_x, src_y, - s->h_edge_pos, s->v_edge_pos); - src = s->sc.edge_emu_buffer; - emu = 1; - } + if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 7, 0) || + (unsigned)src_y >= FFMAX(s->v_edge_pos - (motion_y & 1) - 7, 0)) { + s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src, + s->linesize, s->linesize, + 9, 9, + src_x, src_y, + s->h_edge_pos, s->v_edge_pos); + src = s->sc.edge_emu_buffer; + emu = 1; + } pix_op[dxy](dest, src, s->linesize, 8); return emu; } @@ -304,9 +301,9 @@ void mpeg_motion_internal(MpegEncContext *s, if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 15 , 0) || (unsigned)src_y >= FFMAX( v_edge_pos - (motion_y & 1) - h + 1, 0)) { - if (is_mpeg12 || - s->codec_id == AV_CODEC_ID_MPEG2VIDEO || - s->codec_id == AV_CODEC_ID_MPEG1VIDEO) { + if (is_mpeg12 || (CONFIG_SMALL && + (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); @@ -851,7 +848,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s, switch (s->mv_type) { case MV_TYPE_16X16: - if (s->mcsel) { + if (!is_mpeg12 && s->mcsel) { if (s->real_sprite_warping_points == 1) { gmc1_motion(s, dest_y, dest_cb, dest_cr, ref_picture); @@ -913,60 +910,63 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s, } break; case MV_TYPE_16X8: - for (i = 0; i < 2; i++) { - uint8_t **ref2picture; + if (CONFIG_SMALL || is_mpeg12) { + for (i = 0; i < 2; i++) { + uint8_t **ref2picture; + + if ((s->picture_structure == s->field_select[dir][i] + 1 || + s->pict_type == AV_PICTURE_TYPE_B || s->first_field) && + ref_picture[0]) { + ref2picture = ref_picture; + } else { + ref2picture = s->current_picture_ptr->f->data; + } - if ((s->picture_structure == s->field_select[dir][i] + 1 - || s->pict_type == AV_PICTURE_TYPE_B || s->first_field) && ref_picture[0]) { - ref2picture = ref_picture; - } else { - ref2picture = s->current_picture_ptr->f->data; + 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], + 8, 1, (mb_y & ~1) + i); + + dest_y += 16 * s->linesize; + dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize; + dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize; } - - 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], - 8, 1, (mb_y & ~1) + i); - - dest_y += 16 * s->linesize; - dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize; - dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize; + break; } - break; case MV_TYPE_DMV: - if (s->picture_structure == PICT_FRAME) { - for (i = 0; i < 2; i++) { - int 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 { - if (!ref_picture[0]) { - ref_picture = s->current_picture_ptr->f->data; - } - for (i = 0; i < 2; i++) { - 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, 0, 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 */ - if (!s->first_field) { + if (CONFIG_SMALL || is_mpeg12) { + if (s->picture_structure == PICT_FRAME) { + for (i = 0; i < 2; i++) { + for (int 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 { + if (!ref_picture[0]) { ref_picture = s->current_picture_ptr->f->data; } + for (i = 0; i < 2; i++) { + 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, 0, 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 */ + if (!s->first_field) + ref_picture = s->current_picture_ptr->f->data; + } } + break; } - break; default: av_assert2(0); } }