[med-svn] r2831 - trunk/packages/pvrg/trunk/debian/patches
malat-guest at alioth.debian.org
malat-guest at alioth.debian.org
Mon Dec 22 13:27:37 UTC 2008
Author: malat-guest
Date: 2008-12-22 13:27:37 +0000 (Mon, 22 Dec 2008)
New Revision: 2831
Added:
trunk/packages/pvrg/trunk/debian/patches/pvrg-jpeg-etb.patch
Modified:
trunk/packages/pvrg/trunk/debian/patches/series
Log:
adding patch from eli at panix.com
Added: trunk/packages/pvrg/trunk/debian/patches/pvrg-jpeg-etb.patch
===================================================================
--- trunk/packages/pvrg/trunk/debian/patches/pvrg-jpeg-etb.patch (rev 0)
+++ trunk/packages/pvrg/trunk/debian/patches/pvrg-jpeg-etb.patch 2008-12-22 13:27:37 UTC (rev 2831)
@@ -0,0 +1,499 @@
+Patch from
+http://www.panix.com/~eli/jpeg/
+Add support for PGM output.
+This web page and the etb patch to the PVRG JPEG code is by Eli the Bearded / Benjamin Elijah Griffin.
+Reproduction of code is permitted under the Creative Commons Attribution-ShareAlike License.
+
+--- jpegdir.orig/globals.h 2005-02-03 15:06:00.000000000 -0800
++++ jpegdir/globals.h 2005-02-03 13:25:56.000000000 -0800
+@@ -127,10 +127,12 @@
+ XHUFF *ACXhuff[MAXIMUM_DEVICES]; /* Transmittable huffman tables */
+ int NumberDCTables; /* Number of DC Huffman tables */
+ DHUFF *DCDhuff[MAXIMUM_DEVICES]; /* Decoder huffman tables */
+ EHUFF *DCEhuff[MAXIMUM_DEVICES]; /* Encoder huffman tables */
+ XHUFF *DCXhuff[MAXIMUM_DEVICES]; /* Transmittable huffman tables */
++char *OutBaseName; /* Base file name of output streams */
++int OutPGM; /* Put a PGM header on output streams */
+ };
+
+ FRAME {
+ int Type; /* SOF(X) where X is type (4 bits) */
+ char *ComponentFileName[MAXIMUM_COMPONENTS]; /* image component file names */
+--- jpegdir.orig/io.c 2005-02-03 15:06:00.000000000 -0800
++++ jpegdir/io.c 2005-02-03 13:44:53.000000000 -0800
+@@ -35,10 +35,11 @@
+ #ifdef SYSV
+ #include <sys/fcntl.h>
+ #include <sys/unistd.h>
+ #endif
+
++#include <errno.h>
+
+ /* Functions which are local and which are exported. */
+
+ /*PUBLIC*/
+
+@@ -61,10 +62,11 @@
+ extern void SeekEndIob();
+ extern void CloseIob();
+ extern void MakeIob();
+ extern void PrintIob();
+ extern void InstallIob();
++extern void InstallHeaderIob();
+ extern void TerminateFile();
+
+ extern void ReadLine();
+ extern void ReadPreambleLine();
+ extern void WriteLine();
+@@ -163,14 +165,16 @@
+ int type;
+ int flags;
+ int wsize;
+ {
+ BEGIN("MakeIob");
+- int index,sofs;
++ int index,sofs,hsize;
++ char header[128];
+ BUFFER **current;
+ IOBUF *temp;
+
++
+ for(index=0;index<CScan->NumberComponents;index++) /* Make IOBUF */
+ { /* For each component */
+ if (!(temp = MakeStructure(IOBUF)))
+ {
+ WHEREAMI();
+@@ -180,10 +184,11 @@
+ temp->linelastdefault=(1<<(CFrame->DataPrecision-PointTransform-1));
+ temp->type = type;
+ temp->wsize = wsize;
+ temp->hpos=0;
+ temp->vpos=0;
++ temp->hsize=0;
+ temp->width = CFrame->Width[CScan->ci[index]]; /* Set up widthxheight */
+ temp->height = CFrame->Height[CScan->ci[index]];
+ if (CScan->NumberComponents==1)
+ {
+ temp->hor = 1; /* For non-interleaved mode the freq */
+@@ -213,19 +218,28 @@
+ {
+ WHEREAMI();
+ printf("Cannot allocate Iob bufferlist.\n");
+ exit(ERROR_MEMORY);
+ }
++ if(Loud > MUTE) {
++ printf("About to open %s from io.c:MakeIob\n",
++ CFrame->ComponentFileName[CScan->ci[index]]);
++ }
+ if ((temp->file = /* Open file */
+ open(CFrame->ComponentFileName[CScan->ci[index]],
+ flags,UMASK)) < 0)
+ {
+ WHEREAMI();
+ printf("Cannot open file %s.\n",
+ CFrame->ComponentFileName[CScan->ci[index]]);
+ exit(ERROR_INIT_FILE);
+- } /* Make buffer for every line of component in MDU */
++ }
++
++ temp->hsize = snprintf(temp->header,128,
++ "P5\n%d %d\n255\n",temp->width,temp->height);
++
++ /* Make buffer for every line of component in MDU */
+ for(sofs=0,current=temp->blist;current<temp->blist+temp->num;current++)
+ {
+ *current = MakeXBuffer(CFrame->BufferSize, wsize);
+ (*current)->streamoffs = sofs;
+ (*current)->iob = temp;
+@@ -1137,8 +1151,69 @@
+ Iob->wsize; /* Reset v offset */
+ vertical++;
+ }
+ }
+
++/*BFUNC
++
++InstallHeaderIob() puts a pgm raw header on a file. Use just before closing.
+
++EFUNC*/
++
++void InstallHeaderIob()
++{
++ BEGIN("InstallHeaderIob");
++ size_t rsize,tsize,wsize,lsize;
++ char *timage;
++
++ if((Iob->hsize == 0) || (Iob->header == NULL)) {
++ return;
++ }
++ tsize = lseek(Iob->file,0,2);
++ if(tsize < 1) {
++ return;
++ }
++
++ timage = (char*) malloc(tsize);
++ if(timage == NULL) {
++ WHEREAMI();
++ printf("Malloc failure in InstallHeaderIob\n");
++ exit(1);
++ }
++
++ lsize = lseek(Iob->file,0,0); /* rewind */
++ if(lsize != 0) {
++ WHEREAMI();
++ printf("lseek failure in InstallHeaderIob\n");
++ exit(1);
++ }
++ rsize = read(Iob->file, timage, tsize);
++ if(rsize != tsize) {
++ WHEREAMI();
++ printf("Read failure in InstallHeaderIob (r %d != t %d, fd %d)\n", rsize, tsize, Iob->file);
++ perror("Error:");
++ exit(1);
++ }
++
++ lsize = lseek(Iob->file,0,0); /* rewind */
++ if(lsize != 0) {
++ WHEREAMI();
++ printf("lseek failure in InstallHeaderIob\n");
++ exit(1);
++ }
++ wsize = write(Iob->file, Iob->header, Iob->hsize);
++ if(wsize != Iob->hsize) {
++ WHEREAMI();
++ printf("Write failure in InstallHeaderIob\n");
++ exit(1);
++ }
++ wsize = write(Iob->file, timage, tsize);
++ if(wsize != tsize) {
++ WHEREAMI();
++ printf("Write failure in InstallHeaderIob\n");
++ exit(1);
++ }
++ free(timage);
++
++}
+
+ /*END*/
+--- jpegdir.orig/jpeg.1 2005-02-03 15:06:00.000000000 -0800
++++ jpegdir/jpeg.1 2005-02-03 14:55:54.000000000 -0800
+@@ -4,15 +4,15 @@
+ jpeg \- JPEG compression and decompression
+ .SH SYNOPSIS
+ .B
+ jpeg -iw ImageWidth -ih ImageHeight [-JFIF] [-q(l) Q-Factor]
+ .B
+- [-a] [-b] [-d] [-k predictortype] [-n] [-o] [-y] [-z]
++ [-a] [-b] [-d] [-k predictortype] [-n] [-O] [-y] [-z] [-g]
+ .B
+ [-p PrecisionValue] [-t pointtransform]
+ .B
+- [-r ResyncInterval] [-s StreamName]
++ [-r ResyncInterval] [-s StreamName] [-o OutBaseName]
+ .B
+ [[-ci ComponentIndex1] [-fw FrameWidth1] [-fh FrameHeight1]
+ .B
+ [-hf HorizontalFrequency1] [-vf VerticalFrequency1]
+ .B
+@@ -29,10 +29,18 @@
+ .SH DESCRIPTION
+ .I jpeg
+ is a still-image compression/decompression program that performs
+ JPEG encoding and decoding of multiple raster-scanned files.
+ .PP
++These ``raster-scanned files'' are basically PGM (portable graymap) files
++without the PGM header. A typical JPEG image is made of three of these
++files representing the Y, Cr, and Cb color channels. Usually the Y (lumience)
++channel is full size, while the two chroma channels are half width and
++half height. But no particular channel really needs to be full size, so
++.I jpeg
++will need to know the dimensions of the original image when creating jpegs.
++.PP
+ .SH OPTIONS
+ .TP
+ .B ImageWidth
+ specifies the width of the original image. This should correspond to
+ the width of the widest component and, thus, the width of the
+@@ -68,28 +76,38 @@
+ enables the Lee DCT. (Default is Chen DCT.)
+ .TP
+ .B -d
+ enables decoding. See below.
+ .TP
++.B -g
++This option will put PGM headers on output files when decoding.
++.TP
+ .B -k predictortype
+ The lossless predictor type, specified as an integer between 1-7.
+ If specified, then lossless mode is used.
+ .TP
+ .B -n
+ This option specifies that the files should not be transmitted in
+ interleaved format.
+ .TP
+-.B -o
++.B -o OutBaseName
++This will use specified string as a base name for output files when decoding.
++.TP
++.B -O
+ signals that the command interpreter will read from the standard
+ input.
+ .TP
+ .B -p
+ Specifies the precision. Normally should be between 2-16 for
+ lossless; 8 or 12 for DCT. If it is specified as a number greater
+ than 8 then the input is considered to be unsigned shorts (16 bits,
+ msb first). Not aggressively checked.
+ .TP
++.B -s JPEGStreamName
++When encoding, this will be used as the output file. When decoding, this
++will be used as the input file.
++.TP
+ .B -t pointtransform
+ Specifies the shifting (right) upon loading input and shifting (left)
+ upon writing input. Generally used by the lossless mode only. Can
+ be used by the DCT mode to add or subtract bits.
+ .TP
+@@ -194,36 +212,31 @@
+ .br
+
+ The three output files will be in
+ .B
+ image.jpg.1 image.jpg.2 image.jpg.3.
+-The images can be displayed by the
+-.I cv
+-program.
++.br
+ The images can also be converted to ppm and back through
+ the programs
+ .I cyuv2ppm
+ and
+ .I ppm2cyuv
+-Those utility programs available by anonymous ftp from
+-.I havefun.stanford.edu:pub/cv/CVv1.2.1.tar.Z.
+ .br
+ There are many more options within an internal command interpreter.
+ Please see the accompanying documentation in
+ .I doc.ps
+ for more details.
+ .PP
+-.SH FTP
+-.I jpeg
+-is available by anonymous ftp from
+-.I havefun.stanford.edu:pub/jpeg/JPEGv1.2.tar.Z.
+-.PP
+ .SH BUGS
+ Somewhat slower than many commercial implementations,
+ some bugs are probably lurking around.
+ Lossless coding and decoding are especially slow.
+-Please inform the author at achung at cs.stanford.edu if any bugs
+-are found.
++This program can produce jpeg files that other programs cannot understand.
+ .PP
+ .SH AUTHOR
+ .PP
+ Andy Hung
++.PP
++.SH SEE ALSO
++.BR ppm2cyuv (1),
++.BR cyuv2ppm (1),
++.BR pgm (5).
+--- jpegdir.orig/jpeg.c 2005-02-03 15:06:00.000000000 -0800
++++ jpegdir/jpeg.c 2005-02-03 14:35:45.000000000 -0800
+@@ -212,11 +212,17 @@
+ break;
+ #endif
+ case 'n': /* Set non-interleaved mode */
+ ScanComponentThreshold=1;
+ break;
+- case 'o': /* -o Oracle mode (input parsing)*/
++ case 'g': /* use PGM header on outfiles */
++ CImage->OutPGM = 1;
++ break;
++ case 'o': /* -o outfile */
++ CImage->OutBaseName = argv[++i];
++ break;
++ case 'O': /* -o Oracle mode (input parsing)*/
+ Oracle=1;
+ break;
+ case 'p':
+ CFrame->DataPrecision = atoi(argv[++i]);
+ if (!CFrame->Type) CFrame->Type = 1;
+@@ -1296,30 +1302,34 @@
+ {
+ if (CurrentMDU >= NumberMDU) /* If all decoded */
+ {
+ if (Notify) /* Print statistics */
+ {
+- printf("> GW:%d GH:%d R:%d\n",
++ printf("> GlobalWidth:%d GlobalHeight:%d ResyncInverval:%d\n",
+ CFrame->GlobalWidth,
+ CFrame->GlobalHeight,
+ CFrame->ResyncInterval);
+ }
+ for(i=0;i<CScan->NumberComponents;i++) /* Print Scan info */
+ {
+ if (Notify)
+ {
+- printf(">> C:%d N:%s W:%d H:%d hf:%d vf:%d\n",
++ printf(">> C:%2d N: %s W:%6d H:%6d hf:%d vf:%d\n",
+ CScan->ci[i],
+ CFrame->ComponentFileName[CScan->ci[i]],
+ CFrame->Width[CScan->ci[i]],
+ CFrame->Height[CScan->ci[i]],
+ CFrame->hf[CScan->ci[i]],
+ CFrame->vf[CScan->ci[i]]);
+ }
+ InstallIob(i);
+ FlushIob(); /* Close image files */
+ SeekEndIob();
++ if (CImage->OutPGM)
++ {
++ InstallHeaderIob();
++ }
+ CloseIob();
+ }
+ CurrentMDU=0;
+ if (ScreenAllMarker()<0) /* See if any more images*/
+ {
+@@ -1854,10 +1864,12 @@
+ CImage->NumberQuantizationMatrices = 2; /* Default # matrices is 2 */
+ CImage->QuantizationMatrices[0] = LuminanceQuantization;
+ CImage->QuantizationMatrices[1] = ChrominanceQuantization;
+ CImage->NumberACTables = 0; /* No tables defined yet */
+ CImage->NumberDCTables = 0;
++ CImage->OutBaseName = NULL;
++ CImage->OutPGM = 0;
+ }
+
+ /*BFUNC
+
+ MakeFrame() constructs a Frame Structure and puts it in the Current
+@@ -1979,26 +1991,41 @@
+
+ void MakeConsistentFileNames()
+ {
+ BEGIN("MakeConsistentFileNames");
+ int i;
++ char ext[8];
++
++ if(CImage->OutBaseName == NULL)
++ { /* No base name specified, just use stream. */
++ CImage->OutBaseName = CImage->StreamFileName;
++ }
++
++ if(CImage->OutPGM)
++ { /* PGM header request, let's set the extension. */
++ sprintf(ext,".pgm");
++ }
++ else
++ { /* empty string */
++ *ext = 0;
++ }
+
+ for(i=0;i<CScan->NumberComponents;i++)
+ {
+ if (CImage->ImageSequence) /* If in sequence, must add sequence */
+ { /* identifier */
+ CFrame->ComponentFileName[CScan->ci[i]] =
+- (char *) calloc(strlen(CImage->StreamFileName)+16,sizeof(char));
+- sprintf(CFrame->ComponentFileName[CScan->ci[i]],"%s.%d.%d",
+- CImage->StreamFileName,CImage->ImageSequence,CScan->ci[i]);
++ (char *) calloc(strlen(CImage->StreamFileName)+20,sizeof(char));
++ sprintf(CFrame->ComponentFileName[CScan->ci[i]],"%s.%d.%d%s",
++ CImage->OutBaseName,CImage->ImageSequence,CScan->ci[i], ext);
+ }
+ else if (CFrame->ComponentFileName[CScan->ci[i]] == NULL)
+ { /* Otherwise if none specified, create. */
+ CFrame->ComponentFileName[CScan->ci[i]] =
+- (char *) calloc(strlen(CImage->StreamFileName)+8,sizeof(char));
+- sprintf(CFrame->ComponentFileName[CScan->ci[i]],"%s.%d",
+- CImage->StreamFileName,CScan->ci[i]);
++ (char *) calloc(strlen(CImage->StreamFileName)+12,sizeof(char));
++ sprintf(CFrame->ComponentFileName[CScan->ci[i]],"%s.%d%s",
++ CImage->OutBaseName,CScan->ci[i], ext);
+ }
+ }
+ }
+
+ /*BFUNC
+@@ -2180,13 +2207,13 @@
+ static void Help()
+ {
+ BEGIN("Help");
+
+ printf("jpeg -iw ImageWidth -ih ImageHeight [-JFIF] [-q(l) Q-Factor]\n");
+- printf(" [-a] [-b] [-d] [-k predictortype] [-n] [-o] [-y] [-z]\n");
++ printf(" [-a] [-b] [-d] [-k predictortype] [-n] [-O] [-y] [-z] [-g]\n");
+ printf(" [-p PrecisionValue] [-t pointtransform]\n");
+- printf(" [-r ResyncInterval] [-s StreamName]\n");
++ printf(" [-r ResyncInterval] [-s StreamName] [-o OutBaseName]\n");
+ printf(" [[-ci ComponentIndex1] [-fw FrameWidth1] [-fh FrameHeight1]\n");
+ printf(" [-hf HorizontalFrequency1] [-vf VerticalFrequency1]\n");
+ printf(" ComponentFile1]\n");
+ printf(" [[-ci ComponentIndex2] [-fw FrameWidth2] [-fh FrameHeight2]\n");
+ printf(" [-hf HorizontalFrequency2] [-vf VerticalFrequency2]\n");
+@@ -2194,15 +2221,17 @@
+ printf(" ....\n\n");
+ printf("-JFIF puts a JFIF marker. Don't change component indices.\n");
+ printf("-a enables Reference DCT.\n");
+ printf("-b enables Lee DCT.\n");
+ printf("-d decoder enable.\n");
++ printf("-g put PGM headers on decode output files.\n");
+ printf("-[k predictortype] enables lossless mode.\n");
+ printf("-q specifies quantization factor; -ql specifies can be long.\n");
+ printf("-n enables non-interleaved mode.\n");
+ printf("-[t pointtransform] is the number of bits for the PT shift.\n");
+- printf("-o enables the Command Interpreter.\n");
++ printf("-o set a base name for decode output files.\n");
++ printf("-O enables the Command Interpreter.\n");
+ printf("-p specifies precision.\n");
+ printf("-y run in robust mode against errors (cannot be used with DNL).\n");
+ printf("-z uses default Huffman tables.\n");
+ }
+
+--- jpegdir.orig/marker.c 2005-02-03 15:06:00.000000000 -0800
++++ jpegdir/marker.c 2005-02-03 13:44:53.000000000 -0800
+@@ -666,11 +666,11 @@
+ }
+ else NumberMDU = -1;
+ }
+ else
+ {
+- MakeIob(IOB_BLOCK,O_WRONLY | O_CREAT | O_TRUNC,
++ MakeIob(IOB_BLOCK,O_RDWR | O_CREAT | O_TRUNC,
+ ((CFrame->DataPrecision>8)?2:1));
+ if (CFrame->GlobalHeight)
+ {
+ InstallIob(0);
+ NumberMDU = CScan->MDUWide*CScan->MDUHigh;
+--- jpegdir.orig/prototypes.h 2005-02-03 15:06:00.000000000 -0800
++++ jpegdir/prototypes.h 2005-02-03 13:44:12.000000000 -0800
+@@ -103,10 +103,11 @@
+ extern void MakeIob();
+ extern void PrintIob();
+ extern int NumberBlocksIob();
+ extern int NumberBlockMDUIob();
+ extern void InstallIob();
++extern void InstallHeaderIob();
+ extern void TerminateFile();
+
+ extern int NumberLineMDUIob();
+ extern void ReadLine();
+ extern void ReadPreambleLine();
+diff -U 5 jpegdir.orig/system.h jpegdir/system.h
+--- jpegdir.orig/system.h 2005-02-03 15:06:00.000000000 -0800
++++ jpegdir/system.h 2005-02-03 13:44:12.000000000 -0800
+@@ -66,10 +66,12 @@
+ int width; /* Width and height of image */
+ int height;
+ int file; /* File descriptor */
+ int flags; /* File mode flags */
+ int linelastdefault; /* Last line element default */
++int hsize; /* Header size */
++char header[128]; /* Header textfield */
+ BUFFER **blist; /* A list of buffers */
+ };
+
+ /* XHUFF contains all the information that needs be transmitted */
+ /* EHUFF and DHUFF are derivable from XHUFF */
Property changes on: trunk/packages/pvrg/trunk/debian/patches/pvrg-jpeg-etb.patch
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/packages/pvrg/trunk/debian/patches/series
===================================================================
--- trunk/packages/pvrg/trunk/debian/patches/series 2008-12-22 13:15:26 UTC (rev 2830)
+++ trunk/packages/pvrg/trunk/debian/patches/series 2008-12-22 13:27:37 UTC (rev 2831)
@@ -1,2 +1,3 @@
lexer.l.patch
cmakelists.txt.patch
+pvrg-jpeg-etb.patch
More information about the debian-med-commit
mailing list