[FFmpeg-devel] [PATCH] x86: convert DNxHDenc inline asm to yasm

Ronald S. Bultje rsbultje at gmail.com
Wed Mar 26 20:16:26 CET 2014


Hi,

On Wed, Mar 26, 2014 at 3:01 PM, Timothy Gu <timothygu99 at gmail.com> wrote:

> On Wed, Mar 26, 2014 at 8:54 AM, Ronald S. Bultje <rsbultje at gmail.com>
> wrote:
> > Hi,
> >
> > On Tue, Mar 25, 2014 at 11:21 PM, Timothy Gu <timothygu99 at gmail.com>
> wrote:
> >
> >> +; void get_pixels_8x4_sym_sse2(int16_t *block, const uint8_t *pixels,
> >> +;                              int line_size)
> >> +INIT_XMM sse2
> >> +cglobal get_pixels_8x4_sym, 3,3,5
> >>
> >
> > cglobal get_pixels_8x4_sym, 3, 3, 5, block, pixels, linesize
> >
> >
> >> +    movsxdifnidn r2,    r2d
> >>
> >
> > Change argument type to intptr_t or ptrdiff_t and remove this
> instruction.
>
> OK. I saw it in the disassembly of the C version and
> libavcodec/x86/dsputilenc.asm. That's why I did this.
>
> >
> >
> >> +    pxor      m4,       m4
> >> +    movq      m0,       [r1]
> >>
> >
> > [blockq]
>
> I used to use the named registers (is that what you call it?), but
> then I don't know how to deal with movsxdifnidn. Now I know how the
> issue can fixed, sure.
>
> >
> >
> >> +    add       r1,       r2
> >>
> >
> > add pixelsq, linesizeq
> >
> >
> >> +    movq      m1,       [r1]
> >> +    movq      m2,       [r1+r2]
> >> +    movq      m3,       [r1+r2*2]
> >> +    punpcklbw m0,       m4
> >> +    punpcklbw m1,       m4
> >> +    punpcklbw m2,       m4
> >> +    punpcklbw m3,       m4
> >> +    movdqa    [r0    ], m0
> >> +    movdqa    [r0+16 ], m1
> >> +    movdqa    [r0+32 ], m2
> >> +    movdqa    [r0+48 ], m3
> >> +    movdqa    [r0+64 ], m3
> >> +    movdqa    [r0+80 ], m2
> >> +    movdqa    [r0+96 ], m1
> >> +    movdqa    [r0+112], m0
> >>
> >
>
> > We typically use mova (which expands to movdqa for xmm, and to movq for
> > mmx; likewise, movh expands to movq for xmm and to movd for mmx), but I
> > don't particularly care since you're only using this for xmm, not mmx, so
> > ignore this if you don't care.
>
> I'll change it.
>
> Anyways, this is my first asm patch, and I've never seen asm before,
> so it takes an awful amount of time to look up every single
> instruction, trying to understand how it works like the C version. So
> thank you for your instruction on asm.


You'll find it's pretty much like being new to C - the first few reviews
will be quite drawn-out while you get used to the particular little tricks
we have to make some things "better" (typically in asm "better" means
"faster" or "less instructions" or "easier to read"), and after a while you
know all those tricks and it's really easy.

Ronald


More information about the ffmpeg-devel mailing list