Index: src/comskip.c =================================================================== --- src/comskip.c (revision 92) +++ src/comskip.c (working copy) @@ -12,21 +12,29 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +#include "config.h" #include #include #include #include #include -#include // needed for play_nice routines -#include // needed for sleep command -#include // needed for getcwd +#include // needed for play_nice routines #include -#include "config.h" + +#ifndef LINUX +#include // needed for sleep command +#include // needed for getcwd +#include +#else +#include +#include +#define MAX_PATH 256 +#endif + +#include #include -#include #include "mpeg2.h" #include "mpeg2convert.h" -#include "argtable2.h" #define bool int #define true 1 #define false 0 @@ -54,6 +62,11 @@ // max number of frames that can be marked #define MAX_IDENTIFIERS 300000 #define MAX_COMMERCIALS 1000 + +extern char ProgramName[]; +extern char ProgramArgs[]; +extern char InputFilename[]; + int argument_count; char ** argument = NULL; bool initialized = false; @@ -116,7 +129,7 @@ struct logo_block_info* logo_block = NULL; long logo_block_count = 0; // How many groups have already been identified. Increment after fill. long max_logo_block_count; -extern bool processCC = false; +bool processCC = false; struct ccPacket { unsigned char c1; @@ -1147,6 +1160,14 @@ }; int nerrors; int exitcode = 0; +#ifndef LINUX + sprintf(inifilename,"%s\\comskip.ini",HomeDir); + sprintf(exefilename,"%s\\comskip.exe",HomeDir); +#else + sprintf(inifilename,"%s/comskip.ini",HomeDir); + sprintf(exefilename,"%s/comskip",HomeDir); +#endif + sprintf(incomingCommandLine, ""); if (strchr(argv[0], ' ')) { sprintf(incomingCommandLine, "\"%s\"", argv[0]); @@ -1198,7 +1219,7 @@ exit(2); } - if (strcmp(in->extension[0], ".mpg") == 0 || strcmp(in->extension[0], ".mpeg") == 0) { + if (strcmp(in->extension[0], ".mpg") == 0 || strcmp(in->extension[0], ".mpeg") == 0 || strcmp(in->extension[0], ".nuv") == 0) { sprintf(mpegfilename, "%s", in->filename[0]); in_file = fopen(in->filename[0], "rb"); printf("Opening %s\n", in->filename[0]); @@ -1237,10 +1258,15 @@ ini_file = fopen(inifilename, "r"); if (!ini_file) { +#ifdef LINUX + printf("Can't proceed until search is figured out\n"); + exit(-1); +#else printf("No INI file found in current directory. Searching PATH...\n"); FindIniFile(); printf("INI file found at %s\n", inifilename); ini_file = fopen(inifilename, "r"); +#endif } if (ini_file) { @@ -1289,6 +1315,8 @@ if ((tmp = FindNumber(data, "cc_commercial_type_modifier=")) > -1) cc_commercial_type_modifier = (double)tmp; if ((tmp = FindNumber(data, "cc_wrong_type_modifier=")) > -1) cc_wrong_type_modifier = (double)tmp; if ((tmp = FindNumber(data, "cc_correct_type_modifier=")) > -1) cc_correct_type_modifier = (double)tmp; + if ((tmp = FindNumber(data, "width=")) > -1) width = (int)tmp; + if ((tmp = FindNumber(data, "height=")) > -1) height = (int)tmp; } else { printf("No INI file found anywhere!!!!\n"); } @@ -2860,6 +2888,10 @@ FILE* batfile = NULL; time_t ltime; time(<ime); + +#ifdef LINUX + sprintf(commandLine, "%s %s %s", ProgramName, ProgramArgs, InputFilename); +#else if (strcmp(HomeDir, ".") == 0) { sprintf(batfilename, "comskip.bat"); } else { @@ -2871,6 +2903,7 @@ } else { sprintf(commandLine, "%s", batfilename); } +#endif sprintf(debugText, "Using commandline - %s\n", commandLine); Debug(3); @@ -2885,6 +2918,12 @@ fclose(log_file); } +#ifdef LINUX + fcloseall(); + strcpy(debugText, "Closed all files\n" ); + Debug(3); + if (system(commandLine)) { +#else batfile = fopen(batfilename, "w"); if (batfile) { fprintf(batfile, incomingCommandLine); @@ -2903,6 +2942,7 @@ Debug(1); } +#endif exit(0); } else { startOverAfterLogoInfoAvail = false; @@ -3051,6 +3091,7 @@ initialized = true; } +#ifndef LINUX void FindIniFile(void) { char searchinifile[] = "comskip.ini"; char searchexefile[] = "comskip.exe"; @@ -3073,6 +3114,7 @@ Debug(1); } } +#endif double FindScoreThreshold(double percentile) { int i; @@ -3209,7 +3251,7 @@ Debug(5); for (i = 0; i < logo_block_count; i++) { for (j = logo_block[i].start; j <= logo_block[i].end; j++) { - frame[j].logo_present = TRUE; + frame[j].logo_present = true; } } @@ -3904,7 +3946,7 @@ break; default: - itoa(type, tempString, 10); + sprintf(tempString, "%d", type); break; } } else { @@ -3945,4 +3987,4 @@ } return (type); -} \ No newline at end of file +} Index: src/config.h =================================================================== --- src/config.h (revision 0) +++ src/config.h (revision 0) @@ -0,0 +1,12 @@ +#define PACKAGE "comskip-linux" + +#define VERSION "20041029-0005" + +#define LINUX + +#ifdef LINUX +#define Sleep(x) sleep(x) +#endif + +#define max(a,b) ((a)>(b)?(a):(b)) +#define min(a,b) ((a)<(b)?(a):(b)) Index: src/README.linux =================================================================== --- src/README.linux (revision 0) +++ src/README.linux (revision 0) @@ -0,0 +1,23 @@ +The Makefile for Linux is a quick hack and has several hard-coded values. + +External packages needed prior to compilation: + + mpeg2dec v0.4.0 (or v0.4.0b) + http://libmpeg2.sourceforge.net/ + + argtable2 v2.x.y + http://argtable.sourceforge.net/ + +mpeg2dec v0.4.0 must reside in ../../mpeg2dec-0.4.0 relative to the comskip +src directory. This value is hardcoded at the top of the Makefile. This is +because comskip needed to link against libvo from mpeg2dec. mpeg2dec v0.4.0 +is also expected to be installed so that its normal libs can be linked in +when comskip is linked. + +If argtable2 is installed normally, then it should be linked in properly by +the Makefile. + +After installing the above prerequesits, just type "make" from inside the +src directory and you should end up with a "comskip" program executable under +Linux. + Index: src/mpeg2dec.c =================================================================== --- src/mpeg2dec.c (revision 92) +++ src/mpeg2dec.c (working copy) @@ -20,9 +20,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" + +#ifndef LINUX #include +#endif -#include "config.h" #include #include #include @@ -57,6 +60,10 @@ static int total_offset = 0; static int verbose = 0; +char ProgramName[1024] = ""; +char ProgramArgs[1024] = ""; +char InputFilename[1024] = ""; + //*** added extern FILE * out_file; extern uint8_t ccData[500]; @@ -718,9 +725,12 @@ drivers = vo_drivers (); +#ifndef LINUX //added windows specific SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); +#endif + //print_usage (argv); @@ -752,6 +762,7 @@ fprintf (stderr, PACKAGE"-"VERSION " - by Michel Lespinasse and Aaron Holtzman\n"); + strcpy(ProgramName, argv[0]); handle_args (argc, argv); in_file = LoadSettings(argc, argv); //added Index: src/Makefile =================================================================== --- src/Makefile (revision 0) +++ src/Makefile (revision 0) @@ -0,0 +1,30 @@ +MPEG2DEC = ../../mpeg2dec-0.4.0 +VODIR = $(MPEG2DEC)/libvo +LIBVOLIBS = -lSM -lICE -L/usr/X11R6/lib -lX11 -lXext -lXv -L/usr/lib \ + -Wl,-rpath,/usr/lib -lSDL -lpthread + +LOCAL = /usr/local + +CFLAGS = -I /usr/local/include/mpeg2dec -I $(MPEG2DEC)/include +CFLAGS += -g +LDFLAGS = -L $(LOCAL)/lib $(MPEG2DEC)/libvo/libvo.a +LDFLAGS += -lmpeg2 -lmpeg2convert -largtable2 + +VO_OBJS = $(VODIR)/video_out.o $(VODIR)/video_out_dx.o \ + $(VODIR)/video_out_null.o $(VODIR)/video_out_pgm.o \ + $(VODIR)/video_out_sdl.o $(VODIR)/video_out_x11.o + +SOURCES = comskip.c dump_state.c getopt.c gettimeofday.c mpeg2dec.c +OBJECTS = comskip.o dump_state.o getopt.o gettimeofday.o mpeg2dec.o + +all: comskip + +comskip: $(OBJECTS) + ${CC} -o comskip $(LDFLAGS) $(OBJECTS) $(VO_OBJS) $(LIBVOLIBS) + +.c.o: + ${CC} -c $(CFLAGS) -o $@ $< + +clean: + rm *.o comskip +