[Ffmpeg-devel] swscale patch
Michael Niedermayer
michaelni
Tue Jul 4 14:39:34 CEST 2006
Hi
On Tue, Jul 04, 2006 at 01:17:47PM +0200, Luca Abeni wrote:
> Hi all,
>
> while addressing Michael's comments, I also split swscale.diff in 3
> pieces:
> - the first one just changes libswscale's Makefile making it similar to
> the libav* makefiles
> - the second one changes the headers included by libswscale, including
> avutil.h and, and introduces sws_global_init removing all the references
> to malloc() and free()
> - the third patch introduces the support for ffmpeg's pixel format names
>
> I attach the first two patches (I still have to test the third one). I
> think the first one (build.diff) should be ok, and I hope the second one
> (swscale-part2.diff) properly addresses the comments I received.
>
> The changes are:
> - do not include mangle.h
> - use x86_cpu.h instead of introducing cpu.h
> - removed all the "if (...)" before sws_free()
> - removed sws_init()
> - removed spurious "#include <stdint.h>" from swscale.h
> - removed img_format.h from the patch
>
> I will probably send the third patch tomorrow.
>
>
>
> Luca
> --
> _____________________________________________________________________________
> Copy this in your signature, if you think it is important:
> N O W A R ! ! !
>
[Makefile changes left to Makefile maintainer]
[...]
> Index: mplayer/libswscale/swsutil.h
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ mplayer/libswscale/swsutil.h 2006-07-04 12:37:56.000000000 +0200
> @@ -0,0 +1,16 @@
> +#ifndef __SWS_UTIL__
> +#define __SWS_UTIL__
> +
> +#include "avutil.h"
> +
> +#define AV_LOG_QUIET -1
> +#define AV_LOG_ERROR 0
> +#define AV_LOG_INFO 1
> +#define AV_LOG_DEBUG 2
> +
> +extern void *(*sws_malloc)(unsigned int size);
> +extern void (*sws_free)(void *ptr);
> +extern void (*sws_log)(void*, int level, const char *fmt, ...);
> +
> +char *sws_format_name(int format);
> +#endif
why is this not put in swscale_internal.h ?
[...]
> Index: mplayer/libswscale/swscaler_glue.c
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ mplayer/libswscale/swscaler_glue.c 2006-07-04 12:37:56.000000000 +0200
> @@ -0,0 +1,32 @@
> +#include "config.h"
> +#include "swsutil.h"
> +#include "swscale.h"
> +#include "img_format.h"
> +
> +void *(*sws_malloc)(unsigned int size);
> +void (*sws_free)(void *ptr);
> +void (*sws_log)(void*, int level, const char *fmt, ...);
> +
> +void sws_global_init(void *(*alloc)(unsigned int size),
> + void (*free)(void *ptr), void (*log)(void*, int level, const char *fmt, ...))
> +{
> + sws_malloc = alloc;
> + sws_free = free;
> + sws_log = log;
> +}
> +
> +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);
> +
> + return res;
> +}
why is this not put in swscale.c ?
[...]
> Index: mplayer/mplayer.c
> ===================================================================
> --- mplayer.orig/mplayer.c 2006-07-04 11:05:28.000000000 +0200
> +++ mplayer/mplayer.c 2006-07-04 12:37:56.000000000 +0200
> @@ -37,6 +37,10 @@
>
> #include <errno.h>
>
> +#ifdef HAVE_MALLOC_H
> +#include <malloc.h>
> +#endif
> +
> #include "version.h"
>
> #include "mp_msg.h"
> @@ -83,6 +87,8 @@
>
> #include "input/input.h"
>
> +#include "libswscale/swscale.h"
> +
> int slave_mode=0;
> int player_idle_mode=0;
> extern int verbose;
> @@ -2463,6 +2469,27 @@
> }
>
>
> +static void *my_alloc(unsigned int s)
> +{
> +#ifdef HAVE_MALLOC_H
> + return memalign(16, s);
> +#else
> + return malloc(s);
> +#endif
> +}
> +
> +static void my_log(void* dummy, int level, const char *fmt, ...)
> +{
> + va_list va;
> + static char buff[4096];
> +
> + va_start(va, fmt);
> + vsnprintf(buff, 4096, fmt, va);
> + va_end(va);
> + mp_msg(MSGT_SWS, level, buff);
> +}
> +
> +
> int main(int argc,char* argv[]){
>
>
> @@ -2492,6 +2519,8 @@
> InitTimer();
>
> mp_msg_init();
> +
> + sws_global_init(my_alloc, free, my_log);
>
> mp_msg(MSGT_CPLAYER,MSGL_INFO, "MPlayer " VERSION " (C) 2000-2006 MPlayer Team\n");
> /* Test for CPU capabilities (and corresponding OS support) for optimizing */
> Index: mplayer/mencoder.c
> ===================================================================
> --- mplayer.orig/mencoder.c 2006-07-04 11:05:28.000000000 +0200
> +++ mplayer/mencoder.c 2006-07-04 12:37:56.000000000 +0200
> @@ -37,6 +37,9 @@
>
> #include <sys/time.h>
>
> +#ifdef HAVE_MALLOC_H
> +#include <malloc.h>
> +#endif
>
> #include "version.h"
> #include "mp_msg.h"
> @@ -89,6 +92,9 @@
> #endif
>
> #include "libmpcodecs/ae.h"
> +
> +#include "libswscale/swscale.h"
> +
> int vo_doublebuffering=0;
> int vo_directrendering=0;
> int vo_config_count=0;
> @@ -363,6 +369,26 @@
>
> extern void print_wave_header(WAVEFORMATEX *h, int verbose_level);
>
> +static void *my_alloc(unsigned int s)
> +{
> +#ifdef HAVE_MALLOC_H
> + return memalign(16, s);
> +#else
> + return malloc(s);
> +#endif
> +}
> +
> +static void my_log(void* dummy, int level, const char *fmt, ...)
> +{
> + va_list va;
> + static char buff[4096];
> +
> + va_start(va, fmt);
> + vsnprintf(buff, 4096, fmt, va);
> + va_end(va);
> + mp_msg(MSGT_SWS, level, buff);
> +}
> +
> int main(int argc,char* argv[]){
>
> stream_t* stream=NULL;
> @@ -410,6 +436,9 @@
> audio_encoder_t *aencoder = NULL;
>
> mp_msg_init();
> +
> + sws_global_init(my_alloc, free, my_log);
> +
> mp_msg(MSGT_CPLAYER,MSGL_INFO, "MEncoder " VERSION " (C) 2000-2006 MPlayer Team\n");
>
> /* Test for cpu capabilities (and corresponding OS support) for optimizing */
that code duplication is unacceptable
[...]
--
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