[FFmpeg-devel] [PATCH] swscale alpha channel support
Michael Niedermayer
michaelni
Thu Mar 5 23:43:33 CET 2009
On Thu, Mar 05, 2009 at 11:21:05PM +0100, C?dric Schieli wrote:
> 2009/3/5 Michael Niedermayer <michaelni at gmx.at>:
> > On Thu, Mar 05, 2009 at 03:09:26PM +0100, C?dric Schieli wrote:
> >> 2009/3/2 Michael Niedermayer <michaelni at gmx.at>:
> >> > On Fri, Feb 27, 2009 at 11:30:25PM +0100, C?dric Schieli wrote:
>
> [...]
>
> >> #9 : swscale-example_use_alpha.patch
> >> updated
> >> the second hunk in this one needs some explanations :
> >> without it, swscale-example will segfault
> >> even without any of my patches, simply adding a uint16_t** field to
> >> struct SwsContext and av_malloc'ing between 13 and 236 bytes (or 26
> >> and 408 on x86_64) will make swscale-example to segfault (see
> >> bug.diff)
> >> after some debugging, I found that my alpPixBuf data get corrupted somehow
> >> disabling MMX code with --disable-mmx prevent this from happening
> >> running swscale-example under valgrind (even without bug.diff) will segfault
> >> can someone can help on this ?
> >
> > in swscale_internal.h there are #defines that define the offsets of
> > various fields in the struct so the asm can access them, you dont maybe
> > mess that up by adding a field?
>
> I carefully added my fields either before the defines or at the end of
> the struct
> when testing with "bug.diff", moving around the field in the struct
> doesn't change anything
>
> >
> >
> > and if valgrind itself segfaults, that should be reported to the valgrind
> > devs ...
>
> no, it's not valgrind that segfaults, but swscale-example run under
> valgrind (logfile attached)
> when building with --disable-mmx, all runs fine
gdb output of gcc -O1 -g3 swscale (without fomit-frame-pointer if possible)
(that being bt and disasembly & dump of registers)
would be usefull maybe
>
> > #7
> > [...]
> >> @@ -1191,6 +1254,52 @@
> >> ? ? ? ? ?{
> >> ? ? ? ? ? ? ?//Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
> >> ? ? ? ? ? ? ?case PIX_FMT_RGB32:
> >> + ? ? ? ? ? ? ? ?if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){
> >> +#if !ARCH_X86_64
> >> + ? ? ? ? ? ? ? ? ? ?*(uint16_t **)(&c->u_temp)=abuf0;
> >> + ? ? ? ? ? ? ? ? ? ?*(uint16_t **)(&c->v_temp)=abuf1;
> >> +#endif
> >> + ? ? ? ? ? ? ? ? ? ?__asm__ volatile(
> >> +#if !ARCH_X86_64
> >> + ? ? ? ? ? ? ? ? ? ?"mov %%"REG_b", "ESP_OFFSET"(%5) ? ? ? ?\n\t"
> >> +#endif
> >> + ? ? ? ? ? ? ? ? ? ?"mov ? ? ? ?%4, %%"REG_b" ? ? ? ? ? ? ? \n\t"
> >> +#if !ARCH_X86_64
> >> + ? ? ? ? ? ? ? ? ? ?"push %%"REG_BP" ? ? ? ? ? ? ? ? ? ? ? ?\n\t"
> >> +#endif
> >> + ? ? ? ? ? ? ? ? ? ?YSCALEYUV2RGB(%%REGBP, %5)
> >> +#if !ARCH_X86_64
> >> + ? ? ? ? ? ? ? ? ? ?"push ? ? ? ? ? ? ? ? ? %0 ? ? ? ? ? ? ?\n\t"
> >> + ? ? ? ? ? ? ? ? ? ?"push ? ? ? ? ? ? ? ? ? %1 ? ? ? ? ? ? ?\n\t"
> >> + ? ? ? ? ? ? ? ? ? ?"mov ? ? ? ? ?"U_TEMP"(%5), %0 ? ? ? ? ?\n\t"
> >> + ? ? ? ? ? ? ? ? ? ?"mov ? ? ? ? ?"V_TEMP"(%5), %1 ? ? ? ? ?\n\t"
> >> +#endif
> >> +#if ARCH_X86_64
> >> + ? ? ? ? ? ? ? ? ? ?YSCALEYUV2RGB_YA(%%REGBP, %5, %6, %7)
> >> +#else
> >> + ? ? ? ? ? ? ? ? ? ?YSCALEYUV2RGB_YA(%%REGBP, %5, %0, %1)
> >> +#endif
> >> + ? ? ? ? ? ? ? ? ? ?"psraw ? ? ? ? ? ? ? ? ?$3, %%mm1 ? ? ? \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
> >> + ? ? ? ? ? ? ? ? ? ?"psraw ? ? ? ? ? ? ? ? ?$3, %%mm7 ? ? ? \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
> >> + ? ? ? ? ? ? ? ? ? ?"packuswb ? ? ? ? ? ?%%mm7, %%mm1 ? ? ? \n\t"
> >> +#if !ARCH_X86_64
> >> + ? ? ? ? ? ? ? ? ? ?"pop ? ? ? ? ? ? ? ? ? ?%1 ? ? ? ? ? ? ?\n\t"
> >> + ? ? ? ? ? ? ? ? ? ?"pop ? ? ? ? ? ? ? ? ? ?%0 ? ? ? ? ? ? ?\n\t"
> >> +#endif
> >> + ? ? ? ? ? ? ? ? ? ?WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
> >> +#if !ARCH_X86_64
> >> + ? ? ? ? ? ? ? ? ? ?"pop %%"REG_BP" ? ? ? ? ? ? ? ? ? ? ? ? \n\t"
> >> + ? ? ? ? ? ? ? ? ? ?"mov "ESP_OFFSET"(%5), %%"REG_b" ? ? ? ?\n\t"
> >> +#endif
> >> +
> >> + ? ? ? ? ? ? ? ? ? ?:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
> >> + ? ? ? ? ? ? ? ? ? ?"a" (&c->redDither)
> >> +#if ARCH_X86_64
> >> + ? ? ? ? ? ? ? ? ? ?,"r" (abuf0), "r" (abuf1)
> >> + ? ? ? ? ? ? ? ? ? ?: "%"REG_b, "%"REG_BP
> >> +#endif
> >> + ? ? ? ? ? ? ? ? ? ?);
> >> + ? ? ? ? ? ? ? ?}else{
> >> ? ? ? ? ? ? ? ? ?__asm__ volatile(
> >> ? ? ? ? ? ? ? ? ?"mov %%"REG_b", "ESP_OFFSET"(%5) ? ? ? ?\n\t"
> >> ? ? ? ? ? ? ? ? ?"mov ? ? ? ?%4, %%"REG_b" ? ? ? ? ? ? ? \n\t"
> >
> > ehm, this looks really messy ...
>
> Yes, I wanted to not duplicate code, but it finally looks ugly
> Do you prefer something like this ?
if its a single functon yes otherwise some other solution has to be found
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090305/c18d7575/attachment.pgp>
More information about the ffmpeg-devel
mailing list