From: pottier@clipper.ens.fr (Francois Pottier) Subject: csmp-digest-v3-104 Date: Tue, 11 Jul 1995 13:49:34 +0200 (MET DST) C.S.M.P. Digest Tue, 11 Jul 95 Volume 3 : Issue 104 Today's Topics: Tools for finding mem. leaks-overwrites [Q] How do you create a JFIF file with Quicktime's JPEG? The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier (pottier@clipper.ens.fr). The digest is a collection of article threads from the internet newsgroups comp.sys.mac.programmer.help, csmp.tools and csmp.misc. It is designed for people who read news semi-regularly and want an archive of the discussions. If you don't know what a newsgroup is, you probably don't have access to it. Ask your systems administrator(s) for details. If you don't have access to news, you may still be able to post messages to the group by using a mail server like anon.penet.fi (mail help@anon.penet.fi for more information). Each issue of the digest contains one or more sets of articles (called threads), with each set corresponding to a 'discussion' of a particular subject. The articles are not edited; all articles included in this digest are in their original posted form (as received by our news server at nef.ens.fr). Article threads are not added to the digest until the last article added to the thread is at least two weeks old (this is to ensure that the thread is dead before adding it to the digest). Article threads that consist of only one message are generally not included in the digest. The digest is officially distributed by two means, by email and ftp. If you want to receive the digest by mail, send email to listserv@ens.fr with no subject and one of the following commands as body: help Sends you a summary of commands subscribe csmp-digest Your Name Adds you to the mailing list signoff csmp-digest Removes you from the list Once you have subscribed, you will automatically receive each new issue as it is created. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest. Questions related to the ftp site should be directed to scott.silver@dartmouth.edu. ------------------------------------------------------- >From krev@netcom.com (Umberto milletti) Subject: Tools for finding mem. leaks-overwrites Date: Mon, 19 Jun 1995 22:30:32 GMT Organization: NETCOM On-line Communication Services (408 261-4700 guest) I'm looking for tools that will find memory overwrites (out-of-bounds writes and such), memory leaks and other nasty stuff that's hard to track down without good tools. Other tools I've used in the past that fit this bill are purify/ quantify from Pure, and Boundschecker from NuMega, but I don't think either has a mac version. We're kind of desperate, trying to track down a nasty overwrite. Thanks in advance (please send email, as I don't read this all the time), Umberto@krev.com +++++++++++++++++++++++++++ >From jake@presage.com (Jake Hoelter) Date: Mon, 19 Jun 1995 22:40:08 -0800 Organization: Presage Software In article , krev@netcom.com (Umberto milletti) wrote: >I'm looking for tools that will find memory overwrites (out-of-bounds writes >and such), memory leaks and other nasty stuff that's hard to track down without >good tools. Other tools I've used in the past that fit this bill are purify/ >quantify from Pure, and Boundschecker from NuMega, but I don't think either >has a mac version. >We're kind of desperate, trying to track down a nasty overwrite. There's two tools that are great to use for tracking down leaks. First is Metrowerks' ZoneRanger. It comes with CodeWarrior, plus I think they freely distribute it, so you can download it from wherever. The other tool is QC from Onyx Technology. QC will let you find overwrites, underwrites, invalidate memory, do heap stressing (scramble, purge), and a bunch of other cool stuff. QC costs about $100.00. You can contact Onyx at (813) 795-7801. Or at onyxtech@aol.com. There's a free demo version of QC floating around the nets somewhere. Between the two of those tools you can track down most memory problems on the Mac. Jake Hoelter Presage Software jake@presage.com +++++++++++++++++++++++++++ >From pbenson@iona.ie (Paddy Benson) Date: Wed, 21 Jun 1995 13:32:35 +0000 Organization: IONA Technologies In article , krev@netcom.com (Umberto milletti) wrote: > I'm looking for tools that will find memory overwrites (out-of-bounds writes > and such), memory leaks and other nasty stuff that's hard to track down MacsBug has a leaks dcmd. This is available on the developer CDs. Also MacsBug has a built in StepSpy (SS) command to check when a range in memory changes Paddy -- - --------------------------------------------------------------------- Paddy Benson (IT Design) email: pbenson@iona.ie (on contract to...) IONA Technologies Ltd, ftp: ftp.iona.ie 8-34 Percy Place, www: http://www.iona.ie/ Dublin 4, ph: +353-1-668-6522 Republic of Ireland. fax: +353-1-668-6573 - --------------------------------------------------------------------- +++++++++++++++++++++++++++ >From jordanz@altura.com (Jordan Zimmerman) Date: Wed, 21 Jun 1995 18:10:25 -0800 Organization: Altura Software, Inc. > I'm looking for tools that will find memory overwrites (out-of-bounds writes > and such), memory leaks and other nasty stuff that's hard to track down without > good tools. Other tools I've used in the past that fit this bill are purify/ > quantify from Pure, and Boundschecker from NuMega, but I don't think either > has a mac version. > We're kind of desperate, trying to track down a nasty overwrite. > Thanks in advance (please send email, as I don't read this all the time), > Umberto@krev.com QC (fron Qnyx Technologies), DoubleTrouble & DisposeResource (on Apple Developer CD, etc.), Jasik's Debugger - to name a few. -- Jordan Zimmerman, Altura Software home page: http://www.altura.com/jordanz/home.html Who is John Galt? +++++++++++++++++++++++++++ >From isis@netcom.com (Mike Cohen) Date: Thu, 22 Jun 1995 23:33:12 GMT Organization: ISIS International jordanz@altura.com (Jordan Zimmerman) writes: >QC (fron Qnyx Technologies), DoubleTrouble & DisposeResource (on Apple >Developer CD, etc.), Jasik's Debugger - to name a few. Do you know of anything similar to QC for windoze? I'm trying to debug a memory overwrite problem in some mac code ported to Visual C++. -- Mike Cohen - isis@netcom.com Home Page: ftp://ftp.netcom.com/pub/is/isis/home.html PUSH THE BUTTON... SOMEONE +++++++++++++++++++++++++++ >From jordanz@altura.com (Jordan Zimmerman) Date: Fri, 23 Jun 1995 09:48:50 -0800 Organization: Altura Software, Inc. > In article , krev@netcom.com (Umberto milletti) > wrote: > > > I'm looking for tools that will find memory overwrites (out-of-bounds writes > > and such), memory leaks and other nasty stuff that's hard to track down > > MacsBug has a leaks dcmd. This is available on the developer CDs. Also > MacsBug has a built in StepSpy (SS) command to check when a range in > memory changes > In addition to the commercial/freeware tools out there, I usually build leak checking into my code directly. Using the C preprocessor, you define all memory allocation routines to shells that record the allocation. eg. #define NewHandle(size) RecordNewHandle(size, __FILE__, __LINE__) #define DisposeHandle(h) RecordDisposeHandle(h) So, RecordNewHandle calls NewHandle, saves the handle in an array (also saving which file and line it came from). RecordDisposeHandle removes the allocation from the array. At the end of the program, if you have allocations left in your array, there's a leak. You can use the saved file name and line number to find where it was allocated. This method takes some time to implement (there are a _lot_ of potential allocators), but in the end is really useful. Also, having the info can be used for finding memory corruption, etc. -- Jordan Zimmerman, Altura Software home page: http://www.altura.com/jordanz/home.html Who is John Galt? +++++++++++++++++++++++++++ >From aparajit@natural.com (Aparajita Fishman) Date: 25 Jun 1995 02:11:47 GMT Organization: Natural Intelligence, Inc. > In article , krev@netcom.com (Umberto milletti) > wrote: > > > I'm looking for tools that will find memory overwrites (out-of-bounds writes > > and such), memory leaks and other nasty stuff that's hard to track down Contact info@microquill.com about their product SmartHeap. It's a complete replacement for the memory manager which not only does leak/overwrite detection and so forth, but is also a significantly faster allocator over time than the allocators that come with any compiler on the market. \_ \_ \_ ----------------------------------------------- \_\_\_ \_ Aparajita Fishman aparajita@natural.com \_ \__ \_ Software Developer tel (718) 262-8022 \_ \_ \_ Natural Intelligence, Inc. fax (718) 262-8022 --------------------------- >From oster@netcom.com (David Phillip Oster) Subject: [Q] How do you create a JFIF file with Quicktime's JPEG? Date: Mon, 12 Jun 1995 04:34:57 GMT Organization: Netcom Online Communications Services (408-241-9760 login: guest) The QuickTime volume of Inside Macintosh sample code that works for making a PICT file that has a JPEG compressed image. How do you make a valid file of type JFIF? I've tried just writing the data from QuickTime's FCompressImage into a file, but programs that know JFIF say that that isn't a valid JFIF file. Where is the JFIF file documented? -- - ------- ---------- Ahh! The thorazine is wearing off and the odinazine is coming on... +++++++++++++++++++++++++++ >From oster@netcom.com (David Phillip Oster) Date: Tue, 13 Jun 1995 00:34:47 GMT Organization: Netcom Online Communications Services (408-241-9760 login: guest) In article oster@netcom.com (I) write: >The QuickTime volume of Inside Macintosh sample code that works for making >a PICT file that has a JPEG compressed image. >How do you make a valid file of type JFIF? I've tried just writing the data >from QuickTime's FCompressImage into a file, but programs that know JFIF >say that that isn't a valid JFIF file. >Where is the JFIF file documented? Well, I pulled out a handy CD-ROM of usenet faqs, and found two ways to solve my problem: 1.) source code for reading and writing JPEG files. Free, portable C code for JPEG compression is available from the Independent JPEG Group. A package containing our source code, documentation, and some small test files is available from ftp.uu.net (192.48.96.9) in directory /graphics/jpeg. The current release is v5, file jpegsrc.v5.tar.gz. You can retrieve this file by FTP or UUCP. If you are on a PC and don't know how to cope with .tar.gz format, you may prefer ZIP format, which you can find at Simtel archive sites (see NOTE above), file msdos/graphics/jpegsrc5.zip. On CompuServe, see the GRAPHSUPPORT forum (GO GRAPHSUP), library 15, file jpsrc5.zip. 2.) A kluge that is quick and easy: [11] How do I recognize which file format I have, and what do I do about it? If you have an alleged JPEG file that your software won't read, it's likely to be HSI format or some other proprietary JPEG-based format. You can tell what you have by inspecting the first few bytes of the file: 1. A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0, followed by two variable bytes (often hex 00 10), followed by 'JFIF'. 2. If you see FF D8 at the start, but not the 'JFIF' marker, you may have a "raw JPEG" file. This is probably decodable as-is by JFIF software --- it's worth a try, anyway. 3. HSI files start with 'hsi1'. You're out of luck unless you have HSI software. Portions of the file may look like plain JPEG data, but they won't decompress properly with non-HSI programs. 4. A Macintosh PICT file, if JPEG-compressed, will have several hundred bytes of header (often 726 bytes, but not always) followed by JPEG data. Look for the 3-byte sequence (hex) FF D8 FF --- the text 'Photo - JPEG' will usually appear shortly before this header, and 'JFIF' or 'AppleMark' will usually appear shortly after it. Strip off everything before the FF D8 FF and you should be able to decode the file. - ------------- In code, that looks like this: /* TrimToJFIF - according to the JPEG FAQ, JFIF embedded in Apple starts with FF D8 FF */ static OSErr TrimToJFIF(Handle h){ static char start[] = { 0xFF, 0xD8, 0xFF}; long offset, len; offset = Munger(h, 0, start, 3, NULL, 0); if(offset > 0){ len = GetHandleSize(h); BlockMoveData(*h + offset, *h, len - offset); SetHandleSize(h, len - offset); return noErr; } return eJPEGFormatFailure; } I've tried it, and it works! -- - ------- ---------- Ahh! The thorazine is wearing off and the odinazine is coming on... +++++++++++++++++++++++++++ >From ldo@waikato.ac.nz (Lawrence D9Oliveiro) Date: Tue, 13 Jun 1995 17:41:34 +1200 Organization: University of Waikato In article , oster@netcom.com (David Phillip Oster) wrote: >I've tried just writing the data >from QuickTime's FCompressImage into a file, but programs that know JFIF >say that that isn't a valid JFIF file. That should really be all there is to it. To check that you've written the data properly, have you tried reading it back and putting it through FDecompressImage with the same ImageDescriptionhandle? +++++++++++++++++++++++++++ >From bas@luna.nl (Bas A. Schulte) Date: Tue, 13 Jun 1995 09:59:22 +0200 Organization: Models, Inc. In article , oster@netcom.com (David Phillip Oster) wrote: > >How do you make a valid file of type JFIF? I've tried just writing the data > >from QuickTime's FCompressImage into a file, but programs that know JFIF > >say that that isn't a valid JFIF file. [stuff deleted] > static OSErr TrimToJFIF(Handle h){ > static char start[] = { 0xFF, 0xD8, 0xFF}; > long offset, len; Hmm, I don't know how solid you want your code to be, but I wouldn't dare this. To know for sure where the JFIF (hopefully it IS JFIF) part resides in the PICT, you'd have to fully parse the PICT, scanning through all opcodes until you find the compressed pixmap part. Quite hard to do. The way to go is to use FCompressImage (like Lawrence said). I can assure you that that works. Check your code again. The one thing that might be a problem is when the user has another JPEG codec installed, or Apple changes theirs in a future release. There's no garantuee that the stream output by the codec is JFIF complaint. It will be JPEG, just maybe not always JFIF. BTW, Apple's JPEG codec is really really fast... regards, Bas Schulte +++++++++++++++++++++++++++ >From Maf Vosburgh Date: 14 Jun 1995 22:56:29 GMT Organization: MMC In article David Phillip Oster, oster@netcom.com writes: >The QuickTime volume of Inside Macintosh sample code that works for making >a PICT file that has a JPEG compressed image. > >How do you make a valid file of type JFIF? I've tried just writing the data >from QuickTime's FCompressImage into a file, but programs that know JFIF >say that that isn't a valid JFIF file. I enclose some source code that is based on example code written by Mark Krueger, who wrote the QuickTime Image Compression manager. It contains the useful proc: OSErr WriteJpegData(PicHandle pic, short fileRef); All you do is 1)Make or open a JPEG compressed PICT 2)Make a new empty file of type JPEG or JFIF. 3)Open it. 4)Call WriteJpegData 5)Close the file. Maf Vosburgh +++++++++++++++++++++++++++ >From piguet@ia.epfl.ch (Yves Piguet) Date: Fri, 23 Jun 1995 20:07:57 +0200 Organization: Institut d'automatique, EPFL In article <3rnpet$879@news.bt.net>, Maf Vosburgh wrote: >In article David Phillip Oster, >oster@netcom.com writes: >>How do you make a valid file of type JFIF? I've tried just writing the data >>from QuickTime's FCompressImage into a file, but programs that know JFIF >>say that that isn't a valid JFIF file. > >I enclose some source code that is based on example code written by >Mark Krueger, who wrote the QuickTime Image Compression manager. > >It contains the useful proc: >OSErr WriteJpegData(PicHandle pic, short fileRef); And how do you *read* a jpeg using QT? One has to create the Image Description Record, but how? Thanks in advance! Yves Piguet Institut d'automatique Tel: +41 21 693 38 34 EPFL Fax: +41 21 693 25 74 CH - 1015 Lausanne Talk, cusm: on request +++++++++++++++++++++++++++ >From dale_satterfield@powertalk.apple.com (Dale Satterfield) Date: 26 Jun 1995 15:54:43 GMT Organization: Apple Computer In article , piguet@ia.epfl.ch (Yves Piguet) wrote: > In article <3rnpet$879@news.bt.net>, Maf Vosburgh wrote: > > >In article David Phillip Oster, > >oster@netcom.com writes: > >>How do you make a valid file of type JFIF? I've tried just writing the data > >>from QuickTime's FCompressImage into a file, but programs that know JFIF > >>say that that isn't a valid JFIF file. > > I had this same problem and was able to write out the file data the QT created, and then read it back in again with JPEGView, which had no problem with it. The files were also able to be transfered to a windows machine and its jpeg viewer was able to open them. As to reading in a file, you need to create the descriptor first, by reading the JFIF header. There is sample code out on the net somewhere. I have lost my directions to it. --------------------------- End of C.S.M.P. Digest ********************** Attachment converted: Spiff:Archive.sit (SITD/SIT!) (00033BD7)