--- mpeg_play-2.5-src/Makefile.orig Sat Feb 3 19:57:14 2001 +++ mpeg_play-2.5-src/Makefile Mon Feb 5 00:51:34 2001 @@ -1,17 +1,17 @@ # Step 1: # Set CC to the C compiler you want to use. On Sun, gcc # produces faster code. Your mileage may vary. -CC = gcc +CC = gcc -g #CC = cc # Step 2: # Set INCLUDEDIR equal to -I followed by include directory # path for X11 include files. -INCLUDEDIR = -I/usr/include -I/usr/include/X11 +#INCLUDEDIR = -I/usr/include -I/usr/include/X11 # For Solaris/openwindows -#INCLUDEDIR = -I/usr/include -I/usr/openwin/share/include -I/usr/openwin/include -I/usr/dt/include +INCLUDEDIR = -I/usr/include -I/usr/openwin/share/include -I/usr/openwin/include -I/usr/dt/include # # Step 3: @@ -47,10 +47,10 @@ # To compile as a library (especially reentrant library, see README.lib) # gcc -CFLAGS = -O3 -DNDEBUG -DNONANSI_INCLUDES -DSH_MEM $(INCLUDEDIR) +# CFLAGS = -O3 -DNDEBUG -DNONANSI_INCLUDES -DSH_MEM $(INCLUDEDIR) #Sun Solaris/Openwindows -#CFLAGS = -O3 -DNDEBUG -DBSD -DNONANSI_INCLUDES -DSH_MEM -DSIG_ONE_PARAM $(INCLUDEDIR) +CFLAGS = -O3 -DNDEBUG -DBSD -DNONANSI_INCLUDES -DSH_MEM -DSIG_ONE_PARAM $(INCLUDEDIR) #Linux C Flags #CFLAGS = -O3 -fomit-frame-pointer -ffast-math -finline-functions -m486 -DNDEBUG -DNONANSI_INCLUDES -DSH_MEM -DSIG_ONE_PARAM $(INCLUDEDIR) -DDEFAULT_ORDERED_DITHER @@ -96,7 +96,7 @@ # NOTE: below the default definition are # a few definitions for specific architectures. -LIBS = -L/usr/lib/X11 -lXext -lX11 +# LIBS = -L/usr/lib/X11 -lXext -lX11 # LIBS for MIPS RISC/os 4.5{1,2} #LIBS = -systype sysv -lXext -lX11 -lbsd @@ -108,7 +108,7 @@ #LIBS = -lX11 -lbsd # LIBS for Solaris/Openwindows (some also need -lucb) -#LIBS = -lXext -lX11 -lsocket -lnsl -lw -ldl -lelf +LIBS = -lXext -lX11 -lsocket -lnsl -lw -ldl -lelf # LIBS for SunOS 4.1.3/Openwindows #LIBS = -lXext -lX11 -lnsl -ldl @@ -142,14 +142,14 @@ INSTALL = /etc/install #Solaris INSTALL -#INSTALL = /usr/sbin/install +INSTALL = /usr/sbin/install LD = $(CC) -LDFLAGS = +# LDFLAGS = #Solaris LDFLAGS -#LDFLAGS = -R/usr/openwin/lib:/usr/dt/lib -L/usr/openwin/lib -L/usr/dt/lib +LDFLAGS = -R/usr/openwin/lib:/usr/dt/lib -L/usr/openwin/lib -L/usr/dt/lib MAKEFILE = Makefile @@ -174,11 +174,14 @@ all: $(PROGRAM) -$(PROGRAM): $(OBJS) - $(LD) $(LDFLAGS) $(OBJS) $(LIBS) -lm -o $(PROGRAM) +libmap.a:; (cd map && $(MAKE) $@) + +$(PROGRAM): $(OBJS) libmap.a + $(LD) $(LDFLAGS) $(OBJS) -Lmap -lmap $(LIBS) -lm -o $(PROGRAM) strip $(PROGRAM) clean:; rm -f $(OBJS) core + (cd map && $(MAKE) $@) @make depend clobber:; rm -f $(OBJS) $(PROGRAM) core tags --- mpeg_play-2.5-src/map/Makefile.orig Sun Feb 4 21:19:10 2001 +++ mpeg_play-2.5-src/map/Makefile Sun Feb 4 21:30:39 2001 @@ -3,8 +3,8 @@ ##CC = acc -fast -O4 ##CC = cc -fast -#CC = cc -fast -CC = gcc -g -Wall +CC = cc -fast +#CC = gcc -g -Wall ##CFLAGS = -O2 -DDAMN_INTEL_BYTE_ORDER -DSTDOUT all: maplib_test maplay map --- mpeg_play-2.5-src/map/maplib.c.orig Sun Feb 4 21:17:32 2001 +++ mpeg_play-2.5-src/map/maplib.c Sun Feb 4 23:58:23 2001 @@ -149,7 +149,7 @@ buf[19] = arate & 0xff; buf[23] = chans; - m->write_fn(m->write_fn_data, buf, __441hdr_au_len); + m->write_fn(m->write_fn_data, (void *)buf, __441hdr_au_len); } @@ -171,7 +171,7 @@ buf[24] = arate & 0xff; buf[22] = chans; - m->write_fn(m->write_fn_data, buf, __441hdr_wav_len); + m->write_fn(m->write_fn_data, (void *)buf, __441hdr_wav_len); } m->header_written = 1; --- mpeg_play-2.5-src/readfile.c.orig Wed Nov 1 03:05:34 1995 +++ mpeg_play-2.5-src/readfile.c Mon Feb 5 00:38:14 2001 @@ -995,6 +995,30 @@ else if (packetID == vid_stream->gAudioStreamID) { packetBuffer = (unsigned char *)(*buf_ptr + *length_ptr + 1); fread(packetBuffer, 1, packetDataLength - 1, vid_stream->input); + if (!vid_stream->audio_dump_fp && + vid_stream->audio_dump_name && vid_stream->audio_dump_name[0]) + { + char buf[500]; + + parse_fmt_string(buf, vid_stream->audio_dump_name, vid_stream->filename, 0, 0); + + if (vid_stream->audio_dump_name[0] == '|') + vid_stream->audio_dump_fp = popen(buf+1, "w"); + else + vid_stream->audio_dump_fp = fopen(buf, "w"); + + if (!vid_stream->audio_dump_fp) + { + perror(buf); + vid_stream->audio_dump_name = NULL; /* could not open, shall never try again. */ + } + } + + if (vid_stream->audio_dump_fp) + { + fwrite("\377", 1, 1, vid_stream->audio_dump_fp); + fwrite(packetBuffer, 1, packetDataLength-1, vid_stream->audio_dump_fp); + } } else /* Donno what it is, just nuke it */ { /* This code should be unreachable */ --- mpeg_play-2.5-src/main.c.orig Fri Apr 17 03:29:03 1998 +++ mpeg_play-2.5-src/main.c Mon Feb 5 00:50:13 2001 @@ -162,6 +162,10 @@ int qualityFlag = 0; #endif +char *audio_dump_name = "|play"; +char *audio_dump_name_ppm = "%b.au"; /* Michas mini maplay decodes the audio for us. jw */ +char *ppm_dump_name = "%b_%05d.ppm"; + /* no further error messages */ static BOOLEAN exiting=FALSE; @@ -341,7 +345,11 @@ #endif while (argc) { - if (strcmp(argv[mark], "-nop") == 0) { + if (strcmp(argv[mark], "-audio") == 0) { + argc--; mark++; + audio_dump_name = audio_dump_name_ppm = argv[mark]; + argc--; mark++; + } else if (strcmp(argv[mark], "-nop") == 0) { SetPFlag(TRUE); SetBFlag(TRUE); argc--; mark++; @@ -441,6 +449,16 @@ } framerate = atoi(argv[mark]); argc--; mark++; + + } else if (strcmp(argv[mark], "-ppmname") == 0) { + argc--; mark++; + if (argc < 1) { + perror("Must specify PPM file name after -ppmname flag"); + usage(argv[0]); + } + ppm_dump_name = argv[mark]; + argc--; mark++; + } else if (strcmp(argv[mark], "-ppmwidth") == 0) { argc--; mark++; if (argc < 1) { @@ -449,6 +467,7 @@ } ppm_width = atoi(argv[mark]); argc--; mark++; + } else if (strcmp(argv[mark], "-ppmheight") == 0) { argc--; mark++; if (argc < 1) { @@ -787,6 +806,7 @@ wpixel[2] = 0xff0000; xinfo[0].depth = 24; InitColorDither(1); + audio_dump_name = audio_dump_name_ppm; break; case ORDERED_DITHER: @@ -865,6 +885,9 @@ InitColorDisplay(name, &xinfo[i]); } curVidStream[i] = theStream[i] = NewVidStream((unsigned int) BUF_LENGTH); + theStream[i]->audio_dump_name = audio_dump_name; + theStream[i]->audio_dump_fp = NULL; + theStream[i]->ppm_dump_name = ppm_dump_name; theStream[i]->ppm_width = ppm_width; theStream[i]->ppm_height = ppm_height; theStream[i]->ppm_modulus = ppm_modulus; @@ -1029,6 +1052,7 @@ usage(s) char *s; /* program name */ { + fprintf(stderr, "%s Version %s\n\n", s, VERSION); fprintf(stderr, "Usage:\n"); #ifndef NOCONTROLS fprintf(stderr, "mpeg_play [options] [filename]\n"); @@ -1073,8 +1097,14 @@ #ifdef DCPREC fprintf(stderr, " [-dc {8|9|10|11}] (defaults to 8)\n"); #endif + fprintf(stderr, " [-audio out_file.au] (default '%s', or '%s' with PPM-dump)\n", + audio_dump_name ? audio_dump_name : "", + audio_dump_name_ppm); + fprintf(stderr, " with -dither ppm:\n"); fprintf(stderr, " [-ppmwidth num]\t[-ppmheight num]\t[-ppmskip num]\n"); + fprintf(stderr, " [-ppmname %s]\n", ppm_dump_name); + fprintf(stderr, " (supported format elements: %%d, %%t, %%T, %%n, %%b, %%p) \n", ppm_dump_name); exit (-1); } --- mpeg_play-2.5-src/video.h.orig Wed Oct 25 22:59:38 1995 +++ mpeg_play-2.5-src/video.h Sun Feb 4 23:33:52 2001 @@ -318,6 +318,9 @@ PictImage *ring[RING_BUF_SIZE]; /* Ring buffer of frames. */ /* x,y size of PPM output file */ int ppm_width, ppm_height, ppm_modulus; + char *ppm_dump_name; + char *audio_dump_name; + FILE *audio_dump_fp; } VidStream; typedef struct { @@ -381,6 +384,9 @@ extern int noDisplayFlag; extern int partialFlag, startFrame, endFrame; +extern char *audio_dump_file; +extern FILE *audio_dump_fp; + #ifdef ANALYSIS extern unsigned int bitCount; extern int showEachFlag; @@ -448,4 +454,6 @@ #ifdef __alpha__ #define SIXTYFOUR_BIT #endif + +#define VERSION "2.5 (audio support by jw)" #endif /* video.h already included */ --- mpeg_play-2.5-src/util.c.orig Wed Nov 22 21:18:32 1995 +++ mpeg_play-2.5-src/util.c Mon Feb 5 00:42:46 2001 @@ -493,3 +493,67 @@ /* Return pointer to extra bit info buffer. */ return dataPtr; } + +/* + * use + * %n for the full input filename. + * %b for the input file basename without extension and without path components. + * %p for the input file path components. + * %05d for the current frame number. + * %T for the current image type letter (I, P, B, D) + * %t for the current image type letter (i, p, b, d) in lower case. + * + * All other sprintf sequences are ignored. + * Returns how many frame number escapes were found. + */ +int parse_fmt_string(char *buf, char *fmt, char *filename, int framecount, int pict_type) +{ + static char *path = NULL; + static char *base; + + char *p = NULL; + char *e = NULL; + int byte; + int count = 0; + + if (!path) + { + path = (char *)strdup(filename); + + for (p = path; *p; p++) + if (*p == '/') base = p; + if (base) + *base++ = '0'; + else + base = path; + + for (p = base; *p; p++) + if (*p == '.') e = p; + if (e) *e = '\0'; + } + + p = e = fmt = (char *)strdup(fmt); + + while (*p) + { + while (*e && *e!='%') e++; + while (*e && (*e == '%' || (*e <= '9' && *e >= '0'))) e++; + byte = e[1]; + e[1] = '\0'; + switch (*e) + { + case 'd': *e = 'd'; sprintf(buf, p, framecount); count++; break; + case 'n': *e = 's'; sprintf(buf, p, filename); break; + case 'p': *e = 's'; sprintf(buf, p, path); break; + case 'b': *e = 's'; sprintf(buf, p, base); break; + case 'T': *e = 'c'; sprintf(buf, p, "_IPBD_"[pict_type]); break; + case 't': *e = 'c'; sprintf(buf, p, "_ipbd_"[pict_type]); break; + default: sprintf(buf, "%s", p); break; + } + buf += strlen(buf); + *(++e) = byte; + p = e; + } + free(fmt); + return count; +} --- mpeg_play-2.5-src/gdith.c.orig Wed Oct 25 23:03:58 1995 +++ mpeg_play-2.5-src/gdith.c Mon Feb 5 00:38:02 2001 @@ -1038,7 +1038,7 @@ #ifndef DISABLE_DITHER if (vid_stream->ditherType == NO_DITHER) return; if (vid_stream->ditherType == PPM_DITHER) { - ExecutePPM(vid_stream); + ExecutePPM(vid_stream, 0); return; } #endif @@ -1168,48 +1168,60 @@ */ void -ExecutePPM(vid_stream) - VidStream *vid_stream; +ExecutePPM(vid_stream, close_ppm) + VidStream *vid_stream; + int close_ppm; { - static int munged = 0; - static char mungedInputName[300]; - char fileName[300], cmd[400]; - FILE *file; + extern FILE *popen(const char *, const char *); + + static int separate_files = 0; + static char fileName[500]; + static FILE *file = NULL; int n; unsigned int *p; unsigned int r, g, b; - if (!munged) { - char *cp; - - cp = strrchr(vid_stream->filename, '/'); - if (cp != NULL) - ++cp; - else - cp = vid_stream->filename; - strcpy(mungedInputName, cp); - cp = strrchr(mungedInputName, '.'); - if (cp != NULL) - *cp = '\0'; - munged = 1; - } - - sprintf(fileName, "%s_%05d.ppm", mungedInputName, vid_stream->totNumFrames); - file = fopen(fileName, "w"); - if (vid_stream->ppm_width != -1 && vid_stream->ppm_height != -1) { - if ((vid_stream->ppm_modulus != -1) && - ((vid_stream->totNumFrames-1) % vid_stream->ppm_modulus != 0)) { + if (close_ppm) + { + if (file) + { + if (*fileName == '|') + pclose(file); + else + fclose(file); + } return; - } else { - extern FILE *popen(const char *, const char *); - - sprintf(cmd, "pnmscale -xysize %d %d > %s", - vid_stream->ppm_width, vid_stream->ppm_height, fileName); - file = popen(cmd, "w"); } - } else { - file = fopen(fileName, "w"); - } + + if ((vid_stream->ppm_modulus != -1) && + ((vid_stream->totNumFrames-1) % vid_stream->ppm_modulus != 0)) + return; + + if (!file) + { + fileName[0] = '\0'; + if (vid_stream->ppm_width != -1 && vid_stream->ppm_height != -1) + { + /* + * This is here for backward compatibility. + * We can now do this with a generic popen. jw + */ + sprintf(fileName, "|pnmscale -xysize %d %d %s", + vid_stream->ppm_width, vid_stream->ppm_height, + (vid_stream->ppm_dump_name[0] == '|') ? "" : ">"); + } + + separate_files = parse_fmt_string(fileName + strlen(fileName), + vid_stream->ppm_dump_name, + vid_stream->filename, + vid_stream->totNumFrames, + vid_stream->picture.code_type); + if (*fileName == '|') + file = popen(fileName+1, "w"); + else + file = fopen(fileName, "w"); + } + if (file == NULL) { perror(fileName); exit(1); @@ -1232,11 +1244,14 @@ --n; } - if (vid_stream->ppm_width != -1 && vid_stream->ppm_height != -1) { - pclose(file); - } else { - fclose(file); - } + if (separate_files) + { + if (*fileName == '|') + pclose(file); + else + fclose(file); + file = NULL; + } } #endif --- mpeg_play-2.5-src/video.c.orig Wed Mar 18 02:06:25 1998 +++ mpeg_play-2.5-src/video.c Sun Feb 4 23:56:39 2001 @@ -844,6 +844,17 @@ { int i; + ExecutePPM(astream, 1); /* closing ppm stream, if any */ + + if (astream->audio_dump_fp) + { + if (astream->audio_dump_name[0] == '|') + pclose(astream->audio_dump_fp); + else + fclose(astream->audio_dump_fp); + astream->audio_dump_fp = NULL; + } + if (astream->ext_data != NULL) free(astream->ext_data); --- mpeg_play-2.5-src/proto.h.orig Wed Feb 21 01:24:36 1996 +++ mpeg_play-2.5-src/proto.h Sun Feb 4 23:49:02 2001 @@ -105,7 +105,7 @@ #else void ExecuteDisplay P((VidStream *vid_stream, XInfo *xinfo )); #endif -void ExecutePPM P((VidStream *vid_stream )); +void ExecutePPM P((VidStream *vid_stream, int close_ppm )); #ifdef NO_GETTIMEOFDAY struct timeval {long tv_sec, tv_usec;}; /* secs and usecs since 1-jan-1970 */ int gettimeofday P((struct timeval * retval, void * unused));