|
Subject: [PATCH] ffmpeg as .dll Newsgroups: gmane.comp.video.ffmpeg.devel Date: 2005-03-08 06:11:50 GMT (4 years, 17 weeks, 14 hours and 48 minutes ago)
This is my first
submission, it's on behalf of my colleague, who wrote it.
It patches ffmpeg to operate as a win32-dll. This one was based on the one that was already patched for psp support. If you have any questions, I probably need to check
back with my colleague, so it may take some time before I can react. Enjoy,
Vincent.
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/Makefile,v retrieving revision 1.77 diff -u -r1.77 Makefile --- Makefile 21 Jan 2005 22:16:04 -0000 1.77 +++ Makefile 1 Feb 2005 13:07:14 -0000 <at> <at> -56,7 +56,7 <at> <at> endif ifeq ($(CONFIG_FAAC),yes) -EXTRALIBS+=-lfaac +EXTRALIBS+=-lfaac -shared endif ifeq ($(CONFIG_XVID),yes) Index: cmdutils.c =================================================================== RCS file: /cvsroot/ffmpeg/ffmpeg/cmdutils.c,v retrieving revision 1.7 diff -u -r1.7 cmdutils.c --- cmdutils.c 20 Jan 2005 15:31:07 -0000 1.7 +++ cmdutils.c 1 Feb 2005 15:24:37 -0000 <at> <at> -16,12 +16,18 <at> <at> * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #define HAVE_AV_CONFIG_H #include "avformat.h" #include "common.h" #include "cmdutils.h" +#include <setjmp.h> +// extern static jmp_buf setjmp_mark; +extern jmp_buf setjmp_mark; +#define exit(X) longjmp( setjmp_mark, X|1 ) + void show_help_options(const OptionDef *options, const char *msg, int mask, int value) { const OptionDef *po; Index: ffmpeg.c =================================================================== RCS file: /cvsroot/ffmpeg/ffmpeg/ffmpeg.c,v retrieving revision 1.307 diff -u -r1.307 ffmpeg.c --- ffmpeg.c 29 Jan 2005 02:27:33 -0000 1.307 +++ ffmpeg.c 1 Feb 2005 22:13:23 -0000 <at> <at> -16,6 +16,12 <at> <at> * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + +#include <setjmp.h> + +jmp_buf setjmp_mark; + #define HAVE_AV_CONFIG_H #include <limits.h> #include "avformat.h" <at> <at> -39,10 +45,18 <at> <at> #undef time //needed because HAVE_AV_CONFIG_H is defined on top #include <time.h> +#define exit(X) longjmp( setjmp_mark, X|1 ) #include "cmdutils.h" #undef NDEBUG #include <assert.h> +#include <windows.h> +#include <stdarg.h> +typedef long (WINAPI *CallBack)(long pos, long total); + + +#define getchar() 'y' +// #define exit(X) return(X) #if !defined(INFINITY) && defined(HUGE_VAL) #define INFINITY HUGE_VAL <at> <at> -60,6 +74,9 <at> <at> int in_file; } AVMetaDataMap; +char g_errorbuffer[4096]; +static CallBack g_CallBack; + extern const OptionDef options[]; static void show_help(void); <at> <at> -67,6 +84,8 <at> <at> #define MAX_FILES 20 +static int g_registered = 0; + static AVFormatContext *input_files[MAX_FILES]; static int64_t input_files_ts_offset[MAX_FILES]; static int nb_input_files = 0; <at> <at> -222,7 +241,7 <at> <at> static int64_t start_time = 0; static int64_t rec_timestamp = 0; static int64_t input_ts_offset = 0; -static int file_overwrite = 0; +static int file_overwrite = 1; static char *str_title = NULL; static char *str_author = NULL; static char *str_copyright = NULL; <at> <at> -254,7 +273,7 <at> <at> static int using_stdin = 0; static int using_vhook = 0; -static int verbose = 1; +static int verbose = -1; static int thread_count= 1; static int q_pressed = 0; static int me_range = 0; <at> <at> -427,6 +446,23 <at> <at> #endif +#undef fprintf + +int fprintf(FILE *output,char *lpszMsgFmtStr, ...) +{ + char buf[2048]; + va_list ap; + + if(output != stderr) return 1; + + va_start(ap, lpszMsgFmtStr); + vsnprintf(buf,2048,lpszMsgFmtStr, ap); + va_end(ap); + pstrcat(g_errorbuffer,4096,buf); + return 1; +} + + static int read_ffserver_streams(AVFormatContext *s, const char *filename) { int i, err; <at> <at> -1933,6 +1969,7 <at> <at> av_free_packet(&pkt); /* dump report by using the output first video and audio streams */ + if(g_CallBack(url_ftell(&is->pb),is->file_size)==0) break; print_report(output_files, ost_table, nb_ostreams, 0); } <at> <at> -4161,17 +4198,19 <at> <at> opt_output_file(filename); } -int main(int argc, char **argv) + +int main2(int argc, char **argv) { - int i; + // int i; int64_t ti; - - av_register_all(); - + if(!g_registered) { + av_register_all(); + g_registered = 1; + } if (argc <= 1) show_help(); - else - show_banner(); +// else +// show_banner(); /* parse options */ parse_options(argc, argv, options); <at> <at> -4195,21 +4234,27 <at> <at> printf("bench: utime=%0.3fs\n", ti / 1000000.0); } - /* close files */ - for(i=0;i<nb_output_files;i++) { - /* maybe av_close_output_file ??? */ + +// exit(0); /* not all OS-es handle main() return value */ + return 0; +} + +void clear_converter(void) { + int i; + for(i=0;i<nb_output_files;i++) { AVFormatContext *s = output_files[i]; - int j; - if (!(s->oformat->flags & AVFMT_NOFILE)) - url_fclose(&s->pb); - for(j=0;j<s->nb_streams;j++) - av_free(s->streams[j]); + int j; + if (!(s->oformat->flags & AVFMT_NOFILE)) + url_fclose(&s->pb); + for(j=0;j<s->nb_streams;j++) + av_free(s->streams[j]); av_free(s); } for(i=0;i<nb_input_files;i++) av_close_input_file(input_files[i]); - av_free_static(); +// av_free_static(); + if(intra_matrix) av_free(intra_matrix); <at> <at> -4229,6 +4274,97 <at> <at> exit (255); } #endif - exit(0); /* not all OS-es handle main() return value */ - return 0; + + + + nb_input_files = 0; + nb_output_files = 0; + nb_stream_maps =0; + nb_meta_data_maps = 0; + + +} + + + +_stdcall __declspec(dllexport) int convert( + CallBack callback, + char *arg0, + char *arg1, + char *arg2, + char *arg3, + char *arg4, + char *arg5, + char *arg6, + char *arg7, + char *arg8, + char *arg9, + char *arg10, + char *arg11, + char *arg12, + char *arg13, + char *arg14, + char *arg15, + char *arg16, + char *arg17, + char *arg18, + char *arg19, + char *arg20, + char *arg21, + char *arg22, + char *arg23, + char *arg24, + char *arg25 ) +{ + + char *arg[26]; + int i; + int argc = 1; + + g_CallBack = callback; + arg[0] = arg0; + arg[1] = arg1; + arg[2] = arg2; + arg[3] = arg3; + arg[4] = arg4; + arg[5] = arg5; + arg[6] = arg6; + arg[7] = arg7; + arg[8] = arg8; + arg[9] = arg9; + arg[10] = arg10; + arg[11] = arg11; + arg[12] = arg12; + arg[13] = arg13; + arg[14] = arg14; + arg[15] = arg15; + arg[16] = arg16; + arg[17] = arg17; + arg[18] = arg18; + arg[19] = arg19; + arg[20] = arg20; + arg[21] = arg21; + arg[22] = arg22; + arg[23] = arg23; + arg[24] = arg24; + arg[25] = arg25; + + for(i=1;i<=25;i++) + { + if(*arg[i]) argc++; + else break; + } + strcpy(g_errorbuffer,""); + int retval; + if(setjmp( setjmp_mark ) == 0) { + retval = main2(argc,arg); + }else{ + MessageBox(NULL,g_errorbuffer,"Error",0); + retval = -1; + } + + clear_converter(); + + return retval; } + Index: libavcodec/Makefile =================================================================== RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/Makefile,v retrieving revision 1.167 diff -u -r1.167 Makefile --- libavcodec/Makefile 22 Jan 2005 17:52:00 -0000 1.167 +++ libavcodec/Makefile 31 Jan 2005 12:42:10 -0000 <at> <at> -187,7 +187,7 <at> <at> ifeq ($(TARGET_ARCH_SPARC),yes) OBJS+=sparc/dsputil_vis.o sparc/%.o: sparc/%.c - $(CC) -mcpu=ultrasparc -mtune=ultrasparc $(CFLAGS) -c -o $ <at> $< + $(CC) -mcpu=ultrasparc -mtune=ultrasparc $(CFLAGS) -c $ <at> $< endif ifeq ($(TARGET_ARCH_SPARC64),yes) CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc <at> <at> -231,7 +231,7 <at> <at> $(MAKE) -C libpostproc %.o: %.c - $(CC) $(CFLAGS) -c -o $ <at> $< + $(CC) $(CFLAGS) -c $< %.o: %.S $(CC) $(CFLAGS) -c -o $ <at> $< Index: libavcodec/mem.c =================================================================== RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mem.c,v retrieving revision 1.11 diff -u -r1.11 mem.c --- libavcodec/mem.c 12 Jan 2005 11:14:12 -0000 1.11 +++ libavcodec/mem.c 1 Feb 2005 22:10:45 -0000 <at> <at> -33,6 +33,7 <at> <at> #include <malloc.h> #endif + /* you can redefine av_malloc and av_free in your project to use your memory allocator. You do not need to suppress this file because the linker will do it automatically */ <at> <at> -87,7 +88,8 <at> <at> #else ptr = malloc(size); #endif - return ptr; + + return ptr; } /** <at> <at> -110,6 +112,7 <at> <at> #else return realloc(ptr, size); #endif + } /* NOTE: ptr = NULL is explicetly allowed */ <at> <at> -122,5 +125,7 <at> <at> #else free(ptr); #endif + + ptr = NULL; } |
|
|