- fix pnmtofiasco to accept image from stdin (#476989, #227283)

This commit is contained in:
Jindrich Novy 2009-01-21 07:25:24 +00:00
parent 21f6f26752
commit 9a37f8cc63
2 changed files with 111 additions and 1 deletions

View File

@ -0,0 +1,105 @@
diff -up netpbm-10.35.58/converter/other/fiasco/codec/coder.c.pnmtofiasco-stdin netpbm-10.35.58/converter/other/fiasco/codec/coder.c
--- netpbm-10.35.58/converter/other/fiasco/codec/coder.c.pnmtofiasco-stdin 2009-01-19 09:23:57.000000000 +0100
+++ netpbm-10.35.58/converter/other/fiasco/codec/coder.c 2009-01-21 08:03:00.000000000 +0100
@@ -213,15 +213,14 @@ alloc_coder (char const * const *inputna
*/
{
char *filename;
- int width, w = 0, height, h = 0;
+ int width, w = 0, height, h = 0, format;
bool_t color, c = NO;
+ xelval maxval;
unsigned n;
for (n = 0; (filename = get_input_image_name (inputname, n)); n++)
{
FILE *file;
- xelval maxval;
- int format;
if (filename == NULL)
file = stdin;
else
@@ -251,6 +250,8 @@ alloc_coder (char const * const *inputna
wi->width = w;
wi->height = h;
wi->color = c;
+ wi->format = format;
+ wi->maxval = maxval;
}
/*
@@ -642,7 +643,18 @@ video_coder (char const * const *image_t
*/
future_frame = frame == future_display;
c->mt->number = frame;
- c->mt->original = read_image (image_name);
+ if (strcmp(image_name, "-")) {
+ c->mt->original = read_image (image_name);
+ } else { /* stdin is not seekable - read image contents without rewind */
+ int width = wfa->wfainfo->width;
+ int height = wfa->wfainfo->height;
+ int color = wfa->wfainfo->color;
+ int format = wfa->wfainfo->format;
+ xelval maxval = wfa->wfainfo->maxval;
+
+ c->mt->original = alloc_image(width, height, color, FORMAT_4_4_4);
+ read_image_data(c->mt->original, stdin, color, width, height, maxval, format);
+ }
if (c->tiling->exponent && type == I_FRAME)
perform_tiling (c->mt->original, c->tiling);
diff -up netpbm-10.35.58/converter/other/fiasco/codec/wfa.h.pnmtofiasco-stdin netpbm-10.35.58/converter/other/fiasco/codec/wfa.h
--- netpbm-10.35.58/converter/other/fiasco/codec/wfa.h.pnmtofiasco-stdin 2009-01-19 09:23:57.000000000 +0100
+++ netpbm-10.35.58/converter/other/fiasco/codec/wfa.h 2009-01-21 08:03:28.000000000 +0100
@@ -75,6 +75,7 @@ typedef struct range_info
unsigned level; /* bintree level of range */
} range_info_t;
+#include "pnm.h"
#include "image.h"
#include "rpf.h"
#include "bit-io.h"
@@ -93,6 +94,8 @@ typedef struct wfa_info
unsigned width; /* image width */
unsigned height; /* image height */
unsigned level; /* image level */
+ unsigned format; /* image format */
+ xelval maxval; /* image maximal pixel intensity value */
rpf_t *rpf; /* Standard reduced precision format */
rpf_t *dc_rpf; /* DC reduced precision format */
rpf_t *d_rpf; /* Delta reduced precision format */
diff -up netpbm-10.35.58/converter/other/fiasco/lib/image.c.pnmtofiasco-stdin netpbm-10.35.58/converter/other/fiasco/lib/image.c
--- netpbm-10.35.58/converter/other/fiasco/lib/image.c.pnmtofiasco-stdin 2009-01-19 09:23:57.000000000 +0100
+++ netpbm-10.35.58/converter/other/fiasco/lib/image.c 2009-01-21 08:01:53.000000000 +0100
@@ -273,7 +273,7 @@ free_image (image_t *image)
}
-static void
+void
read_image_data(image_t * const image, FILE *input, const bool_t color,
const int width, const int height, const xelval maxval,
const int format) {
diff -up netpbm-10.35.58/converter/other/fiasco/lib/image.h.pnmtofiasco-stdin netpbm-10.35.58/converter/other/fiasco/lib/image.h
--- netpbm-10.35.58/converter/other/fiasco/lib/image.h.pnmtofiasco-stdin 2009-01-19 09:23:57.000000000 +0100
+++ netpbm-10.35.58/converter/other/fiasco/lib/image.h 2009-01-21 08:02:29.000000000 +0100
@@ -17,6 +17,8 @@
#ifndef _IMAGE_H
#define _IMAGE_H
+#include "pnm.h"
+
#include <stdio.h>
#include "types.h"
#include "fiasco.h"
@@ -51,6 +53,10 @@ read_pnmheader (const char *image_name,
image_t *
read_image (const char *image_name);
void
+read_image_data(image_t * const image, FILE *input, const bool_t color,
+ const int width, const int height, const xelval maxval,
+ const int format);
+void
write_image (const char *image_name, const image_t *image);
bool_t
same_image_type (const image_t *img1, const image_t *img2);

View File

@ -1,7 +1,7 @@
Summary: A library for handling different graphics file formats Summary: A library for handling different graphics file formats
Name: netpbm Name: netpbm
Version: 10.35.58 Version: 10.35.58
Release: 1%{?dist} Release: 2%{?dist}
# See copyright_summary for details # See copyright_summary for details
License: BSD and GPLv2 and IJG and MIT and Public Domain License: BSD and GPLv2 and IJG and MIT and Public Domain
Group: System Environment/Libraries Group: System Environment/Libraries
@ -32,6 +32,7 @@ Patch19: netpbm-10.35-gcc43.patch
Patch20: netpbm-10.35-rgbtxt.patch Patch20: netpbm-10.35-rgbtxt.patch
Patch21: netpbm-10.35-pamtosvgsegfault.patch Patch21: netpbm-10.35-pamtosvgsegfault.patch
Patch22: netpbm-10.35-pnmmontagefix.patch Patch22: netpbm-10.35-pnmmontagefix.patch
Patch23: netpbm-10.35-pnmtofiasco-stdin.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: libjpeg-devel, libpng-devel, libtiff-devel, flex BuildRequires: libjpeg-devel, libpng-devel, libtiff-devel, flex
BuildRequires: libX11-devel, python, jasper-devel BuildRequires: libX11-devel, python, jasper-devel
@ -94,6 +95,7 @@ netpbm-progs. You'll also need to install the netpbm package.
%patch20 -p1 -b .rgbtxt %patch20 -p1 -b .rgbtxt
%patch21 -p1 -b .pamtosvgsegfault %patch21 -p1 -b .pamtosvgsegfault
%patch22 -p1 -b .pnmmontagefix %patch22 -p1 -b .pnmmontagefix
%patch23 -p1 -b .pnmtofiasco-stdin
##mv shhopt/shhopt.h shhopt/pbmshhopt.h ##mv shhopt/shhopt.h shhopt/pbmshhopt.h
##perl -pi -e 's|shhopt.h|pbmshhopt.h|g' `find -name "*.c" -o -name "*.h"` ./GNUmakefile ##perl -pi -e 's|shhopt.h|pbmshhopt.h|g' `find -name "*.c" -o -name "*.h"` ./GNUmakefile
@ -221,6 +223,9 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/netpbm/ %{_datadir}/netpbm/
%changelog %changelog
* Wed Jan 21 2009 Jindrich Novy <jnovy@redhat.com> 10.35.58-2
- fix pnmtofiasco to accept image from stdin (#476989, #227283)
* Mon Jan 19 2009 Jindrich Novy <jnovy@redhat.com> 10.35.58-1 * Mon Jan 19 2009 Jindrich Novy <jnovy@redhat.com> 10.35.58-1
- update to 10.35.38 - update to 10.35.38
- fixes crashes in picttoppm, pbmtomrf, mrftopbm - fixes crashes in picttoppm, pbmtomrf, mrftopbm