Date: Mon, 21 Jul 2003 12:54:08 -0500 (CDT) From: Matthew Reimer <mreimer@vpop.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/54855: PATCH: fix mjpegtools divx tools segfaults Message-ID: <200307211754.h6LHs8do015064@bilbo.vpop.net> Resent-Message-ID: <200307251530.h6PFUJUW085633@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 54855 >Category: ports >Synopsis: PATCH: fix mjpegtools divx tools segfaults >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jul 25 08:30:19 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Matthew Reimer >Release: FreeBSD 4.8-STABLE i386 >Organization: >Environment: System: FreeBSD bilbo.vpop.net 4.8-STABLE FreeBSD 4.8-STABLE #6: Sat Jul 5 14:18:50 CDT 2003 root@bilbo.vpop.net:/usr/obj/usr/src/sys/BILBO i386 -stable mjpegtools 1.6.1 avifile-0.7.34.20030319,2 >Description: Running any of the divx tools (lav2divx, yuv2divx, divxdec) results in a segfault. >How-To-Repeat: Run any of the divx tools (lav2divx, yuv2divx, divxdec). >Fix: From http://sourceforge.net/mailarchive/message.php?msg_id=4333933: --- lavtools/divxdec.cpp.orig Mon Jul 21 12:37:07 2003 +++ lavtools/divxdec.cpp Mon Jul 21 12:11:58 2003 @@ -106,7 +106,7 @@ #include <sys/time.h> #include <unistd.h> // Needed for the access call to check if file exists #include <getopt.h> // getopt -#include <stdint.h> // standard integer types +#include <sys/types.h> // standard integer types #include <stdlib.h> // standard library with integer division #include <stdio.h> #include <config.h> @@ -211,7 +211,7 @@ fmt = RIFFINFO_IYUV; } // only in avifile-0.6 -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 else if ( caps & IVideoDecoder::CAP_I420 ) { fmt = RIFFINFO_I420; @@ -595,7 +595,7 @@ // end of data, yes? return 0; } -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 currentFrame.inputBuffer = imsrc->Data (); #else currentFrame.inputBuffer = imsrc->data (); @@ -634,7 +634,7 @@ break; } // done with image. ( was delete imsrc; ) -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 imsrc->Release() ; #else imsrc->release() ; @@ -944,7 +944,7 @@ mjpeg_debug ( "VIDEO: Using decoder %s", sFourCC ); fourCCToString ( input.files[input.currentFile].outputCodec, sFourCC ); mjpeg_debug ( "VIDEO: Using interim YUV format %s", sFourCC ); -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 input.files[input.currentFile].frames = input.invstream->GetLength (); #else input.files[input.currentFile].frames = input.invstream->GetEndPos (); @@ -957,7 +957,7 @@ input.inastream->StartStreaming (); if ( input.files[input.currentFile].frames == 0) { -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 input.files[input.currentFile].frames = input.inastream->GetLength (); #else input.files[input.currentFile].frames = input.inastream->GetEndPos (); @@ -973,14 +973,14 @@ // key frame. if ( input.processVideo ) { -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 framepos_t fp = input.invstream->SeekToKeyFrame ( firstFrame ); #else framepos_t fp = input.invstream->SeekToKeyframe ( firstFrame ); #endif if ( input.processAudio ) { -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 double pos = input.invstream->GetTime ( max( 0, fp - 1 ) ); input.inastream->SeekTime ( pos ); #else @@ -1284,7 +1284,7 @@ exit (1); } -FILE* real_stdout; +FILE real_stdout; int main (int argc, char **argv) @@ -1309,16 +1309,20 @@ std::cout.rdbuf ( std::cerr.rdbuf () ); // // 4. keep old stdout FILE, and use stderr in its place (for printf ("...") ; ) - real_stdout = stdout ; - stdout = stderr; + real_stdout = *stdout ; + *stdout = *stderr; displayGreeting(); if ( GetAvifileVersion ( ) != AVIFILE_VERSION ) { - mjpeg_error_exit1 ( "This binary was compiled for Avifile version %.2f but the library is %.2f" - , AVIFILE_VERSION - , GetAvifileVersion () ); + mjpeg_error_exit1 ( "This binary was compiled for Avifile version %d.%d.%d but the library is %d.%d.%d" + , AVIFILE_VERSION >> 16 + , (AVIFILE_VERSION >> 8) & 0xff + , AVIFILE_VERSION & 0xff + , GetAvifileVersion () >> 16 + , (GetAvifileVersion () >> 8) & 0xff + , GetAvifileVersion () & 0xff); } ( void ) mjpeg_default_handler_verbosity ( 3 ); @@ -1583,7 +1587,7 @@ inastream = file->GetStream ( 0, AviStream::Audio ); mjpeg_debug ( "AUDIO stream queried" ); } -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 input.files[i].frames = invstream->GetLength(); #else input.files[i].frames = invstream->GetEndPos (); @@ -1733,7 +1737,7 @@ if ( 0 == strcmp ( "-", filenameYUV ) ) { //output.fdYUV = FD_STDOUT; - output.fdYUV = fileno ( real_stdout ); + output.fdYUV = fileno ( &real_stdout ); } else { @@ -2042,7 +2046,7 @@ freeAll (); // reassign cout, stdout to their original values. std::cout.rdbuf ( real_cout ); - stdout = real_stdout; + *stdout = real_stdout; mjpeg_info ( " " ); mjpeg_info ( "Done. %i frames", output.processedFrames ); --- lavtools/lav2divx.cpp.orig Mon Jul 21 12:33:21 2003 +++ lavtools/lav2divx.cpp Mon Jul 21 12:11:43 2003 @@ -218,7 +218,7 @@ printf ( " -s --forcedaudiorate\taudio sample rate of input file (Hz);\n\t\t\tuse only if avifile gets it wrong\n" ); printf ( " -n --noise\t\tnoise filter (0..2, default 0)\n" ); printf ( " -g --guess\t\tguess values for -c and -z options\n" ); -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 printf ( " -L --listcodecs\tdisplay available avifile codecs (LONG)\n" ); printf ( " -k --keyframes\tset keyframes attribute (default 15)\n" ); printf ( " -C --crispness\tset crispness attribute (default 20)\n" ); @@ -256,7 +256,7 @@ mjpeg_info ( "-----------------------------" ); } -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 static void listCodecs ( ) { @@ -289,9 +289,13 @@ if ( GetAvifileVersion ( ) != AVIFILE_VERSION ) { - mjpeg_error_exit1 ( "This binary was compiled for Avifile version %s but the library is %s" - , AVIFILE_VERSION - , GetAvifileVersion ( ) ); + mjpeg_error_exit1 ( "This binary was compiled for Avifile version %d.%d.%d but the library is %d.%d.%d" + , AVIFILE_VERSION >> 16 + , (AVIFILE_VERSION >> 8) & 0xff + , AVIFILE_VERSION & 0xff + , GetAvifileVersion ( ) >> 16 + , (GetAvifileVersion ( ) >> 8) & 0xff + , GetAvifileVersion ( ) & 0xff); } ( void ) mjpeg_default_handler_verbosity ( 1 ); @@ -315,7 +319,7 @@ int opt_h = 0; int opt_mono = 0; -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 int opt_keyframes = 15; int opt_crispness = 20; #endif @@ -379,7 +383,7 @@ {"video_stream", required_argument, NULL, 'V'}, {"number_cpus", required_argument, NULL, 'U'}, {"outputfile", required_argument, NULL, 'o'}, -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 {"keyframes", required_argument, NULL, 'k'}, {"crispness", required_argument, NULL, 'C'}, {"listcodecs", no_argument, NULL, 'L'}, @@ -391,7 +395,7 @@ }; copt = -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 getopt_long ( argc, argv, "LE:fa:e:c:b:o:s:gmvk:C:", long_options, &option_index ); #else getopt_long ( argc, argv, "E:fa:e:c:b:o:s:gmv", long_options, &option_index ); @@ -449,7 +453,7 @@ outputfile = optarg; break; -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 case 'k': opt_keyframes = atoi ( optarg ); break; @@ -681,7 +685,7 @@ avifile = CreateIAviWriteFile ( outputfile ); -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 const CodecInfo *codecInfo = CodecInfo::match ( fccHandler ); if (codecInfo == NULL) { --- lavtools/libavifile.h.orig Thu Apr 25 00:49:12 2002 +++ lavtools/libavifile.h Mon Jul 21 12:13:05 2003 @@ -32,18 +32,18 @@ #include <videoencoder.h> // Correct the version numbers -#if AVIFILE_MAJOR_VERSION == 0 -#if AVIFILE_MINOR_VERSION == 6 -#undef AVIFILE_MINOR_VERSION -#define AVIFILE_MINOR_VERSION 60 -#elif AVIFILE_MINOR_VERSION == 7 -#undef AVIFILE_MINOR_VERSION -#define AVIFILE_MINOR_VERSION 70 -#endif /* AVIFILE_MINOR_VERSION == 6/7 */ -#endif /* AVIFILE_MAJOR_VERSION == 0 */ +//#if AVIFILE_MAJOR_VERSION == 0 +//#if AVIFILE_MINOR_VERSION == 6 +//#undef AVIFILE_MINOR_VERSION +//#define AVIFILE_MINOR_VERSION 60 +//#elif AVIFILE_MINOR_VERSION == 7 +//#undef AVIFILE_MINOR_VERSION +//#define AVIFILE_MINOR_VERSION 70 +//#endif /* AVIFILE_MINOR_VERSION == 6/7 */ +//#endif /* AVIFILE_MAJOR_VERSION == 0 */ // Import version-dependent headers -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION < 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION < 6 #include <aviutil.h> typedef unsigned int framepos_t; #else --- lavtools/yuv2divx.cpp.orig Mon Jul 21 12:33:21 2003 +++ lavtools/yuv2divx.cpp Mon Jul 21 12:16:28 2003 @@ -267,7 +267,7 @@ printf ( " -d --droplsb\t\tdrop x least significant bits (0..3, default 0)\n" ); printf ( " -n --noise\t\tnoise filter (0..2, default 0)\n" ); printf ( " -g --guess\t\tguess values for -c and -z options\n" ); -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 printf ( " -k --keyframes\tset keyframes attribute (default 15)\n" ); printf ( " -C --crispness\tset crispness attribute (default 20)\n" ); printf ( " -L --listcodecs\tshow the list of avifile codecs (LONG!)\n" ); @@ -306,7 +306,7 @@ mjpeg_info ( "-----------------------------" ); } -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 static void listCodecs ( ) { @@ -340,9 +340,13 @@ if ( GetAvifileVersion ( ) != AVIFILE_VERSION ) { - mjpeg_error_exit1 ( "This binary was compiled for Avifile version %s but the library is %s" - , AVIFILE_VERSION - , GetAvifileVersion ( ) ); + mjpeg_error_exit1 ( "This binary was compiled for Avifile version %d.%d.%d but the library is %d.%d.%d" + , AVIFILE_VERSION >> 16 + , (AVIFILE_VERSION >> 8) & 0xff + , AVIFILE_VERSION & 0xff + , GetAvifileVersion ( ) >> 16 + , (GetAvifileVersion ( ) >> 8) & 0xff + , GetAvifileVersion ( ) & 0xff); } ( void ) mjpeg_default_handler_verbosity ( 1 ); @@ -380,7 +384,7 @@ int audio_bytes; -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 int opt_keyframes = 15; int opt_crispness = 20; #endif @@ -429,7 +433,7 @@ {"outputfile", required_argument, NULL, 'o'}, {"droplsb", required_argument, NULL, 'd'}, {"noise", required_argument, NULL, 'n'}, -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 {"keyframes", required_argument, NULL, 'k'}, {"crispness", required_argument, NULL, 'C'}, {"listcodecs", no_argument, NULL, 'L' }, @@ -441,7 +445,7 @@ }; copt = -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 getopt_long ( argc, argv, "F:E:A:a:w:h:e:c:b:o:s:n:d:gvVLk:C:", long_options, &option_index ); #else getopt_long ( argc, argv, "F:E:A:a:w:h:e:c:b:o:s:n:d:gvV", long_options, &option_index ); @@ -503,7 +507,7 @@ audioexist = 1; break; -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 case 'k': opt_keyframes = atoi ( optarg ); break; @@ -769,7 +773,7 @@ avifile = CreateIAviWriteFile ( outputfile ); -#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 60 +#if AVIFILE_MAJOR_VERSION == 0 && AVIFILE_MINOR_VERSION >= 6 const CodecInfo *codecInfo = CodecInfo::match ( opt_codec ); if ( codecInfo == NULL ) { >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200307211754.h6LHs8do015064>