[Ffmpeg-devel] swscale patch

Michael Niedermayer michaelni
Sat Jul 1 12:39:25 CEST 2006


Hi

On Sat, Jul 01, 2006 at 11:18:49AM +0200, Luca Abeni wrote:
[...]
> > [...]
> > > +char *sws_format_name(int format)
> > > +{
> > > +    static char fmt_name[64];
> > > +    char *res;
> > > +    static int buffer;
> > > +
> > > +    res = fmt_name + buffer * 32;
> > > +    buffer = 1 - buffer;
> > > +    snprintf(res, 32, "0x%x (%c%c%c%c)", format,
> > > +		    format >> 24, (format >> 16) & 0xFF,
> > > +		    (format >> 8) & 0xFF,
> > > +		    format & 0xFF);
> > > +
> > 
> > this isnt thread safe
> Opss... I did not think about threads. I see two ways to fix it:
> 1) using a table of strings, or a switch as in vo_format_name
> 2) changing the interface so that the caller provides the buffer
> 
> Since this function is not going to stay here for a long time (I plan to
> switch to ffmpeg pixel format names, and then avcodec_get_pix_fmt_name()
> could be used) I am tempted to just copy vo_format_name(). Which
> solution do you prefer?

leave it, if its just temporary solution


[...]
> > [...]
> > > Index: cpu.h
> > > ===================================================================
> > > --- cpu.h	(revision 0)
> > > +++ cpu.h	(revision 0)
> > > @@ -0,0 +1,34 @@
> > > +#ifndef __SWS_CPU_H__
> > > +#define __SWS_CPU_H__
> > > +
> > > +#ifdef ARCH_X86_64
> > > +#  define REG_a "rax"
> > > +#  define REG_b "rbx"
> > > +#  define REG_c "rcx"
> > > +#  define REG_d "rdx"
> > > +#  define REG_D "rdi"
> > > +#  define REG_S "rsi"
> > > +#  define PTR_SIZE "8"
> > > +#  define REGa    rax
> > > +#  define REGb    rbx
> > > +#  define REGSP   rsp
> > > +#  define REG_SP "rsp"
> > > +#  define REG_BP "rbp"
> > > +#  define REGBP   rbp
> > > +#else
> > > +#  define REG_a "eax"
> > > +#  define REG_b "ebx"
> > > +#  define REG_c "ecx"
> > > +#  define REG_d "edx"
> > > +#  define REG_D "edi"
> > > +#  define REG_S "esi"
> > > +#  define PTR_SIZE "4"
> > > +#  define REGa    eax
> > > +#  define REGb    ebx
> > > +#  define REGSP   esp
> > > +#  define REG_SP "esp"
> > > +#  define REG_BP "ebp"
> > > +#  define REGBP   ebp
> > > +#endif
> > > +
> > > +#endif	/* __SWS_CPU_H__ */
> > > 
> > 
> > one day this needs to be cleaned up and put in a single place per project ...
> I agree.
> I initially saw some of these macros in libavcodec/i386/mmx.h, so I
> tried to use such header. But that is the wrong header, so I ended up
> creating this "cpu.h"...

yes, mmx.h is the wrong place, they should be removed from there ...


> 
> Maybe we should put these macros in libavutils/x86_cpu.h (or something
> similar), and include such file from all the places that use REG_*?
> Let me know if you agree, and I will provide a patch for ffmpeg.

ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list