[FFmpeg-devel] [PATCH] avutil/motion_vector: export subpel motion information
Michael Niedermayer
michaelni at gmx.at
Sun Nov 22 03:24:55 CET 2015
On Fri, Nov 20, 2015 at 11:35:41AM +0100, Clément Bœsch wrote:
> ---
> FATE test changes because of the replacement of >>n with /(1<<n).
> http://ubitux.fr/pub/pics/_the-effect-of-replacing-a-shift-by-a-div.png (new, old, diff)
> ---
> libavcodec/mpegvideo.c | 36 +++++++++++++++++++++---------------
> libavcodec/snowdec.c | 7 +++++--
> libavfilter/vf_codecview.c | 7 +++++--
> libavutil/motion_vector.h | 7 +++++++
> libavutil/version.h | 2 +-
> tests/ref/fate/filter-codecview-mvs | 36 ++++++++++++++++++------------------
> 6 files changed, 57 insertions(+), 38 deletions(-)
>
> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> index 60e19ff..e0dbcab 100644
> --- a/libavcodec/mpegvideo.c
> +++ b/libavcodec/mpegvideo.c
> @@ -1557,15 +1557,20 @@ static void draw_arrow(uint8_t *buf, int sx, int sy, int ex,
>
> static int add_mb(AVMotionVector *mb, uint32_t mb_type,
> int dst_x, int dst_y,
> - int src_x, int src_y,
> + int motion_x, int motion_y, int motion_scale,
> int direction)
> {
> mb->w = IS_8X8(mb_type) || IS_8X16(mb_type) ? 8 : 16;
> mb->h = IS_8X8(mb_type) || IS_16X8(mb_type) ? 8 : 16;
> - mb->src_x = src_x;
> - mb->src_y = src_y;
> +
> + mb->motion_x = motion_x;
> + mb->motion_y = motion_y;
> + mb->motion_scale = motion_scale;
> +
> mb->dst_x = dst_x;
> mb->dst_y = dst_y;
> + mb->src_x = dst_x + motion_x / motion_scale;
> + mb->src_y = dst_y + motion_y / motion_scale;
[...]
> diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
> index 1b288dd..5eb775a 100644
> --- a/libavcodec/snowdec.c
> +++ b/libavcodec/snowdec.c
> @@ -104,8 +104,11 @@ static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer
> avmv->h = block_h;
> avmv->dst_x = block_w*mb_x - block_w/2;
> avmv->dst_y = block_h*mb_y - block_h/2;
> - avmv->src_x = avmv->dst_x + (bn->mx * s->mv_scale)/8;
> - avmv->src_y = avmv->dst_y + (bn->my * s->mv_scale)/8;
> + avmv->motion_scale = 1 << 3;
> + avmv->motion_x = bn->mx * s->mv_scale;
> + avmv->motion_y = bn->my * s->mv_scale;
> + avmv->src_x = avmv->dst_x + avmv->motion_x / avmv->motion_scale;
> + avmv->src_y = avmv->dst_y + avmv->motion_y / avmv->motion_scale;
does gcc optimize these divisions out ?
if not it might be better to avoid them.
IIUC src_x/y are only an approximation, as the exact motion vector
isnt an integer in fullpel units so it would be mostly cosmetic
if x + 4 >> 8, or /8 is used
the patch should be fine either way
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151122/7f2a2ce0/attachment.sig>
More information about the ffmpeg-devel
mailing list